"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[38732],{35627:(e,t,a)=>{a.d(t,{B:()=>c,T:()=>o});var n=a(801081),l=a(25553),r=a(87485),E=a(248951);const i=(0,l.uh)((0,E.P)()),c=(0,n.Mz)(i,r.kh),s=(0,l.uh)((0,E.L)()),o=(0,n.Mz)(s,r.kh)},59372:(e,t,a)=>{a.d(t,{FH:()=>u,YG:()=>m,ad:()=>o,dA:()=>d});var n=a(801081),l=a(960407),r=a(35627),E=a(294591),i=a(477544),c=a(532419),s=a(180830);const o=(0,n.Mz)(s.K8,i.Ag,l.gm,(e,t,a)=>e.filter(({device_macs:e})=>e.includes(a)).reduce((e,{_id:a})=>[...e,...t.filter(({ap_group_ids:e})=>(e||[]).includes(a))],[])),u=(0,n.Mz)(o,e=>e.every(({enabled:e})=>!1===e)),d=(0,n.Mz)(o,e=>e.some(({enabled:e,wlan_bands:t})=>e&&(t||[]).includes(E._$.AX))),m=(0,n.Mz)(l.gm,c.vh,r.B,s.K8,(e,t,a,n)=>{if(!t.includes(e))return null;const l=n.filter(({device_macs:t})=>t.includes(e));return a.filter(({configuration:{ap_group_ids:e}})=>l.some(({_id:t})=>e.includes(t))).some(({configuration:{wlan_bands:e}})=>e.includes(E._$.AX))})},71265:(e,t,a)=>{a.d(t,{R:()=>u,k:()=>d});var n=a(280258),l=a(190497),r=a(953048),E=a(175522),i=a(936621),c=a(305988);const s=[...new Set([n.H,E.Q.join(E.A),r.Zt,i.F,l.nc,c.Vr])],o={numeric:!0,sensitivity:"base"},u=(e,t)=>{const a=[];for(let n=e;n<=t;n+=1)a.push({value:n,label:String(n)});return a},d=e=>({value:t,label:a},{value:n,label:l})=>s.includes(t?.toString())||s.includes(n?.toString())?1/0:a?.toString().localeCompare(l?.toString(),e,o)??-1},175522:(e,t,a)=>{a.d(t,{A:()=>l,Q:()=>r});var n=a(416348);const l="_",r=[n.ZM,n.Je]},211908:(e,t,a)=>{a.d(t,{A:()=>q});var n=a(469733),l=a(296540),r=a(353899),E=a(758649),i=a(742920),c=a(421130),s=a(675359),o=a(699784),u=a(801081),d=a(25553),m=a(87485),C=a(264963);const A=e=>(0,u.Mz)((e=>(0,d.uh)((0,C.lX)({queryParams:{mac:e}})))(e),e=>(0,m.i6)(e)?.devices||[]);var _,M,N=a(768195),p=a(546391);!function(e){e.EXISTING="existing",e.NEW="new"}(_||(_={})),function(e){e.MAC="mac",e.TYPE="type",e.MODEL="model"}(M||(M={}));var I,v=a(238761),T=a(271856),S=a(438628),D=a(162420),R=a(400261),O=a(874807);!function(e){e.DEVICE_REPLACEMENT_MODE="deviceReplacementMode",e.SET_DEVICE_REPLACEMENT_MODE="setDeviceReplacementMode",e.NEW_MAC="newMac",e.SET_NEW_MAC="setNewMac",e.EXISTING_MAC="existingMac",e.SET_EXISTING_MAC="setExistingMac",e.REPLACEMENT_CANDIDATES="replacementCandidates",e.ERROR="error",e.RESET_ERROR="resetError"}(I||(I={}));const g={[I.DEVICE_REPLACEMENT_MODE]:void 0,[I.SET_DEVICE_REPLACEMENT_MODE]:O.P1,[I.NEW_MAC]:void 0,[I.SET_NEW_MAC]:O.P1,[I.EXISTING_MAC]:void 0,[I.SET_EXISTING_MAC]:O.P1,[I.REPLACEMENT_CANDIDATES]:[],[I.ERROR]:void 0,[I.RESET_ERROR]:O.P1},P=(0,l.createContext)(g);const h=a(132196).AH`
  height: 54px;
