"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[99432],{477051(e,t,i){i.r(t),i.d(t,{default:()=>X});var s,o,T=i(274934),r=i(814557),A=i(602086),u=i(977872),E=i(938984),l=i(847399),S=i(343954),n=i(247816),_=i(213920),a=i(401004),c=i(724081),m=i(100978),R=i(541819),d=i(974390),h=i(869332),p=i(470070),I=i(598990),N=i(314229),O=i(434521),C=i(857780),x=i(45978),L=i(754924),U=i(384783),B=i(890932);!function(e){e[e.INTRO_A=1]="INTRO_A",e[e.TEST_A=2]="TEST_A",e[e.INTRO_B=3]="INTRO_B",e[e.TEST_B=4]="TEST_B",e[e.RESULT=5]="RESULT"}(s||(s={})),function(e){e[e.SUCCESS=1]="SUCCESS",e[e.FIRST_FAILURE=2]="FIRST_FAILURE",e[e.SECOND_FAILURE=3]="SECOND_FAILURE"}(o||(o={}));const g=[s.INTRO_A,s.TEST_A,s.INTRO_B,s.TEST_B,s.RESULT],b=(0,n.A)(m.A)`
  gap: 14px;
  margin: 16px;
`,j=(0,n.A)("div")`
  flex-grow: 1;
  border: ${({theme:{themeName:e}})=>r.Ay[`desktop-border-divider-${e}`]};
  height: 2px;
`,v=(0,n.A)(S.A)`
  color: ${({theme:{themeName:e}})=>r.Ay[`desktop-color-green-06-${e}`]};
`,F=(0,n.A)(l.A)`
  color: ${({theme:{themeName:e}})=>r.Ay[`desktop-color-red-06-${e}`]};
`,f=(0,n.A)(m.A)`
  align-items: center;
  justify-content: center;
  color: white;
  background-color: ${({theme:{themeName:e}})=>r.Ay[`desktop-color-ublue-03-${e}`]};
  width: 20px;
  height: 20px;
  border-radius: 50%;
`,D=(0,n.A)(f)`
  color: white;
  background-color: ${({theme:{themeName:e}})=>r.Ay[`desktop-color-ublue-06-${e}`]};
  width: 28px;
  height: 28px;
  border: 4px solid
    ${({theme:{themeName:e}})=>r.Ay[`desktop-color-ublue-03-${e}`]};
`,w=({steps:e,currentStep:t,success:i,value:s})=>void 0!==i?(0,T.jsx)(i?v:F,{height:20,width:20}):e.includes(t)?(0,T.jsx)(D,{children:s}):e.every(e=>e<t)?(0,T.jsx)(v,{height:20,width:20}):(0,T.jsx)(f,{children:s}),y=({step:e,success:t})=>(0,T.jsxs)(b,{alignItems:"center",children:[(0,T.jsx)(w,{steps:[s.INTRO_A,s.TEST_A],currentStep:e,value:1}),(0,T.jsx)(j,{}),(0,T.jsx)(w,{steps:[s.INTRO_B,s.TEST_B],currentStep:e,value:2}),(0,T.jsx)(j,{}),(0,T.jsx)(w,{steps:[s.RESULT],currentStep:e,success:t,value:3})]}),M=(0,n.A)(m.A)`
  position: relative;
`,k=(0,n.A)(d.A)`
  object-fit: cover;
`,$=(0,n.A)(S.A)`
  color: ${({theme:{themeName:e}})=>r.Ay[`desktop-color-green-06-${e}`]};
  position: absolute;
  right: 5px;
  bottom: 5px;
`,Y=(0,n.A)(l.A)`
  color: ${({theme:{themeName:e}})=>r.Ay[`desktop-color-red-06-${e}`]};
  position: absolute;
  right: 5px;
  bottom: 5px;
`,G=(0,n.A)(U.A)`
  width: 415px;
  .contentClassName {
    > div span {
      line-height: 24px;
    }
  }
`,z=(0,n.A)(m.A)`
  height: 116px;
  width: 353px;
`,P=(0,n.A)(E.A)`
  margin: 16px 0;
