import{d as y,K as _,b as g,t as T,z as d,H as w}from"./registerWidgets.89616af0.js";import{f as C,g as h,h as k}from"./icons.9cfdae6d.js";import{a as D}from"./asyncComputed.8ac91a75.js";import{T as u}from"./tables.b83ad23f.js";import{R as I}from"./RuntimeList.097a29c4.js";import"./activeRecord.3d3c7835.js";import"./pubsub.d7600aa1.js";import"./DropdownMenu.8f7fc9d3.js";import"./CircularLoading.0fb686c0.js";import"./lottie.fc57e5ac.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="fdf502ce-e938-413d-a6b1-512989dd9f5c",n._sentryDebugIdIdentifier="sentry-dbid-fdf502ce-e938-413d-a6b1-512989dd9f5c")}catch{}})();const H=y({__name:"Tables",setup(n){const o=w(),{loading:r,result:l,refetch:i}=D(()=>u.list()),c=({key:e})=>o.push({path:`/_editor/table/${encodeURIComponent(e)}`}),m=async({key:e})=>{var t,a;await((a=(t=l.value)==null?void 0:t.find(s=>s.name===e))==null?void 0:a.duplicate()),i()},b=async()=>{const e=await u.create();c({key:e.name})},p=async({key:e})=>{var t,a;confirm("Are you sure you want to delete this table?")&&(await((a=(t=l.value)==null?void 0:t.find(s=>s.name===e))==null?void 0:a.delete()),i())},f=_(()=>{var e,t;return{columns:[{name:"Table Name"},{name:"Table Actions"}],rows:(t=(e=l.value)==null?void 0:e.map(a=>({key:a.name,cells:[{text:a.name,classes:["title","centered"],link:`/_editor/table/${encodeURIComponent(a.name)}`},{text:"",classes:["centered"],actions:[{icon:C,label:"Delete",onClick:p,dangerous:!0},{icon:h,label:"Edit Table",onClick:c},{icon:k,label:"Duplicate",onClick:m}]}]})))!=null?t:[]}});return(e,t)=>(g(),T(I,{loading:d(r),title:"Database Tables",description:"Create and manage your database tables here.","create-button-text":"Create Table","empty-title":"No tables here yet",table:d(f),onCreate:b},null,8,["loading","table"]))}});export{H as default};
//# sourceMappingURL=Tables.e6b943f2.js.map
