import{L as $}from"./tasksController.9fed01d7.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.0396e68e.js";import{a as W}from"./asyncComputed.fdf54570.js";import"./linters.13eb7d79.js";import{S as A}from"./scripts.79d2de54.js";import{W as B}from"./workspaces.c2ddaf04.js";import{R as L,_ as N}from"./RuntimeCommonSettings.5d7a2003.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.dc762825.js";import"./gateway.157f1e61.js";import"./popupNotifcation.17433f53.js";import"./polling.14117eb9.js";import"./string.dc823a05.js";import"./record.0e62b813.js";import"./workspaceStore.63e90c7b.js";import"./url.892c62bd.js";import"./colorHelpers.1afbbca5.js";import"./BaseLayout.ad0c8bf8.js";import"./SaveButton.56eabbc2.js";import"./UnsavedChangesHandler.c9eb6f61.js";import"./ExclamationCircleOutlined.9f5a0e68.js";import"./uuid.1da3d59d.js";import"./NavbarControls.25b3e9ea.js";import"./index.ece7867e.js";import"./CloseCircleOutlined.a33f847d.js";import"./index.445b73ea.js";import"./editor.a6792a5c.js";import"./PhArrowSquareOut.vue.2efa5be9.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.0ad17905.js";import"./BookOutlined.9a743874.js";import"./PhChats.vue.15ccd145.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.224ac585.js";import"./Logo.008d40fa.js";import"./ant-design.8b815b73.js";import"./ai.199f23bb.js";import"./PhCheckCircle.vue.33a74901.js";import"./PhCopySimple.vue.14df4423.js";import"./Avatar.546066ac.js";import"./LoadingOutlined.56cdefbf.js";import"./Card.5d980ebc.js";import"./TabPane.b5e1cdd3.js";import"./PhCaretRight.vue.e51ab724.js";import"./Badge.1e7f212f.js";import"./PhFolder.vue.871b0c3d.js";import"./PhPencil.vue.be504ce9.js";import"./validations.39b5a813.js";import"./toggleHighContrast.7e6f41d2.js";import"./TasksManager.dc2ab47b.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.57c491e0.js";import"./index.dbfdf067.js";import"./CollapsePanel.facbfb38.js";import"./index.f5043392.js";import"./index.c870c5ca.js";import"./index.f55d3423.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]="cd063760-0325-4e9a-9ff8-6dd31e19f07d",i._sentryDebugIdIdentifier="sentry-dbid-cd063760-0325-4e9a-9ff8-6dd31e19f07d")}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]=m=>e.value.title=m)},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,a;return(a=(t=e.tasks)==null?void 0:t.map(c=>{const S=c.payload,g=JSON.stringify(S,null,2),h=g.length>80?g.slice(0,80)+"...":g,T=new Date(c.created.at).toLocaleString();return{label:`${h} - ${T}`,value:c.id}}))!=null?a:[]}),s=f(void 0),m=v(()=>s.value?null:{title:"No trigger task selected",message:"Please select the task that will trigger the script"}),o=f(!1),n=async()=>{var t;o.value=!0;try{await e.script.run((t=s.value)!=null?t:null)}finally{o.value=!1,s.value=void 0,p("refetch-tasks",e.script.id)}};return(t,a)=>(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:a[0]||(a[0]=c=>s.value=c)},null,8,["options","value"])]),_:1})]),_:1}),l(P,{loading:o.value,disabled:t.disabledWarning||m.value,onClick:n,onSave:a[1]||(a[1]=c=>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=o.value)!=null&&n.script.hasChanges()?{title:"Unsaved changes",message:"Save the form before running the workflow"}:null}),m=async n=>{const t=await d.getStageTasks(n);e.value=t.tasks.filter(a=>a.status==="pending")},{result:o}=W(async()=>{const[n,t]=await Promise.all([B.get(),A.get(p.params.id)]);return m(t.id),D({workspace:n,script:t})});return(n,t)=>(y(),_(N,{stage:r(o).script,workspace:r(o).workspace,"stage-type":"scripts",onRefetchTasks:t[0]||(t[0]=a=>m(r(o).script.id))},{settings:u(()=>[l(E,{script:r(o).script},null,8,["script"])]),test:u(()=>[l(F,{ref:"tester",script:r(o).script,"disabled-warning":s.value,tasks:e.value,onRefetchTasks:m},null,8,["script","disabled-warning","tasks"])]),_:1},8,["stage","workspace"]))}});export{Mt as default};
//# sourceMappingURL=ScriptEditor.94f02539.js.map
