__ || Object.getPrototypeOf(o);};return _getPrototypeOf(o);}var

HandlebarsLexer = /*#__PURE__*/function (_BaseLexer) {_inherits(HandlebarsLexer, _BaseLexer);var _super = _createSuper(HandlebarsLexer);
  function HandlebarsLexer() {var _this;var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};_classCallCheck(this, HandlebarsLexer);
    _this = _super.call(this, options);

    _this.functions = options.functions || ['t'];

    _this.createFunctionRegex();
    _this.createArgumentsRegex();return _this;
  }_createClass(HandlebarsLexer, [{ key: "extract", value:

    function extract(content) {
      var matches;

      while (matches = this.functionRegex.exec(content)) {
        var args = this.parseArguments(matches[1] || matches[2]);
        this.populateKeysFromArguments(args);
      }

      return this.keys;
    } }, { key: "parseArguments", value:

    function parseArguments(args) {
      var matches;
      var result = {
        arguments: [],
        options: {} };

      while (matches = this.argumentsRegex.exec(args)) {
        var arg = matches[1];
        var parts = arg.split('=');
        result.arguments.push(arg);
        if (parts.length === 2 && this.validateString(parts[1])) {
          result.options[parts[0]] = parts[1].slice(1, -1);
        }
      }
      return result;
    } }, { key: "populateKeysFromArguments", value:

    function populateKeysFromArguments(args) {
      var firstArgument = args.arguments[0];
      var secondArgument = args.arguments[1];
      var isKeyString = this.validateString(firstArgument);
      var isDefaultValueString = this.validateString(secondArgument);

      if (!isKeyString) {
        this.emit('warning', "Key is not a string literal: ".concat(firstArgument));
      } else {
        var result = _objectSpread(_objectSpread({},
        args.options), {}, {
          key: firstArgument.slice(1, -1) });

        if (isDefaultValueString) {
          result.defaultValue = secondArgument.slice(1, -1);
        }
        this.keys.push(result);
      }
    } }, { key: "createFunctionRegex", value:

    function createFunctionRegex() {
      var functionPattern = this.functionPattern();
      var curlyPattern = '(?:{{)' + functionPattern + '\\s+(.*?)(?:}})';
      var parenthesisPattern = '(?:\\()' + functionPattern + '\\s+(.*)(?:\\))';
      var pattern = curlyPattern + '|' + parenthesisPattern;
      this.functionRegex = new RegExp(pattern, 'gi');
      return this.functionRegex;
    } }, { key: "createArgumentsRegex", value:

    function createArgumentsRegex() {
      var pattern =
      '(?:\\s+|^)' +
      '(' +
      '(?:' +
      _baseLexer["default"].variablePattern +
      '(?:=' +
      _baseLexer["default"].stringOrVariablePattern +
      ')?' +
      ')' +
      '|' +
      _baseLexer["default"].stringPattern +
      ')';
      this.argumentsRegex = new RegExp(pattern, 'gi');
      return this.argumentsRegex;
    } }]);return HandlebarsLexer;}(_baseLexer["default"]);exports["default"] = HandlebarsLexer;module.exports = exports.default;