"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[74104],{274104(e,i,t){t.r(i),t.d(i,{default:()=>Ce});var n=t(274934),s=t(602086),r=t(977872),c=t(832162),o=t(853777),l=t(244081),d=t(735552),a=t(724081),h=t(309130),A=t(793442),C=t(100978),u=t(612389),x=t(869332),M=t(470070),O=t(898118),m=t(95546),j=t(726831),E=t(271656);const p=(0,s.createContext)(void 0),_=({children:e})=>{const[i,t]=(0,s.useState)(E.A),r=(0,s.useMemo)(()=>({unblockedPortsMap:i,setUnblockedPortsMap:t}),[i,t]);return(0,n.jsx)(p.Provider,{value:r,children:e})},v=()=>(0,s.useContext)(p)||{unblockedPortsMap:{},setUnblockedPortsMap:()=>{}};var b=t(938984),g=t(599110);const S=({ids:e})=>{const i=(0,r.wA)(),{unblockedPortsMap:t,setUnblockedPortsMap:c}=v(),o=(0,s.useCallback)(()=>{i((0,O.M)()),e.forEach(e=>c(i=>({...i,[e]:!0})))},[i,e,c]);return e.every(e=>t[e])?null:(0,n.jsx)(g.A,{type:"button",variant:"inline",onClick:o,children:(0,n.jsx)(b.A,{size:"inherit",color:"inherit",weight:"inherit",children:(0,n.jsx)(M.sA,{id:"COMMON_UNBLOCK_ALL"})})})};var k,L=t(214297),N=t(792929),f=t(795206);!function(e){e.NAME="name",e.PORT="port",e.DEVICES="devices",e.MAC_ADDRESS="mac_address",e.BLOCK_TIME="block_time"}(k||(k={}));const w={[k.NAME]:"COMMON_NAME",[k.PORT]:"COMMON_PORT",[k.DEVICES]:"COMMON_DEVICES",[k.MAC_ADDRESS]:"COMMON_MAC_ADDRESS",[k.BLOCK_TIME]:"COMMON_BLOCK_TIME"};var D=t(247816),R=t(347625),P=t(255045),I=t(703842),T=t(85908),y=t(974390),z=t(754924);const F=(0,D.A)(b.A)`
  width: 20px;