`;var L=a(71479),f=a(566723),b=a(294303);const k=(0,L.A)(b.A)`
  align-items: center;
  gap: ${f.YC};
`,w=(0,l.memo)(()=>{const{newMac:e,setNewMac:t,error:a,resetError:n}=(0,l.useContext)(P),r=(0,l.useCallback)(({target:{value:e}})=>{t((0,R.Z)(e)),n()},[t,n]);return l.createElement(S.A,{className:h,value:e,onChange:r,onFocus:n,variant:"secondary",label:l.createElement(k,null,l.createElement(o.sA,{id:"COMMON_MAC_ADDRESS"}),l.createElement(T.A,{portal:!0,width:"100%",maxWidth:248,description:l.createElement(o.sA,{id:"DEVICE_REPLACEMENT_MAC_LOCATION"})},l.createElement(D.A,{isActive:!0}))),width:"100%",invalid:a})});var y=a(362412),V=a(6176);const x=(0,l.memo)(()=>{const{replacementCandidates:e,existingMac:t,setExistingMac:a,error:n,resetError:r}=(0,l.useContext)(P),E=(0,l.useMemo)(()=>e.map(({mac:e,model:t,name:a})=>({label:a,value:e,image:l.createElement(V.A,{model:t}),additionalInfo:e})),[e]),i=(0,l.useCallback)(({value:e})=>{a(String(e)),r()},[a,r]);return l.createElement(y.A.Sorted,{value:t,label:l.createElement(o.sA,{id:"COMMON_DEVICE"}),width:"100%",searchable:!0,onChange:i,onFocus:r,maxHeight:228,options:E,invalid:n})}),z=(0,L.A)(b.A)`
  flex-direction: column;
  gap: ${f.kc};
`,W=(0,l.memo)(()=>{const{replacementCandidates:e,deviceReplacementMode:t,setDeviceReplacementMode:a,resetError:n}=(0,l.useContext)(P),r=(0,l.useMemo)(()=>e.length?[{id:_.EXISTING,children:l.createElement(o.sA,{id:"COMMON_EXISTING"}),onChange:()=>{a(_.EXISTING),n()},checked:t===_.EXISTING},{id:_.NEW,children:l.createElement(o.sA,{id:"COMMON_NEW"}),onChange:()=>{a(_.NEW),n()},checked:t===_.NEW}]:[],[e.length,t,a,n]);return l.createElement(z,null,l.createElement(v.A,{direction:"row",items:r}),t===_.EXISTING?l.createElement(x,null):null,t===_.NEW?l.createElement(w,null):null)}),G=(0,L.A)(b.A)`
  align-items: center;
  gap: ${f.YC};
  width: fit-content;
