import{a7 as $,b as k,a5 as D,d as B,_ as M}from"./app-QjDgb7aF.js";import{b as N,j as a,g as S,i as p,q as l,k as U,I as b,u as t,J as g,D as r,p as d,x as y,F as w,G as x,H as E,a as c}from"./vue-Cm77DuTi.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const F={class:"mehkoush"},L={class:"form"},O={key:0,class:"instances"},j=["onClick"],q={class:"body"},z=["src"],G={class:"name"},H={key:1,class:"empty"},J=N({__name:"MkInstanceSelectDialog",emits:["ok","cancel","closed"],setup(R,{emit:C}){const v=C;let o=c(""),i=c([]),n=c(null),u=c(),f=0;const I=()=>{if(o.value===""){i.value=[];return}const m=++f;B("federation/instances",{host:o.value,limit:10,blocked:!1,suspended:!1,sort:"+pubSub"}).then(s=>{m===f&&(i.value=s.map(e=>({id:e.id,host:e.host,iconUrl:e.iconUrl})))})},_=()=>{n.value!=null&&(v("ok",n.value),u.value?.close())},h=()=>{v("cancel"),u.value?.close()};return(m,s)=>(a(),S(D,{ref_key:"dialogEl",ref:u,"with-ok-button":!0,"ok-button-disabled":t(n)==null,onClick:s[2]||(s[2]=e=>h()),onClose:s[3]||(s[3]=e=>h()),onOk:s[4]||(s[4]=e=>_()),onClosed:s[5]||(s[5]=e=>m.$emit("closed"))},{header:p(()=>[g(r(t(k).ts.selectInstance),1)]),default:p(()=>[l("div",F,[l("div",L,[U($,{modelValue:t(o),"onUpdate:modelValue":[s[0]||(s[0]=e=>b(o)?o.value=e:o=e),I],autofocus:!0},{label:p(()=>[g(r(t(k).ts.instance),1)]),_:1},8,["modelValue"])]),t(o)!=""?(a(),d("div",{key:0,class:y(["result",{hit:t(i).length>0}])},[t(i).length>0?(a(),d("div",O,[(a(!0),d(w,null,x(t(i),e=>(a(),d("div",{key:e.id,class:y(["instance",{selected:t(n)&&t(n).id===e.id}]),onClick:V=>b(n)?n.value=e:n=e,onDblclick:s[1]||(s[1]=V=>_())},[l("div",q,[l("img",{class:"icon",src:e.iconUrl??"/client-assets/dummy.png","aria-hidden":"true"},null,8,z),l("span",G,r(e.host),1)])],42,j))),128))])):(a(),d("div",H,[l("span",null,r(t(k).ts.noInstances),1)]))],2)):E("",!0)])]),_:1},8,["ok-button-disabled"]))}}),K=M(J,[["__scopeId","data-v-52a9129b"]]);export{K as default};
//# sourceMappingURL=MkInstanceSelectDialog-BTwZliaC.js.map
