import{L as $}from"./tasksController.687d0fb0.js";import{d as k,e as f,o as y,c as b,w as u,b as l,u as r,bL as I,cz as _,cy as w,f as v,Y as R,aB as x,ea as C,z as D}from"./index.57388330.js";import{a as W}from"./asyncComputed.dea6d978.js";import"./linters.8b6dede8.js";import{S as A}from"./scripts.f92c2c63.js";import{W as B}from"./workspaces.cb43da8b.js";import{R as L,_ as N}from"./RuntimeCommonSettings.11a2ad2b.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.9a145b51.js";import"./gateway.e592f357.js";import"./popupNotifcation.cc3d27fb.js";import"./polling.99eba4a7.js";import"./string.b6e197ca.js";import"./record.82dac5d0.js";import"./workspaceStore.3e3a3ada.js";import"./url.40a6ac51.js";import"./colorHelpers.ae02acb9.js";import"./BaseLayout.e38326c9.js";import"./SaveButton.1c6ed979.js";import"./UnsavedChangesHandler.d43d61c4.js";import"./ExclamationCircleOutlined.d7c94db5.js";import"./uuid.da10c21a.js";import"./NavbarControls.8cc798e7.js";import"./index.1b2729a9.js";import"./CloseCircleOutlined.6c637870.js";import"./index.8cff4063.js";import"./editor.dd140b16.js";import"./PhArrowSquareOut.vue.b966bb7c.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.834b9f8a.js";import"./BookOutlined.7b183253.js";import"./PhChats.vue.b199fd70.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.de9c8f8c.js";import"./Logo.0a698e5e.js";import"./ant-design.156ae155.js";import"./ai.32ff1556.js";import"./PhCheckCircle.vue.8ab57fc6.js";import"./PhCopySimple.vue.349e2c66.js";import"./Avatar.d0198d03.js";import"./LoadingOutlined.da044905.js";import"./Card.93499b89.js";import"./TabPane.84cd23d9.js";import"./PhCaretRight.vue.85f08d73.js";import"./Badge.b4017a04.js";import"./PhFolder.vue.bcdc96c1.js";import"./PhPencil.vue.945173fd.js";import"./validations.1233d4b0.js";import"./toggleHighContrast.c7dfffe2.js";import"./TasksManager.c1add2a3.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.32f0c42d.js";import"./index.130055b9.js";import"./CollapsePanel.6ec92af1.js";import"./index.57e7f713.js";import"./index.7459f9fa.js";import"./index.85b4d3b9.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]="fcc3b614-1350-4cca-8cd9-214134bb8a67",i._sentryDebugIdIdentifier="sentry-dbid-fcc3b614-1350-4cca-8cd9-214134bb8a67")}catch{}})();const E=k({__name:"ScriptSettings",props:{script:{}},setup(i){const e=f(i.script);return(d,s)=>(y(),b(r(w),{layout:"vertical",style:{"padding-bottom":"50px"}},{default:u(()=>[l(r(_),{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(w),{layout:"vertical",style:{overflow:"auto"}},{default:u(()=>[l(r(_),{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(),b(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.e14256cb.js.map
