'use strict';

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

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

exports['default'] = getIntlManager;

var _mobxReact = require('mobx-react');

var _AppState = require('../../stores/AppState');

var _AppState2 = _interopRequireDefault(_AppState);

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

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

var intlManager = void 0;

// @observer

var IntlManager = function () {
  function IntlManager() {
    (0, _classCallCheck3['default'])(this, IntlManager);

    this.intls = {};
  }

  (0, _createClass3['default'])(IntlManager, [{
    key: 'add',
    value: function add(intlObj) {
      if (_constants.NODE_ENV === 'development') {
        window.console.log('[IntlManager]: before add, the intls is', this.intls);
        window.console.log('[IntlManager]: the intlObj is', intlObj);
      }
      this.intls = (0, _extends3['default'])(this.intls, intlObj);
      if (_constants.NODE_ENV === 'development') {
        window.console.log('[IntlManager]: after add, the intls is:', this.intls);
      }
    }
  }, {
    key: 'delete',
    value: function _delete(code) {
      if (this.intls[code]) {
        delete this.intls[code];
      }
    }
  }, {
    key: 'clear',
    value: function clear() {
      this.intls = {};
    }
  }, {
    key: 'get',
    value: function get(code) {
      return this.intls[code] || undefined;
    }
  }]);
  return IntlManager;
}();

function getIntlManager() {
  if (!intlManager) {
    intlManager = new IntlManager();
  }
  return intlManager;
}