/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/dispatchable-store@1.1.3/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _require=require("eventemitter2"),EventEmitter2=_require.EventEmitter2,setState=Symbol("SetState"),isFunc=function(e){return"function"==typeof e},isObj=function(e){return"object"==(void 0===e?"undefined":_typeof(e))},isNumber=function(e){return"number"==typeof e},DispatchableStore=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,e);var r=_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,{wildcard:!1,maxListeners:100,verboseMemoryLeak:!0}));if(r.subscribe=function(e){return function(t){if(!isFunc(t))throw new TypeError("Expected a Function");var n=function(r){var n=r.action,i=r.prev,o=r.state,s=e(o),c=e(i);s!==c&&t(n,c,s)};return r.subscribers.push(n),r.on("change",n),r.subscribers.length-1}},r[setState]=function(e,t){var n=r.state;r.state=e,r.emit("change",{action:t,prev:n,state:e})},!isObj(t))throw new TypeError("Expected a object");return r.state=t,r.chains={},r.subscribers=[],r}return _inherits(e,EventEmitter2),_createClass(e,[{key:"getState",value:function(){return Object.assign({},this.state)}},{key:"register",value:function(e){if(!isObj(e))throw new TypeError("Expected a object");this.reducer=e}},{key:"dispatch",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Object.assign({},e,{"@@chained":r});isFunc(this.reducer[n.type])?this[setState](this.reducer[n.type](this.state,n.payload),n):console.warn("'"+n.type+"' action is not registered in reducer."),Array.isArray(this.chains[n.type])&&this.chains[n.type].forEach((function(e){return t.dispatch(e,!0)}))}},{key:"chain",value:function(e,t){this.chains[e]=this.chains[e]||[],this.chains[e].push(t)}},{key:"unsubscribe",value:function(e){if(!isNumber(e))throw new TypeError("Expected a Number");this.off("change",this.subscribers[e])}}]),e}();module.exports=DispatchableStore;
//# sourceMappingURL=/sm/d352acadd498cf2a4c5f2c442a069068cc494d5e6bc25c5ac756dd611e06937a.map