!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XStateInterpreter={})}(this,(function(t){"use strict";
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */var e,n,i=function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}function s(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t}!function(t){t.Start="xstate.start",t.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.NullEvent="",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Update="xstate.update",t.Pure="xstate.pure",t.Choose="xstate.choose"}(e||(e={})),function(t){t.Parent="#_parent",t.Internal="#_internal"}(n||(n={}));var a={};function u(t){return Object.keys(t)}function c(t,e){return"object"==typeof(n=t)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?t.value:d(t)?h(t):"string"!=typeof t?t:h(function(t,e){try{return d(t)?t:t.toString().split(e)}catch(e){throw new Error("'"+t+"' is not a valid state path.")}}(t,e));var n}function h(t){if(1===t.length)return t[0];for(var e={},n=e,i=0;i<t.length-1;i++)i===t.length-2?n[t[i]]=t[i+1]:(n[t[i]]={},n=n[t[i]]);return e}function f(t,e,n){var i,o;if(p(t))return t(e,n.data);var s={};try{for(var a=r(Object.keys(t)),u=a.next();!u.done;u=a.next()){var c=u.value,h=t[c];p(h)?s[c]=h(e,n.data):s[c]=h}}catch(t){i={error:t}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}return s}function l(t){return t instanceof Promise||!(null===t||!p(t)&&"object"!=typeof t||!p(t.then))}function d(t){return Array.isArray(t)}function p(t){return"function"==typeof t}function v(t){return"string"==typeof t}function y(t){try{return"subscribe"in t&&p(t.subscribe)}catch(t){return!1}}var m="function"==typeof Symbol&&Symbol.observable||"@@observable";function x(t){try{return"__xstatenode"in t}catch(t){return!1}}var b,w=(b=0,function(){return(++b).toString(16)});function g(t,e){return v(t)||"number"==typeof t?i({type:t},e):t}function S(t,e){if(!v(t)&&"$$type"in t&&"scxml"===t.$$type)return t;var n=g(t);return i({name:n.type,data:n,$$type:"scxml",type:"external"},e)}function E(t){return u(t.states).map((function(e){return t.states[e]}))}function _(t){return e=s(new Set(t.map((function(t){return t.ownEvents})))),(n=[]).concat.apply(n,s(e));var e,n}function O(t,e){return"compound"===e.type?E(e).some((function(e){return"final"===e.type&&(n=t,i=e,Array.isArray(n)?n.some((function(t){return t===i})):n instanceof Set&&n.has(i));var n,i})):"parallel"===e.type&&E(e).every((function(e){return O(t,e)}))}var T=e.Start,I=e.Stop,L=(e.Raise,e.Send),k=e.Cancel,P=(e.NullEvent,e.Assign,e.After,e.DoneState,e.Log),C=e.Init,j=(e.Invoke,e.ErrorExecution,e.ErrorPlatform),N=e.ErrorCustom,D=e.Update,M=(e.Choose,e.Pure,S({type:C}));function z(t,n){var i=e.DoneInvoke+"."+t,r={type:i,data:n,toString:function(){return i}};return r}function A(t,n){var i=e.ErrorPlatform+"."+t,r={type:i,data:n,toString:function(){return i}};return r}var R=function(){function t(t){var e=this;this.actions=[],this.activities=a,this.meta={},this.events=[],this.value=t.value,this.context=t.context,this._event=t._event,this._sessionid=t._sessionid,this.event=this._event.data,this.historyValue=t.historyValue,this.history=t.history,this.actions=t.actions||[],this.activities=t.activities||a,this.meta=t.meta||{},this.events=t.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=t.configuration,this.transitions=t.transitions,this.children=t.children,this.done=!!t.done,Object.defineProperty(this,"nextEvents",{get:function(){return _(e.configuration)}})}return t.from=function(e,n){return e instanceof t?e.context!==n?new t({value:e.value,context:n,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e:new t({value:e,context:n,_event:M,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},t.create=function(e){return new t(e)},t.inert=function(e,n){if(e instanceof t){if(!e.actions.length)return e;var i=M;return new t({value:e.value,context:n,_event:i,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return t.from(e,n)},t.prototype.toStrings=function(t,e){var n=this;if(void 0===t&&(t=this.value),void 0===e&&(e="."),v(t))return[t];var i=u(t);return i.concat.apply(i,s(i.map((function(i){return n.toStrings(t[i],e).map((function(t){return i+e+t}))}))))},t.prototype.toJSON=function(){this.configuration,this.transitions;return function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(this,["configuration","transitions"])},t.prototype.matches=function(t){return function t(e,n,i){void 0===i&&(i=".");var r=c(e,i),o=c(n,i);return v(o)?!!v(r)&&o===r:v(r)?r in o:u(r).every((function(e){return e in o&&t(r[e],o[e])}))}(t,this.value)},t}(),V={deferEvents:!1},J=function(){function t(t){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=i(i({},V),t)}return t.prototype.initialize=function(t){if(this.initialized=!0,t){if(!this.options.deferEvents)return void this.schedule(t);this.process(t)}this.flushEvents()},t.prototype.schedule=function(t){if(this.initialized&&!this.processingEvent){if(0!==this.queue.length)throw new Error("Event queue should be empty when it is not processing events");this.process(t),this.flushEvents()}else this.queue.push(t)},t.prototype.clear=function(){this.queue=[]},t.prototype.flushEvents=function(){for(var t=this.queue.shift();t;)this.process(t),t=this.queue.shift()},t.prototype.process=function(t){this.processingEvent=!0;try{t()}catch(t){throw this.clear(),t}finally{this.processingEvent=!1}},t}(),q=[],U=function(t,e){q.push(t);var n=e(t);return q.pop(),n};var $=new Map,F=0,X=function(){return"x:"+F++},B=function(t,e){return $.set(t,e),t},G=function(t){return $.get(t)},H=function(t){$.delete(t)};function K(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0}function Q(t){if(K()){var e=function(){var t=K();if(t&&"__xstate__"in t)return t.__xstate__}();e&&e.register(t)}}var W,Y={sync:!1,autoForward:!1};(W=t.InterpreterStatus||(t.InterpreterStatus={}))[W.NotStarted=0]="NotStarted",W[W.Running=1]="Running",W[W.Stopped=2]="Stopped";var Z=function(){function o(e,r){var s=this;void 0===r&&(r=o.defaultOptions),this.machine=e,this.scheduler=new J,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=t.InterpreterStatus.NotStarted,this.children=new Map,this.forwardTo=new Set,this.init=this.start,this.send=function(e,n){if(d(e))return s.batch(e),s.state;var i=S(g(e,n));if(s.status===t.InterpreterStatus.Stopped)return s.state;if(s.status!==t.InterpreterStatus.Running&&!s.options.deferEvents)throw new Error('Event "'+i.name+'" was sent to uninitialized service "'+s.machine.id+'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: '+JSON.stringify(i.data));return s.scheduler.schedule((function(){s.forward(i);var t=s.nextState(i);s.update(t,i)})),s._state},this.sendTo=function(t,e){var r,o=s.parent&&(e===n.Parent||s.parent.id===e),a=o?s.parent:v(e)?s.children.get(e)||G(e):(r=e)&&"function"==typeof r.send?e:void 0;if(a)"machine"in a?a.send(i(i({},t),{name:t.name===N?""+A(s.id):t.name,origin:s.sessionId})):a.send(t.data);else if(!o)throw new Error("Unable to send event to child '"+e+"' from service '"+s.id+"'.")};var a=i(i({},o.defaultOptions),r),u=a.clock,c=a.logger,h=a.parent,f=a.id,l=void 0!==f?f:e.id;this.id=l,this.logger=c,this.clock=u,this.parent=h,this.options=a,this.scheduler=new J({deferEvents:this.options.deferEvents}),this.sessionId=X()}return Object.defineProperty(o.prototype,"initialState",{get:function(){var t=this;return this._initialState?this._initialState:U(this,(function(){return t._initialState=t.machine.initialState,t._initialState}))},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),o.prototype.execute=function(t,e){var n,i;try{for(var o=r(t.actions),s=o.next();!s.done;s=o.next()){var a=s.value;this.exec(a,t,e)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},o.prototype.update=function(t,e){var n,i,o,s,a,u,c,h,l=this;if(t._sessionid=this.sessionId,this._state=t,this.options.execute&&this.execute(this.state),this.children.forEach((function(t){l.state.children[t.id]=t})),this.devTools&&this.devTools.send(e.data,t),t.event)try{for(var d=r(this.eventListeners),p=d.next();!p.done;p=d.next()){(0,p.value)(t.event)}}catch(t){n={error:t}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}try{for(var v=r(this.listeners),y=v.next();!y.done;y=v.next()){(0,y.value)(t,t.event)}}catch(t){o={error:t}}finally{try{y&&!y.done&&(s=v.return)&&s.call(v)}finally{if(o)throw o.error}}try{for(var m=r(this.contextListeners),x=m.next();!x.done;x=m.next()){(0,x.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(t){a={error:t}}finally{try{x&&!x.done&&(u=m.return)&&u.call(m)}finally{if(a)throw a.error}}var b=O(t.configuration||[],this.machine);if(this.state.configuration&&b){var w=t.configuration.find((function(t){return"final"===t.type&&t.parent===l.machine})),g=w&&w.doneData?f(w.doneData,t.context,e):void 0;try{for(var S=r(this.doneListeners),E=S.next();!E.done;E=S.next()){(0,E.value)(z(this.id,g))}}catch(t){c={error:t}}finally{try{E&&!E.done&&(h=S.return)&&h.call(S)}finally{if(c)throw c.error}}this.stop()}},o.prototype.onTransition=function(e){return this.listeners.add(e),this.status===t.InterpreterStatus.Running&&e(this.state,this.state.event),this},o.prototype.subscribe=function(e,n,i){var r,o=this;if(!e)return{unsubscribe:function(){}};var s=i;return"function"==typeof e?r=e:(r=e.next.bind(e),s=e.complete.bind(e)),this.listeners.add(r),this.status===t.InterpreterStatus.Running&&r(this.state),s&&this.onDone(s),{unsubscribe:function(){r&&o.listeners.delete(r),s&&o.doneListeners.delete(s)}}},o.prototype.onEvent=function(t){return this.eventListeners.add(t),this},o.prototype.onSend=function(t){return this.sendListeners.add(t),this},o.prototype.onChange=function(t){return this.contextListeners.add(t),this},o.prototype.onStop=function(t){return this.stopListeners.add(t),this},o.prototype.onDone=function(t){return this.doneListeners.add(t),this},o.prototype.off=function(t){return this.listeners.delete(t),this.eventListeners.delete(t),this.sendListeners.delete(t),this.stopListeners.delete(t),this.doneListeners.delete(t),this.contextListeners.delete(t),this},o.prototype.start=function(e){var n=this;if(this.status===t.InterpreterStatus.Running)return this;B(this.sessionId,this),this.initialized=!0,this.status=t.InterpreterStatus.Running;var i=void 0===e?this.initialState:U(this,(function(){return!v(t=e)&&"value"in t&&"history"in t?n.machine.resolveState(e):n.machine.resolveState(R.from(e,n.machine.context));var t}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){n.update(i,M)})),this},o.prototype.stop=function(){var e,n,i,o,s,a,c,h,f,l,d=this;try{for(var v=r(this.listeners),y=v.next();!y.done;y=v.next()){var m=y.value;this.listeners.delete(m)}}catch(t){e={error:t}}finally{try{y&&!y.done&&(n=v.return)&&n.call(v)}finally{if(e)throw e.error}}try{for(var x=r(this.stopListeners),b=x.next();!b.done;b=x.next()){(m=b.value)(),this.stopListeners.delete(m)}}catch(t){i={error:t}}finally{try{b&&!b.done&&(o=x.return)&&o.call(x)}finally{if(i)throw i.error}}try{for(var w=r(this.contextListeners),g=w.next();!g.done;g=w.next()){m=g.value;this.contextListeners.delete(m)}}catch(t){s={error:t}}finally{try{g&&!g.done&&(a=w.return)&&a.call(w)}finally{if(s)throw s.error}}try{for(var S=r(this.doneListeners),E=S.next();!E.done;E=S.next()){m=E.value;this.doneListeners.delete(m)}}catch(t){c={error:t}}finally{try{E&&!E.done&&(h=S.return)&&h.call(S)}finally{if(c)throw c.error}}if(!this.initialized)return this;this.state.configuration.forEach((function(t){var e,n;try{for(var i=r(t.definition.exit),o=i.next();!o.done;o=i.next()){var s=o.value;d.exec(s,d.state)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}})),this.children.forEach((function(t){p(t.stop)&&t.stop()}));try{for(var _=r(u(this.delayedEventsMap)),O=_.next();!O.done;O=_.next()){var T=O.value;this.clock.clearTimeout(this.delayedEventsMap[T])}}catch(t){f={error:t}}finally{try{O&&!O.done&&(l=_.return)&&l.call(_)}finally{if(f)throw f.error}}return this.scheduler.clear(),this.initialized=!1,this.status=t.InterpreterStatus.Stopped,H(this.sessionId),this},o.prototype.batch=function(e){var n=this;if(this.status===t.InterpreterStatus.NotStarted&&this.options.deferEvents);else if(this.status!==t.InterpreterStatus.Running)throw new Error(e.length+' event(s) were sent to uninitialized service "'+this.machine.id+'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.');this.scheduler.schedule((function(){var t,o,a=n.state,u=!1,c=[],h=function(t){var e=S(t);n.forward(e),a=U(n,(function(){return n.machine.transition(a,e)})),c.push.apply(c,s(a.actions.map((function(t){return n=a,r=(e=t).exec,i(i({},e),{exec:void 0!==r?function(){return r(n.context,n.event,{action:e,state:n,_event:n._event})}:void 0});var e,n,r})))),u=u||!!a.changed};try{for(var f=r(e),l=f.next();!l.done;l=f.next()){h(l.value)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(t)throw t.error}}a.changed=u,a.actions=c,n.update(a,S(e[e.length-1]))}))},o.prototype.sender=function(t){return this.send.bind(this,t)},o.prototype.nextState=function(t){var e=this,n=S(t);if(0===n.name.indexOf(j)&&!this.state.nextEvents.some((function(t){return 0===t.indexOf(j)})))throw n.data.data;return U(this,(function(){return e.machine.transition(e.state,n)}))},o.prototype.forward=function(t){var e,n;try{for(var i=r(this.forwardTo),o=i.next();!o.done;o=i.next()){var s=o.value,a=this.children.get(s);if(!a)throw new Error("Unable to forward event '"+t+"' from interpreter '"+this.id+"' to nonexistant child '"+s+"'.");a.send(t)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},o.prototype.defer=function(t){var e=this;this.delayedEventsMap[t.id]=this.clock.setTimeout((function(){t.to?e.sendTo(t._event,t.to):e.send(t._event)}),t.delay)},o.prototype.cancel=function(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]},o.prototype.exec=function(t,n,i){void 0===i&&(i=this.machine.options.actions);var r,o=n.context,s=n._event,a=t.exec||function(t,e){return e&&e[t]||void 0}(t.type,i),u=p(a)?a:a?a.exec:t.exec;if(u)try{return u(o,s.data,{action:t,state:this.state,_event:s})}catch(t){throw this.parent&&this.parent.send({type:"xstate.error",data:t}),t}switch(t.type){case L:var c=t;if("number"==typeof c.delay)return void this.defer(c);c.to?this.sendTo(c._event,c.to):this.send(c._event);break;case k:this.cancel(t.sendId);break;case T:var h=t.activity;if(!this.state.activities[h.id||h.type])break;if(h.type===e.Invoke){var d="string"==typeof(r=h.src)?{type:r}:r,v=this.machine.options.services?this.machine.options.services[d.type]:void 0,m=h.id,b=h.data,w="autoForward"in h?h.autoForward:!!h.forward;if(!v)return;var g=b?f(b,o,s):void 0,S=p(v)?v(o,s.data,{data:g,src:d}):v;l(S)?this.spawnPromise(Promise.resolve(S),m):p(S)?this.spawnCallback(S,m):y(S)?this.spawnObservable(S,m):x(S)&&this.spawnMachine(g?S.withContext(g):S,{id:m,autoForward:w})}else this.spawnActivity(h);break;case I:this.stopChild(t.activity.id);break;case P:var E=t.label,_=t.value;E?this.logger(E,_):this.logger(_)}},o.prototype.removeChild=function(t){this.children.delete(t),this.forwardTo.delete(t),delete this.state.children[t]},o.prototype.stopChild=function(t){var e=this.children.get(t);e&&(this.removeChild(t),p(e.stop)&&e.stop())},o.prototype.spawn=function(t,e,n){if(l(t))return this.spawnPromise(Promise.resolve(t),e);if(p(t))return this.spawnCallback(t,e);if(function(t){try{return"function"==typeof t.send}catch(t){return!1}}(r=t)&&"id"in r)return this.spawnActor(t);if(y(t))return this.spawnObservable(t,e);if(x(t))return this.spawnMachine(t,i(i({},n),{id:e}));throw new Error('Unable to spawn entity "'+e+'" of type "'+typeof t+'".');var r},o.prototype.spawnMachine=function(t,e){var n=this;void 0===e&&(e={});var r=new o(t,i(i({},this.options),{parent:this,id:e.id||t.id})),s=i(i({},Y),e);s.sync&&r.onTransition((function(t){n.send(D,{state:t,id:r.id})}));var a=r;return this.children.set(r.id,a),s.autoForward&&this.forwardTo.add(r.id),r.onDone((function(t){n.removeChild(r.id),n.send(S(t,{origin:r.id}))})).start(),a},o.prototype.spawnPromise=function(t,e){var n=this,i=!1;t.then((function(t){i||(n.removeChild(e),n.send(S(z(e,t),{origin:e})))}),(function(t){if(!i){n.removeChild(e);var r=A(e,t);try{n.send(S(r,{origin:e}))}catch(t){n.devTools&&n.devTools.send(r,n.state),n.machine.strict&&n.stop()}}}));var r={id:e,send:function(){},subscribe:function(e,n,i){var r=function(t,e,n){if("object"==typeof t)return t;var i=function(){};return{next:t,error:e||i,complete:n||i}}(e,n,i),o=!1;return t.then((function(t){o||(r.next(t),o||r.complete())}),(function(t){o||r.error(t)})),{unsubscribe:function(){return o=!0}}},stop:function(){i=!0},toJSON:function(){return{id:e}}};return this.children.set(e,r),r},o.prototype.spawnCallback=function(t,e){var n,i=this,r=!1,o=new Set,s=new Set;try{n=t((function(t){s.forEach((function(e){return e(t)})),r||i.send(S(t,{origin:e}))}),(function(t){o.add(t)}))}catch(t){this.send(A(e,t))}if(l(n))return this.spawnPromise(n,e);var a={id:e,send:function(t){return o.forEach((function(e){return e(t)}))},subscribe:function(t){return s.add(t),{unsubscribe:function(){s.delete(t)}}},stop:function(){r=!0,p(n)&&n()},toJSON:function(){return{id:e}}};return this.children.set(e,a),a},o.prototype.spawnObservable=function(t,e){var n=this,i=t.subscribe((function(t){n.send(S(t,{origin:e}))}),(function(t){n.removeChild(e),n.send(S(A(e,t),{origin:e}))}),(function(){n.removeChild(e),n.send(S(z(e),{origin:e}))})),r={id:e,send:function(){},subscribe:function(e,n,i){return t.subscribe(e,n,i)},stop:function(){return i.unsubscribe()},toJSON:function(){return{id:e}}};return this.children.set(e,r),r},o.prototype.spawnActor=function(t){return this.children.set(t.id,t),t},o.prototype.spawnActivity=function(t){var e=this.machine.options&&this.machine.options.activities?this.machine.options.activities[t.type]:void 0;if(e){var n=e(this.state.context,t);this.spawnEffect(t.id,n)}},o.prototype.spawnEffect=function(t,e){this.children.set(t,{id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:e||void 0,toJSON:function(){return{id:t}}})},o.prototype.attachDev=function(){var t=K();if(this.options.devTools&&t){if(t.__REDUX_DEVTOOLS_EXTENSION__){var e="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=t.__REDUX_DEVTOOLS_EXTENSION__.connect(i(i({name:this.id,autoPause:!0,stateSanitizer:function(t){return{value:t.value,context:t.context,actions:t.actions}}},e),{features:i({jump:!1,skip:!1},e?e.features:void 0)}),this.machine),this.devTools.init(this.state)}Q(this)}},o.prototype.toJSON=function(){return{id:this.id}},o.prototype[m]=function(){return this},o.defaultOptions=function(t){return{execute:!0,deferEvents:!0,clock:{setTimeout:function(t,e){return setTimeout(t,e)},clearTimeout:function(t){return clearTimeout(t)}},logger:t.console.log.bind(console),devTools:!1}}("undefined"!=typeof self?self:global),o.interpret=tt,o}();function tt(t,e){return new Z(t,e)}t.Interpreter=Z,t.interpret=tt,t.spawn=function(t,e){var n=function(t){return v(t)?i(i({},Y),{name:t}):i(i(i({},Y),{name:w()}),t)}(e);return function(e){return e?e.spawn(t,n.name,n):function(t,e,n){var i=function(t){return{id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},toJSON:function(){return{id:t}}}}(e);return i.deferred=!0,x(t)&&(i.state=U(void 0,(function(){return(n?t.withContext(n):t).initialState}))),i}(t,n.name)}(q[q.length-1])},Object.defineProperty(t,"__esModule",{value:!0})}));