var l=Object.defineProperty;var y=(s,t,e)=>t in s?l(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var n=(s,t,e)=>(y(s,typeof t!="symbol"?t+"":t,e),e);import{A as w}from"./activeRecord.57c6bf02.js";class g{async list(){return await(await fetch("/_editor/api/hooks")).json()}async create(){return await(await fetch("/_editor/api/hooks",{method:"POST",headers:{"Content-Type":"application/json"}})).json()}async get(t){return await(await fetch(`/_editor/api/hooks/${t}`)).json()}async update(t,e){return await(await fetch(`/_editor/api/hooks/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()}async delete(t){await fetch(`/_editor/api/hooks/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})}async test(t,e){const o=new URLSearchParams(e.query),i=await fetch(`/_editor/api/hooks/${t}/test?${o.toString()}`,{method:e.method,headers:{"Content-Type":"application/json",...e.headers},body:e.method==="GET"?void 0:e.body}),{status:c,headers:d,body:h,stderr:p,stdout:u}=await i.json();return{status:c,headers:d,body:h,stderr:p,stdout:u}}}const a=new g;class r{constructor(t){n(this,"record");this.record=new w(a,t,"path")}static async list(){return(await a.list()).map(e=>new r(e))}static async create(){const t=await a.create();return new r(t)}static async get(t){const e=await a.get(t);return new r(e)}async delete(){await a.delete(this.path)}async duplicate(){return this}disable(){return a.update(this.path,{enabled:!1})}enable(){return a.update(this.path,{enabled:!0})}async save(){await this.record.save(),console.log("save ",this.path)}onUpdate(t){this.record.pubsub.subscribe("update",t)}hasChanges(){return this.record.hasChanges()}get path(){return this.record.get("path")}set path(t){this.record.set("path",t)}get title(){return this.record.get("title")}get enabled(){return this.record.get("enabled")}get file(){return this.record.get("file")}set file(t){this.record.set("file",t)}async test(t){return a.test(this.path,t)}get routeName(){return"hooks"}}export{r as H};
//# sourceMappingURL=hooks.d59fb935.js.map
