1import{a as at}from"./chunk-BKRTINBH.js";import{a as rt}from"./chunk-4NPJC2LZ.js";import{b as ot}from"./chunk-NHQU5P2E.js";import"./chunk-ZBOBJI6X.js";import"./chunk-GRN4AYRM.js";import"./chunk-FQTOFAG5.js";import"./chunk-GHSZCZA3.js";import"./chunk-F645W6RP.js";import"./chunk-6TD3IOK2.js";import"./chunk-YJTB64MB.js";import"./chunk-AH2PNZM3.js";import"./chunk-HDYCTURY.js";import"./chunk-QJHO5PAG.js";import{K as tt,V as et,f as L,h as A,j as $,k as j,q,s as Q,t as W,u as Y,x as J,y as X,z as Z}from"./chunk-LQ3JKF5N.js";import{d as it,e as nt}from"./chunk-QNA2R4GM.js";import{Bb as v,Bc as R,Db as u,Fd as z,Gd as T,Kb as K,La as r,Lb as S,Ob as F,Qb as p,Rb as k,Sb as m,Ua as O,Zd as U,be as G,ce as H,ec as N,ga as f,hc as l,ic as d,jb as b,jc as M,jd as V,kb as E,ma as c,mb as P,na as h,nb as w,ob as D,oc as I,pb as g,qb as s,rb as a,tc as B,xa as y,zb as C}from"./chunk-VC3BCRKY.js";var st=["otpKeyInput"],pt=o=>({count:o});function mt(o,_){if(o&1){let t=C();s(0,"input",16,0),v("paste",function(e){c(t);let n=u();return h(n.onPaste(e))})("focusin",function(){c(t);let e=u();return h(e.onFocus())})("keydown",function(e){let n=c(t).$index,x=u();return h(x.onKeydown(e,n))})("input",function(e){let n=c(t).$index,x=u();return h(x.onInput(e,n))}),a()}if(o&2){let t=_.$implicit,i=_.$index;F("input--invalid",t.touched&&!t.valid&&!t.disabled),g("formControlName",i)}}function ut(o,_){if(o&1&&(s(0,"ui-error",9),p(1),a()),o&2){let t=u();r(),k(t.formErrorMessage())}}function lt(o,_){if(o&1&&(s(0,"p",14),p(1),l(2,"translate"),a()),o&2){let t=u();r(),m(" ",M(2,1,"AUTH.OTP_PAGE.RESEND_CODE_WITH_TIMER",N(4,pt,t.countDownTimer()))," ")}}function dt(o,_){if(o&1){let t=C();s(0,"button",17),v("click",function(){c(t);let e=u();return h(e.resendOtpCode())}),p(1),l(2,"translate"),a()}if(o&2){let t=u();g("disabled",t.shouldDisableResendButton()),r(),m(" ",d(2,2,"AUTH.OTP_PAGE.RESEND_EMAIL")," ")}}var wt=(()=>{class o{constructor(){this.#o=z({query:{email:T(""),authType:T("")}}),this.otpKeyInput=B("otpKeyInput"),this.countDownTimer=y(0),this.otpKeys=["","","","","",""],this.otpCode="",this.formErrorMessage=y(""),this.#t=f(U),this.#e=f(ot),this.#i=f(at),this.#n=f(J),this.shouldDisableResendButton=y(!1),this.submittedEmailAddress=I(()=>this.#o.values()?.query.email),this.authType=I(()=>this.#o.values().query.authType),this.focusFirstKeyInput=R(()=>{this.otpKeyInput()[0].nativeElement.focus()})}#o;#t;#e;#i;#n;ngOnInit(){this.initializeOtpForm(),this.initializeCountDownTimer(),this.authType()==="signup"&&this.#e.addSignupEvent$({event:"2_land_check_your_email"}).subscribe()}initializeOtpForm(){let t=this.#n.array([]);for(let i=0;i<this.otpKeys.length;i++)t.push(this.#n.control("",[A.required,A.maxLength(1)]));this.otpForm=this.#n.group({otpKey:t})}get otpKeyInputs(){return this.otpForm?.get("otpKey")}initializeCountDownTimer(){this.#i.startTimer$(this.submittedEmailAddress()).subscribe({next:t=>{this.countDownTimer.set(t)}})}onInput(t,i){let n=(t.target.value||"").trim().toUpperCase();if(!n)return;if(n.length>1){this.processPastedText(n);return}this.otpKeyInputs.controls[i].setValue(n),this.otpKeyInput()[i+1]?.nativeElement.focus(),this.otpKeys[i]=n,this.otpKeyInputs.value.includes("")||(this.otpCode=this.otpKeys.join(""),this.otpSubmit(this.submittedEmailAddress(),this.otpCode))}onPaste(t){let e=(t.clipboardData?.getData("text")||"").trim().toUpperCase();this.processPastedText(e)}processPastedText(t){t.split("").forEach((e,n)=>{n>5||(this.otpKeyInputs.controls[n].setValue(e.charAt(0)),this.otpKeys[n]=e.charAt(0),this.otpKeyInput()[0]?.nativeElement.blur())}),this.otpKeys.includes("")||(this.otpCode=this.otpKeys.join(""),this.otpSubmit(this.submittedEmailAddress(),this.otpCode))}onFocus(){this.formErrorMessage.set("");let t=this.otpKeyInputs.controls;t.some(i=>i.getError("invalid"))&&(this.otpKeyInput()[0]?.nativeElement.focus(),t.forEach(i=>i.reset("")))}otpSubmit(t,i){this.otpForm?.markAllAsTouched(),this.otpKeyInput()?.forEach(e=>e.nativeElement.blur()),this.#t.submitOtp$(t,i).subscribe({next:e=>{this.#i.removeOtpResendEmailCodeAttempt(t),this.handleOtpSubmitResponse(e)},error:e=>
1{this.otpKeyInputs.controls.forEach(n=>n.setErrors({invalid:!0})),G(e)&&e.error.message&&(this.formErrorMessage.set(e.error.message),e.status===403&&(this.formErrorMessage.set(e.error.message),this.otpForm.disable(),this.otpKeyInputs.controls.forEach(n=>n.setErrors(null))),H(e,"TOO_MANY_REQUESTS")&&(this.otpForm.disable(),this.shouldDisableResendButton.set(!0)))}})}handleOtpSubmitResponse(t){this.authType()==="login"&&(this.#e.generateSessionId(),this.#e.addEvent({product:"CAKE.com Account",event:t.authenticationFlow?.toLowerCase(),method:"OTP",userId:t.userId||"",organizationId:t.organizationId?t.organizationId:"",organizationStartDate:t.organizationCreationDate?t.organizationCreationDate:"",organizationUserRole:t.organizationUserRole?t.organizationUserRole:""})),this.#t.handleAuthResponse(t)}onKeydown(t,i){(t.key&&t.key.toLowerCase()==="backspace"||t.keyCode&&t.keyCode===8)&&(t.preventDefault(),this.otpKeyInputs.controls[i].setValue(""),this.otpKeyInput()[i-1]?.nativeElement.focus())}resendOtpCode(){let t=this.submittedEmailAddress();this.#t.submitEmail$(t).subscribe({next:()=>{this.#i.setOtpResendEmailCodeAttempt(t),this.initializeCountDownTimer()}})}static{this.\u0275fac=function(i){return new(i||o)}}static{this.\u0275cmp=O({type:o,selectors:[["cake-otp-page"]],viewQuery:function(i,e){i&1&&K(e.otpKeyInput,st,5),i&2&&S()},decls:30,vars:22,consts:[["otpKeyInput",""],[1,"px-[15px]","md:px-[30px]","py-3","bg-white","dark:bg-bgrey-780"],[1,"mb-2","dark:text-bgrey-100","mt-6"],[1,"md:px-[30px]"],[1,"text-regular","text-bgrey-600","mb-6","dark:text-bgrey-400"],[1,"font-semibold","block","break-all"],[1,"form",3,"formGroup"],["formArrayName","otpKey",1,"flex","form__otp-code","mx-auto","justify-between"],["type","text","placeholder","",1,"input","input__otp-code","mb-3","mx-1","d-flex","items-center","justify-center","text-center","dark:bg-bgrey-800","dark:text-bgrey-400",3,"input--invalid","formControlName"],[1,"mx-auto","max-w-[282px]"],[1,"flex","items-center","justify-between","mt-5","mb-1","mx-auto","max-w-[241px]"],["ui-button","","size","small","variation","secondary","iconName","open_in_new","iconPosition","right","href","https://mail.google.com/mail/u/0/#inbox","target","_blank"],["ui-button","","size","small","variation","secondary","iconName","open_in_new","iconPosition","right","href","https://outlook.live.com","target","_blank"],[1,"text-bgrey-600","mt-4","dark:text-bgrey-400","text-tiny"],[1,"text-bgrey-500","mt-2","mb-6"],["data-testid","resend-email",1,"text-[#0015AF]","dark:text-[#B3BBFF]","mt-2","mb-6","underline","mx-auto","text-tiny",3,"disabled"],["type","text","placeholder","",1,"input","input__otp-code","mb-3","mx-1","d-flex","items-center","justify-center","text-center","dark:bg-bgrey-800","dark:text-bgrey-400",3,"paste","focusin","keydown","input","formControlName"],["data-testid","resend-email",1,"text-[#0015AF]","dark:text-[#B3BBFF]","mt-2","mb-6","underline","mx-auto","text-tiny",3,"click","disabled"]],template:function(i,e){i&1&&(s(0,"cake-auth-forms-layout")(1,"div",1)(2,"h2",2),p(3),l(4,"translate"),a(),s(5,"div",3)(6,"p",4),p(7),l(8,"translate"),s(9,"span",5),p(10),a(),p(11),l(12,"translate"),a(),s(13,"form",6)(14,"div",7),w(15,mt,2,3,"input",8,P),a()(),b(17,ut,2,1,"ui-error",9),s(18,"div",10)(19,"a",11),p(20),l(21,"translate"),a(),s(22,"a",12),p(23),l(24,"translate"),a()(),s(25,"p",13),p(26),l(27,"translate"),a(),b(28,lt,3,6,"p",14)(29,dt,3,4,"button",15),a()()()),i&2&&(r(3),m(" ",d(4,10,"AUTH.OTP_PAGE.TITLE")," "),r(4),m(" ",d(8,12,"AUTH.OTP_PAGE.SUBTITLE_1")," "),r(3),m("",e.submittedEmailAddress(),"."),r(),m(" ",d(12,14,"AUTH.OTP_PAGE.SUBTITLE_2")," "),r(2),g("formGroup",e.otpForm),r(2),D(e.otpKeyInputs.controls),r(2),E(e.formErrorMessage()?17:-1),r(3),m(" ",d(21,16,"SHARED.OPEN_GMAIL")," "),r(3),m(" ",d(24,18,"SHARED.OPEN_OUTLOOK")," "),r(3),m(" ",d(27,20,"AUTH.OTP_PAGE.CANT_FIND_EMAIL")," "),r(2),E(e.countDownTimer()?28:29))},dependencies:[X,q,L,$,j,Z,Y,W,Q,et,tt,V,nt,rt,it],encapsulation:2,changeDetection:0})}}return o})();export{wt as OtpPageComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.