"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[6304],{186304:(e,t,a)=>{a.r(t),a.d(t,{default:()=>P});var l=a(132196),n=a(217439),r=a(314714),i=a(48598),o=a(54227),c=a(296540),s=a(469733),E=a(171073),d=a(532419),m=a(768195),u=a(780811),A=a(302167),_=a(459449),O=a(126457),h=a(876250),C=a(294303),p=a(553432),D=a(515219),g=a(252093),f=a(566723),N=a(553089),v=a(96512),k=a(742920),S=a(6510),I=a(213583),M=a(281884),T=a(188912),R=a(564985),L=a(765562),b=a(6176),x=a(349107),y=a(71479),w=a(617147),G=a(822336);const H=(0,y.A)(w.A,{shouldForwardProp:e=>"haveOptions"!==e})`
  width: 460px;
  ${({haveOptions:e})=>e?"min-height: 200px;":""}
`,U=(0,y.A)("div")`
  padding: ${f.kc} ${f.kc} 0 ${f.kc};
  border-radius: ${G.Ay["desktop-radius-base"]};
  border: 1px solid ${({theme:{themeName:e}})=>G.Ay[`desktop-color-neutral-03-${e}`]};
`;var B=a(985370),V=a(892145),F=a(261847);const Z=({searchText:e,setSearchText:t})=>{const a=(0,c.useCallback)((e,a)=>{t((0,F.Zx)(a.toLowerCase()))},[t]),l=(0,c.useCallback)(()=>{t("")},[t]);return c.createElement(V.A,{iconBefore:c.createElement(B.A,{size:"small"}),full:!0,onChange:a,onClear:l,value:e,variant:"secondary",placeholder:(0,_.tz)().formatMessage({id:"COMMON_SEARCH"}),keepRefOnClear:!0})},$=l.AH`
  padding-left: 0;
`,K=l.AH`
  overflow-y: auto;
  height: 100%;
  min-height: 150px;
  max-height: 275px;
  padding: ${f.kc} 0 0 0;
