text: !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MicroMachine=e():t.MicroMachine=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),a=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initial";r(this,t),this.state=e,this.events={},this.callbacks={}}return i(t,[{key:"when",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.events[t]=e,this}},{key:"on",value:function(t,e){if(!e)return this;var n=this.getCallbacks(t);return n.push(e),this.callbacks[t]=n,this}},{key:"off",value:function(t){return t?this.callbacks[t]=[]:this.callbacks={},this}},{key:"trigger",value:function(t){if(this.canTriggerEvent(t)){var e=this.state,n=this.events[t][this.state];return this.triggerCallbacks(t,e,n),this.state=n,!0}return!1}},{key:"getEvents",value:function(){return Object.values(this.events)}},{key:"getAvailableEvents",value:function(){var t=this;return Object.keys(this.events).filter(function(e){return t.canTriggerEvent(e)})}},{key:"canTriggerEvent",value:function(t){var e=this.events[t]||{};return Object.prototype.hasOwnProperty.call(e,this.state)}},{key:"getStates",value:function(){var t=[];return this.getEvents().forEach(function(e){var n=Object.keys(e).concat(Object.values(e));t=t.concat(n)}),Array.from(new Set(t))}},{key:"getCallbacks",value:function(t){return this.callbacks[t]||[]}},{key:"triggerCallbacks",value:function(t,e,n){this.getCallbacks(t).concat(this.getCallbacks("any")).forEach(function(r){r({from:e,to:n,eventName:t})})}}]),t}();t.exports=a}])});