'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _constants = require('../constants');

var _isCharLongDash = require('./isCharLongDash');

var _isCharLongDash2 = _interopRequireDefault(_isCharLongDash);

var _isCharSlashDot = require('./isCharSlashDot');

var _isCharSlashDot2 = _interopRequireDefault(_isCharSlashDot);

var _isCharHiragana = require('./isCharHiragana');

var _isCharHiragana2 = _interopRequireDefault(_isCharHiragana);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Convert [Hiragana](https://en.wikipedia.org/wiki/Hiragana) to [Katakana](https://en.wikipedia.org/wiki/Katakana)
 * Passes through any non-hiragana chars
 * @param  {String} [input=''] text input
 * @return {String} converted text
 * @example
 * hiraganaToKatakana('ひらがな')
 * // => "ヒラガナ"
 * hiraganaToKatakana('ひらがな is a type of kana')
 * // => "ヒラガナ is a type of kana"
 * @ignore
 */
function hiraganaToKatakana() {
  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';

  var kata = [];
  input.split('').forEach(function (char) {
    // Short circuit to avoid incorrect codeshift for 'ー' and '・'
    if ((0, _isCharLongDash2.default)(char) || (0, _isCharSlashDot2.default)(char)) {
      kata.push(char);
    } else if ((0, _isCharHiragana2.default)(char)) {
      // Shift charcode.
      var code = char.charCodeAt(0) + (_constants.KATAKANA_START - _constants.HIRAGANA_START);
      var kataChar = String.fromCharCode(code);
      kata.push(kataChar);
    } else {
      // Pass non-hiragana chars through
      kata.push(char);
    }
  });
  return kata.join('');
}

exports.default = hiraganaToKatakana;