diff --git a/README.md b/README.md index b753bde..6abc401 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# machina v4.0.2 +# machina v4.0.3 ## What is it? Machina.js is a JavaScript framework for highly customizable finite state machines (FSMs). Many of the ideas for machina have been *loosely* inspired by the Erlang/OTP FSM behaviors. diff --git a/changelog.md b/changelog.md index 48c6063..7113312 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +### v4.0.3 +* Updated lodash to ^4.17.15 + ### v4.0.2 * Updated lodash to ^4.17.5 diff --git a/lib/machina.js b/lib/machina.js index 79c5f0f..89f1692 100644 --- a/lib/machina.js +++ b/lib/machina.js @@ -1,7 +1,7 @@ /*! * * machina - A library for creating powerful and flexible finite state machines. Loosely inspired by Erlang/OTP's gen_fsm behavior. * * Author: Jim Cowart (http://ifandelse.com) - * * Version: v4.0.2 + * * Version: v4.0.3 * * Url: http://machina-js.org/ * * License(s): */ diff --git a/lib/machina.min.js.map b/lib/machina.min.js.map index c2049f8..ff4c565 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 dbcf2491954d02cd6037","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","bind","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","stateList","isArray","queued","type","untilState","queuedArgs","deferAndTransition","filterFn","item","includes","toProcess","filter","difference","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,EAAA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,OAEA7F,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: v4.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}.bind( 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}.bind( 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\tvar stateList = _.isArray( stateName ) ? stateName : ( stateName ? [ stateName ] : undefined );\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: stateList,\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 ) || ( _.includes( 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\t// first pass we remove the target state from any `untilState` array\n\t\t\t\t_.each( clientMeta.inputQueue, function( item ) {\n\t\t\t\t\titem.untilState = _.without( item.untilState, name );\n\t\t\t\t} );\n\t\t\t\t// second pass we clear out deferred events with empty untilState arrays\n\t\t\t\tvar filter = function( evnt ) {\n\t\t\t\t\treturn evnt.untilState.length !== 0;\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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCBkYmNmMjQ5MTk1NGQwMmNkNjAzNyIsIndlYnBhY2s6Ly8vLi9zcmMvbWFjaGluYS5qcyIsIndlYnBhY2s6Ly8vZXh0ZXJuYWwge1wicm9vdFwiOlwiX1wiLFwiY29tbW9uanNcIjpcImxvZGFzaFwiLFwiY29tbW9uanMyXCI6XCJsb2Rhc2hcIixcImFtZFwiOlwibG9kYXNoXCJ9Iiwid2VicGFjazovLy8uL3NyYy9lbWl0dGVyLmpzIiwid2VicGFjazovLy8uL3NyYy91dGlscy5qcyIsIndlYnBhY2s6Ly8vLi9zcmMvZXZlbnRzLmpzIiwid2VicGFjazovLy8uL3NyYy9Gc20uanMiLCJ3ZWJwYWNrOi8vLy4vc3JjL0JlaG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Zpb3JhbEZzbS5qc1xuLy8gbW9kdWxlIGlkID0gNlxuLy8gbW9kdWxlIGNodW5rcyA9IDAiXSwic291cmNlUm9vdCI6IiJ9"," \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 dbcf2491954d02cd6037","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}.bind( 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}.bind( 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\tvar stateList = _.isArray( stateName ) ? stateName : ( stateName ? [ stateName ] : undefined );\n\t\tif ( clientMeta.currentActionArgs ) {\n\t\t\tvar queued = {\n\t\t\t\ttype: events.NEXT_TRANSITION,\n\t\t\t\tuntilState: stateList,\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 ) || ( _.includes( 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\t// first pass we remove the target state from any `untilState` array\n\t\t\t_.each( clientMeta.inputQueue, function( item ) {\n\t\t\t\titem.untilState = _.without( item.untilState, name );\n\t\t\t} );\n\t\t\t// second pass we clear out deferred events with empty untilState arrays\n\t\t\tvar filter = function( evnt ) {\n\t\t\t\treturn evnt.untilState.length !== 0;\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 dbcf2491954d02cd6037","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","bind","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","stateList","isArray","queued","type","untilState","queuedArgs","deferAndTransition","filterFn","item","includes","toProcess","filter","difference","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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,QAIA,OAHAsD,KACAhB,GAAA,IAAAgB,EAAA6G,eAAAjD,IAEA5E,IAECxC,EAAAQ,eAEDJ,EAAAwE,OAAAvE,EAAAuE,OAEA7F,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: v4.0.3\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}.bind( 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}.bind( 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\tvar stateList = _.isArray( stateName ) ? stateName : ( stateName ? [ stateName ] : undefined );\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: stateList,\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 ) || ( _.includes( 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\t// first pass we remove the target state from any `untilState` array\n\t\t\t\t_.each( clientMeta.inputQueue, function( item ) {\n\t\t\t\t\titem.untilState = _.without( item.untilState, name );\n\t\t\t\t} );\n\t\t\t\t// second pass we clear out deferred events with empty untilState arrays\n\t\t\t\tvar filter = function( evnt ) {\n\t\t\t\t\treturn evnt.untilState.length !== 0;\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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCBkYmNmMjQ5MTk1NGQwMmNkNjAzNyIsIndlYnBhY2s6Ly8vLi9zcmMvbWFjaGluYS5qcyIsIndlYnBhY2s6Ly8vZXh0ZXJuYWwge1wicm9vdFwiOlwiX1wiLFwiY29tbW9uanNcIjpcImxvZGFzaFwiLFwiY29tbW9uanMyXCI6XCJsb2Rhc2hcIixcImFtZFwiOlwibG9kYXNoXCJ9Iiwid2VicGFjazovLy8uL3NyYy9lbWl0dGVyLmpzIiwid2VicGFjazovLy8uL3NyYy91dGlscy5qcyIsIndlYnBh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mlvcmFsRnNtO1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9zcmMvQmVoYXZpb3JhbEZzbS5qc1xuLy8gbW9kdWxlIGlkID0gNlxuLy8gbW9kdWxlIGNodW5rcyA9IDAiXSwic291cmNlUm9vdCI6IiJ9"," \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 dbcf2491954d02cd6037","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}.bind( 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}.bind( 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\tvar stateList = _.isArray( stateName ) ? stateName : ( stateName ? [ stateName ] : undefined );\n\t\tif ( clientMeta.currentActionArgs ) {\n\t\t\tvar queued = {\n\t\t\t\ttype: events.NEXT_TRANSITION,\n\t\t\t\tuntilState: stateList,\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 ) || ( _.includes( 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\t// first pass we remove the target state from any `untilState` array\n\t\t\t_.each( clientMeta.inputQueue, function( item ) {\n\t\t\t\titem.untilState = _.without( item.untilState, name );\n\t\t\t} );\n\t\t\t// second pass we clear out deferred events with empty untilState arrays\n\t\t\tvar filter = function( evnt ) {\n\t\t\t\treturn evnt.untilState.length !== 0;\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/package.json b/package.json index deedbde..5fb691b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "machina", "description": "A library for creating powerful and flexible finite state machines. Loosely inspired by Erlang/OTP's gen_fsm behavior.", - "version": "4.0.2", + "version": "4.0.3", "homepage": "http://machina-js.org/", "repository": { "type": "git", @@ -67,6 +67,10 @@ { "name": "Joel Purra", "url": "http://joelpurra.com/" + }, + { + "name": "Parker Johansen", + "url": "https://github.com/auroq" } ], "keywords": [ @@ -100,7 +104,7 @@ "node": ">=0.4.0" }, "dependencies": { - "lodash": "^4.17.5" + "lodash": "^4.17.15" }, "devDependencies": { "bower": "1.x",