import{L as $}from"./tasksController.316b9f67.js";import{d as k,e as f,o as y,c as b,w as u,b as p,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.3bb16a7d.js";import{a as W}from"./asyncComputed.cf9b9270.js";import"./linters.02dd0e79.js";import{S as A}from"./scripts.3db57a43.js";import{W as B}from"./workspaces.d7ea87a4.js";import{_ as L,a as N}from"./RunButton.vue_vue_type_script_setup_true_lang.41b71a31.js";import{R as P}from"./SmartChat.4399c862.js";import"./gateway.b9669ee9.js";import"./popupNotifcation.a637fa65.js";import"./polling.e50afa20.js";import"./string.2eb4b01a.js";import"./record.2250875e.js";import"./workspaceStore.c875d00a.js";import"./url.a49f314c.js";import"./colorHelpers.0fdbd497.js";import"./BaseLayout.d3e7c403.js";import"./SaveButton.d566e6d5.js";import"./UnsavedChangesHandler.50a445b7.js";import"./ExclamationCircleOutlined.b6d84f94.js";import"./NavbarControls.3d1380cd.js";import"./index.d713b8dc.js";import"./CloseCircleOutlined.42685e65.js";import"./index.2827b1cb.js";import"./editor.1d77872f.js";import"./PhArrowSquareOut.vue.672280f4.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.81487614.js";import"./BookOutlined.435ccdd9.js";import"./PhChats.vue.e0a644a5.js";import"./TasksManager.784129bb.js";import"./ant-design.480d4716.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.bc7a6d54.js";import"./index.28fc5d7c.js";import"./Card.53cce487.js";import"./TabPane.60e57812.js";import"./CollapsePanel.5d18248f.js";import"./index.885bc03a.js";import"./index.76cb4b41.js";import"./index.0ee6c454.js";import"./Avatar.30b974d7.js";import"./validations.e6b9d1af.js";import"./uuid.6e2419a7.js";import"./PhCaretRight.vue.c4d6780e.js";import"./Badge.a2ade0a9.js";import"./LoadingOutlined.24477ae4.js";import"./PhFolder.vue.4c9406ad.js";import"./PhPencil.vue.88a66847.js";import"./toggleHighContrast.3ea05c88.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.879e19ee.js";import"./Logo.913dce72.js";import"./PhGear.vue.5f842e23.js";import"./ai.102c6818.js";import"./PhCheckCircle.vue.77a91df0.js";import"./PhCopySimple.vue.cc21e885.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]="226b767c-df8a-49d8-8217-bc2e63ef5bf8",i._sentryDebugIdIdentifier="sentry-dbid-226b767c-df8a-49d8-8217-bc2e63ef5bf8")}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(()=>[p(r(_),{label:"Name",required:""},{default:u(()=>[p(r(I),{value:e.value.title,"onUpdate:value":s[0]||(s[0]=m=>e.value.title=m)},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,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,l("refetch-tasks",e.script.id)}};return(t,a)=>(y(),R("div",z,[p(r(w),{layout:"vertical",style:{overflow:"auto"}},{default:u(()=>[p(r(_),{label:"Trigger task"},{default:u(()=>[p(r(x),{options:d.value,value:s.value,onSelect:a[0]||(a[0]=c=>s.value=c)},null,8,["options","value"])]),_:1})]),_:1}),p(L,{loading:o.value,disabled:t.disabledWarning||m.value,onClick:n,onSave:a[1]||(a[1]=c=>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=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(l.params.id)]);return m(t.id),D({workspace:n,script:t})});return(n,t)=>(y(),b(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(()=>[p(E,{script:r(o).script},null,8,["script"])]),test:u(()=>[p(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{Ot as default};
//# sourceMappingURL=ScriptEditor.3b87fec4.js.map
