{"version":3,"file":"obliczeniowo-elementary-password.mjs","sources":["../../../../projects/components/password/components/password-strength/password-strength.component.ts","../../../../projects/components/password/components/password-strength/password-strength.component.html","../../../../projects/components/password/password.module.ts","../../../../projects/components/password/obliczeniowo-elementary-password.ts"],"sourcesContent":["import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core';\nimport { PasswordType } from '../../types/types';\n\n@Component({\n    selector: 'obl-password-strength',\n    templateUrl: './password-strength.component.html',\n    styleUrls: ['./password-strength.component.scss'],\n    changeDetection: ChangeDetectionStrategy.OnPush,\n    standalone: false\n})\nexport class PasswordStrengthComponent {\n  @Input() password = '';\n\n  readonly height = 1;\n\n  readonly weryWeak = Math.pow(26, 10);\n  readonly weak = Math.pow(26 + 26, 10);\n  readonly strong = Math.pow(26 + 26 + 10, 10);\n  readonly weryStrong = Math.pow(26 + 26 + 10 + 30, 10);\n\n  translations: {\n    weryWeak: string,\n    weak: string,\n    strong: string,\n    weryStrong: string\n  } = {\n      weryWeak: 'wery weak',\n      weak: 'weak',\n      strong: 'strong',\n      weryStrong: 'wery strong'\n    };\n\n  id!: string;\n  strengthType: PasswordType = 'weryWeak';\n\n  constructor(protected change: ChangeDetectorRef) {\n    const generate = () => `Password_${Math.floor(Math.random() * 100000000)}`;\n    this.id = generate();\n    while (document.querySelector('#' + this.id)) {\n      this.id = generate();\n    }\n  }\n\n  getK(): number {\n    const strength = this.getStrength();\n    if (strength < this.weryWeak) {\n      this.strengthType = 'weryWeak';\n      return 0.4 * strength / this.weryWeak;\n    } else if (strength < this.weak) {\n      this.strengthType = 'weak';\n      return 0.4 + 0.4 * strength / this.weak;\n    } else if (strength < this.strong) {\n      this.strengthType = 'strong';\n      return 0.8 + 0.1 * strength / this.strong;\n    } else if (strength < this.weryStrong) {\n      this.strengthType = 'weryStrong';\n      return 0.9 + 0.1 * strength / this.weryStrong;\n    }\n    this.strengthType = 'weryStrong';\n    return 1;\n  }\n\n  getStrength(): number {\n    const hasLowerCase = /[a-z]/.test(this.password);\n    const hasUpperCase = /[A-Z]/.test(this.password);\n    const hasNumbers = /[0-9]/.test(this.password);\n    const hasSpecialChars = /[^a-zA-Z0-9\\s]/.test(this.password);\n    const hasWhiteSpace = /[ \\t]/.test(this.password);\n\n    return Math.pow((hasLowerCase && 26 || 0) +\n      (hasUpperCase && 26 || 0) +\n      (hasNumbers && 10 || 0) +\n      (hasSpecialChars && 30 || 0) +\n      (hasWhiteSpace && 2 || 0),\n      this.password.length\n    );\n  }\n}\n","<svg height=\"5\" viewBox=\"0 0 52.916665 1.3229167\">\n  <defs id=\"defs2\">\n    <clipPath [attr.id]=\"id\">\n      <rect [attr.width]=\"100 * getK() + '%'\" height=\"1.3229166\" x=\"0\" y=\"0\" />\n    </clipPath>\n  </defs>\n  <path\n    class=\"background\"\n    d=\"M 0,0 V 1.3229166 H 11.90625 V 0 Z M 13.229167,0 V 1.3229166 H 25.135416 V 0 Z m 13.229166,0 v 1.3229166 h 11.90625 V 0 Z M 39.6875,0 v 1.3229166 h 6.614583 V 0 Z m 7.937499,0 v 1.3229166 h 5.291667 V 0 Z\"\n  />\n  <g [attr.clip-path]=\"'url(#' + id + ')'\">\n    <path class=\"weak\" d=\"M -1.666668e-8,0 V 1.3229167 H 11.90625 V 0 Z\" />\n    <path class=\"weak\" d=\"m 13.229167,0 v 1.3229167 h 11.90625 V 0 Z\" />\n    <path class=\"weak\" d=\"m 26.458333,0 v 1.3229167 h 11.90625 V 0 Z\" />\n    <path class=\"strong\" d=\"m 39.6875,0 v 1.3229167 h 6.614583 V 0 Z\" />\n    <path class=\"wery-strong\" d=\"m 47.625,0 v 1.3229167 h 5.291666 V 0 Z\" />\n  </g>\n</svg>\n{{ translations[strengthType] }}","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { PasswordStrengthComponent } from './components/password-strength/password-strength.component';\n\n@NgModule({\n  declarations: [\n    PasswordStrengthComponent\n  ],\n  imports: [\n    CommonModule\n  ],\n  exports: [\n    Passw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