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