!function(){"use strict";angular.module("ngPasswordStrength",[]).directive("ngPasswordStrength",function(){return{template:'<div class="progress {{valueClass.outter}}"><div class="{{valueClass.inner}} {{innerClass}}" role="progressbar" aria-valuenow="{{value}}" aria-valuemin="0" aria-valuemax="100" ng-style="{width : ( value + \'%\' ) }"><span class="sr-only">{{value}}%</span></div></div>',restrict:"A",scope:{pwd:"=ngPasswordStrength",value:"=strength",innerClassPrefix:"@?",outterClassPrefix:"@?",innerClass:"@?",mode:"=?"},link:function(a){var b={foundation:{innerClass:"meter"},bootstrap:{innerClass:"progress-bar",innerClassPrefix:"progress-bar-"}},c=function(a){var b,c,d,e,f=function(a){for(var b=a.length-1,c="";b>=0;c+=a[b--]);return c},g={pos:{},neg:{}},h={pos:{},neg:{seqLetter:0,seqNumber:0,seqSymbol:0}},i=0,j="abcdefghijklmnopqrstuvwxyz",k="01234567890",l="\\!@#$%&/()=?¿";if(a){for(g.pos.lower=a.match(/[a-z]/g),g.pos.upper=a.match(/[A-Z]/g),g.pos.numbers=a.match(/\d/g),g.pos.symbols=a.match(/[$-/:-?{-~!^_`\[\]]/g),g.pos.middleNumber=a.slice(1,-1).match(/\d/g),g.pos.middleSymbol=a.slice(1,-1).match(/[$-/:-?{-~!^_`\[\]]/g),h.pos.lower=g.pos.lower?g.pos.lower.length:0,h.pos.upper=g.pos.upper?g.pos.upper.length:0,h.pos.numbers=g.pos.numbers?g.pos.numbers.length:0,h.pos.symbols=g.pos.symbols?g.pos.symbols.length:0,b=_.reduce(h.pos,function(a,b){return a+Math.min(1,b)},0),h.pos.numChars=a.length,b+=h.pos.numChars>=8?1:0,h.pos.requirements=b>=3?b:0,h.pos.middleNumber=g.pos.middleNumber?g.pos.middleNumber.length:0,h.pos.middleSymbol=g.pos.middleSymbol?g.pos.middleSymbol.length:0,g.neg.consecLower=a.match(/(?=([a-z]{2}))/g),g.neg.consecUpper=a.match(/(?=([A-Z]{2}))/g),g.neg.consecNumbers=a.match(/(?=(\d{2}))/g),g.neg.onlyNumbers=a.match(/^[0-9]*$/g),g.neg.onlyLetters=a.match(/^([a-z]|[A-Z])*$/g),h.neg.consecLower=g.neg.consecLower?g.neg.consecLower.length:0,h.neg.consecUpper=g.neg.consecUpper?g.neg.consecUpper.length:0,h.neg.consecNumbers=g.neg.consecNumbers?g.neg.consecNumbers.length:0,e=0;e<j.length-2;e++){var m=a.toLowerCase();d=j.substring(e,parseInt(e+3)),c=f(d),(-1!==m.indexOf(d)||-1!==m.indexOf(c))&&h.neg.seqLetter++}for(e=0;e<k.length-2;e++)d=k.substring(e,parseInt(e+3)),c=f(d),(-1!==a.indexOf(d)||-1!==a.toLowerCase().indexOf(c))&&h.neg.seqNumber++;for(e=0;e<l.length-2;e++)d=l.substring(e,parseInt(e+3)),c=f(d),(-1!==a.indexOf(d)||-1!==a.toLowerCase().indexOf(c))&&h.neg.seqSymbol++;h.neg.repeated=_.chain(a.toLowerCase().split("")).countBy(function(a){return a}).reject(function(a){return 1===a}).reduce(function(a,b){return a+b},0).value(),i+=4*h.pos.numChars,h.pos.upper&&(i+=2*(h.pos.numChars-h.pos.upper)),h.pos.lower&&(i+=2*(h.pos.numChars-h.pos.lower)),(h.pos.upper||h.pos.lower)&&(i+=4*h.pos.numbers),i+=6*h.pos.symbols,i+=2*(h.pos.middleSymbol+h.pos.middleNumber),i+=2*h.pos.requirements,i-=2*h.neg.consecLower,i-=2*h.neg.consecUpper,i-=2*h.neg.consecNumbers,i-=3*h.neg.seqNumber,i-=3*h.neg.seqLetter,i-=3*h.neg.seqSymbol,g.neg.onlyNumbers&&(i-=h.pos.numChars),g.neg.onlyLetters&&(i-=h.pos.numChars),h.neg.repeated&&(i-=h.neg.repeated/h.pos.numChars*10)}return Math.max(0,Math.min(100,Math.round(i)))},d=function(b){switch(Math.round(b/33)){case 0:case 1:return{inner:a.outterClassPrefix+"danger",outter:a.innerClassPrefix+"alert"};case 2:return{outter:a.outterClassPrefix+"warning",inner:a.innerClassPrefix+"warning"};case 3:return{outter:a.outterClassPrefix+"success",inner:a.innerClassPrefix+"success"}}};a.innerClassPrefix=a.innerClassPrefix||"",a.outterClassPrefix=a.outterClassPrefix||"",a.$watch("mode",function(){angular.extend(a,b[a.mode]),a.valueClass=d(a.value)}),a.$watch("pwd",function(){a.value=c(a.pwd),a.valueClass=d(a.value)})}}})}();