import{N as k}from"./Navbar.f8099d8d.js";import{B as N}from"./BaseLayout.97a37605.js";import{C as I}from"./ContentLayout.c509f1dd.js";import{C as _}from"./CrudView.fa86e359.js";import{a as O}from"./asyncComputed.c1514d75.js";import{F as x}from"./PhArrowSquareOut.vue.761d1db3.js";import{G as R}from"./PhPencil.vue.22f5fd0d.js";import{d as B,e3 as F,f as M,g as h,K as D,b as o,w as i,u as s,aL as E,o as g,c as L,cs as V,bE as $,cr as j,F as A,cE as G}from"./index.fd66f361.js";import"./gateway.c8676992.js";import{a as m}from"./organization.21be1843.js";import"./columns.a93ffaa0.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.fe7e55b8.js";import"./PhChats.vue.569b8d96.js";import"./PhSignOut.vue.99f479e8.js";import"./router.26c95d47.js";import"./index.13458abe.js";import"./Avatar.02092cfa.js";import"./omniChatStore.4b72ae26.js";import"./record.8d6523fc.js";import"./PhSparkle.vue.8254c822.js";import"./index.92873ed6.js";import"./index.f35aec9d.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.3a6d45c1.js";import"./url.32de1d47.js";import"./PhDotsThreeVertical.vue.cd7ec533.js";import"./Badge.7cfeacae.js";import"./index.fe7b9d7b.js";import"./popupNotifcation.45eb3465.js";import"./string.973cdadd.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]="041a3e92-600e-4583-b382-e020a46aabb8",r._sentryDebugIdIdentifier="sentry-dbid-041a3e92-600e-4583-b382-e020a46aabb8")}catch{}})();const bt=B({__name:"Organizations",setup(r){const l=[{label:"My organizations",path:"/organizations"}],u=[{key:"name",label:"Organization Name"}],f=F(),{loading:b,result:y,refetch:v}=O(()=>m.list()),p=({key:e})=>{f.push({name:"organization",params:{organizationId:e}})},n=M({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);p({key:t.id})},C=h(()=>{var e,t;return{columns:[{title:"Organization Name",align:"left"},{title:"Path"},{title:"",align:"right"}],rows:(t=(e=y.value)==null?void 0:e.map(a=>{var c;return{key:a.id,cells:[{type:"link",text:a.name,to:`/organizations/${encodeURIComponent(a.id)}`},{type:"text",text:(c=a.id)!=null?c:null},{type:"actions",actions:[{icon:x,label:"Go to projects",onClick:p},{icon:R,label:"Rename",onClick:()=>z(a)}]}]}}))!=null?t:[]}});return(e,t)=>(g(),D(E,null,[o(N,null,{navbar:i(()=>[o(k,{breadcrumb:l})]),content:i(()=>[o(I,null,{default:i(()=>[o(_,{"entity-name":"organization",loading:s(b),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(G),{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(),L(s(j),{key:0,layout:"vertical"},{default:i(()=>[o(s(V),{label:"New name"},{default:i(()=>[o(s($),{value:n.value.newName,"onUpdate:value":t[0]||(t[0]=a=>n.value.newName=a)},null,8,["value"])]),_:1})]),_:1})):A("",!0)]),_:1},8,["open"])],64))}});export{bt as default};
//# sourceMappingURL=Organizations.b8e14294.js.map
