import{L as $}from"./tasksController.bbd2773f.js";import{d as k,e as f,o as y,c as _,w as u,b as p,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.0050062d.js";import{a as W}from"./asyncComputed.5a9dc807.js";import"./linters.d48779d0.js";import{S as A}from"./scripts.c68ba376.js";import{W as B}from"./workspaces.f53d3f29.js";import{_ as L,a as N}from"./RunButton.vue_vue_type_script_setup_true_lang.7fb0ea2b.js";import{R as P}from"./SmartChat.a57df402.js";import"./gateway.60411ad8.js";import"./popupNotifcation.675f1b12.js";import"./polling.56c8a3d2.js";import"./string.867fe8ae.js";import"./record.ed103436.js";import"./workspaceStore.ccb2ec4f.js";import"./url.3865bbae.js";import"./colorHelpers.16cd7470.js";import"./BaseLayout.5acc7524.js";import"./SaveButton.420f9186.js";import"./UnsavedChangesHandler.83b1e50a.js";import"./ExclamationCircleOutlined.b19d6975.js";import"./NavbarControls.077fcf71.js";import"./index.58609537.js";import"./CloseCircleOutlined.db339935.js";import"./index.b19a5315.js";import"./editor.ed9504c0.js";import"./PhArrowSquareOut.vue.40487513.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.60f08b82.js";import"./BookOutlined.9a32f29a.js";import"./PhChats.vue.e92f94b2.js";import"./TasksManager.ec09dd2e.js";import"./ant-design.2b9c7b39.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.e67738fa.js";import"./index.dddfec09.js";import"./Card.1b95b8d2.js";import"./TabPane.dcdf721d.js";import"./CollapsePanel.da1aa02b.js";import"./index.bb2e54f0.js";import"./index.826cf710.js";import"./index.75f15071.js";import"./Avatar.6cdc5c6b.js";import"./validations.94273538.js";import"./uuid.f2bb5314.js";import"./PhCaretRight.vue.4e5605d6.js";import"./Badge.3d214d5b.js";import"./LoadingOutlined.de047d23.js";import"./PhFolder.vue.fde7f665.js";import"./PhPencil.vue.80955bf1.js";import"./toggleHighContrast.12d7e729.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.d93ccbf9.js";import"./Logo.22e82baf.js";import"./PhGear.vue.54fec5d2.js";import"./ai.86206df9.js";import"./PhCheckCircle.vue.1f3c2140.js";import"./PhCopySimple.vue.4cef7229.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[l]="085bac31-1a2e-4dd0-a818-ca50c700d862",i._sentryDebugIdIdentifier="sentry-dbid-085bac31-1a2e-4dd0-a818-ca50c700d862")}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(()=>[p(r(w),{label:"Name",required:""},{default:u(()=>[p(r(I),{value:e.value.title,"onUpdate:value":s[0]||(s[0]=c=>e.value.title=c)},null,8,["value"])]),_:1}),p(P,{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:l}){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,l("refetch-tasks",e.script.id)}};return(t,o)=>(y(),R("div",z,[p(r(b),{layout:"vertical",style:{overflow:"auto"}},{default:u(()=>[p(r(w),{label:"Trigger task"},{default:u(()=>[p(r(x),{options:d.value,value:s.value,onSelect:o[0]||(o[0]=m=>s.value=m)},null,8,["options","value"])]),_:1})]),_:1}),p(L,{loading:a.value,disabled:t.disabledWarning||c.value,onClick:n,onSave:o[1]||(o[1]=m=>t.script.save())},null,8,["loading","disabled"])]))}}),Ot=k({__name:"ScriptEditor",setup(i){const l=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(l.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(()=>[p(E,{script:r(a).script},null,8,["script"])]),test:u(()=>[p(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{Ot as default};
//# sourceMappingURL=ScriptEditor.5fbeb02d.js.map
