@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
2 lines (1 loc) • 1.78 kB
JavaScript
import{Oa as n,Qb as s,ab as l,vb as d,wb as h,xa as c,xb as g}from"./chunk-D55YR5X7.js";var M=(()=>{let r=class r{constructor(){this.passwordToCheck="",this.bar0="",this.bar1="",this.bar2="",this.bar3="",this.bar4="",this.colors=["#F00","#F90","#FF0","#7ACC00","#06854B"]}static measureStrength(e){let t=0,o=/[$-/:-?{-~!"^_`[\]]/g,p=/[a-z]+/.test(e),m=/[A-Z]+/.test(e),u=/[0-9]+/.test(e),b=o.test(e),f=[p,m,u,b],a=0;for(let C of f)a+=C===!0?1:0;return t+=2*e.length+(e.length>=10?1:0),t+=a*10,t=e.length<=6?Math.min(t,10):t,t=a===1?Math.min(t,10):t,t=a===2?Math.min(t,20):t,t=a===3?Math.min(t,40):t,t}ngOnChanges(e){let t=e.passwordToCheck.currentValue;if(this.setBarColors(5,"#DDD"),t){let o=this.getColor(r.measureStrength(t));this.setBarColors(o.idx,o.col)}}getColor(e){let t=Math.min(Math.floor((e-1)/10),4);return{idx:t+1,col:this.colors[t]}}setBarColors(e,t){for(let o=0;o<e;o++)this[`bar${o}`]=t}};r.\u0275fac=function(t){return new(t||r)},r.\u0275cmp=l({type:r,selectors:[["app-password-strength-bar"]],inputs:{passwordToCheck:"passwordToCheck"},features:[c],decls:8,vars:10,consts:[["strength",""],["id","strength"],["id","strengthBar"],[1,"point"]],template:function(t,o){t&1&&(d(0,"div",1,0)(2,"ul",2),g(3,"li",3)(4,"li",3)(5,"li",3)(6,"li",3)(7,"li",3),h()()),t&2&&(n(3),s("background-color",o.bar0),n(),s("background-color",o.bar1),n(),s("background-color",o.bar2),n(),s("background-color",o.bar3),n(),s("background-color",o.bar4))},styles:["ul#strengthBar[_ngcontent-%COMP%]{display:flex;list-style:none;padding:0;align-self:center;margin-bottom:-2px}.point[_ngcontent-%COMP%]:last-child{margin:0!important}.point[_ngcontent-%COMP%]{background:#ddd;border-radius:2px;height:6px;margin-right:1px;width:20px}"],changeDetection:0});let i=r;return i})();export{M as a};