import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{Ir as n,Nn as r,Xn as i,Xr as a}from"./vendor-primevue-D50rA9nL.js";import{n as o,r as s}from"./vendor-vue-BAQ5VIVR.js";import{i as c,r as l}from"./api-z_dXWY_S.js";var u,d=t((()=>{s(),r(),c(),u=o(`user`,()=>{let e=a(null),t=a(null),r=i(()=>e.value&&`users`in e.value),o=i(()=>!t.value&&r.value),s=i(()=>Object.entries(e.value?.users??{}).map(([e,t])=>({userId:e,username:t}))),c=i(()=>s.value.find(e=>e.userId===t.value)??null),u=i(()=>e.value!==null);async function initialize(){e.value=await l.getUserConfig(),t.value=localStorage[`Comfy.userId`]}async function createUser(e){let t=await l.createUser(e),n=await t.json();if(t.status>=300)throw Error(n.error??`Error creating user: `+t.status+` `+t.statusText);return{userId:n,username:e}}async function login({userId:e,username:n}){t.value=e,localStorage[`Comfy.userId`]=e,localStorage[`Comfy.userName`]=n}n(()=>{r.value&&t.value&&(l.user=t.value)});async function logout(){delete localStorage[`Comfy.userId`],delete localStorage[`Comfy.userName`]}return{users:s,currentUser:c,isMultiUserServer:r,needsLogin:o,initialized:u,initialize,createUser,login,logout}})}));export{u as n,d as t};
//# sourceMappingURL=userStore-D0IyjTYG.js.map