import{d as v,b as c,r}from"./jwt-decode.esm-rEBc1yJt.js";import{r as I}from"./router-BaFu-do7.js";import{i as w,M as y}from"./member-qsE1qwIO.js";import{P as j}from"./project-D1d7g0j_.js";import"./tables-DdYqLMX_.js";import{u as z}from"./organizationSwitcher-DLmZV2E5.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]="5dc0fcfb-962a-4632-8c8e-eba6f4ee365d",n._sentryDebugIdIdentifier="sentry-dbid-5dc0fcfb-962a-4632-8c8e-eba6f4ee365d")}catch{}})();const F=v("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(p=>p.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 b(){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:b}});export{F as u};
//# sourceMappingURL=projectStore-CqACsnK8.js.map
