import{a7 as f,j as e,aU as g,o as h,aV as b,aW as d,aX as w,d as D,g as k,q as N,aw as L,L as $}from"./index-Cziemgsu.js";import{R as p}from"./ResourceLink-D2AYI_En.js";import{i as T}from"./networks-mhWNV24c.js";const C=({device:t,project:o})=>t.type==="disk"?f(t)?e.jsxs(e.Fragment,{children:["Pool"," ",e.jsx(p,{type:"pool",value:t.pool||"",to:`/ui/project/${o}/storage/pool/${t.pool}`})]}):g(t)?t.source:e.jsxs(e.Fragment,{children:["Volume"," ",e.jsx(p,{type:"volume",value:t.source,to:`/ui/project/${o}/storage/pool/${t.pool}/volumes/custom/${t.source}`})," ","on pool"," ",e.jsx(p,{type:"pool",value:t.pool||"",to:`/ui/project/${o}/storage/pool/${t.pool}`})]}):t.type==="gpu"?e.jsx("span",{title:t.pci,className:"u-truncate",children:t.pci?`PCI  ${t.pci}`:`ID ${t.id}`}):t.type==="proxy"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{title:t.listen,className:"u-truncate",children:["Listen: ",t.listen]}),e.jsxs("div",{title:t.connect,className:"u-truncate",children:["Connect: ",t.connect]})]}):"-",q=({configBaseURL:t,devices:o})=>{const{project:l}=h(),j=(n,a)=>{const s=n[0].toLowerCase(),i=a[0].toLowerCase(),m=n[1].type,u=a[1].type;return m===u?s.localeCompare(i):m.localeCompare(u)},c=Object.entries(o??{}).filter(([n,a])=>a.type!=="nic"&&a.type!=="none").sort(j),r=c.length>0,y=[{content:"Name",sortKey:"name",className:"u-text--muted"},{content:"Type",sortKey:"type",className:"u-text--muted"},{content:"Details",className:"u-text--muted"}],x=c.map(([n,a])=>{let s=a.type;return b(a)&&(f(a)&&(s+=" (root)"),d(a)&&(s+=" (volume)"),g(a)&&(s+=" (host path)")),{columns:[{content:e.jsx(p,{type:"device",value:n,to:`${t}/${w(a)?"other":a.type}`}),role:"cell","aria-label":"Name"},{content:s,role:"cell","aria-label":"Type"},{content:e.jsx(C,{device:a,project:l}),role:"cell","aria-label":"Details"}],sortData:{name:n.toLowerCase(),type:a.type}}});return e.jsxs(e.Fragment,{children:[r&&e.jsx(D.MainTable,{headers:y,rows:x,className:"device-table",sortable:!0}),!r&&e.jsx(e.Fragment,{children:"-"})]})},I=({onFailure:t,devices:o})=>{const{project:l}=h(),{data:j=[],error:c,isLoading:r}=k({queryKey:[N.projects,l,N.networks],queryFn:()=>T(l)});c&&t("Loading networks failed",c);const y=Object.values(o??{}).filter(L).map(s=>s.network),x=y.length>0,n=[{content:"Name",sortKey:"name",className:"u-text--muted"},{content:"Interface",sortKey:"interfaceName",className:"u-text--muted"},{content:"Type",sortKey:"type",className:"u-text--muted"},{content:"Managed",sortKey:"managed",className:"u-text--muted u-hide--small u-hide--medium"}],a=j.filter(s=>y.includes(s.name)).map(s=>{const i=Object.entries(o??{}).filter(([m,u])=>u.type==="nic"&&u.network===s.name).map(([m])=>m);return{columns:[{content:e.jsx(p,{type:"network",value:s.name,to:`/ui/project/${l}/network/${s.name}`}),role:"cell","aria-label":"Name"},{content:i.length>0?i.join(" "):"-",role:"cell","aria-label":"Interface"},{content:s.type,role:"cell","aria-label":"Type"},{content:s.managed?"Yes":"No",role:"cell","aria-label":"Managed"}],sortData:{name:s.name.toLowerCase(),type:s.type,managed:s.managed,interfaceName:i.join(" ")}}});return e.jsxs(e.Fragment,{children:[r&&e.jsx($,{text:"Loading networks..."}),!r&&x&&e.jsx(D.MainTable,{headers:n,rows:a,sortable:!0,className:"network-table"}),!r&&!x&&e.jsx(e.Fragment,{children:"-"})]})};export{q as D,I as N};
