"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[5850],{706840(e,s,t){t.d(s,{t2:()=>A,Kg:()=>l,hJ:()=>h,ut:()=>_,g0:()=>c,gh:()=>r,fH:()=>d});var i=t(29472),o=t(193730);const a=`${t(290454).J}/cmd/lte`,n=e=>e&&e.data&&e.data[0],r=e=>e&&e.apiMsg,l=({mac:e,username:s,password:t,token:r})=>l=>l((0,i.Xj)(o.A.AUTH_DEVICE,a,{mac:e,ubic_username:s,x_ubic_password:t,ubic_2fa_token:r||void 0})).then(n),A=e=>s=>s((0,i.Xj)(o.A.ACTIVATE_TRIAL,a,e)),d=e=>s=>s((0,i.Xj)(o.A.UPDATE_DEVICE,a,e)),c=e=>s=>s((0,i.Xj)(o.A.CHECK_PAYMENT_PAST_DUE,a,e)).then(n),_=e=>s=>s((0,i.Xj)(o.A.PAYMENT_METHODS,a,e)).then(n),h=({macOrMacs:e,username:s,password:t,token:r})=>l=>l((0,i.Xj)(o.A.CHECK_SUBSCRIPTION,a,{macs:"string"==typeof e?[e]:e,ubic_username:s,x_ubic_password:t,ubic_2fa_token:r})).then(n)},69834(e,s,t){var i;t.d(s,{f:()=>i}),function(e){e.API_ERROR_LTE_DEVICE_UNAUTHORIZED="API_ERROR_LTE_DEVICE_UNAUTHORIZED",e.API_ERROR_INCORRECT_CREDENTIALS="API_ERROR_INCORRECT_CREDENTIALS",e.API_ERROR_TOKEN_2FA_REQUIRED="API_ERROR_TOKEN_2FA_REQUIRED",e.API_ERROR_INVALID_2FA_TOKEN="API_ERROR_INVALID_2FA_TOKEN"}(i||(i={}))},19445(e,s,t){t.d(s,{A:()=>f});var i=t(274934),o=t(602086),a=t(418398),n=t(938984),r=t(814557),l=t(843615),A=t(247816),d=t(263705),c=t(409844),_=t(443502),h=t(309130),u=t(652347),E=t(120197),p=t(100978),m=t(470070),x=t(171056);const T=c.AH`
  height: 100%;
`,R=(0,A.A)("div")`
  margin-top: ${h.Ln};
  text-align: left;
  line-height: 18px;
  font-size: ${({theme:{fontSizes:e}})=>e[0]}px;
`,C=(0,A.A)("div")`
  margin-top: ${h.ew};
  display: flex;
  justify-content: center;
`,I=(0,A.A)("div")`
  width: 34px;
  height: 47px;
  text-align: center;
  line-height: 45px;
  border: ${({theme:{themeName:e}})=>r.Ay[`desktop-border-divider-${e}`]};
  font-size: 30px;
  font-weight: ${r.Ay["desktop-font-weight-semibold"]};
  margin: 0 ${({theme:{space:e}})=>e[3]}px;
  cursor: text;
`,O=(0,A.A)(E.A)`
  position: absolute;
  width: 284px;
  height: 47px;
  left: calc(50% - 142px);
  opacity: 0;

  input {
    width: 100% !important;
    height: 100% !important;
    border: none;
  }
`,S=(0,A.A)(p.A)`
  margin-top: ${h.S2};
  margin-bottom: ${h.xO};
  text-align: left;
`,g=(0,A.A)(n.A)`
  flex: 1;
  margin-left: ${h.xO};
`,b=(0,A.A)("input")`
  display: none;
`,f=(0,a.Zz)(m.j4,d.b)(({values:{sso2FA:e,ssoToken:s="",ssoUsername:t,ssoPassword:a,tos:n},hideOwnerDetailsText:r=!1,setFieldValue:A,handleSubmit:h,isSubmitting:f,isValid:N,dirty:U,showTOS:k})=>{const{colors:{text:j}}=(0,d.u)(),{formatMessage:v}=(0,m.tz)(),D=f||(e?6!==s.length:!(N&&U&&(!k||n))),[L,w]=(0,o.useState)(!1),P=(0,o.useCallback)(()=>{w(!0)},[]),V=(0,o.useCallback)(()=>{w(!1)},[]),y=(0,o.useCallback)(e=>{e?.preventDefault?.(),e?.stopPropagation?.(),D||h()},[D,h]);(0,o.useEffect)(()=>{f||6!==s.length||y()},[s]);const M=[...new Array(6)].map((e,t)=>{return(0,i.jsx)(I,{className:L&&s.length===t?(o=j,c.AH`
  border-color: ${_.hu};
  position: relative;

  &:after {
    position: absolute;
    display: block;
    content: '';
    width: 1px;
    height: 36px;
    top: 5px;
    left: 4px;
    background: ${o};

    animation: ${c.i7`
            0% {
                opacity: 1;
            }
            69% {
                opacity: 1;
            }
            70% {
                opacity: 0;
            }
            100% {
                opacity: 0;
            }
        `} 1.2s ease 0s infinite;
  }
