import{N as k}from"./Navbar.54518871.js";import{B as I}from"./BaseLayout.e134b491.js";import{C as N}from"./ContentLayout.b1f8b3b4.js";import{C as _}from"./CrudView.4ab5ff38.js";import{a as O}from"./asyncComputed.728c1605.js";import{F as x}from"./PhArrowSquareOut.vue.faa414ef.js";import{G as M}from"./PhPencil.vue.af42f7c8.js";import{d as R,e4 as h,r as B,c as D,a4 as F,f as o,b as i,u as s,aQ as V,o as g,a as $,cw as j,bI as A,cv as E,h as G,M as L}from"./jwt-decode.esm.4aed0432.js";import"./router.8e8ef823.js";import{a as m}from"./organization.2a3edd07.js";import"./tables.1494ceeb.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.52134169.js";import"./constants.6bea9d72.js";import"./PhChats.vue.f167b275.js";import"./PhSignOut.vue.79b6b9ad.js";import"./index.58d4cba0.js";import"./index.46be4ae3.js";import"./omniChatStore.11a1fa20.js";import"./record.c1a2f873.js";import"./PhSparkle.vue.009dbde3.js";import"./index.2f3003a8.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.b5a50b94.js";import"./url.b192466e.js";import"./PhDotsThreeVertical.vue.ee67ed4a.js";import"./string.8136e838.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[l]="9f83180c-0dc3-411c-9286-5ceb35d06964",r._sentryDebugIdIdentifier="sentry-dbid-9f83180c-0dc3-411c-9286-5ceb35d06964")}catch{}})();const dt=R({__name:"Organizations",setup(r){const l=[{label:"My organizations",path:"/organizations"}],u=[{key:"name",label:"Organization Name"}],f=h(),{loading:y,result:b,refetch:v}=O(()=>m.list()),c=({key:e})=>{f.push({name:"organization",params:{organizationId:e}})},n=B({state:"idle"});function z(e){n.value={state:"renaming",organizationId:e.id,newName:e.name}}async function d(e){if(n.value.state==="renaming"&&e){const{organizationId:t,newName:a}=n.value;await m.rename(t,a),v()}n.value={state:"idle"}}const w=async e=>{const t=await m.create(e.name);c({key:t.id})},C=D(()=>{var e,t;return{columns:[{title:"Organization Name",align:"left"},{title:"Path"},{title:"",align:"right"}],rows:(t=(e=b.value)==null?void 0:e.map(a=>{var p;return{key:a.id,cells:[{type:"link",text:a.name,to:`/organizations/${encodeURIComponent(a.id)}`},{type:"text",text:(p=a.id)!=null?p:null},{type:"actions",actions:[{icon:x,label:"Go to projects",onClick:c},{icon:M,label:"Rename",onClick:()=>z(a)}]}]}}))!=null?t:[]}});return(e,t)=>(g(),F(V,null,[o(I,null,{navbar:i(()=>[o(k,{breadcrumb:l})]),content:i(()=>[o(N,null,{default:i(()=>[o(_,{"entity-name":"organization",loading:s(y),title:"My organizations",description:"An organization is your company\u2019s account. Manage editors, projects and billing.","create-button-text":"Create Organization","empty-title":"No organizations here yet",table:C.value,fields:u,create:w},null,8,["loading","table"])]),_:1})]),_:1}),o(s(L),{open:n.value.state==="renaming",title:"Rename organization",onCancel:t[1]||(t[1]=a=>d(!1)),onOk:t[2]||(t[2]=a=>d(!0))},{default:i(()=>[n.value.state==="renaming"?(g(),$(s(E),{key:0,layout:"vertical"},{default:i(()=>[o(s(j),{label:"New name"},{default:i(()=>[o(s(A),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):G("",!0)]),_:1},8,["open"])],64))}});export{dt as default};
//# sourceMappingURL=Organizations.ab291e0e.js.map
