import{j as t,cr as f,cA as v,o as c,R as u,aD as P,a4 as x,el as m,t as L,da as R,aI as h,d as p,em as T,U as C,en as I}from"./index-C88DWJny.js";import{P as k,D as w,a as b,b as D}from"./ProfileResourceLimits-ChaqL2tV.js";const $=({profile:s,project:o})=>t.jsx(t.Fragment,{children:Object.values(s.devices).some(f)?t.jsx(v,{items:Object.values(s.devices).filter(f).map(e=>t.jsx(c,{type:"network",value:e.network,to:`${u}/ui/project/${encodeURIComponent(o)}/network/${encodeURIComponent(e.network)}`},e.network))}):"-"}),U=({profileName:s,projectName:o})=>{const{data:e,isLoading:a}=P(s,o),{project:i,isLoading:r}=x(),n=m(i);if(!e&&!(a||r))return t.jsxs(t.Fragment,{children:["Profile ",t.jsx(L,{type:"profile",value:s,bold:!0})," not found"]});const d=e?.description||"-",j=R(o,o==="default",e?e.used_by:[]).length,l=e?h(e):"",g=[{title:"Profile",value:e?t.jsx(k,{profile:e}):t.jsx(p.Spinner,{}),valueTitle:s},{title:"Description",value:d,valueTitle:d},{title:"Defined in",value:`${n?"Current":"Default"} project`},{title:"Root storage",value:l?t.jsx(c,{type:"pool",value:l,to:`${u}/ui/project/${encodeURIComponent(o)}/storage/pool/${encodeURIComponent(l)}`}):"-",truncate:!1,className:"storage-list"},{title:"Networks",value:e?t.jsx($,{profile:e,project:o}):"-",truncate:!1,className:"networks-list"},{title:"Devices",value:e?t.jsx(w,{devices:Object.values(e.devices),className:"truncated"}):"-",truncate:!1},{title:"Limits",value:e?t.jsx(b,{profile:e}):"-",truncate:!1},{title:"Configuration",value:t.jsx(D,{profile:e,className:"truncated"}),truncate:!1},{title:"Used by",value:j}];return t.jsx(T,{rows:g,className:"profile-rich-tooltip-table"})},A=({profileName:s,projectName:o,className:e,disabled:a})=>{const i=!C(I,"height"),r=`${u}/ui/project/${encodeURIComponent(o)}/profile/${encodeURIComponent(s)}`,n=t.jsx(c,{type:"profile",value:s,to:r,hasTitle:!i,className:e,disabled:a});return i?t.jsx(p.Tooltip,{zIndex:1e3,position:"right",message:t.jsx(U,{profileName:s,projectName:o}),children:n}):t.jsx(t.Fragment,{children:n})};export{A as P};
