"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[28348],{358935(e,a,t){t.d(a,{X2:()=>C,lX:()=>d,uC:()=>A});var E=t(571766),s=t(29472),i=t(159469),n=t(774366);const l=`${t(290454).w}/device/:mac:`,r=`${l}/replacement-candidates`,c=`${l}/replace?replacementDeviceMac=:replacement-mac:`,o=`${l}/replace`,d=(e={},a={})=>(0,s.Kd)("replacementCandidates",`${r.replace(":mac:",e.queryParams?.mac)}`,e.queryParams?.mac,e,{...a,idField:"mac"}),A=(e,a)=>t=>t((0,s.vB)(E.aC,null,null,n.A.POST,c.replace(":mac:",e).replace(":replacement-mac:",a),{},null,{})),C=e=>a=>a((0,s.vB)(E.aC,null,null,n.A.DELETE,o.replace(":mac:",e),{},null,{failureToast:()=>({icon:i.C.danger,message:"COMMON_UNKNOWN_ERROR"})}))},752104(e,a,t){t.d(a,{A:()=>s,Q:()=>i});var E=t(765567);const s="_",i=[E.ZM,E.Je]},721398(e,a,t){t.d(a,{A:()=>l});var E=t(274934),s=t(125799),i=t(853777),n=t(470070);const l=({messageId:e,tooltipClassName:a,values:t,isInteractive:l,portal:r,variant:c="twoTone",size:o="medium"})=>(0,E.jsx)(s.A,{description:(0,E.jsx)(n.sA,{id:e,values:t}),width:210,isInteractive:l,portal:r,tooltipClassName:a,children:(0,E.jsx)(i.A,{isActive:!0,omitSvgMargin:!0,variant:c,size:o})})},418193(e,a,t){t.d(a,{A:()=>l});var E=t(274934),s=t(938984),i=t(470070),n=t(664092);const l=({has_fan:e=!1,fan_level:a})=>e&&Number.isFinite(a)?(0,E.jsxs)(n.A,{children:[(0,E.jsx)(s.A,{color:"text-2",size:"medium",children:(0,E.jsx)(i.sA,{id:"DEVICE_PROPERTY_OVERVIEW_FAN_LEVEL"})}),(0,E.jsx)(s.A,{color:"text-3",size:"medium",children:a})]}):null},446722(e,a,t){t.d(a,{A:()=>o});var E=t(274934),s=t(125799),i=t(938984),n=t(241365),l=t(600191),r=t(470070),c=t(664092);const o=({has_temperature:e=!1,overheating:a=!1,general_temperature:t})=>e&&Number.isFinite(t)?(0,E.jsxs)(c.A,{children:[(0,E.jsx)(i.A,{color:"text-2",size:"medium",children:(0,E.jsx)(r.sA,{id:"COMMON_TEMPERATURE"})}),(0,E.jsx)(i.A,{color:"text-3",size:"medium",children:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(r.sA,{id:"DEVICE_PROPERTY_OVERVIEW_TEMPERATURE_VALUE",values:{temperature:t}}),a?(0,E.jsx)(s.A,{description:(0,E.jsx)(r.sA,{id:"DEVICE_PROPERTY_OVERVIEW_TEMPERATURE_OVERHEATING"}),width:180,position:"left",className:"ml-1",style:{display:"inline-block",verticalAlign:"text-bottom"},children:(0,E.jsx)(l.A,{style:{color:n.Ay["color-danger"]}})}):null]})})]}):null},999837(e,a,t){t.d(a,{A:()=>z});var E=t(274934),s=t(977872),i=t(602086),n=t(696264),l=t(599110),r=t(159469),c=t(706925),o=t(700444),d=t(470070),A=t(222102),C=t(656466),_=t(401042),u=t(358935);var m,M,N=t(857780),R=t(570866);!function(e){e.EXISTING="existing",e.NEW="new"}(m||(m={})),function(e){e.MAC="mac",e.TYPE="type",e.MODEL="model"}(M||(M={}));var T,I=t(990330),x=t(125799),v=t(843615),p=t(853777),S=t(489714),D=t(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"}(T||(T={}));const O=(0,i.createContext)({[T.DEVICE_REPLACEMENT_MODE]:void 0,[T.SET_DEVICE_REPLACEMENT_MODE]:D.P1,[T.NEW_MAC]:void 0,[T.SET_NEW_MAC]:D.P1,[T.EXISTING_MAC]:void 0,[T.SET_EXISTING_MAC]:D.P1,[T.REPLACEMENT_CANDIDATES]:[],[T.ERROR]:void 0,[T.RESET_ERROR]:D.P1}),h=t(409844).AH`
  height: 54px;
`;var P=t(247816),g=t(309130),j=t(100978);const L=(0,P.A)(j.A)`
  align-items: center;
  gap: ${g.YC};
`,V=(0,i.memo)(()=>{const{newMac:e,setNewMac:a,error:t,resetError:s}=(0,i.useContext)(O),n=(0,i.useCallback)(({target:{value:e}})=>{a((0,S.Z)(e)),s()},[a,s]);return(0,E.jsx)(v.A,{className:h,value:e,onChange:n,onFocus:s,variant:"secondary",label:(0,E.jsxs)(L,{children:[(0,E.jsx)(d.sA,{id:"COMMON_MAC_ADDRESS"}),(0,E.jsx)(x.A,{portal:!0,width:"100%",maxWidth:248,description:(0,E.jsx)(d.sA,{id:"DEVICE_REPLACEMENT_MAC_LOCATION"}),children:(0,E.jsx)(p.A,{isActive:!0})})]}),width:"100%",invalid:t})});var b=t(237887),k=t(974390);const w=(0,i.memo)(()=>{const{replacementCandidates:e,existingMac:a,setExistingMac:t,error:s,resetError:n}=(0,i.useContext)(O),l=(0,i.useMemo)(()=>e.map(({mac:e,model:a,name:t})=>({label:t,value:e,image:(0,E.jsx)(k.A,{model:a}),additionalInfo:e})),[e]),r=(0,i.useCallback)(({value:e})=>{t(String(e)),n()},[t,n]);return(0,E.jsx)(b.A.Sorted,{value:a,label:(0,E.jsx)(d.sA,{id:"COMMON_DEVICE"}),width:"100%",searchable:!0,onChange:r,onFocus:n,maxHeight:228,options:l,invalid:s})}),f=(0,P.A)(j.A)`
  flex-direction: column;
  gap: ${g.kc};
`,W=(0,i.memo)(()=>{const{replacementCandidates:e,deviceReplacementMode:a,setDeviceReplacementMode:t,resetError:s}=(0,i.useContext)(O),n=(0,i.useMemo)(()=>e.length?[{id:m.EXISTING,children:(0,E.jsx)(d.sA,{id:"COMMON_EXISTING"}),onChange:()=>{t(m.EXISTING),s()},checked:a===m.EXISTING},{id:m.NEW,children:(0,E.jsx)(d.sA,{id:"COMMON_NEW"}),onChange:()=>{t(m.NEW),s()},checked:a===m.NEW}]:[],[e.length,a,t,s]);return(0,E.jsxs)(f,{children:[(0,E.jsx)(I.A,{direction:"row",items:n}),a===m.EXISTING?(0,E.jsx)(w,{}):null,a===m.NEW?(0,E.jsx)(V,{}):null]})}),y=(0,P.A)(j.A)`
  align-items: center;
  gap: ${g.YC};
  width: fit-content;
`;var G=t(721398);const X={[N.gQ.INCOMPATIBLE_REPLACEMENT]:"DEVICE_REPLACEMENT_DEVICE_INCOMPATIBLE_REPLACEMENT_ERROR",[N.gQ.REPLACEMENT_ALREADY_ASSIGNED]:"DEVICE_REPLACEMENT_DEVICE_REPLACEMENT_ALREADY_ASSIGNED_ERROR"},U=({mac:e,hideTooltip:a=!1})=>{const{formatMessage:t}=(0,d.tz)(),c=(0,s.wA)(),[M,I]=(0,i.useState)(!1),[x,v]=(0,i.useState)(!1),[p,S]=(0,i.useState)(m.NEW),[D,h]=(0,i.useState)(""),[P,g]=(0,i.useState)(""),[j,L]=(0,i.useState)(void 0),V=(0,s.d4)((0,i.useMemo)(()=>(e=>(0,A.Mz)((e=>(0,C.uh)((0,u.lX)({queryParams:{mac:e}})))(e),e=>(0,_.i6)(e)?.devices||[]))(e),[e])),b=(0,i.useCallback)(()=>{I(!0)},[]),k=(0,i.useCallback)(()=>{I(!1),h(""),g(""),v(!1),S(m.NEW),L(void 0)},[]),w=(0,i.useCallback)(()=>{switch(p){case m.EXISTING:return P;case m.NEW:return D;default:return}},[p,P,D]),f=(0,i.useCallback)(()=>{c((0,o.ox)({icon:r.C.success,message:"DEVICE_REPLACEMENT_DEVICE_SET",duration:3e3})),k()},[c,k]),U=(0,i.useCallback)(e=>{switch(e.apiData?.replacement_state){case N.gQ.INCOMPATIBLE_REPLACEMENT:case N.gQ.REPLACEMENT_ALREADY_ASSIGNED:L(t({id:X[e.apiData.replacement_state]}));break;default:c((0,o.ox)({icon:r.C.danger,message:"DEVICE_FAILED_TO_SET_REPLACEMENT_DEVICE",duration:3e3}))}},[c,t]),z=(0,i.useCallback)(()=>{v(!1)},[]),F=(0,i.useCallback)(()=>{v(!0),c((0,u.uC)(e,w())).then(f).catch(U).finally(z)},[c,f,U,e,w,z]),Y=(0,i.useMemo)(()=>Boolean(w().match(R.b8)),[w]),q=(0,i.useMemo)(()=>[{text:(0,E.jsx)(d.sA,{id:"COMMON_ACTION_CANCEL"}),variant:"tertiary",onClick:k},{text:(0,E.jsx)(d.sA,{id:"COMMON_ACTION_APPLY"}),variant:"primary",onClick:F,disabled:!Y||x,loader:x?"spinner":void 0}],[k,F,Y,x]),$=(0,i.useCallback)(()=>{L(void 0)},[L]),B=(0,i.useMemo)(()=>({[T.DEVICE_REPLACEMENT_MODE]:p,[T.SET_DEVICE_REPLACEMENT_MODE]:S,[T.NEW_MAC]:D,[T.SET_NEW_MAC]:h,[T.EXISTING_MAC]:P,[T.SET_EXISTING_MAC]:g,[T.REPLACEMENT_CANDIDATES]:V,[T.ERROR]:j,[T.RESET_ERROR]:$}),[p,D,P,V,j,$]);return(0,i.useEffect)(()=>{c((0,u.lX)({queryParams:{mac:e}}))},[c,e]),(0,E.jsx)(O.Provider,{value:B,children:(0,E.jsx)(n.A,{allowOverflow:!0,title:(0,E.jsx)(d.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"}),body:(0,E.jsx)(W,{}),position:"top",portal:!0,actions:q,isOpen:M,onRequestClose:k,children:(0,E.jsxs)(y,{children:[(0,E.jsx)(l.A,{type:"button",variant:"inline",size:"medium",onClick:b,children:(0,E.jsx)(d.sA,{id:"DEVICE_SET_REPLACEMENT_DEVICE"})}),a?null:(0,E.jsx)(G.A,{messageId:"DEVICE_SET_REPLACEMENT_DEVICE_DESCRIPTION",variant:"outline"})]})})})},z=(0,i.memo)(({model:e,type:a,...t})=>(0,c.G)({type:a,model:e})?(0,E.jsx)(U,{type:a,model:e,...t}):null)},696049(e,a,t){t.d(a,{H:()=>E});const E=""},706925(e,a,t){t.d(a,{G:()=>l});var E=t(956978),s=t(857780);const i=[s.bq.USW,s.bq.UAP,s.bq.USP],n=[s.W4.UDBA69F],l=({type:e,model:a})=>(i.includes(e)||n.includes(a))&&!(0,E.tNJ)({model:a})},237887(e,a,t){t.d(a,{A:()=>A});var E=t(274934),s=t(602086),i=t(977872),n=t(693371),l=t(767822),r=t(820633),c=t(308111);const o=e=>(0,E.jsx)(n.A,{renderOption:l.q,...e}),d=e=>(0,E.jsx)(o,{...e});d.Sorted=e=>{const a=(0,i.d4)(r.zi),t=(0,s.useMemo)(()=>(0,c.k)(a),[a]);return(0,E.jsx)(o,{...e,sortBy:t})};const A=d},308111(e,a,t){t.d(a,{R:()=>d,k:()=>A});var E=t(696049),s=t(350068),i=t(177173),n=t(752104),l=t(64222),r=t(332530);const c=[...new Set([E.H,n.Q.join(n.A),i.Zt,l.F,s.nc,r.Vr])],o={numeric:!0,sensitivity:"base"},d=(e,a)=>{const t=[];for(let E=e;E<=a;E+=1)t.push({value:E,label:String(E)});return t},A=e=>({value:a,label:t},{value:E,label:s})=>c.includes(a?.toString())||c.includes(E?.toString())?1/0:t?.toString().localeCompare(s?.toString(),e,o)??-1},489714(e,a,t){t.d(a,{Z:()=>s});var E=t(570866);const s=e=>e?e.replace(E.SD,"").replace(E.fA,"$&:").substring(0,17).toLowerCase():e}}]);