import{j as e,r as u}from"./@radix-3bj3otF9.js";import{C as _}from"./CodeSnippet-C2p1JJEZ.js";import{C as x}from"./collapsible-chevron-CRi1mieO.js";import{a6 as O,e as d,C as h,q as j,t as f,v as b,a1 as T,r as q,T as L,d as R}from"./index-Cs2FY84s.js";import{b as m}from"./@tanstack-CByuvRcg.js";import{a as E,L as z}from"./@react-router-Ct_TgVUW.js";import{D as B}from"./deployment-status-tag-7j1Qxmk2.js";import{K as p,a as c}from"./KeyValue-Dba6goo4.js";import{P as F}from"./pipeline-link-W-agDCn-.js";import{R as K,C as W}from"./ComponentCollapsible-DhbNnixh.js";import{s as A}from"./index-Aaj1O_4o.js";import"./chevron-down-smmnLxYI.js";import"./@reactflow-CwWcBchH.js";import"./eye-vFb-iYpN.js";import"./CollapsibleCard-ErHP3-9N.js";import"./ComponentBadge-DxjeE6Hn.js";import"./ComponentIcon-CLH2B8Js.js";import"./bar-chart-square-check-Diki0CFQ.js";import"./layout-zVxDzB0C.js";import"./transform-CRpCHU_K.js";import"./stack-detail-query-DR_HwbzU.js";function Q({Component:s}){const{snapshotId:r}=E(),a=m({...O.detail(r),throwOnError:!0});if(a.isPending)return e.jsx(d,{className:"h-[200px] w-full"});if(a.isError)return null;const o=a.data;return e.jsx(s,{snapshot:o})}function H(){return e.jsx(Q,{Component:V})}function V({snapshot:s}){var t;const[r,a]=u.useState(!0);if(!((t=s.body)==null?void 0:t.runnable))return null;const n=`from zenml.client import Client

Client().trigger_pipeline(snapshot_name_or_id="${s.id}")`;return e.jsxs(h,{open:r,onOpenChange:a,children:[e.jsx(j,{className:"flex items-center gap-[10px]",children:e.jsxs(f,{className:"flex w-full gap-2",children:[e.jsx(x,{open:r}),e.jsx("span",{children:"Code"})]})}),e.jsxs(b,{className:"border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3",children:[e.jsx("p",{className:"mb-2",children:"Run the snapshot"}),e.jsx(_,{fullWidth:!0,highlightCode:!0,wrap:!0,code:n})]})]})}function $(){return e.jsx(Q,{Component:G})}function G({snapshot:s}){var v,S,k,w,I,D,P;const[r,a]=u.useState(!0),o=s.id,i=(v=s.resources)==null?void 0:v.pipeline.name,n=(S=s.resources)==null?void 0:S.pipeline.id,t=(k=s.resources)==null?void 0:k.code_reference,g=(w=t==null?void 0:t.body)==null?void 0:w.code_repository.id,C=(I=t==null?void 0:t.body)==null?void 0:I.commit,l=(D=s.resources)==null?void 0:D.deployment,y=l==null?void 0:l.id,N=(P=l==null?void 0:l.body)==null?void 0:P.status;return e.jsxs(h,{open:r,onOpenChange:a,children:[e.jsx(j,{className:"flex items-center gap-[10px]",children:e.jsxs(f,{className:"flex w-full gap-2",children:[e.jsx(x,{open:r}),"Details"]})}),e.jsx(b,{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(p,{label:"Id",value:e.jsxs("div",{className:"group/copybutton flex items-center gap-0.5",children:[o,e.jsx(T,{copyText:o})]})}),e.jsx(p,{label:"Pipeline",value:i&&n?e.jsx(F,{pipelineId:n,pipelineName:i}):e.jsx(c,{})}),e.jsx(p,{label:"Deployment",value:y&&N?e.jsx(z,{to:q.projects.deployments.detail.overview(y),children:e.jsx(B,{size:"sm",status:N})}):e.jsx(c,{})}),e.jsx(p,{label:"Repository/Commit",value:g&&C?e.jsx(K,{repositoryId:g,commit:C}):e.jsx(c,{})})]})})]})}function J({stack:s}){var n;const[r,a]=u.useState(!0),o=s.name,i=Object.values(((n=s.metadata)==null?void 0:n.components)??{}).flat();return e.jsxs(h,{open:r,onOpenChange:a,children:[e.jsxs(j,{className:"flex items-center justify-between",children:[e.jsxs(f,{className:"flex w-full gap-2",children:[e.jsx(x,{open:r}),"Stack"]}),e.jsx("div",{children:e.jsxs(L,{className:"flex w-fit items-center gap-1 whitespace-nowrap text-turquoise-600",color:"turquoise",emphasis:"subtle",rounded:!1,children:[e.jsx(R,{className:"h-4 w-4 fill-current"}),o]})})]}),e.jsx(b,{className:"border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3",children:e.jsx("ul",{className:"space-y-5",children:i.map(t=>e.jsx("li",{className:"w-full",children:e.jsx(W,{component:t,objectConfig:{}})},t.id))})})]})}function M(){var i,n,t;const{snapshotId:s}=E(),r=m({...O.detail(s)}),a=(t=(n=(i=r.data)==null?void 0:i.resources)==null?void 0:n.stack)==null?void 0:t.id,o=m({...A.stackDetail(a??""),enabled:!!a});return r.isPending?e.jsx(d,{className:"h-[300px] w-full"}):r.isError?e.jsx("div",{children:"Failed to load snapshot."}):a?o.isPending?e.jsx(d,{className:"h-[300px] w-full"}):o.isError?e.jsx("div",{children:"Failed to load stack."}):e.jsx(J,{stack:o.data}):e.jsx("div",{children:"Stack not available for this snapshot."})}function fe(){return e.jsxs("div",{className:"grid grid-cols-1 gap-5 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsx($,{}),e.jsx(H,{})]}),e.jsx("div",{children:e.jsx(M,{})})]})}export{fe as default};
