From e3e3837ae6fb6dabc11b0261454f2e7a9b9de40e Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 6 May 2018 16:34:03 +0200 Subject: [PATCH] Fix duplicate call to child FSM factory function in a config object --- lib/machina.js | 3 +-- lib/machina.min.js | 2 +- lib/machina.min.js.map | 2 +- spec/utils.spec.js | 42 ++++++++++++++++++++++++++++++++++++++++++ src/utils.js | 1 - 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/lib/machina.js b/lib/machina.js index 61cb2f0..7eaf353 100644 --- a/lib/machina.js +++ b/lib/machina.js @@ -228,7 +228,6 @@ return /******/ (function(modules) { // webpackBootstrap // is this a config object with a factory? if ( config.factory ) { childFsmDefinition = config; - childFsmDefinition.instance = childFsmDefinition.factory(); } else { // assuming this is a machina instance childFsmDefinition.factory = function() { @@ -735,4 +734,4 @@ return /******/ (function(modules) { // webpackBootstrap /******/ ]) }); ; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCBhY2NhOTQxZDVhNDg3MDEyNzkxYSIsIndlYnBhY2s6Ly8vLi9zcmMvbWFjaGluYS5qcyIsIndlYnBhY2s6Ly8vZXh0ZXJuYWwge1wicm9vdFwiOlwiX1wiLFwiY29tbW9uanNcIjpcImxvZGFzaFwiLFwiY29tbW9uanMyXCI6XCJsb2Rhc2hcIixcImFtZFwiOlwibG9kYXNoXCJ9Iiwid2VicGFjazovLy8uL3NyYy9lbWl0dGVyLmpzIiwid2VicGFjazovLy8uL3NyYy91dGlscy5qcyIsIndlYnBhY2s6Ly8vLi9zcmMvZXZlbnRzLmpzIiwid2VicGFjazovLy8uL3NyYy9Gc20uanMiLCJ3ZWJwYWNrOi8vLy4vc3JjL0JlaGF2aW9yYWxGc20uanMiXSwibmFtZX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YXRlICs9IFwiLlwiICsgY2hpbGQuY29tcG9zaXRlU3RhdGUoIGNsaWVudCApO1xuXHRcdH1cblx0XHRyZXR1cm4gc3RhdGU7XG5cdH1cbn0sIGVtaXR0ZXIuZ2V0SW5zdGFuY2UoKSApO1xuXG5CZWhhdmlvcmFsRnNtLmV4dGVuZCA9IHV0aWxzLmV4dGVuZDtcblxubW9kdWxlLmV4cG9ydHMgPSBCZWhhdmlvcmFsRnNtO1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvQmVoYXZpb3JhbEZzbS5qc1xuLy8gbW9kdWxlIGlkID0gNlxuLy8gbW9kdWxlIGNodW5rcyA9IDAiXSwic291cmNlUm9vdCI6IiJ9 \ No newline at end of file diff --git a/lib/machina.min.js b/lib/machina.min.js index e73c60a..8e0df95 100644 --- a/lib/machina.min.js +++ b/lib/machina.min.js @@ -1,2 +1,2 @@ -(function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("lodash")):"function"==typeof define&&define.amd?define(["lodash"],e):"object"==typeof exports?exports.machina=e(require("lodash")):t.machina=e(t._)})(this,function(t){return function(t){function e(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return t[i].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){var i=n(1),s=n(2);t.exports=i.merge(s.instance,{Fsm:n(5),BehavioralFsm:n(6),utils:n(3),eventListeners:{newFsm:[]}})},function(e,n){e.exports=t},function(t,e,n){function i(){return{emit:function(t){var e=s.getLeaklessArgs(arguments);this.eventListeners["*"]&&a.each(this.eventListeners["*"],function(t){if(this.useSafeEmit)try{t.apply(this,e)}catch(n){console&&"undefined"!=typeof console.log&&console.log(n.stack)}else t.apply(this,e)},this),this.eventListeners[t]&&a.each(this.eventListeners[t],function(t){if(this.useSafeEmit)try{t.apply(this,e.slice(1))}catch(n){console&&"undefined"!=typeof console.log&&console.log(n.stack)}else t.apply(this,e.slice(1))},this)},on:function(t,e){var n=this;return n.eventListeners=n.eventListeners||{"*":[]},n.eventListeners[t]||(n.eventListeners[t]=[]),n.eventListeners[t].push(e),{eventName:t,callback:e,off:function(){n.off(t,e)}}},off:function(t,e){this.eventListeners=this.eventListeners||{"*":[]},t?this.eventListeners[t]=e?a.without(this.eventListeners[t],e):[]:this.eventListeners={}}}}var s=n(3),a=n(1);t.exports={getInstance:i,instance:i()}},function(t,e,n){function i(){return{initialState:"uninitialized",eventListeners:{"*":[]},states:{},namespace:h(),useSafeEmit:!1,hierarchy:{},pendingDelegations:{}}}function s(){return{inputQueue:[],targetReplayState:"",state:void 0,priorState:void 0,priorAction:"",currentAction:"",currentActionArgs:void 0,inExitHandler:!1}}function a(t,e){for(var n=[],i=e||0;in;n++)t[n]=e.substr(Math.floor(16*Math.random()),1);return t[14]="4",t[19]=e.substr(3&t[19]|8,1),t[8]=t[13]=t[18]=t[23]="-",t.join("")}var u=[].slice,l=n(4),p=n(1),h=function(){var t=0;return function(){return"fsm."+t++}}(),f=["states","initialState"],d=function(t,e){var n,i=this,s={},a=function(){};return n=t&&t.hasOwnProperty("constructor")?t.constructor:function(){var t=u.call(arguments,0);t[0]=t[0]||{};var e,n=t[0].states||{};e=p.merge(p.cloneDeep(s),{states:n}),e.initialState=t[0].initialState||this.initialState,p.extend(t[0],e),i.apply(this,t)},p.merge(n,i),a.prototype=i.prototype,n.prototype=new a,t&&(p.extend(n.prototype,t),p.merge(s,p.transform(t,function(t,e,n){-1!==f.indexOf(n)&&(t[n]=e)}))),e&&p.merge(n,e),n.prototype.constructor=n,n.__super__=i.prototype,n};t.exports={createUUID:c,extend:d,getDefaultBehavioralOptions:i,getDefaultOptions:i,getDefaultClientMeta:s,getChildFsmInstance:r,getLeaklessArgs:a,listenToChild:o,makeFsmNamespace:h}},function(t,e){t.exports={NEXT_TRANSITION:"transition",HANDLING:"handling",HANDLED:"handled",NO_HANDLER:"nohandler",TRANSITION:"transition",TRANSITIONED:"transitioned",INVALID_STATE:"invalidstate",DEFERRED:"deferred",NEW_FSM:"newfsm"}},function(t,e,n){var i=n(6),s=n(3),a=n(1),r={constructor:function(){i.apply(this,arguments),this.ensureClientMeta()},initClient:function(){var t=this.initialState;if(!t)throw new Error("You must specify an initial state for this FSM");if(!this.states[t])throw new Error("The initial state specified does not exist in the states object.");this.transition(t)},ensureClientMeta:function(){return this._stamped||(this._stamped=!0,a.defaults(this,a.cloneDeep(s.getDefaultClientMeta())),this.initClient()),this},ensureClientArg:function(t){var e=t;return"object"!=typeof e[0]||"inputType"in e[0]||e[0]===this?("object"!=typeof e[0]||"object"==typeof e[0]&&"inputType"in e[0])&&e.unshift(this):e.splice(0,1,this),e},getHandlerArgs:function(t,e){var n=t,i=n[1];return"object"==typeof inputType&&n.splice(1,1,i.inputType),n.slice(e?1:2)},getSystemHandlerArgs:function(t,e){return t},buildEventPayload:function(){var t=this.ensureClientArg(s.getLeaklessArgs(arguments)),e=t[1];return a.isPlainObject(e)?a.extend(e,{namespace:this.namespace}):{data:e||null,namespace:this.namespace}}};a.each(["handle","transition","deferUntilTransition","processQueue","clearQueue"],function(t){r[t]=function(){var e=this.ensureClientArg(s.getLeaklessArgs(arguments));return i.prototype[t].apply(this,e)}}),r=i.extend(r),t.exports=r},function(t,e,n){function i(t){s.extend(this,t),s.defaults(this,a.getDefaultBehavioralOptions()),this.initialize.apply(this,arguments),o.emit(c.NEW_FSM,this)}var s=n(1),a=n(3),r=n(2),o=r.instance,c=n(4),u="__machina__";s.extend(i.prototype,{initialize:function(){},initClient:function(t){var e=this.initialState;if(!e)throw new Error("You must specify an initial state for this FSM");if(!this.states[e])throw new Error("The initial state specified does not exist in the states object.");this.transition(t,e)},configForState:function(t){var e,n=this.states[t];return s.each(this.hierarchy,function(t,e){t&&"function"==typeof t.off&&t.off()}),n._child&&(n._child=a.getChildFsmInstance(n._child),e=n._child&&n._child.instance,this.hierarchy[e.namespace]=a.listenToChild(this,e)),e},ensureClientMeta:function(t){if("object"!=typeof t)throw new Error("An FSM client must be an object.");return t[u]=t[u]||{},t[u][this.namespace]||(t[u][this.namespace]=s.cloneDeep(a.getDefaultClientMeta()),this.initClient(t)),t[u][this.namespace]},buildEventPayload:function(t,e){return s.isPlainObject(e)?s.extend(e,{client:t,namespace:this.namespace}):{client:t,data:e||null,namespace:this.namespace}},getHandlerArgs:function(t,e){var n=t.slice(0),i=n[1];return"object"==typeof i&&n.splice(1,1,i.inputType),e?n:[n[0]].concat(n.slice(2))},getSystemHandlerArgs:function(t,e){return[e].concat(t)},handle:function(t,e){var n=e;if("undefined"==typeof e)throw new Error("The input argument passed to the FSM's handle method is undefined. Did you forget to pass the input name?");"string"==typeof e&&(n={inputType:e,delegated:!1,ticket:void 0});var i=this.ensureClientMeta(t),r=a.getLeaklessArgs(arguments);"object"!=typeof e&&r.splice(1,1,n),i.currentActionArgs=r.slice(1);var o,u,l,p,h,f=i.state,d=this.states[f],g=!1;if(!i.inExitHandler)if(l=this.configForState(f),!l||this.pendingDelegations[n.ticket]||n.bubbling){n.ticket&&this.pendingDelegations[n.ticket]&&delete this.pendingDelegations[n.ticket],o=d[n.inputType]?n.inputType:"*",g="*"===o,u=d[o]||this[o]||this["*"],h=i.state+"."+o,i.currentAction=h;var m=this.buildEventPayload(t,{inputType:n.inputType,delegated:n.delegated,ticket:n.ticket});u?(this.emit(c.HANDLING,m),"function"==typeof u?p=u.apply(this,this.getHandlerArgs(r,g)):(p=u,this.transition(t,u)),this.emit(c.HANDLED,m)):this.emit(c.NO_HANDLER,s.extend({args:r},m)),i.priorAction=i.currentAction,i.currentAction="",i.currentActionArgs=void 0}else n.ticket=n.ticket||a.createUUID(),n.delegated=!0,this.pendingDelegations[n.ticket]={delegatedTo:l.namespace},p=l.handle.apply(l,r);return p},transition:function(t,e){var n,i=this.ensureClientMeta(t),s=i.state,r=this.states[s],o=this.states[e],u=a.getLeaklessArgs(arguments).slice(2);if(!i.inExitHandler&&e!==s){if(o){n=this.configForState(e),r&&r._onExit&&(i.inExitHandler=!0,r._onExit.call(this,t),i.inExitHandler=!1),i.targetReplayState=e,i.priorState=s,i.state=e;var l=this.buildEventPayload(t,{fromState:i.priorState,action:i.currentAction,toState:e});return this.emit(c.TRANSITION,l),o._onEnter&&o._onEnter.apply(this,this.getSystemHandlerArgs(u,t)),this.emit(c.TRANSITIONED,l),n&&n.handle(t,"_reset"),void(i.targetReplayState===e&&this.processQueue(t,c.NEXT_TRANSITION))}this.emit(c.INVALID_STATE,this.buildEventPayload(t,{state:i.state,attemptedState:e}))}},deferUntilTransition:function(t,e){var n=this.ensureClientMeta(t);if(n.currentActionArgs){var i={type:c.NEXT_TRANSITION,untilState:e,args:n.currentActionArgs};n.inputQueue.push(i);var s=this.buildEventPayload(t,{state:n.state,queuedArgs:i});this.emit(c.DEFERRED,s)}},deferAndTransition:function(t,e){this.deferUntilTransition(t,e),this.transition(t,e)},processQueue:function(t){var e=this.ensureClientMeta(t),n=function(t){return!t.untilState||t.untilState===e.state},i=s.filter(e.inputQueue,n);e.inputQueue=s.difference(e.inputQueue,i),s.each(i,function(e){this.handle.apply(this,[t].concat(e.args))}.bind(this))},clearQueue:function(t,e){var n=this.ensureClientMeta(t);if(e){var i=function(t){return e?t.untilState!==e:!0};n.inputQueue=s.filter(n.inputQueue,i)}else n.inputQueue=[]},compositeState:function(t){var e=this.ensureClientMeta(t),n=e.state,i=this.states[n]._child&&this.states[n]._child.instance;return i&&(n+="."+i.compositeState(t)),n}},r.getInstance()),i.extend=a.extend,t.exports=i}])}); +(function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("lodash")):"function"==typeof define&&define.amd?define(["lodash"],e):"object"==typeof exports?exports.machina=e(require("lodash")):t.machina=e(t._)})(this,function(t){return function(t){function e(i){if(n[i])return n[i].exports;var s=n[i]={exports:{},id:i,loaded:!1};return t[i].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){var i=n(1),s=n(2);t.exports=i.merge(s.instance,{Fsm:n(5),BehavioralFsm:n(6),utils:n(3),eventListeners:{newFsm:[]}})},function(e,n){e.exports=t},function(t,e,n){function i(){return{emit:function(t){var e=s.getLeaklessArgs(arguments);this.eventListeners["*"]&&a.each(this.eventListeners["*"],function(t){if(this.useSafeEmit)try{t.apply(this,e)}catch(n){console&&"undefined"!=typeof console.log&&console.log(n.stack)}else t.apply(this,e)},this),this.eventListeners[t]&&a.each(this.eventListeners[t],function(t){if(this.useSafeEmit)try{t.apply(this,e.slice(1))}catch(n){console&&"undefined"!=typeof console.log&&console.log(n.stack)}else t.apply(this,e.slice(1))},this)},on:function(t,e){var n=this;return n.eventListeners=n.eventListeners||{"*":[]},n.eventListeners[t]||(n.eventListeners[t]=[]),n.eventListeners[t].push(e),{eventName:t,callback:e,off:function(){n.off(t,e)}}},off:function(t,e){this.eventListeners=this.eventListeners||{"*":[]},t?this.eventListeners[t]=e?a.without(this.eventListeners[t],e):[]:this.eventListeners={}}}}var s=n(3),a=n(1);t.exports={getInstance:i,instance:i()}},function(t,e,n){function i(){return{initialState:"uninitialized",eventListeners:{"*":[]},states:{},namespace:h(),useSafeEmit:!1,hierarchy:{},pendingDelegations:{}}}function s(){return{inputQueue:[],targetReplayState:"",state:void 0,priorState:void 0,priorAction:"",currentAction:"",currentActionArgs:void 0,inExitHandler:!1}}function a(t,e){for(var n=[],i=e||0;in;n++)t[n]=e.substr(Math.floor(16*Math.random()),1);return t[14]="4",t[19]=e.substr(3&t[19]|8,1),t[8]=t[13]=t[18]=t[23]="-",t.join("")}var u=[].slice,l=n(4),p=n(1),h=function(){var t=0;return function(){return"fsm."+t++}}(),f=["states","initialState"],d=function(t,e){var n,i=this,s={},a=function(){};return n=t&&t.hasOwnProperty("constructor")?t.constructor:function(){var t=u.call(arguments,0);t[0]=t[0]||{};var e,n=t[0].states||{};e=p.merge(p.cloneDeep(s),{states:n}),e.initialState=t[0].initialState||this.initialState,p.extend(t[0],e),i.apply(this,t)},p.merge(n,i),a.prototype=i.prototype,n.prototype=new a,t&&(p.extend(n.prototype,t),p.merge(s,p.transform(t,function(t,e,n){-1!==f.indexOf(n)&&(t[n]=e)}))),e&&p.merge(n,e),n.prototype.constructor=n,n.__super__=i.prototype,n};t.exports={createUUID:c,extend:d,getDefaultBehavioralOptions:i,getDefaultOptions:i,getDefaultClientMeta:s,getChildFsmInstance:r,getLeaklessArgs:a,listenToChild:o,makeFsmNamespace:h}},function(t,e){t.exports={NEXT_TRANSITION:"transition",HANDLING:"handling",HANDLED:"handled",NO_HANDLER:"nohandler",TRANSITION:"transition",TRANSITIONED:"transitioned",INVALID_STATE:"invalidstate",DEFERRED:"deferred",NEW_FSM:"newfsm"}},function(t,e,n){var i=n(6),s=n(3),a=n(1),r={constructor:function(){i.apply(this,arguments),this.ensureClientMeta()},initClient:function(){var t=this.initialState;if(!t)throw new Error("You must specify an initial state for this FSM");if(!this.states[t])throw new Error("The initial state specified does not exist in the states object.");this.transition(t)},ensureClientMeta:function(){return this._stamped||(this._stamped=!0,a.defaults(this,a.cloneDeep(s.getDefaultClientMeta())),this.initClient()),this},ensureClientArg:function(t){var e=t;return"object"!=typeof e[0]||"inputType"in e[0]||e[0]===this?("object"!=typeof e[0]||"object"==typeof e[0]&&"inputType"in e[0])&&e.unshift(this):e.splice(0,1,this),e},getHandlerArgs:function(t,e){var n=t,i=n[1];return"object"==typeof inputType&&n.splice(1,1,i.inputType),n.slice(e?1:2)},getSystemHandlerArgs:function(t,e){return t},buildEventPayload:function(){var t=this.ensureClientArg(s.getLeaklessArgs(arguments)),e=t[1];return a.isPlainObject(e)?a.extend(e,{namespace:this.namespace}):{data:e||null,namespace:this.namespace}}};a.each(["handle","transition","deferUntilTransition","processQueue","clearQueue"],function(t){r[t]=function(){var e=this.ensureClientArg(s.getLeaklessArgs(arguments));return i.prototype[t].apply(this,e)}}),r=i.extend(r),t.exports=r},function(t,e,n){function i(t){s.extend(this,t),s.defaults(this,a.getDefaultBehavioralOptions()),this.initialize.apply(this,arguments),o.emit(c.NEW_FSM,this)}var s=n(1),a=n(3),r=n(2),o=r.instance,c=n(4),u="__machina__";s.extend(i.prototype,{initialize:function(){},initClient:function(t){var e=this.initialState;if(!e)throw new Error("You must specify an initial state for this FSM");if(!this.states[e])throw new Error("The initial state specified does not exist in the states object.");this.transition(t,e)},configForState:function(t){var e,n=this.states[t];return s.each(this.hierarchy,function(t,e){t&&"function"==typeof t.off&&t.off()}),n._child&&(n._child=a.getChildFsmInstance(n._child),e=n._child&&n._child.instance,this.hierarchy[e.namespace]=a.listenToChild(this,e)),e},ensureClientMeta:function(t){if("object"!=typeof t)throw new Error("An FSM client must be an object.");return t[u]=t[u]||{},t[u][this.namespace]||(t[u][this.namespace]=s.cloneDeep(a.getDefaultClientMeta()),this.initClient(t)),t[u][this.namespace]},buildEventPayload:function(t,e){return s.isPlainObject(e)?s.extend(e,{client:t,namespace:this.namespace}):{client:t,data:e||null,namespace:this.namespace}},getHandlerArgs:function(t,e){var n=t.slice(0),i=n[1];return"object"==typeof i&&n.splice(1,1,i.inputType),e?n:[n[0]].concat(n.slice(2))},getSystemHandlerArgs:function(t,e){return[e].concat(t)},handle:function(t,e){var n=e;if("undefined"==typeof e)throw new Error("The input argument passed to the FSM's handle method is undefined. Did you forget to pass the input name?");"string"==typeof e&&(n={inputType:e,delegated:!1,ticket:void 0});var i=this.ensureClientMeta(t),r=a.getLeaklessArgs(arguments);"object"!=typeof e&&r.splice(1,1,n),i.currentActionArgs=r.slice(1);var o,u,l,p,h,f=i.state,d=this.states[f],g=!1;if(!i.inExitHandler)if(l=this.configForState(f),!l||this.pendingDelegations[n.ticket]||n.bubbling){n.ticket&&this.pendingDelegations[n.ticket]&&delete this.pendingDelegations[n.ticket],o=d[n.inputType]?n.inputType:"*",g="*"===o,u=d[o]||this[o]||this["*"],h=i.state+"."+o,i.currentAction=h;var m=this.buildEventPayload(t,{inputType:n.inputType,delegated:n.delegated,ticket:n.ticket});u?(this.emit(c.HANDLING,m),"function"==typeof u?p=u.apply(this,this.getHandlerArgs(r,g)):(p=u,this.transition(t,u)),this.emit(c.HANDLED,m)):this.emit(c.NO_HANDLER,s.extend({args:r},m)),i.priorAction=i.currentAction,i.currentAction="",i.currentActionArgs=void 0}else n.ticket=n.ticket||a.createUUID(),n.delegated=!0,this.pendingDelegations[n.ticket]={delegatedTo:l.namespace},p=l.handle.apply(l,r);return p},transition:function(t,e){var n,i=this.ensureClientMeta(t),s=i.state,r=this.states[s],o=this.states[e],u=a.getLeaklessArgs(arguments).slice(2);if(!i.inExitHandler&&e!==s){if(o){n=this.configForState(e),r&&r._onExit&&(i.inExitHandler=!0,r._onExit.call(this,t),i.inExitHandler=!1),i.targetReplayState=e,i.priorState=s,i.state=e;var l=this.buildEventPayload(t,{fromState:i.priorState,action:i.currentAction,toState:e});return this.emit(c.TRANSITION,l),o._onEnter&&o._onEnter.apply(this,this.getSystemHandlerArgs(u,t)),this.emit(c.TRANSITIONED,l),n&&n.handle(t,"_reset"),void(i.targetReplayState===e&&this.processQueue(t,c.NEXT_TRANSITION))}this.emit(c.INVALID_STATE,this.buildEventPayload(t,{state:i.state,attemptedState:e}))}},deferUntilTransition:function(t,e){var n=this.ensureClientMeta(t);if(n.currentActionArgs){var i={type:c.NEXT_TRANSITION,untilState:e,args:n.currentActionArgs};n.inputQueue.push(i);var s=this.buildEventPayload(t,{state:n.state,queuedArgs:i});this.emit(c.DEFERRED,s)}},deferAndTransition:function(t,e){this.deferUntilTransition(t,e),this.transition(t,e)},processQueue:function(t){var e=this.ensureClientMeta(t),n=function(t){return!t.untilState||t.untilState===e.state},i=s.filter(e.inputQueue,n);e.inputQueue=s.difference(e.inputQueue,i),s.each(i,function(e){this.handle.apply(this,[t].concat(e.args))}.bind(this))},clearQueue:function(t,e){var n=this.ensureClientMeta(t);if(e){var i=function(t){return e?t.untilState!==e:!0};n.inputQueue=s.filter(n.inputQueue,i)}else n.inputQueue=[]},compositeState:function(t){var e=this.ensureClientMeta(t),n=e.state,i=this.states[n]._child&&this.states[n]._child.instance;return i&&(n+="."+i.compositeState(t)),n}},r.getInstance()),i.extend=a.extend,t.exports=i}])}); //# sourceMappingURL=machina.min.js.map diff --git a/lib/machina.min.js.map b/lib/machina.min.js.map index 3b0b5b4..935e993 100644 --- a/lib/machina.min.js.map +++ b/lib/machina.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","machina.js","webpack:/webpack/bootstrap acca941d5a487012791a","webpack:///src/machina.js","webpack:/external {\"root\":\"_\",\"commonjs\":\"lodash\",\"commonjs2\":\"lodash\",\"amd\":\"lodash\"}","webpack:///src/emitter.js","webpack:///src/utils.js","webpack:///src/events.js","webpack:///src/Fsm.js","webpack:///src/BehavioralFsm.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_","emitter","merge","instance","Fsm","BehavioralFsm","utils","eventListeners","newFsm","getInstance","emit","eventName","args","getLeaklessArgs","arguments","each","callback","useSafeEmit","apply","exception","console","log","stack","slice","on","self","*","push","off","without","getDefaultBehavioralOptions","initialState","states","namespace","makeFsmNamespace","hierarchy","pendingDelegations","getDefaultClientMeta","inputQueue","targetReplayState","state","undefined","priorState","priorAction","currentAction","currentActionArgs","inExitHandler","startIdx","result","i","length","getChildFsmInstance","config","childFsmDefinition","listenToChild","fsm","child","data","events","NO_HANDLER","ticket","delegated","bubbling","inputType","handle","HANDLING","createUUID","s","hexDigits","substr","Math","floor","random","join","machinaCount","_machKeys","extend","protoProps","staticProps","parent","machObj","Ctor","hasOwnProperty","constructor","blendedState","instanceStates","cloneDeep","prototype","transform","accum","val","key","indexOf","__super__","getDefaultOptions","NEXT_TRANSITION","HANDLED","TRANSITION","TRANSITIONED","INVALID_STATE","DEFERRED","NEW_FSM","ensureClientMeta","initClient","Error","transition","_stamped","defaults","ensureClientArg","_args","unshift","splice","getHandlerArgs","isCatchAll","input","getSystemHandlerArgs","client","buildEventPayload","isPlainObject","methodWithClientInjected","options","initialize","topLevelEmitter","MACHINA_PROP","configForState","newState","newStateObj","childListener","_child","concat","inputDef","clientMeta","handlerName","handler","action","currentState","stateObj","eventPayload","delegatedTo","curState","curStateObj","_onExit","fromState","toState","_onEnter","processQueue","attemptedState","deferUntilTransition","stateName","queued","type","untilState","queuedArgs","deferAndTransition","filterFn","item","toProcess","filter","difference","bind","clearQueue","name","evnt","compositeState"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,WACA,kBAAAC,SAAAA,OAAAC,IACAD,QAAA,UAAAJ,GACA,gBAAAC,SACAA,QAAA,QAAAD,EAAAG,QAAA,WAEAJ,EAAA,QAAAC,EAAAD,EAAA,KACCO,KAAA,SAAAC,GACD,MCOgB,UAAUC,GCb1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAT,OAGA,IAAAC,GAAAS,EAAAD,IACAT,WACAW,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAZ,EAAAD,QAAAC,EAAAA,EAAAD,QAAAQ,GAGAP,EAAAW,QAAA,EAGAX,EAAAD,QAvBA,GAAAU,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDuBM,SAAUP,EAAQD,EAASQ,GE7DjC,GAAAS,GAAAT,EAAA,GACAU,EAAAV,EAAA,EAEAP,GAAAD,QAAAiB,EAAAE,MAAAD,EAAAE,UACAC,IAAAb,EAAA,GACAc,cAAAd,EAAA,GACAe,MAAAf,EAAA,GACAgB,gBACAC,cFsEM,SAAUxB,EAAQD,GG9ExBC,EAAAD,QAAAM,GHoFM,SAAUL,EAAQD,EAASQ,GIjFjC,QAAAkB,KACA,OACAC,KAAA,SAAAC,GACA,GAAAC,GA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AAA4E,OAAA9C,MAAA9B,MAAAgI,GAAAa,OAAA0B,EAAA/I,QACGmJ,KAAA3K,QAGH4K,WAAA,SAAA5C,EAAA6C,GACA,GAAA9B,GAAA/I,KAAAkH,iBAAAc,EACA,IAAA6C,EAEG,CACH,GAAAJ,GAAA,SAAAK,GACA,MAAAD,GAAAC,EAAAX,aAAAU,GAAA,EAEA9B,GAAA7F,WAAAtC,EAAA6J,OAAA1B,EAAA7F,WAAAuH,OALA1B,GAAA7F,eASA6H,eAAA,SAAA/C,GACA,GAAAe,GAAA/I,KAAAkH,iBAAAc,GACA5E,EAAA2F,EAAA3F,MACAgB,EAAApE,KAAA4C,OAAAQ,GAAAwF,QAAA5I,KAAA4C,OAAAQ,GAAAwF,OAAA7H,QAIA,OAHAqD,KACAhB,GAAA,IAAAgB,EAAA2G,eAAA/C,IAEA5E,IAECvC,EAAAQ,eAEDJ,EAAAuE,OAAAtE,EAAAsE,OAEA5F,EAAAD,QAAAsB","file":"machina.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"lodash\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"lodash\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"machina\"] = factory(require(\"lodash\"));\n\telse\n\t\troot[\"machina\"] = factory(root[\"_\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","/*!\n * * machina - A library for creating powerful and flexible finite state machines. Loosely inspired by Erlang/OTP's gen_fsm behavior.\n * * Author: Jim Cowart (http://ifandelse.com)\n * * Version: v2.0.2\n * * Url: http://machina-js.org/\n * * License(s): \n */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"lodash\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"lodash\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"machina\"] = factory(require(\"lodash\"));\n\telse\n\t\troot[\"machina\"] = factory(root[\"_\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar _ = __webpack_require__( 1 );\n\tvar emitter = __webpack_require__( 2 );\n\t\n\tmodule.exports = _.merge( emitter.instance, {\n\t\tFsm: __webpack_require__( 5 ),\n\t\tBehavioralFsm: __webpack_require__( 6 ),\n\t\tutils: __webpack_require__( 3 ),\n\t\teventListeners: {\n\t\t\tnewFsm: []\n\t\t}\n\t} );\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar utils = __webpack_require__( 3 );\n\tvar _ = __webpack_require__( 1 );\n\t\n\tfunction getInstance() {\n\t\treturn {\n\t\t\temit: function( eventName ) {\n\t\t\t\tvar args = utils.getLeaklessArgs( arguments );\n\t\t\t\tif ( this.eventListeners[ \"*\" ] ) {\n\t\t\t\t\t_.each( this.eventListeners[ \"*\" ], function( callback ) {\n\t\t\t\t\t\tif ( !this.useSafeEmit ) {\n\t\t\t\t\t\t\tcallback.apply( this, args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tcallback.apply( this, args );\n\t\t\t\t\t\t\t} catch ( exception ) {\n\t\t\t\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\t\t\t\tif ( console && typeof console.log !== \"undefined\" ) {\n\t\t\t\t\t\t\t\t\tconsole.log( exception.stack );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}, this );\n\t\t\t\t}\n\t\t\t\tif ( this.eventListeners[ eventName ] ) {\n\t\t\t\t\t_.each( this.eventListeners[ eventName ], function( callback ) {\n\t\t\t\t\t\tif ( !this.useSafeEmit ) {\n\t\t\t\t\t\t\tcallback.apply( this, args.slice( 1 ) );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tcallback.apply( this, args.slice( 1 ) );\n\t\t\t\t\t\t\t} catch ( exception ) {\n\t\t\t\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\t\t\t\tif ( console && typeof console.log !== \"undefined\" ) {\n\t\t\t\t\t\t\t\t\tconsole.log( exception.stack );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}, this );\n\t\t\t\t}\n\t\t\t},\n\t\n\t\t\ton: function( eventName, callback ) {\n\t\t\t\tvar self = this;\n\t\t\t\tself.eventListeners = self.eventListeners || { \"*\": [] };\n\t\t\t\tif ( !self.eventListeners[ eventName ] ) {\n\t\t\t\t\tself.eventListeners[ eventName ] = [];\n\t\t\t\t}\n\t\t\t\tself.eventListeners[ eventName ].push( callback );\n\t\t\t\treturn {\n\t\t\t\t\teventName: eventName,\n\t\t\t\t\tcallback: callback,\n\t\t\t\t\toff: function() {\n\t\t\t\t\t\tself.off( eventName, callback );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\n\t\t\toff: function( eventName, callback ) {\n\t\t\t\tthis.eventListeners = this.eventListeners || { \"*\": [] };\n\t\t\t\tif ( !eventName ) {\n\t\t\t\t\tthis.eventListeners = {};\n\t\t\t\t} else {\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tthis.eventListeners[ eventName ] = _.without( this.eventListeners[ eventName ], callback );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.eventListeners[ eventName ] = [];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tmodule.exports = {\n\t\tgetInstance: getInstance,\n\t\tinstance: getInstance()\n\t};\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar slice = [].slice;\n\tvar events = __webpack_require__( 4 );\n\tvar _ = __webpack_require__( 1 );\n\t\n\tvar makeFsmNamespace = ( function() {\n\t\tvar machinaCount = 0;\n\t\treturn function() {\n\t\t\treturn \"fsm.\" + machinaCount++;\n\t\t};\n\t} )();\n\t\n\tfunction getDefaultBehavioralOptions() {\n\t\treturn {\n\t\t\tinitialState: \"uninitialized\",\n\t\t\teventListeners: {\n\t\t\t\t\"*\": []\n\t\t\t},\n\t\t\tstates: {},\n\t\t\tnamespace: makeFsmNamespace(),\n\t\t\tuseSafeEmit: false,\n\t\t\thierarchy: {},\n\t\t\tpendingDelegations: {}\n\t\t};\n\t}\n\t\n\tfunction getDefaultClientMeta() {\n\t\treturn {\n\t\t\tinputQueue: [],\n\t\t\ttargetReplayState: \"\",\n\t\t\tstate: undefined,\n\t\t\tpriorState: undefined,\n\t\t\tpriorAction: \"\",\n\t\t\tcurrentAction: \"\",\n\t\t\tcurrentActionArgs: undefined,\n\t\t\tinExitHandler: false\n\t\t};\n\t}\n\t\n\tfunction getLeaklessArgs( args, startIdx ) {\n\t\tvar result = [];\n\t\tfor ( var i = ( startIdx || 0 ); i < args.length; i++ ) {\n\t\t\tresult[ i ] = args[ i ];\n\t\t}\n\t\treturn result;\n\t}\n\t/*\n\t\thandle ->\n\t\t\tchild = stateObj._child && stateObj._child.instance;\n\t\n\t\ttransition ->\n\t\t\tnewStateObj._child = getChildFsmInstance( newStateObj._child );\n\t\t\tchild = newStateObj._child && newStateObj._child.instance;\n\t*/\n\tfunction getChildFsmInstance( config ) {\n\t\tif ( !config ) {\n\t\t\treturn;\n\t\t}\n\t\tvar childFsmDefinition = {};\n\t\tif ( typeof config === \"object\" ) {\n\t\t\t// is this a config object with a factory?\n\t\t\tif ( config.factory ) {\n\t\t\t\tchildFsmDefinition = config;\n\t\t\t\tchildFsmDefinition.instance = childFsmDefinition.factory();\n\t\t\t} else {\n\t\t\t\t// assuming this is a machina instance\n\t\t\t\tchildFsmDefinition.factory = function() {\n\t\t\t\t\treturn config;\n\t\t\t\t};\n\t\t\t}\n\t\t} else if ( typeof config === \"function\" ) {\n\t\t\tchildFsmDefinition.factory = config;\n\t\t}\n\t\tchildFsmDefinition.instance = childFsmDefinition.factory();\n\t\treturn childFsmDefinition;\n\t}\n\t\n\tfunction listenToChild( fsm, child ) {\n\t\t// Need to investigate potential for discarded event\n\t\t// listener memory leak in long-running, deeply-nested hierarchies.\n\t\treturn child.on( \"*\", function( eventName, data ) {\n\t\t\tswitch ( eventName ) {\n\t\t\t\tcase events.NO_HANDLER:\n\t\t\t\t\tif ( !data.ticket && !data.delegated && data.namespace !== fsm.namespace ) {\n\t\t\t\t\t\t// Ok - we're dealing w/ a child handling input that should bubble up\n\t\t\t\t\t\tdata.args[ 1 ].bubbling = true;\n\t\t\t\t\t}\n\t\t\t\t\t// we do NOT bubble _reset inputs up to the parent\n\t\t\t\t\tif ( data.inputType !== \"_reset\" ) {\n\t\t\t\t\t\tfsm.handle.apply( fsm, data.args );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase events.HANDLING :\n\t\t\t\t\tvar ticket = data.ticket;\n\t\t\t\t\tif ( ticket && fsm.pendingDelegations[ ticket ] ) {\n\t\t\t\t\t\tdelete fsm.pendingDelegations[ ticket ];\n\t\t\t\t\t}\n\t\t\t\t\tfsm.emit( eventName, data ); // possibly transform payload?\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tfsm.emit( eventName, data ); // possibly transform payload?\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} );\n\t}\n\t\n\t// _machKeys are members we want to track across the prototype chain of an extended FSM constructor\n\t// Since we want to eventually merge the aggregate of those values onto the instance so that FSMs\n\t// that share the same extended prototype won't share state *on* those prototypes.\n\tvar _machKeys = [ \"states\", \"initialState\" ];\n\tvar extend = function( protoProps, staticProps ) {\n\t\tvar parent = this;\n\t\tvar fsm; // placeholder for instance constructor\n\t\tvar machObj = {}; // object used to hold initialState & states from prototype for instance-level merging\n\t\tvar Ctor = function() {}; // placeholder ctor function used to insert level in prototype chain\n\t\n\t\t// The constructor function for the new subclass is either defined by you\n\t\t// (the \"constructor\" property in your `extend` definition), or defaulted\n\t\t// by us to simply call the parent's constructor.\n\t\tif ( protoProps && protoProps.hasOwnProperty( \"constructor\" ) ) {\n\t\t\tfsm = protoProps.constructor;\n\t\t} else {\n\t\t\t// The default machina constructor (when using inheritance) creates a\n\t\t\t// deep copy of the states/initialState values from the prototype and\n\t\t\t// extends them over the instance so that they'll be instance-level.\n\t\t\t// If an options arg (args[0]) is passed in, a states or intialState\n\t\t\t// value will be preferred over any data pulled up from the prototype.\n\t\t\tfsm = function() {\n\t\t\t\tvar args = slice.call( arguments, 0 );\n\t\t\t\targs[ 0 ] = args[ 0 ] || {};\n\t\t\t\tvar blendedState;\n\t\t\t\tvar instanceStates = args[ 0 ].states || {};\n\t\t\t\tblendedState = _.merge( _.cloneDeep( machObj ), { states: instanceStates } );\n\t\t\t\tblendedState.initialState = args[ 0 ].initialState || this.initialState;\n\t\t\t\t_.extend( args[ 0 ], blendedState );\n\t\t\t\tparent.apply( this, args );\n\t\t\t};\n\t\t}\n\t\n\t\t// Inherit class (static) properties from parent.\n\t\t_.merge( fsm, parent );\n\t\n\t\t// Set the prototype chain to inherit from `parent`, without calling\n\t\t// `parent`'s constructor function.\n\t\tCtor.prototype = parent.prototype;\n\t\tfsm.prototype = new Ctor();\n\t\n\t\t// Add prototype properties (instance properties) to the subclass,\n\t\t// if supplied.\n\t\tif ( protoProps ) {\n\t\t\t_.extend( fsm.prototype, protoProps );\n\t\t\t_.merge( machObj, _.transform( protoProps, function( accum, val, key ) {\n\t\t\t\tif ( _machKeys.indexOf( key ) !== -1 ) {\n\t\t\t\t\taccum[ key ] = val;\n\t\t\t\t}\n\t\t\t} ) );\n\t\t}\n\t\n\t\t// Add static properties to the constructor function, if supplied.\n\t\tif ( staticProps ) {\n\t\t\t_.merge( fsm, staticProps );\n\t\t}\n\t\n\t\t// Correctly set child's `prototype.constructor`.\n\t\tfsm.prototype.constructor = fsm;\n\t\n\t\t// Set a convenience property in case the parent's prototype is needed later.\n\t\tfsm.__super__ = parent.prototype;\n\t\treturn fsm;\n\t};\n\t\n\tfunction createUUID() {\n\t\tvar s = [];\n\t\tvar hexDigits = \"0123456789abcdef\";\n\t\tfor ( var i = 0; i < 36; i++ ) {\n\t\t\ts[ i ] = hexDigits.substr( Math.floor( Math.random() * 0x10 ), 1 );\n\t\t}\n\t\ts[ 14 ] = \"4\"; // bits 12-15 of the time_hi_and_version field to 0010\n\t\t/* jshint ignore:start */\n\t\ts[ 19 ] = hexDigits.substr( ( s[ 19 ] & 0x3 ) | 0x8, 1 ); // bits 6-7 of the clock_seq_hi_and_reserved to 01\n\t\t/* jshint ignore:end */\n\t\ts[ 8 ] = s[ 13 ] = s[ 18 ] = s[ 23 ] = \"-\";\n\t\treturn s.join( \"\" );\n\t}\n\t\n\tmodule.exports = {\n\t\tcreateUUID: createUUID,\n\t\textend: extend,\n\t\tgetDefaultBehavioralOptions: getDefaultBehavioralOptions,\n\t\tgetDefaultOptions: getDefaultBehavioralOptions,\n\t\tgetDefaultClientMeta: getDefaultClientMeta,\n\t\tgetChildFsmInstance: getChildFsmInstance,\n\t\tgetLeaklessArgs: getLeaklessArgs,\n\t\tlistenToChild: listenToChild,\n\t\tmakeFsmNamespace: makeFsmNamespace\n\t};\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = {\n\t\tNEXT_TRANSITION: \"transition\",\n\t\tHANDLING: \"handling\",\n\t\tHANDLED: \"handled\",\n\t\tNO_HANDLER: \"nohandler\",\n\t\tTRANSITION: \"transition\",\n\t\tTRANSITIONED: \"transitioned\",\n\t\tINVALID_STATE: \"invalidstate\",\n\t\tDEFERRED: \"deferred\",\n\t\tNEW_FSM: \"newfsm\"\n\t};\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar BehavioralFsm = __webpack_require__( 6 );\n\tvar utils = __webpack_require__( 3 );\n\tvar _ = __webpack_require__( 1 );\n\t\n\tvar Fsm = {\n\t\tconstructor: function() {\n\t\t\tBehavioralFsm.apply( this, arguments );\n\t\t\tthis.ensureClientMeta();\n\t\t},\n\t\tinitClient: function initClient() {\n\t\t\tvar initialState = this.initialState;\n\t\t\tif ( !initialState ) {\n\t\t\t\tthrow new Error( \"You must specify an initial state for this FSM\" );\n\t\t\t}\n\t\t\tif ( !this.states[ initialState ] ) {\n\t\t\t\tthrow new Error( \"The initial state specified does not exist in the states object.\" );\n\t\t\t}\n\t\t\tthis.transition( initialState );\n\t\t},\n\t\tensureClientMeta: function ensureClientMeta() {\n\t\t\tif ( !this._stamped ) {\n\t\t\t\tthis._stamped = true;\n\t\t\t\t_.defaults( this, _.cloneDeep( utils.getDefaultClientMeta() ) );\n\t\t\t\tthis.initClient();\n\t\t\t}\n\t\t\treturn this;\n\t\t},\n\t\n\t\tensureClientArg: function( args ) {\n\t\t\tvar _args = args;\n\t\t\t// we need to test the args and verify that if a client arg has\n\t\t\t// been passed, it must be this FSM instance (this isn't a behavioral FSM)\n\t\t\tif ( typeof _args[ 0 ] === \"object\" && !( \"inputType\" in _args[ 0 ] ) && _args[ 0 ] !== this ) {\n\t\t\t\t_args.splice( 0, 1, this );\n\t\t\t} else if ( typeof _args[ 0 ] !== \"object\" || ( typeof _args[ 0 ] === \"object\" && ( \"inputType\" in _args[ 0 ] ) ) ) {\n\t\t\t\t_args.unshift( this );\n\t\t\t}\n\t\t\treturn _args;\n\t\t},\n\t\n\t\tgetHandlerArgs: function( args, isCatchAll ) {\n\t\t\t// index 0 is the client, index 1 is inputType\n\t\t\t// if we're in a catch-all handler, input type needs to be included in the args\n\t\t\t// inputType might be an object, so we need to just get the inputType string if so\n\t\t\tvar _args = args;\n\t\t\tvar input = _args[ 1 ];\n\t\t\tif ( typeof inputType === \"object\" ) {\n\t\t\t\t_args.splice( 1, 1, input.inputType );\n\t\t\t}\n\t\t\treturn isCatchAll ?\n\t\t\t\t_args.slice( 1 ) :\n\t\t\t\t_args.slice( 2 );\n\t\t},\n\t\n\t\tgetSystemHandlerArgs: function( args, client ) {\n\t\t\treturn args;\n\t\t},\n\t\n\t\t// \"classic\" machina FSM do not emit the client property on events (which would be the FSM itself)\n\t\tbuildEventPayload: function() {\n\t\t\tvar args = this.ensureClientArg( utils.getLeaklessArgs( arguments ) );\n\t\t\tvar data = args[ 1 ];\n\t\t\tif ( _.isPlainObject( data ) ) {\n\t\t\t\treturn _.extend( data, { namespace: this.namespace } );\n\t\t\t} else {\n\t\t\t\treturn { data: data || null, namespace: this.namespace };\n\t\t\t}\n\t\t}\n\t};\n\t\n\t_.each( [\n\t\t\"handle\",\n\t\t\"transition\",\n\t\t\"deferUntilTransition\",\n\t\t\"processQueue\",\n\t\t\"clearQueue\"\n\t], function( methodWithClientInjected ) {\n\t\tFsm[ methodWithClientInjected ] = function() {\n\t\t\tvar args = this.ensureClientArg( utils.getLeaklessArgs( arguments ) );\n\t\t\treturn BehavioralFsm.prototype[ methodWithClientInjected ].apply( this, args );\n\t\t};\n\t} );\n\t\n\tFsm = BehavioralFsm.extend( Fsm );\n\t\n\tmodule.exports = Fsm;\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar _ = __webpack_require__( 1 );\n\tvar utils = __webpack_require__( 3 );\n\tvar emitter = __webpack_require__( 2 );\n\tvar topLevelEmitter = emitter.instance;\n\tvar events = __webpack_require__( 4 );\n\t\n\tvar MACHINA_PROP = \"__machina__\";\n\t\n\tfunction BehavioralFsm( options ) {\n\t\t_.extend( this, options );\n\t\t_.defaults( this, utils.getDefaultBehavioralOptions() );\n\t\tthis.initialize.apply( this, arguments );\n\t\ttopLevelEmitter.emit( events.NEW_FSM, this );\n\t}\n\t\n\t_.extend( BehavioralFsm.prototype, {\n\t\tinitialize: function() {},\n\t\n\t\tinitClient: function initClient( client ) {\n\t\t\tvar initialState = this.initialState;\n\t\t\tif ( !initialState ) {\n\t\t\t\tthrow new Error( \"You must specify an initial state for this FSM\" );\n\t\t\t}\n\t\t\tif ( !this.states[ initialState ] ) {\n\t\t\t\tthrow new Error( \"The initial state specified does not exist in the states object.\" );\n\t\t\t}\n\t\t\tthis.transition( client, initialState );\n\t\t},\n\t\n\t\tconfigForState: function configForState( newState ) {\n\t\t\tvar newStateObj = this.states[ newState ];\n\t\t\tvar child;\n\t\t\t_.each( this.hierarchy, function( childListener, key ) {\n\t\t\t\tif ( childListener && typeof childListener.off === \"function\" ) {\n\t\t\t\t\tchildListener.off();\n\t\t\t\t}\n\t\t\t} );\n\t\n\t\t\tif ( newStateObj._child ) {\n\t\t\t\tnewStateObj._child = utils.getChildFsmInstance( newStateObj._child );\n\t\t\t\tchild = newStateObj._child && newStateObj._child.instance;\n\t\t\t\tthis.hierarchy[ child.namespace ] = utils.listenToChild( this, child );\n\t\t\t}\n\t\n\t\t\treturn child;\n\t\t},\n\t\n\t\tensureClientMeta: function ensureClientMeta( client ) {\n\t\t\tif ( typeof client !== \"object\" ) {\n\t\t\t\tthrow new Error( \"An FSM client must be an object.\" );\n\t\t\t}\n\t\t\tclient[ MACHINA_PROP ] = client[ MACHINA_PROP ] || {};\n\t\t\tif ( !client[ MACHINA_PROP ][ this.namespace ] ) {\n\t\t\t\tclient[ MACHINA_PROP ][ this.namespace ] = _.cloneDeep( utils.getDefaultClientMeta() );\n\t\t\t\tthis.initClient( client );\n\t\t\t}\n\t\t\treturn client[ MACHINA_PROP ][ this.namespace ];\n\t\t},\n\t\n\t\tbuildEventPayload: function( client, data ) {\n\t\t\tif ( _.isPlainObject( data ) ) {\n\t\t\t\treturn _.extend( data, { client: client, namespace: this.namespace } );\n\t\t\t} else {\n\t\t\t\treturn { client: client, data: data || null, namespace: this.namespace };\n\t\t\t}\n\t\t},\n\t\n\t\tgetHandlerArgs: function( args, isCatchAll ) {\n\t\t\t// index 0 is the client, index 1 is inputType\n\t\t\t// if we're in a catch-all handler, input type needs to be included in the args\n\t\t\t// inputType might be an object, so we need to just get the inputType string if so\n\t\t\tvar _args = args.slice( 0 );\n\t\t\tvar input = _args[ 1 ];\n\t\t\tif ( typeof input === \"object\" ) {\n\t\t\t\t_args.splice( 1, 1, input.inputType );\n\t\t\t}\n\t\t\treturn isCatchAll ?\n\t\t\t\t_args :\n\t\t\t\t[ _args[ 0 ] ].concat( _args.slice( 2 ) );\n\t\t},\n\t\n\t\tgetSystemHandlerArgs: function( args, client ) {\n\t\t\treturn [ client ].concat( args );\n\t\t},\n\t\n\t\thandle: function( client, input ) {\n\t\t\tvar inputDef = input;\n\t\t\tif ( typeof input === \"undefined\" ) {\n\t\t\t\tthrow new Error( \"The input argument passed to the FSM's handle method is undefined. Did you forget to pass the input name?\" );\n\t\t\t}\n\t\t\tif ( typeof input === \"string\" ) {\n\t\t\t\tinputDef = { inputType: input, delegated: false, ticket: undefined };\n\t\t\t}\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tvar args = utils.getLeaklessArgs( arguments );\n\t\t\tif ( typeof input !== \"object\" ) {\n\t\t\t\targs.splice( 1, 1, inputDef );\n\t\t\t}\n\t\t\tclientMeta.currentActionArgs = args.slice( 1 );\n\t\t\tvar currentState = clientMeta.state;\n\t\t\tvar stateObj = this.states[ currentState ];\n\t\t\tvar handlerName;\n\t\t\tvar handler;\n\t\t\tvar isCatchAll = false;\n\t\t\tvar child;\n\t\t\tvar result;\n\t\t\tvar action;\n\t\t\tif ( !clientMeta.inExitHandler ) {\n\t\t\t\tchild = this.configForState( currentState );\n\t\t\t\tif ( child && !this.pendingDelegations[ inputDef.ticket ] && !inputDef.bubbling ) {\n\t\t\t\t\tinputDef.ticket = ( inputDef.ticket || utils.createUUID() );\n\t\t\t\t\tinputDef.delegated = true;\n\t\t\t\t\tthis.pendingDelegations[ inputDef.ticket ] = { delegatedTo: child.namespace };\n\t\t\t\t\t// WARNING - returning a value from `handle` on child FSMs is not really supported.\n\t\t\t\t\t// If you need to return values from child FSM input handlers, use events instead.\n\t\t\t\t\tresult = child.handle.apply( child, args );\n\t\t\t\t} else {\n\t\t\t\t\tif ( inputDef.ticket && this.pendingDelegations[ inputDef.ticket ] ) {\n\t\t\t\t\t\tdelete this.pendingDelegations[ inputDef.ticket ];\n\t\t\t\t\t}\n\t\t\t\t\thandlerName = stateObj[ inputDef.inputType ] ? inputDef.inputType : \"*\";\n\t\t\t\t\tisCatchAll = ( handlerName === \"*\" );\n\t\t\t\t\thandler = ( stateObj[ handlerName ] || this[ handlerName ] ) || this[ \"*\" ];\n\t\t\t\t\taction = clientMeta.state + \".\" + handlerName;\n\t\t\t\t\tclientMeta.currentAction = action;\n\t\t\t\t\tvar eventPayload = this.buildEventPayload(\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\t{ inputType: inputDef.inputType, delegated: inputDef.delegated, ticket: inputDef.ticket }\n\t\t\t\t\t);\n\t\t\t\t\tif ( !handler ) {\n\t\t\t\t\t\tthis.emit( events.NO_HANDLER, _.extend( { args: args }, eventPayload ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.emit( events.HANDLING, eventPayload );\n\t\t\t\t\t\tif ( typeof handler === \"function\" ) {\n\t\t\t\t\t\t\tresult = handler.apply( this, this.getHandlerArgs( args, isCatchAll ) );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult = handler;\n\t\t\t\t\t\t\tthis.transition( client, handler );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.emit( events.HANDLED, eventPayload );\n\t\t\t\t\t}\n\t\t\t\t\tclientMeta.priorAction = clientMeta.currentAction;\n\t\t\t\t\tclientMeta.currentAction = \"\";\n\t\t\t\t\tclientMeta.currentActionArgs = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t\n\t\ttransition: function( client, newState ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tvar curState = clientMeta.state;\n\t\t\tvar curStateObj = this.states[ curState ];\n\t\t\tvar newStateObj = this.states[ newState ];\n\t\t\tvar child;\n\t\t\tvar args = utils.getLeaklessArgs( arguments ).slice( 2 );\n\t\t\tif ( !clientMeta.inExitHandler && newState !== curState ) {\n\t\t\t\tif ( newStateObj ) {\n\t\t\t\t\tchild = this.configForState( newState );\n\t\t\t\t\tif ( curStateObj && curStateObj._onExit ) {\n\t\t\t\t\t\tclientMeta.inExitHandler = true;\n\t\t\t\t\t\tcurStateObj._onExit.call( this, client );\n\t\t\t\t\t\tclientMeta.inExitHandler = false;\n\t\t\t\t\t}\n\t\t\t\t\tclientMeta.targetReplayState = newState;\n\t\t\t\t\tclientMeta.priorState = curState;\n\t\t\t\t\tclientMeta.state = newState;\n\t\t\t\t\tvar eventPayload = this.buildEventPayload( client, {\n\t\t\t\t\t\tfromState: clientMeta.priorState,\n\t\t\t\t\t\taction: clientMeta.currentAction,\n\t\t\t\t\t\ttoState: newState\n\t\t\t\t\t} );\n\t\t\t\t\tthis.emit( events.TRANSITION, eventPayload );\n\t\t\t\t\tif ( newStateObj._onEnter ) {\n\t\t\t\t\t\tnewStateObj._onEnter.apply( this, this.getSystemHandlerArgs( args, client ) );\n\t\t\t\t\t}\n\t\t\t\t\tthis.emit( events.TRANSITIONED, eventPayload );\n\t\t\t\t\tif ( child ) {\n\t\t\t\t\t\tchild.handle( client, \"_reset\" );\n\t\t\t\t\t}\n\t\n\t\t\t\t\tif ( clientMeta.targetReplayState === newState ) {\n\t\t\t\t\t\tthis.processQueue( client, events.NEXT_TRANSITION );\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.emit( events.INVALID_STATE, this.buildEventPayload( client, {\n\t\t\t\t\tstate: clientMeta.state,\n\t\t\t\t\tattemptedState: newState\n\t\t\t\t} ) );\n\t\t\t}\n\t\t},\n\t\n\t\tdeferUntilTransition: function( client, stateName ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tif ( clientMeta.currentActionArgs ) {\n\t\t\t\tvar queued = {\n\t\t\t\t\ttype: events.NEXT_TRANSITION,\n\t\t\t\t\tuntilState: stateName,\n\t\t\t\t\targs: clientMeta.currentActionArgs\n\t\t\t\t};\n\t\t\t\tclientMeta.inputQueue.push( queued );\n\t\t\t\tvar eventPayload = this.buildEventPayload( client, {\n\t\t\t\t\tstate: clientMeta.state,\n\t\t\t\t\tqueuedArgs: queued\n\t\t\t\t} );\n\t\t\t\tthis.emit( events.DEFERRED, eventPayload );\n\t\t\t}\n\t\t},\n\t\n\t\tdeferAndTransition: function( client, stateName ) {\n\t\t\tthis.deferUntilTransition( client, stateName );\n\t\t\tthis.transition( client, stateName );\n\t\t},\n\t\n\t\tprocessQueue: function( client ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tvar filterFn = function( item ) {\n\t\t\t\treturn ( ( !item.untilState ) || ( item.untilState === clientMeta.state ) );\n\t\t\t};\n\t\t\tvar toProcess = _.filter( clientMeta.inputQueue, filterFn );\n\t\t\tclientMeta.inputQueue = _.difference( clientMeta.inputQueue, toProcess );\n\t\t\t_.each( toProcess, function( item ) {\n\t\t\t\tthis.handle.apply( this, [ client ].concat( item.args ) );\n\t\t\t}.bind( this ) );\n\t\t},\n\t\n\t\tclearQueue: function( client, name ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tif ( !name ) {\n\t\t\t\tclientMeta.inputQueue = [];\n\t\t\t} else {\n\t\t\t\tvar filter = function( evnt ) {\n\t\t\t\t\treturn ( name ? evnt.untilState !== name : true );\n\t\t\t\t};\n\t\t\t\tclientMeta.inputQueue = _.filter( clientMeta.inputQueue, filter );\n\t\t\t}\n\t\t},\n\t\n\t\tcompositeState: function( client ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tvar state = clientMeta.state;\n\t\t\tvar child = this.states[state]._child && this.states[state]._child.instance;\n\t\t\tif ( child ) {\n\t\t\t\tstate += \".\" + child.compositeState( client );\n\t\t\t}\n\t\t\treturn state;\n\t\t}\n\t}, emitter.getInstance() );\n\t\n\tBehavioralFsm.extend = utils.extend;\n\t\n\tmodule.exports = BehavioralFsm;\n\n\n/***/ })\n/******/ ])\n});\n;\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCBhY2NhOTQxZDVhNDg3MDEyNzkxYSIsIndlYnBhY2s6Ly8vLi9zcmMvbWFjaGluYS5qcyIsIndlYnBhY2s6Ly8vZXh0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RdWV1ZSA9IF8uZmlsdGVyKCBjbGllbnRNZXRhLmlucHV0UXVldWUsIGZpbHRlciApO1xuXHRcdH1cblx0fSxcblxuXHRjb21wb3NpdGVTdGF0ZTogZnVuY3Rpb24oIGNsaWVudCApIHtcblx0XHR2YXIgY2xpZW50TWV0YSA9IHRoaXMuZW5zdXJlQ2xpZW50TWV0YSggY2xpZW50ICk7XG5cdFx0dmFyIHN0YXRlID0gY2xpZW50TWV0YS5zdGF0ZTtcblx0XHR2YXIgY2hpbGQgPSB0aGlzLnN0YXRlc1tzdGF0ZV0uX2NoaWxkICYmIHRoaXMuc3RhdGVzW3N0YXRlXS5fY2hpbGQuaW5zdGFuY2U7XG5cdFx0aWYgKCBjaGlsZCApIHtcblx0XHRcdHN0YXRlICs9IFwiLlwiICsgY2hpbGQuY29tcG9zaXRlU3RhdGUoIGNsaWVudCApO1xuXHRcdH1cblx0XHRyZXR1cm4gc3RhdGU7XG5cdH1cbn0sIGVtaXR0ZXIuZ2V0SW5zdGFuY2UoKSApO1xuXG5CZWhhdmlvcmFsRnNtLmV4dGVuZCA9IHV0aWxzLmV4dGVuZDtcblxubW9kdWxlLmV4cG9ydHMgPSBCZWhhdmlvcmFsRnNtO1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvQmVoYXZpb3JhbEZzbS5qc1xuLy8gbW9kdWxlIGlkID0gNlxuLy8gbW9kdWxlIGNodW5rcyA9IDAiXSwic291cmNlUm9vdCI6IiJ9"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap acca941d5a487012791a","var _ = require( \"lodash\" );\nvar emitter = require( \"./emitter\" );\n\nmodule.exports = _.merge( emitter.instance, {\n\tFsm: require( \"./Fsm\" ),\n\tBehavioralFsm: require( \"./BehavioralFsm\" ),\n\tutils: require( \"./utils\" ),\n\teventListeners: {\n\t\tnewFsm: []\n\t}\n} );\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/machina.js\n// module id = 0\n// module chunks = 0","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"_\",\"commonjs\":\"lodash\",\"commonjs2\":\"lodash\",\"amd\":\"lodash\"}\n// module id = 1\n// module chunks = 0","var utils = require( \"./utils\" );\nvar _ = require( \"lodash\" );\n\nfunction getInstance() {\n\treturn {\n\t\temit: function( eventName ) {\n\t\t\tvar args = utils.getLeaklessArgs( arguments );\n\t\t\tif ( this.eventListeners[ \"*\" ] ) {\n\t\t\t\t_.each( this.eventListeners[ \"*\" ], function( callback ) {\n\t\t\t\t\tif ( !this.useSafeEmit ) {\n\t\t\t\t\t\tcallback.apply( this, args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcallback.apply( this, args );\n\t\t\t\t\t\t} catch ( exception ) {\n\t\t\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\t\t\tif ( console && typeof console.log !== \"undefined\" ) {\n\t\t\t\t\t\t\t\tconsole.log( exception.stack );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, this );\n\t\t\t}\n\t\t\tif ( this.eventListeners[ eventName ] ) {\n\t\t\t\t_.each( this.eventListeners[ eventName ], function( callback ) {\n\t\t\t\t\tif ( !this.useSafeEmit ) {\n\t\t\t\t\t\tcallback.apply( this, args.slice( 1 ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcallback.apply( this, args.slice( 1 ) );\n\t\t\t\t\t\t} catch ( exception ) {\n\t\t\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\t\t\tif ( console && typeof console.log !== \"undefined\" ) {\n\t\t\t\t\t\t\t\tconsole.log( exception.stack );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, this );\n\t\t\t}\n\t\t},\n\n\t\ton: function( eventName, callback ) {\n\t\t\tvar self = this;\n\t\t\tself.eventListeners = self.eventListeners || { \"*\": [] };\n\t\t\tif ( !self.eventListeners[ eventName ] ) {\n\t\t\t\tself.eventListeners[ eventName ] = [];\n\t\t\t}\n\t\t\tself.eventListeners[ eventName ].push( callback );\n\t\t\treturn {\n\t\t\t\teventName: eventName,\n\t\t\t\tcallback: callback,\n\t\t\t\toff: function() {\n\t\t\t\t\tself.off( eventName, callback );\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\n\t\toff: function( eventName, callback ) {\n\t\t\tthis.eventListeners = this.eventListeners || { \"*\": [] };\n\t\t\tif ( !eventName ) {\n\t\t\t\tthis.eventListeners = {};\n\t\t\t} else {\n\t\t\t\tif ( callback ) {\n\t\t\t\t\tthis.eventListeners[ eventName ] = _.without( this.eventListeners[ eventName ], callback );\n\t\t\t\t} else {\n\t\t\t\t\tthis.eventListeners[ eventName ] = [];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n\nmodule.exports = {\n\tgetInstance: getInstance,\n\tinstance: getInstance()\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/emitter.js\n// module id = 2\n// module chunks = 0","var slice = [].slice;\nvar events = require( \"./events.js\" );\nvar _ = require( \"lodash\" );\n\nvar makeFsmNamespace = ( function() {\n\tvar machinaCount = 0;\n\treturn function() {\n\t\treturn \"fsm.\" + machinaCount++;\n\t};\n} )();\n\nfunction getDefaultBehavioralOptions() {\n\treturn {\n\t\tinitialState: \"uninitialized\",\n\t\teventListeners: {\n\t\t\t\"*\": []\n\t\t},\n\t\tstates: {},\n\t\tnamespace: makeFsmNamespace(),\n\t\tuseSafeEmit: false,\n\t\thierarchy: {},\n\t\tpendingDelegations: {}\n\t};\n}\n\nfunction getDefaultClientMeta() {\n\treturn {\n\t\tinputQueue: [],\n\t\ttargetReplayState: \"\",\n\t\tstate: undefined,\n\t\tpriorState: undefined,\n\t\tpriorAction: \"\",\n\t\tcurrentAction: \"\",\n\t\tcurrentActionArgs: undefined,\n\t\tinExitHandler: false\n\t};\n}\n\nfunction getLeaklessArgs( args, startIdx ) {\n\tvar result = [];\n\tfor ( var i = ( startIdx || 0 ); i < args.length; i++ ) {\n\t\tresult[ i ] = args[ i ];\n\t}\n\treturn result;\n}\n/*\n\thandle ->\n\t\tchild = stateObj._child && stateObj._child.instance;\n\n\ttransition ->\n\t\tnewStateObj._child = getChildFsmInstance( newStateObj._child );\n\t\tchild = newStateObj._child && newStateObj._child.instance;\n*/\nfunction getChildFsmInstance( config ) {\n\tif ( !config ) {\n\t\treturn;\n\t}\n\tvar childFsmDefinition = {};\n\tif ( typeof config === \"object\" ) {\n\t\t// is this a config object with a factory?\n\t\tif ( config.factory ) {\n\t\t\tchildFsmDefinition = config;\n\t\t\tchildFsmDefinition.instance = childFsmDefinition.factory();\n\t\t} else {\n\t\t\t// assuming this is a machina instance\n\t\t\tchildFsmDefinition.factory = function() {\n\t\t\t\treturn config;\n\t\t\t};\n\t\t}\n\t} else if ( typeof config === \"function\" ) {\n\t\tchildFsmDefinition.factory = config;\n\t}\n\tchildFsmDefinition.instance = childFsmDefinition.factory();\n\treturn childFsmDefinition;\n}\n\nfunction listenToChild( fsm, child ) {\n\t// Need to investigate potential for discarded event\n\t// listener memory leak in long-running, deeply-nested hierarchies.\n\treturn child.on( \"*\", function( eventName, data ) {\n\t\tswitch ( eventName ) {\n\t\t\tcase events.NO_HANDLER:\n\t\t\t\tif ( !data.ticket && !data.delegated && data.namespace !== fsm.namespace ) {\n\t\t\t\t\t// Ok - we're dealing w/ a child handling input that should bubble up\n\t\t\t\t\tdata.args[ 1 ].bubbling = true;\n\t\t\t\t}\n\t\t\t\t// we do NOT bubble _reset inputs up to the parent\n\t\t\t\tif ( data.inputType !== \"_reset\" ) {\n\t\t\t\t\tfsm.handle.apply( fsm, data.args );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase events.HANDLING :\n\t\t\t\tvar ticket = data.ticket;\n\t\t\t\tif ( ticket && fsm.pendingDelegations[ ticket ] ) {\n\t\t\t\t\tdelete fsm.pendingDelegations[ ticket ];\n\t\t\t\t}\n\t\t\t\tfsm.emit( eventName, data ); // possibly transform payload?\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tfsm.emit( eventName, data ); // possibly transform payload?\n\t\t\t\tbreak;\n\t\t}\n\t} );\n}\n\n// _machKeys are members we want to track across the prototype chain of an extended FSM constructor\n// Since we want to eventually merge the aggregate of those values onto the instance so that FSMs\n// that share the same extended prototype won't share state *on* those prototypes.\nvar _machKeys = [ \"states\", \"initialState\" ];\nvar extend = function( protoProps, staticProps ) {\n\tvar parent = this;\n\tvar fsm; // placeholder for instance constructor\n\tvar machObj = {}; // object used to hold initialState & states from prototype for instance-level merging\n\tvar Ctor = function() {}; // placeholder ctor function used to insert level in prototype chain\n\n\t// The constructor function for the new subclass is either defined by you\n\t// (the \"constructor\" property in your `extend` definition), or defaulted\n\t// by us to simply call the parent's constructor.\n\tif ( protoProps && protoProps.hasOwnProperty( \"constructor\" ) ) {\n\t\tfsm = protoProps.constructor;\n\t} else {\n\t\t// The default machina constructor (when using inheritance) creates a\n\t\t// deep copy of the states/initialState values from the prototype and\n\t\t// extends them over the instance so that they'll be instance-level.\n\t\t// If an options arg (args[0]) is passed in, a states or intialState\n\t\t// value will be preferred over any data pulled up from the prototype.\n\t\tfsm = function() {\n\t\t\tvar args = slice.call( arguments, 0 );\n\t\t\targs[ 0 ] = args[ 0 ] || {};\n\t\t\tvar blendedState;\n\t\t\tvar instanceStates = args[ 0 ].states || {};\n\t\t\tblendedState = _.merge( _.cloneDeep( machObj ), { states: instanceStates } );\n\t\t\tblendedState.initialState = args[ 0 ].initialState || this.initialState;\n\t\t\t_.extend( args[ 0 ], blendedState );\n\t\t\tparent.apply( this, args );\n\t\t};\n\t}\n\n\t// Inherit class (static) properties from parent.\n\t_.merge( fsm, parent );\n\n\t// Set the prototype chain to inherit from `parent`, without calling\n\t// `parent`'s constructor function.\n\tCtor.prototype = parent.prototype;\n\tfsm.prototype = new Ctor();\n\n\t// Add prototype properties (instance properties) to the subclass,\n\t// if supplied.\n\tif ( protoProps ) {\n\t\t_.extend( fsm.prototype, protoProps );\n\t\t_.merge( machObj, _.transform( protoProps, function( accum, val, key ) {\n\t\t\tif ( _machKeys.indexOf( key ) !== -1 ) {\n\t\t\t\taccum[ key ] = val;\n\t\t\t}\n\t\t} ) );\n\t}\n\n\t// Add static properties to the constructor function, if supplied.\n\tif ( staticProps ) {\n\t\t_.merge( fsm, staticProps );\n\t}\n\n\t// Correctly set child's `prototype.constructor`.\n\tfsm.prototype.constructor = fsm;\n\n\t// Set a convenience property in case the parent's prototype is needed later.\n\tfsm.__super__ = parent.prototype;\n\treturn fsm;\n};\n\nfunction createUUID() {\n\tvar s = [];\n\tvar hexDigits = \"0123456789abcdef\";\n\tfor ( var i = 0; i < 36; i++ ) {\n\t\ts[ i ] = hexDigits.substr( Math.floor( Math.random() * 0x10 ), 1 );\n\t}\n\ts[ 14 ] = \"4\"; // bits 12-15 of the time_hi_and_version field to 0010\n\t/* jshint ignore:start */\n\ts[ 19 ] = hexDigits.substr( ( s[ 19 ] & 0x3 ) | 0x8, 1 ); // bits 6-7 of the clock_seq_hi_and_reserved to 01\n\t/* jshint ignore:end */\n\ts[ 8 ] = s[ 13 ] = s[ 18 ] = s[ 23 ] = \"-\";\n\treturn s.join( \"\" );\n}\n\nmodule.exports = {\n\tcreateUUID: createUUID,\n\textend: extend,\n\tgetDefaultBehavioralOptions: getDefaultBehavioralOptions,\n\tgetDefaultOptions: getDefaultBehavioralOptions,\n\tgetDefaultClientMeta: getDefaultClientMeta,\n\tgetChildFsmInstance: getChildFsmInstance,\n\tgetLeaklessArgs: getLeaklessArgs,\n\tlistenToChild: listenToChild,\n\tmakeFsmNamespace: makeFsmNamespace\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/utils.js\n// module id = 3\n// module chunks = 0","module.exports = {\n\tNEXT_TRANSITION: \"transition\",\n\tHANDLING: \"handling\",\n\tHANDLED: \"handled\",\n\tNO_HANDLER: \"nohandler\",\n\tTRANSITION: \"transition\",\n\tTRANSITIONED: \"transitioned\",\n\tINVALID_STATE: \"invalidstate\",\n\tDEFERRED: \"deferred\",\n\tNEW_FSM: \"newfsm\"\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/events.js\n// module id = 4\n// module chunks = 0","var BehavioralFsm = require( \"./BehavioralFsm\" );\nvar utils = require( \"./utils\" );\nvar _ = require( \"lodash\" );\n\nvar Fsm = {\n\tconstructor: function() {\n\t\tBehavioralFsm.apply( this, arguments );\n\t\tthis.ensureClientMeta();\n\t},\n\tinitClient: function initClient() {\n\t\tvar initialState = this.initialState;\n\t\tif ( !initialState ) {\n\t\t\tthrow new Error( \"You must specify an initial state for this FSM\" );\n\t\t}\n\t\tif ( !this.states[ initialState ] ) {\n\t\t\tthrow new Error( \"The initial state specified does not exist in the states object.\" );\n\t\t}\n\t\tthis.transition( initialState );\n\t},\n\tensureClientMeta: function ensureClientMeta() {\n\t\tif ( !this._stamped ) {\n\t\t\tthis._stamped = true;\n\t\t\t_.defaults( this, _.cloneDeep( utils.getDefaultClientMeta() ) );\n\t\t\tthis.initClient();\n\t\t}\n\t\treturn this;\n\t},\n\n\tensureClientArg: function( args ) {\n\t\tvar _args = args;\n\t\t// we need to test the args and verify that if a client arg has\n\t\t// been passed, it must be this FSM instance (this isn't a behavioral FSM)\n\t\tif ( typeof _args[ 0 ] === \"object\" && !( \"inputType\" in _args[ 0 ] ) && _args[ 0 ] !== this ) {\n\t\t\t_args.splice( 0, 1, this );\n\t\t} else if ( typeof _args[ 0 ] !== \"object\" || ( typeof _args[ 0 ] === \"object\" && ( \"inputType\" in _args[ 0 ] ) ) ) {\n\t\t\t_args.unshift( this );\n\t\t}\n\t\treturn _args;\n\t},\n\n\tgetHandlerArgs: function( args, isCatchAll ) {\n\t\t// index 0 is the client, index 1 is inputType\n\t\t// if we're in a catch-all handler, input type needs to be included in the args\n\t\t// inputType might be an object, so we need to just get the inputType string if so\n\t\tvar _args = args;\n\t\tvar input = _args[ 1 ];\n\t\tif ( typeof inputType === \"object\" ) {\n\t\t\t_args.splice( 1, 1, input.inputType );\n\t\t}\n\t\treturn isCatchAll ?\n\t\t\t_args.slice( 1 ) :\n\t\t\t_args.slice( 2 );\n\t},\n\n\tgetSystemHandlerArgs: function( args, client ) {\n\t\treturn args;\n\t},\n\n\t// \"classic\" machina FSM do not emit the client property on events (which would be the FSM itself)\n\tbuildEventPayload: function() {\n\t\tvar args = this.ensureClientArg( utils.getLeaklessArgs( arguments ) );\n\t\tvar data = args[ 1 ];\n\t\tif ( _.isPlainObject( data ) ) {\n\t\t\treturn _.extend( data, { namespace: this.namespace } );\n\t\t} else {\n\t\t\treturn { data: data || null, namespace: this.namespace };\n\t\t}\n\t}\n};\n\n_.each( [\n\t\"handle\",\n\t\"transition\",\n\t\"deferUntilTransition\",\n\t\"processQueue\",\n\t\"clearQueue\"\n], function( methodWithClientInjected ) {\n\tFsm[ methodWithClientInjected ] = function() {\n\t\tvar args = this.ensureClientArg( utils.getLeaklessArgs( arguments ) );\n\t\treturn BehavioralFsm.prototype[ methodWithClientInjected ].apply( this, args );\n\t};\n} );\n\nFsm = BehavioralFsm.extend( Fsm );\n\nmodule.exports = Fsm;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/Fsm.js\n// module id = 5\n// module chunks = 0","var _ = require( \"lodash\" );\nvar utils = require( \"./utils\" );\nvar emitter = require( \"./emitter\" );\nvar topLevelEmitter = emitter.instance;\nvar events = require( \"./events\" );\n\nvar MACHINA_PROP = \"__machina__\";\n\nfunction BehavioralFsm( options ) {\n\t_.extend( this, options );\n\t_.defaults( this, utils.getDefaultBehavioralOptions() );\n\tthis.initialize.apply( this, arguments );\n\ttopLevelEmitter.emit( events.NEW_FSM, this );\n}\n\n_.extend( BehavioralFsm.prototype, {\n\tinitialize: function() {},\n\n\tinitClient: function initClient( client ) {\n\t\tvar initialState = this.initialState;\n\t\tif ( !initialState ) {\n\t\t\tthrow new Error( \"You must specify an initial state for this FSM\" );\n\t\t}\n\t\tif ( !this.states[ initialState ] ) {\n\t\t\tthrow new Error( \"The initial state specified does not exist in the states object.\" );\n\t\t}\n\t\tthis.transition( client, initialState );\n\t},\n\n\tconfigForState: function configForState( newState ) {\n\t\tvar newStateObj = this.states[ newState ];\n\t\tvar child;\n\t\t_.each( this.hierarchy, function( childListener, key ) {\n\t\t\tif ( childListener && typeof childListener.off === \"function\" ) {\n\t\t\t\tchildListener.off();\n\t\t\t}\n\t\t} );\n\n\t\tif ( newStateObj._child ) {\n\t\t\tnewStateObj._child = utils.getChildFsmInstance( newStateObj._child );\n\t\t\tchild = newStateObj._child && newStateObj._child.instance;\n\t\t\tthis.hierarchy[ child.namespace ] = utils.listenToChild( this, child );\n\t\t}\n\n\t\treturn child;\n\t},\n\n\tensureClientMeta: function ensureClientMeta( client ) {\n\t\tif ( typeof client !== \"object\" ) {\n\t\t\tthrow new Error( \"An FSM client must be an object.\" );\n\t\t}\n\t\tclient[ MACHINA_PROP ] = client[ MACHINA_PROP ] || {};\n\t\tif ( !client[ MACHINA_PROP ][ this.namespace ] ) {\n\t\t\tclient[ MACHINA_PROP ][ this.namespace ] = _.cloneDeep( utils.getDefaultClientMeta() );\n\t\t\tthis.initClient( client );\n\t\t}\n\t\treturn client[ MACHINA_PROP ][ this.namespace ];\n\t},\n\n\tbuildEventPayload: function( client, data ) {\n\t\tif ( _.isPlainObject( data ) ) {\n\t\t\treturn _.extend( data, { client: client, namespace: this.namespace } );\n\t\t} else {\n\t\t\treturn { client: client, data: data || null, namespace: this.namespace };\n\t\t}\n\t},\n\n\tgetHandlerArgs: function( args, isCatchAll ) {\n\t\t// index 0 is the client, index 1 is inputType\n\t\t// if we're in a catch-all handler, input type needs to be included in the args\n\t\t// inputType might be an object, so we need to just get the inputType string if so\n\t\tvar _args = args.slice( 0 );\n\t\tvar input = _args[ 1 ];\n\t\tif ( typeof input === \"object\" ) {\n\t\t\t_args.splice( 1, 1, input.inputType );\n\t\t}\n\t\treturn isCatchAll ?\n\t\t\t_args :\n\t\t\t[ _args[ 0 ] ].concat( _args.slice( 2 ) );\n\t},\n\n\tgetSystemHandlerArgs: function( args, client ) {\n\t\treturn [ client ].concat( args );\n\t},\n\n\thandle: function( client, input ) {\n\t\tvar inputDef = input;\n\t\tif ( typeof input === \"undefined\" ) {\n\t\t\tthrow new Error( \"The input argument passed to the FSM's handle method is undefined. Did you forget to pass the input name?\" );\n\t\t}\n\t\tif ( typeof input === \"string\" ) {\n\t\t\tinputDef = { inputType: input, delegated: false, ticket: undefined };\n\t\t}\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tvar args = utils.getLeaklessArgs( arguments );\n\t\tif ( typeof input !== \"object\" ) {\n\t\t\targs.splice( 1, 1, inputDef );\n\t\t}\n\t\tclientMeta.currentActionArgs = args.slice( 1 );\n\t\tvar currentState = clientMeta.state;\n\t\tvar stateObj = this.states[ currentState ];\n\t\tvar handlerName;\n\t\tvar handler;\n\t\tvar isCatchAll = false;\n\t\tvar child;\n\t\tvar result;\n\t\tvar action;\n\t\tif ( !clientMeta.inExitHandler ) {\n\t\t\tchild = this.configForState( currentState );\n\t\t\tif ( child && !this.pendingDelegations[ inputDef.ticket ] && !inputDef.bubbling ) {\n\t\t\t\tinputDef.ticket = ( inputDef.ticket || utils.createUUID() );\n\t\t\t\tinputDef.delegated = true;\n\t\t\t\tthis.pendingDelegations[ inputDef.ticket ] = { delegatedTo: child.namespace };\n\t\t\t\t// WARNING - returning a value from `handle` on child FSMs is not really supported.\n\t\t\t\t// If you need to return values from child FSM input handlers, use events instead.\n\t\t\t\tresult = child.handle.apply( child, args );\n\t\t\t} else {\n\t\t\t\tif ( inputDef.ticket && this.pendingDelegations[ inputDef.ticket ] ) {\n\t\t\t\t\tdelete this.pendingDelegations[ inputDef.ticket ];\n\t\t\t\t}\n\t\t\t\thandlerName = stateObj[ inputDef.inputType ] ? inputDef.inputType : \"*\";\n\t\t\t\tisCatchAll = ( handlerName === \"*\" );\n\t\t\t\thandler = ( stateObj[ handlerName ] || this[ handlerName ] ) || this[ \"*\" ];\n\t\t\t\taction = clientMeta.state + \".\" + handlerName;\n\t\t\t\tclientMeta.currentAction = action;\n\t\t\t\tvar eventPayload = this.buildEventPayload(\n\t\t\t\t\tclient,\n\t\t\t\t\t{ inputType: inputDef.inputType, delegated: inputDef.delegated, ticket: inputDef.ticket }\n\t\t\t\t);\n\t\t\t\tif ( !handler ) {\n\t\t\t\t\tthis.emit( events.NO_HANDLER, _.extend( { args: args }, eventPayload ) );\n\t\t\t\t} else {\n\t\t\t\t\tthis.emit( events.HANDLING, eventPayload );\n\t\t\t\t\tif ( typeof handler === \"function\" ) {\n\t\t\t\t\t\tresult = handler.apply( this, this.getHandlerArgs( args, isCatchAll ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = handler;\n\t\t\t\t\t\tthis.transition( client, handler );\n\t\t\t\t\t}\n\t\t\t\t\tthis.emit( events.HANDLED, eventPayload );\n\t\t\t\t}\n\t\t\t\tclientMeta.priorAction = clientMeta.currentAction;\n\t\t\t\tclientMeta.currentAction = \"\";\n\t\t\t\tclientMeta.currentActionArgs = undefined;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t},\n\n\ttransition: function( client, newState ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tvar curState = clientMeta.state;\n\t\tvar curStateObj = this.states[ curState ];\n\t\tvar newStateObj = this.states[ newState ];\n\t\tvar child;\n\t\tvar args = utils.getLeaklessArgs( arguments ).slice( 2 );\n\t\tif ( !clientMeta.inExitHandler && newState !== curState ) {\n\t\t\tif ( newStateObj ) {\n\t\t\t\tchild = this.configForState( newState );\n\t\t\t\tif ( curStateObj && curStateObj._onExit ) {\n\t\t\t\t\tclientMeta.inExitHandler = true;\n\t\t\t\t\tcurStateObj._onExit.call( this, client );\n\t\t\t\t\tclientMeta.inExitHandler = false;\n\t\t\t\t}\n\t\t\t\tclientMeta.targetReplayState = newState;\n\t\t\t\tclientMeta.priorState = curState;\n\t\t\t\tclientMeta.state = newState;\n\t\t\t\tvar eventPayload = this.buildEventPayload( client, {\n\t\t\t\t\tfromState: clientMeta.priorState,\n\t\t\t\t\taction: clientMeta.currentAction,\n\t\t\t\t\ttoState: newState\n\t\t\t\t} );\n\t\t\t\tthis.emit( events.TRANSITION, eventPayload );\n\t\t\t\tif ( newStateObj._onEnter ) {\n\t\t\t\t\tnewStateObj._onEnter.apply( this, this.getSystemHandlerArgs( args, client ) );\n\t\t\t\t}\n\t\t\t\tthis.emit( events.TRANSITIONED, eventPayload );\n\t\t\t\tif ( child ) {\n\t\t\t\t\tchild.handle( client, \"_reset\" );\n\t\t\t\t}\n\n\t\t\t\tif ( clientMeta.targetReplayState === newState ) {\n\t\t\t\t\tthis.processQueue( client, events.NEXT_TRANSITION );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.emit( events.INVALID_STATE, this.buildEventPayload( client, {\n\t\t\t\tstate: clientMeta.state,\n\t\t\t\tattemptedState: newState\n\t\t\t} ) );\n\t\t}\n\t},\n\n\tdeferUntilTransition: function( client, stateName ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tif ( clientMeta.currentActionArgs ) {\n\t\t\tvar queued = {\n\t\t\t\ttype: events.NEXT_TRANSITION,\n\t\t\t\tuntilState: stateName,\n\t\t\t\targs: clientMeta.currentActionArgs\n\t\t\t};\n\t\t\tclientMeta.inputQueue.push( queued );\n\t\t\tvar eventPayload = this.buildEventPayload( client, {\n\t\t\t\tstate: clientMeta.state,\n\t\t\t\tqueuedArgs: queued\n\t\t\t} );\n\t\t\tthis.emit( events.DEFERRED, eventPayload );\n\t\t}\n\t},\n\n\tdeferAndTransition: function( client, stateName ) {\n\t\tthis.deferUntilTransition( client, stateName );\n\t\tthis.transition( client, stateName );\n\t},\n\n\tprocessQueue: function( client ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tvar filterFn = function( item ) {\n\t\t\treturn ( ( !item.untilState ) || ( item.untilState === clientMeta.state ) );\n\t\t};\n\t\tvar toProcess = _.filter( clientMeta.inputQueue, filterFn );\n\t\tclientMeta.inputQueue = _.difference( clientMeta.inputQueue, toProcess );\n\t\t_.each( toProcess, function( item ) {\n\t\t\tthis.handle.apply( this, [ client ].concat( item.args ) );\n\t\t}.bind( this ) );\n\t},\n\n\tclearQueue: function( client, name ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tif ( !name ) {\n\t\t\tclientMeta.inputQueue = [];\n\t\t} else {\n\t\t\tvar filter = function( evnt ) {\n\t\t\t\treturn ( name ? evnt.untilState !== name : true );\n\t\t\t};\n\t\t\tclientMeta.inputQueue = _.filter( clientMeta.inputQueue, filter );\n\t\t}\n\t},\n\n\tcompositeState: function( client ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tvar state = clientMeta.state;\n\t\tvar child = this.states[state]._child && this.states[state]._child.instance;\n\t\tif ( child ) {\n\t\t\tstate += \".\" + child.compositeState( client );\n\t\t}\n\t\treturn state;\n\t}\n}, emitter.getInstance() );\n\nBehavioralFsm.extend = utils.extend;\n\nmodule.exports = BehavioralFsm;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/BehavioralFsm.js\n// module id = 6\n// module chunks = 0"]} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","machina.js","webpack:/webpack/bootstrap 255185ed97e192137e5e","webpack:///src/machina.js","webpack:/external {\"root\":\"_\",\"commonjs\":\"lodash\",\"commonjs2\":\"lodash\",\"amd\":\"lodash\"}","webpack:///src/emitter.js","webpack:///src/utils.js","webpack:///src/events.js","webpack:///src/Fsm.js","webpack:///src/BehavioralFsm.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_1__","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_","emitter","merge","instance","Fsm","BehavioralFsm","utils","eventListeners","newFsm","getInstance","emit","eventName","args","getLeaklessArgs","arguments","each","callback","useSafeEmit","apply","exception","console","log","stack","slice","on","self","*","push","off","without","getDefaultBehavioralOptions","initialState","states","namespace","makeFsmNamespace","hierarchy","pendingDelegations","getDefaultClientMeta","inputQueue","targetReplayState","state","undefined","priorState","priorAction","currentAction","currentActionArgs","inExitHandler","startIdx","result","i","length","getChildFsmInstance","config","childFsmDefinition","listenToChild","fsm","child","data","events","NO_HANDLER","ticket","delegated","bubbling","inputType","handle","HANDLING","createUUID","s","hexDigits","substr","Math","floor","random","join","machinaCount","_machKeys","extend","protoProps","staticProps","parent","machObj","Ctor","hasOwnProperty","constructor","blendedState","instanceStates","cloneDeep","prototype","transform","accum","val","key","indexOf","__super__","getDefaultOptions","NEXT_TRANSITION","HANDLED","TRANSITION","TRANSITIONED","INVALID_STATE","DEFERRED","NEW_FSM","ensureClientMeta","initClient","Error","transition","_stamped","defaults","ensureClientArg","_args","unshift","splice","getHandlerArgs","isCatchAll","input","getSystemHandlerArgs","client","buildEventPayload","isPlainObject","methodWithClientInjected","options","initialize","topLevelEmitter","MACHINA_PROP","configForState","newState","newStateObj","childListener","_child","concat","inputDef","clientMeta","handlerName","handler","action","currentState","stateObj","eventPayload","delegatedTo","curState","curStateObj","_onExit","fromState","toState","_onEnter","processQueue","attemptedState","deferUntilTransition","stateName","queued","type","untilState","queuedArgs","deferAndTransition","filterFn","item","toProcess","filter","difference","bind","clearQueue","name","evnt","compositeState"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,WACA,kBAAAC,SAAAA,OAAAC,IACAD,QAAA,UAAAJ,GACA,gBAAAC,SACAA,QAAA,QAAAD,EAAAG,QAAA,WAEAJ,EAAA,QAAAC,EAAAD,EAAA,KACCO,KAAA,SAAAC,GACD,MCOgB,UAAUC,GCb1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAT,OAGA,IAAAC,GAAAS,EAAAD,IACAT,WACAW,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAZ,EAAAD,QAAAC,EAAAA,EAAAD,QAAAQ,GAGAP,EAAAW,QAAA,EAGAX,EAAAD,QAvBA,GAAAU,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDuBM,SAAUP,EAAQD,EAASQ,GE7DjC,GAAAS,GAAAT,EAAA,GACAU,EAAAV,EAAA,EAEAP,GAAAD,QAAAiB,EAAAE,MAAAD,EAAAE,UACAC,IAAAb,EAAA,GACAc,cAAAd,EAAA,GACAe,MAAAf,EAAA,GACAgB,gBACAC,cFsEM,SAAUxB,EAAQD,GG9ExBC,EAAAD,QAAAM,GHoFM,SAAUL,EAAQD,EAASQ,GIjFjC,QAAAkB,KACA,OACAC,KAAA,SAAAC,GACA,GAAAC,GAAAN,EAAAO,gBAAAC,UACA1B,MAAAmB,eAAA,MACAP,EAAAe,KAAA3B,K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A6C,GACA,GAAA9B,GAAA/I,KAAAkH,iBAAAc,EACA,IAAA6C,EAEG,CACH,GAAAJ,GAAA,SAAAK,GACA,MAAAD,GAAAC,EAAAX,aAAAU,GAAA,EAEA9B,GAAA7F,WAAAtC,EAAA6J,OAAA1B,EAAA7F,WAAAuH,OALA1B,GAAA7F,eASA6H,eAAA,SAAA/C,GACA,GAAAe,GAAA/I,KAAAkH,iBAAAc,GACA5E,EAAA2F,EAAA3F,MACAgB,EAAApE,KAAA4C,OAAAQ,GAAAwF,QAAA5I,KAAA4C,OAAAQ,GAAAwF,OAAA7H,QAIA,OAHAqD,KACAhB,GAAA,IAAAgB,EAAA2G,eAAA/C,IAEA5E,IAECvC,EAAAQ,eAEDJ,EAAAuE,OAAAtE,EAAAsE,OAEA5F,EAAAD,QAAAsB","file":"machina.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"lodash\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"lodash\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"machina\"] = factory(require(\"lodash\"));\n\telse\n\t\troot[\"machina\"] = factory(root[\"_\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","/*!\n * * machina - A library for creating powerful and flexible finite state machines. Loosely inspired by Erlang/OTP's gen_fsm behavior.\n * * Author: Jim Cowart (http://ifandelse.com)\n * * Version: v2.0.2\n * * Url: http://machina-js.org/\n * * License(s): \n */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"lodash\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"lodash\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"machina\"] = factory(require(\"lodash\"));\n\telse\n\t\troot[\"machina\"] = factory(root[\"_\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar _ = __webpack_require__( 1 );\n\tvar emitter = __webpack_require__( 2 );\n\t\n\tmodule.exports = _.merge( emitter.instance, {\n\t\tFsm: __webpack_require__( 5 ),\n\t\tBehavioralFsm: __webpack_require__( 6 ),\n\t\tutils: __webpack_require__( 3 ),\n\t\teventListeners: {\n\t\t\tnewFsm: []\n\t\t}\n\t} );\n\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar utils = __webpack_require__( 3 );\n\tvar _ = __webpack_require__( 1 );\n\t\n\tfunction getInstance() {\n\t\treturn {\n\t\t\temit: function( eventName ) {\n\t\t\t\tvar args = utils.getLeaklessArgs( arguments );\n\t\t\t\tif ( this.eventListeners[ \"*\" ] ) {\n\t\t\t\t\t_.each( this.eventListeners[ \"*\" ], function( callback ) {\n\t\t\t\t\t\tif ( !this.useSafeEmit ) {\n\t\t\t\t\t\t\tcallback.apply( this, args );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tcallback.apply( this, args );\n\t\t\t\t\t\t\t} catch ( exception ) {\n\t\t\t\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\t\t\t\tif ( console && typeof console.log !== \"undefined\" ) {\n\t\t\t\t\t\t\t\t\tconsole.log( exception.stack );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}, this );\n\t\t\t\t}\n\t\t\t\tif ( this.eventListeners[ eventName ] ) {\n\t\t\t\t\t_.each( this.eventListeners[ eventName ], function( callback ) {\n\t\t\t\t\t\tif ( !this.useSafeEmit ) {\n\t\t\t\t\t\t\tcallback.apply( this, args.slice( 1 ) );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tcallback.apply( this, args.slice( 1 ) );\n\t\t\t\t\t\t\t} catch ( exception ) {\n\t\t\t\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\t\t\t\tif ( console && typeof console.log !== \"undefined\" ) {\n\t\t\t\t\t\t\t\t\tconsole.log( exception.stack );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}, this );\n\t\t\t\t}\n\t\t\t},\n\t\n\t\t\ton: function( eventName, callback ) {\n\t\t\t\tvar self = this;\n\t\t\t\tself.eventListeners = self.eventListeners || { \"*\": [] };\n\t\t\t\tif ( !self.eventListeners[ eventName ] ) {\n\t\t\t\t\tself.eventListeners[ eventName ] = [];\n\t\t\t\t}\n\t\t\t\tself.eventListeners[ eventName ].push( callback );\n\t\t\t\treturn {\n\t\t\t\t\teventName: eventName,\n\t\t\t\t\tcallback: callback,\n\t\t\t\t\toff: function() {\n\t\t\t\t\t\tself.off( eventName, callback );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\n\t\t\toff: function( eventName, callback ) {\n\t\t\t\tthis.eventListeners = this.eventListeners || { \"*\": [] };\n\t\t\t\tif ( !eventName ) {\n\t\t\t\t\tthis.eventListeners = {};\n\t\t\t\t} else {\n\t\t\t\t\tif ( callback ) {\n\t\t\t\t\t\tthis.eventListeners[ eventName ] = _.without( this.eventListeners[ eventName ], callback );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.eventListeners[ eventName ] = [];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\t\n\tmodule.exports = {\n\t\tgetInstance: getInstance,\n\t\tinstance: getInstance()\n\t};\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar slice = [].slice;\n\tvar events = __webpack_require__( 4 );\n\tvar _ = __webpack_require__( 1 );\n\t\n\tvar makeFsmNamespace = ( function() {\n\t\tvar machinaCount = 0;\n\t\treturn function() {\n\t\t\treturn \"fsm.\" + machinaCount++;\n\t\t};\n\t} )();\n\t\n\tfunction getDefaultBehavioralOptions() {\n\t\treturn {\n\t\t\tinitialState: \"uninitialized\",\n\t\t\teventListeners: {\n\t\t\t\t\"*\": []\n\t\t\t},\n\t\t\tstates: {},\n\t\t\tnamespace: makeFsmNamespace(),\n\t\t\tuseSafeEmit: false,\n\t\t\thierarchy: {},\n\t\t\tpendingDelegations: {}\n\t\t};\n\t}\n\t\n\tfunction getDefaultClientMeta() {\n\t\treturn {\n\t\t\tinputQueue: [],\n\t\t\ttargetReplayState: \"\",\n\t\t\tstate: undefined,\n\t\t\tpriorState: undefined,\n\t\t\tpriorAction: \"\",\n\t\t\tcurrentAction: \"\",\n\t\t\tcurrentActionArgs: undefined,\n\t\t\tinExitHandler: false\n\t\t};\n\t}\n\t\n\tfunction getLeaklessArgs( args, startIdx ) {\n\t\tvar result = [];\n\t\tfor ( var i = ( startIdx || 0 ); i < args.length; i++ ) {\n\t\t\tresult[ i ] = args[ i ];\n\t\t}\n\t\treturn result;\n\t}\n\t/*\n\t\thandle ->\n\t\t\tchild = stateObj._child && stateObj._child.instance;\n\t\n\t\ttransition ->\n\t\t\tnewStateObj._child = getChildFsmInstance( newStateObj._child );\n\t\t\tchild = newStateObj._child && newStateObj._child.instance;\n\t*/\n\tfunction getChildFsmInstance( config ) {\n\t\tif ( !config ) {\n\t\t\treturn;\n\t\t}\n\t\tvar childFsmDefinition = {};\n\t\tif ( typeof config === \"object\" ) {\n\t\t\t// is this a config object with a factory?\n\t\t\tif ( config.factory ) {\n\t\t\t\tchildFsmDefinition = config;\n\t\t\t} else {\n\t\t\t\t// assuming this is a machina instance\n\t\t\t\tchildFsmDefinition.factory = function() {\n\t\t\t\t\treturn config;\n\t\t\t\t};\n\t\t\t}\n\t\t} else if ( typeof config === \"function\" ) {\n\t\t\tchildFsmDefinition.factory = config;\n\t\t}\n\t\tchildFsmDefinition.instance = childFsmDefinition.factory();\n\t\treturn childFsmDefinition;\n\t}\n\t\n\tfunction listenToChild( fsm, child ) {\n\t\t// Need to investigate potential for discarded event\n\t\t// listener memory leak in long-running, deeply-nested hierarchies.\n\t\treturn child.on( \"*\", function( eventName, data ) {\n\t\t\tswitch ( eventName ) {\n\t\t\t\tcase events.NO_HANDLER:\n\t\t\t\t\tif ( !data.ticket && !data.delegated && data.namespace !== fsm.namespace ) {\n\t\t\t\t\t\t// Ok - we're dealing w/ a child handling input that should bubble up\n\t\t\t\t\t\tdata.args[ 1 ].bubbling = true;\n\t\t\t\t\t}\n\t\t\t\t\t// we do NOT bubble _reset inputs up to the parent\n\t\t\t\t\tif ( data.inputType !== \"_reset\" ) {\n\t\t\t\t\t\tfsm.handle.apply( fsm, data.args );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase events.HANDLING :\n\t\t\t\t\tvar ticket = data.ticket;\n\t\t\t\t\tif ( ticket && fsm.pendingDelegations[ ticket ] ) {\n\t\t\t\t\t\tdelete fsm.pendingDelegations[ ticket ];\n\t\t\t\t\t}\n\t\t\t\t\tfsm.emit( eventName, data ); // possibly transform payload?\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tfsm.emit( eventName, data ); // possibly transform payload?\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} );\n\t}\n\t\n\t// _machKeys are members we want to track across the prototype chain of an extended FSM constructor\n\t// Since we want to eventually merge the aggregate of those values onto the instance so that FSMs\n\t// that share the same extended prototype won't share state *on* those prototypes.\n\tvar _machKeys = [ \"states\", \"initialState\" ];\n\tvar extend = function( protoProps, staticProps ) {\n\t\tvar parent = this;\n\t\tvar fsm; // placeholder for instance constructor\n\t\tvar machObj = {}; // object used to hold initialState & states from prototype for instance-level merging\n\t\tvar Ctor = function() {}; // placeholder ctor function used to insert level in prototype chain\n\t\n\t\t// The constructor function for the new subclass is either defined by you\n\t\t// (the \"constructor\" property in your `extend` definition), or defaulted\n\t\t// by us to simply call the parent's constructor.\n\t\tif ( protoProps && protoProps.hasOwnProperty( \"constructor\" ) ) {\n\t\t\tfsm = protoProps.constructor;\n\t\t} else {\n\t\t\t// The default machina constructor (when using inheritance) creates a\n\t\t\t// deep copy of the states/initialState values from the prototype and\n\t\t\t// extends them over the instance so that they'll be instance-level.\n\t\t\t// If an options arg (args[0]) is passed in, a states or intialState\n\t\t\t// value will be preferred over any data pulled up from the prototype.\n\t\t\tfsm = function() {\n\t\t\t\tvar args = slice.call( arguments, 0 );\n\t\t\t\targs[ 0 ] = args[ 0 ] || {};\n\t\t\t\tvar blendedState;\n\t\t\t\tvar instanceStates = args[ 0 ].states || {};\n\t\t\t\tblendedState = _.merge( _.cloneDeep( machObj ), { states: instanceStates } );\n\t\t\t\tblendedState.initialState = args[ 0 ].initialState || this.initialState;\n\t\t\t\t_.extend( args[ 0 ], blendedState );\n\t\t\t\tparent.apply( this, args );\n\t\t\t};\n\t\t}\n\t\n\t\t// Inherit class (static) properties from parent.\n\t\t_.merge( fsm, parent );\n\t\n\t\t// Set the prototype chain to inherit from `parent`, without calling\n\t\t// `parent`'s constructor function.\n\t\tCtor.prototype = parent.prototype;\n\t\tfsm.prototype = new Ctor();\n\t\n\t\t// Add prototype properties (instance properties) to the subclass,\n\t\t// if supplied.\n\t\tif ( protoProps ) {\n\t\t\t_.extend( fsm.prototype, protoProps );\n\t\t\t_.merge( machObj, _.transform( protoProps, function( accum, val, key ) {\n\t\t\t\tif ( _machKeys.indexOf( key ) !== -1 ) {\n\t\t\t\t\taccum[ key ] = val;\n\t\t\t\t}\n\t\t\t} ) );\n\t\t}\n\t\n\t\t// Add static properties to the constructor function, if supplied.\n\t\tif ( staticProps ) {\n\t\t\t_.merge( fsm, staticProps );\n\t\t}\n\t\n\t\t// Correctly set child's `prototype.constructor`.\n\t\tfsm.prototype.constructor = fsm;\n\t\n\t\t// Set a convenience property in case the parent's prototype is needed later.\n\t\tfsm.__super__ = parent.prototype;\n\t\treturn fsm;\n\t};\n\t\n\tfunction createUUID() {\n\t\tvar s = [];\n\t\tvar hexDigits = \"0123456789abcdef\";\n\t\tfor ( var i = 0; i < 36; i++ ) {\n\t\t\ts[ i ] = hexDigits.substr( Math.floor( Math.random() * 0x10 ), 1 );\n\t\t}\n\t\ts[ 14 ] = \"4\"; // bits 12-15 of the time_hi_and_version field to 0010\n\t\t/* jshint ignore:start */\n\t\ts[ 19 ] = hexDigits.substr( ( s[ 19 ] & 0x3 ) | 0x8, 1 ); // bits 6-7 of the clock_seq_hi_and_reserved to 01\n\t\t/* jshint ignore:end */\n\t\ts[ 8 ] = s[ 13 ] = s[ 18 ] = s[ 23 ] = \"-\";\n\t\treturn s.join( \"\" );\n\t}\n\t\n\tmodule.exports = {\n\t\tcreateUUID: createUUID,\n\t\textend: extend,\n\t\tgetDefaultBehavioralOptions: getDefaultBehavioralOptions,\n\t\tgetDefaultOptions: getDefaultBehavioralOptions,\n\t\tgetDefaultClientMeta: getDefaultClientMeta,\n\t\tgetChildFsmInstance: getChildFsmInstance,\n\t\tgetLeaklessArgs: getLeaklessArgs,\n\t\tlistenToChild: listenToChild,\n\t\tmakeFsmNamespace: makeFsmNamespace\n\t};\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\n\tmodule.exports = {\n\t\tNEXT_TRANSITION: \"transition\",\n\t\tHANDLING: \"handling\",\n\t\tHANDLED: \"handled\",\n\t\tNO_HANDLER: \"nohandler\",\n\t\tTRANSITION: \"transition\",\n\t\tTRANSITIONED: \"transitioned\",\n\t\tINVALID_STATE: \"invalidstate\",\n\t\tDEFERRED: \"deferred\",\n\t\tNEW_FSM: \"newfsm\"\n\t};\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar BehavioralFsm = __webpack_require__( 6 );\n\tvar utils = __webpack_require__( 3 );\n\tvar _ = __webpack_require__( 1 );\n\t\n\tvar Fsm = {\n\t\tconstructor: function() {\n\t\t\tBehavioralFsm.apply( this, arguments );\n\t\t\tthis.ensureClientMeta();\n\t\t},\n\t\tinitClient: function initClient() {\n\t\t\tvar initialState = this.initialState;\n\t\t\tif ( !initialState ) {\n\t\t\t\tthrow new Error( \"You must specify an initial state for this FSM\" );\n\t\t\t}\n\t\t\tif ( !this.states[ initialState ] ) {\n\t\t\t\tthrow new Error( \"The initial state specified does not exist in the states object.\" );\n\t\t\t}\n\t\t\tthis.transition( initialState );\n\t\t},\n\t\tensureClientMeta: function ensureClientMeta() {\n\t\t\tif ( !this._stamped ) {\n\t\t\t\tthis._stamped = true;\n\t\t\t\t_.defaults( this, _.cloneDeep( utils.getDefaultClientMeta() ) );\n\t\t\t\tthis.initClient();\n\t\t\t}\n\t\t\treturn this;\n\t\t},\n\t\n\t\tensureClientArg: function( args ) {\n\t\t\tvar _args = args;\n\t\t\t// we need to test the args and verify that if a client arg has\n\t\t\t// been passed, it must be this FSM instance (this isn't a behavioral FSM)\n\t\t\tif ( typeof _args[ 0 ] === \"object\" && !( \"inputType\" in _args[ 0 ] ) && _args[ 0 ] !== this ) {\n\t\t\t\t_args.splice( 0, 1, this );\n\t\t\t} else if ( typeof _args[ 0 ] !== \"object\" || ( typeof _args[ 0 ] === \"object\" && ( \"inputType\" in _args[ 0 ] ) ) ) {\n\t\t\t\t_args.unshift( this );\n\t\t\t}\n\t\t\treturn _args;\n\t\t},\n\t\n\t\tgetHandlerArgs: function( args, isCatchAll ) {\n\t\t\t// index 0 is the client, index 1 is inputType\n\t\t\t// if we're in a catch-all handler, input type needs to be included in the args\n\t\t\t// inputType might be an object, so we need to just get the inputType string if so\n\t\t\tvar _args = args;\n\t\t\tvar input = _args[ 1 ];\n\t\t\tif ( typeof inputType === \"object\" ) {\n\t\t\t\t_args.splice( 1, 1, input.inputType );\n\t\t\t}\n\t\t\treturn isCatchAll ?\n\t\t\t\t_args.slice( 1 ) :\n\t\t\t\t_args.slice( 2 );\n\t\t},\n\t\n\t\tgetSystemHandlerArgs: function( args, client ) {\n\t\t\treturn args;\n\t\t},\n\t\n\t\t// \"classic\" machina FSM do not emit the client property on events (which would be the FSM itself)\n\t\tbuildEventPayload: function() {\n\t\t\tvar args = this.ensureClientArg( utils.getLeaklessArgs( arguments ) );\n\t\t\tvar data = args[ 1 ];\n\t\t\tif ( _.isPlainObject( data ) ) {\n\t\t\t\treturn _.extend( data, { namespace: this.namespace } );\n\t\t\t} else {\n\t\t\t\treturn { data: data || null, namespace: this.namespace };\n\t\t\t}\n\t\t}\n\t};\n\t\n\t_.each( [\n\t\t\"handle\",\n\t\t\"transition\",\n\t\t\"deferUntilTransition\",\n\t\t\"processQueue\",\n\t\t\"clearQueue\"\n\t], function( methodWithClientInjected ) {\n\t\tFsm[ methodWithClientInjected ] = function() {\n\t\t\tvar args = this.ensureClientArg( utils.getLeaklessArgs( arguments ) );\n\t\t\treturn BehavioralFsm.prototype[ methodWithClientInjected ].apply( this, args );\n\t\t};\n\t} );\n\t\n\tFsm = BehavioralFsm.extend( Fsm );\n\t\n\tmodule.exports = Fsm;\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar _ = __webpack_require__( 1 );\n\tvar utils = __webpack_require__( 3 );\n\tvar emitter = __webpack_require__( 2 );\n\tvar topLevelEmitter = emitter.instance;\n\tvar events = __webpack_require__( 4 );\n\t\n\tvar MACHINA_PROP = \"__machina__\";\n\t\n\tfunction BehavioralFsm( options ) {\n\t\t_.extend( this, options );\n\t\t_.defaults( this, utils.getDefaultBehavioralOptions() );\n\t\tthis.initialize.apply( this, arguments );\n\t\ttopLevelEmitter.emit( events.NEW_FSM, this );\n\t}\n\t\n\t_.extend( BehavioralFsm.prototype, {\n\t\tinitialize: function() {},\n\t\n\t\tinitClient: function initClient( client ) {\n\t\t\tvar initialState = this.initialState;\n\t\t\tif ( !initialState ) {\n\t\t\t\tthrow new Error( \"You must specify an initial state for this FSM\" );\n\t\t\t}\n\t\t\tif ( !this.states[ initialState ] ) {\n\t\t\t\tthrow new Error( \"The initial state specified does not exist in the states object.\" );\n\t\t\t}\n\t\t\tthis.transition( client, initialState );\n\t\t},\n\t\n\t\tconfigForState: function configForState( newState ) {\n\t\t\tvar newStateObj = this.states[ newState ];\n\t\t\tvar child;\n\t\t\t_.each( this.hierarchy, function( childListener, key ) {\n\t\t\t\tif ( childListener && typeof childListener.off === \"function\" ) {\n\t\t\t\t\tchildListener.off();\n\t\t\t\t}\n\t\t\t} );\n\t\n\t\t\tif ( newStateObj._child ) {\n\t\t\t\tnewStateObj._child = utils.getChildFsmInstance( newStateObj._child );\n\t\t\t\tchild = newStateObj._child && newStateObj._child.instance;\n\t\t\t\tthis.hierarchy[ child.namespace ] = utils.listenToChild( this, child );\n\t\t\t}\n\t\n\t\t\treturn child;\n\t\t},\n\t\n\t\tensureClientMeta: function ensureClientMeta( client ) {\n\t\t\tif ( typeof client !== \"object\" ) {\n\t\t\t\tthrow new Error( \"An FSM client must be an object.\" );\n\t\t\t}\n\t\t\tclient[ MACHINA_PROP ] = client[ MACHINA_PROP ] || {};\n\t\t\tif ( !client[ MACHINA_PROP ][ this.namespace ] ) {\n\t\t\t\tclient[ MACHINA_PROP ][ this.namespace ] = _.cloneDeep( utils.getDefaultClientMeta() );\n\t\t\t\tthis.initClient( client );\n\t\t\t}\n\t\t\treturn client[ MACHINA_PROP ][ this.namespace ];\n\t\t},\n\t\n\t\tbuildEventPayload: function( client, data ) {\n\t\t\tif ( _.isPlainObject( data ) ) {\n\t\t\t\treturn _.extend( data, { client: client, namespace: this.namespace } );\n\t\t\t} else {\n\t\t\t\treturn { client: client, data: data || null, namespace: this.namespace };\n\t\t\t}\n\t\t},\n\t\n\t\tgetHandlerArgs: function( args, isCatchAll ) {\n\t\t\t// index 0 is the client, index 1 is inputType\n\t\t\t// if we're in a catch-all handler, input type needs to be included in the args\n\t\t\t// inputType might be an object, so we need to just get the inputType string if so\n\t\t\tvar _args = args.slice( 0 );\n\t\t\tvar input = _args[ 1 ];\n\t\t\tif ( typeof input === \"object\" ) {\n\t\t\t\t_args.splice( 1, 1, input.inputType );\n\t\t\t}\n\t\t\treturn isCatchAll ?\n\t\t\t\t_args :\n\t\t\t\t[ _args[ 0 ] ].concat( _args.slice( 2 ) );\n\t\t},\n\t\n\t\tgetSystemHandlerArgs: function( args, client ) {\n\t\t\treturn [ client ].concat( args );\n\t\t},\n\t\n\t\thandle: function( client, input ) {\n\t\t\tvar inputDef = input;\n\t\t\tif ( typeof input === \"undefined\" ) {\n\t\t\t\tthrow new Error( \"The input argument passed to the FSM's handle method is undefined. Did you forget to pass the input name?\" );\n\t\t\t}\n\t\t\tif ( typeof input === \"string\" ) {\n\t\t\t\tinputDef = { inputType: input, delegated: false, ticket: undefined };\n\t\t\t}\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tvar args = utils.getLeaklessArgs( arguments );\n\t\t\tif ( typeof input !== \"object\" ) {\n\t\t\t\targs.splice( 1, 1, inputDef );\n\t\t\t}\n\t\t\tclientMeta.currentActionArgs = args.slice( 1 );\n\t\t\tvar currentState = clientMeta.state;\n\t\t\tvar stateObj = this.states[ currentState ];\n\t\t\tvar handlerName;\n\t\t\tvar handler;\n\t\t\tvar isCatchAll = false;\n\t\t\tvar child;\n\t\t\tvar result;\n\t\t\tvar action;\n\t\t\tif ( !clientMeta.inExitHandler ) {\n\t\t\t\tchild = this.configForState( currentState );\n\t\t\t\tif ( child && !this.pendingDelegations[ inputDef.ticket ] && !inputDef.bubbling ) {\n\t\t\t\t\tinputDef.ticket = ( inputDef.ticket || utils.createUUID() );\n\t\t\t\t\tinputDef.delegated = true;\n\t\t\t\t\tthis.pendingDelegations[ inputDef.ticket ] = { delegatedTo: child.namespace };\n\t\t\t\t\t// WARNING - returning a value from `handle` on child FSMs is not really supported.\n\t\t\t\t\t// If you need to return values from child FSM input handlers, use events instead.\n\t\t\t\t\tresult = child.handle.apply( child, args );\n\t\t\t\t} else {\n\t\t\t\t\tif ( inputDef.ticket && this.pendingDelegations[ inputDef.ticket ] ) {\n\t\t\t\t\t\tdelete this.pendingDelegations[ inputDef.ticket ];\n\t\t\t\t\t}\n\t\t\t\t\thandlerName = stateObj[ inputDef.inputType ] ? inputDef.inputType : \"*\";\n\t\t\t\t\tisCatchAll = ( handlerName === \"*\" );\n\t\t\t\t\thandler = ( stateObj[ handlerName ] || this[ handlerName ] ) || this[ \"*\" ];\n\t\t\t\t\taction = clientMeta.state + \".\" + handlerName;\n\t\t\t\t\tclientMeta.currentAction = action;\n\t\t\t\t\tvar eventPayload = this.buildEventPayload(\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\t{ inputType: inputDef.inputType, delegated: inputDef.delegated, ticket: inputDef.ticket }\n\t\t\t\t\t);\n\t\t\t\t\tif ( !handler ) {\n\t\t\t\t\t\tthis.emit( events.NO_HANDLER, _.extend( { args: args }, eventPayload ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.emit( events.HANDLING, eventPayload );\n\t\t\t\t\t\tif ( typeof handler === \"function\" ) {\n\t\t\t\t\t\t\tresult = handler.apply( this, this.getHandlerArgs( args, isCatchAll ) );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult = handler;\n\t\t\t\t\t\t\tthis.transition( client, handler );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.emit( events.HANDLED, eventPayload );\n\t\t\t\t\t}\n\t\t\t\t\tclientMeta.priorAction = clientMeta.currentAction;\n\t\t\t\t\tclientMeta.currentAction = \"\";\n\t\t\t\t\tclientMeta.currentActionArgs = undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t\n\t\ttransition: function( client, newState ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tvar curState = clientMeta.state;\n\t\t\tvar curStateObj = this.states[ curState ];\n\t\t\tvar newStateObj = this.states[ newState ];\n\t\t\tvar child;\n\t\t\tvar args = utils.getLeaklessArgs( arguments ).slice( 2 );\n\t\t\tif ( !clientMeta.inExitHandler && newState !== curState ) {\n\t\t\t\tif ( newStateObj ) {\n\t\t\t\t\tchild = this.configForState( newState );\n\t\t\t\t\tif ( curStateObj && curStateObj._onExit ) {\n\t\t\t\t\t\tclientMeta.inExitHandler = true;\n\t\t\t\t\t\tcurStateObj._onExit.call( this, client );\n\t\t\t\t\t\tclientMeta.inExitHandler = false;\n\t\t\t\t\t}\n\t\t\t\t\tclientMeta.targetReplayState = newState;\n\t\t\t\t\tclientMeta.priorState = curState;\n\t\t\t\t\tclientMeta.state = newState;\n\t\t\t\t\tvar eventPayload = this.buildEventPayload( client, {\n\t\t\t\t\t\tfromState: clientMeta.priorState,\n\t\t\t\t\t\taction: clientMeta.currentAction,\n\t\t\t\t\t\ttoState: newState\n\t\t\t\t\t} );\n\t\t\t\t\tthis.emit( events.TRANSITION, eventPayload );\n\t\t\t\t\tif ( newStateObj._onEnter ) {\n\t\t\t\t\t\tnewStateObj._onEnter.apply( this, this.getSystemHandlerArgs( args, client ) );\n\t\t\t\t\t}\n\t\t\t\t\tthis.emit( events.TRANSITIONED, eventPayload );\n\t\t\t\t\tif ( child ) {\n\t\t\t\t\t\tchild.handle( client, \"_reset\" );\n\t\t\t\t\t}\n\t\n\t\t\t\t\tif ( clientMeta.targetReplayState === newState ) {\n\t\t\t\t\t\tthis.processQueue( client, events.NEXT_TRANSITION );\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.emit( events.INVALID_STATE, this.buildEventPayload( client, {\n\t\t\t\t\tstate: clientMeta.state,\n\t\t\t\t\tattemptedState: newState\n\t\t\t\t} ) );\n\t\t\t}\n\t\t},\n\t\n\t\tdeferUntilTransition: function( client, stateName ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tif ( clientMeta.currentActionArgs ) {\n\t\t\t\tvar queued = {\n\t\t\t\t\ttype: events.NEXT_TRANSITION,\n\t\t\t\t\tuntilState: stateName,\n\t\t\t\t\targs: clientMeta.currentActionArgs\n\t\t\t\t};\n\t\t\t\tclientMeta.inputQueue.push( queued );\n\t\t\t\tvar eventPayload = this.buildEventPayload( client, {\n\t\t\t\t\tstate: clientMeta.state,\n\t\t\t\t\tqueuedArgs: queued\n\t\t\t\t} );\n\t\t\t\tthis.emit( events.DEFERRED, eventPayload );\n\t\t\t}\n\t\t},\n\t\n\t\tdeferAndTransition: function( client, stateName ) {\n\t\t\tthis.deferUntilTransition( client, stateName );\n\t\t\tthis.transition( client, stateName );\n\t\t},\n\t\n\t\tprocessQueue: function( client ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tvar filterFn = function( item ) {\n\t\t\t\treturn ( ( !item.untilState ) || ( item.untilState === clientMeta.state ) );\n\t\t\t};\n\t\t\tvar toProcess = _.filter( clientMeta.inputQueue, filterFn );\n\t\t\tclientMeta.inputQueue = _.difference( clientMeta.inputQueue, toProcess );\n\t\t\t_.each( toProcess, function( item ) {\n\t\t\t\tthis.handle.apply( this, [ client ].concat( item.args ) );\n\t\t\t}.bind( this ) );\n\t\t},\n\t\n\t\tclearQueue: function( client, name ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tif ( !name ) {\n\t\t\t\tclientMeta.inputQueue = [];\n\t\t\t} else {\n\t\t\t\tvar filter = function( evnt ) {\n\t\t\t\t\treturn ( name ? evnt.untilState !== name : true );\n\t\t\t\t};\n\t\t\t\tclientMeta.inputQueue = _.filter( clientMeta.inputQueue, filter );\n\t\t\t}\n\t\t},\n\t\n\t\tcompositeState: function( client ) {\n\t\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\t\tvar state = clientMeta.state;\n\t\t\tvar child = this.states[state]._child && this.states[state]._child.instance;\n\t\t\tif ( child ) {\n\t\t\t\tstate += \".\" + child.compositeState( client );\n\t\t\t}\n\t\t\treturn state;\n\t\t}\n\t}, emitter.getInstance() );\n\t\n\tBehavioralFsm.extend = utils.extend;\n\t\n\tmodule.exports = BehavioralFsm;\n\n\n/***/ })\n/******/ ])\n});\n;\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCAyNTUxODVlZDk3ZTE5MjEzN2U1ZSIsIndlYnBhY2s6Ly8vLi9zcmMvbWFjaGluYS5qcyIsIndlYnBhY2s6Ly8vZXh0ZXJuYWwge1wicm9vdFwiOlwiX1wiLFwiY29tbW9uanNcIjpcImxvZGFzaFwiLFwiY29tbW9uanMyXCI6XCJsb2Rhc2hcIixcImFtZFwiOlwibG9kYXNoXCJ9Iiw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TWV0YS5zdGF0ZTtcblx0XHR2YXIgY2hpbGQgPSB0aGlzLnN0YXRlc1tzdGF0ZV0uX2NoaWxkICYmIHRoaXMuc3RhdGVzW3N0YXRlXS5fY2hpbGQuaW5zdGFuY2U7XG5cdFx0aWYgKCBjaGlsZCApIHtcblx0XHRcdHN0YXRlICs9IFwiLlwiICsgY2hpbGQuY29tcG9zaXRlU3RhdGUoIGNsaWVudCApO1xuXHRcdH1cblx0XHRyZXR1cm4gc3RhdGU7XG5cdH1cbn0sIGVtaXR0ZXIuZ2V0SW5zdGFuY2UoKSApO1xuXG5CZWhhdmlvcmFsRnNtLmV4dGVuZCA9IHV0aWxzLmV4dGVuZDtcblxubW9kdWxlLmV4cG9ydHMgPSBCZWhhdmlvcmFsRnNtO1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvQmVoYXZpb3JhbEZzbS5qc1xuLy8gbW9kdWxlIGlkID0gNlxuLy8gbW9kdWxlIGNodW5rcyA9IDAiXSwic291cmNlUm9vdCI6IiJ9"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 255185ed97e192137e5e","var _ = require( \"lodash\" );\nvar emitter = require( \"./emitter\" );\n\nmodule.exports = _.merge( emitter.instance, {\n\tFsm: require( \"./Fsm\" ),\n\tBehavioralFsm: require( \"./BehavioralFsm\" ),\n\tutils: require( \"./utils\" ),\n\teventListeners: {\n\t\tnewFsm: []\n\t}\n} );\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/machina.js\n// module id = 0\n// module chunks = 0","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"_\",\"commonjs\":\"lodash\",\"commonjs2\":\"lodash\",\"amd\":\"lodash\"}\n// module id = 1\n// module chunks = 0","var utils = require( \"./utils\" );\nvar _ = require( \"lodash\" );\n\nfunction getInstance() {\n\treturn {\n\t\temit: function( eventName ) {\n\t\t\tvar args = utils.getLeaklessArgs( arguments );\n\t\t\tif ( this.eventListeners[ \"*\" ] ) {\n\t\t\t\t_.each( this.eventListeners[ \"*\" ], function( callback ) {\n\t\t\t\t\tif ( !this.useSafeEmit ) {\n\t\t\t\t\t\tcallback.apply( this, args );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcallback.apply( this, args );\n\t\t\t\t\t\t} catch ( exception ) {\n\t\t\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\t\t\tif ( console && typeof console.log !== \"undefined\" ) {\n\t\t\t\t\t\t\t\tconsole.log( exception.stack );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, this );\n\t\t\t}\n\t\t\tif ( this.eventListeners[ eventName ] ) {\n\t\t\t\t_.each( this.eventListeners[ eventName ], function( callback ) {\n\t\t\t\t\tif ( !this.useSafeEmit ) {\n\t\t\t\t\t\tcallback.apply( this, args.slice( 1 ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcallback.apply( this, args.slice( 1 ) );\n\t\t\t\t\t\t} catch ( exception ) {\n\t\t\t\t\t\t\t/* istanbul ignore else */\n\t\t\t\t\t\t\tif ( console && typeof console.log !== \"undefined\" ) {\n\t\t\t\t\t\t\t\tconsole.log( exception.stack );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, this );\n\t\t\t}\n\t\t},\n\n\t\ton: function( eventName, callback ) {\n\t\t\tvar self = this;\n\t\t\tself.eventListeners = self.eventListeners || { \"*\": [] };\n\t\t\tif ( !self.eventListeners[ eventName ] ) {\n\t\t\t\tself.eventListeners[ eventName ] = [];\n\t\t\t}\n\t\t\tself.eventListeners[ eventName ].push( callback );\n\t\t\treturn {\n\t\t\t\teventName: eventName,\n\t\t\t\tcallback: callback,\n\t\t\t\toff: function() {\n\t\t\t\t\tself.off( eventName, callback );\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\n\t\toff: function( eventName, callback ) {\n\t\t\tthis.eventListeners = this.eventListeners || { \"*\": [] };\n\t\t\tif ( !eventName ) {\n\t\t\t\tthis.eventListeners = {};\n\t\t\t} else {\n\t\t\t\tif ( callback ) {\n\t\t\t\t\tthis.eventListeners[ eventName ] = _.without( this.eventListeners[ eventName ], callback );\n\t\t\t\t} else {\n\t\t\t\t\tthis.eventListeners[ eventName ] = [];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n}\n\nmodule.exports = {\n\tgetInstance: getInstance,\n\tinstance: getInstance()\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/emitter.js\n// module id = 2\n// module chunks = 0","var slice = [].slice;\nvar events = require( \"./events.js\" );\nvar _ = require( \"lodash\" );\n\nvar makeFsmNamespace = ( function() {\n\tvar machinaCount = 0;\n\treturn function() {\n\t\treturn \"fsm.\" + machinaCount++;\n\t};\n} )();\n\nfunction getDefaultBehavioralOptions() {\n\treturn {\n\t\tinitialState: \"uninitialized\",\n\t\teventListeners: {\n\t\t\t\"*\": []\n\t\t},\n\t\tstates: {},\n\t\tnamespace: makeFsmNamespace(),\n\t\tuseSafeEmit: false,\n\t\thierarchy: {},\n\t\tpendingDelegations: {}\n\t};\n}\n\nfunction getDefaultClientMeta() {\n\treturn {\n\t\tinputQueue: [],\n\t\ttargetReplayState: \"\",\n\t\tstate: undefined,\n\t\tpriorState: undefined,\n\t\tpriorAction: \"\",\n\t\tcurrentAction: \"\",\n\t\tcurrentActionArgs: undefined,\n\t\tinExitHandler: false\n\t};\n}\n\nfunction getLeaklessArgs( args, startIdx ) {\n\tvar result = [];\n\tfor ( var i = ( startIdx || 0 ); i < args.length; i++ ) {\n\t\tresult[ i ] = args[ i ];\n\t}\n\treturn result;\n}\n/*\n\thandle ->\n\t\tchild = stateObj._child && stateObj._child.instance;\n\n\ttransition ->\n\t\tnewStateObj._child = getChildFsmInstance( newStateObj._child );\n\t\tchild = newStateObj._child && newStateObj._child.instance;\n*/\nfunction getChildFsmInstance( config ) {\n\tif ( !config ) {\n\t\treturn;\n\t}\n\tvar childFsmDefinition = {};\n\tif ( typeof config === \"object\" ) {\n\t\t// is this a config object with a factory?\n\t\tif ( config.factory ) {\n\t\t\tchildFsmDefinition = config;\n\t\t} else {\n\t\t\t// assuming this is a machina instance\n\t\t\tchildFsmDefinition.factory = function() {\n\t\t\t\treturn config;\n\t\t\t};\n\t\t}\n\t} else if ( typeof config === \"function\" ) {\n\t\tchildFsmDefinition.factory = config;\n\t}\n\tchildFsmDefinition.instance = childFsmDefinition.factory();\n\treturn childFsmDefinition;\n}\n\nfunction listenToChild( fsm, child ) {\n\t// Need to investigate potential for discarded event\n\t// listener memory leak in long-running, deeply-nested hierarchies.\n\treturn child.on( \"*\", function( eventName, data ) {\n\t\tswitch ( eventName ) {\n\t\t\tcase events.NO_HANDLER:\n\t\t\t\tif ( !data.ticket && !data.delegated && data.namespace !== fsm.namespace ) {\n\t\t\t\t\t// Ok - we're dealing w/ a child handling input that should bubble up\n\t\t\t\t\tdata.args[ 1 ].bubbling = true;\n\t\t\t\t}\n\t\t\t\t// we do NOT bubble _reset inputs up to the parent\n\t\t\t\tif ( data.inputType !== \"_reset\" ) {\n\t\t\t\t\tfsm.handle.apply( fsm, data.args );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase events.HANDLING :\n\t\t\t\tvar ticket = data.ticket;\n\t\t\t\tif ( ticket && fsm.pendingDelegations[ ticket ] ) {\n\t\t\t\t\tdelete fsm.pendingDelegations[ ticket ];\n\t\t\t\t}\n\t\t\t\tfsm.emit( eventName, data ); // possibly transform payload?\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tfsm.emit( eventName, data ); // possibly transform payload?\n\t\t\t\tbreak;\n\t\t}\n\t} );\n}\n\n// _machKeys are members we want to track across the prototype chain of an extended FSM constructor\n// Since we want to eventually merge the aggregate of those values onto the instance so that FSMs\n// that share the same extended prototype won't share state *on* those prototypes.\nvar _machKeys = [ \"states\", \"initialState\" ];\nvar extend = function( protoProps, staticProps ) {\n\tvar parent = this;\n\tvar fsm; // placeholder for instance constructor\n\tvar machObj = {}; // object used to hold initialState & states from prototype for instance-level merging\n\tvar Ctor = function() {}; // placeholder ctor function used to insert level in prototype chain\n\n\t// The constructor function for the new subclass is either defined by you\n\t// (the \"constructor\" property in your `extend` definition), or defaulted\n\t// by us to simply call the parent's constructor.\n\tif ( protoProps && protoProps.hasOwnProperty( \"constructor\" ) ) {\n\t\tfsm = protoProps.constructor;\n\t} else {\n\t\t// The default machina constructor (when using inheritance) creates a\n\t\t// deep copy of the states/initialState values from the prototype and\n\t\t// extends them over the instance so that they'll be instance-level.\n\t\t// If an options arg (args[0]) is passed in, a states or intialState\n\t\t// value will be preferred over any data pulled up from the prototype.\n\t\tfsm = function() {\n\t\t\tvar args = slice.call( arguments, 0 );\n\t\t\targs[ 0 ] = args[ 0 ] || {};\n\t\t\tvar blendedState;\n\t\t\tvar instanceStates = args[ 0 ].states || {};\n\t\t\tblendedState = _.merge( _.cloneDeep( machObj ), { states: instanceStates } );\n\t\t\tblendedState.initialState = args[ 0 ].initialState || this.initialState;\n\t\t\t_.extend( args[ 0 ], blendedState );\n\t\t\tparent.apply( this, args );\n\t\t};\n\t}\n\n\t// Inherit class (static) properties from parent.\n\t_.merge( fsm, parent );\n\n\t// Set the prototype chain to inherit from `parent`, without calling\n\t// `parent`'s constructor function.\n\tCtor.prototype = parent.prototype;\n\tfsm.prototype = new Ctor();\n\n\t// Add prototype properties (instance properties) to the subclass,\n\t// if supplied.\n\tif ( protoProps ) {\n\t\t_.extend( fsm.prototype, protoProps );\n\t\t_.merge( machObj, _.transform( protoProps, function( accum, val, key ) {\n\t\t\tif ( _machKeys.indexOf( key ) !== -1 ) {\n\t\t\t\taccum[ key ] = val;\n\t\t\t}\n\t\t} ) );\n\t}\n\n\t// Add static properties to the constructor function, if supplied.\n\tif ( staticProps ) {\n\t\t_.merge( fsm, staticProps );\n\t}\n\n\t// Correctly set child's `prototype.constructor`.\n\tfsm.prototype.constructor = fsm;\n\n\t// Set a convenience property in case the parent's prototype is needed later.\n\tfsm.__super__ = parent.prototype;\n\treturn fsm;\n};\n\nfunction createUUID() {\n\tvar s = [];\n\tvar hexDigits = \"0123456789abcdef\";\n\tfor ( var i = 0; i < 36; i++ ) {\n\t\ts[ i ] = hexDigits.substr( Math.floor( Math.random() * 0x10 ), 1 );\n\t}\n\ts[ 14 ] = \"4\"; // bits 12-15 of the time_hi_and_version field to 0010\n\t/* jshint ignore:start */\n\ts[ 19 ] = hexDigits.substr( ( s[ 19 ] & 0x3 ) | 0x8, 1 ); // bits 6-7 of the clock_seq_hi_and_reserved to 01\n\t/* jshint ignore:end */\n\ts[ 8 ] = s[ 13 ] = s[ 18 ] = s[ 23 ] = \"-\";\n\treturn s.join( \"\" );\n}\n\nmodule.exports = {\n\tcreateUUID: createUUID,\n\textend: extend,\n\tgetDefaultBehavioralOptions: getDefaultBehavioralOptions,\n\tgetDefaultOptions: getDefaultBehavioralOptions,\n\tgetDefaultClientMeta: getDefaultClientMeta,\n\tgetChildFsmInstance: getChildFsmInstance,\n\tgetLeaklessArgs: getLeaklessArgs,\n\tlistenToChild: listenToChild,\n\tmakeFsmNamespace: makeFsmNamespace\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/utils.js\n// module id = 3\n// module chunks = 0","module.exports = {\n\tNEXT_TRANSITION: \"transition\",\n\tHANDLING: \"handling\",\n\tHANDLED: \"handled\",\n\tNO_HANDLER: \"nohandler\",\n\tTRANSITION: \"transition\",\n\tTRANSITIONED: \"transitioned\",\n\tINVALID_STATE: \"invalidstate\",\n\tDEFERRED: \"deferred\",\n\tNEW_FSM: \"newfsm\"\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/events.js\n// module id = 4\n// module chunks = 0","var BehavioralFsm = require( \"./BehavioralFsm\" );\nvar utils = require( \"./utils\" );\nvar _ = require( \"lodash\" );\n\nvar Fsm = {\n\tconstructor: function() {\n\t\tBehavioralFsm.apply( this, arguments );\n\t\tthis.ensureClientMeta();\n\t},\n\tinitClient: function initClient() {\n\t\tvar initialState = this.initialState;\n\t\tif ( !initialState ) {\n\t\t\tthrow new Error( \"You must specify an initial state for this FSM\" );\n\t\t}\n\t\tif ( !this.states[ initialState ] ) {\n\t\t\tthrow new Error( \"The initial state specified does not exist in the states object.\" );\n\t\t}\n\t\tthis.transition( initialState );\n\t},\n\tensureClientMeta: function ensureClientMeta() {\n\t\tif ( !this._stamped ) {\n\t\t\tthis._stamped = true;\n\t\t\t_.defaults( this, _.cloneDeep( utils.getDefaultClientMeta() ) );\n\t\t\tthis.initClient();\n\t\t}\n\t\treturn this;\n\t},\n\n\tensureClientArg: function( args ) {\n\t\tvar _args = args;\n\t\t// we need to test the args and verify that if a client arg has\n\t\t// been passed, it must be this FSM instance (this isn't a behavioral FSM)\n\t\tif ( typeof _args[ 0 ] === \"object\" && !( \"inputType\" in _args[ 0 ] ) && _args[ 0 ] !== this ) {\n\t\t\t_args.splice( 0, 1, this );\n\t\t} else if ( typeof _args[ 0 ] !== \"object\" || ( typeof _args[ 0 ] === \"object\" && ( \"inputType\" in _args[ 0 ] ) ) ) {\n\t\t\t_args.unshift( this );\n\t\t}\n\t\treturn _args;\n\t},\n\n\tgetHandlerArgs: function( args, isCatchAll ) {\n\t\t// index 0 is the client, index 1 is inputType\n\t\t// if we're in a catch-all handler, input type needs to be included in the args\n\t\t// inputType might be an object, so we need to just get the inputType string if so\n\t\tvar _args = args;\n\t\tvar input = _args[ 1 ];\n\t\tif ( typeof inputType === \"object\" ) {\n\t\t\t_args.splice( 1, 1, input.inputType );\n\t\t}\n\t\treturn isCatchAll ?\n\t\t\t_args.slice( 1 ) :\n\t\t\t_args.slice( 2 );\n\t},\n\n\tgetSystemHandlerArgs: function( args, client ) {\n\t\treturn args;\n\t},\n\n\t// \"classic\" machina FSM do not emit the client property on events (which would be the FSM itself)\n\tbuildEventPayload: function() {\n\t\tvar args = this.ensureClientArg( utils.getLeaklessArgs( arguments ) );\n\t\tvar data = args[ 1 ];\n\t\tif ( _.isPlainObject( data ) ) {\n\t\t\treturn _.extend( data, { namespace: this.namespace } );\n\t\t} else {\n\t\t\treturn { data: data || null, namespace: this.namespace };\n\t\t}\n\t}\n};\n\n_.each( [\n\t\"handle\",\n\t\"transition\",\n\t\"deferUntilTransition\",\n\t\"processQueue\",\n\t\"clearQueue\"\n], function( methodWithClientInjected ) {\n\tFsm[ methodWithClientInjected ] = function() {\n\t\tvar args = this.ensureClientArg( utils.getLeaklessArgs( arguments ) );\n\t\treturn BehavioralFsm.prototype[ methodWithClientInjected ].apply( this, args );\n\t};\n} );\n\nFsm = BehavioralFsm.extend( Fsm );\n\nmodule.exports = Fsm;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/Fsm.js\n// module id = 5\n// module chunks = 0","var _ = require( \"lodash\" );\nvar utils = require( \"./utils\" );\nvar emitter = require( \"./emitter\" );\nvar topLevelEmitter = emitter.instance;\nvar events = require( \"./events\" );\n\nvar MACHINA_PROP = \"__machina__\";\n\nfunction BehavioralFsm( options ) {\n\t_.extend( this, options );\n\t_.defaults( this, utils.getDefaultBehavioralOptions() );\n\tthis.initialize.apply( this, arguments );\n\ttopLevelEmitter.emit( events.NEW_FSM, this );\n}\n\n_.extend( BehavioralFsm.prototype, {\n\tinitialize: function() {},\n\n\tinitClient: function initClient( client ) {\n\t\tvar initialState = this.initialState;\n\t\tif ( !initialState ) {\n\t\t\tthrow new Error( \"You must specify an initial state for this FSM\" );\n\t\t}\n\t\tif ( !this.states[ initialState ] ) {\n\t\t\tthrow new Error( \"The initial state specified does not exist in the states object.\" );\n\t\t}\n\t\tthis.transition( client, initialState );\n\t},\n\n\tconfigForState: function configForState( newState ) {\n\t\tvar newStateObj = this.states[ newState ];\n\t\tvar child;\n\t\t_.each( this.hierarchy, function( childListener, key ) {\n\t\t\tif ( childListener && typeof childListener.off === \"function\" ) {\n\t\t\t\tchildListener.off();\n\t\t\t}\n\t\t} );\n\n\t\tif ( newStateObj._child ) {\n\t\t\tnewStateObj._child = utils.getChildFsmInstance( newStateObj._child );\n\t\t\tchild = newStateObj._child && newStateObj._child.instance;\n\t\t\tthis.hierarchy[ child.namespace ] = utils.listenToChild( this, child );\n\t\t}\n\n\t\treturn child;\n\t},\n\n\tensureClientMeta: function ensureClientMeta( client ) {\n\t\tif ( typeof client !== \"object\" ) {\n\t\t\tthrow new Error( \"An FSM client must be an object.\" );\n\t\t}\n\t\tclient[ MACHINA_PROP ] = client[ MACHINA_PROP ] || {};\n\t\tif ( !client[ MACHINA_PROP ][ this.namespace ] ) {\n\t\t\tclient[ MACHINA_PROP ][ this.namespace ] = _.cloneDeep( utils.getDefaultClientMeta() );\n\t\t\tthis.initClient( client );\n\t\t}\n\t\treturn client[ MACHINA_PROP ][ this.namespace ];\n\t},\n\n\tbuildEventPayload: function( client, data ) {\n\t\tif ( _.isPlainObject( data ) ) {\n\t\t\treturn _.extend( data, { client: client, namespace: this.namespace } );\n\t\t} else {\n\t\t\treturn { client: client, data: data || null, namespace: this.namespace };\n\t\t}\n\t},\n\n\tgetHandlerArgs: function( args, isCatchAll ) {\n\t\t// index 0 is the client, index 1 is inputType\n\t\t// if we're in a catch-all handler, input type needs to be included in the args\n\t\t// inputType might be an object, so we need to just get the inputType string if so\n\t\tvar _args = args.slice( 0 );\n\t\tvar input = _args[ 1 ];\n\t\tif ( typeof input === \"object\" ) {\n\t\t\t_args.splice( 1, 1, input.inputType );\n\t\t}\n\t\treturn isCatchAll ?\n\t\t\t_args :\n\t\t\t[ _args[ 0 ] ].concat( _args.slice( 2 ) );\n\t},\n\n\tgetSystemHandlerArgs: function( args, client ) {\n\t\treturn [ client ].concat( args );\n\t},\n\n\thandle: function( client, input ) {\n\t\tvar inputDef = input;\n\t\tif ( typeof input === \"undefined\" ) {\n\t\t\tthrow new Error( \"The input argument passed to the FSM's handle method is undefined. Did you forget to pass the input name?\" );\n\t\t}\n\t\tif ( typeof input === \"string\" ) {\n\t\t\tinputDef = { inputType: input, delegated: false, ticket: undefined };\n\t\t}\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tvar args = utils.getLeaklessArgs( arguments );\n\t\tif ( typeof input !== \"object\" ) {\n\t\t\targs.splice( 1, 1, inputDef );\n\t\t}\n\t\tclientMeta.currentActionArgs = args.slice( 1 );\n\t\tvar currentState = clientMeta.state;\n\t\tvar stateObj = this.states[ currentState ];\n\t\tvar handlerName;\n\t\tvar handler;\n\t\tvar isCatchAll = false;\n\t\tvar child;\n\t\tvar result;\n\t\tvar action;\n\t\tif ( !clientMeta.inExitHandler ) {\n\t\t\tchild = this.configForState( currentState );\n\t\t\tif ( child && !this.pendingDelegations[ inputDef.ticket ] && !inputDef.bubbling ) {\n\t\t\t\tinputDef.ticket = ( inputDef.ticket || utils.createUUID() );\n\t\t\t\tinputDef.delegated = true;\n\t\t\t\tthis.pendingDelegations[ inputDef.ticket ] = { delegatedTo: child.namespace };\n\t\t\t\t// WARNING - returning a value from `handle` on child FSMs is not really supported.\n\t\t\t\t// If you need to return values from child FSM input handlers, use events instead.\n\t\t\t\tresult = child.handle.apply( child, args );\n\t\t\t} else {\n\t\t\t\tif ( inputDef.ticket && this.pendingDelegations[ inputDef.ticket ] ) {\n\t\t\t\t\tdelete this.pendingDelegations[ inputDef.ticket ];\n\t\t\t\t}\n\t\t\t\thandlerName = stateObj[ inputDef.inputType ] ? inputDef.inputType : \"*\";\n\t\t\t\tisCatchAll = ( handlerName === \"*\" );\n\t\t\t\thandler = ( stateObj[ handlerName ] || this[ handlerName ] ) || this[ \"*\" ];\n\t\t\t\taction = clientMeta.state + \".\" + handlerName;\n\t\t\t\tclientMeta.currentAction = action;\n\t\t\t\tvar eventPayload = this.buildEventPayload(\n\t\t\t\t\tclient,\n\t\t\t\t\t{ inputType: inputDef.inputType, delegated: inputDef.delegated, ticket: inputDef.ticket }\n\t\t\t\t);\n\t\t\t\tif ( !handler ) {\n\t\t\t\t\tthis.emit( events.NO_HANDLER, _.extend( { args: args }, eventPayload ) );\n\t\t\t\t} else {\n\t\t\t\t\tthis.emit( events.HANDLING, eventPayload );\n\t\t\t\t\tif ( typeof handler === \"function\" ) {\n\t\t\t\t\t\tresult = handler.apply( this, this.getHandlerArgs( args, isCatchAll ) );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = handler;\n\t\t\t\t\t\tthis.transition( client, handler );\n\t\t\t\t\t}\n\t\t\t\t\tthis.emit( events.HANDLED, eventPayload );\n\t\t\t\t}\n\t\t\t\tclientMeta.priorAction = clientMeta.currentAction;\n\t\t\t\tclientMeta.currentAction = \"\";\n\t\t\t\tclientMeta.currentActionArgs = undefined;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t},\n\n\ttransition: function( client, newState ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tvar curState = clientMeta.state;\n\t\tvar curStateObj = this.states[ curState ];\n\t\tvar newStateObj = this.states[ newState ];\n\t\tvar child;\n\t\tvar args = utils.getLeaklessArgs( arguments ).slice( 2 );\n\t\tif ( !clientMeta.inExitHandler && newState !== curState ) {\n\t\t\tif ( newStateObj ) {\n\t\t\t\tchild = this.configForState( newState );\n\t\t\t\tif ( curStateObj && curStateObj._onExit ) {\n\t\t\t\t\tclientMeta.inExitHandler = true;\n\t\t\t\t\tcurStateObj._onExit.call( this, client );\n\t\t\t\t\tclientMeta.inExitHandler = false;\n\t\t\t\t}\n\t\t\t\tclientMeta.targetReplayState = newState;\n\t\t\t\tclientMeta.priorState = curState;\n\t\t\t\tclientMeta.state = newState;\n\t\t\t\tvar eventPayload = this.buildEventPayload( client, {\n\t\t\t\t\tfromState: clientMeta.priorState,\n\t\t\t\t\taction: clientMeta.currentAction,\n\t\t\t\t\ttoState: newState\n\t\t\t\t} );\n\t\t\t\tthis.emit( events.TRANSITION, eventPayload );\n\t\t\t\tif ( newStateObj._onEnter ) {\n\t\t\t\t\tnewStateObj._onEnter.apply( this, this.getSystemHandlerArgs( args, client ) );\n\t\t\t\t}\n\t\t\t\tthis.emit( events.TRANSITIONED, eventPayload );\n\t\t\t\tif ( child ) {\n\t\t\t\t\tchild.handle( client, \"_reset\" );\n\t\t\t\t}\n\n\t\t\t\tif ( clientMeta.targetReplayState === newState ) {\n\t\t\t\t\tthis.processQueue( client, events.NEXT_TRANSITION );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.emit( events.INVALID_STATE, this.buildEventPayload( client, {\n\t\t\t\tstate: clientMeta.state,\n\t\t\t\tattemptedState: newState\n\t\t\t} ) );\n\t\t}\n\t},\n\n\tdeferUntilTransition: function( client, stateName ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tif ( clientMeta.currentActionArgs ) {\n\t\t\tvar queued = {\n\t\t\t\ttype: events.NEXT_TRANSITION,\n\t\t\t\tuntilState: stateName,\n\t\t\t\targs: clientMeta.currentActionArgs\n\t\t\t};\n\t\t\tclientMeta.inputQueue.push( queued );\n\t\t\tvar eventPayload = this.buildEventPayload( client, {\n\t\t\t\tstate: clientMeta.state,\n\t\t\t\tqueuedArgs: queued\n\t\t\t} );\n\t\t\tthis.emit( events.DEFERRED, eventPayload );\n\t\t}\n\t},\n\n\tdeferAndTransition: function( client, stateName ) {\n\t\tthis.deferUntilTransition( client, stateName );\n\t\tthis.transition( client, stateName );\n\t},\n\n\tprocessQueue: function( client ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tvar filterFn = function( item ) {\n\t\t\treturn ( ( !item.untilState ) || ( item.untilState === clientMeta.state ) );\n\t\t};\n\t\tvar toProcess = _.filter( clientMeta.inputQueue, filterFn );\n\t\tclientMeta.inputQueue = _.difference( clientMeta.inputQueue, toProcess );\n\t\t_.each( toProcess, function( item ) {\n\t\t\tthis.handle.apply( this, [ client ].concat( item.args ) );\n\t\t}.bind( this ) );\n\t},\n\n\tclearQueue: function( client, name ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tif ( !name ) {\n\t\t\tclientMeta.inputQueue = [];\n\t\t} else {\n\t\t\tvar filter = function( evnt ) {\n\t\t\t\treturn ( name ? evnt.untilState !== name : true );\n\t\t\t};\n\t\t\tclientMeta.inputQueue = _.filter( clientMeta.inputQueue, filter );\n\t\t}\n\t},\n\n\tcompositeState: function( client ) {\n\t\tvar clientMeta = this.ensureClientMeta( client );\n\t\tvar state = clientMeta.state;\n\t\tvar child = this.states[state]._child && this.states[state]._child.instance;\n\t\tif ( child ) {\n\t\t\tstate += \".\" + child.compositeState( client );\n\t\t}\n\t\treturn state;\n\t}\n}, emitter.getInstance() );\n\nBehavioralFsm.extend = utils.extend;\n\nmodule.exports = BehavioralFsm;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/BehavioralFsm.js\n// module id = 6\n// module chunks = 0"]} \ No newline at end of file diff --git a/spec/utils.spec.js b/spec/utils.spec.js index 3ef4fdc..3103768 100644 --- a/spec/utils.spec.js +++ b/spec/utils.spec.js @@ -104,5 +104,47 @@ describe( "Machina Namespace Events", function() { console.log = log; } ); } ); + + after( function() { + machina.off( "*" ); + } ); + } ); + describe( "when specifying a factory function", function() { + it( "should only be called once when specified as a function", function() { + var counter = 0; + var child = new machina.Fsm( { states: { uninitialized: {} } } ); + + new machina.Fsm( { + states: { + uninitialized: { + _child: function() { + counter += 1; + return child; + } + } + } + } ); + + counter.should.equal( 1 ); + } ); + it( "should only be called once when specified in a configuration object", function() { + var counter = 0; + var child = new machina.Fsm( { states: { uninitialized: {} } } ); + + new machina.Fsm( { + states: { + uninitialized: { + _child: { + factory: function() { + counter += 1; + return child; + } + } + } + } + } ); + + counter.should.equal( 1 ); + } ); } ); } ); diff --git a/src/utils.js b/src/utils.js index 96d509d..b05aa29 100644 --- a/src/utils.js +++ b/src/utils.js @@ -60,7 +60,6 @@ function getChildFsmInstance( config ) { // is this a config object with a factory? if ( config.factory ) { childFsmDefinition = config; - childFsmDefinition.instance = childFsmDefinition.factory(); } else { // assuming this is a machina instance childFsmDefinition.factory = function() {