import{cM as y,j as t,t as j,L as I,d as k,d0 as b,cE as L,o as w,R as d,af as f,eq as U,U as C,er as $}from"./index-Dz5JRQhj.js";import{b as S,u as P,j as _}from"./useNetworks-kWi7yZ5O.js";const A=({network:s,project:i})=>{const{data:o}=S(s.name,i);if(o&&o.length>0){const l=o.filter(y).filter(n=>n!==void 0&&n.config&&n.config.parent).map(n=>n.config.parent);if(l.length===0)return"-";const e=[...new Set(l)];return e.length===1?e[0]:`${e.length} different parents`}return s?.config.parent||"-"},F=({networkName:s,projectName:i,networkUrl:o,clusterMember:l})=>{const{data:e,isLoading:n,error:c}=P(s,i,l),{data:a}=_(s,i,l,!n||!c);if(!e&&!n)return t.jsxs(t.Fragment,{children:["Network ",t.jsx(j,{type:"network",value:s,bold:!0})," not found"]});const v=e?.description||"-",g=e?.config["security.acls"]?.split(","),R=e?.config["ipv4.address"]||"-",x=e?.config["ipv6.address"]||"-",m=e?.config.vlan||"-",h=e?.config.mtu||"-",{counters:p}=a??{},r=[{title:"Network",value:e?t.jsx(I,{to:o,title:s,children:s}):t.jsx(k.Spinner,{}),valueTitle:s},{title:"Description",value:v,valueTitle:v},{title:"State",value:a?.state||"-"},{title:"Type",value:e?.type||"-"}];e?.managed&&(e?.type==="bridge"||e?.type==="ovn")?r.push({title:"IPV4",value:R},{title:"IPV6",value:x}):r.push({title:"Parent",value:e&&t.jsx(A,{network:e,project:i})},{title:"VLAN ID",value:m}),b.includes(e?.type??"")?r.push({title:"ACLs",value:t.jsx(L,{items:g?g.map(u=>t.jsx(w,{type:"network-acl",value:u,to:`${d}/ui/project/${encodeURIComponent(i)}/network-acl/${encodeURIComponent(u)}`},u)):[t.jsx(t.Fragment,{children:"-"})]})}):r.push({title:"MTU",value:h});const T=()=>e?{bridge:{title:"MTU",value:h},ovn:{title:"Uplink",value:e.config.network||"-"},macvlan:{title:"GVRP registration",value:e.config.gvrp||"-"},physical:{title:"OVN ingress",value:e.config["ovn.ingress_mode"]||"-"}}[e.type]||{title:"-",value:"-"}:{title:"-",value:"-"};return r.push(T()),r.push({title:"Statistics",value:t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"general-field-label",children:["RX: ",f(p?.bytes_received??0)," (",p?.packets_received??0," packets)"]}),t.jsxs("div",{className:"general-field-label",children:["TX: ",f(p?.bytes_sent??0)," (",p?.packets_sent??0," packets)"]})]})}),r.push({title:"Used by",value:e?.used_by?.length||0}),t.jsx(U,{rows:r,className:"profile-rich-tooltip-table"})},M=({networkName:s,projectName:i,clusterMember:o,className:l,disabled:e})=>{const n=!C($,"height"),c=o?`${d}/ui/project/${encodeURIComponent(i)}/member/${encodeURIComponent(o)}/network/${encodeURIComponent(s)}`:`${d}/ui/project/${encodeURIComponent(i)}/network/${encodeURIComponent(s)}`,a=t.jsx(w,{type:"network",value:s,to:c,hasTitle:!n,className:l,disabled:e});return n?t.jsx(k.Tooltip,{zIndex:1e3,position:"right",message:t.jsx(F,{networkName:s,projectName:i,networkUrl:c,clusterMember:o}),children:a}):t.jsx(t.Fragment,{children:a})};export{M as N};
