"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[90548],{358935(e,t,a){a.d(t,{X2:()=>m,lX:()=>d,uC:()=>_});var s=a(571766),i=a(29472),n=a(159469),o=a(774366);const r=(0,a(401042).T7)("device/:mac:"),l=`${r}/replacement-candidates`,E=`${r}/replace?replacementDeviceMac=:replacement-mac:`,c=`${r}/replace`,d=(e={},t={})=>(0,i.Kd)("replacementCandidates",`${l.replace(":mac:",e.queryParams?.mac)}`,e.queryParams?.mac,e,{...t,idField:"mac"}),_=(e,t)=>a=>a((0,i.vB)(s.aC,null,null,o.A.POST,E.replace(":mac:",e).replace(":replacement-mac:",t),{},null,{})),m=e=>t=>t((0,i.vB)(s.aC,null,null,o.A.DELETE,c.replace(":mac:",e),{},null,{failureToast:()=>({icon:n.C.danger,message:"COMMON_UNKNOWN_ERROR"})}))},752104(e,t,a){a.d(t,{A:()=>i,Q:()=>n});var s=a(765567);const i="_",n=[s.ZM,s.Je]},721398(e,t,a){a.d(t,{A:()=>r});var s=a(274934),i=a(548941),n=a(247368),o=a(470070);const r=({messageId:e,tooltipClassName:t,values:a,isInteractive:r,portal:l,variant:E="twoTone",size:c="medium"})=>(0,s.jsx)(i.A,{description:(0,s.jsx)(o.sA,{id:e,values:a}),width:210,isInteractive:r,portal:l,tooltipClassName:t,children:(0,s.jsx)(n.A,{isActive:!0,omitSvgMargin:!0,variant:E,size:c})})},948803(e,t,a){a.d(t,{A:()=>l});var s=a(274934),i=a(179102),n=a(347625),o=a(470070),r=a(664092);const l=({model:e})=>(0,s.jsxs)(r.A,{children:[(0,s.jsx)(i.A,{color:"text-2",size:"medium",children:(0,s.jsx)(o.sA,{id:"COMMON_MODEL"})}),(0,s.jsx)(i.A,{color:"text-3",size:"medium",children:(0,n.Lm)(e)})]})},999837(e,t,a){a.d(t,{A:()=>q});var s=a(274934),i=a(977872),n=a(602086),o=a(13790),r=a(526744),l=a(159469),E=a(706925),c=a(700444),d=a(470070),_=a(222102),m=a(15989),A=a(401042),u=a(358935);var C,p,v=a(857780),M=a(570866);!function(e){e.EXISTING="existing",e.NEW="new"}(C||(C={})),function(e){e.MAC="mac",e.TYPE="type",e.MODEL="model"}(p||(p={}));var N,x=a(183028),I=a(548941),T=a(699709),S=a(247368),R=a(489714),j=a(947414);!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"}(N||(N={}));const h=(0,n.createContext)({[N.DEVICE_REPLACEMENT_MODE]:void 0,[N.SET_DEVICE_REPLACEMENT_MODE]:j.P1,[N.NEW_MAC]:void 0,[N.SET_NEW_MAC]:j.P1,[N.EXISTING_MAC]:void 0,[N.SET_EXISTING_MAC]:j.P1,[N.REPLACEMENT_CANDIDATES]:[],[N.ERROR]:void 0,[N.RESET_ERROR]:j.P1}),D=a(409844).AH`
  height: 54px;
`;var O=a(247816),P=a(309130),g=a(100978);const w=(0,O.A)(g.A)`
  align-items: center;
  gap: ${P.YC};
`,b=(0,n.memo)(()=>{const{newMac:e,setNewMac:t,error:a,resetError:i}=(0,n.useContext)(h),o=(0,n.useCallback)(({target:{value:e}})=>{t((0,R.Z)(e)),i()},[t,i]);return(0,s.jsx)(T.A,{className:D,value:e,onChange:o,onFocus:i,variant:"secondary",label:(0,s.jsxs)(w,{children:[(0,s.jsx)(d.sA,{id:"COMMON_MAC_ADDRESS"}),(0,s.jsx)(I.A,{portal:!0,width:"100%",maxWidth:248,description:(0,s.jsx)(d.sA,{id:"DEVICE_REPLACEMENT_MAC_LOCATION"}),children:(0,s.jsx)(S.A,{isActive:!0})})]}),width:"100%",invalid:a})});var L=a(237887),k=a(974390);const y=(0,n.memo)(()=>{const{replacementCandidates:e,existingMac:t,setExistingMac:a,error:i,resetError:o}=(0,n.useContext)(h),r=(0,n.useMemo)(()=>e.map(({mac:e,model:t,name:a})=>({label:a,value:e,image:(0,s.jsx)(k.A,{model:t}),additionalInfo:e})),[e]),l=(0,n.useCallback)(({value:e})=>{a(String(e)),o()},[a,o]);return(0,s.jsx)(L.A.Sorted,{value:t,label:(0,s.jsx)(d.sA,{id:"COMMON_DEVICE"}),width:"100%",searchable:!0,onChange:l,onFocus:o,maxHeight:228,options:r,invalid:i})}),f=(0,O.A)(g.A)`
  flex-direction: column;
  gap: ${P.kc};
`,V=(0,n.memo)(()=>{const{replacementCandidates:e,deviceReplacementMode:t,setDeviceReplacementMode:a,resetError:i}=(0,n.useContext)(h),o=(0,n.useMemo)(()=>e.length?[{id:C.EXISTING,children:(0,s.jsx)(d.sA,{id:"COMMON_EXISTING"}),onChange:()=>{a(C.EXISTING),i()},checked:t===C.EXISTING},{id:C.NEW,children:(0,s.jsx)(d.sA,{id:"COMMON_NEW"}),onChange:()=>{a(C.NEW),i()},checked:t===C.NEW}]:[],[e.length,t,a,i]);return(0,s.jsxs)(f,{children:[(0,s.jsx)(x.A,{direction:"row",items:o}),t===C.EXISTING?(0,s.jsx)(y,{}):null,t===C.NEW?(0,s.jsx)(b,{}):null]})}),W=(0,O.A)(g.A)`
  align-items: center;
  gap: ${P.YC};
  width: fit-content;
`;var G=a(721398);const X={[v.gQ.INCOMPATIBLE_REPLACEMENT]:"DEVICE_REPLACEMENT_DEVICE_INCOMPATIBLE_REPLACEMENT_ERROR",[v.gQ.REPLACEMENT_ALREADY_ASSIGNED]:"DEVICE_REPLACEMENT_DEVICE_REPLACEMENT_ALREADY_ASSIGNED_ERROR"},B=({mac:e,hideTooltip:t=!1})=>{const{formatMessage:a}=(0,d.tz)(),E=(0,i.wA)(),[p,x]=(0,n.useState)(!1),[I,T]=(0,n.useState)(!1),[S,R]=(0,n.useState)(C.NEW),[j,D]=(0,n.useState)(""),[O,P]=(0,n.useState)(""),[g,w]=(0,n.useState)(void 0),b=(0,i.d4)((0,n.useMemo)(()=>(e=>(0,_.Mz)((e=>(0,m.uh)((0,u.lX)({queryParams:{mac:e}})))(e),e=>(0,A.i6)(e)?.devices||[]))(e),[e])),L=(0,n.useCallback)(()=>{x(!0)},[]),k=(0,n.useCallback)(()=>{x(!1),D(""),P(""),T(!1),R(C.NEW),w(void 0)},[]),y=(0,n.useCallback)(()=>{switch(S){case C.EXISTING:return O;case C.NEW:return j;default:return}},[S,O,j]),f=(0,n.useCallback)(()=>{E((0,c.ox)({icon:l.C.success,message:"DEVICE_REPLACEMENT_DEVICE_SET",duration:3e3})),k()},[E,k]),B=(0,n.useCallback)(e=>{switch(e.apiData?.replacement_state){case v.gQ.INCOMPATIBLE_REPLACEMENT:case v.gQ.REPLACEMENT_ALREADY_ASSIGNED:w(a({id:X[e.apiData.replacement_state]}));break;default:E((0,c.ox)({icon:l.C.danger,message:"DEVICE_FAILED_TO_SET_REPLACEMENT_DEVICE",duration:3e3}))}},[E,a]),q=(0,n.useCallback)(()=>{T(!1)},[]),Y=(0,n.useCallback)(()=>{T(!0),E((0,u.uC)(e,y())).then(f).catch(B).finally(q)},[E,f,B,e,y,q]),z=(0,n.useMemo)(()=>Boolean(y().match(M.b8)),[y]),$=(0,n.useMemo)(()=>[{text:(0,s.jsx)(d.sA,{id:"COMMON_ACTION_CANCEL"}),variant:"tertiary",onClick:k},{text:(0,s.jsx)(d.sA,{id:"COMMON_ACTION_APPLY"}),variant:"primary",onClick:Y,disabled:!z||I,loader:I?"spinner":void 0}],[k,Y,z,I]),F=(0,n.useCallback)(()=>{w(void 0)},[w]),U=(0,n.useMemo)(()=>({[N.DEVICE_REPLACEMENT_MODE]:S,[N.SET_DEVICE_REPLACEMENT_MODE]:R,[N.NEW_MAC]:j,[N.SET_NEW_MAC]:D,[N.EXISTING_MAC]:O,[N.SET_EXISTING_MAC]:P,[N.REPLACEMENT_CANDIDATES]:b,[N.ERROR]:g,[N.RESET_ERROR]:F}),[S,j,O,b,g,F]);return(0,n.useEffect)(()=>{E((0,u.lX)({queryParams:{mac:e}}))},[E,e]),(0,s.jsx)(h.Provider,{value:U,children:(0,s.jsx)(o.A,{allowOverflow:!0,title:(0,s.jsx)(d.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"}),body:(0,s.jsx)(V,{}),position:"top",portal:!0,actions:$,isOpen:p,onRequestClose:k,children:(0,s.jsxs)(W,{children:[(0,s.jsx)(r.A,{type:"button",variant:"inline",size:"medium",onClick:L,children:(0,s.jsx)(d.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"})}),t?null:(0,s.jsx)(G.A,{messageId:"DEVICE_SET_REPLACEMENT_DEVICE_DESCRIPTION",variant:"outline"})]})})})},q=(0,n.memo)(({model:e,type:t,...a})=>(0,E.G)({type:t,model:e})?(0,s.jsx)(B,{type:t,model:e,...a}):null)},718968(e,t,a){a.r(t),a.d(t,{default:()=>A});var s=a(274934),i=a(241092),n=a(979653),o=a(808202),r=a(872926),l=a(23377),E=a(189042),c=a(384780),d=a(383550),_=a(216082),m=a(109700);const A=({activeItem:e,activeItem:{name:t,adopted:a,mac:A,type:u,model:C,ethernet_overrides:p,port_table:v,lan_ip:M,ipv6:N,displayable_version:x,uptime:I,sys_stats:T,ip:S,detailed_states:{device_near_power_limit:R}={device_near_power_limit:!1},total_used_power:j,total_max_power:h,config_network:D,"system-stats":O,psu_table:P,shortname:g,uplink:w,oob_info:b,device_mode_override:L}})=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(d.A,{activeItem:e,showPortOverview:!0,hidePortsButton:!0,children:(0,s.jsx)(E.A,{activeItem:e,showPortsButton:!0,showCaptureButton:!0})}),(0,s.jsx)(r.A,{ip:S,adopted:a,config_network:D}),(0,s.jsx)(o.A,{mac:A,type:u,model:C,device_near_power_limit:R,total_used_power:j,total_max_power:h}),(0,s.jsx)(c.A,{activeItem:e}),(0,s.jsx)(i.A,{psu_table:P}),(0,s.jsx)(n.A,{name:t,model:C,type:u,ip:S,uplink:w,lan_ip:M,ipv6:N,mac:A,displayable_version:x,connection_network_id:e.connection_network_id,uptime:I,sys_stats:T,systemStatsMem:O?.mem,total_used_power:j,ethernet_overrides:p,port_table:v,device_mode_override:L}),(0,s.jsx)(l.A,{activeItem:e}),(0,s.jsx)(m.A,{oob_info:b,type:u,uplink:w,device_mode_override:L}),(0,s.jsx)(_.A,{shortname:g})]})},979653(e,t,a){a.d(t,{A:()=>p});var s=a(274934),i=a(906701),n=a(100978),o=a(535322),r=a(857780),l=a(893762),E=a(766022),c=a(382583),d=a(948803),_=a(725870),m=a(924453),A=a(664613),u=a(597377),C=a(643334);const p=({name:e,model:t,ip:a,lan_ip:p,ipv6:v,mac:M,connection_network_id:N,displayable_version:x,uptime:I,sys_stats:T,systemStatsMem:S,type:R,total_used_power:j,device_mode_override:h,deviceState:D,ethernet_overrides:O,port_table:P,uplink:g})=>{const w=h===r.Yp.MANAGED_SHADOW_GATEWAY;return(0,s.jsx)(o.A,{children:(0,s.jsxs)(n.A,{height:"100%",flexDirection:"column",children:[(0,s.jsx)(d.A,{model:t}),w?null:(0,s.jsx)(u.A,{ip:a,lan_ip:p,type:R,ethernet_overrides:O,port_table:P,uplink:g,device_mode_override:h}),w?null:(0,s.jsx)(i.A,{ipv6_address:v}),w?null:(0,s.jsx)(c.A,{connection_network_id:N}),(0,s.jsx)(m.A,{mac:M}),(0,s.jsx)(C.A,{displayable_version:x,mac:M,name:e,model:t,type:R,uptime:I,deviceState:D}),(0,s.jsx)(l.A,{uptime:I}),w?null:(0,s.jsx)(_.A,{systemStatsMem:S}),w?null:(0,s.jsx)(A.A,{sys_stats:T}),w?null:(0,s.jsx)(E.A,{totalPower:j})]})})}},696049(e,t,a){a.d(t,{H:()=>s});const s=""},706925(e,t,a){a.d(t,{G:()=>r});var s=a(956978),i=a(857780);const n=[i.bq.USW,i.bq.UAP,i.bq.USP],o=[i.W4.UDBA69F],r=({type:e,model:t})=>(n.includes(e)||o.includes(t))&&!(0,s.tNJ)({model:t})},237887(e,t,a){a.d(t,{A:()=>_});var s=a(274934),i=a(602086),n=a(977872),o=a(310075),r=a(711892),l=a(820633),E=a(308111);const c=e=>(0,s.jsx)(o.A,{renderOption:r.q,...e}),d=e=>(0,s.jsx)(c,{...e});d.Sorted=e=>{const t=(0,n.d4)(l.zi),a=(0,i.useMemo)(()=>(0,E.k)(t),[t]);return(0,s.jsx)(c,{...e,sortBy:a})};const _=d},308111(e,t,a){a.d(t,{R:()=>d,k:()=>_});var s=a(696049),i=a(350068),n=a(177173),o=a(752104),r=a(64222),l=a(230853);const E=[...new Set([s.H,o.Q.join(o.A),n.Zt,r.F,i.nc,l.Vr])],c={numeric:!0,sensitivity:"base"},d=(e,t)=>{const a=[];for(let s=e;s<=t;s+=1)a.push({value:s,label:String(s)});return a},_=e=>({value:t,label:a},{value:s,label:i})=>E.includes(t?.toString())||E.includes(s?.toString())?1/0:a?.toString().localeCompare(i?.toString(),e,c)??-1},489714(e,t,a){a.d(t,{Z:()=>i});var s=a(570866);const i=e=>e?e.replace(s.SD,"").replace(s.fA,"$&:").substring(0,17).toLowerCase():e}}]);