text: 'use strict';
  
  Object.defineProperty(exports, '__esModule', {
    value: true
  });
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  
  var _estraverse = require('estraverse');
  
  var _estraverse2 = _interopRequireDefault(_estraverse);
  
  var _esutilsLibAstJs = require('esutils/lib/ast.js');
  
  var _esutilsLibAstJs2 = _interopRequireDefault(_esutilsLibAstJs);
  
  var _syntaxTemplateLiteralJs = require('./../syntax/template-literal.js');
  
  var _syntaxTemplateLiteralJs2 = _interopRequireDefault(_syntaxTemplateLiteralJs);
  
  var _utilsTypeCheckerJs = require('./../utils/type-checker.js');
  
  var _utilsTypeCheckerJs2 = _interopRequireDefault(_utilsTypeCheckerJs);
  
  var _lodash = require('lodash');
  
  var _lodash2 = _interopRequireDefault(_lodash);
  
  exports['default'] = function (ast) {
    _estraverse2['default'].replace(ast, {
      enter: traverser
    });
  };
  
  var operands = undefined,
      hasString = undefined,
      hasExpression = undefined,
      currentExpression = undefined;
  
  function traverser(node) {
    if (node.type === 'BinaryExpression' && node.operator === '+') {
  
      operands = [];
      hasString = false;
      currentExpression = node;
  
      _estraverse2['default'].traverse(node, {
        enter: detector
      });
  
      if (hasString) {
        operands = (0, _lodash2['default'])(operands).reverse().value();
  
        var templateString = new _syntaxTemplateLiteralJs2['default']();
        templateString.createFromArray(operands);
        this.skip();
        return templateString;
      }
    }
  }
  
  function detector(node) {
  
    if (_utilsTypeCheckerJs2['default'].isBinaryExpression(node)) {
      if (node.operator === '+') {
        var left = node.left;
        var right = node.right;
  
        addOperand(right);
  
        if (!_utilsTypeCheckerJs2['default'].isBinaryExpression(left)) {
          addOperand(left);
  
          this.skip();
        }
      } else {
        addOperand(node);
        this.skip();
      }
    }
  }
  
  function addOperand(node) {
  
    if (operands.indexOf(node) === -1) {
      if (_utilsTypeCheckerJs2['default'].isString(node)) {
        hasString = true;
      }
  
      if (_esutilsLibAstJs2['default'].isExpression(node) && !_utilsTypeCheckerJs2['default'].isLiteral(node)) {
        hasExpression = true;
      }
  
      operands.push(node);
    }
  }
  module.exports = exports['default'];