import{f as N,a as y,i as k,a5 as S,a3 as I,n as L}from"./app-JmgyQoR0.js";import{F as z}from"./split-mI9ZWkMh.js";import{b as j,a as d,e as G,D as U,h as a,i as H,j as u,K as m,E as f,z as p,u as c,l as o,t as n,F as A,G as B,x as C,H as E}from"./vue-y3KLWBaS.js";const K={class:"tbhwbxda"},O={class:"form"},T={key:0,class:"users"},W=["onClick"],X={class:"body"},q={key:1,class:"empty"},J={key:1,class:"recent"},P={class:"users"},Q=["onClick"],R={class:"body"},Y=j({__name:"MkUserSelectDialog",emits:["ok","cancel","closed"],setup(Z,{emit:F}){const M=F;let r=d(""),i=d(""),v=d([]),V=d([]),l=d(null),_=d();const $=()=>{if(r.value===""&&i.value===""){v.value=[];return}N("users/search-by-username-and-host",{username:r.value,host:i.value,limit:10,detail:!1}).then(t=>{v.value=t})},b=()=>{if(l.value==null)return;M("ok",l.value),_.value.close();let t=y.state.recentlyUsedUsers;t=t.filter(s=>s!==l.value.id),t.unshift(l.value.id),y.set("recentlyUsedUsers",t.splice(0,16))},g=()=>{M("cancel"),_.value.close()};return G(()=>{N("users/show",{userIds:y.state.recentlyUsedUsers}).then(t=>{V.value=t})}),(t,s)=>{const w=U("MkAvatar"),x=U("MkUserName"),D=U("MkAcct");return a(),H(I,{ref_key:"dialogEl",ref:_,"with-ok-button":!0,"ok-button-disabled":l.value==null,onClick:s[4]||(s[4]=e=>g()),onClose:s[5]||(s[5]=e=>g()),onOk:s[6]||(s[6]=e=>b()),onClosed:s[7]||(s[7]=e=>t.$emit("closed"))},{header:u(()=>[m(f(p(k).ts.selectUser),1)]),default:u(()=>[c("div",K,[c("div",O,[o(z,{"min-width":170},{default:u(()=>[o(S,{modelValue:r.value,"onUpdate:modelValue":[s[0]||(s[0]=e=>r.value=e),$],autofocus:!0},{label:u(()=>[m(f(p(k).ts.username),1)]),prefix:u(()=>[m("@")]),_:1},8,["modelValue"]),o(S,{modelValue:i.value,"onUpdate:modelValue":[s[1]||(s[1]=e=>i.value=e),$]},{label:u(()=>[m(f(p(k).ts.host),1)]),prefix:u(()=>[m("@")]),_:1},8,["modelValue"])]),_:1})]),r.value!=""||i.value!=""?(a(),n("div",{key:0,class:C(["result",{hit:v.value.length>0}])},[v.value.length>0?(a(),n("div",T,[(a(!0),n(A,null,B(v.value,e=>(a(),n("div",{key:e.id,class:C(["user",{selected:l.value&&l.value.id===e.id}]),onClick:h=>l.value=e,onDblclick:s[2]||(s[2]=h=>b())},[o(w,{user:e,class:"avatar","show-indicator":!0,disableLink:""},null,8,["user"]),c("div",X,[o(x,{user:e,class:"name"},null,8,["user"]),o(D,{user:e,class:"acct"},null,8,["user"])])],42,W))),128))])):(a(),n("div",q,[c("span",null,f(p(k).ts.noUsers),1)]))],2)):E("",!0),r.value==""&&i.value==""?(a(),n("div",J,[c("div",P,[(a(!0),n(A,null,B(V.value,e=>(a(),n("div",{key:e.id,class:C(["user",{selected:l.value&&l.value.id===e.id}]),onClick:h=>l.value=e,onDblclick:s[3]||(s[3]=h=>b())},[o(w,{user:e,class:"avatar","show-indicator":!0,disableLink:""},null,8,["user"]),c("div",R,[o(x,{user:e,class:"name"},null,8,["user"]),o(D,{user:e,class:"acct"},null,8,["user"])])],42,Q))),128))])])):E("",!0)])]),_:1},8,["ok-button-disabled"])}}}),te=L(Y,[["__scopeId","data-v-f12313f0"]]);export{te as default};
