import{d as h,K as f,b as y,t as H,z as r,H as _}from"./registerWidgets.7452ec0b.js";import{f as C,g as b,h as g}from"./icons.97625e56.js";import{a as w}from"./asyncComputed.23d75013.js";import{H as c}from"./hooks.911e43af.js";import{R as x}from"./RuntimeList.9384f45c.js";import"./utils.95f0e9e8.js";import"./pubsub.a0411919.js";import"./DropdownMenu.e6caac19.js";import"./CircularLoading.6725993e.js";const $=h({__name:"Hooks",setup(R){const l=_(),{loading:p,result:a,refetch:s}=w(()=>c.list()),i=({key:e})=>l.push({path:`/_editor/hook/${encodeURIComponent(e)}`}),u=async({key:e})=>{var o,t;await((t=(o=a.value)==null?void 0:o.find(n=>n.path===e))==null?void 0:t.duplicate()),s()},m=async()=>{const e=await c.create();i({key:e.path})},d=async({key:e})=>{var o,t;confirm("Are you sure you want to delete this hook?")&&(await((t=(o=a.value)==null?void 0:o.find(n=>n.path===e))==null?void 0:t.delete()),s())},k=f(()=>{var e,o;return{columns:[{name:"Hook Name"},{name:"Path"},{name:"Hook Actions"}],rows:(o=(e=a.value)==null?void 0:e.map(t=>({key:t.path,cells:[{text:t.title,classes:["title","centered"],link:`/_editor/hook/${encodeURIComponent(t.path)}`},{text:t.path},{text:"",classes:["centered"],actions:[{icon:C,label:"Delete",onClick:d,dangerous:!0},{icon:b,label:"Edit Hook",onClick:i},{icon:g,label:"Duplicate",onClick:u}]}]})))!=null?o:[]}});return(e,o)=>(y(),H(x,{loading:r(p),title:"Python Hooks",description:"Trigger your Python scripts with a request.","create-button-text":"Create Hook","empty-title":"No hooks here yet",table:r(k),onCreate:m},null,8,["loading","table"]))}});export{$ as default};
//# sourceMappingURL=Hooks.d9bd4a73.js.map