`,X=({batteryMac:e,hostMac:t})=>{const i=(0,u.wA)(),r=(0,u.d4)(B.p),[l,S]=(0,A.useState)({timeoutA:void 0,timeoutB:void 0,step:s.INTRO_A,result:void 0,tryAgain:!1}),{step:n}=l,m=(0,A.useCallback)(()=>{l.timeoutA&&clearTimeout(l.timeoutA),l.timeoutB&&clearTimeout(l.timeoutB),i((0,h.AS)())},[i,l.timeoutA,l.timeoutB]),d=((e,t)=>{switch(e){case s.INTRO_A:return"TEST_BATTERY_MODAL_TEST_A_DESC";case s.TEST_A:case s.TEST_B:return"TEST_BATTERY_MODAL_TESTING_DESC";case s.INTRO_B:return"TEST_BATTERY_MODAL_TEST_B_DESC"}switch(t){case o.SUCCESS:return"TEST_BATTERY_MODAL_TEST_SUCCESS";case o.FIRST_FAILURE:return"TEST_BATTERY_MODAL_TEST_FIRST_FAILURE";case o.SECOND_FAILURE:return"TEST_BATTERY_MODAL_TEST_SECOND_FAILURE"}return""})(n,l.result),U=(0,u.d4)((0,A.useMemo)(()=>(0,L.tG)(e),[e])),b=(0,u.d4)((0,A.useMemo)(()=>(0,L.tG)(t),[t])),j=(0,O.S9)(b),v=(0,N.Pi)(b.psu_table),F=(0,N.vl)(b.psu_table);(0,A.useEffect)(()=>{if(n===s.TEST_A&&!l.timeoutA){const e=()=>{l.timeoutA&&clearTimeout(l.timeoutA),S({...l,step:s.RESULT,timeoutA:void 0,result:l.result===o.FIRST_FAILURE?o.SECOND_FAILURE:o.FIRST_FAILURE})};j===x.g.DISCONNECTED&&e();const t=setTimeout(e,75e3);S({...l,timeoutA:t})}},[n,l.timeoutA]),(0,A.useEffect)(()=>{n!==s.TEST_A&&(n!==s.RESULT||l.result!==o.FIRST_FAILURE)||!l.timeoutA||F?.online||j!==x.g.CONNECTED||!v?.online&&U.batteryState!==C.Rv.POWER_DELIVER||(clearTimeout(l.timeoutA),S({...l,timeoutA:void 0,step:s.INTRO_B}))},[F?.online,v?.online,U.batteryState,n,l]),(0,A.useEffect)(()=>{if(n===s.TEST_B&&l.result!==o.SECOND_FAILURE&&!l.timeoutA&&!l.timeoutB){const e=setTimeout(()=>{clearTimeout(l.timeoutB),S({...l,timeoutB:void 0,step:s.RESULT,result:l.result===o.FIRST_FAILURE?o.SECOND_FAILURE:o.FIRST_FAILURE})},75e3);S({...l,timeoutB:e})}},[n,l]),(0,A.useEffect)(()=>{n===s.TEST_B&&!l.result&&l.timeoutB&&F?.online&&(clearTimeout(l.timeoutB),S({...l,timeoutB:void 0,step:s.RESULT,result:o.SUCCESS}))},[F?.online,n,l]);const f=()=>{var e;n===s.RESULT?i((0,h.AS)()):S({...l,step:(e=n,g[Math.min(g.indexOf(e)+1,g.length-1)])})},D=n===s.RESULT?"COMMON_ACTION_DONE":"COMMON_ACTION_NEXT";let w,X="";n!==s.INTRO_A||l.tryAgain?n===s.RESULT&&l.result===o.FIRST_FAILURE?(X="COMMON_ACTION_TRY_AGAIN",w=()=>S({...l,step:s.INTRO_A})):n===s.RESULT&&l.result===o.SECOND_FAILURE&&(X="COMMON_CONTACT_SUPPORT"):(X="TEST_BATTERY_MODAL_SKIP",w=m);const q=l.result&&l.result===o.SUCCESS;let K="";n===s.INTRO_A?K="Animation_01.svg":n===s.INTRO_B?K="Animation_03.svg":n!==s.TEST_A&&n!==s.TEST_B||(K="Animation_02.svg");const V=(0,A.useMemo)(()=>[!!X&&{variant:"tertiary",text:(0,T.jsx)(p.sA,{id:X}),onClick:w,disabled:!(!l.timeoutA&&!l.timeoutB),type:"button"},{variant:"primary",text:(0,T.jsx)(p.sA,{id:D}),onClick:f,disabled:!(!l.timeoutA&&!l.timeoutB),type:"button"}].filter(e=>e),[l,n,w]);return(0,c.A)([(0,I.Uc)(),(0,a.Zi)(_.B.SETTINGS)],(0,T.jsxs)(G,{allowOverflow:!0,title:(0,T.jsx)(E.A,{weight:"bold",size:"large",children:(0,T.jsx)(p.sA,{id:"TEST_BATTERY_MODAL_TITLE"})}),size:"small",contentClassName:"contentClassName",actions:V,onRequestClose:m,children:[(0,T.jsx)(k,{model:U.model,width:352,height:112,size:R.Xh.LARGE}),(0,T.jsx)(y,{step:n,success:q}),n!==s.RESULT?(0,T.jsx)(z,{marginLeft:12,justifyContent:"center",alignItems:"center",children:(0,T.jsx)("object",{width:"100%","aria-label":`SmartBattery ${K}`,data:`${r}/SmartBattery/${K}`})}):(0,T.jsxs)(M,{children:[(0,T.jsx)(k,{model:U.model,width:352,height:112,size:R.Xh.LARGE}),(0,T.jsx)(l.result===o.SUCCESS?$:Y,{height:40,width:40})]}),(0,T.jsx)(P,{size:"medium",children:d?(0,T.jsx)(p.sA,{id:d}):null})]}))}}}]);