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.49183eff.js";import"./outputWidgets.37f6afb9.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="18089062-52f2-40a4-8a75-8ffb7d625981",e._sentryDebugIdIdentifier="sentry-dbid-18089062-52f2-40a4-8a75-8ffb7d625981")}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(e){const a=n.stages.find(i=>i.typeName===e||i.typeName===`${e}s`);if(!a)throw new Error(`No metadata found for stage ${e}`);return a.icon}const f=n.stages.flatMap(e=>e.transitions.flatMap(a=>a.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 a=await fetch("/_editor/api/workflows");if(a.ok){const i=await a.json();return o.parse(i)}else throw new Error("Failed to fetch initial data")}async update(a){const i=await fetch("/_editor/api/workflows",{method:"PUT",headers:g,body:JSON.stringify(a)});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.e3099b68.js.map
