import{L as $}from"./tasksController.124792c6.js";import{d as k,e as f,o as y,c as _,w as u,b as l,u as r,bL as I,cz as w,cy as b,f as v,Y as R,aB as x,ea as C,z as D}from"./index.ea15e788.js";import{a as W}from"./asyncComputed.d5cfb74d.js";import"./linters.c0ab638e.js";import{S as A}from"./scripts.3569640e.js";import{W as B}from"./workspaces.3eb1c958.js";import{R as L,_ as N}from"./RuntimeCommonSettings.1a5cfbbf.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.449020d3.js";import"./gateway.5334dd49.js";import"./popupNotifcation.b87da6c9.js";import"./polling.01693b7a.js";import"./string.f9be58bd.js";import"./record.907dac13.js";import"./workspaceStore.bdb77ad7.js";import"./url.d05e65d7.js";import"./colorHelpers.d0003e86.js";import"./BaseLayout.e7a45513.js";import"./SaveButton.00be2f9f.js";import"./UnsavedChangesHandler.328c6c59.js";import"./ExclamationCircleOutlined.5d3118bd.js";import"./uuid.66caf399.js";import"./NavbarControls.cb26ff0e.js";import"./index.ee7a7065.js";import"./CloseCircleOutlined.411285dd.js";import"./index.85e2ba9b.js";import"./editor.35acc704.js";import"./PhArrowSquareOut.vue.9d77e562.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.622d1777.js";import"./BookOutlined.63fa8786.js";import"./PhChats.vue.9a5529d0.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.e4aee598.js";import"./Logo.57ffcb9b.js";import"./ant-design.bd02d7e1.js";import"./ai.a7643ac0.js";import"./PhCheckCircle.vue.53780125.js";import"./PhCopySimple.vue.75621609.js";import"./Avatar.62c06646.js";import"./LoadingOutlined.6a703759.js";import"./Card.4bc91893.js";import"./TabPane.f9ab489b.js";import"./PhCaretRight.vue.270e58a5.js";import"./Badge.06a33f73.js";import"./PhFolder.vue.bb2d2e96.js";import"./PhPencil.vue.2fbe6402.js";import"./validations.603d7437.js";import"./toggleHighContrast.9ed2c4bf.js";import"./TasksManager.ef2965ec.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.e9684b89.js";import"./index.15481bef.js";import"./CollapsePanel.63446aa1.js";import"./index.d0640c0b.js";import"./index.4eb97923.js";import"./index.ac86c672.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},p=new Error().stack;p&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[p]="8c129350-068a-434c-ab1c-7235e93555fe",i._sentryDebugIdIdentifier="sentry-dbid-8c129350-068a-434c-ab1c-7235e93555fe")}catch{}})();const E=k({__name:"ScriptSettings",props:{script:{}},setup(i){const e=f(i.script);return(d,s)=>(y(),_(r(b),{layout:"vertical",style:{"padding-bottom":"50px"}},{default:u(()=>[l(r(w),{label:"Name",required:""},{default:u(()=>[l(r(I),{value:e.value.title,"onUpdate:value":s[0]||(s[0]=c=>e.value.title=c)},null,8,["value"])]),_:1}),l(L,{runtime:e.value},null,8,["runtime"])]),_:1}))}}),z={style:{width:"100%",display:"flex","flex-direction":"column"}},F=k({__name:"ScriptTester",props:{script:{},disabledWarning:{},tasks:{}},emits:["refetch-tasks"],setup(i,{emit:p}){const e=i,d=v(()=>{var t,o;return(o=(t=e.tasks)==null?void 0:t.map(m=>{const S=m.payload,g=JSON.stringify(S,null,2),h=g.length>80?g.slice(0,80)+"...":g,T=new Date(m.created.at).toLocaleString();return{label:`${h} - ${T}`,value:m.id}}))!=null?o:[]}),s=f(void 0),c=v(()=>s.value?null:{title:"No trigger task selected",message:"Please select the task that will trigger the script"}),a=f(!1),n=async()=>{var t;a.value=!0;try{await e.script.run((t=s.value)!=null?t:null)}finally{a.value=!1,s.value=void 0,p("refetch-tasks",e.script.id)}};return(t,o)=>(y(),R("div",z,[l(r(b),{layout:"vertical",style:{overflow:"auto"}},{default:u(()=>[l(r(w),{label:"Trigger task"},{default:u(()=>[l(r(x),{options:d.value,value:s.value,onSelect:o[0]||(o[0]=m=>s.value=m)},null,8,["options","value"])]),_:1})]),_:1}),l(P,{loading:a.value,disabled:t.disabledWarning||c.value,onClick:n,onSave:o[1]||(o[1]=m=>t.script.save())},null,8,["loading","disabled"])]))}}),Mt=k({__name:"ScriptEditor",setup(i){const p=C(),e=f(null),d=new $,s=v(()=>{var n;return(n=a.value)!=null&&n.script.hasChanges()?{title:"Unsaved changes",message:"Save the form before running the workflow"}:null}),c=async n=>{const t=await d.getStageTasks(n);e.value=t.tasks.filter(o=>o.status==="pending")},{result:a}=W(async()=>{const[n,t]=await Promise.all([B.get(),A.get(p.params.id)]);return c(t.id),D({workspace:n,script:t})});return(n,t)=>(y(),_(N,{stage:r(a).script,workspace:r(a).workspace,"stage-type":"scripts",onRefetchTasks:t[0]||(t[0]=o=>c(r(a).script.id))},{settings:u(()=>[l(E,{script:r(a).script},null,8,["script"])]),test:u(()=>[l(F,{ref:"tester",script:r(a).script,"disabled-warning":s.value,tasks:e.value,onRefetchTasks:c},null,8,["script","disabled-warning","tasks"])]),_:1},8,["stage","workspace"]))}});export{Mt as default};
//# sourceMappingURL=ScriptEditor.30f27d22.js.map
