UNPKG

@scion-scxml/core

Version:

StateCharts Interpretation and Optimization eNgine (SCION) CORE is an implementation of Statecharts in JavaScript.

3 lines 49.9 kB
/*! @scion-scxml/core 2021-04-18 */ !function(a,b){if("function"==typeof define&&define.amd)define(["module","exports"],b);else if("undefined"!=typeof exports)b(module,exports);else{var c={exports:{}};b(c,c.exports),a.scion=a.scion||{},a.scion.core=c.exports}}(this,function(a,b){"use strict";var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};!function(d){if("object"===("undefined"==typeof b?"undefined":c(b))&&"undefined"!=typeof a)a.exports=d();else if("function"==typeof define&&define.amd)define([],d);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.core=d()}}(function(){return function(){function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c||a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}return a}()({1:[function(a,b,d){(function(d){function e(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function f(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function g(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==("undefined"==typeof b?"undefined":c(b))&&"function"!=typeof b?a:b}function h(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof b?"undefined":c(b)));a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var i=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),j=a("@scion-scxml/core-base"),k=(j.helpers,j.query),l=j.helpers.transitionComparator,m=function(a){function b(a,c){return f(this,b),c=c||{},c.legacySemantics=!1,g(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a,c))}return h(b,a),i(b,[{key:"_selectTransitions",value:function(a,b){var c=this.opts.transitionSelector,d=new this.opts.Set,e=this._evaluateAction.bind(this,a),f=this._configuration.iter().sort(l),g=!0,h=!1,i=void 0;try{for(var j,m=f[Symbol.iterator]();!(g=(j=m.next()).done);g=!0){var n=j.value,o=!0,p=!1,q=void 0;try{a:for(var r,s=[n].concat(k.getAncestors(n))[Symbol.iterator]();!(o=(r=s.next()).done);o=!0){var t=r.value,u=!0,v=!1,w=void 0;try{for(var x,y=t.transitions[Symbol.iterator]();!(u=(x=y.next()).done);u=!0){var z=x.value;if(c(z,a,e,b)){d.add(z);break a}}}catch(A){v=!0,w=A}finally{try{!u&&y["return"]&&y["return"]()}finally{if(v)throw w}}}}catch(A){p=!0,q=A}finally{try{!o&&s["return"]&&s["return"]()}finally{if(p)throw q}}}}catch(A){h=!0,i=A}finally{try{!g&&m["return"]&&m["return"]()}finally{if(h)throw i}}var B=this._removeConflictingTransition(d);return this._log("priorityEnabledTransitions",B),B}},{key:"_removeConflictingTransition",value:function(a){var b=this,c=new this.opts.Set,d=!0,f=!1,g=void 0;try{for(var h,i=a.iter()[Symbol.iterator]();!(d=(h=i.next()).done);d=!0){var j=h.value,k=!1,l=new Set,m=!0,n=!1,o=void 0;try{for(var p,q=function(){var a=p.value,c=b._computeExitSet([j]),d=b._computeExitSet([a]),f=[].concat(e(c)).some(function(a){return d.has(a)})||[].concat(e(d)).some(function(a){return c.has(a)});if(b._log("t1ExitSet",j.source.id,[].concat(e(c)).map(function(a){return a.id})),b._log("t2ExitSet",a.source.id,[].concat(e(d)).map(function(a){return a.id})),b._log("hasIntersection",f),f){if(!(a.source.descendants.indexOf(j.source)>-1))return k=!0,"break";l.add(a)}},r=c.iter()[Symbol.iterator]();!(m=(p=r.next()).done);m=!0){var s=q();if("break"===s)break}}catch(t){n=!0,o=t}finally{try{!m&&r["return"]&&r["return"]()}finally{if(n)throw o}}if(!k){var u=!0,v=!1,w=void 0;try{for(var x,y=l[Symbol.iterator]();!(u=(x=y.next()).done);u=!0){var z=x.value;c.remove(z)}}catch(t){v=!0,w=t}finally{try{!u&&y["return"]&&y["return"]()}finally{if(v)throw w}}c.add(j)}}}catch(t){f=!0,g=t}finally{try{!d&&i["return"]&&i["return"]()}finally{if(f)throw g}}return c}}]),b}(j.BaseInterpreter);j.Statechart=m,j.InterpreterScriptingContext.invokers={"http://www.w3.org/TR/scxml/":function(a,b,c,e){if(!b.constructorFunction)throw new Error("Invoke object needs a constructorFunction property");var f=b.constructorFunction,g={invokeid:b.id,params:b.params,parentSession:a,docUrl:b.docUrl},h=c,i=void 0;g.parentSession instanceof m&&(i=new m(f,g)),e(null,i,f,h),d(function(){return i.start()})}},j.InterpreterScriptingContext.invokers[void 0]=j.InterpreterScriptingContext.invokers[null]=j.InterpreterScriptingContext.invokers.scxml=j.InterpreterScriptingContext.invokers["http://www.w3.org/TR/scxml/"],b.exports=j}).call(this,a("timers").setImmediate)},{"@scion-scxml/core-base":6,timers:9}],2:[function(a,b,c){function d(a){a=a||[],this.o=new Set(a)}d.prototype={add:function(a){this.o.add(a)},remove:function(a){return this.o["delete"](a)},union:function(a){var b=!0,c=!1,d=void 0;try{for(var e,f=a.o[Symbol.iterator]();!(b=(e=f.next()).done);b=!0){var g=e.value;this.o.add(g)}}catch(h){c=!0,d=h}finally{try{!b&&f["return"]&&f["return"]()}finally{if(c)throw d}}return this},difference:function(a){var b=!0,c=!1,d=void 0;try{for(var e,f=a.o[Symbol.iterator]();!(b=(e=f.next()).done);b=!0){var g=e.value;this.o["delete"](g)}}catch(h){c=!0,d=h}finally{try{!b&&f["return"]&&f["return"]()}finally{if(c)throw d}}return this},contains:function(a){return this.o.has(a)},iter:function(){return Array.from(this.o)},isEmpty:function(){return!this.o.size},size:function(){return this.o.size},equals:function(a){if(this.o.size!==a.size())return!1;var b=!0,c=!1,d=void 0;try{for(var e,f=this.o[Symbol.iterator]();!(b=(e=f.next()).done);b=!0){var g=e.value;if(!a.contains(g))return!1}}catch(h){c=!0,d=h}finally{try{!b&&f["return"]&&f["return"]()}finally{if(c)throw d}}return!0},toString:function(){return 0===this.o.size?"<empty>":Array.from(this.o).join(",\n")}},b.exports=d},{}],3:[function(a,b,c){var d={BASIC:0,COMPOSITE:1,PARALLEL:2,HISTORY:3,INITIAL:4,FINAL:5},e="http://www.w3.org/TR/scxml/#SCXMLEventProcessor",f="http://www.w3.org/TR/scxml/#BasicHTTPEventProcessor",g=/\.\*$/;b.exports={STATE_TYPES:d,SCXML_IOPROCESSOR_TYPE:e,HTTP_IOPROCESSOR_TYPE:f,RX_TRAILING_WILDCARD:g}},{}],4:[function(a,b,d){function e(a,b){return Object.keys(b).forEach(function(c){a[c]=b[c]}),a}function f(a){return a.targets}function g(a,b){return a.documentOrder-b.documentOrder}function h(a,b){function c(a){void 0===q[a]&&(q[a]=0);do var b=q[a]++,c="$generated-"+a+"-"+b;while(o.has(c));return c}function d(a){return{$deserializeDatamodel:a.$deserializeDatamodel||function(){},$serializeDatamodel:a.$serializeDatamodel||function(){return null},$idToStateMap:o,docUrl:a.docUrl,name:a.name,states:[{$type:"initial",transitions:[{target:a}]},a],modelFnName:a.modelFnName}}function e(a){return a+" -- "+(this.events?"("+this.events.join(",")+")":null)+(this.cond?"["+this.cond.name+"]":"")+" --> "+(this.targets?this.targets.join(","):null)}function f(){return this.id}function g(a){if(a.id&&o.set(a.id,a),a.states)for(var b=0,c=a.states.length;b<c;b++)g(a.states[b])}function h(a,b){w&&(b.toString=f),b.transitions&&n.push.apply(n,b.transitions),b.$type=b.$type||"state",b.ancestors=a,b.depth=a.length,b.parent=a[0],b.documentOrder=p++,b.transitions=b.transitions||[];for(var d=0,g=b.transitions.length;d<g;d++){var j=b.transitions[d];j.documentOrder=p++,j.source=b,w&&(j.toString=e.bind(j,b))}if(b.states)for(var k=[b].concat(a),d=0,g=b.states.length;d<g;d++)h(k,b.states[d]);switch(b.$type){case"parallel":b.typeEnum=u.PARALLEL,b.isAtomic=!1;break;case"initial":b.typeEnum=u.INITIAL,b.isAtomic=!0;break;case"history":b.typeEnum=u.HISTORY,b.isAtomic=!0;break;case"final":b.typeEnum=u.FINAL,b.isAtomic=!0;break;case"state":case"scxml":b.states&&b.states.length?(b.typeEnum=u.COMPOSITE,b.isAtomic=!1):(b.typeEnum=u.BASIC,b.isAtomic=!0);break;default:throw new Error("Unknown state type: "+b.$type)}b.states?b.descendants=b.states.concat(b.states.map(function(a){return a.descendants}).reduce(function(a,b){return a.concat(b)},[])):b.descendants=[];var l;if(b.typeEnum===u.COMPOSITE&&(Array.isArray(b.initial)||"string"==typeof b.initial?r.push(b):(l=b.states.filter(function(a){return"initial"===a.$type}),b.initialRef=[l.length?l[0]:b.states[0]],i(b))),b.typeEnum===u.COMPOSITE||b.typeEnum===u.PARALLEL){var m=b.states.filter(function(a){return"history"===a.$type});b.historyRef=m}b.id||(b.id=c(b.$type),o.set(b.id,b)),["onEntry","onExit"].forEach(function(a){b[a]&&(Array.isArray(b[a])||(b[a]=[b[a]]),b[a].every(function(a){return Array.isArray(a)})||(b[a]=[b[a]]))}),b.invokes&&!Array.isArray(b.invokes)&&(b.invokes=[b.invokes],b.invokes.forEach(function(a){a.finalize&&!Array.isArray(a.finalize)&&(a.finalize=[a.finalize])}))}function i(a){if(!a.initialRef)throw new Error("Unable to locate initial state for composite state: "+a.id)}function j(){for(var a=0,b=r.length;a<b;a++){var c=r[a],d=Array.isArray(c.initial)?c.initial:[c.initial];c.initialRef=d.map(function(a){return o.get(a)}),i(c)}}function k(){for(var a=0,b=n.length;a<b;a++){var c=n[a];if(c.onTransition&&!Array.isArray(c.onTransition)&&(c.onTransition=[c.onTransition]),"string"==typeof c.event&&(c.events=c.event.trim().split(t)),delete c.event,!c.targets&&"undefined"!=typeof c.target)if("string"==typeof c.target){var d=o.get(c.target);if(!d)throw new Error("Unable to find target state with id "+c.target);c.target=d,c.targets=[c.target]}else if(Array.isArray(c.target))c.targets=c.target.map(function(a){if("string"==typeof a){if(a=o.get(a),!a)throw new Error("Unable to find target state with id "+c.target);return a}return a});else{if("object"!==s(c.target))throw new Error("Transition target has unknown type: "+c.target);c.targets=[c.target]}}for(var a=0,b=n.length;a<b;a++){var c=n[a];c.targets&&(c.lcca=m(c.source,c.targets[0])),c.scope=l(c)}}function l(a){var b="internal"===a.type&&a.source.typeEnum===u.COMPOSITE&&a.source.parent&&a.targets&&a.targets.every(function(b){return a.source.descendants.indexOf(b)>-1});return a.targets?b?a.source:a.lcca:null}function m(a,c){for(var d=[],e=0,f=a.ancestors.length;e<f;e++){var g=a.ancestors[e];(b&&b.legacySemantics?g.typeEnum===u.COMPOSITE:g.typeEnum===u.COMPOSITE||g.typeEnum===u.PARALLEL)&&g.descendants.indexOf(c)>-1&&d.push(g)}if(!d.length)throw new Error("Could not find LCA for states.");return d[0]}var n=[],o=new Map,p=0,q={},r=[],t=/\s+/;g(a);var v=d(a);return h([],v),k(),j(),v}function i(a,b){return a=a.replace(v,""),a===b||!(a.length>b.length)&&("."===b.charAt(a.length)&&0===b.indexOf(a))}function j(a,b){return a.events.some(function(a){return"*"===a||i(a,b)})}function k(a,b,c,d){return(d?!a.events:a.events&&b&&b.name&&j(a,b.name))&&(!a.cond||c(a.cond))}function l(a){return a.transitions.filter(function(a){return!a.events||a.events&&0===a.events.length})}function m(a){var b=a[0],c=a[1];o(b.source,c.source);return b.source.depth<c.source.depth?c:c.source.depth<b.source.depth?b:b.documentOrder<c.documentOrder?b:c}function n(a,b){return o(a,b)*-1}function o(a,b){return a.depth>b.depth?-1:a.depth<b.depth?1:a.documentOrder<b.documentOrder?1:a.documentOrder>b.documentOrder?-1:0}function p(a,b,c){var d=a.call(c,b._x,b._x._sessionid,b._x._ioprocessors,c.isIn.bind(c));return d.modelFnName=a.name,d}function q(a,b){return a.map(function(a){var c=b.get(a);if(!c)throw new Error("Error loading serialized configuration. Unable to locate state with id "+a);return c})}function r(a,b){var c={};return Object.keys(a).forEach(function(d){c[d]=a[d].map(function(a){var c=b.get(a);if(!c)throw new Error("Error loading serialized history. Unable to locate state with id "+a);return c})}),c}var s="function"==typeof Symbol&&"symbol"===c(Symbol.iterator)?function(a){return"undefined"==typeof a?"undefined":c(a)}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":"undefined"==typeof a?"undefined":c(a)},t=a("./constants"),u=t.STATE_TYPES,v=t.RX_TRAILING_WILDCARD,w=!1;b.exports={extend:e,transitionWithTargets:f,transitionComparator:g,initializeModel:h,isEventPrefixMatch:i,isTransitionMatch:j,scxmlPrefixTransitionSelector:k,eventlessTransitionSelector:l,getTransitionWithHigherSourceChildPriority:m,sortInEntryOrder:n,getStateWithHigherSourceChildPriority:o,initializeModelGeneratorFn:p,deserializeSerializedConfiguration:q,deserializeHistory:r}},{"./constants":3}],5:[function(a,b,c){var d=a("./constants"),e={isDescendant:function(a,b){return b.descendants.indexOf(a)>-1},getAncestors:function(a,b){var c;return c=a.ancestors.indexOf(b),c>-1?a.ancestors.slice(0,c):a.ancestors},isOrthogonalTo:function(a,b){return!this.isAncestrallyRelatedTo(a,b)&&this.getLCA(a,b).typeEnum===d.STATE_TYPES.PARALLEL},isAncestrallyRelatedTo:function(a,b){return this.getAncestorsOrSelf(b).indexOf(a)>-1||this.getAncestorsOrSelf(a).indexOf(b)>-1},getAncestorsOrSelf:function(a,b){return[a].concat(e.getAncestors(a,b))},getDescendantsOrSelf:function(a){return[a].concat(a.descendants)},getLCA:function(a,b){var c=this.getAncestors(a).filter(function(a){return a.descendants.indexOf(b)>-1},this);return c[0]}};b.exports=e},{"./constants":3}],6:[function(a,b,d){(function(d,e){function f(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function h(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!==("undefined"==typeof b?"undefined":c(b))&&"function"!=typeof b?a:b}function i(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof b?"undefined":c(b)));a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function j(){}var k=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&h["return"]&&h["return"]()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l="function"==typeof Symbol&&"symbol"===c(Symbol.iterator)?function(a){return"undefined"==typeof a?"undefined":c(a)}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":"undefined"==typeof a?"undefined":c(a)},m=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),n=a("tiny-events").EventEmitter,o=a("util"),p=a("./ArraySet"),q=a("./constants"),r=a("./helpers"),s=a("./query"),t=r.extend,u=r.transitionWithTargets,v=r.transitionComparator,w=r.initializeModel,x=(r.isEventPrefixMatch,r.isTransitionMatch,r.scxmlPrefixTransitionSelector),y=(r.eventlessTransitionSelector,r.getTransitionWithHigherSourceChildPriority),z=r.sortInEntryOrder,A=r.getStateWithHigherSourceChildPriority,B=r.initializeModelGeneratorFn,C=r.deserializeSerializedConfiguration,D=r.deserializeHistory,E=q.STATE_TYPES.BASIC,F=q.STATE_TYPES.COMPOSITE,G=q.STATE_TYPES.PARALLEL,H=q.STATE_TYPES.HISTORY,I=q.STATE_TYPES.INITIAL,J=q.STATE_TYPES.FINAL,K=q.SCXML_IOPROCESSOR_TYPE,L="undefined"!=typeof d&&!!d.env.DEBUG,M=function(a){function c(a,d){g(this,c);var e=h(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));e.opts=d,e.opts.InterpreterScriptingContext=e.opts.InterpreterScriptingContext||N,e._isStepping=!1,e._scriptingContext=e.opts.interpreterScriptingContext||(e.opts.InterpreterScriptingContext?new e.opts.InterpreterScriptingContext(e):{}),e.opts.generateSessionid=e.opts.generateSessionid||c.generateSessionid,e.opts.sessionid=e.opts.sessionid||e.opts.generateSessionid(),e.opts.sessionRegistry=e.opts.sessionRegistry||c.sessionRegistry,e.opts.invokerExecutionContext=d.invokerExecutionContext||a._executionContext;var f={};f[K]={location:"#_scxml_"+e.opts.sessionid},f.scxml=f[K],e.opts._x={_sessionid:e.opts.sessionid,_ioprocessors:f};var i;if("function"==typeof a)i=B(a,e.opts,e);else{if("object"!==("undefined"==typeof a?"undefined":l(a)))throw new Error("Unexpected model type. Expected model factory function, or scjson object.");i=JSON.parse(JSON.stringify(a))}return e._model=w(i,e.opts),e.opts.console=e.opts.console||("undefined"==typeof console?{log:function(){}}:console),e.opts.Set=e.opts.Set||p,e.opts.priorityComparisonFn=e.opts.priorityComparisonFn||y,e.opts.transitionSelector=e.opts.transitionSelector||x,e.opts.sessionRegistry.set(String(e.opts.sessionid),e),e._scriptingContext.log=e._scriptingContext.log||function(){this.opts.console.log.apply?this.opts.console.log.apply(this.opts.console,arguments):this.opts.console.log(Array.prototype.slice.apply(arguments).join(","))}.bind(e),e._externalEventQueue=[],e._internalEventQueue=[],e.opts.params&&e._model.$deserializeDatamodel(e.opts.params),e.opts.snapshot?(e._configuration=new e.opts.Set(C(e.opts.snapshot[0],e._model.$idToStateMap)),e._historyValue=D(e.opts.snapshot[1],e._model.$idToStateMap),e._isInFinalState=e.opts.snapshot[2],e._model.$deserializeDatamodel(e.opts.snapshot[3]),e._internalEventQueue=e.opts.snapshot[4]):(e._configuration=new e.opts.Set,e._historyValue={},e._isInFinalState=!1),c.EVENTS.forEach(function(a){this.on(a,this._log.bind(this,a))},e),b.exports.emit("new",e),e}return i(c,a),m(c,[{key:"cancel",value:function(){delete this.opts.parentSession,this._isInFinalState||(this._isInFinalState=!0,this._log("session cancelled "+this.opts.invokeid),this._exitInterpreter(null))}},{key:"_exitInterpreter",value:function(a){var b=this;this._cancelAllDelayedSends();for(var c=this._getFullConfiguration().sort(A),d=0,e=c.length;d<e;d++){var f=c[d];if(void 0!==f.onExit)for(var g=0,h=f.onExit.length;g<h;g++)for(var i=f.onExit[g],j=0,k=i.length;j<k;j++){var l=i[j];try{l.call(this._scriptingContext,null)}catch(m){this._handleError(m,l);break}}f.invokes&&f.invokes.forEach(function(a){b._scriptingContext.cancelInvoke(a.id)}),"final"===f.$type&&"scxml"===f.parent.$type&&(this.opts.parentSession&&this._scriptingContext.send({target:"#_parent",name:"done.invoke."+this.opts.invokeid,data:f.donedata&&f.donedata.call(this._scriptingContext,a)}),this.opts.sessionRegistry["delete"](this.opts.sessionid),this.emit("onExitInterpreter",a))}}},{key:"start",value:function(){return this._initStart(),this._performBigStep(),this.getConfiguration()}},{key:"startAsync",value:function(a){a=this._initStart(a),this.genAsync(null,a)}},{key:"_initStart",value:function(a){var b=this;return"function"!=typeof a&&(a=j),this._log("performing initial big step"),this._model.initialRef.forEach(function(a){return b._configuration.add(a)}),a}},{key:"getConfiguration",value:function(){return this._configuration.iter().map(function(a){return a.id})}},{key:"_getFullConfiguration",value:function(){return this._configuration.iter().map(function(a){return[a].concat(s.getAncestors(a))},this).reduce(function(a,b){return a.concat(b)},[]).reduce(function(a,b){return a.indexOf(b)>-1?a:a.concat(b)},[])}},{key:"getFullConfiguration",value:function(){return this._getFullConfiguration().map(function(a){return a.id})}},{key:"isIn",value:function(a){return this.getFullConfiguration().indexOf(a)>-1}},{key:"isFinal",value:function(){return this._isInFinalState}},{key:"_performBigStep",value:function(a){var b=void 0,c=void 0,d=void 0,e=void 0,f=this._startBigStep(a),g=k(f,4);for(d=g[0],e=g[1],c=g[2],b=g[3];c;){var h=this._selectTransitionsAndPerformSmallStep(b,e,d),i=k(h,2);b=i[0],c=i[1]}this._finishBigStep(b,e,d)}},{key:"_selectTransitionsAndPerformSmallStep",value:function(a,b,c){var d=this._selectTransitions(a,!0);if(d.isEmpty()){var e=this._internalEventQueue.shift();e&&(a=e,d=this._selectTransitions(a,!1))}if(!d.isEmpty()){this.emit("onSmallStepBegin",a);var f=void 0,g=void 0,h=this._performSmallStep(a,d),i=k(h,2);f=i[0],g=i[1],f&&f.forEach(function(a){return c.add(a)}),g&&g.forEach(function(a){return b.add(a)}),this.emit("onSmallStepEnd",a)}var j=!d.isEmpty()||this._internalEventQueue.length;return[a,j]}},{key:"_startBigStep",value:function(a){var b=this;this.emit("onBigStepBegin",a),this._configuration.iter().forEach(function(c){c.invokes&&c.invokes.forEach(function(c){c.autoforward&&b._scriptingContext.send({target:"#_"+c.id,name:a.name,data:a.data}),c.id===a.invokeid&&c.finalize&&c.finalize.forEach(function(c){return b._evaluateAction(a,c)})})}),a&&this._internalEventQueue.push(a);var c=new Set,d=new Set,e=!0,f=a;return[d,c,e,f]}},{key:"_finishBigStep",value:function(a,b,c,d){var e=this,g=Array.from(new Set([].concat(f(b)).filter(function(a){return a.invokes&&!c.has(a)}))).sort(z);g.forEach(function(b){b.invokes.forEach(function(b){return e._evaluateAction(a,b)})}),c.forEach(function(a){a.invokes&&a.invokes.forEach(function(a){e._scriptingContext.cancelInvoke(a.id)})}),this._isInFinalState=this._configuration.iter().every(function(a){return a.typeEnum===J}),this._isInFinalState&&this._exitInterpreter(a),this.emit("onBigStepEnd",a),d&&d(void 0,this.getConfiguration())}},{key:"_cancelAllDelayedSends",value:function(){var a=!0,b=!1,c=void 0;try{for(var d,e=this._scriptingContext._timeouts[Symbol.iterator]();!(a=(d=e.next()).done);a=!0){var f=d.value;f.sendOptions.delay&&(this._log("cancelling delayed send",f),clearTimeout(f.timeoutHandle),this._scriptingContext._timeouts["delete"](f))}}catch(g){b=!0,c=g}finally{try{!a&&e["return"]&&e["return"]()}finally{if(b)throw c}}Object.keys(this._scriptingContext._timeoutMap).forEach(function(a){delete this._scriptingContext._timeoutMap[a]},this)}},{key:"_performBigStepAsync",value:function(a,b){function c(a){this.emit(a);var i=this._selectTransitionsAndPerformSmallStep(d,h,g),j=k(i,2);d=j[0],f=j[1],f?(this.emit("onBigStepSuspend"),e(c.bind(this,"onBigStepResume"))):this._finishBigStep(d,h,g,b)}var d=void 0,f=void 0,g=void 0,h=void 0,i=this._startBigStep(a),j=k(i,4);g=j[0],h=j[1],f=j[2],d=j[3],c.call(this,"onBigStepBegin")}},{key:"_performSmallStep",value:function(a,b){this._log("selecting transitions with currentEvent",a),this._log("selected transitions",b);var c=void 0,d=void 0;if(!b.isEmpty()){var e=new this.opts.Set(b.iter().filter(u));c=this._exitStates(a,e),this._executeTransitions(a,b),d=this._enterStates(a,e),this._log("new configuration ",this._configuration)}return[c,d]}},{key:"_exitStates",value:function(a,b){var c=void 0,d=void 0,e=this._getStatesExited(b),f=k(e,2);c=f[0],d=f[1],this._log("exiting states");for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i.isAtomic&&this._configuration.remove(i),this._log("exiting ",i.id),this.emit("onExit",i.id),void 0!==i.onExit)for(var j=0,l=i.onExit.length;j<l;j++)for(var m=i.onExit[j],n=0,o=m.length;n<o;n++){var p=m[n];try{p.call(this._scriptingContext,a)}catch(q){this._handleError(q,p);break}}var r;if(i.historyRef){var s=!0,t=!1,u=void 0;try{for(var v,w=i.historyRef[Symbol.iterator]();!(s=(v=w.next()).done);s=!0){var x=v.value;r=x.isDeep?function(a){return a.typeEnum===E&&i.descendants.indexOf(a)>-1}:function(a){return a.parent===i},this._historyValue[x.id]=d.filter(r)}}catch(y){t=!0,u=y}finally{try{!s&&w["return"]&&w["return"]()}finally{if(t)throw u}}}}return d}},{key:"_getStatesExited",value:function(a){for(var b=new this.opts.Set,c=new this.opts.Set,d=a.iter(),e=0,f=d.length;e<f;e++)for(var g=d[e],h=g.scope,i=h.descendants,j=this._configuration.iter(),k=0,l=j.length;k<l;k++){var m=j[k];if(i.indexOf(m)>-1){c.add(m),b.add(m);for(var n=s.getAncestors(m,h),o=0,p=n.length;o<p;o++)b.add(n[o])}}var q=b.iter().sort(A);return[c,q]}},{key:"_executeTransitions",value:function(a,b){var c=b.iter().sort(v);this._log("executing transitition actions");for(var d=0,e=c.length;d<e;d++){var f=c[d],g=f.targets&&f.targets.map(function(a){return a.id});if(this.emit("onTransition",f.source.id,g,f.source.transitions.indexOf(f)),void 0!==f.onTransition)for(var h=0,i=f.onTransition.length;h<i;h++){var j=f.onTransition[h];try{j.call(this._scriptingContext,a)}catch(k){this._handleError(k,j);break}}}}},{key:"_enterStates",value:function(a,b){var c=this;this._log("entering states");var d=new Set,e=new Set,f={};this._computeEntrySet(b,d,e,f),d=Array.from(d).sort(z),this._log("statesEntered ",d);for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i.isAtomic&&this._configuration.add(i),this._log("entering",i.id),this.emit("onEntry",i.id),void 0!==i.onEntry)for(var j=0,k=i.onEntry.length;j<k;j++)for(var l=i.onEntry[j],m=0,n=l.length;m<n;m++){var o=l[m];try{o.call(this._scriptingContext,a)}catch(p){this._handleError(p,o);break}}if(e.has(i)){var q=!0,r=!1,s=void 0;try{for(var t,u=i.initialRef[Symbol.iterator]();!(q=(t=u.next()).done);q=!0){var v=t.value;if(this.emit("onDefaultEntry",v.id),v.typeEnum===I){var w=v.transitions[0];if(void 0!==w.onTransition){this._log("executing initial transition content for initial state of parent state",i.id);for(var x=0,y=w.onTransition.length;x<y;x++){var A=w.onTransition[x];try{A.call(this._scriptingContext,a)}catch(p){this._handleError(p,A);break}}}}}}catch(B){r=!0,s=B}finally{try{!q&&u["return"]&&u["return"]()}finally{if(r)throw s}}}if(f[i.id]){var C=f[i.id];if(void 0!==C.onTransition){this._log("executing history transition content for history state of parent state",i.id);for(var x=0,y=C.onTransition.length;x<y;x++){var D=C.onTransition[x];try{D.call(this._scriptingContext,a)}catch(p){this._handleError(p,D);break}}}}}for(var g=0,h=d.length;g<h;g++){var i=d[g];if(i.typeEnum===J){var E=i.parent,F=E.parent;this._internalEventQueue.push({name:"done.state."+E.id,data:i.donedata&&i.donedata.call(this._scriptingContext,a)}),F&&F.typeEnum===G&&F.states.every(function(a){return c.isInFinalState(a)})&&this._internalEventQueue.push({name:"done.state."+F.id})}}return d}},{key:"_getEffectiveTargetStates",value:function(a){var b=new Set,c=!0,d=!1,e=void 0;try{for(var g,h=a.targets[Symbol.iterator]();!(c=(g=h.next()).done);c=!0){var i=g.value;i.typeEnum===H?i.id in this._historyValue?this._historyValue[i.id].forEach(function(a){return b.add(a)}):[].concat(f(this._getEffectiveTargetStates(i.transitions[0]))).forEach(function(a){return b.add(a)}):b.add(i)}}catch(j){d=!0,e=j}finally{try{!c&&h["return"]&&h["return"]()}finally{if(d)throw e}}return b}},{key:"_computeEntrySet",value:function(a,b,c,d){var e=!0,f=!1,g=void 0;try{for(var h,i=a.iter()[Symbol.iterator]();!(e=(h=i.next()).done);e=!0){var j=h.value,k=!0,l=!1,m=void 0;try{for(var n,o=j.targets[Symbol.iterator]();!(k=(n=o.next()).done);k=!0){var p=n.value;this._addDescendantStatesToEnter(p,b,c,d)}}catch(q){l=!0,m=q}finally{try{!k&&o["return"]&&o["return"]()}finally{if(l)throw m}}var r=j.scope,s=!0,t=!1,u=void 0;try{for(var v,w=this._getEffectiveTargetStates(j)[Symbol.iterator]();!(s=(v=w.next()).done);s=!0){var x=v.value;this._addAncestorStatesToEnter(x,r,b,c,d)}}catch(q){t=!0,u=q}finally{try{!s&&w["return"]&&w["return"]()}finally{if(t)throw u}}}}catch(q){f=!0,g=q}finally{try{!e&&i["return"]&&i["return"]()}finally{if(f)throw g}}}},{key:"_computeExitSet",value:function(a){var b=new Set,c=!0,d=!1,e=void 0;try{for(var f,g=a[Symbol.iterator]();!(c=(f=g.next()).done);c=!0){var h=f.value;if(h.targets){var i=h.scope,j=!0,k=!1,l=void 0;try{for(var m,n=this._getFullConfiguration()[Symbol.iterator]();!(j=(m=n.next()).done);j=!0){var o=m.value;s.isDescendant(o,i)&&b.add(o)}}catch(p){k=!0,l=p}finally{try{!j&&n["return"]&&n["return"]()}finally{if(k)throw l}}}}}catch(p){d=!0,e=p}finally{try{!c&&g["return"]&&g["return"]()}finally{if(d)throw e}}return b}},{key:"_addAncestorStatesToEnter",value:function(a,b,c,d,e){var g=this,h=function(a){if(a.typeEnum===G){var b=!0,h=!1,i=void 0;try{for(var j,k=function(){var a=j.value;a.typeEnum===H||[].concat(f(c)).some(function(b){return s.isDescendant(b,a)})||g._addDescendantStatesToEnter(a,c,d,e)},l=a.states[Symbol.iterator]();!(b=(j=l.next()).done);b=!0)k()}catch(m){h=!0,i=m}finally{try{!b&&l["return"]&&l["return"]()}finally{if(h)throw i}}}},i=!0,j=!1,k=void 0;try{for(var l,m=s.getAncestors(a,b)[Symbol.iterator]();!(i=(l=m.next()).done);i=!0){var n=l.value;c.add(n),h(n)}}catch(o){j=!0,k=o}finally{try{!i&&m["return"]&&m["return"]()}finally{if(j)throw k}}h(b)}},{key:"_addDescendantStatesToEnter",value:function(a,b,c,d){var e=this;if(a.typeEnum===H)if(this._historyValue[a.id]){var g=!0,h=!1,i=void 0;try{for(var j,k=this._historyValue[a.id][Symbol.iterator]();!(g=(j=k.next()).done);g=!0){var l=j.value;this._addDescendantStatesToEnter(l,b,c,d)}}catch(m){h=!0,i=m}finally{try{!g&&k["return"]&&k["return"]()}finally{if(h)throw i}}var n=!0,o=!1,p=void 0;try{for(var q,r=this._historyValue[a.id][Symbol.iterator]();!(n=(q=r.next()).done);n=!0){var t=q.value;this._addAncestorStatesToEnter(t,a.parent,b,c,d)}}catch(m){o=!0,p=m}finally{try{!n&&r["return"]&&r["return"]()}finally{if(o)throw p}}}else{d[a.parent.id]=a.transitions[0];var u=!0,v=!1,w=void 0;try{for(var x,y=a.transitions[0].targets[Symbol.iterator]();!(u=(x=y.next()).done);u=!0){var z=x.value;this._addDescendantStatesToEnter(z,b,c,d)}}catch(m){v=!0,w=m}finally{try{!u&&y["return"]&&y["return"]()}finally{if(v)throw w}}var A=!0,B=!1,C=void 0;try{for(var D,E=a.transitions[0].targets[Symbol.iterator]();!(A=(D=E.next()).done);A=!0){var J=D.value;this._addAncestorStatesToEnter(J,a.parent,b,c,d)}}catch(m){B=!0,C=m}finally{try{!A&&E["return"]&&E["return"]()}finally{if(B)throw C}}}else if(b.add(a),a.typeEnum===F){c.add(a);var K=!0,L=!1,M=void 0;try{for(var N,O=a.initialRef[Symbol.iterator]();!(K=(N=O.next()).done);K=!0){var P=N.value,Q=P.typeEnum===I?P.transitions[0].targets:[P],R=!0,S=!1,T=void 0;try{for(var U,V=Q[Symbol.iterator]();!(R=(U=V.next()).done);R=!0){var W=U.value;this._addDescendantStatesToEnter(W,b,c,d)}}catch(m){S=!0,T=m}finally{try{!R&&V["return"]&&V["return"]()}finally{if(S)throw T}}}}catch(m){L=!0,M=m}finally{try{!K&&O["return"]&&O["return"]()}finally{if(L)throw M}}var X=!0,Y=!1,Z=void 0;try{for(var $,_=a.initialRef[Symbol.iterator]();!(X=($=_.next()).done);X=!0){var aa=$.value,ba=aa.typeEnum===I?aa.transitions[0].targets:[aa],ca=!0,da=!1,ea=void 0;try{for(var fa,ga=ba[Symbol.iterator]();!(ca=(fa=ga.next()).done);ca=!0){var ha=fa.value;this._addAncestorStatesToEnter(ha,a,b,c,d)}}catch(m){da=!0,ea=m}finally{try{!ca&&ga["return"]&&ga["return"]()}finally{if(da)throw ea}}}}catch(m){Y=!0,Z=m}finally{try{!X&&_["return"]&&_["return"]()}finally{if(Y)throw Z}}}else if(a.typeEnum===G){var ia=!0,ja=!1,ka=void 0;try{for(var la,ma=function(){var a=la.value;a.typeEnum===H||[].concat(f(b)).some(function(b){return s.isDescendant(b,a)})||e._addDescendantStatesToEnter(a,b,c,d)},na=a.states[Symbol.iterator]();!(ia=(la=na.next()).done);ia=!0)ma()}catch(m){ja=!0,ka=m}finally{try{!ia&&na["return"]&&na["return"]()}finally{if(ja)throw ka}}}}},{key:"isInFinalState",value:function(a){var b=this;return a.typeEnum===F?a.states.some(function(a){return a.typeEnum===J&&b._configuration.contains(a)}):a.typeEnum===G&&a.states.every(this.isInFinalState.bind(this))}},{key:"_evaluateAction",value:function(a,b){try{return b.call(this._scriptingContext,a)}catch(c){this._handleError(c,b)}}},{key:"_handleError",value:function(a,b){var c=a instanceof Error||"string"==typeof a.__proto__.name&&a.__proto__.name.match(/^.*Error$/)?{ name:"error.execution",data:{tagname:b.tagname,line:b.line,column:b.column,reason:a.message},type:"platform"}:a.name?a:{name:"error.execution",data:a,type:"platform"};this._internalEventQueue.push(c),this.emit("onError",c)}},{key:"_log",value:function(){if(L){var a=Array.from(arguments);this.opts.console.log(a[0]+": "+a.slice(1).map(function(a){return null===a?"null":void 0===a?"undefined":"string"==typeof a?a:"[object Object]"===a.toString()?o.inspect(a):a.toString()}).join(", ")+"\n")}}},{key:"registerListener",value:function(a){c.EVENTS.forEach(function(b){a[b]&&this.on(b,a[b])},this)}},{key:"unregisterListener",value:function(a){c.EVENTS.forEach(function(b){a[b]&&this.off(b,a[b])},this)}},{key:"getAllTransitionEvents",value:function(){function a(c){if(c.transitions)for(var d=0,e=c.transitions.length;d<e;d++)b[c.transitions[d].event]=!0;if(c.states)for(var f=0,g=c.states.length;f<g;f++)a(c.states[f])}var b={};return a(this._model),Object.keys(b)}},{key:"getSnapshot",value:function(){return[this.getConfiguration(),this._serializeHistory(),this._isInFinalState,this._model.$serializeDatamodel(),this._internalEventQueue.slice()]}},{key:"_serializeHistory",value:function(){var a={};return Object.keys(this._historyValue).forEach(function(b){a[b]=this._historyValue[b].map(function(a){return a.id})},this),a}},{key:"gen",value:function(a,b){var c;switch("undefined"==typeof a?"undefined":l(a)){case"string":c={name:a,data:b};break;case"object":if("string"!=typeof a.name)throw new Error('Event object must have "name" property of type string.');c=a;break;default:throw new Error("First argument to gen must be a string or object.")}if(this._isStepping)throw new Error("Cannot call gen during a big-step");return this._isStepping=!0,this._performBigStep(c),this._isStepping=!1,this.getConfiguration()}},{key:"genAsync",value:function(a,b){function c(a,b){this._performBigStepAsync(a,function(a,d){b(a,d),this._externalEventQueue.length?c.apply(this,this._externalEventQueue.shift()):this._isStepping=!1}.bind(this))}if(null!==a&&("object"!==("undefined"==typeof a?"undefined":l(a))||!a||"string"!=typeof a.name))throw new Error("Expected currentEvent to be null or an Object with a name");"function"!=typeof b&&(b=j),this._externalEventQueue.push([a,b]),this._isStepping||(this._isStepping=!0,c.apply(this,this._externalEventQueue.shift()))}}]),c}(n);M.EVENTS=["onEntry","onExit","onTransition","onDefaultEntry","onError","onBigStepBegin","onBigStepSuspend","onBigStepResume","onSmallStepBegin","onSmallStepEnd","onBigStepEnd","onExitInterpreter"],M.sessionIdCounter=1,M.generateSessionid=function(){return M.sessionIdCounter++},M.sessionRegistry=new Map;var N=function(){function a(b){g(this,a),this._interpreter=b,this._timeoutMap={},this._invokeMap={},this._timeouts=new Set,this.validateUriRegex=/(#_.*)|\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i,this.invokeSendTargetRegex=/^#_(.*)$/,this.scxmlSendTargetRegex=/^#_scxml_(.*)$/}return m(a,[{key:"raise",value:function(a){this._installDefaultPropsOnEvent(a,!0),this._interpreter._internalEventQueue.push(a)}},{key:"parseXmlStringAsDOM",value:function(b){return(this._interpreter.opts.xmlParser||a.xmlParser).parse(b)}},{key:"invoke",value:function(b){var c=this;this._invokeMap[b.id]=new Promise(function(d,e){(c._interpreter.opts.invokers||a.invokers)[b.type](c._interpreter,b,c._interpreter.opts.invokerExecutionContext,function(a,b){return a?e(a):(c._interpreter.emit("onInvokedSessionInitialized",b),void d(b))})})}},{key:"cancelInvoke",value:function(a){var b=this,c=this._invokeMap[a];this._interpreter._log("cancelling session with invokeid "+a),c&&(this._interpreter._log("sessionPromise found"),c.then(function(c){b._interpreter._log("resolved session "+a+". cancelling... "),c.cancel(),delete b._invokeMap[a]},function(a){}))}},{key:"_installDefaultPropsOnEvent",value:function(a,b){b||(a.origin=this._interpreter.opts._x._ioprocessors.scxml.location,a.origintype=a.type||K),"undefined"==typeof a.type&&(a.type=b?"internal":"external"),["name","sendid","invokeid","data","origin","origintype"].forEach(function(b){"undefined"==typeof a[b]&&(a[b]=void 0)})}},{key:"send",value:function(a,b){function c(a,b,c){if(a.target){var d=this.validateUriRegex.test(a.target);if(!d)throw{name:"error.execution",data:"Target is not valid URI",sendid:a.sendid,type:"platform"}}if(g!==K)throw{name:"error.execution",data:"Unsupported event processor type",sendid:a.sendid,type:"platform"};c.call(this,a,b)}function d(a,b){function c(c){var d=setTimeout(function(){a.sendid&&delete this._timeoutMap[a.sendid],this._timeouts["delete"](e),this._interpreter.opts.doSend?this._interpreter.opts.doSend(c,a):c[this._interpreter.opts.sendAsync?"genAsync":"gen"](a)}.bind(this),b.delay||0),e={sendOptions:b,timeoutHandle:d};a.sendid&&(this._timeoutMap[a.sendid]=d),this._timeouts.add(e)}var d=this;if("undefined"==typeof setTimeout)throw new Error("Default implementation of BaseInterpreter.prototype.send will not work unless setTimeout is defined globally.");var e;if("#_internal"===a.target)this.raise(a);else if(this._installDefaultPropsOnEvent(a,!1),a.origintype=K,a.target)if("#_parent"===a.target){if(!this._interpreter.opts.parentSession)throw{name:"error.communication",data:"Parent session not specified",sendid:a.sendid,type:"platform"};a.invokeid=this._interpreter.opts.invokeid,c.call(this,this._interpreter.opts.parentSession)}else if(e=a.target.match(this.scxmlSendTargetRegex)){var f=e[1],g=this._interpreter.opts.sessionRegistry.get(f);if(!g)throw{name:"error.communication",sendid:a.sendid,type:"platform"};c.call(this,g)}else{if(!(e=a.target.match(this.invokeSendTargetRegex)))throw new Error("Unrecognized send target.");var h=e[1];this._invokeMap[h].then(function(a){c.call(d,a)})}else c.call(this,this._interpreter)}function e(){this._interpreter.emit(a.name,a.data)}this._interpreter._log("send event",a,b),b=b||{};var f,g=b.type||K;f="https://github.com/jbeard4/SCION#publish"===a.type?e:this._interpreter.opts.customSend?this._interpreter.opts.customSend:d,b=b||{},this._interpreter._log("sending event",a.name,"with content",a.data,"after delay",b.delay),c.call(this,a,b,f)}},{key:"cancel",value:function(a){if(this._interpreter.opts.customCancel)return this._interpreter.opts.customCancel.apply(this,[a]);if("undefined"==typeof clearTimeout)throw new Error("Default implementation of BaseInterpreter.prototype.cancel will not work unless setTimeout is defined globally.");a in this._timeoutMap&&(this._interpreter._log("cancelling ",a," with timeout id ",this._timeoutMap[a]),clearTimeout(this._timeoutMap[a]))}}]),a}();b.exports=t(new n,{BaseInterpreter:M,ArraySet:p,STATE_TYPES:q.STATE_TYPES,initializeModel:w,InterpreterScriptingContext:N,helpers:r,query:s})}).call(this,a("_process"),a("timers").setImmediate)},{"./ArraySet":2,"./constants":3,"./helpers":4,"./query":5,_process:8,timers:9,"tiny-events":10,util:12}],7:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})}:b.exports=function(a,b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],8:[function(a,b,c){function d(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function f(a){if(l===setTimeout)return setTimeout(a,0);if((l===d||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function g(a){if(m===clearTimeout)return clearTimeout(a);if((m===e||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function h(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&i())}function i(){if(!q){var a=f(h);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,g(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:d}catch(a){l=d}try{m="function"==typeof clearTimeout?clearTimeout:e}catch(a){m=e}}();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||f(i)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.prependListener=k,n.prependOnceListener=k,n.listeners=function(a){return[]},n.binding=function(a){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(a){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],9:[function(a,b,c){(function(b,d){function e(a,b){this._id=a,this._clearFn=b}var f=a("process/browser.js").nextTick,g=Function.prototype.apply,h=Array.prototype.slice,i={},j=0;c.setTimeout=function(){return new e(g.call(setTimeout,window,arguments),clearTimeout)},c.setInterval=function(){return new e(g.call(setInterval,window,arguments),clearInterval)},c.clearTimeout=c.clearInterval=function(a){a.close()},e.prototype.unref=e.prototype.ref=function(){},e.prototype.close=function(){this._clearFn.call(window,this._id)},c.enroll=function(a,b){clearTimeout(a._idleTimeoutId),a._idleTimeout=b},c.unenroll=function(a){clearTimeout(a._idleTimeoutId),a._idleTimeout=-1},c._unrefActive=c.active=function(a){clearTimeout(a._idleTimeoutId);var b=a._idleTimeout;b>=0&&(a._idleTimeoutId=setTimeout(function(){a._onTimeout&&a._onTimeout()},b))},c.setImmediate="function"==typeof b?b:function(a){var b=j++,d=!(arguments.length<2)&&h.call(arguments,1);return i[b]=!0,f(function(){i[b]&&(d?a.apply(null,d):a.call(null),c.clearImmediate(b))}),b},c.clearImmediate="function"==typeof d?d:function(a){delete i[a]}}).call(this,a("timers").setImmediate,a("timers").clearImmediate)},{"process/browser.js":8,timers:9}],10:[function(a,b,c){function d(){this._listeners={}}d.prototype.on=function(a,b){return Array.isArray(this._listeners[a])||(this._listeners[a]=[]),this._listeners[a].indexOf(b)===-1&&this._listeners[a].push(b),this},d.prototype.once=function(a,b){function c(){for(var e=[],f=0;f<arguments.length;f+=1)e[f]=arguments[f];d.off(a,c),b.apply(d,e)}var d=this;return c.listener=b,this.on(a,c)},d.prototype.off=function(a,b){if(!Array.isArray(this._listeners[a]))return this;if("undefined"==typeof b)return this._listeners[a]=[],this;var c=this._listeners[a].indexOf(b);if(c===-1)for(var d=0;d<this._listeners[a].length;d+=1)if(this._listeners[a][d].listener===b){c=d;break}return this._listeners[a].splice(c,1),this},d.prototype.emit=function(a){if(!Array.isArray(this._listeners[a]))return this;for(var b=[],c=1;c<arguments.length;c+=1)b[c-1]=arguments[c];return this._listeners[a].forEach(function(a){a.apply(this,b)},this),this},b.exports.EventEmitter=d},{}],11:[function(a,b,d){b.exports=function(a){return a&&"object"===("undefined"==typeof a?"undefined":c(a))&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],12:[function(a,b,d){(function(b,e){function f(a,b){var c={seen:[],stylize:h};return arguments.length>=3&&(c.depth=arguments[2]),arguments.length>=4&&(c.colors=arguments[3]),q(b)?c.showHidden=b:b&&d._extend(c,b),w(c.showHidden)&&(c.showHidden=!1),w(c.depth)&&(c.depth=2),w(c.colors)&&(c.colors=!1),w(c.customInspect)&&(c.customInspect=!0),c.colors&&(c.stylize=g),j(c,a,c.depth)}function g(a,b){var c=f.styles[b];return c?"["+f.colors[c][0]+"m"+a+"["+f.colors[c][1]+"m":a}function h(a,b){return a}function i(a){var b={};return a.forEach(function(a,c){b[a]=!0}),b}function j(a,b,c){if(a.customInspect&&b&&B(b.inspect)&&b.inspect!==d.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(c,a);return u(e)||(e=j(a,e,c)),e}var f=k(a,b);if(f)return f;var g=Object.keys(b),h=i(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),A(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return l(b);if(0===g.length){if(B(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(x(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(z(b))return a.stylize(Date.prototype.toString.call(b),"date");if(A(b))return l(b)}var r="",s=!1,t=["{","}"];if(p(b)&&(s=!0,t=["[","]"]),B(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(x(b)&&(r=" "+RegExp.prototype.toString.call(b)),z(b)&&(r=" "+Date.prototype.toUTCString.call(b)),A(b)&&(r=" "+l(b)),0===g.length&&(!s||0==b.length))return t[0]+r+t[1];if(c<0)return x(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var w;return w=s?m(a,b,c,h,g):g.map(function(d){return n(a,b,c,h,d,s)}),a.seen.pop(),o(w,r,t)}function k(a,b){if(w(b))return a.stylize("undefined","undefined");if(u(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return t(b)?a.stylize(""+b,"number"):q(b)?a.stylize(""+b,"boolean"):r(b)?a.stylize("null","null"):void 0}function l(a){return"["+Error.prototype.toString.call(a)+"]"}function m(a,b,c,d,e){for(var f=[],g=0,h=b.length;g<h;++g)G(b,String(g))?f.push(n(a,b,c,d,String(g),!0)):f.push("");return e.forEach(function(e){e.match(/^\d+$/)||f.push(n(a,b,c,d,e,!0))}),f}function n(a,b,c,d,e,f){var g,h,i;if(i=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},i.get?h=i.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):i.set&&(h=a.stylize("[Setter]","special")),G(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(i.value)<0?(h=r(c)?j(a,i.value,null):j(a,i.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),w(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function o(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function p(a){return Array.isArray(a)}function q(a){return"boolean"==typeof a}function r(a){return null===a}function s(a){return null==a}function t(a){return"number"==typeof a}function u(a){return"string"==typeof a}function v(a){return"symbol"===("undefined"==typeof a?"undefined":c(a))}function w(a){return void 0===a}function x(a){return y(a)&&"[object RegExp]"===D(a)}function y(a){return"object"===("undefined"==typeof a?"undefined":c(a))&&null!==a}function z(a){return y(a)&&"[object Date]"===D(a)}function A(a){return y(a)&&("[object Error]"===D(a)||a instanceof Error)}function B(a){return"function"==typeof a}function C(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"===("undefined"==typeof a?"undefined":c(a))||"undefined"==typeof a}function D(a){return Object.prototype.toString.call(a)}function E(a){return a<10?"0"+a.toString(10):a.toString(10)}function F(){var a=new Date,b=[E(a.getHours()),E(a.getMinutes()),E(a.getSeconds())].join(":");return[a.getDate(),K[a.getMonth()],b].join(" ")}function G(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var H=/%[sdj%]/g;d.format=function(a){if(!u(a)){for(var b=[],c=0;c<arguments.length;c++)b.push(f(arguments[c]));return b.join(" ")}for(var c=1,d=arguments,e=d.length,g=String(a).replace(H,function(a){if("%%"===a)return"%";if(c>=e)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];c<e;h=d[++c])g+=r(h)||!y(h)?" "+h:" "+f(h);return g},d.deprecate=function(a,c){function f(){if(!g){if(b.throwDeprecation)throw new Error(c);b.traceDeprecation?console.trace(c):console.error(c),g=!0}return a.apply(this,arguments)}if(w(e.process))return function(){return d.deprecate(a,c).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var I,J={};d.debuglog=function(a){if(w(I)&&(I=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!J[a])if(new RegExp("\\b"+a+"\\b","i").test(I)){var c=b.pid;J[a]=function(){var b=d.format.apply(d,arguments);console.error("%s %d: %s",a,c,b)}}else J[a]=function(){};return J[a]},d.inspect=f,f.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},f.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},d.isArray=p,d.isBoolean=q,d.isNull=r,d.isNullOrUndefined=s,d.isNumber=t,d.isString=u,d.isSymbol=v,d.isUndefined=w,d.isRegExp=x,d.isObject=y,d.isDate=z,d.isError=A,d.isFunction=B,d.isPrimitive=C,d.isBuffer=a("./support/isBuffer");var K=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];d.log=function(){console.log("%s - %s",F(),d.format.apply(d,arguments))},d.inherits=a("inherits"),d._extend=function(a,b){if(!b||!y(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":11,_process:8,inherits:7}]},{},[1])(1)})});