import{l as n}from"./fetch.a2434bd0.js";import{z as t}from"./outputWidgets.161060e0.js";import{w as i}from"./metadata.7b60aad0.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[e]="bfea4682-61ae-49c0-b174-e9f7745f58b1",o._sentryDebugIdIdentifier="sentry-dbid-bfea4682-61ae-49c0-b174-e9f7745f58b1")}catch{}})();const l=i.stages.flatMap(o=>o.transitions.flatMap(e=>e.typeName)),c=t.object({type:t.enum(["forms","hooks","jobs","scripts","conditions","iterators"]),id:t.string(),title:t.string(),position:t.object({x:t.number(),y:t.number()}),props:t.object({path:t.string().nullable(),filename:t.string().nullable(),variableName:t.string().nullable(),itemName:t.string().nullable()})}),d=t.object({id:t.string(),type:t.enum(l),sourceStageId:t.string(),targetStageId:t.string(),props:t.object({conditionValue:t.string().nullable()})}),s=t.object({stages:t.array(c),transitions:t.array(d)}),f={"Content-Type":"application/json"},h="abstra-run-id";class b{async load(){const e=await fetch("/_editor/api/workflows");if(e.ok){const a=await e.json();return s.parse(a)}else throw new Error("Failed to fetch initial data")}async update(e){const a=await fetch("/_editor/api/workflows",{method:"PUT",headers:f,body:JSON.stringify(e)});if(a.ok){const r=await a.json();return s.parse(r)}else throw new Error("Failed to update workflow")}}class y{constructor(e,a=n){this.authProvider=e,this.fetch=a}get headers(){return{"Content-Type":"application/json",...this.authProvider.authHeaders()}}async load(){const e=await this.fetch("/_workflows",{headers:this.headers});if(e.ok){const a=await e.json();return s.parse(a)}else throw new Error("Failed to fetch initial data")}async update(e){const a=await this.fetch("/_workflows",{body:JSON.stringify(e),headers:this.headers,method:"PUT"});if(a.ok){const r=await a.json();return s.parse(r)}else throw new Error("Failed to update workflow")}}export{h as A,b as E,y as P};
//# sourceMappingURL=api.d87a733a.js.map
