import{j as l,km as C,kn as w,a as p,L as W,c7 as s,at as D,r as N,cG as U,fU as u,dV as A,cL as y,ko as v,kp as O,ap as $,d as S,fW as B,cK as I}from"./index-_eM6l4Nf.js";import{L as t}from"./LabelValue-CRG5UPNe.js";const V=({title:i,children:r})=>l.jsxs(C,{children:[i&&l.jsx(w,{as:"h2",fontSize:"18px",color:"gray",alignItems:"center",mb:"10px",children:i}),r]}),E=({color:i="black",size:r="12px",sx:e,...n})=>l.jsx(p,{width:r,height:r,bg:i,...n,as:"span",alignItems:"center",justifyContent:"center",sx:{borderRadius:"50%",userSelect:"none",...e}}),_=({lastTransitionTime:i,lastUpdateTime:r,message:e,reason:n,type:o,ready:a,age:x})=>l.jsx(W,{children:l.jsxs(p,{gap:"5px",alignItems:"center",children:[l.jsx(E,{color:q({type:o,reason:n,message:e,ready:a}),size:"8px"}),l.jsx(s,{fontWeight:"bold",children:o}),l.jsx(s,{color:"gray",children:n}),l.jsxs(s,{color:"grayShade1",children:["- ",e]}),(r||i)&&l.jsx(s,{color:"grayShade1",children:D(r??i)}),l.jsxs(s,{color:"grayShade1",children:["- ",x]})]})}),q=({type:i,reason:r,message:e,ready:n})=>n||i==="Available"&&r!=="MinimumReplicasUnavailable"?"primary":r!=null&&r.includes("Unavailable")||r!=null&&r.includes("NotReady")||e!=null&&e.includes("unready")||e!=null&&e.includes("Unavailable")?"labels.red":i==="Progressing"||r!=null&&r.includes("Progressing")||r!=null&&r.includes("ReplicaSetUpdated")?"labels.yellow":"gray",F=function({items:i,Component:r}){return l.jsxs(p,{sx:{borderLeft:"2px solid",borderColor:"grayShade2",ml:"2px",pl:"12px",flexDirection:"column",gap:"8px"},children:[i.length===0&&"-",i.map((e,n)=>l.jsx(r,{...e},n))]})},G=({message:i,reason:r,type:e,age:n,from:o})=>l.jsxs(W,{children:[l.jsxs(p,{gap:"5px",alignItems:"center",flexWrap:"wrap",children:[l.jsx(E,{color:T({type:e,reason:r}),size:"8px"}),l.jsx(s,{fontWeight:"bold",children:e}),l.jsxs(s,{color:"gray",children:["- ",r]}),l.jsxs(s,{color:"grayShade1",children:["- ",i]})]}),l.jsxs(s,{color:"grayShade1",children:[n,o&&` from ${o}`]})]}),T=({type:i,reason:r})=>i==="Warning"||r!=null&&r.toLocaleLowerCase().includes("failed")||r!=null&&r.toLocaleLowerCase().includes("unhealthy")?"labels.red":i==="Normal"?"primary":"gray",X=({events:i})=>l.jsxs(C,{children:[l.jsx(w,{as:"h3",size:"xs",mb:"8px",color:"gray",children:"Events"}),l.jsx(F,{items:i,Component:G})]}),K=i=>{const r=i.toLowerCase();return r.includes("running")?"primary":r.includes("pending")||r.includes("unknown")?"labels.orange":r.includes("failed")?"labels.red":"black"},Z=N.memo(({title:i,withBorder:r=!1,name:e,namespace:n,events:o,expandable:a,desiredReplicas:x,lastCondition:k,ready:M,readyReplicas:j,status:d,activePods:g,succeededPods:b,failedPods:f,children:L})=>{const z=r?A:V,{isOpen:c,onToggle:m}=U({defaultIsOpen:!a}),h=n||u(j)||u(x)||g!==void 0||b!==void 0||f!==void 0||u(o==null?void 0:o.items)||L;return l.jsx(z,{title:i,children:l.jsxs(y,{gap:"12px",children:[l.jsxs(v,{alignItems:"center",justifyContent:"space-between",children:[a&&h&&l.jsx(O,{ml:"-10px",mr:"10px",my:"-7px","aria-label":c?"Collapse details":"Expand details",icon:l.jsx($,{icon:c?S.arrow_up:S.arrow_down}),size:"sm",variant:"ghost",onClick:m,sx:{alignSelf:"end"}}),l.jsxs(v,{gap:"12px",alignItems:"center",cursor:a&&h?"pointer":"default",onClick:a&&h?m:void 0,flex:"1",children:[!c&&l.jsx(t,{label:"",value:e}),d&&!c&&l.jsx(t,{label:"",value:d,color:K(d)})]})]}),l.jsx(B,{in:c,animateOpacity:!0,children:h&&l.jsxs(y,{gap:"12px",onClick:()=>{a&&c&&m()},cursor:a&&c?"pointer":"default",children:[l.jsxs(y,{direction:"row",gap:"20px",flexWrap:"wrap",children:[l.jsx(t,{label:c?"name":"",value:e}),d&&l.jsx(t,{label:"status",value:d,color:K(d)}),n&&l.jsx(t,{label:"namespace",value:n}),x&&j&&l.jsx(I,{orientation:"vertical",height:"36px"}),u(j)&&u(x)&&l.jsx(t,{label:"pod readiness",value:`${j}/${x}`}),k&&l.jsx(t,{label:"condition",value:l.jsx(_,{...k,ready:M})}),g!==void 0&&l.jsx(t,{label:"active pods",value:g}),b!==void 0&&l.jsx(t,{label:"succeeded pods",value:b}),f!==void 0&&l.jsx(t,{label:"failed pods",value:f})]}),l.jsx(I,{}),u(o==null?void 0:o.items)&&l.jsx(X,{events:o.items}),L]})})]})})}),Q=({pods:i})=>l.jsxs(C,{children:[l.jsx(w,{as:"h3",size:"xs",mb:"8px",color:"gray",children:"Pods"}),l.jsx(v,{flexDirection:"column",gap:"12px",children:i.map(r=>l.jsx(Z,{expandable:i.length>1,withBorder:!0,...r},r.name))})]});export{Z as K,Q as a};
