"use strict";(self.webpackChunkdami=self.webpackChunkdami||[]).push([[4950],{4950:(e,o,t)=>{t.r(o),t.d(o,{default:()=>f});var r=t(93150),a=t.n(r),n=t(31263),s=t(82070),i=t(77881),l=t(68821);function w(e,o){return Array.isArray(e)?e.find((({id:e})=>e===o)):e[o]}const f=async function({id:e,data:o}){if(""===o.workflowId)throw new Error("empty-workflow");const{workflows:t,teamWorkflows:r}=await a().storage.local.get(["workflows","teamWorkflows"]);let f=null;if(o.workflowId.startsWith("team")){f=w(Object.values(Object.values(r||{})[0]??{}),o.workflowId)}else f=w(t,o.workflowId);if(!f){const e=new Error("no-workflow");throw e.data={workflowId:o.workflowId},e}f=(0,i.Z)(f);const d={variables:{}};if((0,n.cb)(o.globalData)||(d.globalData=o.globalData),o.insertAllVars)d.variables=JSON.parse(JSON.stringify(this.engine.referenceData.variables));else if(o.insertVars){o.insertVars.split(",").forEach((e=>{const o=e.trim(),t=this.engine.referenceData.variables[o];(t||"boolean"==typeof t)&&(d.variables[o]=t)}))}const c={options:{data:d,parentWorkflow:{id:this.engine.id,name:this.engine.workflow.name}},events:{onInit:e=>{this.childWorkflowId=e.id},onDestroyed:e=>{if(o.executeId){const{variables:t,table:r}=e.referenceData;this.engine.referenceData.workflow[o.executeId]={table:r,variables:t}}}},states:this.engine.states,logger:this.engine.logger,blocksHandler:this.engine.blocksHandler};if(f.drawflow.nodes.some((e=>"execute-workflow"===e.label&&e.data.workflowId===this.engine.workflow.id)))throw new Error("workflow-infinite-loop");const k=await function(e,o){return new Promise(((t,r)=>{if(e.isProtected&&!(0,n.Rx)(e.drawflow,null)){const o=(0,s.c)(e.pass);e.drawflow=(0,s.Z)(e,o)}const a=new l.Z(e,o);a.init(),a.on("destroyed",(({id:e,status:n,message:s})=>{if(o.events.onDestroyed(a),"error"===n){const o=new Error(s);return o.data={logId:e},void r(o)}t({id:e,status:n,message:s})})),o.events.onInit(a)}))}(f,c);return{data:"",logId:k.id,nextBlockId:this.getBlockConnections(e)}}}}]);