1import {o as o$1}from'./chunk-C14-eSCk.js';import {g,iy as a,aY as w,aW as H,bi as G,B as wi,fp as ii,O as On,Y as YG,q as qd,iA as o,iB as r,f as qS,bz as oi,cy as ei,bZ as Qe,b_ as Xn,b$ as Yn,iC as _t$1,iD as Jt,c2 as Fn,c3 as Mn,iE as At,h as g$1,H as yt,L as gv,eh as Jv,d6 as CM,d7 as wM,aG as fM,bu as Hd,i as ta,Z as Zv,aH as sh,ar as yM,aI as ah,Q as QM,P as Pd,j as Vv,aC as oM,de as rM,I as eM,bv as $d,u as uT,ak as jv,G as Gd,bQ as fN,aD as iM,N as tM,dg as iS,k as Pv,dh as aS,bw as EN,y as yD,bx as CN,eK as cb}from'./main-DZECCSYF.js';var dt=["otpInput"],_t=n=>({email:n}),ht=n=>({time:n});function ft(n,_){if(n&1){let t=fM();ta(0,"input",15,0),Zv("input",function(i){let o=sh(t).$implicit,a=yM(2);return ah(a.onInput(i,o))})("keydown",function(i){let o=sh(t).$implicit,a=yM(2);return ah(a.onKeyDown(i,o))})("paste",function(i){sh(t);let o=yM(2);return ah(o.onPaste(i))}),Pd(),iS();}if(n&2){let t=_.$implicit,e=yM(2);jv("formControlName",t)("name","code-"+t)("id","code-"+t),Pv("autocomplete",t===0?"one-time-code":"off")("disabled",e.loading()?true:null),aS();}}function gt(n,_){if(n&1){let t=fM();ta(0,"div",9)(1,"button",16),Zv("click",function(){sh(t);let i=yM(2);return ah(i.clearCode())}),QM(2),Pd()();}if(n&2){let t=yM().$implicit;uT(2),Gd(" \u2715 ",t("otp.otp.clearCode")," ");}}function vt(n,_){if(n&1){let t=fM();ta(0,"button",17),Zv("click",function(){sh(t);let i=yM(2);return ah(i.resendEmail())}),QM(1),Pd();}if(n&2){let t=yM().$implicit,e=yM();jv("disabled",!e.resendButtonActive()),uT(),Gd(" ",t("otp.otp.resendEmail")," ");}}function xt(n,_){if(n&1&&(ta(0,"span",13),QM(1),EN(2,"minuteSeconds"),Pd()),n&2){let t=yM().$implicit,e=yM();uT(),yD(t("otp.otp.resendEmailTimer",fN(3,ht,CN(2,1,e.timer()))));}}function Ct(n,_){if(n&1){let t=fM();Hd(0),ta(1,"form",2),Zv("ngSubmit",function(){sh(t);let i=yM();return ah(i.onSubmit())}),ta(2,"div",3)(3,"div",4)(4,"h2",5),QM(5),Pd(),Vv(6,"p",6),ta(7,"div",7),oM(8,ft,2,5,"input",8,rM),Pd(),eM(10,gt,3,1,"div",9),ta(11,"div",10)(12,"p",11),QM(13),eM(14,vt,2,2,"button",12)(15,xt,3,5,"span",13),Pd()()(),ta(16,"button",14),QM(17),Pd()()(),$d();}if(n&2){let t=_.$implicit,e=yM();uT(),jv("formGroup",e.otpForm),uT(4),Gd(" ",t("otp.otp.title")," "),uT(),jv("innerHTML",t("otp.otp.description",fN(8,_t,e.email())),cb),uT(2),iM(e.otpSlots),uT(2),tM(e.hasInput()&&!e.loading()?10:-1),uT(3),Gd(" ",t("otp.otp.noEmailReceived")," "),uT(),tM(e.showResendButton()?14:15),uT(2),jv("disabled",e.code().length!==6||e.loading()),uT(),Gd(" ",t("otp.otp.buttonText")," ");}}var pt=6,Mt=(()=>{class n{constructor(){this._otpService=g(a),this._authService=g(w),this._router=g(H),this._route=g(G),this._noti=g(wi),this._fb=g(ii),this._pendingFocusRaf=null,this._intervalId=null,this.otpSlots=Array.from({length:pt},(t,e)=>e),this.otpForm=this._fb.group({digits:this._fb.array(this.otpSlots.map(()=>this._fb.control("")))}),this.email=On(""),this.loading=On(false),this._digitValues=YG(this.otpForm.controls.digits.valueChanges,{initialValue:this.otpSlots.map(()=>"")}),this.digitValues=qd(()=>this._digitValues()),this.code=qd(()=>this._digitValues().join("")),this.hasInput=qd(()=>this._digitValues().some(t=>t!=="")),this.showResendButton=On(false),this.timer=On(300),this.resendButtonActive=On(true);}ngOnInit(){let t=this._route.snapshot.queryParams.email;t&&this.email.set(t),this._startTimer();}ngOnDestroy(){this._intervalId!==null&&(clearInterval(this._intervalId),this._intervalId=null),this._cancelPendingFocusShift(),o.removeAllListeners();}async onSubmit(){let t=this.email().trim(),e=this.code().trim();!t||!e||e.length!==pt||(this.loading.set(true),this._otpService.verifyOtp(t,e).subscribe({next:async i=>{await this._authService.storeOtpAuthorization(i.schools,i.ssoToken??""),this._router.navigate(["/auth/generic-client/school-select"]);},error:i=>{this.loading.set(false),this._noti.errorIntl("auth.otp.verifyError");}}));}onInput(t,e){let o=t.target?.value??"";if(o.length>1){this._applyPastedDigits(o,e);return}let a=o.replace(/\D/g,"");a!==o&&this._digitsArray.at(e).setValue(a),a&&e<this.otpSlots.length-1&&this._queueFocusShift(e+1);}onKeyDown(t,e){if(t.key==="Backspace"&&!this._digitValues()[e]&&e>0){t.preventDefault(),this._focusInput(e-1);return}if(t.key==="ArrowLeft"&&e>0){t.preventDefault(),this._focusInput(e-1);return}t.key==="ArrowRight"&&e<this.otpSlots.length-1&&(t.preventDefault(),this._focusInput(e+1));}onPaste(t){t.preventDefault();let e=t.clipboardData?.getData("text")??"";if(e){this._applyPastedDigits(e,0);return}navigator.clipboard?.readText().then(i=>this._applyPastedDigits(i,0),()=>{});}resendEmail(){this.resendButtonActive()&&(this.resendButtonActive.set(false),this._otpService.requestOtp(this.email()
1).subscribe({next:()=>{this._noti.successIntl("auth.otp.resendSuccess"),this.resendButtonActive.set(true),this._startTimer();},error:()=>{this._noti.errorIntl("auth.otp.resendError"),this.resendButtonActive.set(true);}}));}clearCode(){this._digitsArray.controls.forEach(t=>t.setValue("")),this._focusInput(0);}get _digitsArray(){return this.otpForm.controls.digits}_applyPastedDigits(t,e){let i=this.otpSlots.length-e,o=t.replace(/\D/g,"").slice(0,i);if(!o)return;let a=this._digitsArray;for(let C=0;C<o.length;C+=1)a.at(e+C).setValue(o[C]);let mt=Math.min(e+o.length,this.otpSlots.length-1);this._focusInput(mt);}_focusInput(t){this._cancelPendingFocusShift();let i=this._otpInputs?.toArray()?.[t]?.nativeElement;i&&(i.focus(),i.select());}_queueFocusShift(t){this._cancelPendingFocusShift(),this._pendingFocusRaf=requestAnimationFrame(()=>{this._pendingFocusRaf=null,this._focusInput(t);});}_cancelPendingFocusShift(){this._pendingFocusRaf!==null&&(cancelAnimationFrame(this._pendingFocusRaf),this._pendingFocusRaf=null);}_startTimer(){o.addListener("resume",()=>{this._setUpdatedTimer();}),o.addListener("pause",()=>{this._storeTimerPause();}),this.showResendButton.set(false),this.timer.set(300),this._intervalId!==null&&clearInterval(this._intervalId),this._intervalId=setInterval(()=>{this.timer()>0?this.timer.set(this.timer()-1):(this.showResendButton.set(true),this._intervalId!==null&&(clearInterval(this._intervalId),this._intervalId=null));},1e3);}goBack(){this._router.navigate(["/auth/generic-client/email"]);}_storeTimerPause(){r.set({key:"genericClientOtpTimerPaused",value:Date.now().toString()});}async _setUpdatedTimer(){let t=await r.get({key:"genericClientOtpTimerPaused"});if(t.value){let e=Date.now(),i=parseInt(t.value,10),o=Math.floor((e-i)/1e3);this.timer.update(a=>a-o);}r.remove({key:"genericClientOtpTimerPaused"});}static{this.\u0275fac=function(e){return new(e||n)};}static{this.\u0275cmp=qS({type:n,selectors:[["appc-generic-client-otp"]],viewQuery:function(e,i){if(e&1&&Jv(dt,5),e&2){let o;CM(o=wM())&&(i._otpInputs=o);}},decls:1,vars:0,consts:[["otpInput",""],[4,"transloco"],[1,"h-full","md:flex","md:w-full","md:justify-center",3,"ngSubmit","formGroup"],[1,"flex","h-full","flex-col","items-center","justify-between","md:justify-center"],[1,"w-full","md:max-w-md"],[1,"mb-2","mt-1","text-2xl","font-semibold"],[1,"mb-6","text-sm","text-mspot-neutral-600",3,"innerHTML"],["formArrayName","digits",1,"flex","justify-center","gap-1","px-1"],["type","text","inputmode","numeric","pattern","[0-9]*","required","",1,"h-20","w-full","flex-1","overflow-hidden","rounded","border","border-mspot-neutral-200","bg-backgrounds-surface-raised","text-center","text-xl","font-semibold","tracking-widest","drop-shadow-md","backdrop-blur-sm","focus:border-primary","focus:outline-none","disabled:opacity-60","md:w-16",3,"formControlName","name","id"],[1,"my-4","flex","justify-center"],[1,"mt-4","flex","justify-center"],[1,"mb-6","text-sm","text-mspot-neutral-600"],["type","button",1,"font-semibold","text-primary",3,"disabled"],[1,"text-mspot-neutral-600"],["type","submit","mspotButton","","color","primary","variant","strong","size","lg",1,"h-[2.375rem]","w-full",3,"disabled"],["type","text","inputmode","numeric","pattern","[0-9]*","required","",1,"h-20","w-full","flex-1","overflow-hidden","rounded","border","border-mspot-neutral-200","bg-backgrounds-surface-raised","text-center","text-xl","font-semibold","tracking-widest","drop-shadow-md","backdrop-blur-sm","focus:border-primary","focus:outline-none","disabled:opacity-60","md:w-16",3,"input","keydown","paste","formControlName","name","id"],["type","button","mspotButton","","color","system","variant","weak","size","sm",3,"click"],["type","button",1,"font-semibold","text-primary",3,"click","disabled"]],template:function(e,i){e&1&&gv(0,Ct,18,10,"ng-container",1);},dependencies:[oi,ei,Qe,Xn,Yn,_t$1,Jt,Fn,Mn,At,g$1,yt,o$1],encapsulation:2});}}return n})();export{Mt as GenericClientOtpComponent};
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.