`):void 0,children:s[t]||""},`sso-token-char-${t.toString()}`);var o});return(0,i.jsxs)("form",{onSubmit:y,autoComplete:"off",children:[(0,i.jsxs)(i.Fragment,e?{children:[(0,i.jsxs)(C,{children:[M,(0,i.jsx)(O,{name:"ssoToken",maxLength:"6",onFocus:P,onBlur:V,containerWrapperClassName:T,inputContentClassName:T})]}),(0,i.jsx)(u.A,{fieldName:"ssoToken"})]}:{children:[(0,i.jsxs)(p.A,{flexDirection:"column",alignItems:"flex-start",children:[(0,i.jsx)(l.A,{label:v({id:"LTE_SSO_LOGIN_LABEL_EMAIL_OR_USERNAME"}),name:"ssoUsername",value:t,onChange:e=>A("ssoUsername",e.target.value||""),full:!0}),(0,i.jsx)(u.A,{fieldName:"ssoUsername"})]}),(0,i.jsxs)(p.A,{flexDirection:"column",alignItems:"flex-start",children:[(0,i.jsx)(l.A,{label:v({id:"COMMON_PASSWORD"}),name:"ssoPassword",value:a,type:"password",onChange:e=>A("ssoPassword",e.target.value||""),full:!0}),(0,i.jsx)(u.A,{fieldName:"ssoPassword"})]}),r?null:(0,i.jsx)(R,{children:(0,i.jsx)(m.sA,{id:"DEVICE_ULTE_SETUP_ACCOUNT_DETAILS"})}),k?(0,i.jsxs)(S,{justifyContent:"space-between",alignItems:"center",children:[(0,i.jsx)(E.A,{label:"DEVICE_ULTE_SETUP_LABEL_ACCEPT_TOS",name:"tos",type:"checkbox"}),(0,i.jsx)(g,{children:(0,i.jsx)(m.sA,{id:"DEVICE_ULTE_SETUP_LABEL_ACCEPT_TOS",values:{link:(0,i.jsx)("a",{href:x.Ay.LEGAL_USE_TOS,target:"_blank",rel:"noopener noreferrer",children:(0,i.jsx)(m.sA,{id:"COMMON_TOS"})})}})})]}):null]}),(0,i.jsx)(b,{type:"submit"})]})})},93298(e,s,t){t.d(s,{A:()=>T});var i=t(274934),o=t(814557),a=t(847399),n=t(856639),r=t(247816),l=t(309130),A=t(384783),d=t(291508);const c=(0,r.A)(A.A,(0,d.A)("originalSize"))`
  ${({originalSize:e})=>e?"":"width: 500px;"}
  padding: 24px;
`,_=(0,r.A)("header",(0,d.A)("onRequestClose"))`
  position: relative;
  text-align: center;
`,h=(0,r.A)("div")`
  font-size: ${({theme:{fontSizes:e}})=>e[3]}px;
  font-weight: ${o.Ay["desktop-font-weight-semibold"]};
  margin-bottom: ${({theme:{space:e}})=>e[4]}px;
`,u=(0,r.A)("div")`
  width: 345px;
  line-height: 18px;
  margin: 0 auto ${({theme:{space:e}})=>e[5]}px;
`,E=(0,r.A)(n.A)`
  position: absolute;
  top: 0;
  left: 0;
  cursor: pointer;
  color: ${({theme:{colors:{subtleText:e}}})=>e};
  width: 16px;
  height: 16px;
`,p=(0,r.A)(a.A)`
  position: absolute;
  top: 0;
  right: 0;
  cursor: pointer;
  color: ${({theme:{colors:{subtleText:e}}})=>e};
`,m=(0,r.A)("div")`
  max-height: 340px;
  overflow: auto;
`,x=(0,r.A)("div")`
  text-align: center;
  width: 100%;
  min-height: ${l.ZH};
  line-height: 18px;
  margin: 0 auto 8px;
