import{L as $}from"./tasksController.98768fc1.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.fa78dbc3.js";import{a as W}from"./asyncComputed.12aeb11c.js";import"./linters.21252bcf.js";import{S as A}from"./scripts.13e9cfed.js";import{W as B}from"./workspaces.c91a032b.js";import{_ as L,a as N}from"./RunButton.vue_vue_type_script_setup_true_lang.7888bfa3.js";import{R as P}from"./SmartChat.87ac0bd7.js";import"./gateway.ae4a1089.js";import"./popupNotifcation.42d265d2.js";import"./polling.3a62e36e.js";import"./string.2d4a8451.js";import"./record.0f0973ec.js";import"./workspaceStore.cbdc12fe.js";import"./url.d89d37ba.js";import"./colorHelpers.5d7d9b37.js";import"./BaseLayout.f8d7b422.js";import"./SaveButton.6361bec1.js";import"./UnsavedChangesHandler.d8fd1ffe.js";import"./ExclamationCircleOutlined.8a931d04.js";import"./NavbarControls.00845f9b.js";import"./index.112a2a7d.js";import"./CloseCircleOutlined.b5fd7418.js";import"./index.b024e6f5.js";import"./editor.1d515037.js";import"./PhArrowSquareOut.vue.d11cd4a5.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.16ee81e0.js";import"./BookOutlined.86c7be2a.js";import"./PhChats.vue.25969e6d.js";import"./TasksManager.31be7dc5.js";import"./ant-design.a6589efa.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.cfc22152.js";import"./index.590dad1a.js";import"./Card.6aad870a.js";import"./TabPane.c63c9eca.js";import"./CollapsePanel.6b4c9500.js";import"./index.82dfab4c.js";import"./index.4fe9a3e8.js";import"./index.57308903.js";import"./Avatar.fd49a83f.js";import"./validations.552f9427.js";import"./uuid.66b11928.js";import"./PhCaretRight.vue.072b332c.js";import"./Badge.fb885d78.js";import"./LoadingOutlined.1bea686d.js";import"./PhFolder.vue.4e9d0c4f.js";import"./PhPencil.vue.620d3c62.js";import"./toggleHighContrast.48440b99.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.3c4de684.js";import"./Logo.8926268e.js";import"./PhGear.vue.7776d222.js";import"./ai.e119c913.js";import"./PhCheckCircle.vue.6d5d2143.js";import"./PhCopySimple.vue.be02f6f2.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]="e33057c5-ba8a-4f57-9325-2b96afc2db6c",i._sentryDebugIdIdentifier="sentry-dbid-e33057c5-ba8a-4f57-9325-2b96afc2db6c")}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]=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(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: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(),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(()=>[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.b5f9fed2.js.map
