import{N as l}from"./chunk-NCBQEKN3.js";import{a,b as o}from"./chunk-RA2WU32H.js";var g=class s{MAX_INTENTOS=5;BLOQUEO_MS=15*60*1e3;INACTIVIDAD_MS=30*60*1e3;KEY_INTENTOS="_sec_att";KEY_BLOQUEO="_sec_lock";KEY_ULTIMA_ACT="_sec_last";RATE_CONFIG={cambio_password:{max:5,windowMs:5*60*1e3},recuperar_email:{max:3,windowMs:5*60*1e3},reenviar_codigo:{max:3,windowMs:5*60*1e3},eliminar_cuenta:{max:3,windowMs:5*60*1e3}};inactividadTimer;registrarIntentoFallido(){let e=Date.now(),r=this.getIntentos().filter(n=>e-n<this.BLOQUEO_MS);r.push(e),sessionStorage.setItem(this.KEY_INTENTOS,JSON.stringify(r)),r.length>=this.MAX_INTENTOS&&sessionStorage.setItem(this.KEY_BLOQUEO,String(e+this.BLOQUEO_MS))}estasBloqueado(){let e=Number(sessionStorage.getItem(this.KEY_BLOQUEO)??0);return Date.now()<e?!0:(e>0&&(sessionStorage.removeItem(this.KEY_BLOQUEO),sessionStorage.removeItem(this.KEY_INTENTOS)),!1)}tiempoBloqueoRestante(){let e=Number(sessionStorage.getItem(this.KEY_BLOQUEO)??0);return Math.max(0,Math.ceil((e-Date.now())/1e3))}resetearIntentos(){sessionStorage.removeItem(this.KEY_INTENTOS),sessionStorage.removeItem(this.KEY_BLOQUEO)}intentosRestantes(){let e=this.getIntentos().filter(t=>Date.now()-t<this.BLOQUEO_MS);return Math.max(0,this.MAX_INTENTOS-e.length)}getIntentos(){try{return JSON.parse(sessionStorage.getItem(this.KEY_INTENTOS)??"[]")}catch{return[]}}registrarFalloEn(e){let t=this.RATE_CONFIG[e];if(!t)return;let r=Date.now(),n=this.getRlIntentos(e).filter(i=>r-i<t.windowMs);n.push(r),sessionStorage.setItem(`_rl_att_${e}`,JSON.stringify(n)),n.length>=t.max&&sessionStorage.setItem(`_rl_lock_${e}`,String(r+t.windowMs))}estaBloqueadoPara(e){let t=Number(sessionStorage.getItem(`_rl_lock_${e}`)??0);return Date.now()<t?!0:(t>0&&(sessionStorage.removeItem(`_rl_lock_${e}`),sessionStorage.removeItem(`_rl_att_${e}`)),!1)}tiempoRestantePara(e){let t=Number(sessionStorage.getItem(`_rl_lock_${e}`)??0);return Math.max(0,Math.ceil((t-Date.now())/1e3))}resetearAccion(e){sessionStorage.removeItem(`_rl_att_${e}`),sessionStorage.removeItem(`_rl_lock_${e}`)}intentosRestantesPara(e){let t=this.RATE_CONFIG[e];if(!t)return 99;let r=this.getRlIntentos(e).filter(n=>Date.now()-n<t.windowMs);return Math.max(0,t.max-r.length)}getRlIntentos(e){try{return JSON.parse(sessionStorage.getItem(`_rl_att_${e}`)??"[]")}catch{return[]}}iniciarWatchdogInactividad(e){this.resetearInactividad(e),["mousemove","keydown","click","touchstart","scroll"].forEach(r=>document.addEventListener(r,()=>this.resetearInactividad(e),{passive:!0}))}resetearInactividad(e){clearTimeout(this.inactividadTimer),sessionStorage.setItem(this.KEY_ULTIMA_ACT,String(Date.now())),this.inactividadTimer=setTimeout(()=>{e()},this.INACTIVIDAD_MS)}detenerWatchdog(){clearTimeout(this.inactividadTimer)}sanitizar(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;").trim()}sanitizarObjeto(e){let t={};for(let r of Object.keys(e))t[r]=typeof e[r]=="string"?this.sanitizar(e[r]):e[r];return t}evaluarPassword(e){let t=0,r=[];e.length>=8?t++:r.push("M\xEDnimo 8 caracteres"),e.length>=12&&t++,/[A-Z]/.test(e)?t++:r.push("Agrega may\xFAsculas"),/[0-9]/.test(e)?t++:r.push("Agrega n\xFAmeros"),/[^A-Za-z0-9]/.test(e)?t++:r.push("Agrega s\xEDmbolos (!@#$)");let n=[{nivel:"Muy d\xE9bil",color:"#ef4444"},{nivel:"D\xE9bil",color:"#f97316"},{nivel:"Regular",color:"#eab308"},{nivel:"Fuerte",color:"#22c55e"},{nivel:"Muy fuerte",color:"#16a34a"}],i=Math.min(t,4);return o(a({puntaje:i},n[i]),{sugerencias:r})}iniciarWatchdogVisibilidad(e){document.addEventListener("visibilitychange",()=>{document.hidden&&e()})}detectarDevTools(){return window.outerWidth-window.innerWidth>160||window.outerHeight-window.innerHeight>160}limpiarClipboard(){navigator.clipboard?.writeText("").catch(()=>{})}generarFingerprint(){let e=[navigator.userAgent,navigator.language,screen.width,screen.height,screen.colorDepth,new Date().getTimezoneOffset(),navigator.hardwareConcurrency??0].join("|"),t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t^e.charCodeAt(r);return String(t>>>0)}validarFingerprint(){let e=sessionStorage.getItem("_fp"),t=this.generarFingerprint();return e?e===t:(sessionStorage.setItem("_fp",t),!0)}static \u0275fac=function(t){return new(t||s)};static \u0275prov=l({token:s,factory:s.\u0275fac,providedIn:"root"})};export{g as a};
