"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[37309],{237309:(e,t,i)=>{i.r(t),i.d(t,{default:()=>j});var o,r,T=i(469733),l=i(296540),E=i(927099),s=i(793336),n=i(618983),u=i(71479),a=i(834959),A=i(413357),m=i(582724),c=i(294303),S=i(876250),_=i(6176),R=i(126457),h=i(699784),I=i(457311),d=i(757167),p=i(837612),O=i(768195),C=i(602197),N=i(532419),L=i(705426),B=i(130851);!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"}(o||(o={})),function(e){e[e.SUCCESS=1]="SUCCESS",e[e.FIRST_FAILURE=2]="FIRST_FAILURE",e[e.SECOND_FAILURE=3]="SECOND_FAILURE"}(r||(r={}));const U=[o.INTRO_A,o.TEST_A,o.INTRO_B,o.TEST_B,o.RESULT];var g=i(822336);const f=(0,u.A)(c.A)`
  gap: 14px;
  margin: 16px;
`,v=(0,u.A)("div")`
  flex-grow: 1;
  border: ${({theme:{themeName:e}})=>g.Ay[`desktop-border-divider-${e}`]};
  height: 2px;
`,F=(0,u.A)(n.A)`
  color: ${({theme:{motifPalette:{green06:e}}})=>e};
`,b=(0,u.A)(s.A)`
  color: ${({theme:{motifPalette:{red06:e}}})=>e};
`,D=(0,u.A)(c.A)`
  align-items: center;
  justify-content: center;
  color: white;
  background-color: ${({theme:{motifPalette:{uBlue03:e}}})=>e};
  width: 20px;
  height: 20px;
  border-radius: 50%;
`,w=(0,u.A)(D)`
  color: white;
  background-color: ${({theme:{motifPalette:{uBlue06:e}}})=>e};
  width: 28px;
  height: 28px;
  border: 4px solid
    ${({theme:{motifPalette:{uBlue03:e}}})=>e};
`,x=({steps:e,currentStep:t,success:i,value:o})=>void 0!==i?i?l.createElement(F,{height:20,width:20}):l.createElement(b,{height:20,width:20}):e.includes(t)?l.createElement(w,null,o):e.every(e=>e<t)?l.createElement(F,{height:20,width:20}):l.createElement(D,null,o),M=({step:e,success:t})=>l.createElement(f,{alignItems:"center"},l.createElement(x,{steps:[o.INTRO_A,o.TEST_A],currentStep:e,value:1}),l.createElement(v,null),l.createElement(x,{steps:[o.INTRO_B,o.TEST_B],currentStep:e,value:2}),l.createElement(v,null),l.createElement(x,{steps:[o.RESULT],currentStep:e,success:t,value:3})),y=(0,u.A)(c.A)`
  position: relative;
`,k=(0,u.A)(_.A)`
  object-fit: cover;
`,P=(0,u.A)(n.A)`
  color: ${({theme:{motifPalette:{green06:e}}})=>e};
  position: absolute;
  right: 5px;
  bottom: 5px;
`,$=(0,u.A)(s.A)`
  color: ${({theme:{motifPalette:{red06:e}}})=>e};
  position: absolute;
  right: 5px;
  bottom: 5px;
`,Y=(0,u.A)(L.A)`
  width: 415px;
  .contentClassName {
    > div span {
      line-height: 24px;
    }
  }
`,G=(0,u.A)(c.A)`
  height: 116px;
  width: 353px;
`,z=(0,u.A)(E.A)`
  margin: 16px 0;
`,j=({batteryMac:e,hostMac:t})=>{const i=(0,T.useDispatch)(),s=(0,T.useSelector)(B.p),[n,u]=(0,l.useState)({timeoutA:void 0,timeoutB:void 0,step:o.INTRO_A,result:void 0,tryAgain:!1}),{step:c}=n,_=(0,l.useCallback)(()=>{n.timeoutA&&clearTimeout(n.timeoutA),n.timeoutB&&clearTimeout(n.timeoutB),i((0,R.AS)())},[i,n.timeoutA,n.timeoutB]),L=((e,t)=>{switch(e){case o.INTRO_A:return"TEST_BATTERY_MODAL_TEST_A_DESC";case o.TEST_A:case o.TEST_B:return"TEST_BATTERY_MODAL_TESTING_DESC";case o.INTRO_B:return"TEST_BATTERY_MODAL_TEST_B_DESC"}switch(t){case r.SUCCESS:return"TEST_BATTERY_MODAL_TEST_SUCCESS";case r.FIRST_FAILURE:return"TEST_BATTERY_MODAL_TEST_FIRST_FAILURE";case r.SECOND_FAILURE:return"TEST_BATTERY_MODAL_TEST_SECOND_FAILURE"}return""})(c,n.result),g=(0,T.useSelector)((0,l.useMemo)(()=>(0,N.tG)(e),[e])),f=(0,T.useSelector)((0,l.useMemo)(()=>(0,N.tG)(t),[t])),v=(0,p.S9)(f),F=(0,d.Pi)(f.psu_table),b=(0,d.vl)(f.psu_table);(0,l.useEffect)(()=>{if(c===o.TEST_A&&!n.timeoutA){const e=()=>{n.timeoutA&&clearTimeout(n.timeoutA),u({...n,step:o.RESULT,timeoutA:void 0,result:n.result===r.FIRST_FAILURE?r.SECOND_FAILURE:r.FIRST_FAILURE})};v===C.g.DISCONNECTED&&e();const t=setTimeout(e,75e3);u({...n,timeoutA:t})}},[c,n.timeoutA]),(0,l.useEffect)(()=>{c!==o.TEST_A&&(c!==o.RESULT||n.result!==r.FIRST_FAILURE)||!n.timeoutA||b?.online||v!==C.g.CONNECTED||!F?.online&&g.batteryState!==O.Rv.POWER_DELIVER||(clearTimeout(n.timeoutA),u({...n,timeoutA:void 0,step:o.INTRO_B}))},[b?.online,F?.online,g.batteryState,c,n]),(0,l.useEffect)(()=>{if(c===o.TEST_B&&n.result!==r.SECOND_FAILURE&&!n.timeoutA&&!n.timeoutB){const e=setTimeout(()=>{clearTimeout(n.timeoutB),u({...n,timeoutB:void 0,step:o.RESULT,result:n.result===r.FIRST_FAILURE?r.SECOND_FAILURE:r.FIRST_FAILURE})},75e3);u({...n,timeoutB:e})}},[c,n]),(0,l.useEffect)(()=>{c===o.TEST_B&&!n.result&&n.timeoutB&&b?.online&&(clearTimeout(n.timeoutB),u({...n,timeoutB:void 0,step:o.RESULT,result:r.SUCCESS}))},[b?.online,c,n]);const D=()=>{var e;c===o.RESULT?i((0,R.AS)()):u({...n,step:(e=c,U[Math.min(U.indexOf(e)+1,U.length-1)])})},w=c===o.RESULT?"COMMON_ACTION_DONE":"COMMON_ACTION_NEXT";let x,j="";c!==o.INTRO_A||n.tryAgain?c===o.RESULT&&n.result===r.FIRST_FAILURE?(j="COMMON_ACTION_TRY_AGAIN",x=()=>u({...n,step:o.INTRO_A})):c===o.RESULT&&n.result===r.SECOND_FAILURE&&(j="COMMON_CONTACT_SUPPORT"):(j="TEST_BATTERY_MODAL_SKIP",x=_);const X=n.result&&n.result===r.SUCCESS;let q="";c===o.INTRO_A?q="Animation_01.svg":c===o.INTRO_B?q="Animation_03.svg":c!==o.TEST_A&&c!==o.TEST_B||(q="Animation_02.svg");const K=(0,l.useMemo)(()=>[!!j&&{variant:"tertiary",text:l.createElement(h.sA,{id:j}),onClick:x,disabled:!(!n.timeoutA&&!n.timeoutB),type:"button"},{variant:"primary",text:l.createElement(h.sA,{id:w}),onClick:D,disabled:!(!n.timeoutA&&!n.timeoutB),type:"button"}].filter(e=>e),[n,c,x]);return(0,m.A)([(0,I.Uc)(),(0,A.Zi)(a.B.SETTINGS)],l.createElement(Y,{allowOverflow:!0,title:l.createElement(E.A,{weight:"bold",size:"header-xs"},l.createElement(h.sA,{id:"TEST_BATTERY_MODAL_TITLE"})),size:"small",contentClassName:"contentClassName",actions:K,onRequestClose:_},l.createElement(k,{model:g.model,width:352,height:112,size:S.Xh.LARGE}),l.createElement(M,{step:c,success:X}),c!==o.RESULT?l.createElement(G,{marginLeft:12,justifyContent:"center",alignItems:"center"},l.createElement("object",{width:"100%","aria-label":`SmartBattery ${q}`,data:`${s}/SmartBattery/${q}`})):l.createElement(y,null,l.createElement(k,{model:g.model,width:352,height:112,size:S.Xh.LARGE}),n.result===r.SUCCESS?l.createElement(P,{height:40,width:40}):l.createElement($,{height:40,width:40})),l.createElement(z,{size:"body"},l.createElement(h.sA,{id:L}))))}}}]);