import{d,r as l,af as g,l as f}from"./jwt-decode.esm-BYfS37aG.js";import{r as u}from"./router-D53qV9Zg.js";import{O as c}from"./organization-BI2IWMw4.js";import"./tables-nYEEmE6H.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="b83a0400-aac4-44c3-a135-390cfe32c46a",a._sentryDebugIdIdentifier="sentry-dbid-b83a0400-aac4-44c3-a135-390cfe32c46a")}catch{}})();const S=d("organizationSwitcher",()=>{const a=l([]),t=l(!1),o=async()=>{t.value=!0;try{const e=await c.list();a.value=e.sort((r,n)=>r.name.localeCompare(n.name))}finally{t.value=!1}};return{organizations:a,loading:t,fetchOrganizations:o,renameOrganization:async(e,r)=>{const n=a.value.find(s=>s.id===e);if(!n)return!1;const i=n.name;n.name=r;try{return await c.rename(e,r),!0}catch(s){return n.name=i,g.error(f.translate("i18n_breadcrumb_rename_error")),console.error("Failed to rename organization",s),!1}},selectDefaultOrganization:async()=>{if(await o(),a.value.length===0)return{name:"onboarding"};const e=localStorage.getItem("lastSelectedOrganizationId"),r=e?a.value.find(i=>i.id===e):null;return r?{name:"organization",params:{organizationId:r.id}}:(e&&localStorage.removeItem("lastSelectedOrganizationId"),{name:"organization",params:{organizationId:a.value[0].id}})},selectOrganization:e=>{localStorage.setItem("lastSelectedOrganizationId",e),u.push({name:"organization",params:{organizationId:e}})}}});export{S as u};
//# sourceMappingURL=organizationSwitcher-DapMvF_6.js.map
