var $=Object.defineProperty;var b=(n,s)=>$(n,"name",{value:s,configurable:!0});import{bq as x,r as u,o as k,n as S,c as V,d as h,l as C,e as t,x as E,br as a,f as N,u as B,E as m,p as y,q as _,A as i,t as p,J as T,s as R,h as z}from"./vendor-other-yzRpIrj2.js";import{f as M,r as j,j as q,a as A,s as D}from"./vendor-primevue-RJTR6wkG.js";import{k as I}from"./vendor-vue-ByIfjd1d.js";import{a7 as J,bk as K,cb as O,bp as P}from"./index-xLwXl4ov.js";import"./vendor-xterm-CWYFmgbN.js";import"./vendor-three-b7sMVVQK.js";import"./vendor-tiptap-DcddbIvp.js";const W={class:"flex w-full grow items-center justify-center overflow-auto"},F=x({__name:"BaseViewTemplate",props:{dark:{type:Boolean,default:!1}},setup(n){const s={color:"rgba(0, 0, 0, 0)",symbolColor:"#d4d4d4"},c={color:"rgba(0, 0, 0, 0)",symbolColor:"#171717"},r=u(null);return k(async()=>{J()&&(await S(),K().changeTheme({...n.dark?s:c,height:r.value?.getBoundingClientRect().height??0}))}),(l,d)=>(h(),V("div",{class:B(["flex h-svh w-screen flex-col font-sans",[l.dark?"dark-theme bg-neutral-900 text-neutral-300":"bg-neutral-300 text-neutral-900"]])},[C(t("div",{ref_key:"topMenuRef",ref:r,class:"app-drag h-(--comfy-topbar-height) w-full"},null,512),[[E,a(O)()]]),t("div",W,[N(l.$slots,"default")])],2))}}),G={id:"comfy-user-selection",class:"relative min-w-84 rounded-lg bg-(--comfy-menu-bg) p-5 px-10 shadow-lg"},H={class:"flex w-full flex-col items-center"},L={class:"flex w-full flex-col gap-2"},Q={for:"new-user-input"},X={class:"flex w-full flex-col gap-2"},Y={for:"existing-user-select"},Z={class:"mt-5"},ie=x({__name:"UserSelectView",setup(n){const s=P(),c=I(),r=u(null),l=u(""),d=u(""),w=m(()=>l.value.trim()!==""),U=m(()=>s.users.find(e=>e.username===l.value)?`User "${l.value}" already exists`:""),v=m(()=>U.value||d.value),g=b(async()=>{try{const e=w.value?await s.createUser(l.value):r.value;if(!e)throw new Error("No user selected");await s.login(e),await c.push("/")}catch(e){d.value=e instanceof Error?e.message:JSON.stringify(e)}},"login");return k(async()=>{s.initialized||await s.initialize()}),(e,o)=>(h(),y(F,{dark:""},{default:_(()=>[t("main",G,[o[2]||(o[2]=t("h1",{class:"my-2.5 mb-7 font-normal"},"ComfyUI",-1)),t("div",H,[t("div",L,[t("label",Q,p(e.$t("userSelect.newUser"))+":",1),i(a(M),{id:"new-user-input",modelValue:l.value,"onUpdate:modelValue":o[0]||(o[0]=f=>l.value=f),placeholder:e.$t("userSelect.enterUsername"),onKeyup:T(g,["enter"])},null,8,["modelValue","placeholder"])]),i(a(j)),t("div",X,[t("label",Y,p(e.$t("userSelect.existingUser"))+":",1),i(a(q),{modelValue:r.value,"onUpdate:modelValue":o[1]||(o[1]=f=>r.value=f),class:"w-full","input-id":"existing-user-select",options:a(s).users,"option-label":"username",placeholder:e.$t("userSelect.selectUser"),disabled:w.value},null,8,["modelValue","options","placeholder","disabled"]),v.value?(h(),y(a(A),{key:0,severity:"error"},{default:_(()=>[z(p(v.value),1)]),_:1})):R("",!0)]),t("footer",Z,[i(a(D),{label:e.$t("userSelect.next"),onClick:g},null,8,["label"])])])])]),_:1}))}});export{ie as default};
//# sourceMappingURL=UserSelectView-DAdP_EPE.js.map
