"use strict";(self.webpackChunkunifiNetworkUi=self.webpackChunkunifiNetworkUi||[]).push([[4602],{688094:(e,t,a)=>{a.d(t,{t2:()=>c,Kg:()=>l,hJ:()=>_,ut:()=>m,g0:()=>A,gh:()=>r,fH:()=>E});var s=a(294201),o=a(691189);const n="/api/s/{site}/cmd/lte",i=e=>e&&e.data&&e.data[0],r=e=>e&&e.apiMsg,l=({mac:e,username:t,password:a,token:r})=>l=>l((0,o.Xj)(s.A.AUTH_DEVICE,n,{mac:e,ubic_username:t,x_ubic_password:a,ubic_2fa_token:r||void 0})).then(i),c=e=>t=>t((0,o.Xj)(s.A.ACTIVATE_TRIAL,n,e)),E=e=>t=>t((0,o.Xj)(s.A.UPDATE_DEVICE,n,e)),A=e=>t=>t((0,o.Xj)(s.A.CHECK_PAYMENT_PAST_DUE,n,e)).then(i),m=e=>t=>t((0,o.Xj)(s.A.PAYMENT_METHODS,n,e)).then(i),_=({macOrMacs:e,username:t,password:a,token:r})=>l=>l((0,o.Xj)(s.A.CHECK_SUBSCRIPTION,n,{macs:"string"==typeof e?[e]:e,ubic_username:t,x_ubic_password:a,ubic_2fa_token:r})).then(i)},685375:(e,t,a)=>{var s;a.d(t,{f:()=>s}),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"}(s||(s={}))},748598:(e,t,a)=>{a.d(t,{A:()=>f});var s=a(296540),o=a(438628),n=a(927099),i=a(71479),r=a(132196),l=a(822336),c=a(998837),E=a(868238),A=a(388151),m=a(459449),_=a(923831),d=a(294303),u=a(574137),p=a(566723),h=a(372382);const R=r.AH`
  height: 100%;
`,T=(0,i.A)("div")`
  margin-top: ${p.Ln};
  text-align: left;
  line-height: 18px;
  font-size: ${({theme:{fontSizes:e}})=>e[0]}px;
`,C=(0,i.A)("div")`
  margin-top: ${p.ew};
  display: flex;
  justify-content: center;
`,I=(0,i.A)("div")`
  width: 34px;
  height: 47px;
  text-align: center;
  line-height: 45px;
  border: ${({theme:{themeName:e}})=>l.Ay[`desktop-border-divider-${e}`]};
  font-size: 30px;
  font-weight: ${l.Ay["desktop-font-weight-semibold"]};
  margin: 0 ${({theme:{space:e}})=>e[3]}px;
  cursor: text;
`,O=(0,i.A)(A.A)`
  position: absolute;
  width: 284px;
  height: 47px;
  left: calc(50% - 142px);
  opacity: 0;

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

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

    animation: ${r.i7`
            0% {
                opacity: 1;
            }
            69% {
                opacity: 1;
            }
            70% {
                opacity: 0;
            }
            100% {
                opacity: 0;
            }
        `} 1.2s ease 0s infinite;
  }
`):void 0},o);var i});return s.createElement("form",{onSubmit:M,autoComplete:"off"},e?s.createElement(s.Fragment,null,s.createElement(C,null,F,s.createElement(O,{name:"ssoToken",maxLength:"6",onFocus:V,onBlur:y,containerWrapperClassName:R,inputContentClassName:R})),s.createElement(h.A,{fieldName:"ssoToken"})):s.createElement(s.Fragment,null,s.createElement(d.A,{flexDirection:"column",alignItems:"flex-start"},s.createElement(o.A,{label:D({id:"LTE_SSO_LOGIN_LABEL_EMAIL_OR_USERNAME"}),name:"ssoUsername",value:a,onChange:e=>E("ssoUsername",e.target.value||""),full:!0}),s.createElement(h.A,{fieldName:"ssoUsername"})),s.createElement(d.A,{flexDirection:"column",alignItems:"flex-start"},s.createElement(o.A,{label:D({id:"COMMON_PASSWORD"}),name:"ssoPassword",value:n,type:"password",onChange:e=>E("ssoPassword",e.target.value||""),full:!0}),s.createElement(h.A,{fieldName:"ssoPassword"})),l?null:s.createElement(T,null,s.createElement(m.sA,{id:"DEVICE_ULTE_SETUP_ACCOUNT_DETAILS"})),U?s.createElement(g,{justifyContent:"space-between",alignItems:"center"},s.createElement(A.A,{label:"DEVICE_ULTE_SETUP_LABEL_ACCEPT_TOS",name:"tos",type:"checkbox"}),s.createElement(S,null,s.createElement(m.sA,{id:"DEVICE_ULTE_SETUP_LABEL_ACCEPT_TOS",values:{link:s.createElement("a",{href:_.Ay.LEGAL_USE_TOS,target:"_blank",rel:"noopener noreferrer"},s.createElement(m.sA,{id:"COMMON_TOS"}))}}))):null),s.createElement(b,{type:"submit"}))})},431253:(e,t,a)=>{a.d(t,{A:()=>R});var s=a(350312),o=a(793336),n=a(296540),i=a(71479),r=a(822336),l=a(566723),c=a(705426);const E=(0,i.A)(c.A,{shouldForwardProp:e=>"originalSize"!==e})`
  ${({originalSize:e})=>e?"":"width: 500px;"}
  padding: 24px;
`,A=(0,i.A)("header",{shouldForwardProp:e=>"onRequestClose"!==e})`
  position: relative;
  text-align: center;
`,m=(0,i.A)("div")`
  font-size: ${({theme:{fontSizes:e}})=>e[3]}px;
  font-weight: ${r.Ay["desktop-font-weight-semibold"]};
  margin-bottom: ${({theme:{space:e}})=>e[4]}px;
`,_=(0,i.A)("div")`
  width: 345px;
  line-height: 18px;
  margin: 0 auto ${({theme:{space:e}})=>e[5]}px;
`,d=(0,i.A)(s.A)`
  position: absolute;
  top: 0;
  left: 0;
  cursor: pointer;
  color: ${({theme:{colors:{subtleText:e}}})=>e};
  width: 16px;
  height: 16px;
`,u=(0,i.A)(o.A)`
  position: absolute;
  top: 0;
  right: 0;
  cursor: pointer;
  color: ${({theme:{colors:{subtleText:e}}})=>e};
`,p=(0,i.A)("div")`
  max-height: 340px;
  overflow: auto;
`,h=(0,i.A)("div")`
  text-align: center;
  width: 100%;
  min-height: ${l.ZH};
  line-height: 18px;
  margin: 0 auto 8px;
`,R=({headerBackButtonAction:e,headerTitle:t,headerSubTitle:a,onClose:s,actions:o,children:i,originalSize:r=!1,...l})=>{const c=n.createElement(A,null,!!e&&n.createElement(d,{actionable:!0,onClick:e}),n.createElement(m,null,t),n.createElement(u,{actionable:!0,onClick:s}),!!a&&n.createElement(_,null,a));return n.createElement(E,{onRequestClose:s,originalSize:r,size:"small",header:c,actions:o,...l},n.createElement(p,null,n.createElement(h,null,i)))}},724602:(e,t,a)=>{a.r(t),a.d(t,{default:()=>b});var s=a(868238),o=a(469733),n=a(951272),i=a(870443),r=a(953141),l=a(532419),c=a(685375),E=a(688094),A=a(417378),m=a(126457),_=a(675359),d=a(811569),u=a(742920),p=a(367370),h=a(198494),R=a(902786),T=a(296540),C=a(459449),I=a(431253),O=a(748598);const g=({isValid:e,dirty:t,isSubmitting:a,setFieldValue:s,hideModal:o,values:{sso2FA:n,ssoToken:i=""},values:r,handleSubmit:l,errors:c})=>{const E=a||(n?6!==i.length:!(e&&t)),A=(0,T.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),E||l()},[E]),m=(0,T.useCallback)(()=>{n&&s("sso2FA",!1)},[n,s]),_=[{text:T.createElement(C.sA,{id:"COMMON_ACTION_CANCEL"}),onClick:o},{text:T.createElement(C.sA,{id:"COMMON_ACTION_VERIFY"}),onClick:A,variant:"primary",disabled:E,loader:a?"spinner":void 0,type:"submit"}];return T.createElement(I.A,{onClose:o,headerTitle:T.createElement(C.sA,{id:"LTE_SUBSCRIPTION_ACCOUNT_HEADER"}),headerSubTitle:T.createElement(C.sA,{id:n?"LTE_SUBSCRIPTION_ACCOUNT_SUB_HEADER_2FA":"LTE_SUBSCRIPTION_ACCOUNT_SUB_HEADER"}),headerBackButtonAction:n?m:void 0,actions:_,originalSize:!0},T.createElement(O.A,{handleSubmit:l,setFieldValue:s,values:r,errors:c,isSubmitting:a,isValid:e,dirty:t,hideOwnerDetailsText:!0}))},S=(0,n.bk)({enableReinitialize:!0,isInitialValid:!0,mapPropsToValues:({ssoUsername:e=""})=>({ssoUsername:e,ssoPassword:"",ssoToken:"",tos:!1,sso2FA:!1,openRemoteController:!1}),validationSchema:i.A.object().shape({ssoUsername:i.A.string().label("LTE_SSO_LOGIN_LABEL_EMAIL_OR_USERNAME").required(),ssoPassword:i.A.string().label("COMMON_PASSWORD").required(),tos:i.A.boolean(),ssoToken:i.A.string(),sso2FA:i.A.boolean(),openRemoteController:i.A.boolean()}),handleSubmit:({ssoUsername:e,ssoPassword:t,ssoToken:a},{props:{macs:s,devices:o,checkLteSubscription:n,createToast:i,formatMessage:l,fetchInfo:E,hideModal:A,showLteDeviceUnavailable:m},setFieldValue:_,setErrors:d,setSubmitting:p})=>{p(!0);n({username:e||void 0,password:t||void 0,token:a||void 0,macOrMacs:s}).then(async({user_uuid:e})=>{o.some(t=>!(0,R._D)(t,e))?m():(await E(),A())}).catch(({apiMsg:e})=>{switch(r.r[e]){case c.f.API_ERROR_INCORRECT_CREDENTIALS:d({ssoUsername:l({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"}),ssoPassword:l({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"})});break;case c.f.API_ERROR_INVALID_2FA_TOKEN:d({ssoToken:l({id:"DEVICE_SSO_ACTIONS_AUTH_INVALID_ERROR"})}),_("ssoToken","");break;case c.f.API_ERROR_TOKEN_2FA_REQUIRED:_("sso2FA",!0);break;default:i({type:u.C.danger,message:"DEVICE_SSO_ACTIONS_AUTH_ERROR"})}p(!1)})}}),b=(0,s.Zz)((0,o.connect)((e,{macs:t})=>{const a=(0,h.Pk)(e);return{env:(0,A.S$)(e),ssoUsername:(0,h.rU)(e)||a,ssoUuid:a,devices:(0,l.ID)(e).filter(({mac:e})=>t.includes(e))}},{hideModal:m.AS,createToast:_.ox,checkLteSubscription:E.hJ,fetchInfo:p.N,showLteDeviceUnavailable:d.Zo}),S)(g)}}]);