{"version":3,"file":"ngx-morse.mjs","sources":["../../../projects/ngx-morse/src/lib/dictionary.ts","../../../projects/ngx-morse/src/lib/exceptions/invalid-input.ts","../../../projects/ngx-morse/src/lib/ngx-morse.service.ts","../../../projects/ngx-morse/src/lib/ngx-morse.module.ts","../../../projects/ngx-morse/src/public-api.ts","../../../projects/ngx-morse/src/ngx-morse.ts"],"sourcesContent":["// JSON representing the morse code chart\nexport const Dictionary = {\n  \n  // Letters\n  'a': '.-',\n  'b': '-...',\n  'c': '-.-.',\n  'd': '-..',\n  'e': '.',\n  'f': '..-.',\n  'g': '--.',\n  'h': '....',\n  'i': '..',\n  'j': '.---',\n  'k': '-.-',\n  'l': '.-..',\n  'm': '--',\n  'n': '-.',\n  'o': '---',\n  'p': '.--.',\n  'q': '--.-',\n  'r': '.-.',\n  's': '...',\n  't': '-',\n  'u': '..-',\n  'v': '...-',\n  'w': '.--',\n  'x': '-..-',\n  'y': '-.--',\n  'z': '--..',\n  'ä': '.-.-',\n  'á': '.--.-',\n  'å': '.--.-',\n  'é': '.-..',\n  'ñ': '-.--',\n  'ö': '--.',\n  'ü': '.--',\n\n  // Digits\n  '0': '-----',\n  '1': '.----',\n  '2': '..---',\n  '3': '...--',\n  '4': '....-',\n  '5': '.....',\n  '6': '-....',\n  '7': '--...',\n  '8': '---..',\n  '9': '----.',\n\n  // Special characters\n  ' ': '/',\n  '\\n': '.-.-',\n  '&': '.-...',\n  '\\'': '.----.',\n  '@': '.--.-.',\n  ')': '-.--.-',\n  '(': '-.--.',\n  ':': '---...',\n  ',': '--..--',\n  '=': '-...-',\n  '!': '-.-.--',\n  '.': '.-.-.-',\n  '-': '-....-',\n  '+': '.-.-.',\n  '\"': '.-..-.',\n  '?': '..--..',\n  '/': '-..-.',\n}\n","import { Dictionary } from \"../dictionary\";\n\nclass InvalidInputError extends Error {\n  public static INVALID_INPUT: string =\n        \"Valid inputs are: Alphabets, digits (0-9) and a few special characters. \" +\n        \"Please see the list of valid characters: \" +\n    Object.keys(Dictionary).toString();\n\n  public static INVALID_MORSE_INPUT: string =\n    \"String contains invalid or corrupted Morse code.\";\n\n  constructor(public message: string) {\n    super(message);\n    this.name = \"InvalidInputError\";\n    this.stack = (<any>new Error()).stack;\n  }\n}\n\nexport default InvalidInputError;\n","import { Injectable } from '@angular/core';\nimport { Dictionary } from './dictionary';\nimport InvalidInputError from './exceptions/invalid-input';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class NgxMorseService {\n\n  constructor() { }\n\n  //\n  // Encoding : text to morse\n  //\n  encode(message : string) :string {\n\n    let cipher : string = '';\n\n    for(let letter of message){\n\n      // Looks up the dictionary and adds the correspponding morse code\n      // along with a space to separate morse codes for different characters\n      if (!(letter.toLowerCase() in Dictionary)) {\n        throw new InvalidInputError(InvalidInputError.INVALID_INPUT);\n      }\n\n      cipher += Dictionary[letter.toLowerCase()];\n\n      // if(letter!=' ') {\n      //   console.log(letter,Dictionary[letter.toLowerCase()])\n      // } else {\n      //   // 1 space indicates different characters and 2 indicates different words\n      //   cipher += ' ';\n      // }\n\n      cipher += ' ';\n\n    }\n\n    return cipher;\n\n  }\n\n  //\n  // Decoding : morse to text\n  //\n  decode(message : string) :string {\n\n    // Extra space added at the end to access the last morse code \n    message += ' ';\n  \n    let decipher : string = ''; \n    let citext : string = '';\n    \n    for(let letter of message) {\n\n      // Check for space \n      if(letter!=' ') {\n\n        // Counter to keep track of space \n        var i = 0;\n      \n        // Storing morse code of a single character \n        citext += letter; \n\n      } else {\n\n        // If i = 1 that indicates a new character \n        i += 1;\n      \n        // If i = 2 that indicates a new word \n        if (i==2) {\n          // Adding space to separate words \n          decipher += ' '\n        } else {\n          // Accessing the keys using their values\n\t        const letterDecodedFromMorseCode = Object.keys(Dictionary).find(key => Dictionary[key] === citext);\n          if (!letterDecodedFromMorseCode) {\n            throw new InvalidInputError(InvalidInputError.INVALID_MORSE_INPUT);\n          }\n          decipher += letterDecodedFromMorseCode;\n          citext = '';\n        }\n      \n      }\n\n    }\n  \n    return decipher;\n  }\n\n}\n","import { NgModule } from '@angular/core';\n\n@NgModule({\n  declarations: [],\n  imports: [],\n  exports: []\n})\nexport class NgxMorseModule { }\n","/*\n * Public API Surface of ngx-morse\n */\n\nexport * from './lib/ngx-morse.service';\nexport * from './lib/ngx-morse.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAAA;AACO,MAAM,UAAU,GAAG;;AAGxB,IAAA,GAAG,EAAE,IAAI;AACT,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,GAAG;AACR,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,IAAI;AACT,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,IAAI;AACT,IAAA,GAAG,EAAE,IAAI;AACT,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,GAAG;AACR,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,OAAO;AACZ,IAAA,GAAG,EAAE,OAAO;AACZ,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,GAAG,EAAE,KAAK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