"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[58793],{653464(e,i,s){s.d(i,{Mw:()=>a,bx:()=>I,Vp:()=>_,v8:()=>l,$w:()=>o});var E=s(29472),t=s(193730);const n=(0,s(401042).C1)("cmd/mbb"),o=(e,i={})=>(0,E.Xj)(t.A.VERIFY_PIN,n,{cmd:t.A.VERIFY_PIN,...e},i),a=(e,i={})=>(0,E.Xj)(t.A.ESIM_ADD,n,{cmd:t.A.ESIM_ADD,...e},i),I=(e,i={})=>(0,E.Xj)(t.A.ESIM_DELETE,n,{cmd:t.A.ESIM_DELETE,...e},i),_=(e,i={})=>(0,E.Xj)(t.A.READ_INACTIVE_SLOT_SIM_CARD,n,{cmd:t.A.READ_INACTIVE_SLOT_SIM_CARD,...e},i),l=(e,i={})=>(0,E.Xj)(t.A.RESET_USAGE,n,{cmd:t.A.RESET_USAGE,...e},i)},358793(e,i,s){s.r(i),s.d(i,{default:()=>z});var E=s(274934),t=s(505817),n=s(602086),o=s(977872),a=s(843871),I=s(179102),_=s(83985),l=s(212370),c=s(830990),A=s(377067),d=s(247816),r=s(263705),C=s(590979),S=s(291508),D=s(669439),R=s(950804),x=s(947414),m=s(449339),O=s(309130),u=s(205521),j=s(869332),V=s(470070),T=s(653464),M=s(262768),p=s(754924),h=s(789562),N=s(589650),f=s(120197),g=s(100978),v=s(384783),b=s(288991);const L="DEVICE_ESIM_PROFILE_UNAVAILABLE";var U;!function(e){e[e.ACTIVATION=0]="ACTIVATION",e[e.SUCCESS=1]="SUCCESS"}(U||(U={}));const k=(0,d.A)(v.A,(0,S.A)("step"))`
  height: ${({step:e})=>e===U.SUCCESS?"unset":"320px"};
