import{j as e}from"./@radix-DAoBbclx.js";import{C as y}from"./CodeSnippet-j6SUjNoa.js";import{b as w,C as F}from"./CollapsibleCard-CehR97tz.js";import{aG as R,e as x,bg as g,ai as $,C as P,o as D,q as O,t as T,aN as X,bh as q,aO as C,aQ as N,aV as G,a1 as z,aH as M,x as H}from"./index-DnCFURX3.js";import{a as S}from"./@monaco-editor-Di1Jq_O0.js";import{b}from"./@tanstack-2852wz5w.js";import{a as Z}from"./@react-router-BTai9D5g.js";import"./json-faker-TB_1tyv3.js";import{J as B}from"./@json-schema-faker-ZU6lJtJH.js";import{N as K,K as k,a as v,b as Y,V as ee}from"./KeyValue-B_OUMPK3.js";import{P as te}from"./pipeline-link-n7S1rP3v.js";import{u as se,D as ne}from"./DockerImageCollapsible-LbprlXN0.js";import{E as L}from"./EmptyState-BpQ7TzW2.js";import{S as re}from"./stack-info-full-D9-Nct8G.js";import{u as ae}from"./stack-detail-query-CIp7lmsE.js";import"./@elkjs-CmhuJAjY.js";import"./chevron-down-DPrYU2vK.js";import"./@reactflow-CLotj7HR.js";import"./@zod-3snSrKBm.js";import"./eye-C2BdTq-f.js";import"./ComponentIcon-BOGF3ktm.js";import"./bar-chart-square-check-CVLivjI6.js";import"./layout-BtXy9gkl.js";import"./transform-CoT5Lusb.js";import"./constants-BUlqx9qT.js";function f({Component:s}){const{deploymentId:t}=Z(),n=b({...R.detail(t),throwOnError:!0});if(n.isPending)return e.jsx(x,{className:"h-[200px] w-full"});if(n.isError)return null;const a=n.data;return e.jsx(s,{deployment:a})}function E(s){return"*".repeat(Math.min(s.length,10))}function J(s,t){if(!t)return s;const n=E(t);return s.replace(n,t)}function oe(s,t,n){const a=[];n&&a.push(`-H "Authorization: Bearer ${E(n)}"`),a.push('-H "Content-Type: application/json"');const r=a.join(` \\
  `);if(t){const o=g(JSON.stringify(t,null,2).split(`
`).join(`
    `));return`curl -X POST ${s}/invoke \\
  ${r} \\
  -d '{
    "parameters": ${o}
  }'`}return`curl -X POST ${s}/invoke \\
  ${r}`}function ie(s,t){if(!t||typeof t!="object"||Array.isArray(t))return`zenml deployment invoke ${g(s)}`;const n=Object.entries(t).map(([a,r])=>{const o=typeof r=="object"&&r!==null,i=JSON.stringify(r),l=o?`'${g(i)}'`:g(i);return`--${a}=${l}`}).join(" ");return`zenml deployment invoke ${g(s)} ${n}`}function le({deploymentId:s,defaultBody:t}){const n=`from zenml.deployers.utils import invoke_deployment

`;let a="";if(t&&typeof t=="object"&&!Array.isArray(t)){const r=Object.entries(t).map(([o,i])=>{const l=JSON.stringify(i);return`    ${o}=${l}`}).join(`,
`);r&&(a=`,
${r}`)}return`${n}response = invoke_deployment(
    deployment_name_or_id="${s}"${a}
)`}function ce(s,t,n){const a=[];n&&a.push(`    "Authorization": "Bearer ${E(n)}"`),a.push('    "Content-Type": "application/json"');const r=a.join(`,
`);if(t){const o=JSON.stringify(t,null,2).split(`
`).map((i,l)=>l===0?i:`    ${i}`).join(`
`);return`const response = await fetch("${s}/invoke", {
  method: "POST",
  headers: {
${r}
  },
  body: JSON.stringify({
    parameters: ${o}
  })
});`}return`const response = await fetch("${s}/invoke", {
  method: "POST",
  headers: {
${r}
  }
});`}function pe(){return e.jsx(f,{Component:ue})}function ue({deployment:s}){var m,h,A,Q,_,V;const[t,n]=S.useState(!0),[a,r]=S.useState("cli"),o=(h=(m=s.resources)==null?void 0:m.snapshot)==null?void 0:h.id,i=b({...$.detail(o),enabled:!!o});if(!o)return null;if(i.isPending)return e.jsx(x,{className:"h-[200px] w-full"});if(i.isError)return null;const d=(Q=(A=i.data.metadata)==null?void 0:A.pipeline_spec)==null?void 0:Q.input_schema,p=d?B.generate(d):{},c=(_=s.body)==null?void 0:_.url,u=((V=s.metadata)==null?void 0:V.auth_key)??void 0;return e.jsxs(P,{open:t,onOpenChange:n,children:[e.jsx(D,{className:"flex h-9 items-center gap-[10px]",children:e.jsxs(O,{className:"flex w-full gap-2",children:[e.jsx(w,{open:t}),"Invocation"]})}),e.jsx(T,{className:"space-y-5 border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3",children:e.jsxs(X,{value:a,onValueChange:r,children:[e.jsxs(q,{children:[e.jsx(C,{className:"flex items-center gap-2 truncate text-text-md",value:"cli",children:e.jsx("span",{children:"CLI"})}),e.jsx(C,{className:"flex items-center gap-2 truncate text-text-md",value:"python",children:e.jsx("span",{children:"Python"})}),!!c&&e.jsx(C,{className:"flex items-center gap-2 truncate text-text-md",value:"curl",children:e.jsx("span",{children:"cURL"})}),!!c&&e.jsx(C,{className:"flex items-center gap-2 truncate text-text-md",value:"ts",children:e.jsx("span",{children:"Typescript"})})]}),e.jsx(N,{className:"m-0 mt-5 border-0 bg-transparent p-0",value:"cli",children:e.jsx(y,{fullWidth:!0,highlightCode:!0,language:"bash",wrap:!0,code:ie(s.name,p)})}),e.jsx(N,{className:"m-0 mt-5 border-0 bg-transparent p-0",value:"python",children:e.jsx(y,{fullWidth:!0,highlightCode:!0,language:"python",wrap:!0,code:le({deploymentId:s.id,defaultBody:p})})}),!!c&&e.jsx(N,{className:"m-0 mt-5 border-0 bg-transparent p-0",value:"curl",children:(()=>{const j=oe(c,p,u);return e.jsx(y,{fullWidth:!0,highlightCode:!0,wrap:!0,language:"bash",copyCode:J(j,u),code:j})})()}),!!c&&e.jsx(N,{className:"m-0 mt-5 border-0 bg-transparent p-0",value:"ts",children:(()=>{const j=ce(c,p,u);return e.jsx(y,{fullWidth:!0,wrap:!0,highlightCode:!0,language:"ts",copyCode:J(j,u),code:j})})()})]})})]})}function de(){return e.jsx(f,{Component:me})}function me({deployment:s}){var r,o,i;const t=(o=(r=s.resources)==null?void 0:r.deployer)==null?void 0:o.id,n=b({...G.componentDetail(t),enabled:!!t});if(!t)return null;if(n.isPending)return e.jsx(x,{className:"h-[200px] w-full"});if(n.isError)return null;const a=n.data;return e.jsx(K,{isInitialOpen:!0,title:"Deployer Configuration",data:(i=a.metadata)==null?void 0:i.configuration})}function he(){return e.jsx(f,{Component:xe})}function xe({deployment:s}){var p,c,u,m,h;const[t,n]=S.useState(!0),a=s.id,r=(p=s.resources)==null?void 0:p.snapshot,o=r==null?void 0:r.id,i=r==null?void 0:r.name,l=(u=(c=s.resources)==null?void 0:c.pipeline)==null?void 0:u.id,d=(h=(m=s.resources)==null?void 0:m.pipeline)==null?void 0:h.name;return e.jsxs(P,{open:t,onOpenChange:n,children:[e.jsx(D,{className:"flex h-9 items-center gap-[10px]",children:e.jsxs(O,{className:"flex w-full gap-2",children:[e.jsx(w,{open:t}),"Details"]})}),e.jsx(T,{className:"border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3",children:e.jsxs("dl",{className:"grid grid-cols-1 gap-x-[10px] gap-y-2 md:grid-cols-3 md:gap-y-4",children:[e.jsx(k,{label:"Id",value:e.jsxs("div",{className:"group/copybutton flex items-center gap-0.5",children:[a,e.jsx(z,{copyText:a})]})}),e.jsx(k,{label:"Snapshot",value:o&&i?e.jsx(M,{snapshotId:o,snapshotName:i}):e.jsx(v,{})}),e.jsx(Y,{className:"h-auto",children:"Pipeline"}),e.jsx(ee,{className:"h-auto",children:l&&d?e.jsx(te,{pipelineId:l,pipelineName:d}):e.jsx(v,{})})]})})]})}function W({title:s,subtitle:t}){return e.jsx(L,{className:"p-5",icon:e.jsx(H,{className:"h-[60px] w-[60px] fill-neutral-300"}),children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-text-lg font-semibold",children:s}),t&&e.jsx("p",{className:"text-text-md text-theme-text-secondary",children:t})]})})}function fe(){return e.jsx(f,{Component:je})}function je({deployment:s}){var l,d,p,c,u,m,h;const t=(d=(l=s.resources)==null?void 0:l.snapshot)==null?void 0:d.id,n=b($.detail(t)),a=(u=(c=(p=n.data)==null?void 0:p.resources)==null?void 0:c.build)==null?void 0:u.id,r=se({buildId:a},{enabled:!!a});if(!t)return null;if(n.isPending)return e.jsx(x,{className:"h-[200px] w-full"});if(n.isError)return e.jsx("div",{children:e.jsx(W,{title:"Unable to get the docker build",subtitle:"Something went wrong fetching the snapshot"})});if(!a)return null;if(r.isPending)return e.jsx(x,{className:"h-[200px] w-full"});if(r.isError)return e.jsx("div",{children:e.jsx(W,{title:"Unable to get the docker build",subtitle:"Something went wrong fetching the build"})});const i=(h=(m=r.data.metadata)==null?void 0:m.images)==null?void 0:h.deployer;return i?e.jsx(ne,{displayCopyButton:!1,data:i}):null}function ge(){return e.jsx(f,{Component:be})}function be({deployment:s}){var r;const[t,n]=S.useState(!0),a=(r=s.body)==null?void 0:r.url;return e.jsxs(P,{open:t,onOpenChange:n,children:[e.jsx(D,{className:"flex h-9 items-center gap-[10px]",children:e.jsxs(O,{className:"flex w-full gap-2",children:[e.jsx(w,{open:t}),"Endpoint"]})}),e.jsx(T,{className:"border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3",children:e.jsx("dl",{className:"grid grid-cols-1 gap-x-[10px] gap-y-2 md:grid-cols-3 md:gap-y-4",children:e.jsx(k,{label:"Endpoint",value:a?e.jsxs("div",{className:"group/copybutton flex items-center gap-0.5",children:[e.jsx("a",{className:"link truncate",href:a,target:"_blank",rel:"noopener noreferrer",children:a}),e.jsx(z,{copyText:a})]}):e.jsx(v,{})})})})]})}function ye(){return e.jsx(f,{Component:Ce})}function Ce({deployment:s}){var n;const t=(n=s.resources)==null?void 0:n.snapshot;return t?e.jsx(Ne,{snapshotId:t.id}):e.jsx(U,{})}function Ne({snapshotId:s}){var a,r,o;const t=b({...$.detail(s)});if(t.isPending)return e.jsx(x,{className:"h-[200px] w-full"});if(t.isError)return e.jsx(I,{title:"Unable to get Stack",subtitle:"Something went wrong fetching the deployment snapshot"});const n=(o=(r=(a=t.data)==null?void 0:a.resources)==null?void 0:r.stack)==null?void 0:o.id;return n?e.jsx(Se,{snapshot:t.data,stackId:n}):e.jsx(U,{})}function Se({snapshot:s,stackId:t}){var o;const n=ae({stackId:t});if(n.isPending)return e.jsx(x,{className:"h-[200px] w-full"});if(n.isError)return e.jsx(I,{title:"Failed to fetch the stack",subtitle:"Something went wrong fetching the stack"});const a=n.data,r=((o=s.metadata)==null?void 0:o.pipeline_configuration.settings)||{};return e.jsx(re,{stack:a,objectConfig:r})}function I({title:s,subtitle:t}){return e.jsx(F,{title:"Stack",initialOpen:!0,children:e.jsx(L,{className:"p-5",icon:e.jsx(H,{className:"h-[60px] w-[60px] fill-neutral-300"}),children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-text-lg font-semibold",children:s}),t&&e.jsx("p",{className:"text-text-md text-theme-text-secondary",children:t})]})})})}function U(){return e.jsx(I,{title:"No Stack",subtitle:"There is no stack associated with this deployment."})}function Me(){return e.jsxs("div",{className:"grid grid-cols-1 gap-5 p-5 lg:grid-cols-2 lg:px-[80px]",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsx(ge,{}),e.jsx(pe,{}),e.jsx(he,{}),e.jsx(de,{})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(ye,{}),e.jsx(fe,{})]})]})}export{Me as default};
