var c=Object.defineProperty;var d=(s,t,e)=>t in s?c(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var o=(s,t,e)=>(d(s,typeof t!="symbol"?t+"":t,e),e);import{A as p}from"./record.f45db9bc.js";import"./vue-router.c536fc2b.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[t]="edb82352-9c9c-4643-8d40-39b0c51296c8",s._sentryDebugIdIdentifier="sentry-dbid-edb82352-9c9c-4643-8d40-39b0c51296c8")}catch{}})();class h{async list(){return await(await fetch("/_editor/api/scripts")).json()}async create(t,e,r){return await(await fetch("/_editor/api/scripts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t,file:e,position:r})})).json()}async get(t){return await(await fetch(`/_editor/api/scripts/${t}`)).json()}async update(t,e){return await(await fetch(`/_editor/api/scripts/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()}async delete(t,e){const r=e?"?remove_file=true":"",a=`/_editor/api/scripts/${t}`+r;await fetch(a,{method:"DELETE",headers:{"Content-Type":"application/json"}})}async run(t,e){return(await fetch(`/_editor/api/scripts/${t}/run`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({stage_run_id:e})})).ok}async test(t){return(await fetch(`/_editor/api/scripts/${t}/test`,{method:"POST",headers:{"Content-Type":"application/json"}})).ok}}const n=new h;class i{constructor(t){o(this,"record");this.record=p.create(n,t)}static async list(){return(await n.list()).map(e=>new i(e))}static async create(t,e,r){const a=await n.create(t,e,r);return new i(a)}static async get(t){const e=await n.get(t);return new i(e)}async delete(t){await n.delete(this.id,t)}async duplicate(){return this}async save(t){const e=this.codeContent;await this.record.save(t),this.record.updateInitialState("code_content",e)}onUpdate(t){this.record.pubsub.subscribe("update",t)}hasChanges(t){return this.record.hasChanges(t)}getInitialState(t){return this.record.getInitialState(t)}updateInitialState(t,e){this.record.updateInitialState(t,e)}get id(){return this.record.get("id")}get codeContent(){return this.record.get("code_content")}set codeContent(t){this.record.set("code_content",t)}get title(){return this.record.get("title")}set title(t){this.record.set("title",t)}get type(){return"script"}get file(){return this.record.get("file")}set file(t){this.record.set("file",t)}get path(){return this.record.get("path")}set path(t){this.record.set("path",t)}async test(){return n.test(this.id)}async run(t){return n.run(this.id,t)}get position(){const[t,e]=this.record.get("workflow_position");return{x:t,y:e,referential:"world"}}get isInitial(){return!1}static from(t){return new i(t)}}export{i as S};
//# sourceMappingURL=scripts.5d91db12.js.map
