import{z as t}from"./index.cf4c23b9.js";import{f as r,h as d,j as l,g as c,o as p,q as y}from"./icons.c5a369ef.js";import"./outputWidgets.3c3deba7.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="49d17d37-dc31-4463-af7e-6224d4d1b990",a._sentryDebugIdIdentifier="sentry-dbid-49d17d37-dc31-4463-af7e-6224d4d1b990")}catch{}})();const n={stages:[{icon:r,typeName:"forms",description:"Wait for a user input",key:"F",title:"Forms",startingOnly:!1,transitions:[{typeName:"forms:finished",title:"Finished",additionalPayload:[]},{typeName:"forms:failed",title:"Failed",additionalPayload:[]}]},{typeName:"hooks",title:"Hooks",startingOnly:!1,icon:d,description:"Wait for an external API call",key:"H",transitions:[{typeName:"hooks:finished",title:"Finished",additionalPayload:[]},{typeName:"hooks:failed",title:"Failed",additionalPayload:[]}]},{typeName:"jobs",title:"Jobs",startingOnly:!0,icon:l,description:"Scheduled tasks",key:"J",transitions:[{typeName:"jobs:finished",title:"Finished",additionalPayload:[]},{typeName:"jobs:failed",title:"Failed",additionalPayload:[]}]},{typeName:"scripts",title:"Scripts",startingOnly:!1,icon:c,description:"Run a script",key:"S",transitions:[{typeName:"scripts:finished",title:"Finished",additionalPayload:[]},{typeName:"scripts:failed",title:"Failed",additionalPayload:[]}]},{typeName:"conditions",title:"Conditions",startingOnly:!1,icon:p,description:"Make a decision",key:"C",transitions:[{typeName:"conditions:patternMatched",title:"Pattern Matched",additionalPayload:[]},{typeName:"conditions:patternNotMatched",title:"Pattern Not Matched",additionalPayload:[]}]},{typeName:"iterators",title:"Iterators",startingOnly:!1,icon:y,description:"Split thread for each element in a list",key:"I",transitions:[{typeName:"iterators:each",title:"Each",additionalPayload:[{key:"item",type:"typing.Any",title:"Item"}]}]}]};function N(a){const e=n.stages.find(i=>i.typeName===a||i.typeName===`${a}s`);if(!e)throw new Error(`No metadata found for stage ${a}`);return e.icon}const f=n.stages.flatMap(a=>a.transitions.flatMap(e=>e.typeName)),m=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()})}),h=t.object({id:t.string(),type:t.enum(f),sourceStageId:t.string(),targetStageId:t.string(),props:t.object({conditionValue:t.string().nullable()})}),o=t.object({stages:t.array(m),transitions:t.array(h)}),g={"Content-Type":"application/json"},k="abstra-run-id";class I{async load(){const e=await fetch("/_editor/api/workflows");if(e.ok){const i=await e.json();return o.parse(i)}else throw new Error("Failed to fetch initial data")}async update(e){const i=await fetch("/_editor/api/workflows",{method:"PUT",headers:g,body:JSON.stringify(e)});if(i.ok){const s=await i.json();return o.parse(s)}else throw new Error("Failed to update workflow")}}export{k as A,I as W,N as s,n as w};
//# sourceMappingURL=api.046dfddf.js.map
