import{N as k}from"./Navbar-xNoiYIje.js";import{B as C}from"./BaseLayout-CAFdFQyK.js";import{C as N}from"./ContentLayout-SexkWDKT.js";import{C as O}from"./CrudView-wZnp03a2.js";import{a as I}from"./asyncComputed-IJY6wgme.js";import{F as _}from"./PhArrowSquareOut.vue-ztkY6P_e.js";import{G as x}from"./PhPencil.vue-DCNvh_hA.js";import{d as B,T as R,r as D,e as F,l as M,m as c,g as n,G as o,D as l,B as h,p as j,aj as G,ak as V,al as $,O as A,F as E}from"./jwt-decode.esm-Dca5fHH5.js";import"./router-D5wfdag3.js";import{O as m}from"./organization-DepCCxnV.js";import"./tables-BsqTY_wE.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang-D-iosY4j.js";import"./constants-B1LrRAnj.js";import"./PhChats.vue-D3T3i4Kd.js";import"./PhSignOut.vue-XpGBgo63.js";import"./index-ZQBk4l6i.js";import"./index-BLK1I0IS.js";import"./omniChatStore-Bi-5MYwj.js";import"./record-BZIfMWML.js";import"./uuid-CK8Ke_G7.js";import"./PhCopySimple.vue-C9uB_c9T.js";import"./PhBookBookmark.vue-DvO8S191.js";import"./PhSparkle.vue-Yp2ok4fJ.js";import"./index-CXHcOjiL.js";import"./DocsButton.vue_vue_type_script_setup_true_lang-BnwqPwfA.js";import"./url-CoyBb3Dp.js";import"./PhDotsThreeVertical.vue-B1x6I4wD.js";import"./index-Cyx2lZTa.js";import"./string-BYR4BIXr.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[s]="24e33ac4-2d44-4c5d-89ee-b0e4de180bb7",i._sentryDebugIdIdentifier="sentry-dbid-24e33ac4-2d44-4c5d-89ee-b0e4de180bb7")}catch{}})();const fe=B({__name:"Organizations",setup(i){const s=[{label:"My organizations",path:"/organizations"}],p=[{key:"name",label:"Organization Name"}],g=R(),{loading:f,result:y,refetch:b}=I(()=>m.list()),u=({key:e})=>{g.push({name:"organization",params:{organizationId:e}})},a=D({state:"idle"});function v(e){a.value={state:"renaming",organizationId:e.id,newName:e.name}}async function d(e){if(a.value.state==="renaming"&&e){const{organizationId:t,newName:r}=a.value;await m.rename(t,r),b()}a.value={state:"idle"}}const z=async e=>{const t=await m.create(e.name);u({key:t.id})},w=F(()=>({columns:[{title:"Organization Name",align:"left"},{title:"Path"},{title:"",align:"right"}],rows:y.value?.map(e=>({key:e.id,cells:[{type:"link",text:e.name,to:`/organizations/${encodeURIComponent(e.id)}`},{type:"text",text:e.id??null},{type:"actions",actions:[{icon:_,label:"Go to projects",onClick:u},{icon:x,label:"Rename",onClick:()=>v(e)}]}]}))??[]}));return(e,t)=>(c(),M(E,null,[n(C,null,{navbar:o(()=>[n(k,{breadcrumb:s})]),content:o(()=>[n(N,null,{default:o(()=>[n(O,{"entity-name":"organization",loading:l(f),title:"My organizations",description:"An organization is your company’s account. Manage editors, projects and billing.","create-button-text":"Create Organization","empty-title":"No organizations here yet",table:w.value,fields:p,create:z},null,8,["loading","table"])]),_:1})]),_:1}),n(l(A),{open:a.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=r=>d(!1)),onOk:t[2]||(t[2]=r=>d(!0))},{default:o(()=>[a.value.state==="renaming"?(c(),h(l(G),{key:0,layout:"vertical"},{default:o(()=>[n(l(V),{label:"New name"},{default:o(()=>[n(l($),{value:a.value.newName,"onUpdate:value":t[0]||(t[0]=r=>a.value.newName=r)},null,8,["value"])]),_:1})]),_:1})):j("",!0)]),_:1},8,["open"])],64))}});export{fe as default};
//# sourceMappingURL=Organizations-goc1WR0U.js.map
