'use strict';

const _ = require('underscore');

const alphabet = {};

alphabet.ascii85 = {};
alphabet.ascii85.enc = {
  0:  '!',
  1:  '"',
  2:  '#',
  3:  '$',
  4:  '%',
  5:  '&',
  6:  '\'',
  7:  '(',
  8:  ')',
  9:  '*',
  10: '+',
  11: ',',
  12: '-',
  13: '.',
  14: '/',
  15: '0',
  16: '1',
  17: '2',
  18: '3',
  19: '4',
  20: '5',
  21: '6',
  22: '7',
  23: '8',
  24: '9',
  25: ':',
  26: ';',
  27: '<',
  28: '=',
  29: '>',
  30: '?',
  31: '@',
  32: 'A',
  33: 'B',
  34: 'C',
  35: 'D',
  36: 'E',
  37: 'F',
  38: 'G',
  39: 'H',
  40: 'I',
  41: 'J',
  42: 'K',
  43: 'L',
  44: 'M',
  45: 'N',
  46: 'O',
  47: 'P',
  48: 'Q',
  49: 'R',
  50: 'S',
  51: 'T',
  52: 'U',
  53: 'V',
  54: 'W',
  55: 'X',
  56: 'Y',
  57: 'Z',
  58: '[',
  59: '\\',
  60: ']',
  61: '^',
  62: '_',
  63: '`',
  64: 'a',
  65: 'b',
  66: 'c',
  67: 'd',
  68: 'e',
  69: 'f',
  70: 'g',
  71: 'h',
  72: 'i',
  73: 'j',
  74: 'k',
  75: 'l',
  76: 'm',
  77: 'n',
  78: 'o',
  79: 'p',
  80: 'q',
  81: 'r',
  82: 's',
  83: 't',
  84: 'u'
};
alphabet.ascii85.dec = _.object(
  _.map(_.values(alphabet.ascii85.enc), function(v) { /* The keys */
    return v.charCodeAt(0);
  }),
  _.map(_.keys(alphabet.ascii85.enc), function(v) { /* The values */
    return parseInt(v);
  })
);

alphabet.z85 = {};
alphabet.z85.enc = {
  0:  '0',
  1:  '1',
  2:  '2',
  3:  '3',
  4:  '4',
  5:  '5',
  6:  '6',
  7:  '7',
  8:  '8',
  9:  '9',
  10: 'a',
  11: 'b',
  12: 'c',
  13: 'd',
  14: 'e',
  15: 'f',
  16: 'g',
  17: 'h',
  18: 'i',
  19: 'j',
  20: 'k',
  21: 'l',
  22: 'm',
  23: 'n',
  24: 'o',
  25: 'p',
  26: 'q',
  27: 'r',
  28: 's',
  29: 't',
  30: 'u',
  31: 'v',
  32: 'w',
  33: 'x',
  34: 'y',
  35: 'z',
  36: 'A',
  37: 'B',
  38: 'C',
  39: 'D',
  40: 'E',
  41: 'F',
  42: 'G',
  43: 'H',
  44: 'I',
  45: 'J',
  46: 'K',
  47: 'L',
  48: 'M',
  49: 'N',
  50: 'O',
  51: 'P',
  52: 'Q',
  53: 'R',
  54: 'S',
  55: 'T',
  56: 'U',
  57: 'V',
  58: 'W',
  59: 'X',
  60: 'Y',
  61: 'Z',
  62: '.',
  63: '-',
  64: ':',
  65: '+',
  66: '=',
  67: '^',
  68: '!',
  69: '/',
  70: '*',
  71: '?',
  72: '&',
  73: '<',
  74: '>',
  75: '(',
  76: ')',
  77: '[',
  78: ']',
  79: '{',
  80: '}',
  81: '@',
  82: '%',
  83: '$',
  84: '#'
};
alphabet.z85.dec = _.object(
  _.map(_.values(alphabet.z85.enc), function(v) { /* The keys */
    return v.charCodeAt(0);
  }),
  _.map(_.keys(alphabet.z85.enc), function(v) { /* The values */
    return parseInt(v);
  })
);

alphabet.ipv6 = {};
alphabet.ipv6.enc = {
  0:  '0',
  1:  '1',
  2:  '2',
  3:  '3',
  4:  '4',
  5:  '5',
  6:  '6',
  7:  '7',
  8:  '8',
  9:  '9',
  10: 'A',
  11: 'B',
  12: 'C',
  13: 'D',
  14: 'E',
  15: 'F',
  16: 'G',
  17: 'H',
  18: 'I',
  19: 'J',
  20: 'K',
  21: 'L',
  22: 'M',
  23: 'N',
  24: 'O',
  25: 'P',
  26: 'Q',
  27: 'R',
  28: 'S',
  29: 'T',
  30: 'U',
  31: 'V',
  32: 'W',
  33: 'X',
  34: 'Y',
  35: 'Z',
  36: 'a',
  37: 'b',
  38: 'c',
  39: 'd',
  40: 'e',
  41: 'f',
  42: 'g',
  43: 'h',
  44: 'i',
  45: 'j',
  46: 'k',
  47: 'l',
  48: 'm',
  49: 'n',
  50: 'o',
  51: 'p',
  52: 'q',
  53: 'r',
  54: 's',
  55: 't',
  56: 'u',
  57: 'v',
  58: 'w',
  59: 'x',
  60: 'y',
  61: 'z',
  62: '!',
  63: '#',
  64: '$',
  65: '%',
  66: '&',
  67: '(',
  68: ')',
  69: '*',
  70: '+',
  71: '-',
  72: ';',
  73: '<',
  74: '=',
  75: '>',
  76: '?',
  77: '@',
  78: '^',
  79: '_',
  80: '`',
  81: '{',
  82: '|',
  83: '}',
  84: '~'
};
alphabet.ipv6.dec = _.object(
  _.map(_.values(alphabet.ipv6.enc), function(v) { /* The keys */
    return v.charCodeAt(0);
  }),
  _.map(_.keys(alphabet.ipv6.enc), function(v) { /* The values */
    return parseInt(v);
  })
);

module.exports = alphabet;
