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