`,P=(0,c.memo)(({activeMacs:e})=>{const[t,a]=(0,c.useState)(e),l=(0,s.useDispatch)(),y=(0,v.I)(),w=(0,s.useSelector)(A.ZZ),G=w===I.A.US.numericCode,B=w===I.A.CA.numericCode,V=(0,s.useSelector)((0,d.nH)(t)).filter(e=>(0,u.io)(e)&&(0,N.X5)(e,w)),F=V.filter(e=>(0,u.KK)(e.model,"outdoorModeSupport")),P=1===V.length||1===F.length,z=F?.[0],X=P&&z&&(0,u.KK)(z?.model,"outdoorModeSupport"),W=P&&V?.[0]&&(0,u.J2)(V[0]),J=P&&z&&!((0,u.ER)(z)||(0,u.Um)(z)),[Y,q]=(0,c.useState)(""),[Q,j]=(0,c.useState)(1===V.length?t:[]),[ee,te]=(0,c.useState)(!1),[ae,le]=(0,c.useState)(!1),[ne,re]=(0,c.useState)(!1),[ie,oe]=(0,c.useState)(X?m.Dd.OUTDOOR:m.Dd.INDOOR),ce=(e=>e.filter(({mac:e})=>Boolean(e)).map(({model:e,mac:t})=>({label:(0,S.Lm)(e),value:t,image:c.createElement(C.A,{maxWidth:20,maxHeight:20},c.createElement(b.A,{model:e,width:20,height:20})),additionalInfo:t})))(F.length?F:V),se=(0,c.useMemo)(()=>((e,t)=>e.filter(e=>"string"==typeof e.value&&e?.value&&e.value.toLowerCase()?.includes(t)||e.label.toLowerCase()?.includes(t)))(ce,Y),[ce,Y]);(0,c.useEffect)(()=>{oe(X?m.Dd.OUTDOOR:m.Dd.INDOOR)},[X]);const Ee=(0,c.useCallback)(()=>{l((0,O.AS)())},[l]),de=(0,c.useCallback)(()=>{const e=se.map(({value:e})=>e);if(ee){const t=[...Q];j(t.filter(t=>!e.includes(t)))}else j([...new Set([...Q,...e])])},[ee,se,Q]),me=(0,c.useCallback)((e,{value:t})=>{const a=Q.some(e=>e===t);j(a?Q.filter(e=>e!==t):[...Q,t])},[Q]),ue=(0,c.useCallback)(()=>{le(!0);const e=[];V.forEach(t=>{if(!Q.includes(t.mac))return;const a=(0,u.KK)(t?.model,"outdoorModeSupport"),n=(0,N.X5)(t,w)?{afc_enabled:!0}:{},r=!a||ie!==m.Dd.OUTDOOR&&P?{outdoor_mode_override:m.Gi.OFF}:{outdoor_mode_override:m.Gi.ON},i={radio_table:[]};t?.radio_table.forEach(e=>{const t={radio:e.radio,name:e.name};i.radio_table.push(e.radio===R.sx.RADIO_6E&&e?.tx_power_mode===R.PB.DISABLED?{...t,tx_power_mode:R.PB.AUTO}:t)}),e.push(l((0,E.ex)({...n,...r,...i},t._id,t.mac,{failureToast:{icon:k.C.danger,message:"COMMON_AFC_ENABLING_ERROR_TOAST"},mergeAndOverrideKeys:["radio_table"],extend:!0})))}),Promise.all(e).catch(y).finally(()=>{le(!1),Ee()})},[Q,y,V,w,ie,l,Ee,P]),Ae=(0,c.useMemo)(()=>{const e=[];P?e.push({type:"button",variant:"link",target:"_blank",text:c.createElement(_.sA,{id:"COMMON_LEARN_MORE"}),href:L.A.afcArticle,className:$}):e.push({type:"button",variant:"link",text:c.createElement(r.A,{checked:ee,id:"isSelectAllChecked",onChange:()=>te(!ee)},c.createElement(_.sA,{id:"COMMON_ACTION_SELECT_ALL"}),` (${se.length})`),onClick:de,className:$});const t=[[{type:"button",text:c.createElement(_.sA,{id:"COMMON_ACTION_CANCEL"}),autoFocus:!1,onClick:Ee},{type:"button",variant:"primary",text:c.createElement(_.sA,{id:"COMMON_ACTION_SAVE"}),autoFocus:!0,onClick:ue,disabled:0===Q.length||!ne,loader:ae?"loading":void 0}]];return[...e,...t]},[P,Ee,ue,Q.length,ne,ae,ee,se.length,de]),_e=(0,c.useMemo)(()=>G?"DEVICE_ENABLE_AFC_MODAL_HEADER_US":B?"DEVICE_ENABLE_AFC_MODAL_HEADER_CA":"DEVICE_EXTEND_6GHZ_RANGE",[G,B]);return(0,c.useEffect)(()=>{var e;te((e=Q,se.every(t=>e.includes(t.value))))},[se,Q]),(0,c.useEffect)(()=>{1===V.length&&0===Q.length&&j(t)},[t,V.length,Q.length]),(0,c.useEffect)(()=>{if(1===e.length&&!t.includes(e[0])){const l=[...new Set([...t,...e])];a(l),j(l)}},[e,t]),c.createElement(H,{title:c.createElement(_.sA,{id:!X&&P?_e:"DEVICE_ENABLE_6GHZ"}),isOpen:V.length>0,shouldCloseOnOverlayClick:!1,onRequestClose:Ee,actions:Ae,haveOptions:!!ce.length},c.createElement(C.A,{flexDirection:"column",gap:f.kc},P?c.createElement(C.A,{flexDirection:"column",alignItems:"center"},c.createElement(b.A,{model:V[0].model,width:120,height:120,size:h.Xh.LARGE}),c.createElement(C.A,{alignItems:"center",gap:f.YC},c.createElement(n.A,{size:"medium",variant:"body-primary",weight:"bold"},(0,S.Q)(V[0])),c.createElement(n.A,{size:"medium",variant:"body-primary"},(0,S.oT)(V[0]))),V[0]?.uplink?.uplink_device_name?c.createElement(C.A,{alignItems:"center"},c.createElement(T.A,{activeItem:V[0],connectionStatus:(0,M.H)(V[0].deviceState,V[0].uplink.type)})):null):null,P&&X&&J?c.createElement(p.A,null,[m.Dd.INDOOR,m.Dd.OUTDOOR].map(e=>c.createElement(o.A,{key:e,id:e,value:e,checked:ie===e,onChange:()=>oe(e)},c.createElement(C.A,{alignItems:"center",gap:f.YC},c.createElement(_.sA,{id:D.J[e]}),e===m.Dd.OUTDOOR?c.createElement(g.A,{messageId:W?"DEVICE_ENABLE_AFC_MODAL_INSTALL_MODE_OUTDOOR_6GHZ_TOOLTIP":"DEVICE_ENABLE_AFC_MODAL_INSTALL_MODE_OUTDOOR_TOOLTIP",values:{link:c.createElement(x.A,{id:"COMMON_LEARN_MORE",href:L.A.afcArticle})},variant:"outline",isInteractive:!0,portal:!0}):null)))):null,P?null:c.createElement(U,null,c.createElement(Z,{searchText:Y,setSearchText:q}),c.createElement(i.A,{options:se,handleOptionChange:me,isChecked:e=>Q.some(t=>t===e.value),isDisabled:()=>!1,within:"popover",createOptionText:()=>null,handleCreateOption:()=>null,searchValue:Y,showCreateOption:!1,isWindowed:!0,className:K})),c.createElement(C.A,{flexDirection:"column"},c.createElement(r.A,{id:"tos_agreement",checked:ne,onChange:()=>re(!ne)},c.createElement(n.A,{size:"medium",variant:"body-primary"},c.createElement(_.sA,{id:X?"DEVICE_ENABLE_6GHZ":B?"DEVICE_ENABLE_AFC_MODAL_HEADER_CA":"DEVICE_EXTEND_6GHZ_RANGE",values:{link:c.createElement(x.A,{noWrap:!0,id:"COMMON_TOS",href:L.A.termsOfServiceUrl})}}),c.createElement("br",null),c.createElement(_.sA,{id:X?"DEVICE_ENABLE_6GHZ_TOS_AGREE":B?"DEVICE_INCREASE_SPECTRUM_INDOOR_TOS_AGREE":"DEVICE_ENABLE_EXTEND_6GHZ_RANGE_TOS_AGREE",values:{link:c.createElement(x.A,{noWrap:!0,id:"COMMON_TOS",href:L.A.termsOfServiceUrl})}}))))))})}}]);