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