var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.RouteAction=exports.default=void 0;var _toConsumableArray2=_interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _RoutingSystem=_interopRequireDefault(require("./RoutingSystem.js"));var _ViewSystem=_interopRequireWildcard(require("./ViewSystem.js"));var _ModuleSystem=_interopRequireDefault(require("./ModuleSystem.js"));var _modules=_interopRequireDefault(require("../../modules"));var _EventSystem=_interopRequireDefault(require("./EventSystem"));var _System=_interopRequireDefault(require("./System"));var ActionSystem=function(_BaseSystem){(0,_inherits2.default)(ActionSystem,_BaseSystem);function ActionSystem(CS){var _this;(0,_classCallCheck2.default)(this,ActionSystem);_this=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(ActionSystem).call(this));_this.CoreSystem=CS;_this.EventSystem=new _EventSystem.default();_this.events=(0,_toConsumableArray2.default)(ActionSystem.Actions);_this._disabled=false;_this.setupEvents();return _this;}(0,_createClass2.default)(ActionSystem,[{key:"setupEvents",value:function setupEvents(){var _this2=this;this.events.map(function(Action){_this2.EventSystem.on(Action.id,function(d){return _this2.dispatch(Action,d);});});}},{key:"dispatch",value:function dispatch(Action,data){return!this._disabled&&new Action(this.CoreSystem).run(data);}},{key:"disable",value:function disable(){this._disabled=true;}},{key:"enable",value:function enable(){this._disabled=false;}},{key:"toggle",value:function toggle(value){this._disabled=value||!this._disabled;}},{key:"createAction",value:function createAction(action){if(!action.type)return;this.EventSystem.emit(action.type,action.data);}}]);return ActionSystem;}(_System.default);exports.default=ActionSystem;var RouteAction=function(){function RouteAction(CS){(0,_classCallCheck2.default)(this,RouteAction);this.CoreSystem=CS;}(0,_createClass2.default)(RouteAction,[{key:"run",value:function run(data){var route=data.route;if(route)this.CoreSystem.goto(route);}}]);return RouteAction;}();exports.RouteAction=RouteAction;RouteAction.id="changeRoute";ActionSystem.RouteAction=RouteAction;ActionSystem.Actions=[RouteAction];