import"./rolldown-runtime-DIIn1E2Q.js";import{W as e,nt as t,rt as n,st as r}from"./vendor-primevue-_eYbXsHY.js";import{A as i,D as a,F as o,I as s,O as c,R as l,Rt as u,Ut as d,Z as f,_t as p,et as m,k as h,kt as g,o as _,y as v}from"./vendor-vue-core-DO0afONr.js";import"./vendor-other-D7fTIduy.js";import"./api-BebQfoGK.js";import"./vendor-markdown-Da9QPS2x.js";import"./colorUtil-xHrUTSza.js";import"./i18n-dAUEhQVe.js";import"./vendor-reka-ui-D1HCh14_.js";import{t as y}from"./Button-hTbieW3T.js";import{t as b}from"./userStore-DMlTsx5E.js";import{t as x}from"./BaseViewTemplate-DBZUwRdb.js";var S={id:`comfy-user-selection`,class:`relative min-w-84 rounded-lg bg-(--comfy-menu-bg) p-5 px-10 shadow-lg`},C={class:`flex w-full flex-col items-center`},w={class:`flex w-full flex-col gap-2`},T={for:`new-user-input`},E={class:`flex w-full flex-col gap-2`},D={for:`existing-user-select`},O={class:`mt-5`},k=l({__name:`UserSelectView`,setup(l){let k=b(),A=_(),j=g(null),M=g(``),N=g(``),P=a(()=>M.value.trim()!==``),F=a(()=>k.users.find(e=>e.username===M.value)?`User "${M.value}" already exists`:``),I=a(()=>F.value||N.value),login=async()=>{try{let e=P.value?await k.createUser(M.value):j.value;if(!e)throw Error(`No user selected`);await k.login(e),await A.push(`/`)}catch(e){N.value=e instanceof Error?e.message:JSON.stringify(e)}};return f(async()=>{document.getElementById(`splash-loader`)?.remove(),k.initialized||await k.initialize()}),(a,l)=>(m(),h(x,{dark:``},{default:p(()=>[c(`main`,S,[l[2]||=c(`h1`,{class:`my-2.5 mb-7 font-normal`},`ComfyUI`,-1),c(`div`,C,[c(`div`,w,[c(`label`,T,d(a.$t(`userSelect.newUser`))+`:`,1),s(u(n),{id:`new-user-input`,modelValue:M.value,"onUpdate:modelValue":l[0]||=e=>M.value=e,placeholder:a.$t(`userSelect.enterUsername`),onKeyup:v(login,[`enter`])},null,8,[`modelValue`,`placeholder`])]),s(u(e)),c(`div`,E,[c(`label`,D,d(a.$t(`userSelect.existingUser`))+`:`,1),s(u(t),{modelValue:j.value,"onUpdate:modelValue":l[1]||=e=>j.value=e,class:`w-full`,"input-id":`existing-user-select`,options:u(k).users,"option-label":`username`,placeholder:a.$t(`userSelect.selectUser`),disabled:P.value},null,8,[`modelValue`,`options`,`placeholder`,`disabled`]),I.value?(m(),h(u(r),{key:0,severity:`error`},{default:p(()=>[o(d(I.value),1)]),_:1})):i(``,!0)]),c(`footer`,O,[s(y,{onClick:login},{default:p(()=>[o(d(a.$t(`userSelect.next`)),1)]),_:1})])])])]),_:1}))}});export{k as default};
//# sourceMappingURL=UserSelectView-D__VowVM.js.map