import{d as b,b as c,r}from"./jwt-decode.esm-CZajAnkk.js";import{r as I}from"./router-C8CCuUKN.js";import{i as w,M as y}from"./member-D3C_DPKf.js";import{a as j}from"./project-DTFW8XGL.js";import"./tables-BosOXgsx.js";import{u as z}from"./organizationSwitcher-C5dAiDRY.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="89137ade-f908-48df-83a0-04cf3806f488",n._sentryDebugIdIdentifier="sentry-dbid-89137ade-f908-48df-83a0-04cf3806f488")}catch{}})();const P=b("project",()=>{const n=c(()=>I.currentRoute.value.params.projectId),a=r(null),t=r(null),i=r(null),l=r(!1),d=r(null),f=new y,g=c(()=>w(i.value));async function m(s){if(!(a.value?.id===s&&t.value)){l.value=!0,d.value=null;try{const e=await j.get(s);a.value={id:e.id,folderId:e.folderId,name:e.name,subdomain:e.subdomain,organizationId:e.organizationId};const u=z();u.organizations.length===0&&await u.fetchOrganizations();const o=u.organizations.find(v=>v.id===e.organizationId);o&&(t.value={id:o.id,name:o.name,featureFlags:o.featureFlags,billingMetadata:o.billingMetadata}),i.value=await f.me(e.organizationId).catch(()=>null)}catch(e){throw d.value=e instanceof Error?e.message:"Failed to load project",console.error("Failed to load project:",e),e}finally{l.value=!1}}}function p(){a.value=null,t.value=null,i.value=null,l.value=!1,d.value=null}return{projectId:n,project:a,organization:t,currentMember:i,isAdmin:g,loading:l,error:d,get organizationId(){return t.value?.id},get billingMetadata(){return t.value?.billingMetadata},loadProject:m,resetStore:p}});export{P as u};
//# sourceMappingURL=projectStore-DZ-D9Wa_.js.map
