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