`,y=({pending:e,onTimeout:i})=>(0,E.jsxs)(g.A,{flexDirection:"column",flex:1,alignItems:"center",gap:O.Ln,children:[(0,E.jsx)(f.A,{name:"activation_code",label:(0,E.jsxs)(g.A,{alignItems:"center",gap:O.YC,children:[(0,E.jsx)(I.A,{variant:"inherit",children:(0,E.jsx)(V.sA,{id:"DEVICE_ESIM_ACTIVATION_CODE"})}),(0,E.jsx)(D.A,{description:(0,E.jsx)(V.sA,{id:"DEVICE_ENTER_ACTIVATION_CODE_TOOLTIP"}),children:(0,E.jsx)("span",{children:(0,E.jsx)(c.A,{isActive:!0,size:"original"})})})]}),type:"input",variant:"secondary",full:!0,validateOnBlur:!0,disabled:e}),e?(0,E.jsxs)(g.A,{width:"100%",flexDirection:"column",gap:O.YC,flex:1,justifyContent:"flex-end",children:[(0,E.jsx)(h.A,{size:8,duration:140,onComplete:i}),(0,E.jsx)(I.A,{color:"text-3",size:"small",children:(0,E.jsx)(V.sA,{id:"DEVICE_DOWNLOADING_ESIM_PROFILES"})})]}):(0,E.jsx)(f.A,{name:"confirmation_code",label:(0,E.jsxs)(g.A,{alignItems:"center",gap:O.YC,children:[(0,E.jsx)(I.A,{variant:"inherit",children:(0,E.jsx)(V.sA,{id:"DEVICE_ESIM_CONFIRMATION_CODE"})}),(0,E.jsx)(D.A,{description:(0,E.jsx)(V.sA,{id:"DEVICE_ESIM_CONFIRMATION_CODE_TOOLTIP"}),children:(0,E.jsx)("span",{children:(0,E.jsx)(c.A,{isActive:!0,size:"original"})})})]}),type:"input",variant:"secondary",full:!0,disabled:e})]}),P=()=>{const{themeName:e}=(0,r.u)();return(0,E.jsxs)(g.A,{flexDirection:"column",flex:1,alignItems:"center",gap:O.Ln,children:[(0,E.jsxs)(g.A,{position:"relative",children:[(0,E.jsx)(l.A,{transparent:!0,size:"header",color:t.Ay[`desktop-color-ublue-06-${e}`]}),(0,E.jsx)(g.A,{position:"absolute",right:0,bottom:0,alignItems:"center",justifyContent:"center",children:(0,E.jsx)(A.A,{size:"original",variant:"fill",color:t.Ay[`desktop-color-green-06-${e}`]})})]}),(0,E.jsxs)(g.A,{flexDirection:"column",gap:O.kc,alignItems:"center",children:[(0,E.jsx)(I.A,{color:"text-1",weight:"bold",children:(0,E.jsx)(V.sA,{id:"DEVICE_ESIM_ACTIVATED"})}),(0,E.jsx)(I.A,{color:"text-2",children:(0,E.jsx)(V.sA,{id:"DEVICE_ESIM_ACTIVATED_DESCRIPTION"})})]})]})},w=({onClose:e,mac:i,slot:s})=>{const t=(0,o.wA)(),{formatMessage:I}=(0,V.tz)(),{values:{activation_code:l,confirmation_code:c},setFieldError:A,isValid:d}=(0,a.j7)(),{mbb:r={}}=(0,o.d4)((0,n.useMemo)(()=>(0,p.tG)(i),[i])),S=(0,n.useMemo)(()=>Boolean(r.esim&&(0,M.n8)(r.esim)),[r.esim]),D=(0,n.useMemo)(()=>Boolean(r.esim&&(0,M.q5)(r.esim,r.sim?.[s])),[r.esim,r.sim,s]),[R,x]=(0,n.useState)(S),[h,f]=(0,n.useState)(U.ACTIVATION),v=(0,n.useCallback)(()=>{t((0,j.AS)()),e?.()},[e,t]),w=(0,n.useCallback)(()=>{v()},[v]),F=(0,n.useCallback)(()=>{if(!R&&!S){x(!0);try{t((0,T.Mw)({mac:i,activation_code:l,...c?{confirmation_code:c}:{}}))}catch{A("activation_code",I({id:"DEVICE_ESIM_PROFILE_UNAVAILABLE"})),x(!1)}}},[R,S,t,i,l,c,A,I]),G=(0,n.useCallback)(()=>{x(!1),A("activation_code",I({id:L}))},[I,A]);return(0,n.useEffect)(()=>{D&&f(U.SUCCESS)},[D]),(0,n.useEffect)(()=>{const e=r.esim?.last_operation?.code;switch(e){case void 0:case 0:return;default:A("activation_code",I({id:b.O3[e]??L}))}x(!1)},[I,r.esim?.last_operation?.code,A]),(0,E.jsxs)(k,{title:h!==U.SUCCESS?(0,E.jsx)(V.sA,{id:"DEVICE_ADD_ESIM"}):void 0,onRequestClose:w,size:"small",step:h,actions:h!==U.SUCCESS?[{type:"button",text:(0,E.jsx)(V.sA,{id:"COMMON_ACTION_NEXT"}),onClick:F,variant:"primary",disabled:R||!d,loader:R?"loading":void 0}]:void 0,footer:h===U.SUCCESS?(0,E.jsx)(g.A,{alignItems:"center",justifyContent:"center",padding:O.Ln,paddingTop:O.YC,children:(0,E.jsx)(_.A,{...C.A.addDataTestId(C.A.TestId.SIDE_PANEL_TRIGGER),onPress:()=>{t((0,u.XP)({type:m.H.DEVICE,id:i,tab:N.BC.SETTINGS,subId:s.toString()})),v()},children:(0,E.jsx)(V.sA,{id:"DEVICE_MANAGE_DEVICES"})})}):void 0,children:[h===U.ACTIVATION?(0,E.jsx)(y,{pending:R,onTimeout:G}):null,h===U.SUCCESS?(0,E.jsx)(P,{}):null]})},F=R.A.object().shape({activation_code:R.A.string().label("DEVICE_ESIM_ACTIVATION_CODE").matches(/^((1|2)|(LPA:(1|2)))\$(.*)?\$[a-zA-Z0-9-]+$/,{message:(0,E.jsx)(V.sA,{id:"DEVICE_ESIM_INVALID_ACTIVATION_CODE"})}).required(),confirmation_code:R.A.string().label("DEVICE_ESIM_CONFIRMATION_CODE").optional()}),G={activation_code:""},z=e=>(0,E.jsx)(a.l1,{initialValues:G,onSubmit:x.P1,validationSchema:F,validateOnMount:!0,children:(0,E.jsx)(w,{...e})})},288991(e,i,s){s.d(i,{$n:()=>_,A2:()=>o,AZ:()=>d,Cs:()=>t,Gp:()=>I,HE:()=>a,O3:()=>m,Qe:()=>l,S2:()=>R,XM:()=>E,e0:()=>D,f7:()=>S,mD:()=>c,mJ:()=>C,tG:()=>A,tl:()=>r,x_:()=>x,yr:()=>n});const E="DEVICE_ESIM_ACTIVATION_ERROR_DEFAULT",t=-1,n=0,o=1,a=2,I=104,_=105,l=113,c=122,A=123,d=124,r=125,C=126,S=127,D=209,R=601,x=602,m={[t]:E,[o]:"DEVICE_ESIM_ERROR_104",[a]:"DEVICE_ESIM_ERROR_125",[I]:"DEVICE_ESIM_ERROR_104",[_]:"DEVICE_ESIM_ERROR_104",[l]:"DEVICE_ESIM_ERROR_104",[c]:"DEVICE_ESIM_ERROR_122",[A]:"DEVICE_ESIM_ERROR_122",[d]:"DEVICE_ESIM_ERROR_122",[r]:"DEVICE_ESIM_ERROR_125",[C]:"DEVICE_ESIM_ERROR_126",[S]:"DEVICE_ESIM_ERROR_127",[D]:"DEVICE_ESIM_ERROR_209",[R]:"DEVICE_ESIM_ERROR_601",[x]:"DEVICE_ESIM_ERROR_602"}}}]);