import{L as $}from"./tasksController.9d537405.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.5572dd7e.js";import{a as W}from"./asyncComputed.ec375dc7.js";import"./linters.5d4f4193.js";import{S as A}from"./scripts.d04c162f.js";import{W as B}from"./workspaces.bd759025.js";import{R as L,_ as N}from"./RuntimeCommonSettings.70c8243f.js";import{_ as P}from"./RunButton.vue_vue_type_script_setup_true_lang.a7714da0.js";import"./gateway.eaf0365c.js";import"./popupNotifcation.0dd61396.js";import"./polling.2c36bf65.js";import"./string.21e44731.js";import"./record.b39e4f7d.js";import"./workspaceStore.911f36b5.js";import"./url.d80febd7.js";import"./colorHelpers.b1f37418.js";import"./BaseLayout.bd87fbab.js";import"./SaveButton.4bb0f678.js";import"./UnsavedChangesHandler.53aaad84.js";import"./ExclamationCircleOutlined.f0ffb2ff.js";import"./log.51595ca7.js";import"./index.9f36e6e9.js";import"./CloseCircleOutlined.350b3cab.js";import"./index.39057a1e.js";import"./editor.c2555793.js";import"./PhArrowSquareOut.vue.8adfc125.js";import"./DocsButton.vue_vue_type_script_setup_true_lang.c22e4b87.js";import"./BookOutlined.65669461.js";import"./PhChats.vue.492f009d.js";import"./ai.6e7ef10a.js";import"./uuid.581ddf8f.js";import"./PhCheckCircle.vue.8ac3d648.js";import"./PhCopySimple.vue.bbc0f891.js";import"./controller.95fec66e.js";import"./vue-flow-core.274e6d98.js";import"./validations.e28306b4.js";import"./metadata.630b4d92.js";import"./PhRobot.vue.b6d33908.js";import"./PhWebhooksLogo.vue.7feade71.js";import"./controller.3825979b.js";import"./fetch.6614bd02.js";import"./PhPencil.vue.5a3116a4.js";import"./AbstraLogo.vue_vue_type_script_setup_true_lang.0f0f172d.js";import"./Logo.70a49b64.js";import"./ant-design.0882cf6b.js";import"./Avatar.4c9fea1d.js";import"./LoadingOutlined.cfab984f.js";import"./Card.d430f4bc.js";import"./TabPane.065b3329.js";import"./Badge.d7e06fdc.js";import"./SourceCode.0286154a.js";import"./PhFolder.vue.868ca452.js";import"./toggleHighContrast.45c0353c.js";import"./TasksManager.5f46bc4c.js";import"./AbstraButton.vue_vue_type_script_setup_true_lang.07f6f371.js";import"./index.8df74d74.js";import"./CollapsePanel.6c33189d.js";import"./index.e8ccec63.js";import"./index.7d23e19f.js";import"./index.b832bc30.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},l=new Error().stack;l&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[l]="a7858933-df75-4337-b02c-f451a4686709",a._sentryDebugIdIdentifier="sentry-dbid-a7858933-df75-4337-b02c-f451a4686709")}catch{}})();const E=k({__name:"ScriptSettings",props:{script:{}},setup(a){const e=f(a.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]=m=>e.value.title=m)},null,8,["value"])]),_:1}),p(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(a,{emit:l}){const e=a,d=v(()=>{var t,i;return(i=(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?i:[]}),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,i)=>(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:i[0]||(i[0]=c=>s.value=c)},null,8,["options","value"])]),_:1})]),_:1}),p(P,{loading:o.value,disabled:t.disabledWarning||m.value,onClick:n,onSave:i[1]||(i[1]=c=>t.script.save())},null,8,["loading","disabled"])]))}}),jt=k({__name:"ScriptEditor",setup(a){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(i=>i.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(),_(N,{stage:r(o).script,workspace:r(o).workspace,"stage-type":"scripts",onRefetchTasks:t[0]||(t[0]=i=>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{jt as default};
//# sourceMappingURL=ScriptEditor.aa7676bd.js.map