`;var X=a(252093);const B={[N.gQ.INCOMPATIBLE_REPLACEMENT]:"DEVICE_REPLACEMENT_DEVICE_INCOMPATIBLE_REPLACEMENT_ERROR",[N.gQ.REPLACEMENT_ALREADY_ASSIGNED]:"DEVICE_REPLACEMENT_DEVICE_REPLACEMENT_ALREADY_ASSIGNED_ERROR"},$=({mac:e,hideTooltip:t=!1})=>{const{formatMessage:a}=(0,o.tz)(),c=(0,n.useDispatch)(),[u,d]=(0,l.useState)(!1),[m,M]=(0,l.useState)(!1),[v,T]=(0,l.useState)(_.NEW),[S,D]=(0,l.useState)(""),[R,O]=(0,l.useState)(""),[g,h]=(0,l.useState)(void 0),L=(0,n.useSelector)((0,l.useMemo)(()=>A(e),[e])),f=(0,l.useCallback)(()=>{d(!0)},[]),b=(0,l.useCallback)(()=>{d(!1),D(""),O(""),M(!1),T(_.NEW),h(void 0)},[]),k=(0,l.useCallback)(()=>{switch(v){case _.EXISTING:return R;case _.NEW:return S;default:return}},[v,R,S]),w=(0,l.useCallback)(()=>{c((0,s.ox)({icon:i.C.success,message:"DEVICE_REPLACEMENT_DEVICE_SET",duration:3e3})),b()},[c,b]),y=(0,l.useCallback)(e=>{switch(e.apiData?.replacement_state){case N.gQ.INCOMPATIBLE_REPLACEMENT:case N.gQ.REPLACEMENT_ALREADY_ASSIGNED:h(a({id:B[e.apiData.replacement_state]}));break;case N.gQ.CANNOT_REPLACE:default:c((0,s.ox)({icon:i.C.danger,message:"DEVICE_FAILED_TO_SET_REPLACEMENT_DEVICE",duration:3e3}))}},[c,a]),V=(0,l.useCallback)(()=>{M(!1)},[]),x=(0,l.useCallback)(()=>{M(!0),c((0,C.uC)(e,k())).then(w).catch(y).finally(V)},[c,w,y,e,k,V]),z=(0,l.useMemo)(()=>Boolean(k().match(p.b8)),[k]),$=(0,l.useMemo)(()=>[{text:l.createElement(o.sA,{id:"COMMON_ACTION_CANCEL"}),variant:"tertiary",onClick:b},{text:l.createElement(o.sA,{id:"COMMON_ACTION_APPLY"}),variant:"primary",onClick:x,disabled:!z||m,loader:m?"spinner":void 0}],[b,x,z,m]),q=(0,l.useCallback)(()=>{h(void 0)},[h]),Q=(0,l.useMemo)(()=>({[I.DEVICE_REPLACEMENT_MODE]:v,[I.SET_DEVICE_REPLACEMENT_MODE]:T,[I.NEW_MAC]:S,[I.SET_NEW_MAC]:D,[I.EXISTING_MAC]:R,[I.SET_EXISTING_MAC]:O,[I.REPLACEMENT_CANDIDATES]:L,[I.ERROR]:g,[I.RESET_ERROR]:q}),[v,S,R,L,g,q]);return(0,l.useEffect)(()=>{c((0,C.lX)({queryParams:{mac:e}}))},[c,e]),l.createElement(P.Provider,{value:Q},l.createElement(r.A,{allowOverflow:!0,title:l.createElement(o.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"}),body:l.createElement(W,null),position:"top",portal:!0,actions:$,isOpen:u,onRequestClose:b},l.createElement(G,null,l.createElement(E.A,{type:"button",variant:"inline",size:"medium",onClick:f},l.createElement(o.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"})),t?null:l.createElement(X.A,{messageId:"DEVICE_SET_REPLACEMENT_DEVICE_DESCRIPTION",variant:"outline"}))))},q=(0,l.memo)(({model:e,type:t,...a})=>(0,c.G)({type:t,model:e})?l.createElement($,{type:t,model:e,...a}):null)},252093:(e,t,a)=>{a.d(t,{A:()=>i});var n=a(296540),l=a(271856),r=a(162420),E=a(699784);const i=({messageId:e,tooltipClassName:t,values:a,isInteractive:i,portal:c,variant:s="twoTone",size:o="medium"})=>n.createElement(l.A,{description:n.createElement(E.sA,{id:e,values:a}),width:210,isInteractive:i,portal:c,tooltipClassName:t},n.createElement(r.A,{isActive:!0,omitSvgMargin:!0,variant:s,size:o}))},264963:(e,t,a)=>{a.d(t,{X2:()=>m,lX:()=>u,uC:()=>d});var n=a(516693),l=a(691189),r=a(742920),E=a(887831);const i="/v2/api/site/{site}/device/:mac:",c=`${i}/replacement-candidates`,s=`${i}/replace?replacementDeviceMac=:replacement-mac:`,o=`${i}/replace`,u=(e={},t={})=>(0,l.Kd)("replacementCandidates",`${c.replace(":mac:",e.queryParams?.mac)}`,e.queryParams?.mac,e,{...t,idField:"mac"}),d=(e,t)=>a=>a((0,l.vB)(n.aC,null,null,E.A.POST,s.replace(":mac:",e).replace(":replacement-mac:",t),{},null,{})),m=e=>t=>t((0,l.vB)(n.aC,null,null,E.A.DELETE,o.replace(":mac:",e),{},null,{failureToast:()=>({icon:r.C.danger,message:"COMMON_UNKNOWN_ERROR"})}))},284428:(e,t,a)=>{a.d(t,{Im:()=>c,iL:()=>s,mQ:()=>E,pv:()=>r,q:()=>i});var n=a(296540),l=a(451449);function r(){return(0,n.useContext)(l.I)}function E(){return r().fields}function i(){return r().tooltipPopovers}function c(){return r().tooltipIcons}function s(){return r().labels}},362412:(e,t,a)=>{a.d(t,{A:()=>u});var n=a(469733),l=a(296540),r=a(436331),E=a(805837),i=a(282556),c=a(71265);const s=e=>l.createElement(r.A,{renderOption:E.q,...e}),o=e=>l.createElement(s,{...e});o.Sorted=e=>{const t=(0,n.useSelector)(i.zi),a=(0,l.useMemo)(()=>(0,c.k)(t),[t]);return l.createElement(s,{...e,sortBy:a})};const u=o},400261:(e,t,a)=>{a.d(t,{Z:()=>l});var n=a(546391);const l=e=>e?e.replace(n.SD,"").replace(n.fA,"$&:").substring(0,17).toLowerCase():e},421130:(e,t,a)=>{a.d(t,{G:()=>i});var n=a(780811),l=a(768195);const r=[l.bq.USW,l.bq.UAP],E=[l.W4.UDBA69F],i=({type:e,model:t})=>(r.includes(e)||E.includes(t))&&!(0,n.tNJ)({model:t})},451449:(e,t,a)=>{a.d(t,{I:()=>n});const n=(0,a(296540).createContext)({fields:!1,labels:!1,tooltipPopovers:!1,tooltipIcons:!1})},766624:(e,t,a)=>{a.d(t,{A:()=>c});var n=a(296540),l=a(271856),r=a(709690),E=a(284428),i=a(566723);const c=({description:e,isInteractive:t,portal:a=!0,cursorType:c,title:s,position:o,width:u,iconProps:d,disabled:m=!1})=>{const C=(0,E.Im)()||m,A=(0,E.q)();return n.createElement(l.A,{description:e,portal:a,isInteractive:t,style:{display:"flex",alignItems:"center"},cursorType:c,title:s,position:o,width:u,disableHover:A},n.createElement(r.A,{isActive:!0,size:"original",opacity:C?i.xN:void 0,...d}))}},772317:(e,t,a)=>{a.d(t,{A:()=>R});var n,l=a(592563),r=a(296540),E=a(469733),i=a(217439),c=a(187483),s=a(699784),o=a(689965),u=a(86571),d=a(801081);!function(e){e.OPEN_MODAL="openModal"}(n||(n={}));const m=(0,d.Mz)(c.zn,e=>void 0!==e[n.OPEN_MODAL]);var C=a(523275),A=a(840279),_=a(919952);const M=e=>e[_.U.UIDB]||(0,C.A)(),N=(0,d.Mz)(M,({version:e})=>Boolean(e)),p=(0,d.Mz)(M,({devices:e})=>e||(0,A.A)());var I=a(765562),v=a(79871);const T=()=>{const e=(0,E.useDispatch)(),t=(0,E.useSelector)(N);return(0,r.useEffect)(()=>{t||(async()=>{const t=await fetch(I.A.fingerprintPublicDatabasePath),a=await t.json();e((0,v.$)(a))})()},[t,e]),t},S=({uidbDevice:e})=>{const t=(0,E.useSelector)(c.zn),a=t?.[n.OPEN_MODAL];return a?r.createElement(l.A,{onClick:()=>a(e)},r.createElement(i.A,{size:"medium",color:"inherit"},r.createElement(s.sA,{id:"DEVICE_SHOW_DETAILS"}))):null},D=({shortname:e})=>{const t=(0,E.useSelector)((e=>(0,d.Mz)(p,t=>t.find(t=>t.shortnames?.includes(e))||(0,C.A)()))(e));return T(),t?.compliance?r.createElement(o.A,{type:o.I.ACCORDION,items:[{id:"compliance",label:r.createElement(u.A,{id:"COMMON_COMPLIANCE"}),renderContent:()=>r.createElement(S,{uidbDevice:t}),openByDefault:!0}]}):null},R=({shortname:e})=>(0,E.useSelector)(m)?r.createElement(D,{shortname:e}):null}}]);