import{j as l,l7 as C,l8 as w,q as p,F as K,ck as t,ar as W,r as D,cS as F,gO as u,bk as N,c as $,cW as y,l9 as v,la as U,ao as q,v as k,gQ as A,cX as I}from"./index-Cox3ZWL0.js";import{L as s}from"./LabelValue-BkTpmDa_.js";const B=({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]}),M=({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(K,{children:l.jsxs(p,{gap:"5px",alignItems:"center",children:[l.jsx(M,{color:J({type:o,reason:n,message:e,ready:a}),size:"8px"}),l.jsx(t,{fontWeight:"bold",children:o}),l.jsx(t,{color:"gray",children:n}),l.jsxs(t,{color:"grayShade1",children:["- ",e]}),(r||i)&&l.jsx(t,{color:"grayShade1",children:W(r??i)}),l.jsxs(t,{color:"grayShade1",children:["- ",x]})]})}),J=({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",Q=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))]})},V=({message:i,reason:r,type:e,age:n,from:o})=>l.jsxs(K,{children:[l.jsxs(p,{gap:"5px",alignItems:"center",flexWrap:"wrap",children:[l.jsx(M,{color:X({type:e,reason:r}),size:"8px"}),l.jsx(t,{fontWeight:"bold",children:e}),l.jsxs(t,{color:"gray",children:["- ",r]}),l.jsxs(t,{color:"grayShade1",children:["- ",i]})]}),l.jsxs(t,{color:"grayShade1",children:[n,o&&` from ${o}`]})]}),X=({type:i,reason:r})=>i==="Warning"||r!=null&&r.toLocaleLowerCase().includes("failed")||r!=null&&r.toLocaleLowerCase().includes("unhealthy")?"labels.red":i==="Normal"?"primary":"gray",Y=({events:i})=>l.jsxs(C,{children:[l.jsx(w,{as:"h3",size:"xs",mb:"8px",color:"gray",children:"Events"}),l.jsx(Q,{items:i,Component:V})]}),E=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=D.memo(({title:i,withBorder:r=!1,name:e,namespace:n,events:o,expandable:a,desiredReplicas:x,lastCondition:S,ready:z,readyReplicas:h,status:d,activePods:g,succeededPods:b,failedPods:f,children:L})=>{const O=r?N:B,{isOpen:c,onToggle:m}=F({defaultIsOpen:!a}),j=n||u(h)||u(x)||g!==void 0||b!==void 0||f!==void 0||u(o==null?void 0:o.items)||L;return l.jsxs(O,{title:i,children:[!j&&l.jsx($,{gray:!0,fontSize:"16px",children:"-"}),l.jsxs(y,{gap:"12px",children:[l.jsxs(v,{alignItems:"center",justifyContent:"space-between",children:[a&&j&&l.jsx(U,{ml:"-10px",mr:"10px",my:"-7px","aria-label":c?"Collapse details":"Expand details",icon:l.jsx(q,{icon:c?k.arrow_up:k.arrow_down}),size:"sm",variant:"ghost",onClick:m,sx:{alignSelf:"end"}}),l.jsxs(v,{gap:"12px",alignItems:"center",cursor:a&&j?"pointer":"default",onClick:a&&j?m:void 0,flex:"1",children:[!c&&l.jsx(s,{label:"",value:e}),d&&!c&&l.jsx(s,{label:"",value:d,color:E(d)})]})]}),l.jsx(A,{in:c,animateOpacity:!0,children:j&&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(s,{label:c?"name":"",value:e}),d&&l.jsx(s,{label:"status",value:d,color:E(d)}),n&&l.jsx(s,{label:"namespace",value:n}),x&&h&&l.jsx(I,{orientation:"vertical",height:"36px"}),u(h)&&u(x)&&l.jsx(s,{label:"pod readiness",value:`${h}/${x}`}),S&&l.jsx(s,{label:"condition",value:l.jsx(_,{...S,ready:z})}),g!==void 0&&l.jsx(s,{label:"active pods",value:g}),b!==void 0&&l.jsx(s,{label:"succeeded pods",value:b}),f!==void 0&&l.jsx(s,{label:"failed pods",value:f})]}),l.jsx(I,{}),u(o==null?void 0:o.items)&&l.jsx(Y,{events:o.items}),L]})})]})]})}),T=({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,T as a};
