import{aD as x,a as D,x as k,b as B,aE as F,c,aF as I,$ as N,u as a,f as b,w as d,h as J,g as O,B as V,o as P,j as i,aG as T,aH as $,aI as E,aJ as G,X as y,aB as f}from"./index-e7fdb3d4.js";import{u as M}from"./usePageTitle-df55e3a5.js";class U extends x{parse(t){return JSON.parse(decodeURIComponent(t??""))}format(t){return encodeURIComponent(JSON.stringify(t))}}const A=D({__name:"FlowRunCreate",setup(h){const t=k(),s=B("deploymentId"),n=V(),m=F("parameters",U,void 0),w=c(()=>!e.value||!m.value?{}:I.map("SchemaValuesResponse",{schema:e.value.parameterOpenApiSchema,values:m.value},"SchemaValues")),R=N(t.deployments.getDeployment,[s]),e=c(()=>R.response),_=async r=>{var l,o;try{const u=await t.deployments.createDeploymentFlowRun(s.value,r),p=((o=(l=r.state)==null?void 0:l.stateDetails)==null?void 0:o.scheduledTime)??void 0,C=!p,S=E(G,{flowRun:u,flowRunRoute:y.flowRun,router:n,immediate:C,startTime:p});f(S,"success"),n.push(y.deployment(s.value))}catch(u){f("Something went wrong trying to create a flow run","error"),console.error(u)}},v=()=>{n.back()},g=c(()=>e.value?`Create Flow Run for Deployment: ${e.value.name}`:"Create Flow Run for Deployment");return M(g),(r,l)=>{const o=O("p-layout-default");return a(e)?(P(),b(o,{key:0},{header:d(()=>[i(a(T),{deployment:a(e)},null,8,["deployment"])]),default:d(()=>[i(a($),{deployment:a(e),parameters:a(w),onSubmit:_,onCancel:v},null,8,["deployment","parameters"])]),_:1})):J("",!0)}}});export{A as default};