`,{background:K,border:B,text:U}=T.jK[P.LX.ERROR],W=({device:e,port_idx:i})=>{const t=e?.port_table.find(e=>e.port_idx===i);return t?(0,n.jsxs)(C.A,{alignItems:"center",gap:h.kc,children:[(0,n.jsx)(I.A,{background:K,border:B,text:U,icon:P.FZ.ERROR,isLocating:!1,isInteractive:!0}),(0,n.jsx)(F,{size:"inherit",variant:"inherit",color:"inherit",weight:"inherit",children:i}),(0,n.jsx)(y.A,{model:e.model,width:20,height:20}),(0,n.jsx)(b.A,{size:"inherit",color:"inherit",weight:"inherit",children:(0,R.Q)(e)})]}):(0,n.jsx)(b.A,{size:"inherit",color:"inherit",weight:"inherit",children:(0,n.jsx)(M.sA,{id:"COMMON_FALLBACK"})})},V=({device:e})=>(0,n.jsxs)(C.A,{alignItems:"center",gap:h.kc,children:[(0,n.jsx)(y.A,{model:e.model,width:20,height:20}),(0,n.jsx)(b.A,{size:"inherit",color:"inherit",weight:"inherit",children:(0,R.Q)(e)})]}),G=({child:e,mac:i,port_idx:t})=>{const c=(0,r.d4)((0,s.useMemo)(()=>(0,z.tG)(i),[i]));return c?e?(0,n.jsx)(V,{device:c}):(0,n.jsx)(W,{device:c,port_idx:t}):(0,n.jsx)(b.A,{size:"inherit",color:"inherit",weight:"inherit",children:(0,n.jsx)(M.sA,{id:"COMMON_FALLBACK"})})},H=[{id:k.PORT,label:(0,n.jsx)(M.sA,{id:w[k.PORT]}),minWidth:250,renderCell:({port_idx:e,mac:i,child:t})=>(0,n.jsx)(G,{port_idx:e,mac:i,child:t})},{id:k.NAME,label:(0,n.jsx)(M.sA,{id:w[k.NAME]}),minWidth:160,renderCell:({name:e})=>e},{id:k.DEVICES,label:(0,n.jsx)(M.sA,{id:w[k.DEVICES]}),minWidth:80,renderCell:({devices:e})=>e},{id:k.MAC_ADDRESS,label:(0,n.jsx)(M.sA,{id:w[k.MAC_ADDRESS]}),minWidth:140,renderCell:({mac:e})=>e}];var Z=t(222102),q=t(172205);const Q=e=>e[q.U.LOOP_DETECTION_MODAL],X=(0,Z.Mz)(Q,({selectedDevice:e})=>e),J=(0,Z.Mz)(Q,({search:e})=>e),Y=(0,s.memo)(({onClick:e,id:i})=>{const{unblockedPortsMap:t,setUnblockedPortsMap:r}=v(),c=(0,s.useCallback)(()=>{r(e=>({...e,[i]:!0})),e()},[i,e,r]);return(0,n.jsx)(C.A,{justifyContent:"flex-end",paddingRight:h.xO,alignItems:"center",children:t[i]?(0,n.jsx)(b.A,{size:"inherit",color:"inherit",weight:"inherit",children:(0,n.jsx)(M.sA,{id:"COMMON_DETECTING"})}):(0,n.jsx)(g.A,{type:"button",variant:"inline",color:"danger",onClick:c,children:(0,n.jsx)(M.sA,{id:"COMMON_ACTION_UNBLOCK"})})})}),$=({items:e})=>{const i=(0,r.wA)(),t=(0,r.d4)(J),c=(0,r.d4)(X),o=e.filter(e=>{if(c&&e.mac!==c)return!1;const i=t.toLowerCase();return!(t&&!(e.mac.toLowerCase().includes(i)||e.model.toLowerCase().includes(i)||e.device_name.toLowerCase().includes(i)))}),l=(0,s.useCallback)((e,t)=>()=>{i((0,f.jx)(e,t))},[i]),d=(0,s.useCallback)(e=>(0,n.jsx)(Y,{onClick:l(e.mac,e.port_idx),id:(0,m.FS)(e.mac,e.port_idx)}),[l]);return(0,n.jsx)(N.A,{items:o,idField:"id",truncateHeaderCells:!0,columns:H,disableColumnFilters:!0,renderHoverContent:e=>e.isChild?void 0:d(e)})};var ee=t(20049),ie=t(860606),te=t(464693),ne=t(6032);const se=()=>{const e=(0,r.wA)(),[i,t]=(0,s.useState)(""),c=(0,s.useCallback)((i,n)=>{t(n),e((0,ne.pm)(n))},[e]),o=(0,s.useCallback)(()=>{t(""),e((0,ne.pm)(""))},[e]);return(0,n.jsx)(ie.A,{iconBefore:(0,n.jsx)(te.A,{size:"small"}),full:!0,onChange:c,onClear:o,value:i,variant:"secondary",placeholder:(0,M.tz)().formatMessage({id:"NETWORKS_LOGS_SEARCH"})})};var re=t(767822),ce=t(237887),oe=t(754237),le=t(177173),de=t(212635),ae=t(251905);const he=({macs:e})=>{const i=(0,r.wA)(),t=(0,r.d4)(ee.Mi),c=(0,r.d4)(X),{deviceOptions:o,clearable:l}=(0,s.useMemo)(()=>({deviceOptions:t.filter(({value:i})=>{const{type:t,id:n}=(0,ae.Se)(i);return t===de.F7.DEVICE&&e.includes(n)}),clearable:Boolean(t.find(({value:e})=>e===le.Zt))}),[t,e]),d=(0,s.useCallback)(e=>{const{type:t,id:n}=(0,ae.Se)(e.value);i((0,ne.aT)(t===de.F7.DEVICE?n:le.Zt))},[i]);return(0,n.jsx)(ce.A.Sorted,{variant:"secondary",searchable:!0,onChange:d,options:o,value:c,maxHeight:oe.W,clearable:l,renderOption:re.q})},Ae=({items:e})=>{const i=(0,r.d4)(ee.RM),{macs:t}=(0,s.useMemo)(()=>{const t=new Set;return e.forEach(e=>{i.find(i=>i.mac===e.mac)&&t.add(e.mac)}),{macs:Array.from(t)}},[e.length]);return e.length?(0,n.jsxs)(C.A,{gap:h.Ln,justifyContent:"space-between",width:"100%",children:[(0,n.jsx)(he,{macs:t}),(0,n.jsx)(se,{})]}):null},Ce=()=>{const e=(0,r.wA)(),i=(0,r.d4)(L.s),t=i.map(e=>(0,m.FS)(e.mac,e.port_idx));return(0,s.useEffect)(()=>(e((0,O.F)(void 0,{crudCacheStrategy:{type:l.e.POLLED,interval:5e3}})),()=>{e((0,d.NM)((0,O.F)(void 0,{crudCacheStrategy:{type:l.e.POLLED,interval:5e3}})))}),[e]),(0,a.A)([(0,O.F)()],(0,n.jsx)(c.A,{onRequestClose:()=>{e((0,x.AS)())},isOpen:!0,title:(0,n.jsx)(M.sA,{id:"COMMON_PORTS"}),size:"large",children:(0,n.jsx)(_,{children:(0,n.jsxs)(C.A,{gap:h.Ln,flexDirection:"column",alignItems:"start",children:[(0,n.jsx)(u.A,{icon:(0,n.jsx)(o.A,{isActive:!0,size:"original",variant:"fill"}),description:(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(M.sA,{id:"NETWORKS_LOOP_DETECTION_MODAL_MESSAGE"})," ",(0,n.jsx)(A.A,{href:j.A.loopProtection,id:"COMMON_LEARN_MORE"})]})}),(0,n.jsx)(Ae,{items:i}),(0,n.jsx)($,{items:i}),(0,n.jsx)(S,{ids:t})]})})}))}},754237(e,i,t){t.d(i,{W:()=>s,k:()=>n});const n=34,s=12*n}}]);