import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import{X as t,ct as n,et as r,rt as i}from"./vendor-primevue-7po8Zk9v.js";import{$ as a,Bt as o,D as s,E as c,Et as l,F as u,Ft as d,L as f,O as p,P as m,X as h,ht as g,k as _,o as v,v as y}from"./vendor-vue-core-D3IvUUeM.js";import"./vendor-other-CrvBxfcV.js";import"./types-0oh-UGWL.js";import"./api-3C7_IVZO.js";import"./colorUtil-C83P1Arv.js";import"./i18n-DjEVEIh2.js";import"./vendor-reka-ui-Bm3o_ZTf.js";import{t as b}from"./Button-mG8zDgxj.js";import{t as x}from"./userStore-C0ilqLSS.js";import{t as S}from"./BaseViewTemplate-BY8GIa0B.js";var C={id:`comfy-user-selection`,class:`relative min-w-84 rounded-lg bg-(--comfy-menu-bg) p-5 px-10 shadow-lg`},w={class:`flex w-full flex-col items-center`},T={class:`flex w-full flex-col gap-2`},E={for:`new-user-input`},D={class:`flex w-full flex-col gap-2`},O={for:`existing-user-select`},k={class:`mt-5`},A=f({__name:`UserSelectView`,setup(e){let f=x(),A=v(),j=l(null),M=l(``),N=l(``),P=c(()=>M.value.trim()!==``),F=c(()=>f.users.find(e=>e.username===M.value)?`User "${M.value}" already exists`:``),I=c(()=>F.value||N.value),login=async()=>{try{let e=P.value?await f.createUser(M.value):j.value;if(!e)throw Error(`No user selected`);await f.login(e),await A.push(`/`)}catch(e){N.value=e instanceof Error?e.message:JSON.stringify(e)}};return h(async()=>{f.initialized||await f.initialize()}),(e,c)=>(a(),p(S,{dark:``},{default:g(()=>[s(`main`,C,[c[2]||=s(`h1`,{class:`my-2.5 mb-7 font-normal`},`ComfyUI`,-1),s(`div`,w,[s(`div`,T,[s(`label`,E,o(e.$t(`userSelect.newUser`))+`:`,1),u(d(i),{id:`new-user-input`,modelValue:M.value,"onUpdate:modelValue":c[0]||=e=>M.value=e,placeholder:e.$t(`userSelect.enterUsername`),onKeyup:y(login,[`enter`])},null,8,[`modelValue`,`placeholder`])]),u(d(t)),s(`div`,D,[s(`label`,O,o(e.$t(`userSelect.existingUser`))+`:`,1),u(d(r),{modelValue:j.value,"onUpdate:modelValue":c[1]||=e=>j.value=e,class:`w-full`,"input-id":`existing-user-select`,options:d(f).users,"option-label":`username`,placeholder:e.$t(`userSelect.selectUser`),disabled:P.value},null,8,[`modelValue`,`options`,`placeholder`,`disabled`]),I.value?(a(),p(d(n),{key:0,severity:`error`},{default:g(()=>[m(o(I.value),1)]),_:1})):_(``,!0)]),s(`footer`,k,[u(b,{onClick:login},{default:g(()=>[m(o(e.$t(`userSelect.next`)),1)]),_:1})])])])]),_:1}))}});export{A as default};
//# sourceMappingURL=UserSelectView-BwA3YGCG.js.map