'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default = undefined;var _createClass = function () {function defineProperties(target, props) {for (var i = 0; i < props.length; i++) {var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);}}return function (Constructor, protoProps, staticProps) {if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;};}();var _desc, _value, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity.  If not, see <http://www.gnu.org/licenses/>.

var _mobx = require('mobx');
var _store = require('store');var _store2 = _interopRequireDefault(_store);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _initDefineProp(target, property, descriptor, context) {if (!descriptor) return;Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 });}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {var desc = {};Object['ke' + 'ys'](descriptor).forEach(function (key) {desc[key] = descriptor[key];});desc.enumerable = !!desc.enumerable;desc.configurable = !!desc.configurable;if ('value' in desc || desc.initializer) {desc.writable = true;}desc = decorators.slice().reverse().reduce(function (desc, decorator) {return decorator(target, property, desc) || desc;}, desc);if (context && desc.initializer !== void 0) {desc.value = desc.initializer ? desc.initializer.call(context) : void 0;desc.initializer = undefined;}if (desc.initializer === void 0) {Object['define' + 'Property'](target, property, desc);desc = null;}return desc;}function _initializerWarningHelper(descriptor, context) {throw new Error('Decorating class property failed. Please ensure that transform-class-properties is enabled.');}

var LS_KEY = '_parity::history';
var MAX_ENTRIES = 5;

var instances = {};var

Store = (_class = function () {


  function Store(type) {var _this = this;_classCallCheck(this, Store);_initDefineProp(this, 'history', _descriptor, this);_initDefineProp(this, 'add', _descriptor2, this);_initDefineProp(this, 'clear', _descriptor3, this);_initDefineProp(this, 'load', _descriptor4, this);this.






















    save = function () {
      return _store2.default.set(_this.historyKey, _this.history);
    };this.historyKey = LS_KEY + '::' + type;this.load();}_createClass(Store, null, [{ key: 'get', value: function get(

    type) {
      if (!instances[type]) {
        instances[type] = new Store(type);
      }

      return instances[type];
    } }]);return Store;}(), (_descriptor = _applyDecoratedDescriptor(_class.prototype, 'history', [_mobx.observable], { enumerable: true, initializer: function initializer() {return [];} }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, 'add', [_mobx.action], { enumerable: true, initializer: function initializer() {var _this2 = this;return function (entry, type) {_this2.history = [{ entry: entry, timestamp: Date.now(), type: type }].concat(_this2.history.filter(function (h) {return h.entry !== entry;})).slice(0, MAX_ENTRIES);_this2.save();};} }), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, 'clear', [_mobx.action], { enumerable: true, initializer: function initializer() {var _this3 = this;return function () {_this3.history = [];_this3.save();};} }), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, 'load', [_mobx.action], { enumerable: true, initializer: function initializer() {var _this4 = this;return function () {_this4.history = _store2.default.get(_this4.historyKey) || [];};} })), _class);exports.default = Store;