`,T=({headerBackButtonAction:e,headerTitle:s,headerSubTitle:t,onClose:o,actions:a,children:n,originalSize:r=!1,...l})=>{const A=(0,i.jsxs)(_,{children:[e?(0,i.jsx)(E,{actionable:!0,onClick:e}):null,(0,i.jsx)(h,{children:s}),(0,i.jsx)(p,{actionable:!0,onClick:o}),t?(0,i.jsx)(u,{children:t}):null]});return(0,i.jsx)(c,{onRequestClose:o,originalSize:r,size:"small",header:A,actions:a,...l,children:(0,i.jsx)(m,{children:(0,i.jsx)(x,{children:n})})})}},805850(e,s,t){t.r(s),t.d(s,{default:()=>g});var i=t(418398),o=t(977872),a=t(843871),n=t(159469),r=t(950804),l=t(700444),A=t(869332),d=t(355108),c=t(594633),_=t(69834),h=t(706840),u=t(570801),E=t(412927),p=t(333015),m=t(754924),x=t(352210),T=t(274934),R=t(602086),C=t(470070),I=t(93298),O=t(19445);const S=(0,a.bk)({enableReinitialize:!0,isInitialValid:!0,mapPropsToValues:({ssoUsername:e=""})=>({ssoUsername:e,ssoPassword:"",ssoToken:"",tos:!1,sso2FA:!1,openRemoteController:!1}),validationSchema:r.A.object().shape({ssoUsername:r.A.string().label("LTE_SSO_LOGIN_LABEL_EMAIL_OR_USERNAME").required(),ssoPassword:r.A.string().label("COMMON_PASSWORD").required(),tos:r.A.boolean(),ssoToken:r.A.string(),sso2FA:r.A.boolean(),openRemoteController:r.A.boolean()}),handleSubmit:({ssoUsername:e,ssoPassword:s,ssoToken:t},{props:{macs:i,devices:o,checkLteSubscription:a,createToast:r,formatMessage:l,fetchInfo:A,hideModal:d,showLteDeviceUnavailable:c},setFieldValue:h,setErrors:u,setSubmitting:E})=>{E(!0),a({username:e||void 0,password:s||void 0,token:t||void 0,macOrMacs:i}).then(async({user_uuid:e})=>{o.some(s=>!(0,p._D)(s,e))?c():(await A(),d())}).catch(({apiMsg:e})=>{switch(x.API_STRING_TRANSLATION[e]){case _.f.API_ERROR_INCORRECT_CREDENTIALS:u({ssoUsername:l({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"}),ssoPassword:l({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"})});break;case _.f.API_ERROR_INVALID_2FA_TOKEN:u({ssoToken:l({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"})}),h("ssoToken","");break;case _.f.API_ERROR_TOKEN_2FA_REQUIRED:h("sso2FA",!0);break;default:r({type:n.C.danger,message:"DEVICE_SSO_ACTIONS_AUTH_ERROR"})}E(!1)})}}),g=(0,i.Zz)((0,o.Ng)((e,{macs:s})=>{const t=(0,u.Pk)(e);return{env:(0,c.S$)(e),ssoUsername:(0,u.rU)(e)||t,ssoUuid:t,devices:(0,m.ID)(e).filter(({mac:e})=>s.includes(e))}},{hideModal:A.AS,createToast:l.ox,checkLteSubscription:h.hJ,fetchInfo:E.N,showLteDeviceUnavailable:d.Zo}),S)(({isValid:e,dirty:s,isSubmitting:t,setFieldValue:i,hideModal:o,values:{sso2FA:a,ssoToken:n=""},values:r,handleSubmit:l,errors:A})=>{const d=t||(a?6!==n.length:!(e&&s)),c=(0,R.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),d||l()},[d]),_=(0,R.useCallback)(()=>{a&&i("sso2FA",!1)},[a,i]),h=[{text:(0,T.jsx)(C.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:o},{text:(0,T.jsx)(C.sA,{id:"COMMON_ACTION_VERIFY"}),onClick:c,variant:"primary",disabled:d,loader:t?"spinner":void 0,type:"submit"}];return(0,T.jsx)(I.A,{onClose:o,headerTitle:(0,T.jsx)(C.sA,{id:"LTE_SUBSCRIPTION_ACCOUNT_HEADER"}),headerSubTitle:(0,T.jsx)(C.sA,{id:a?"LTE_SUBSCRIPTION_ACCOUNT_SUB_HEADER_2FA":"LTE_SUBSCRIPTION_ACCOUNT_SUB_HEADER"}),headerBackButtonAction:a?_:void 0,actions:h,originalSize:!0,children:(0,T.jsx)(O.A,{handleSubmit:l,setFieldValue:i,values:r,errors:A,isSubmitting:t,isValid:e,dirty:s,hideOwnerDetailsText:!0})})})}}]);