{"version":3,"file":"iban.mjs","sources":["../../../../src/tools/formatters/iban.ts"],"sourcesContent":["import { Type } from './../type'\n\nexport class IbanSpecification {\n  /**\n   * the code of the country\n   */\n  readonly countryCode: string\n\n  /**\n   * the length of the IBAN\n   */\n  readonly length: number\n\n  /**\n   * the structure of the underlying BBAN (for validation and formatting)\n   */\n  readonly structure: string\n\n  /**\n   * an example valid IBAN\n   */\n  readonly example: string\n\n  private _cachedRegex: null | RegExp = null\n\n  constructor(\n    countryCode: string,\n    length: number,\n    structure: string,\n    example: string\n  ) {\n    this.countryCode = countryCode\n    this.length = length\n    this.structure = structure\n    this.example = example\n  }\n\n  /**\n   * Check if the passed iban is valid, according to this specification.\n   *\n   * @param {string} iban the iban to validate\n   * @returns {boolean} true if valid, false otherwise\n   */\n  isValid(iban: string): boolean {\n    return (\n      this.length === iban.length\n      && this.countryCode === iban.slice(0, 2)\n      && this._regex().test(iban.slice(4))\n      && this._iso7064Mod9710(this._iso13616Prepare(iban)) == 1\n    )\n  }\n\n  /**\n   * Convert the passed IBAN to a country-specific BBAN.\n   *\n   * @param iban the IBAN to convert\n   * @param separator the separator to use between BBAN blocks\n   * @returns {string} the BBAN\n   */\n  toBBAN(iban: string, separator: string): string {\n    return (this._regex().exec(iban.slice(4) || '') || [])\n      .slice(1)\n      .join(separator)\n  }\n\n  /**\n   * Convert the passed BBAN to an IBAN for this country specification.\n   * Please note that <i>\"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account\"</i>.\n   * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits\n   *\n   * @param bban the BBAN to convert to IBAN\n   * @returns {string} the IBAN\n   */\n  fromBBAN(bban: string): string {\n    if (!this.isValidBBAN(bban)) {\n      throw new Error('Invalid BBAN')\n    }\n\n    const remainder = this._iso7064Mod9710(\n      this._iso13616Prepare(this.countryCode + '00' + bban)\n    )\n\n    const checkDigit = ('0' + (98 - remainder)).slice(-2)\n\n    return this.countryCode + checkDigit + bban\n  }\n\n  /**\n   * Check of the passed BBAN is valid.\n   * This function only checks the format of the BBAN (length and compliance with alphanumeric specifications) but does not\n   * verify the check digit.\n   *\n   * @param bban the BBAN to validate\n   * @returns {boolean} true if the passed bban is a valid BBAN, according to this specification, false otherwise\n   */\n  isValidBBAN(bban: string): boolean {\n    return this.length - 4 === bban.length && this._regex().test(bban)\n  }\n\n  /**\n   * Lazy-loaded regex (parse the structure and construct the regular expression the first time we need it for validation)\n   */\n  private _regex(): RegExp {\n    if (null === this._cachedRegex) {\n      this._cachedRegex = this._parseStructure(this.structure)\n    }\n\n    return this._cachedRegex\n  }\n\n  /**\n   * Parse the BBAN structure used to configure each IBAN Specification and returns a matching regular expression.\n   * A structure is composed of blocks of three characters (one letter and two digits).\n   * Each block represents\n   * a logical group in the typical representation of the BBAN.\n   * For each group, the letter indicates which characters\n   * are allowed in this group, and the following 2-digits number tells the length of the group.\n   *\n   * @param {string} structure the structure to parse\n   * @returns {RegExp}\n   */\n  private _parseStructure(structure: string): RegExp {\n    // split in blocks of 3 chars\n    const regex = (structure.match(/(.{3})/g) || []).map(\n      (block: string): string => {\n        // parse each structure block (1-char + 2-digits)\n        let format\n        const pattern = block.slice(0, 1)\n        const repeats = Number.parseInt(block.slice(1), 10)\n\n        switch (pattern) {\n          case 'A':\n            format = '0-9A-Za-z'\n            break\n          case 'B':\n            format = '0-9A-Z'\n            break\n          case 'C':\n            format = 'A-Za-z'\n            break\n          case 'F':\n            format = '0-9'\n            break\n          case 'L':\n            format = 'a-z'\n            break\n          case 'U':\n            format = 'A-Z'\n            break\n          case 'W':\n            format = '0-9a-z'\n            break\n        }\n\n        return '([' + format + ']{' + repeats + '})'\n      }\n    )\n\n    return new RegExp('^' + regex.join('') + '$')\n  }\n\n  /**\n   * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to\n   * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.\n   *\n   * @param {string} iban the IBAN\n   * @returns {string} the prepared IBAN\n   */\n  private _iso13616Prepare(iban: string): string {\n    const A = 'A'.charCodeAt(0)\n\n    const Z = 'Z'.charCodeAt(0)\n\n    iban = iban.toUpperCase()\n\n    iban = iban.substring(4) + iban.substring(0, 4)\n    return (\n      iban\n        .split('')\n        .map((n: string): string => {\n          const code = n.charCodeAt(0)\n          if (code >= A && code <= Z) {\n            // A = 10, B = 11, ... Z = 35\n            return (code - A + 10).toString()\n          } else {\n            return n\n          }\n        })\n        .join('')\n    )\n  }\n\n  /**\n   * Calculates MOD 97 10 of the passed IBAN as specified in ISO7064.\n   *\n   * @param iban\n   * @returns {number} MOD\n   */\n  private _iso7064Mod9710(iban: string): number {\n    let remainder = iban\n    let block\n\n    while (remainder.length > 2) {\n      block = remainder.slice(0, 9)\n      remainder\n        = (Number.parseInt(block, 10) % 97) + remainder.slice(block.length)\n    }\n\n    return Number.parseInt(remainder, 10) % 97\n  }\n}\n\nexport class FormatterIban {\n  private static isInternalConstructing: boolean = false\n  private static instance: FormatterIban | null = null\n\n  private _countries: Map<string, IbanSpecification>\n\n  // region Init ////\n  private constructor() {\n    if (!FormatterIban.isInternalConstructing) {\n      throw new TypeError('FormatterIban is not constructable')\n    }\n    FormatterIban.isInternalConstructing = false\n\n    this._countries = new Map()\n  }\n\n  /**\n   * @return FormatterIban\n   */\n  static getInstance(): FormatterIban {\n    if (!FormatterIban.instance) {\n      FormatterIban.isInternalConstructing = true\n      FormatterIban.instance = new FormatterIban()\n    }\n\n    return FormatterIban.instance\n  }\n\n  addSpecification(IBAN: IbanSpecification): void {\n    this._countries.set(IBAN.countryCode, IBAN)\n  }\n\n  // endregion ////\n\n  // region IBAN ////\n  /**\n   * Check if an IBAN is valid.\n   *\n   * @param {string} iban the IBAN to validate.\n   * @returns {boolean} true if the passed IBAN is valid, false otherwise\n   */\n  isValid(iban: string): boolean {\n    if (!Type.isString(iban)) {\n      return false\n    }\n\n    iban = this.electronicFormat(iban)\n    const countryCode = iban.slice(0, 2)\n\n    if (!this._countries.has(countryCode)) {\n      throw new Error(`No country with code ${countryCode}`)\n    }\n\n    const countryStructure = this._countries.get(countryCode)\n\n    return !!countryStructure && countryStructure.isValid(iban)\n  }\n\n  printFormat(iban: string, separator?: string): string {\n    if (typeof separator == 'undefined') {\n      separator = ' '\n    }\n\n    const EVERY_FOUR_CHARS = /(.{4})(?!$)/g\n\n    return this.electronicFormat(iban).replace(\n      EVERY_FOUR_CHARS,\n      '$1' + separator\n    )\n  }\n\n  electronicFormat(iban: string): string {\n    const NON_ALPHANUM = /[^a-z0-9]/gi\n\n    return iban.replace(NON_ALPHANUM, '').toUpperCase()\n  }\n\n  // endregion ////\n\n  // region BBAN ////\n  /**\n   * Convert an IBAN to a BBAN.\n   *\n   * @param iban\n   * @param {string} [separator] the separator to use between the blocks of the BBAN, defaults to ' '\n   * @returns {string|*} Convert an IBAN to a BBAN.\n   */\n  toBBAN(iban: string, separator?: string): string {\n    if (typeof separator == 'undefined') {\n      separator = ' '\n    }\n\n    iban = this.electronicFormat(iban)\n\n    const countryCode = iban.slice(0, 2)\n    if (!this._countries.has(countryCode)) {\n      throw new Error(`No country with code ${countryCode}`)\n    }\n\n    const countryStructure = this._countries.get(countryCode)\n\n    if (!countryStructure) {\n      throw new Error(`No country with code ${countryCode}`)\n    }\n\n    return countryStructure.toBBAN(iban, separator)\n  }\n\n  /**\n   * Convert the passed BBAN to an IBAN for this country specification.\n   * Please note that <i>\"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account\"</i>.\n   * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits\n   *\n   * @param countryCode the country of the BBAN\n   * @param bban the BBAN to convert to IBAN\n   * @returns {string} the IBAN\n   */\n  fromBBAN(countryCode: string, bban: string): string {\n    if (!this._countries.has(countryCode)) {\n      throw new Error(`No country with code ${countryCode}`)\n    }\n\n    const countryStructure = this._countries.get(countryCode)\n\n    if (!countryStructure) {\n      throw new Error(`No country with code ${countryCode}`)\n    }\n\n    return countryStructure.fromBBAN(this.electronicFormat(bban))\n  }\n\n  /**\n   * Check the validity of the passed BBAN.\n   *\n   * @param countryCode the country of the BBAN\n   * @param bban the BBAN to check the validity of\n   */\n  isValidBBAN(countryCode: string, bban: string): boolean {\n    if (!Type.isString(bban)) {\n      return false\n    }\n\n    if (!this._countries.has(countryCode)) {\n      throw new Error(`No country with code ${countryCode}`)\n    }\n\n    const countryStructure = this._countries.get(countryCode)\n\n    return (\n      !!countryStructure\n      && countryStructure.isValidBBAN(this.electronicFormat(bban))\n    )\n  }\n\n  // endregion ////\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAEO,MAAM,iBAAA,CAAkB;AAAA,EAF/B;AAE+B,IAAA,MAAA,CAAA,IAAA,EAAA,mBAAA,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAIpB,WAAA;AAAA;AAAA;AAAA;AAAA,EAKA,MAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKA,OAAA;AAAA,EAED,YAAA,GAA8B,IAAA;AAAA,EAEtC,WAAA,CACE,WAAA,EACA,MAAA,EACA,SAAA,EACA,OAAA,EACA;AACA,IAAA,IAAA,CAAK,WAAA,GAAc,WAAA;AACnB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AACjB,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAAQ,IAAA,EAAuB;AAC7B,IAAA,OACE,IAAA,CAAK,MAAA,KAAW,IAAA,CAAK,MAAA,IAClB,IAAA,CAAK,WAAA,KAAgB,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,IACpC,IAAA,CAAK,MAAA,GAAS,IAAA,CAAK,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA,IAChC,IAAA,CAAK,eAA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