text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  Object.defineProperty(exports, "mockChannel", {
    enumerable: true,
    get: function get() {
      return _storybookChannelMock.default;
    }
  });
  Object.defineProperty(exports, "makeDecorator", {
    enumerable: true,
    get: function get() {
      return _makeDecorator.makeDecorator;
    }
  });
  exports.default = exports.AddonStore = void 0;
  
  require("core-js/modules/es6.object.define-property");
  
  require("core-js/modules/es6.function.name");
  
  require("core-js/modules/es6.array.iterator");
  
  require("core-js/modules/es6.object.keys");
  
  require("core-js/modules/es6.array.map");
  
  require("core-js/modules/web.dom.iterable");
  
  require("core-js/modules/es6.array.for-each");
  
  var _global = _interopRequireDefault(require("global"));
  
  var _storybookChannelMock = _interopRequireDefault(require("./storybook-channel-mock"));
  
  var _makeDecorator = require("./make-decorator");
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
  
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  
  var AddonStore =
  /*#__PURE__*/
  function () {
    function AddonStore() {
      _classCallCheck(this, AddonStore);
  
      this.loaders = {};
      this.panels = {};
      this.channel = null;
      this.preview = null;
      this.database = null;
    }
  
    _createClass(AddonStore, [{
      key: "getChannel",
      value: function getChannel() {
        // this.channel should get overwritten by setChannel. If it wasn't called (e.g. in non-browser environment), throw.
        if (!this.channel) {
          throw new Error('Accessing nonexistent addons channel, see https://storybook.js.org/basics/faq/#why-is-there-no-addons-channel');
        }
  
        return this.channel;
      }
    }, {
      key: "hasChannel",
      value: function hasChannel() {
        return Boolean(this.channel);
      }
    }, {
      key: "setChannel",
      value: function setChannel(channel) {
        this.channel = channel;
      }
    }, {
      key: "getPreview",
      value: function getPreview() {
        return this.preview;
      }
    }, {
      key: "setPreview",
      value: function setPreview(preview) {
        this.preview = preview;
      }
    }, {
      key: "getDatabase",
      value: function getDatabase() {
        return this.database;
      }
    }, {
      key: "setDatabase",
      value: function setDatabase(database) {
        this.database = database;
      }
    }, {
      key: "getPanels",
      value: function getPanels() {
        return this.panels;
      }
    }, {
      key: "addPanel",
      value: function addPanel(name, panel) {
        // supporting legacy addons, which have not migrated to the active-prop
        // const original = panel.render;
        // if (original && original.toString() && !original.toString().match(/active/)) {
        //  this.panels[name] = {
        //    ...panel,
        //    render: ({ active }) => TabWrapper({ active, render: original }),
        //  };
        // } else {
        this.panels[name] = panel; // }
      }
    }, {
      key: "register",
      value: function register(name, loader) {
        this.loaders[name] = loader;
      }
    }, {
      key: "loadAddons",
      value: function loadAddons(api) {
        var _this = this;
  
        Object.keys(this.loaders).map(function (name) {
          return _this.loaders[name];
        }).forEach(function (loader) {
          return loader(api);
        });
      }
    }]);
  
    return AddonStore;
  }(); // Enforce addons store to be a singleton
  
  
  exports.AddonStore = AddonStore;
  var KEY = '__STORYBOOK_ADDONS';
  
  function getAddonsStore() {
    if (!_global.default[KEY]) {
      _global.default[KEY] = new AddonStore();
    }
  
    return _global.default[KEY];
  }
  
  var _default = getAddonsStore();
  
  exports.default = _default;