xstate 4.14.0 → 4.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,66 @@
1
1
  # xstate
2
2
 
3
+ ## 4.15.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`497c543d`](https://github.com/davidkpiano/xstate/commit/497c543d2980ea1a277b30b340a7bcd3dd0b3cb6) [#1766](https://github.com/davidkpiano/xstate/pull/1766) Thanks [@Andarist](https://github.com/Andarist)! - Fixed an issue with events received from callback actors not having the appropriate `_event.origin` set.
8
+
9
+ ## 4.15.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`8a8cfa32`](https://github.com/davidkpiano/xstate/commit/8a8cfa32d99aedf11f4af93ba56fa9ba68925c74) [#1704](https://github.com/davidkpiano/xstate/pull/1704) Thanks [@blimmer](https://github.com/blimmer)! - The default `clock` methods (`setTimeout` and `clearTimeout`) are now invoked properly with the global context preserved for those invocations which matter for some JS environments. More details can be found in the corresponding issue: [#1703](https://github.com/davidkpiano/xstate/issues/1703).
14
+
15
+ ## 4.15.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`6596d0ba`](https://github.com/davidkpiano/xstate/commit/6596d0ba163341fc43d214b48115536cb4815b68) [#1622](https://github.com/davidkpiano/xstate/pull/1622) Thanks [@davidkpiano](https://github.com/davidkpiano)! - Spawned/invoked actors and interpreters are now typed as extending `ActorRef` (e.g., `SpawnedActorRef`) rather than `Actor` or `Interpreter`. This unification of types should make it more straightforward to provide actor types:
20
+
21
+ ```diff
22
+ import {
23
+ - Actor
24
+ + ActorRef
25
+ } from 'xstate';
26
+
27
+ // ...
28
+
29
+ interface SomeContext {
30
+ - server?: Actor;
31
+ + server?: ActorRef<ServerEvent>;
32
+ }
33
+ ```
34
+
35
+ It's also easier to specify the type of a spawned/invoked machine with `ActorRefFrom`:
36
+
37
+ ```diff
38
+ import {
39
+ createMachine,
40
+ - Actor
41
+ + ActorRefFrom
42
+ } from 'xstate';
43
+
44
+ const serverMachine = createMachine<ServerContext, ServerEvent>({
45
+ // ...
46
+ });
47
+
48
+ interface SomeContext {
49
+ - server?: Actor; // difficult to type
50
+ + server?: ActorRefFrom<typeof serverMachine>;
51
+ }
52
+ ```
53
+
54
+ ### Patch Changes
55
+
56
+ - [`75a91b07`](https://github.com/davidkpiano/xstate/commit/75a91b078a10a86f13edc9eec3ac1d6246607002) [#1692](https://github.com/davidkpiano/xstate/pull/1692) Thanks [@Andarist](https://github.com/Andarist)! - Fixed an issue with history state entering a wrong state if the most recent visit in its parent has been caused by a transient transition.
57
+
58
+ ## 4.14.1
59
+
60
+ ### Patch Changes
61
+
62
+ - [`02c76350`](https://github.com/davidkpiano/xstate/commit/02c763504da0808eeb281587981a5baf8ba884a1) [#1656](https://github.com/davidkpiano/xstate/pull/1656) Thanks [@Andarist](https://github.com/Andarist)! - Exit actions will now be properly called when a service gets canceled by calling its `stop` method.
63
+
3
64
  ## 4.14.0
4
65
 
5
66
  ### Minor Changes
@@ -12,4 +12,4 @@
12
12
 
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
- ***************************************************************************** */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&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}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 w="function"==typeof Symbol&&Symbol.observable||"@@observable";function m(t){try{return"__xstatenode"in t}catch(t){return!1}}var x,b=(x=0,function(){return(++x).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 I=e.Start,T=e.Stop,L=(e.Raise,e.Send),k=e.Cancel,P=(e.NullEvent,e.Assign,e.After,e.DoneState,e.Log),C=e.Init,N=(e.Invoke,e.ErrorExecution,e.ErrorPlatform),j=e.ErrorCustom,D=e.Update,M=(e.Choose,e.Pure,S({type:C}));function A(t,n){var i=e.DoneInvoke+"."+t,r={type:i,data:n,toString:function(){return i}};return r}function R(t,n){var i=e.ErrorPlatform+"."+t,r={type:i,data:n,toString:function(){return i}};return r}var z=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};function $(t){try{return"function"==typeof t.send}catch(t){return!1}}var F,X=new Map,B=0,G=function(){return"x:"+B++},H=function(t,e){return X.set(t,e),t},K=function(t){return X.get(t)},Q=function(t){X.delete(t)},W={sync:!1,autoForward:!1};(F=t.InterpreterStatus||(t.InterpreterStatus={}))[F.NotStarted=0]="NotStarted",F[F.Running=1]="Running",F[F.Stopped=2]="Stopped";var Y=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=s.parent&&(e===n.Parent||s.parent.id===e),o=r?s.parent:$(e)?e:s.children.get(e)||K(e);if(o)"machine"in o?o.send(i(i({},t),{name:t.name===j?""+R(s.id):t.name,origin:s.sessionId})):o.send(t.data);else if(!r)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=G()}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 w=r(this.contextListeners),m=w.next();!m.done;m=w.next()){(0,m.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(t){a={error:t}}finally{try{m&&!m.done&&(u=w.return)&&u.call(w)}finally{if(a)throw a.error}}var x=O(t.configuration||[],this.machine);if(this.state.configuration&&x){this.state.configuration.forEach((function(e){var n,i;try{for(var o=r(e.definition.exit),s=o.next();!s.done;s=o.next()){var a=s.value;l.exec(a,t)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}}));var b=t.configuration.find((function(t){return"final"===t.type&&t.parent===l.machine})),g=b&&b.doneData?f(b.doneData,t.context,e):void 0;try{for(var S=r(this.doneListeners),E=S.next();!E.done;E=S.next()){(0,E.value)(A(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;H(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(z.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;try{for(var d=r(this.listeners),v=d.next();!v.done;v=d.next()){var y=v.value;this.listeners.delete(y)}}catch(t){e={error:t}}finally{try{v&&!v.done&&(n=d.return)&&n.call(d)}finally{if(e)throw e.error}}try{for(var w=r(this.stopListeners),m=w.next();!m.done;m=w.next()){(y=m.value)(),this.stopListeners.delete(y)}}catch(t){i={error:t}}finally{try{m&&!m.done&&(o=w.return)&&o.call(w)}finally{if(i)throw i.error}}try{for(var x=r(this.contextListeners),b=x.next();!b.done;b=x.next()){y=b.value;this.contextListeners.delete(y)}}catch(t){s={error:t}}finally{try{b&&!b.done&&(a=x.return)&&a.call(x)}finally{if(s)throw s.error}}try{for(var g=r(this.doneListeners),S=g.next();!S.done;S=g.next()){y=S.value;this.doneListeners.delete(y)}}catch(t){c={error:t}}finally{try{S&&!S.done&&(h=g.return)&&h.call(g)}finally{if(c)throw c.error}}this.children.forEach((function(t){p(t.stop)&&t.stop()}));try{for(var E=r(u(this.delayedEventsMap)),_=E.next();!_.done;_=E.next()){var O=_.value;this.clock.clearTimeout(this.delayedEventsMap[O])}}catch(t){f={error:t}}finally{try{_&&!_.done&&(l=E.return)&&l.call(E)}finally{if(f)throw f.error}}return this.scheduler.clear(),this.initialized=!1,this.status=t.InterpreterStatus.Stopped,Q(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(N)&&!this.state.nextEvents.some((function(t){return 0===t.indexOf(N)})))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 I: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,w=h.id,x=h.data,b="autoForward"in h?h.autoForward:!!h.forward;if(!v)return;var g=x?f(x,o,s):void 0,S=p(v)?v(o,s.data,{data:g,src:d}):v;l(S)?this.spawnPromise(Promise.resolve(S),w):p(S)?this.spawnCallback(S,w):y(S)?this.spawnObservable(S,w):m(S)&&this.spawnMachine(g?S.withContext(g):S,{id:w,autoForward:b})}else this.spawnActivity(h);break;case T: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($(t))return this.spawnActor(t);if(y(t))return this.spawnObservable(t,e);if(m(t))return this.spawnMachine(t,i(i({},n),{id:e}));throw new Error('Unable to spawn entity "'+e+'" of type "'+typeof t+'".')},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({},W),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(A(e,t),{origin:e})))}),(function(t){if(!i){n.removeChild(e);var r=R(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=!1;return t.then((function(t){r||(e&&e(t),r||i&&i())}),(function(t){r||n(t)})),{unsubscribe:function(){return r=!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(t)}),(function(t){o.add(t)}))}catch(t){this.send(R(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(R(e,t),{origin:e}))}),(function(){n.removeChild(e),n.send(S(A(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(){if(this.options.devTools&&"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){var t="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=window.__REDUX_DEVTOOLS_EXTENSION__.connect(i(i({name:this.id,autoPause:!0,stateSanitizer:function(t){return{value:t.value,context:t.context,actions:t.actions}}},t),{features:i({jump:!1,skip:!1},t?t.features:void 0)}),this.machine),this.devTools.init(this.state)}},o.prototype.toJSON=function(){return{id:this.id}},o.prototype[w]=function(){return this},o.defaultOptions=function(t){return{execute:!0,deferEvents:!0,clock:{setTimeout:function(e,n){return t.setTimeout.call(null,e,n)},clearTimeout:function(e){return t.clearTimeout.call(null,e)}},logger:t.console.log.bind(console),devTools:!1}}("undefined"!=typeof self?self:global),o.interpret=Z,o}();function Z(t,e){return new Y(t,e)}t.Interpreter=Y,t.interpret=Z,t.spawn=function(t,e){var n=function(t){return v(t)?i(i({},W),{name:t}):i(i(i({},W),{name:b()}),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,m(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})}));
15
+ ***************************************************************************** */var e,n,r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function o(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.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:l(t)?h(t):"string"!=typeof t?t:h(function(t,e){try{return l(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,r=0;r<t.length-1;r++)r===t.length-2?n[t[r]]=t[r+1]:(n[t[r]]={},n=n[t[r]]);return e}function f(t,e,n){var r,o;if(p(t))return t(e,n.data);var s={};try{for(var a=i(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){r={error:t}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}return s}function d(t){return t instanceof Promise||!(null===t||!p(t)&&"object"!=typeof t||!p(t.then))}function l(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 w(t){try{return"__xstatenode"in t}catch(t){return!1}}var x,b=(x=0,function(){return(++x).toString(16)});function g(t,e){return v(t)||"number"==typeof t?r({type:t},e):t}function S(t,e){if(!v(t)&&"$$type"in t&&"scxml"===t.$$type)return t;var n=g(t);return r({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,r=e,Array.isArray(n)?n.some((function(t){return t===r})):n instanceof Set&&n.has(r));var n,r})):"parallel"===e.type&&E(e).every((function(e){return O(t,e)}))}var I=e.Start,T=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 A(t,n){var r=e.DoneInvoke+"."+t,i={type:r,data:n,toString:function(){return r}};return i}function R(t,n){var r=e.ErrorPlatform+"."+t,i={type:r,data:n,toString:function(){return r}};return i}var z=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 r=M;return new t({value:e.value,context:n,_event:r,_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 r=u(t);return r.concat.apply(r,s(r.map((function(r){return n.toStrings(t[r],e).map((function(t){return r+e+t}))}))))},t.prototype.toJSON=function(){this.configuration,this.transitions;return function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(this,["configuration","transitions"])},t.prototype.matches=function(t){return function t(e,n,r){void 0===r&&(r=".");var i=c(e,r),o=c(n,r);return v(o)?!!v(i)&&o===i:v(i)?i in o:u(i).every((function(e){return e in o&&t(i[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=r(r({},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 $,F=new Map,X=0,B=function(){return"x:"+X++},G=function(t,e){return F.set(t,e),t},H=function(t){return F.get(t)},K=function(t){F.delete(t)},Q={sync:!1,autoForward:!1};($=t.InterpreterStatus||(t.InterpreterStatus={}))[$.NotStarted=0]="NotStarted",$[$.Running=1]="Running",$[$.Stopped=2]="Stopped";var W=function(){function o(e,i){var s=this;void 0===i&&(i=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(l(e))return s.batch(e),s.state;var r=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 "'+r.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(r.data));return s.scheduler.schedule((function(){s.forward(r);var t=s.nextState(r);s.update(t,r)})),s._state},this.sendTo=function(t,e){var i,o=s.parent&&(e===n.Parent||s.parent.id===e),a=o?s.parent:v(e)?s.children.get(e)||H(e):(i=e)&&"function"==typeof i.send?e:void 0;if(a)"machine"in a?a.send(r(r({},t),{name:t.name===N?""+R(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=r(r({},o.defaultOptions),i),u=a.clock,c=a.logger,h=a.parent,f=a.id,d=void 0!==f?f:e.id;this.id=d,this.logger=c,this.clock=u,this.parent=h,this.options=a,this.scheduler=new J({deferEvents:this.options.deferEvents}),this.sessionId=B()}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,r;try{for(var o=i(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&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},o.prototype.update=function(t,e){var n,r,o,s,a,u,c,h,d=this;if(t._sessionid=this.sessionId,this._state=t,this.options.execute&&this.execute(this.state),this.children.forEach((function(t){d.state.children[t.id]=t})),this.devTools&&this.devTools.send(e.data,t),t.event)try{for(var l=i(this.eventListeners),p=l.next();!p.done;p=l.next()){(0,p.value)(t.event)}}catch(t){n={error:t}}finally{try{p&&!p.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}try{for(var v=i(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=i(this.contextListeners),w=m.next();!w.done;w=m.next()){(0,w.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(t){a={error:t}}finally{try{w&&!w.done&&(u=m.return)&&u.call(m)}finally{if(a)throw a.error}}var x=O(t.configuration||[],this.machine);if(this.state.configuration&&x){var b=t.configuration.find((function(t){return"final"===t.type&&t.parent===d.machine})),g=b&&b.doneData?f(b.doneData,t.context,e):void 0;try{for(var S=i(this.doneListeners),E=S.next();!E.done;E=S.next()){(0,E.value)(A(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,r){var i,o=this;if(!e)return{unsubscribe:function(){}};var s=r;return"function"==typeof e?i=e:(i=e.next.bind(e),s=e.complete.bind(e)),this.listeners.add(i),this.status===t.InterpreterStatus.Running&&i(this.state),s&&this.onDone(s),{unsubscribe:function(){i&&o.listeners.delete(i),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;G(this.sessionId,this),this.initialized=!0,this.status=t.InterpreterStatus.Running;var r=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(z.from(e,n.machine.context));var t}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){n.update(r,M)})),this},o.prototype.stop=function(){var e,n,r,o,s,a,c,h,f,d,l=this;try{for(var v=i(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 w=i(this.stopListeners),x=w.next();!x.done;x=w.next()){(m=x.value)(),this.stopListeners.delete(m)}}catch(t){r={error:t}}finally{try{x&&!x.done&&(o=w.return)&&o.call(w)}finally{if(r)throw r.error}}try{for(var b=i(this.contextListeners),g=b.next();!g.done;g=b.next()){m=g.value;this.contextListeners.delete(m)}}catch(t){s={error:t}}finally{try{g&&!g.done&&(a=b.return)&&a.call(b)}finally{if(s)throw s.error}}try{for(var S=i(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}}this.state.configuration.forEach((function(t){var e,n;try{for(var r=i(t.definition.exit),o=r.next();!o.done;o=r.next()){var s=o.value;l.exec(s,l.state)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}})),this.children.forEach((function(t){p(t.stop)&&t.stop()}));try{for(var _=i(u(this.delayedEventsMap)),O=_.next();!O.done;O=_.next()){var I=O.value;this.clock.clearTimeout(this.delayedEventsMap[I])}}catch(t){f={error:t}}finally{try{O&&!O.done&&(d=_.return)&&d.call(_)}finally{if(f)throw f.error}}return this.scheduler.clear(),this.initialized=!1,this.status=t.InterpreterStatus.Stopped,K(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,i=(e=t).exec,r(r({},e),{exec:void 0!==i?function(){return i(n.context,n.event,{action:e,state:n,_event:n._event})}:void 0});var e,n,i})))),u=u||!!a.changed};try{for(var f=i(e),d=f.next();!d.done;d=f.next()){h(d.value)}}catch(e){t={error:e}}finally{try{d&&!d.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 r=i(this.forwardTo),o=r.next();!o.done;o=r.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=r.return)&&n.call(r)}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,r){void 0===r&&(r=this.machine.options.actions);var i,o=n.context,s=n._event,a=t.exec||function(t,e){return e&&e[t]||void 0}(t.type,r),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 I:var h=t.activity;if(!this.state.activities[h.id||h.type])break;if(h.type===e.Invoke){var l="string"==typeof(i=h.src)?{type:i}:i,v=this.machine.options.services?this.machine.options.services[l.type]:void 0,m=h.id,x=h.data,b="autoForward"in h?h.autoForward:!!h.forward;if(!v)return;var g=x?f(x,o,s):void 0,S=p(v)?v(o,s.data,{data:g,src:l}):v;d(S)?this.spawnPromise(Promise.resolve(S),m):p(S)?this.spawnCallback(S,m):y(S)?this.spawnObservable(S,m):w(S)&&this.spawnMachine(g?S.withContext(g):S,{id:m,autoForward:b})}else this.spawnActivity(h);break;case T: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(d(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}}(i=t)&&"id"in i)return this.spawnActor(t);if(y(t))return this.spawnObservable(t,e);if(w(t))return this.spawnMachine(t,r(r({},n),{id:e}));throw new Error('Unable to spawn entity "'+e+'" of type "'+typeof t+'".');var i},o.prototype.spawnMachine=function(t,e){var n=this;void 0===e&&(e={});var i=new o(t,r(r({},this.options),{parent:this,id:e.id||t.id})),s=r(r({},Q),e);s.sync&&i.onTransition((function(t){n.send(D,{state:t,id:i.id})}));var a=i;return this.children.set(i.id,a),s.autoForward&&this.forwardTo.add(i.id),i.onDone((function(t){n.removeChild(i.id),n.send(S(t,{origin:i.id}))})).start(),a},o.prototype.spawnPromise=function(t,e){var n=this,r=!1;t.then((function(t){r||(n.removeChild(e),n.send(S(A(e,t),{origin:e})))}),(function(t){if(!r){n.removeChild(e);var i=R(e,t);try{n.send(S(i,{origin:e}))}catch(t){n.devTools&&n.devTools.send(i,n.state),n.machine.strict&&n.stop()}}}));var i={id:e,send:function(){},subscribe:function(e,n,r){var i=function(t,e,n){if("object"==typeof t)return t;var r=function(){};return{next:t,error:e||r,complete:n||r}}(e,n,r),o=!1;return t.then((function(t){o||(i.next(t),o||i.complete())}),(function(t){o||i.error(t)})),{unsubscribe:function(){return o=!0}}},stop:function(){r=!0},toJSON:function(){return{id:e}}};return this.children.set(e,i),i},o.prototype.spawnCallback=function(t,e){var n,r=this,i=!1,o=new Set,s=new Set;try{n=t((function(t){s.forEach((function(e){return e(t)})),i||r.send(S(t,{origin:e}))}),(function(t){o.add(t)}))}catch(t){this.send(R(e,t))}if(d(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(){i=!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,r=t.subscribe((function(t){n.send(S(t,{origin:e}))}),(function(t){n.removeChild(e),n.send(S(R(e,t),{origin:e}))}),(function(){n.removeChild(e),n.send(S(A(e),{origin:e}))})),i={id:e,send:function(){},subscribe:function(e,n,r){return t.subscribe(e,n,r)},stop:function(){return r.unsubscribe()},toJSON:function(){return{id:e}}};return this.children.set(e,i),i},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(){if(this.options.devTools&&"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){var t="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=window.__REDUX_DEVTOOLS_EXTENSION__.connect(r(r({name:this.id,autoPause:!0,stateSanitizer:function(t){return{value:t.value,context:t.context,actions:t.actions}}},t),{features:r({jump:!1,skip:!1},t?t.features:void 0)}),this.machine),this.devTools.init(this.state)}},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=Y,o}();function Y(t,e){return new W(t,e)}t.Interpreter=W,t.interpret=Y,t.spawn=function(t,e){var n=function(t){return v(t)?r(r({},Q),{name:t}):r(r(r({},Q),{name:b()}),t)}(e);return function(e){return e?e.spawn(t,n.name,n):function(t,e,n){var r=function(t){return{id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},toJSON:function(){return{id:t}}}}(e);return r.deferred=!0,w(t)&&(r.state=U(void 0,(function(){return(n?t.withContext(n):t).initialState}))),r}(t,n.name)}(q[q.length-1])},Object.defineProperty(t,"__esModule",{value:!0})}));
package/dist/xstate.js CHANGED
@@ -12,4 +12,4 @@
12
12
 
13
13
  See the Apache Version 2.0 License for specific language governing permissions
14
14
  and limitations under the License.
15
- ***************************************************************************** */var e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function r(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function i(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function o(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}var a={};function s(t){return Object.keys(t)}function c(t,e,n){void 0===n&&(n=".");var r=f(t,n),i=f(e,n);return N(i)?!!N(r)&&i===r:N(r)?r in i:s(r).every((function(t){return t in i&&c(r[t],i[t])}))}function u(t){try{return N(t)||"number"==typeof t?""+t:t.type}catch(t){throw new Error("Events must be strings or objects with a string event.type property.")}}function h(t,e){try{return E(t)?t:t.toString().split(e)}catch(e){throw new Error("'"+t+"' is not a valid state path.")}}function f(t,e){return"object"==typeof(n=t)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?t.value:E(t)?l(t):"string"!=typeof t?t:l(h(t,e));var n}function l(t){if(1===t.length)return t[0];for(var e={},n=e,r=0;r<t.length-1;r++)r===t.length-2?n[t[r]]=t[r+1]:(n[t[r]]={},n=n[t[r]]);return e}function d(t,e){for(var n={},r=s(t),i=0;i<r.length;i++){var o=r[i];n[o]=e(t[o],o,t,i)}return n}function v(t,e,n){var i,o,a={};try{for(var c=r(s(t)),u=c.next();!u.done;u=c.next()){var h=u.value,f=t[h];n(f)&&(a[h]=e(f,h,t))}}catch(t){i={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}return a}var p=function(t){return function(e){var n,i,o=e;try{for(var a=r(t),s=a.next();!s.done;s=a.next()){o=o[s.value]}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o}};function y(t){return t?N(t)?[[t]]:g(s(t).map((function(e){var n=t[e];return"string"==typeof n||n&&Object.keys(n).length?y(t[e]).map((function(t){return[e].concat(t)})):[[e]]}))):[[]]}function g(t){var e;return(e=[]).concat.apply(e,o(t))}function m(t){return E(t)?t:[t]}function x(t){return void 0===t?[]:m(t)}function S(t,e,n){var i,o;if(T(t))return t(e,n.data);var a={};try{for(var s=r(Object.keys(t)),c=s.next();!c.done;c=s.next()){var u=c.value,h=t[u];T(h)?a[u]=h(e,n.data):a[u]=h}}catch(t){i={error:t}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return a}function w(t){return t instanceof Promise||!(null===t||!T(t)&&"object"!=typeof t||!T(t.then))}function b(t,e){var n,o,a=i([[],[]],2),s=a[0],c=a[1];try{for(var u=r(t),h=u.next();!h.done;h=u.next()){var f=h.value;e(f)?s.push(f):c.push(f)}}catch(t){n={error:t}}finally{try{h&&!h.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}return[s,c]}function _(t,e){return d(t.states,(function(t,n){if(t){var r=(N(e)?void 0:e[n])||(t?t.current:void 0);if(r)return{current:r,states:_(t,r)}}}))}function E(t){return Array.isArray(t)}function T(t){return"function"==typeof t}function N(t){return"string"==typeof t}function O(t,e){if(t)return N(t)?{type:"xstate.guard",name:t,predicate:e?e[t]:void 0}:T(t)?{type:"xstate.guard",name:t.name,predicate:t}:t}function A(t){try{return"subscribe"in t&&T(t.subscribe)}catch(t){return!1}}var P="function"==typeof Symbol&&Symbol.observable||"@@observable";function k(t){try{return"__xstatenode"in t}catch(t){return!1}}var I,V,C,j=(I=0,function(){return(++I).toString(16)});function L(t,n){return N(t)||"number"==typeof t?e({type:t},n):t}function D(t,n){if(!N(t)&&"$$type"in t&&"scxml"===t.$$type)return t;var r=L(t);return e({name:r.type,data:r,$$type:"scxml",type:"external"},n)}function M(t,n){return m(n).map((function(n){return void 0===n||"string"==typeof n||k(n)?{target:n,event:t}:e(e({},n),{event:t})}))}function R(t,e,n,r,i){var o=t.options.guards,a={state:i,cond:e,_event:r};if("xstate.guard"===e.type)return e.predicate(n,r.data,a);var s=o[e.type];if(!s)throw new Error("Guard '"+e.type+"' is not implemented on machine '"+t.id+"'.");return s(n,r.data,a)}function F(t){return"string"==typeof t?{type:t}:t}(V=t.ActionTypes||(t.ActionTypes={})).Start="xstate.start",V.Stop="xstate.stop",V.Raise="xstate.raise",V.Send="xstate.send",V.Cancel="xstate.cancel",V.NullEvent="",V.Assign="xstate.assign",V.After="xstate.after",V.DoneState="done.state",V.DoneInvoke="done.invoke",V.Log="xstate.log",V.Init="xstate.init",V.Invoke="xstate.invoke",V.ErrorExecution="error.execution",V.ErrorCommunication="error.communication",V.ErrorPlatform="error.platform",V.ErrorCustom="xstate.error",V.Update="xstate.update",V.Pure="xstate.pure",V.Choose="xstate.choose",(C=t.SpecialTargets||(t.SpecialTargets={})).Parent="#_parent",C.Internal="#_internal";var U=function(t){return"atomic"===t.type||"final"===t.type};function z(t){return s(t.states).map((function(e){return t.states[e]}))}function J(t){var e=[t];return U(t)?e:e.concat(g(z(t).map(J)))}function B(t,e){var n,i,o,a,s,c,u,h,f=q(new Set(t)),l=new Set(e);try{for(var d=r(l),v=d.next();!v.done;v=d.next())for(var p=(E=v.value).parent;p&&!l.has(p);)l.add(p),p=p.parent}catch(t){n={error:t}}finally{try{v&&!v.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}var y=q(l);try{for(var g=r(l),m=g.next();!m.done;m=g.next()){if("compound"!==(E=m.value).type||y.get(E)&&y.get(E).length){if("parallel"===E.type)try{for(var x=(s=void 0,r(z(E))),S=x.next();!S.done;S=x.next()){var w=S.value;"history"!==w.type&&(l.has(w)||(l.add(w),f.get(w)?f.get(w).forEach((function(t){return l.add(t)})):w.initialStateNodes.forEach((function(t){return l.add(t)}))))}}catch(t){s={error:t}}finally{try{S&&!S.done&&(c=x.return)&&c.call(x)}finally{if(s)throw s.error}}}else f.get(E)?f.get(E).forEach((function(t){return l.add(t)})):E.initialStateNodes.forEach((function(t){return l.add(t)}))}}catch(t){o={error:t}}finally{try{m&&!m.done&&(a=g.return)&&a.call(g)}finally{if(o)throw o.error}}try{for(var b=r(l),_=b.next();!_.done;_=b.next()){var E;for(p=(E=_.value).parent;p&&!l.has(p);)l.add(p),p=p.parent}}catch(t){u={error:t}}finally{try{_&&!_.done&&(h=b.return)&&h.call(b)}finally{if(u)throw u.error}}return l}function q(t){var e,n,i=new Map;try{for(var o=r(t),a=o.next();!a.done;a=o.next()){var s=a.value;i.has(s)||i.set(s,[]),s.parent&&(i.has(s.parent)||i.set(s.parent,[]),i.get(s.parent).push(s))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return i}function $(t,e){return function t(e,n){var r=n.get(e);if(!r)return{};if("compound"===e.type){var i=r[0];if(!i)return{};if(U(i))return i.key}var o={};return r.forEach((function(e){o[e.key]=t(e,n)})),o}(t,q(B([t],e)))}function X(t,e){return Array.isArray(t)?t.some((function(t){return t===e})):t instanceof Set&&t.has(e)}function H(t,e){return"compound"===e.type?z(e).some((function(e){return"final"===e.type&&X(t,e)})):"parallel"===e.type&&z(e).every((function(e){return H(t,e)}))}var G=t.ActionTypes.Start,K=t.ActionTypes.Stop,Q=t.ActionTypes.Raise,W=t.ActionTypes.Send,Y=t.ActionTypes.Cancel,Z=t.ActionTypes.NullEvent,tt=t.ActionTypes.Assign,et=(t.ActionTypes.After,t.ActionTypes.DoneState,t.ActionTypes.Log),nt=t.ActionTypes.Init,rt=t.ActionTypes.Invoke,it=(t.ActionTypes.ErrorExecution,t.ActionTypes.ErrorPlatform),ot=t.ActionTypes.ErrorCustom,at=t.ActionTypes.Update,st=t.ActionTypes.Choose,ct=t.ActionTypes.Pure,ut=D({type:nt});function ht(t,e){return e&&e[t]||void 0}function ft(t,n){var r;if(N(t)||"number"==typeof t){var i=ht(t,n);r=T(i)?{type:t,exec:i}:i||{type:t,exec:void 0}}else if(T(t))r={type:t.name||t.toString(),exec:t};else{if(T(i=ht(t.type,n)))r=e(e({},t),{exec:i});else if(i){var o=i.type||t.type;r=e(e(e({},i),t),{type:o})}else r=t}return Object.defineProperty(r,"toString",{value:function(){return r.type},enumerable:!1,configurable:!0}),r}var lt=function(t,e){return t?(E(t)?t:[t]).map((function(t){return ft(t,e)})):[]};function dt(t){var n=ft(t);return e(e({id:N(t)?t:n.id},n),{type:n.type})}function vt(e){return N(e)?{type:Q,event:e}:pt(e,{to:t.SpecialTargets.Internal})}function pt(t,e){return{to:e?e.to:void 0,type:W,event:T(t)?t:L(t),delay:e?e.delay:void 0,id:e&&void 0!==e.id?e.id:T(t)?t.name:u(t)}}function yt(n,r){return pt(n,e(e({},r),{to:t.SpecialTargets.Parent}))}function gt(){return yt(at)}var mt=function(t,e){return{context:t,event:e}};var xt=function(t){return{type:Y,sendId:t}};function St(e){var n=dt(e);return{type:t.ActionTypes.Start,activity:n,exec:void 0}}function wt(e){var n=T(e)?e:dt(e);return{type:t.ActionTypes.Stop,activity:n,exec:void 0}}var bt=function(t){return{type:tt,assignment:t}};function _t(e,n){var r=n?"#"+n:"";return t.ActionTypes.After+"("+e+")"+r}function Et(e,n){var r=t.ActionTypes.DoneState+"."+e,i={type:r,data:n,toString:function(){return r}};return i}function Tt(e,n){var r=t.ActionTypes.DoneInvoke+"."+e,i={type:r,data:n,toString:function(){return r}};return i}function Nt(e,n){var r=t.ActionTypes.ErrorPlatform+"."+e,i={type:r,data:n,toString:function(){return r}};return i}function Ot(t,n){return pt((function(t,e){return e}),e(e({},n),{to:t}))}function At(n,o,a,c,u){var h=i(b(u,(function(t){return t.type===tt})),2),f=h[0],l=h[1],d=f.length?function(t,e,n,i){return t?n.reduce((function(t,n){var o,a,c=n.assignment,u={state:i,action:n,_event:e},h={};if(T(c))h=c(t,e.data,u);else try{for(var f=r(s(c)),l=f.next();!l.done;l=f.next()){var d=l.value,v=c[d];h[d]=T(v)?v(t,e.data,u):v}}catch(t){o={error:t}}finally{try{l&&!l.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}return Object.assign({},t,h)}),t):t}(a,c,f,o):a;return[g(l.map((function(r){var i;switch(r.type){case Q:return{type:Q,_event:D(r.event)};case W:return function(t,n,r,i){var o,a={_event:r},s=D(T(t.event)?t.event(n,r.data,a):t.event);if(N(t.delay)){var c=i&&i[t.delay];o=T(c)?c(n,r.data,a):c}else o=T(t.delay)?t.delay(n,r.data,a):t.delay;var u=T(t.to)?t.to(n,r.data,a):t.to;return e(e({},t),{to:u,_event:s,event:s.data,delay:o})}(r,d,c,n.options.delays);case et:return function(t,n,r){return e(e({},t),{value:N(t.expr)?t.expr:t.expr(n,r.data,{_event:r})})}(r,d,c);case st:if(!(s=null===(i=r.conds.find((function(t){var e=O(t.cond,n.options.guards);return!e||R(n,e,d,c,o)})))||void 0===i?void 0:i.actions))return[];var a=At(n,o,d,c,lt(x(s),n.options.actions));return d=a[1],a[0];case ct:var s;if(!(s=r.get(d,c.data)))return[];a=At(n,o,d,c,lt(x(s),n.options.actions));return d=a[1],a[0];case K:return function(e,n,r){var i=T(e.activity)?e.activity(n,r.data):e.activity,o="string"==typeof i?{id:i}:i;return{type:t.ActionTypes.Stop,activity:o}}(r,d,c);default:return ft(r,n.options.actions)}}))),d]}var Pt=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 t=e.configuration,g(o(new Set(t.map((function(t){return t.ownEvents})))));var t}})}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:ut,_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 r=ut;return new t({value:e.value,context:n,_event:r,_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="."),N(t))return[t];var r=s(t);return r.concat.apply(r,o(r.map((function(r){return n.toStrings(t[r],e).map((function(t){return r+e+t}))}))))},t.prototype.toJSON=function(){this.configuration,this.transitions;return n(this,["configuration","transitions"])},t.prototype.matches=function(t){return c(t,this.value)},t}(),kt=[],It=function(t,e){kt.push(t);var n=e(t);return kt.pop(),n};function Vt(t){return{id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},toJSON:function(){return{id:t}}}}function Ct(t,e,n){var r=Vt(e);return r.deferred=!0,k(t)&&(r.state=It(void 0,(function(){return(n?t.withContext(n):t).initialState}))),r}function jt(t){try{return"function"==typeof t.send}catch(t){return!1}}function Lt(t){if("string"==typeof t){var e={type:t,toString:function(){return t}};return e}return t}function Dt(t){return e(e({type:rt},t),{toJSON:function(){t.onDone,t.onError;var r=n(t,["onDone","onError"]);return e(e({},r),{type:rt,src:Lt(t.src)})}})}var Mt={},Rt=function(t){return"#"===t[0]},Ft=function(){function a(t,n,i){var c=this;this.config=t,this.context=i,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.options=Object.assign({actions:{},guards:{},services:{},activities:{},delays:{}},n),this.parent=this.options._parent,this.key=this.config.key||this.options._key||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:"."),this.id=this.config.id||o([this.machine.key],this.path).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&s(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.initial=this.config.initial,this.states=this.config.states?d(this.config.states,(function(t,n){var r,i=new a(t,{_parent:c,_key:n});return Object.assign(c.idMap,e(((r={})[i.id]=i,r),i.idMap)),i})):Mt;var u=0;!function t(e){var n,i;e.order=u++;try{for(var o=r(z(e)),a=o.next();!a.done;a=o.next()){t(a.value)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}}(this),this.history=!0===this.config.history?"shallow":this.config.history||!1,this._transient=!!this.config.always||!!this.config.on&&(Array.isArray(this.config.on)?this.config.on.some((function(t){return""===t.event})):""in this.config.on),this.strict=!!this.config.strict,this.onEntry=x(this.config.entry||this.config.onEntry).map((function(t){return ft(t)})),this.onExit=x(this.config.exit||this.config.onExit).map((function(t){return ft(t)})),this.meta=this.config.meta,this.doneData="final"===this.type?this.config.data:void 0,this.invoke=x(this.config.invoke).map((function(t,n){var r,i;if(k(t))return c.machine.options.services=e(((r={})[t.id]=t,r),c.machine.options.services),Dt({src:t.id,id:t.id});if(N(t.src))return Dt(e(e({},t),{id:t.id||t.src,src:t.src}));if(k(t.src)||T(t.src)){var o=c.id+":invocation["+n+"]";return c.machine.options.services=e(((i={})[o]=t.src,i),c.machine.options.services),Dt(e(e({id:o},t),{src:o}))}var a=t.src;return Dt(e(e({id:a.type},t),{src:a}))})),this.activities=x(this.config.activities).concat(this.invoke).map((function(t){return dt(t)})),this.transition=this.transition.bind(this)}return a.prototype._init=function(){this.__cache.transitions||J(this).forEach((function(t){return t.on}))},a.prototype.withConfig=function(t,n){void 0===n&&(n=this.context);var r=this.options,i=r.actions,o=r.activities,s=r.guards,c=r.services,u=r.delays;return new a(this.config,{actions:e(e({},i),t.actions),activities:e(e({},o),t.activities),guards:e(e({},s),t.guards),services:e(e({},c),t.services),delays:e(e({},u),t.delays)},n)},a.prototype.withContext=function(t){return new a(this.config,this.options,t)},Object.defineProperty(a.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:d(this.states,(function(t){return t.definition})),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke}},enumerable:!1,configurable:!0}),a.prototype.toJSON=function(){return this.definition},Object.defineProperty(a.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var t=this.transitions;return this.__cache.on=t.reduce((function(t,e){return t[e.eventType]=t[e.eventType]||[],t[e.eventType].push(e),t}),{})},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),a.prototype.getCandidates=function(t){if(this.__cache.candidates[t])return this.__cache.candidates[t];var e=""===t,n=this.transitions.filter((function(n){var r=n.eventType===t;return e?r:r||"*"===n.eventType}));return this.__cache.candidates[t]=n,n},a.prototype.getDelayedTransitions=function(){var t=this,n=this.config.after;if(!n)return[];var r=function(e,n){var r=_t(T(e)?t.id+":delay["+n+"]":e,t.id);return t.onEntry.push(pt(r,{delay:e})),t.onExit.push(xt(r)),r};return(E(n)?n.map((function(t,n){var i=r(t.delay,n);return e(e({},t),{event:i})})):g(s(n).map((function(t,i){var o=n[t],a=N(o)?{target:o}:o,s=isNaN(+t)?t:+t,c=r(s,i);return x(a).map((function(t){return e(e({},t),{event:c,delay:s})}))})))).map((function(n){var r=n.delay;return e(e({},t.formatTransition(n)),{delay:r})}))},a.prototype.getStateNodes=function(t){var e,n=this;if(!t)return[];var r=t instanceof Pt?t.value:f(t,this.delimiter);if(N(r)){var i=this.getStateNode(r).initial;return void 0!==i?this.getStateNodes(((e={})[r]=i,e)):[this.states[r]]}var o=s(r);return o.map((function(t){return n.getStateNode(t)})).concat(o.reduce((function(t,e){var i=n.getStateNode(e).getStateNodes(r[e]);return t.concat(i)}),[]))},a.prototype.handles=function(t){var e=u(t);return this.events.includes(e)},a.prototype.resolveState=function(t){var n=Array.from(B([],this.getStateNodes(t.value)));return new Pt(e(e({},t),{value:this.resolve(t.value),configuration:n}))},a.prototype.transitionLeafNode=function(t,e,n){var r=this.getStateNode(t).next(e,n);return r&&r.transitions.length?r:this.next(e,n)},a.prototype.transitionCompoundNode=function(t,e,n){var r=s(t),i=this.getStateNode(r[0])._transition(t[r[0]],e,n);return i&&i.transitions.length?i:this.next(e,n)},a.prototype.transitionParallelNode=function(t,e,n){var i,o,a={};try{for(var c=r(s(t)),u=c.next();!u.done;u=c.next()){var h=u.value,f=t[h];if(f){var l=this.getStateNode(h)._transition(f,e,n);l&&(a[h]=l)}}}catch(t){i={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}var d=s(a).map((function(t){return a[t]})),v=g(d.map((function(t){return t.transitions})));if(!d.some((function(t){return t.transitions.length>0})))return this.next(e,n);var p=g(d.map((function(t){return t.entrySet}))),y=g(s(a).map((function(t){return a[t].configuration})));return{transitions:v,entrySet:p,exitSet:g(d.map((function(t){return t.exitSet}))),configuration:y,source:e,actions:g(s(a).map((function(t){return a[t].actions})))}},a.prototype._transition=function(t,e,n){return N(t)?this.transitionLeafNode(t,e,n):1===s(t).length?this.transitionCompoundNode(t,e,n):this.transitionParallelNode(t,e,n)},a.prototype.next=function(t,e){var n,i,a,s=this,u=e.name,h=[],l=[];try{for(var d=r(this.getCandidates(u)),v=d.next();!v.done;v=d.next()){var y=v.value,m=y.cond,x=y.in,S=t.context,w=!x||(N(x)&&Rt(x)?t.matches(f(this.getStateNodeById(x).path,this.delimiter)):c(f(x,this.delimiter),p(this.path.slice(0,-2))(t.value))),b=!1;try{b=!m||R(this.machine,m,S,e,t)}catch(t){throw new Error("Unable to evaluate guard '"+(m.name||m.type)+"' in transition for event '"+u+"' in state node '"+this.id+"':\n"+t.message)}if(b&&w){void 0!==y.target&&(l=y.target),h.push.apply(h,o(y.actions)),a=y;break}}}catch(t){n={error:t}}finally{try{v&&!v.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}if(a){if(!l.length)return{transitions:[a],entrySet:[],exitSet:[],configuration:t.value?[this]:[],source:t,actions:h};var _=g(l.map((function(e){return s.getRelativeStateNodes(e,t.historyValue)}))),E=!!a.internal;return{transitions:[a],entrySet:E?[]:g(_.map((function(t){return s.nodesFromChild(t)}))),exitSet:E?[]:[this],configuration:_,source:t,actions:h}}},a.prototype.nodesFromChild=function(t){if(t.escapes(this))return[];for(var e=[],n=t;n&&n!==this;)e.push(n),n=n.parent;return e.push(this),e},a.prototype.escapes=function(t){if(this===t)return!1;for(var e=this.parent;e;){if(e===t)return!1;e=e.parent}return!0},a.prototype.getActions=function(t,e,n,a){var s,c,u,h,f=B([],a?this.getStateNodes(a.value):[this]),l=t.configuration.length?B(f,t.configuration):f;try{for(var d=r(l),v=d.next();!v.done;v=d.next()){X(f,m=v.value)||t.entrySet.push(m)}}catch(t){s={error:t}}finally{try{v&&!v.done&&(c=d.return)&&c.call(d)}finally{if(s)throw s.error}}try{for(var p=r(f),y=p.next();!y.done;y=p.next()){var m;X(l,m=y.value)&&!X(t.exitSet,m.parent)||t.exitSet.push(m)}}catch(t){u={error:t}}finally{try{y&&!y.done&&(h=p.return)&&h.call(p)}finally{if(u)throw u.error}}t.source||(t.exitSet=[],t.entrySet.push(this));var x=g(t.entrySet.map((function(r){var i=[];if("final"!==r.type)return i;var o=r.parent;if(!o.parent)return i;i.push(Et(r.id,r.doneData),Et(o.id,r.doneData?S(r.doneData,e,n):void 0));var a=o.parent;return"parallel"===a.type&&z(a).every((function(e){return H(t.configuration,e)}))&&i.push(Et(a.id)),i})));t.exitSet.sort((function(t,e){return e.order-t.order})),t.entrySet.sort((function(t,e){return t.order-e.order}));var w=new Set(t.entrySet),b=new Set(t.exitSet),_=i([g(Array.from(w).map((function(t){return o(t.activities.map((function(t){return St(t)})),t.onEntry)}))).concat(x.map(vt)),g(Array.from(b).map((function(t){return o(t.onExit,t.activities.map((function(t){return wt(t)})))})))],2),E=_[0],T=_[1];return lt(T.concat(t.actions).concat(E),this.machine.options.actions)},a.prototype.transition=function(t,e,n){void 0===t&&(t=this.initialState);var r,i,a=D(e);if(t instanceof Pt)r=void 0===n?t:this.resolveState(Pt.from(t,n));else{var s=N(t)?this.resolve(l(this.getResolvedPath(t))):this.resolve(t),c=n||this.machine.context;r=this.resolveState(Pt.from(s,c))}if(this.strict&&!this.events.includes(a.name)&&(i=a.name,!/^(done|error)\./.test(i)))throw new Error("Machine '"+this.id+"' does not accept event '"+a.name+"'");var u=this._transition(r.value,r,a)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:r,actions:[]},h=B([],this.getStateNodes(r.value)),f=u.configuration.length?B(h,u.configuration):h;return u.configuration=o(f),this.resolveTransition(u,r,a)},a.prototype.resolveRaisedTransition=function(t,e,n){var r,i=t.actions;return(t=this.transition(t,e))._event=n,t.event=n.data,(r=t.actions).unshift.apply(r,o(i)),t},a.prototype.resolveTransition=function(n,o,a,c){var u,h,f=this;void 0===a&&(a=ut),void 0===c&&(c=this.machine.context);var l=n.configuration,d=!o||n.transitions.length>0?$(this.machine,l):void 0,v=o?o.historyValue?o.historyValue:n.source?this.machine.historyValue(o.value):void 0:void 0,p=o?o.context:c,y=this.getActions(n,p,a,o),g=o?e({},o.activities):{};try{for(var m=r(y),x=m.next();!x.done;x=m.next()){var w=x.value;w.type===G?g[w.activity.id||w.activity.type]=w:w.type===K&&(g[w.activity.id||w.activity.type]=!1)}}catch(t){u={error:t}}finally{try{x&&!x.done&&(h=m.return)&&h.call(m)}finally{if(u)throw u.error}}var E,T,O=i(At(this,o,p,a,y),2),A=O[0],P=O[1],k=i(b(A,(function(e){return e.type===Q||e.type===W&&e.to===t.SpecialTargets.Internal})),2),I=k[0],V=k[1],C=A.filter((function(t){var e;return t.type===G&&(null===(e=t.activity)||void 0===e?void 0:e.type)===rt})).reduce((function(t,e){return t[e.activity.id]=function(t,e,n,r){var i,o=F(t.src),a=null===(i=null==e?void 0:e.options.services)||void 0===i?void 0:i[o.type],s=t.data?S(t.data,n,r):void 0,c=a?Ct(a,t.id,s):Vt(t.id);return c.meta=t,c}(e.activity,f.machine,P,a),t}),o?e({},o.children):{}),j=d?n.configuration:o?o.configuration:[],L=j.reduce((function(t,e){return void 0!==e.meta&&(t[e.id]=e.meta),t}),{}),D=H(j,this),M=new Pt({value:d||o.value,context:P,_event:a,_sessionid:o?o._sessionid:null,historyValue:d?v?(E=v,T=d,{current:T,states:_(E,T)}):void 0:o?o.historyValue:void 0,history:!d||n.source?o:void 0,actions:d?V:[],activities:d?g:o?o.activities:{},meta:d?L:o?o.meta:void 0,events:[],configuration:j,transitions:n.transitions,children:C,done:D}),R=p!==P;M.changed=a.name===at||R;var U=M.history;if(U&&delete U.history,!d)return M;var z=M;if(!D)for((this._transient||l.some((function(t){return t._transient})))&&(z=this.resolveRaisedTransition(z,{type:Z},a));I.length;){var J=I.shift();z=this.resolveRaisedTransition(z,J._event,a)}var B=z.changed||(U?!!z.actions.length||R||typeof U.value!=typeof z.value||!function t(e,n){if(e===n)return!0;if(void 0===e||void 0===n)return!1;if(N(e)||N(n))return e===n;var r=s(e),i=s(n);return r.length===i.length&&r.every((function(r){return t(e[r],n[r])}))}(z.value,U.value):void 0);return z.changed=B,z.historyValue=M.historyValue,z.history=U,z},a.prototype.getStateNode=function(t){if(Rt(t))return this.machine.getStateNodeById(t);if(!this.states)throw new Error("Unable to retrieve child state '"+t+"' from '"+this.id+"'; no child states exist.");var e=this.states[t];if(!e)throw new Error("Child state '"+t+"' does not exist on '"+this.id+"'");return e},a.prototype.getStateNodeById=function(t){var e=Rt(t)?t.slice("#".length):t;if(e===this.id)return this;var n=this.machine.idMap[e];if(!n)throw new Error("Child state node '#"+e+"' does not exist on machine '"+this.id+"'");return n},a.prototype.getStateNodeByPath=function(t){if("string"==typeof t&&Rt(t))try{return this.getStateNodeById(t.slice(1))}catch(t){}for(var e=h(t,this.delimiter).slice(),n=this;e.length;){var r=e.shift();if(!r.length)break;n=n.getStateNode(r)}return n},a.prototype.resolve=function(t){var e,n=this;if(!t)return this.initialStateValue||Mt;switch(this.type){case"parallel":return d(this.initialStateValue,(function(e,r){return e?n.getStateNode(r).resolve(t[r]||e):Mt}));case"compound":if(N(t)){var r=this.getStateNode(t);return"parallel"===r.type||"compound"===r.type?((e={})[t]=r.initialStateValue,e):t}return s(t).length?d(t,(function(t,e){return t?n.getStateNode(e).resolve(t):Mt})):this.initialStateValue||{};default:return t||Mt}},a.prototype.getResolvedPath=function(t){if(Rt(t)){var e=this.machine.idMap[t.slice("#".length)];if(!e)throw new Error("Unable to find state node '"+t+"'");return e.path}return h(t,this.delimiter)},Object.defineProperty(a.prototype,"initialStateValue",{get:function(){var t,e;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;if("parallel"===this.type)e=v(this.states,(function(t){return t.initialStateValue||Mt}),(function(t){return!("history"===t.type)}));else if(void 0!==this.initial){if(!this.states[this.initial])throw new Error("Initial state '"+this.initial+"' not found on '"+this.key+"'");e=U(this.states[this.initial])?this.initial:((t={})[this.initial]=this.states[this.initial].initialStateValue,t)}return this.__cache.initialStateValue=e,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),a.prototype.getInitialState=function(t,e){var n=this.getStateNodes(t);return this.resolveTransition({configuration:n,entrySet:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,void 0,e)},Object.defineProperty(a.prototype,"initialState",{get:function(){this._init();var t=this.initialStateValue;if(!t)throw new Error("Cannot retrieve initial state from simple state '"+this.id+"'.");return this.getInitialState(t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"target",{get:function(){var t;if("history"===this.type){var e=this.config;t=N(e.target)&&Rt(e.target)?l(this.machine.getStateNodeById(e.target).path.slice(this.path.length-1)):e.target}return t},enumerable:!1,configurable:!0}),a.prototype.getRelativeStateNodes=function(t,e,n){return void 0===n&&(n=!0),n?"history"===t.type?t.resolveHistory(e):t.initialStateNodes:[t]},Object.defineProperty(a.prototype,"initialStateNodes",{get:function(){var t=this;return U(this)?[this]:"compound"!==this.type||this.initial?g(y(this.initialStateValue).map((function(e){return t.getFromRelativePath(e)}))):[this]},enumerable:!1,configurable:!0}),a.prototype.getFromRelativePath=function(t){if(!t.length)return[this];var e=i(t),n=e[0],r=e.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '"+n+"' from node with no states");var o=this.getStateNode(n);if("history"===o.type)return o.resolveHistory();if(!this.states[n])throw new Error("Child state '"+n+"' does not exist on '"+this.id+"'");return this.states[n].getFromRelativePath(r)},a.prototype.historyValue=function(t){if(s(this.states).length)return{current:t||this.initialStateValue,states:v(this.states,(function(e,n){if(!t)return e.historyValue();var r=N(t)?void 0:t[n];return e.historyValue(r||e.initialStateValue)}),(function(t){return!t.history}))}},a.prototype.resolveHistory=function(t){var e=this;if("history"!==this.type)return[this];var n=this.parent;if(!t){var i=this.target;return i?g(y(i).map((function(t){return n.getFromRelativePath(t)}))):n.initialStateNodes}var o,a,s=(o=n.path,a="states",function(t){var e,n,i=t;try{for(var s=r(o),c=s.next();!c.done;c=s.next()){var u=c.value;i=i[a][u]}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return i})(t).current;return N(s)?[n.getStateNode(s)]:g(y(s).map((function(t){return"deep"===e.history?n.getFromRelativePath(t):[n.states[t[0]]]})))},Object.defineProperty(a.prototype,"stateIds",{get:function(){var t=this,e=g(s(this.states).map((function(e){return t.states[e].stateIds})));return[this.id].concat(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"events",{get:function(){var t,e,n,i;if(this.__cache.events)return this.__cache.events;var o=this.states,a=new Set(this.ownEvents);if(o)try{for(var c=r(s(o)),u=c.next();!u.done;u=c.next()){var h=o[u.value];if(h.states)try{for(var f=(n=void 0,r(h.events)),l=f.next();!l.done;l=f.next()){var d=l.value;a.add(""+d)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}return this.__cache.events=Array.from(a)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"ownEvents",{get:function(){var t=new Set(this.transitions.filter((function(t){return!(!t.target&&!t.actions.length&&t.internal)})).map((function(t){return t.eventType})));return Array.from(t)},enumerable:!1,configurable:!0}),a.prototype.resolveTarget=function(t){var e=this;if(void 0!==t)return t.map((function(t){if(!N(t))return t;var n=t[0]===e.delimiter;if(n&&!e.parent)return e.getStateNodeByPath(t.slice(1));var r=n?e.key+t:t;if(!e.parent)return e.getStateNodeByPath(r);try{return e.parent.getStateNodeByPath(r)}catch(t){throw new Error("Invalid transition definition for state node '"+e.id+"':\n"+t.message)}}))},a.prototype.formatTransition=function(t){var n=this,r=function(t){if(void 0!==t&&""!==t)return x(t)}(t.target),i="internal"in t?t.internal:!r||r.some((function(t){return N(t)&&t[0]===n.delimiter})),o=this.machine.options.guards,a=this.resolveTarget(r),s=e(e({},t),{actions:lt(x(t.actions)),cond:O(t.cond,o),target:a,source:this,internal:i,eventType:t.event,toJSON:function(){return e(e({},s),{target:s.target?s.target.map((function(t){return"#"+t.id})):void 0,source:"#"+n.id})}});return s},a.prototype.formatTransitions=function(){var t,e,i,a=this;if(this.config.on)if(Array.isArray(this.config.on))i=this.config.on;else{var c=this.config.on,u=c["*"],h=void 0===u?[]:u,f=n(c,["*"]);i=g(s(f).map((function(t){return M(t,f[t])})).concat(M("*",h)))}else i=[];var l=this.config.always?M("",this.config.always):[],d=this.config.onDone?M(String(Et(this.id)),this.config.onDone):[],v=g(this.invoke.map((function(t){var e=[];return t.onDone&&e.push.apply(e,o(M(String(Tt(t.id)),t.onDone))),t.onError&&e.push.apply(e,o(M(String(Nt(t.id)),t.onError))),e}))),p=this.after,y=g(o(d,v,i,l).map((function(t){return x(t).map((function(t){return a.formatTransition(t)}))})));try{for(var m=r(p),S=m.next();!S.done;S=m.next()){var w=S.value;y.push(w)}}catch(e){t={error:e}}finally{try{S&&!S.done&&(e=m.return)&&e.call(m)}finally{if(t)throw t.error}}return y},a}();var Ut,zt={deferEvents:!1},Jt=function(){function t(t){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=e(e({},zt),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}(),Bt=new Map,qt=0,$t=function(){return"x:"+qt++},Xt=function(t,e){return Bt.set(t,e),t},Ht=function(t){return Bt.get(t)},Gt=function(t){Bt.delete(t)},Kt={sync:!1,autoForward:!1};(Ut=t.InterpreterStatus||(t.InterpreterStatus={}))[Ut.NotStarted=0]="NotStarted",Ut[Ut.Running=1]="Running",Ut[Ut.Stopped=2]="Stopped";var Qt=function(){function n(r,i){var o=this;void 0===i&&(i=n.defaultOptions),this.machine=r,this.scheduler=new Jt,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(E(e))return o.batch(e),o.state;var r=D(L(e,n));if(o.status===t.InterpreterStatus.Stopped)return o.state;if(o.status!==t.InterpreterStatus.Running&&!o.options.deferEvents)throw new Error('Event "'+r.name+'" was sent to uninitialized service "'+o.machine.id+'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: '+JSON.stringify(r.data));return o.scheduler.schedule((function(){o.forward(r);var t=o.nextState(r);o.update(t,r)})),o._state},this.sendTo=function(n,r){var i=o.parent&&(r===t.SpecialTargets.Parent||o.parent.id===r),a=i?o.parent:jt(r)?r:o.children.get(r)||Ht(r);if(a)"machine"in a?a.send(e(e({},n),{name:n.name===ot?""+Nt(o.id):n.name,origin:o.sessionId})):a.send(n.data);else if(!i)throw new Error("Unable to send event to child '"+r+"' from service '"+o.id+"'.")};var a=e(e({},n.defaultOptions),i),s=a.clock,c=a.logger,u=a.parent,h=a.id,f=void 0!==h?h:r.id;this.id=f,this.logger=c,this.clock=s,this.parent=u,this.options=a,this.scheduler=new Jt({deferEvents:this.options.deferEvents}),this.sessionId=$t()}return Object.defineProperty(n.prototype,"initialState",{get:function(){var t=this;return this._initialState?this._initialState:It(this,(function(){return t._initialState=t.machine.initialState,t._initialState}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),n.prototype.execute=function(t,e){var n,i;try{for(var o=r(t.actions),a=o.next();!a.done;a=o.next()){var s=a.value;this.exec(s,t,e)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},n.prototype.update=function(t,e){var n,i,o,a,s,c,u,h,f=this;if(t._sessionid=this.sessionId,this._state=t,this.options.execute&&this.execute(this.state),this.children.forEach((function(t){f.state.children[t.id]=t})),this.devTools&&this.devTools.send(e.data,t),t.event)try{for(var l=r(this.eventListeners),d=l.next();!d.done;d=l.next()){(0,d.value)(t.event)}}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}try{for(var v=r(this.listeners),p=v.next();!p.done;p=v.next()){(0,p.value)(t,t.event)}}catch(t){o={error:t}}finally{try{p&&!p.done&&(a=v.return)&&a.call(v)}finally{if(o)throw o.error}}try{for(var y=r(this.contextListeners),g=y.next();!g.done;g=y.next()){(0,g.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(t){s={error:t}}finally{try{g&&!g.done&&(c=y.return)&&c.call(y)}finally{if(s)throw s.error}}var m=H(t.configuration||[],this.machine);if(this.state.configuration&&m){this.state.configuration.forEach((function(e){var n,i;try{for(var o=r(e.definition.exit),a=o.next();!a.done;a=o.next()){var s=a.value;f.exec(s,t)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}}));var x=t.configuration.find((function(t){return"final"===t.type&&t.parent===f.machine})),w=x&&x.doneData?S(x.doneData,t.context,e):void 0;try{for(var b=r(this.doneListeners),_=b.next();!_.done;_=b.next()){(0,_.value)(Tt(this.id,w))}}catch(t){u={error:t}}finally{try{_&&!_.done&&(h=b.return)&&h.call(b)}finally{if(u)throw u.error}}this.stop()}},n.prototype.onTransition=function(e){return this.listeners.add(e),this.status===t.InterpreterStatus.Running&&e(this.state,this.state.event),this},n.prototype.subscribe=function(e,n,r){var i,o=this;if(!e)return{unsubscribe:function(){}};var a=r;return"function"==typeof e?i=e:(i=e.next.bind(e),a=e.complete.bind(e)),this.listeners.add(i),this.status===t.InterpreterStatus.Running&&i(this.state),a&&this.onDone(a),{unsubscribe:function(){i&&o.listeners.delete(i),a&&o.doneListeners.delete(a)}}},n.prototype.onEvent=function(t){return this.eventListeners.add(t),this},n.prototype.onSend=function(t){return this.sendListeners.add(t),this},n.prototype.onChange=function(t){return this.contextListeners.add(t),this},n.prototype.onStop=function(t){return this.stopListeners.add(t),this},n.prototype.onDone=function(t){return this.doneListeners.add(t),this},n.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},n.prototype.start=function(e){var n=this;if(this.status===t.InterpreterStatus.Running)return this;Xt(this.sessionId,this),this.initialized=!0,this.status=t.InterpreterStatus.Running;var r=void 0===e?this.initialState:It(this,(function(){return!N(t=e)&&"value"in t&&"history"in t?n.machine.resolveState(e):n.machine.resolveState(Pt.from(e,n.machine.context));var t}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){n.update(r,ut)})),this},n.prototype.stop=function(){var e,n,i,o,a,c,u,h,f,l;try{for(var d=r(this.listeners),v=d.next();!v.done;v=d.next()){var p=v.value;this.listeners.delete(p)}}catch(t){e={error:t}}finally{try{v&&!v.done&&(n=d.return)&&n.call(d)}finally{if(e)throw e.error}}try{for(var y=r(this.stopListeners),g=y.next();!g.done;g=y.next()){(p=g.value)(),this.stopListeners.delete(p)}}catch(t){i={error:t}}finally{try{g&&!g.done&&(o=y.return)&&o.call(y)}finally{if(i)throw i.error}}try{for(var m=r(this.contextListeners),x=m.next();!x.done;x=m.next()){p=x.value;this.contextListeners.delete(p)}}catch(t){a={error:t}}finally{try{x&&!x.done&&(c=m.return)&&c.call(m)}finally{if(a)throw a.error}}try{for(var S=r(this.doneListeners),w=S.next();!w.done;w=S.next()){p=w.value;this.doneListeners.delete(p)}}catch(t){u={error:t}}finally{try{w&&!w.done&&(h=S.return)&&h.call(S)}finally{if(u)throw u.error}}this.children.forEach((function(t){T(t.stop)&&t.stop()}));try{for(var b=r(s(this.delayedEventsMap)),_=b.next();!_.done;_=b.next()){var E=_.value;this.clock.clearTimeout(this.delayedEventsMap[E])}}catch(t){f={error:t}}finally{try{_&&!_.done&&(l=b.return)&&l.call(b)}finally{if(f)throw f.error}}return this.scheduler.clear(),this.initialized=!1,this.status=t.InterpreterStatus.Stopped,Gt(this.sessionId),this},n.prototype.batch=function(n){var i=this;if(this.status===t.InterpreterStatus.NotStarted&&this.options.deferEvents);else if(this.status!==t.InterpreterStatus.Running)throw new Error(n.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,a,s=i.state,c=!1,u=[],h=function(t){var n=D(t);i.forward(n),s=It(i,(function(){return i.machine.transition(s,n)})),u.push.apply(u,o(s.actions.map((function(t){return r=s,i=(n=t).exec,e(e({},n),{exec:void 0!==i?function(){return i(r.context,r.event,{action:n,state:r,_event:r._event})}:void 0});var n,r,i})))),c=c||!!s.changed};try{for(var f=r(n),l=f.next();!l.done;l=f.next()){h(l.value)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(a=f.return)&&a.call(f)}finally{if(t)throw t.error}}s.changed=c,s.actions=u,i.update(s,D(n[n.length-1]))}))},n.prototype.sender=function(t){return this.send.bind(this,t)},n.prototype.nextState=function(t){var e=this,n=D(t);if(0===n.name.indexOf(it)&&!this.state.nextEvents.some((function(t){return 0===t.indexOf(it)})))throw n.data.data;return It(this,(function(){return e.machine.transition(e.state,n)}))},n.prototype.forward=function(t){var e,n;try{for(var i=r(this.forwardTo),o=i.next();!o.done;o=i.next()){var a=o.value,s=this.children.get(a);if(!s)throw new Error("Unable to forward event '"+t+"' from interpreter '"+this.id+"' to nonexistant child '"+a+"'.");s.send(t)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},n.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)},n.prototype.cancel=function(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]},n.prototype.exec=function(e,n,r){void 0===r&&(r=this.machine.options.actions);var i=n.context,o=n._event,a=e.exec||ht(e.type,r),s=T(a)?a:a?a.exec:e.exec;if(s)try{return s(i,o.data,{action:e,state:this.state,_event:o})}catch(t){throw this.parent&&this.parent.send({type:"xstate.error",data:t}),t}switch(e.type){case W:var c=e;if("number"==typeof c.delay)return void this.defer(c);c.to?this.sendTo(c._event,c.to):this.send(c._event);break;case Y:this.cancel(e.sendId);break;case G:var u=e.activity;if(!this.state.activities[u.id||u.type])break;if(u.type===t.ActionTypes.Invoke){var h=F(u.src),f=this.machine.options.services?this.machine.options.services[h.type]:void 0,l=u.id,d=u.data,v="autoForward"in u?u.autoForward:!!u.forward;if(!f)return;var p=d?S(d,i,o):void 0,y=T(f)?f(i,o.data,{data:p,src:h}):f;w(y)?this.spawnPromise(Promise.resolve(y),l):T(y)?this.spawnCallback(y,l):A(y)?this.spawnObservable(y,l):k(y)&&this.spawnMachine(p?y.withContext(p):y,{id:l,autoForward:v})}else this.spawnActivity(u);break;case K:this.stopChild(e.activity.id);break;case et:var g=e.label,m=e.value;g?this.logger(g,m):this.logger(m)}},n.prototype.removeChild=function(t){this.children.delete(t),this.forwardTo.delete(t),delete this.state.children[t]},n.prototype.stopChild=function(t){var e=this.children.get(t);e&&(this.removeChild(t),T(e.stop)&&e.stop())},n.prototype.spawn=function(t,n,r){if(w(t))return this.spawnPromise(Promise.resolve(t),n);if(T(t))return this.spawnCallback(t,n);if(jt(t))return this.spawnActor(t);if(A(t))return this.spawnObservable(t,n);if(k(t))return this.spawnMachine(t,e(e({},r),{id:n}));throw new Error('Unable to spawn entity "'+n+'" of type "'+typeof t+'".')},n.prototype.spawnMachine=function(t,r){var i=this;void 0===r&&(r={});var o=new n(t,e(e({},this.options),{parent:this,id:r.id||t.id})),a=e(e({},Kt),r);a.sync&&o.onTransition((function(t){i.send(at,{state:t,id:o.id})}));var s=o;return this.children.set(o.id,s),a.autoForward&&this.forwardTo.add(o.id),o.onDone((function(t){i.removeChild(o.id),i.send(D(t,{origin:o.id}))})).start(),s},n.prototype.spawnPromise=function(t,e){var n=this,r=!1;t.then((function(t){r||(n.removeChild(e),n.send(D(Tt(e,t),{origin:e})))}),(function(t){if(!r){n.removeChild(e);var i=Nt(e,t);try{n.send(D(i,{origin:e}))}catch(t){n.devTools&&n.devTools.send(i,n.state),n.machine.strict&&n.stop()}}}));var i={id:e,send:function(){},subscribe:function(e,n,r){var i=!1;return t.then((function(t){i||(e&&e(t),i||r&&r())}),(function(t){i||n(t)})),{unsubscribe:function(){return i=!0}}},stop:function(){r=!0},toJSON:function(){return{id:e}}};return this.children.set(e,i),i},n.prototype.spawnCallback=function(t,e){var n,r=this,i=!1,o=new Set,a=new Set;try{n=t((function(t){a.forEach((function(e){return e(t)})),i||r.send(t)}),(function(t){o.add(t)}))}catch(t){this.send(Nt(e,t))}if(w(n))return this.spawnPromise(n,e);var s={id:e,send:function(t){return o.forEach((function(e){return e(t)}))},subscribe:function(t){return a.add(t),{unsubscribe:function(){a.delete(t)}}},stop:function(){i=!0,T(n)&&n()},toJSON:function(){return{id:e}}};return this.children.set(e,s),s},n.prototype.spawnObservable=function(t,e){var n=this,r=t.subscribe((function(t){n.send(D(t,{origin:e}))}),(function(t){n.removeChild(e),n.send(D(Nt(e,t),{origin:e}))}),(function(){n.removeChild(e),n.send(D(Tt(e),{origin:e}))})),i={id:e,send:function(){},subscribe:function(e,n,r){return t.subscribe(e,n,r)},stop:function(){return r.unsubscribe()},toJSON:function(){return{id:e}}};return this.children.set(e,i),i},n.prototype.spawnActor=function(t){return this.children.set(t.id,t),t},n.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)}},n.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}}})},n.prototype.attachDev=function(){if(this.options.devTools&&"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){var t="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=window.__REDUX_DEVTOOLS_EXTENSION__.connect(e(e({name:this.id,autoPause:!0,stateSanitizer:function(t){return{value:t.value,context:t.context,actions:t.actions}}},t),{features:e({jump:!1,skip:!1},t?t.features:void 0)}),this.machine),this.devTools.init(this.state)}},n.prototype.toJSON=function(){return{id:this.id}},n.prototype[P]=function(){return this},n.defaultOptions=function(t){return{execute:!0,deferEvents:!0,clock:{setTimeout:function(e,n){return t.setTimeout.call(null,e,n)},clearTimeout:function(e){return t.clearTimeout.call(null,e)}},logger:t.console.log.bind(console),devTools:!1}}("undefined"!=typeof self?self:global),n.interpret=Wt,n}();function Wt(t,e){return new Qt(t,e)}var Yt={raise:vt,send:pt,sendParent:yt,sendUpdate:gt,log:function(t,e){return void 0===t&&(t=mt),{type:et,label:e,expr:t}},cancel:xt,start:St,stop:wt,assign:bt,after:_t,done:Et,respond:function(t,n){return pt(t,e(e({},n),{to:function(t,e,n){return n._event.origin}}))},forwardTo:Ot,escalate:function(n,r){return yt((function(t,e,r){return{type:ot,data:T(n)?n(t,e,r):n}}),e(e({},r),{to:t.SpecialTargets.Parent}))},choose:function(e){return{type:t.ActionTypes.Choose,conds:e}},pure:function(e){return{type:t.ActionTypes.Pure,get:e}}};t.Interpreter=Qt,t.Machine=function(t,e,n){void 0===n&&(n=t.context);var r="function"==typeof n?n():n;return new Ft(t,e,r)},t.State=Pt,t.StateNode=Ft,t.actions=Yt,t.assign=bt,t.createMachine=function(t,e){var n="function"==typeof t.context?t.context():t.context;return new Ft(t,e,n)},t.doneInvoke=Tt,t.forwardTo=Ot,t.interpret=Wt,t.mapState=function(t,e){var n,i,o;try{for(var a=r(s(t)),u=a.next();!u.done;u=a.next()){var h=u.value;c(h,e)&&(!o||e.length>o.length)&&(o=h)}}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return t[o]},t.matchState=function(t,e,n){var o,a,s=Pt.from(t,t instanceof Pt?t.context:void 0);try{for(var c=r(e),u=c.next();!u.done;u=c.next()){var h=i(u.value,2),f=h[0],l=h[1];if(s.matches(f))return l(s)}}catch(t){o={error:t}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(o)throw o.error}}return n(s)},t.matchesState=c,t.send=pt,t.sendParent=yt,t.sendUpdate=gt,t.spawn=function(t,n){var r=function(t){return N(t)?e(e({},Kt),{name:t}):e(e(e({},Kt),{name:j()}),t)}(n);return function(e){return e?e.spawn(t,r.name,r):Ct(t,r.name)}(kt[kt.length-1])},Object.defineProperty(t,"__esModule",{value:!0})}));
15
+ ***************************************************************************** */var e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function r(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function i(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function o(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}var a={};function s(t){return Object.keys(t)}function c(t,e,n){void 0===n&&(n=".");var r=f(t,n),i=f(e,n);return N(i)?!!N(r)&&i===r:N(r)?r in i:s(r).every((function(t){return t in i&&c(r[t],i[t])}))}function u(t){try{return N(t)||"number"==typeof t?""+t:t.type}catch(t){throw new Error("Events must be strings or objects with a string event.type property.")}}function h(t,e){try{return E(t)?t:t.toString().split(e)}catch(e){throw new Error("'"+t+"' is not a valid state path.")}}function f(t,e){return"object"==typeof(n=t)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?t.value:E(t)?l(t):"string"!=typeof t?t:l(h(t,e));var n}function l(t){if(1===t.length)return t[0];for(var e={},n=e,r=0;r<t.length-1;r++)r===t.length-2?n[t[r]]=t[r+1]:(n[t[r]]={},n=n[t[r]]);return e}function d(t,e){for(var n={},r=s(t),i=0;i<r.length;i++){var o=r[i];n[o]=e(t[o],o,t,i)}return n}function p(t,e,n){var i,o,a={};try{for(var c=r(s(t)),u=c.next();!u.done;u=c.next()){var h=u.value,f=t[h];n(f)&&(a[h]=e(f,h,t))}}catch(t){i={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}return a}var v=function(t){return function(e){var n,i,o=e;try{for(var a=r(t),s=a.next();!s.done;s=a.next()){o=o[s.value]}}catch(t){n={error:t}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return o}};function y(t){return t?N(t)?[[t]]:g(s(t).map((function(e){var n=t[e];return"string"==typeof n||n&&Object.keys(n).length?y(t[e]).map((function(t){return[e].concat(t)})):[[e]]}))):[[]]}function g(t){var e;return(e=[]).concat.apply(e,o(t))}function m(t){return E(t)?t:[t]}function x(t){return void 0===t?[]:m(t)}function S(t,e,n){var i,o;if(T(t))return t(e,n.data);var a={};try{for(var s=r(Object.keys(t)),c=s.next();!c.done;c=s.next()){var u=c.value,h=t[u];T(h)?a[u]=h(e,n.data):a[u]=h}}catch(t){i={error:t}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return a}function w(t){return t instanceof Promise||!(null===t||!T(t)&&"object"!=typeof t||!T(t.then))}function b(t,e){var n,o,a=i([[],[]],2),s=a[0],c=a[1];try{for(var u=r(t),h=u.next();!h.done;h=u.next()){var f=h.value;e(f)?s.push(f):c.push(f)}}catch(t){n={error:t}}finally{try{h&&!h.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}return[s,c]}function _(t,e){return d(t.states,(function(t,n){if(t){var r=(N(e)?void 0:e[n])||(t?t.current:void 0);if(r)return{current:r,states:_(t,r)}}}))}function E(t){return Array.isArray(t)}function T(t){return"function"==typeof t}function N(t){return"string"==typeof t}function O(t,e){if(t)return N(t)?{type:"xstate.guard",name:t,predicate:e?e[t]:void 0}:T(t)?{type:"xstate.guard",name:t.name,predicate:t}:t}function A(t){try{return"subscribe"in t&&T(t.subscribe)}catch(t){return!1}}var P="function"==typeof Symbol&&Symbol.observable||"@@observable";function k(t){try{return"__xstatenode"in t}catch(t){return!1}}var I,j,C,V=(I=0,function(){return(++I).toString(16)});function L(t,n){return N(t)||"number"==typeof t?e({type:t},n):t}function D(t,n){if(!N(t)&&"$$type"in t&&"scxml"===t.$$type)return t;var r=L(t);return e({name:r.type,data:r,$$type:"scxml",type:"external"},n)}function M(t,n){return m(n).map((function(n){return void 0===n||"string"==typeof n||k(n)?{target:n,event:t}:e(e({},n),{event:t})}))}function R(t,e,n,r,i){var o=t.options.guards,a={state:i,cond:e,_event:r};if("xstate.guard"===e.type)return e.predicate(n,r.data,a);var s=o[e.type];if(!s)throw new Error("Guard '"+e.type+"' is not implemented on machine '"+t.id+"'.");return s(n,r.data,a)}function F(t){return"string"==typeof t?{type:t}:t}(j=t.ActionTypes||(t.ActionTypes={})).Start="xstate.start",j.Stop="xstate.stop",j.Raise="xstate.raise",j.Send="xstate.send",j.Cancel="xstate.cancel",j.NullEvent="",j.Assign="xstate.assign",j.After="xstate.after",j.DoneState="done.state",j.DoneInvoke="done.invoke",j.Log="xstate.log",j.Init="xstate.init",j.Invoke="xstate.invoke",j.ErrorExecution="error.execution",j.ErrorCommunication="error.communication",j.ErrorPlatform="error.platform",j.ErrorCustom="xstate.error",j.Update="xstate.update",j.Pure="xstate.pure",j.Choose="xstate.choose",(C=t.SpecialTargets||(t.SpecialTargets={})).Parent="#_parent",C.Internal="#_internal";var U=function(t){return"atomic"===t.type||"final"===t.type};function z(t){return s(t.states).map((function(e){return t.states[e]}))}function J(t){var e=[t];return U(t)?e:e.concat(g(z(t).map(J)))}function B(t,e){var n,i,o,a,s,c,u,h,f=q(new Set(t)),l=new Set(e);try{for(var d=r(l),p=d.next();!p.done;p=d.next())for(var v=(E=p.value).parent;v&&!l.has(v);)l.add(v),v=v.parent}catch(t){n={error:t}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}var y=q(l);try{for(var g=r(l),m=g.next();!m.done;m=g.next()){if("compound"!==(E=m.value).type||y.get(E)&&y.get(E).length){if("parallel"===E.type)try{for(var x=(s=void 0,r(z(E))),S=x.next();!S.done;S=x.next()){var w=S.value;"history"!==w.type&&(l.has(w)||(l.add(w),f.get(w)?f.get(w).forEach((function(t){return l.add(t)})):w.initialStateNodes.forEach((function(t){return l.add(t)}))))}}catch(t){s={error:t}}finally{try{S&&!S.done&&(c=x.return)&&c.call(x)}finally{if(s)throw s.error}}}else f.get(E)?f.get(E).forEach((function(t){return l.add(t)})):E.initialStateNodes.forEach((function(t){return l.add(t)}))}}catch(t){o={error:t}}finally{try{m&&!m.done&&(a=g.return)&&a.call(g)}finally{if(o)throw o.error}}try{for(var b=r(l),_=b.next();!_.done;_=b.next()){var E;for(v=(E=_.value).parent;v&&!l.has(v);)l.add(v),v=v.parent}}catch(t){u={error:t}}finally{try{_&&!_.done&&(h=b.return)&&h.call(b)}finally{if(u)throw u.error}}return l}function q(t){var e,n,i=new Map;try{for(var o=r(t),a=o.next();!a.done;a=o.next()){var s=a.value;i.has(s)||i.set(s,[]),s.parent&&(i.has(s.parent)||i.set(s.parent,[]),i.get(s.parent).push(s))}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return i}function $(t,e){return function t(e,n){var r=n.get(e);if(!r)return{};if("compound"===e.type){var i=r[0];if(!i)return{};if(U(i))return i.key}var o={};return r.forEach((function(e){o[e.key]=t(e,n)})),o}(t,q(B([t],e)))}function X(t,e){return Array.isArray(t)?t.some((function(t){return t===e})):t instanceof Set&&t.has(e)}function H(t,e){return"compound"===e.type?z(e).some((function(e){return"final"===e.type&&X(t,e)})):"parallel"===e.type&&z(e).every((function(e){return H(t,e)}))}var G=t.ActionTypes.Start,K=t.ActionTypes.Stop,Q=t.ActionTypes.Raise,W=t.ActionTypes.Send,Y=t.ActionTypes.Cancel,Z=t.ActionTypes.NullEvent,tt=t.ActionTypes.Assign,et=(t.ActionTypes.After,t.ActionTypes.DoneState,t.ActionTypes.Log),nt=t.ActionTypes.Init,rt=t.ActionTypes.Invoke,it=(t.ActionTypes.ErrorExecution,t.ActionTypes.ErrorPlatform),ot=t.ActionTypes.ErrorCustom,at=t.ActionTypes.Update,st=t.ActionTypes.Choose,ct=t.ActionTypes.Pure,ut=D({type:nt});function ht(t,e){return e&&e[t]||void 0}function ft(t,n){var r;if(N(t)||"number"==typeof t){var i=ht(t,n);r=T(i)?{type:t,exec:i}:i||{type:t,exec:void 0}}else if(T(t))r={type:t.name||t.toString(),exec:t};else{if(T(i=ht(t.type,n)))r=e(e({},t),{exec:i});else if(i){var o=i.type||t.type;r=e(e(e({},i),t),{type:o})}else r=t}return Object.defineProperty(r,"toString",{value:function(){return r.type},enumerable:!1,configurable:!0}),r}var lt=function(t,e){return t?(E(t)?t:[t]).map((function(t){return ft(t,e)})):[]};function dt(t){var n=ft(t);return e(e({id:N(t)?t:n.id},n),{type:n.type})}function pt(e){return N(e)?{type:Q,event:e}:vt(e,{to:t.SpecialTargets.Internal})}function vt(t,e){return{to:e?e.to:void 0,type:W,event:T(t)?t:L(t),delay:e?e.delay:void 0,id:e&&void 0!==e.id?e.id:T(t)?t.name:u(t)}}function yt(n,r){return vt(n,e(e({},r),{to:t.SpecialTargets.Parent}))}function gt(){return yt(at)}var mt=function(t,e){return{context:t,event:e}};var xt=function(t){return{type:Y,sendId:t}};function St(e){var n=dt(e);return{type:t.ActionTypes.Start,activity:n,exec:void 0}}function wt(e){var n=T(e)?e:dt(e);return{type:t.ActionTypes.Stop,activity:n,exec:void 0}}var bt=function(t){return{type:tt,assignment:t}};function _t(e,n){var r=n?"#"+n:"";return t.ActionTypes.After+"("+e+")"+r}function Et(e,n){var r=t.ActionTypes.DoneState+"."+e,i={type:r,data:n,toString:function(){return r}};return i}function Tt(e,n){var r=t.ActionTypes.DoneInvoke+"."+e,i={type:r,data:n,toString:function(){return r}};return i}function Nt(e,n){var r=t.ActionTypes.ErrorPlatform+"."+e,i={type:r,data:n,toString:function(){return r}};return i}function Ot(t,n){return vt((function(t,e){return e}),e(e({},n),{to:t}))}function At(n,o,a,c,u){var h=i(b(u,(function(t){return t.type===tt})),2),f=h[0],l=h[1],d=f.length?function(t,e,n,i){return t?n.reduce((function(t,n){var o,a,c=n.assignment,u={state:i,action:n,_event:e},h={};if(T(c))h=c(t,e.data,u);else try{for(var f=r(s(c)),l=f.next();!l.done;l=f.next()){var d=l.value,p=c[d];h[d]=T(p)?p(t,e.data,u):p}}catch(t){o={error:t}}finally{try{l&&!l.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}return Object.assign({},t,h)}),t):t}(a,c,f,o):a;return[g(l.map((function(r){var i;switch(r.type){case Q:return{type:Q,_event:D(r.event)};case W:return function(t,n,r,i){var o,a={_event:r},s=D(T(t.event)?t.event(n,r.data,a):t.event);if(N(t.delay)){var c=i&&i[t.delay];o=T(c)?c(n,r.data,a):c}else o=T(t.delay)?t.delay(n,r.data,a):t.delay;var u=T(t.to)?t.to(n,r.data,a):t.to;return e(e({},t),{to:u,_event:s,event:s.data,delay:o})}(r,d,c,n.options.delays);case et:return function(t,n,r){return e(e({},t),{value:N(t.expr)?t.expr:t.expr(n,r.data,{_event:r})})}(r,d,c);case st:if(!(s=null===(i=r.conds.find((function(t){var e=O(t.cond,n.options.guards);return!e||R(n,e,d,c,o)})))||void 0===i?void 0:i.actions))return[];var a=At(n,o,d,c,lt(x(s),n.options.actions));return d=a[1],a[0];case ct:var s;if(!(s=r.get(d,c.data)))return[];a=At(n,o,d,c,lt(x(s),n.options.actions));return d=a[1],a[0];case K:return function(e,n,r){var i=T(e.activity)?e.activity(n,r.data):e.activity,o="string"==typeof i?{id:i}:i;return{type:t.ActionTypes.Stop,activity:o}}(r,d,c);default:return ft(r,n.options.actions)}}))),d]}var Pt=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 t=e.configuration,g(o(new Set(t.map((function(t){return t.ownEvents})))));var t}})}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:ut,_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 r=ut;return new t({value:e.value,context:n,_event:r,_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="."),N(t))return[t];var r=s(t);return r.concat.apply(r,o(r.map((function(r){return n.toStrings(t[r],e).map((function(t){return r+e+t}))}))))},t.prototype.toJSON=function(){this.configuration,this.transitions;return n(this,["configuration","transitions"])},t.prototype.matches=function(t){return c(t,this.value)},t}(),kt=[],It=function(t,e){kt.push(t);var n=e(t);return kt.pop(),n};function jt(t){return{id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},toJSON:function(){return{id:t}}}}function Ct(t,e,n){var r=jt(e);return r.deferred=!0,k(t)&&(r.state=It(void 0,(function(){return(n?t.withContext(n):t).initialState}))),r}function Vt(t){if("string"==typeof t){var e={type:t,toString:function(){return t}};return e}return t}function Lt(t){return e(e({type:rt},t),{toJSON:function(){t.onDone,t.onError;var r=n(t,["onDone","onError"]);return e(e({},r),{type:rt,src:Vt(t.src)})}})}var Dt={},Mt=function(t){return"#"===t[0]},Rt=function(){function a(t,n,i){var c=this;this.config=t,this.context=i,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.options=Object.assign({actions:{},guards:{},services:{},activities:{},delays:{}},n),this.parent=this.options._parent,this.key=this.config.key||this.options._key||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:"."),this.id=this.config.id||o([this.machine.key],this.path).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&s(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.initial=this.config.initial,this.states=this.config.states?d(this.config.states,(function(t,n){var r,i=new a(t,{_parent:c,_key:n});return Object.assign(c.idMap,e(((r={})[i.id]=i,r),i.idMap)),i})):Dt;var u=0;!function t(e){var n,i;e.order=u++;try{for(var o=r(z(e)),a=o.next();!a.done;a=o.next()){t(a.value)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}}(this),this.history=!0===this.config.history?"shallow":this.config.history||!1,this._transient=!!this.config.always||!!this.config.on&&(Array.isArray(this.config.on)?this.config.on.some((function(t){return""===t.event})):""in this.config.on),this.strict=!!this.config.strict,this.onEntry=x(this.config.entry||this.config.onEntry).map((function(t){return ft(t)})),this.onExit=x(this.config.exit||this.config.onExit).map((function(t){return ft(t)})),this.meta=this.config.meta,this.doneData="final"===this.type?this.config.data:void 0,this.invoke=x(this.config.invoke).map((function(t,n){var r,i;if(k(t))return c.machine.options.services=e(((r={})[t.id]=t,r),c.machine.options.services),Lt({src:t.id,id:t.id});if(N(t.src))return Lt(e(e({},t),{id:t.id||t.src,src:t.src}));if(k(t.src)||T(t.src)){var o=c.id+":invocation["+n+"]";return c.machine.options.services=e(((i={})[o]=t.src,i),c.machine.options.services),Lt(e(e({id:o},t),{src:o}))}var a=t.src;return Lt(e(e({id:a.type},t),{src:a}))})),this.activities=x(this.config.activities).concat(this.invoke).map((function(t){return dt(t)})),this.transition=this.transition.bind(this)}return a.prototype._init=function(){this.__cache.transitions||J(this).forEach((function(t){return t.on}))},a.prototype.withConfig=function(t,n){void 0===n&&(n=this.context);var r=this.options,i=r.actions,o=r.activities,s=r.guards,c=r.services,u=r.delays;return new a(this.config,{actions:e(e({},i),t.actions),activities:e(e({},o),t.activities),guards:e(e({},s),t.guards),services:e(e({},c),t.services),delays:e(e({},u),t.delays)},n)},a.prototype.withContext=function(t){return new a(this.config,this.options,t)},Object.defineProperty(a.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:d(this.states,(function(t){return t.definition})),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke}},enumerable:!1,configurable:!0}),a.prototype.toJSON=function(){return this.definition},Object.defineProperty(a.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var t=this.transitions;return this.__cache.on=t.reduce((function(t,e){return t[e.eventType]=t[e.eventType]||[],t[e.eventType].push(e),t}),{})},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),a.prototype.getCandidates=function(t){if(this.__cache.candidates[t])return this.__cache.candidates[t];var e=""===t,n=this.transitions.filter((function(n){var r=n.eventType===t;return e?r:r||"*"===n.eventType}));return this.__cache.candidates[t]=n,n},a.prototype.getDelayedTransitions=function(){var t=this,n=this.config.after;if(!n)return[];var r=function(e,n){var r=_t(T(e)?t.id+":delay["+n+"]":e,t.id);return t.onEntry.push(vt(r,{delay:e})),t.onExit.push(xt(r)),r};return(E(n)?n.map((function(t,n){var i=r(t.delay,n);return e(e({},t),{event:i})})):g(s(n).map((function(t,i){var o=n[t],a=N(o)?{target:o}:o,s=isNaN(+t)?t:+t,c=r(s,i);return x(a).map((function(t){return e(e({},t),{event:c,delay:s})}))})))).map((function(n){var r=n.delay;return e(e({},t.formatTransition(n)),{delay:r})}))},a.prototype.getStateNodes=function(t){var e,n=this;if(!t)return[];var r=t instanceof Pt?t.value:f(t,this.delimiter);if(N(r)){var i=this.getStateNode(r).initial;return void 0!==i?this.getStateNodes(((e={})[r]=i,e)):[this.states[r]]}var o=s(r);return o.map((function(t){return n.getStateNode(t)})).concat(o.reduce((function(t,e){var i=n.getStateNode(e).getStateNodes(r[e]);return t.concat(i)}),[]))},a.prototype.handles=function(t){var e=u(t);return this.events.includes(e)},a.prototype.resolveState=function(t){var n=Array.from(B([],this.getStateNodes(t.value)));return new Pt(e(e({},t),{value:this.resolve(t.value),configuration:n}))},a.prototype.transitionLeafNode=function(t,e,n){var r=this.getStateNode(t).next(e,n);return r&&r.transitions.length?r:this.next(e,n)},a.prototype.transitionCompoundNode=function(t,e,n){var r=s(t),i=this.getStateNode(r[0])._transition(t[r[0]],e,n);return i&&i.transitions.length?i:this.next(e,n)},a.prototype.transitionParallelNode=function(t,e,n){var i,o,a={};try{for(var c=r(s(t)),u=c.next();!u.done;u=c.next()){var h=u.value,f=t[h];if(f){var l=this.getStateNode(h)._transition(f,e,n);l&&(a[h]=l)}}}catch(t){i={error:t}}finally{try{u&&!u.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}var d=s(a).map((function(t){return a[t]})),p=g(d.map((function(t){return t.transitions})));if(!d.some((function(t){return t.transitions.length>0})))return this.next(e,n);var v=g(d.map((function(t){return t.entrySet}))),y=g(s(a).map((function(t){return a[t].configuration})));return{transitions:p,entrySet:v,exitSet:g(d.map((function(t){return t.exitSet}))),configuration:y,source:e,actions:g(s(a).map((function(t){return a[t].actions})))}},a.prototype._transition=function(t,e,n){return N(t)?this.transitionLeafNode(t,e,n):1===s(t).length?this.transitionCompoundNode(t,e,n):this.transitionParallelNode(t,e,n)},a.prototype.next=function(t,e){var n,i,a,s=this,u=e.name,h=[],l=[];try{for(var d=r(this.getCandidates(u)),p=d.next();!p.done;p=d.next()){var y=p.value,m=y.cond,x=y.in,S=t.context,w=!x||(N(x)&&Mt(x)?t.matches(f(this.getStateNodeById(x).path,this.delimiter)):c(f(x,this.delimiter),v(this.path.slice(0,-2))(t.value))),b=!1;try{b=!m||R(this.machine,m,S,e,t)}catch(t){throw new Error("Unable to evaluate guard '"+(m.name||m.type)+"' in transition for event '"+u+"' in state node '"+this.id+"':\n"+t.message)}if(b&&w){void 0!==y.target&&(l=y.target),h.push.apply(h,o(y.actions)),a=y;break}}}catch(t){n={error:t}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}if(a){if(!l.length)return{transitions:[a],entrySet:[],exitSet:[],configuration:t.value?[this]:[],source:t,actions:h};var _=g(l.map((function(e){return s.getRelativeStateNodes(e,t.historyValue)}))),E=!!a.internal;return{transitions:[a],entrySet:E?[]:g(_.map((function(t){return s.nodesFromChild(t)}))),exitSet:E?[]:[this],configuration:_,source:t,actions:h}}},a.prototype.nodesFromChild=function(t){if(t.escapes(this))return[];for(var e=[],n=t;n&&n!==this;)e.push(n),n=n.parent;return e.push(this),e},a.prototype.escapes=function(t){if(this===t)return!1;for(var e=this.parent;e;){if(e===t)return!1;e=e.parent}return!0},a.prototype.getActions=function(t,e,n,a){var s,c,u,h,f=B([],a?this.getStateNodes(a.value):[this]),l=t.configuration.length?B(f,t.configuration):f;try{for(var d=r(l),p=d.next();!p.done;p=d.next()){X(f,m=p.value)||t.entrySet.push(m)}}catch(t){s={error:t}}finally{try{p&&!p.done&&(c=d.return)&&c.call(d)}finally{if(s)throw s.error}}try{for(var v=r(f),y=v.next();!y.done;y=v.next()){var m;X(l,m=y.value)&&!X(t.exitSet,m.parent)||t.exitSet.push(m)}}catch(t){u={error:t}}finally{try{y&&!y.done&&(h=v.return)&&h.call(v)}finally{if(u)throw u.error}}t.source||(t.exitSet=[],t.entrySet.push(this));var x=g(t.entrySet.map((function(r){var i=[];if("final"!==r.type)return i;var o=r.parent;if(!o.parent)return i;i.push(Et(r.id,r.doneData),Et(o.id,r.doneData?S(r.doneData,e,n):void 0));var a=o.parent;return"parallel"===a.type&&z(a).every((function(e){return H(t.configuration,e)}))&&i.push(Et(a.id)),i})));t.exitSet.sort((function(t,e){return e.order-t.order})),t.entrySet.sort((function(t,e){return t.order-e.order}));var w=new Set(t.entrySet),b=new Set(t.exitSet),_=i([g(Array.from(w).map((function(t){return o(t.activities.map((function(t){return St(t)})),t.onEntry)}))).concat(x.map(pt)),g(Array.from(b).map((function(t){return o(t.onExit,t.activities.map((function(t){return wt(t)})))})))],2),E=_[0],T=_[1];return lt(T.concat(t.actions).concat(E),this.machine.options.actions)},a.prototype.transition=function(t,e,n){void 0===t&&(t=this.initialState);var r,i,a=D(e);if(t instanceof Pt)r=void 0===n?t:this.resolveState(Pt.from(t,n));else{var s=N(t)?this.resolve(l(this.getResolvedPath(t))):this.resolve(t),c=n||this.machine.context;r=this.resolveState(Pt.from(s,c))}if(this.strict&&!this.events.includes(a.name)&&(i=a.name,!/^(done|error)\./.test(i)))throw new Error("Machine '"+this.id+"' does not accept event '"+a.name+"'");var u=this._transition(r.value,r,a)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:r,actions:[]},h=B([],this.getStateNodes(r.value)),f=u.configuration.length?B(h,u.configuration):h;return u.configuration=o(f),this.resolveTransition(u,r,a)},a.prototype.resolveRaisedTransition=function(t,e,n){var r,i=t.actions;return(t=this.transition(t,e))._event=n,t.event=n.data,(r=t.actions).unshift.apply(r,o(i)),t},a.prototype.resolveTransition=function(n,o,a,c){var u,h,f=this;void 0===a&&(a=ut),void 0===c&&(c=this.machine.context);var l=n.configuration,d=!o||n.transitions.length>0?$(this.machine,l):void 0,p=o?o.historyValue?o.historyValue:n.source?this.machine.historyValue(o.value):void 0:void 0,v=o?o.context:c,y=this.getActions(n,v,a,o),g=o?e({},o.activities):{};try{for(var m=r(y),x=m.next();!x.done;x=m.next()){var w=x.value;w.type===G?g[w.activity.id||w.activity.type]=w:w.type===K&&(g[w.activity.id||w.activity.type]=!1)}}catch(t){u={error:t}}finally{try{x&&!x.done&&(h=m.return)&&h.call(m)}finally{if(u)throw u.error}}var E,T,O=i(At(this,o,v,a,y),2),A=O[0],P=O[1],k=i(b(A,(function(e){return e.type===Q||e.type===W&&e.to===t.SpecialTargets.Internal})),2),I=k[0],j=k[1],C=A.filter((function(t){var e;return t.type===G&&(null===(e=t.activity)||void 0===e?void 0:e.type)===rt})).reduce((function(t,e){return t[e.activity.id]=function(t,e,n,r){var i,o=F(t.src),a=null===(i=null==e?void 0:e.options.services)||void 0===i?void 0:i[o.type],s=t.data?S(t.data,n,r):void 0,c=a?Ct(a,t.id,s):jt(t.id);return c.meta=t,c}(e.activity,f.machine,P,a),t}),o?e({},o.children):{}),V=d?n.configuration:o?o.configuration:[],L=V.reduce((function(t,e){return void 0!==e.meta&&(t[e.id]=e.meta),t}),{}),D=H(V,this),M=new Pt({value:d||o.value,context:P,_event:a,_sessionid:o?o._sessionid:null,historyValue:d?p?(E=p,T=d,{current:T,states:_(E,T)}):void 0:o?o.historyValue:void 0,history:!d||n.source?o:void 0,actions:d?j:[],activities:d?g:o?o.activities:{},meta:d?L:o?o.meta:void 0,events:[],configuration:V,transitions:n.transitions,children:C,done:D}),R=v!==P;M.changed=a.name===at||R;var U=M.history;if(U&&delete U.history,!d)return M;var z=M;if(!D)for((this._transient||l.some((function(t){return t._transient})))&&(z=this.resolveRaisedTransition(z,{type:Z},a));I.length;){var J=I.shift();z=this.resolveRaisedTransition(z,J._event,a)}var B=z.changed||(U?!!z.actions.length||R||typeof U.value!=typeof z.value||!function t(e,n){if(e===n)return!0;if(void 0===e||void 0===n)return!1;if(N(e)||N(n))return e===n;var r=s(e),i=s(n);return r.length===i.length&&r.every((function(r){return t(e[r],n[r])}))}(z.value,U.value):void 0);return z.changed=B,z.history=U,z},a.prototype.getStateNode=function(t){if(Mt(t))return this.machine.getStateNodeById(t);if(!this.states)throw new Error("Unable to retrieve child state '"+t+"' from '"+this.id+"'; no child states exist.");var e=this.states[t];if(!e)throw new Error("Child state '"+t+"' does not exist on '"+this.id+"'");return e},a.prototype.getStateNodeById=function(t){var e=Mt(t)?t.slice("#".length):t;if(e===this.id)return this;var n=this.machine.idMap[e];if(!n)throw new Error("Child state node '#"+e+"' does not exist on machine '"+this.id+"'");return n},a.prototype.getStateNodeByPath=function(t){if("string"==typeof t&&Mt(t))try{return this.getStateNodeById(t.slice(1))}catch(t){}for(var e=h(t,this.delimiter).slice(),n=this;e.length;){var r=e.shift();if(!r.length)break;n=n.getStateNode(r)}return n},a.prototype.resolve=function(t){var e,n=this;if(!t)return this.initialStateValue||Dt;switch(this.type){case"parallel":return d(this.initialStateValue,(function(e,r){return e?n.getStateNode(r).resolve(t[r]||e):Dt}));case"compound":if(N(t)){var r=this.getStateNode(t);return"parallel"===r.type||"compound"===r.type?((e={})[t]=r.initialStateValue,e):t}return s(t).length?d(t,(function(t,e){return t?n.getStateNode(e).resolve(t):Dt})):this.initialStateValue||{};default:return t||Dt}},a.prototype.getResolvedPath=function(t){if(Mt(t)){var e=this.machine.idMap[t.slice("#".length)];if(!e)throw new Error("Unable to find state node '"+t+"'");return e.path}return h(t,this.delimiter)},Object.defineProperty(a.prototype,"initialStateValue",{get:function(){var t,e;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;if("parallel"===this.type)e=p(this.states,(function(t){return t.initialStateValue||Dt}),(function(t){return!("history"===t.type)}));else if(void 0!==this.initial){if(!this.states[this.initial])throw new Error("Initial state '"+this.initial+"' not found on '"+this.key+"'");e=U(this.states[this.initial])?this.initial:((t={})[this.initial]=this.states[this.initial].initialStateValue,t)}return this.__cache.initialStateValue=e,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),a.prototype.getInitialState=function(t,e){var n=this.getStateNodes(t);return this.resolveTransition({configuration:n,entrySet:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,void 0,e)},Object.defineProperty(a.prototype,"initialState",{get:function(){this._init();var t=this.initialStateValue;if(!t)throw new Error("Cannot retrieve initial state from simple state '"+this.id+"'.");return this.getInitialState(t)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"target",{get:function(){var t;if("history"===this.type){var e=this.config;t=N(e.target)&&Mt(e.target)?l(this.machine.getStateNodeById(e.target).path.slice(this.path.length-1)):e.target}return t},enumerable:!1,configurable:!0}),a.prototype.getRelativeStateNodes=function(t,e,n){return void 0===n&&(n=!0),n?"history"===t.type?t.resolveHistory(e):t.initialStateNodes:[t]},Object.defineProperty(a.prototype,"initialStateNodes",{get:function(){var t=this;return U(this)?[this]:"compound"!==this.type||this.initial?g(y(this.initialStateValue).map((function(e){return t.getFromRelativePath(e)}))):[this]},enumerable:!1,configurable:!0}),a.prototype.getFromRelativePath=function(t){if(!t.length)return[this];var e=i(t),n=e[0],r=e.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '"+n+"' from node with no states");var o=this.getStateNode(n);if("history"===o.type)return o.resolveHistory();if(!this.states[n])throw new Error("Child state '"+n+"' does not exist on '"+this.id+"'");return this.states[n].getFromRelativePath(r)},a.prototype.historyValue=function(t){if(s(this.states).length)return{current:t||this.initialStateValue,states:p(this.states,(function(e,n){if(!t)return e.historyValue();var r=N(t)?void 0:t[n];return e.historyValue(r||e.initialStateValue)}),(function(t){return!t.history}))}},a.prototype.resolveHistory=function(t){var e=this;if("history"!==this.type)return[this];var n=this.parent;if(!t){var i=this.target;return i?g(y(i).map((function(t){return n.getFromRelativePath(t)}))):n.initialStateNodes}var o,a,s=(o=n.path,a="states",function(t){var e,n,i=t;try{for(var s=r(o),c=s.next();!c.done;c=s.next()){var u=c.value;i=i[a][u]}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return i})(t).current;return N(s)?[n.getStateNode(s)]:g(y(s).map((function(t){return"deep"===e.history?n.getFromRelativePath(t):[n.states[t[0]]]})))},Object.defineProperty(a.prototype,"stateIds",{get:function(){var t=this,e=g(s(this.states).map((function(e){return t.states[e].stateIds})));return[this.id].concat(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"events",{get:function(){var t,e,n,i;if(this.__cache.events)return this.__cache.events;var o=this.states,a=new Set(this.ownEvents);if(o)try{for(var c=r(s(o)),u=c.next();!u.done;u=c.next()){var h=o[u.value];if(h.states)try{for(var f=(n=void 0,r(h.events)),l=f.next();!l.done;l=f.next()){var d=l.value;a.add(""+d)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}return this.__cache.events=Array.from(a)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"ownEvents",{get:function(){var t=new Set(this.transitions.filter((function(t){return!(!t.target&&!t.actions.length&&t.internal)})).map((function(t){return t.eventType})));return Array.from(t)},enumerable:!1,configurable:!0}),a.prototype.resolveTarget=function(t){var e=this;if(void 0!==t)return t.map((function(t){if(!N(t))return t;var n=t[0]===e.delimiter;if(n&&!e.parent)return e.getStateNodeByPath(t.slice(1));var r=n?e.key+t:t;if(!e.parent)return e.getStateNodeByPath(r);try{return e.parent.getStateNodeByPath(r)}catch(t){throw new Error("Invalid transition definition for state node '"+e.id+"':\n"+t.message)}}))},a.prototype.formatTransition=function(t){var n=this,r=function(t){if(void 0!==t&&""!==t)return x(t)}(t.target),i="internal"in t?t.internal:!r||r.some((function(t){return N(t)&&t[0]===n.delimiter})),o=this.machine.options.guards,a=this.resolveTarget(r),s=e(e({},t),{actions:lt(x(t.actions)),cond:O(t.cond,o),target:a,source:this,internal:i,eventType:t.event,toJSON:function(){return e(e({},s),{target:s.target?s.target.map((function(t){return"#"+t.id})):void 0,source:"#"+n.id})}});return s},a.prototype.formatTransitions=function(){var t,e,i,a=this;if(this.config.on)if(Array.isArray(this.config.on))i=this.config.on;else{var c=this.config.on,u=c["*"],h=void 0===u?[]:u,f=n(c,["*"]);i=g(s(f).map((function(t){return M(t,f[t])})).concat(M("*",h)))}else i=[];var l=this.config.always?M("",this.config.always):[],d=this.config.onDone?M(String(Et(this.id)),this.config.onDone):[],p=g(this.invoke.map((function(t){var e=[];return t.onDone&&e.push.apply(e,o(M(String(Tt(t.id)),t.onDone))),t.onError&&e.push.apply(e,o(M(String(Nt(t.id)),t.onError))),e}))),v=this.after,y=g(o(d,p,i,l).map((function(t){return x(t).map((function(t){return a.formatTransition(t)}))})));try{for(var m=r(v),S=m.next();!S.done;S=m.next()){var w=S.value;y.push(w)}}catch(e){t={error:e}}finally{try{S&&!S.done&&(e=m.return)&&e.call(m)}finally{if(t)throw t.error}}return y},a}();var Ft,Ut={deferEvents:!1},zt=function(){function t(t){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=e(e({},Ut),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}(),Jt=new Map,Bt=0,qt=function(){return"x:"+Bt++},$t=function(t,e){return Jt.set(t,e),t},Xt=function(t){return Jt.get(t)},Ht=function(t){Jt.delete(t)},Gt={sync:!1,autoForward:!1};(Ft=t.InterpreterStatus||(t.InterpreterStatus={}))[Ft.NotStarted=0]="NotStarted",Ft[Ft.Running=1]="Running",Ft[Ft.Stopped=2]="Stopped";var Kt=function(){function n(r,i){var o=this;void 0===i&&(i=n.defaultOptions),this.machine=r,this.scheduler=new zt,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(E(e))return o.batch(e),o.state;var r=D(L(e,n));if(o.status===t.InterpreterStatus.Stopped)return o.state;if(o.status!==t.InterpreterStatus.Running&&!o.options.deferEvents)throw new Error('Event "'+r.name+'" was sent to uninitialized service "'+o.machine.id+'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: '+JSON.stringify(r.data));return o.scheduler.schedule((function(){o.forward(r);var t=o.nextState(r);o.update(t,r)})),o._state},this.sendTo=function(n,r){var i,a=o.parent&&(r===t.SpecialTargets.Parent||o.parent.id===r),s=a?o.parent:N(r)?o.children.get(r)||Xt(r):(i=r)&&"function"==typeof i.send?r:void 0;if(s)"machine"in s?s.send(e(e({},n),{name:n.name===ot?""+Nt(o.id):n.name,origin:o.sessionId})):s.send(n.data);else if(!a)throw new Error("Unable to send event to child '"+r+"' from service '"+o.id+"'.")};var a=e(e({},n.defaultOptions),i),s=a.clock,c=a.logger,u=a.parent,h=a.id,f=void 0!==h?h:r.id;this.id=f,this.logger=c,this.clock=s,this.parent=u,this.options=a,this.scheduler=new zt({deferEvents:this.options.deferEvents}),this.sessionId=qt()}return Object.defineProperty(n.prototype,"initialState",{get:function(){var t=this;return this._initialState?this._initialState:It(this,(function(){return t._initialState=t.machine.initialState,t._initialState}))},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),n.prototype.execute=function(t,e){var n,i;try{for(var o=r(t.actions),a=o.next();!a.done;a=o.next()){var s=a.value;this.exec(s,t,e)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}},n.prototype.update=function(t,e){var n,i,o,a,s,c,u,h,f=this;if(t._sessionid=this.sessionId,this._state=t,this.options.execute&&this.execute(this.state),this.children.forEach((function(t){f.state.children[t.id]=t})),this.devTools&&this.devTools.send(e.data,t),t.event)try{for(var l=r(this.eventListeners),d=l.next();!d.done;d=l.next()){(0,d.value)(t.event)}}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}try{for(var p=r(this.listeners),v=p.next();!v.done;v=p.next()){(0,v.value)(t,t.event)}}catch(t){o={error:t}}finally{try{v&&!v.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}try{for(var y=r(this.contextListeners),g=y.next();!g.done;g=y.next()){(0,g.value)(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(t){s={error:t}}finally{try{g&&!g.done&&(c=y.return)&&c.call(y)}finally{if(s)throw s.error}}var m=H(t.configuration||[],this.machine);if(this.state.configuration&&m){var x=t.configuration.find((function(t){return"final"===t.type&&t.parent===f.machine})),w=x&&x.doneData?S(x.doneData,t.context,e):void 0;try{for(var b=r(this.doneListeners),_=b.next();!_.done;_=b.next()){(0,_.value)(Tt(this.id,w))}}catch(t){u={error:t}}finally{try{_&&!_.done&&(h=b.return)&&h.call(b)}finally{if(u)throw u.error}}this.stop()}},n.prototype.onTransition=function(e){return this.listeners.add(e),this.status===t.InterpreterStatus.Running&&e(this.state,this.state.event),this},n.prototype.subscribe=function(e,n,r){var i,o=this;if(!e)return{unsubscribe:function(){}};var a=r;return"function"==typeof e?i=e:(i=e.next.bind(e),a=e.complete.bind(e)),this.listeners.add(i),this.status===t.InterpreterStatus.Running&&i(this.state),a&&this.onDone(a),{unsubscribe:function(){i&&o.listeners.delete(i),a&&o.doneListeners.delete(a)}}},n.prototype.onEvent=function(t){return this.eventListeners.add(t),this},n.prototype.onSend=function(t){return this.sendListeners.add(t),this},n.prototype.onChange=function(t){return this.contextListeners.add(t),this},n.prototype.onStop=function(t){return this.stopListeners.add(t),this},n.prototype.onDone=function(t){return this.doneListeners.add(t),this},n.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},n.prototype.start=function(e){var n=this;if(this.status===t.InterpreterStatus.Running)return this;$t(this.sessionId,this),this.initialized=!0,this.status=t.InterpreterStatus.Running;var r=void 0===e?this.initialState:It(this,(function(){return!N(t=e)&&"value"in t&&"history"in t?n.machine.resolveState(e):n.machine.resolveState(Pt.from(e,n.machine.context));var t}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){n.update(r,ut)})),this},n.prototype.stop=function(){var e,n,i,o,a,c,u,h,f,l,d=this;try{for(var p=r(this.listeners),v=p.next();!v.done;v=p.next()){var y=v.value;this.listeners.delete(y)}}catch(t){e={error:t}}finally{try{v&&!v.done&&(n=p.return)&&n.call(p)}finally{if(e)throw e.error}}try{for(var g=r(this.stopListeners),m=g.next();!m.done;m=g.next()){(y=m.value)(),this.stopListeners.delete(y)}}catch(t){i={error:t}}finally{try{m&&!m.done&&(o=g.return)&&o.call(g)}finally{if(i)throw i.error}}try{for(var x=r(this.contextListeners),S=x.next();!S.done;S=x.next()){y=S.value;this.contextListeners.delete(y)}}catch(t){a={error:t}}finally{try{S&&!S.done&&(c=x.return)&&c.call(x)}finally{if(a)throw a.error}}try{for(var w=r(this.doneListeners),b=w.next();!b.done;b=w.next()){y=b.value;this.doneListeners.delete(y)}}catch(t){u={error:t}}finally{try{b&&!b.done&&(h=w.return)&&h.call(w)}finally{if(u)throw u.error}}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 a=o.value;d.exec(a,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){T(t.stop)&&t.stop()}));try{for(var _=r(s(this.delayedEventsMap)),E=_.next();!E.done;E=_.next()){var N=E.value;this.clock.clearTimeout(this.delayedEventsMap[N])}}catch(t){f={error:t}}finally{try{E&&!E.done&&(l=_.return)&&l.call(_)}finally{if(f)throw f.error}}return this.scheduler.clear(),this.initialized=!1,this.status=t.InterpreterStatus.Stopped,Ht(this.sessionId),this},n.prototype.batch=function(n){var i=this;if(this.status===t.InterpreterStatus.NotStarted&&this.options.deferEvents);else if(this.status!==t.InterpreterStatus.Running)throw new Error(n.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,a,s=i.state,c=!1,u=[],h=function(t){var n=D(t);i.forward(n),s=It(i,(function(){return i.machine.transition(s,n)})),u.push.apply(u,o(s.actions.map((function(t){return r=s,i=(n=t).exec,e(e({},n),{exec:void 0!==i?function(){return i(r.context,r.event,{action:n,state:r,_event:r._event})}:void 0});var n,r,i})))),c=c||!!s.changed};try{for(var f=r(n),l=f.next();!l.done;l=f.next()){h(l.value)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(a=f.return)&&a.call(f)}finally{if(t)throw t.error}}s.changed=c,s.actions=u,i.update(s,D(n[n.length-1]))}))},n.prototype.sender=function(t){return this.send.bind(this,t)},n.prototype.nextState=function(t){var e=this,n=D(t);if(0===n.name.indexOf(it)&&!this.state.nextEvents.some((function(t){return 0===t.indexOf(it)})))throw n.data.data;return It(this,(function(){return e.machine.transition(e.state,n)}))},n.prototype.forward=function(t){var e,n;try{for(var i=r(this.forwardTo),o=i.next();!o.done;o=i.next()){var a=o.value,s=this.children.get(a);if(!s)throw new Error("Unable to forward event '"+t+"' from interpreter '"+this.id+"' to nonexistant child '"+a+"'.");s.send(t)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},n.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)},n.prototype.cancel=function(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]},n.prototype.exec=function(e,n,r){void 0===r&&(r=this.machine.options.actions);var i=n.context,o=n._event,a=e.exec||ht(e.type,r),s=T(a)?a:a?a.exec:e.exec;if(s)try{return s(i,o.data,{action:e,state:this.state,_event:o})}catch(t){throw this.parent&&this.parent.send({type:"xstate.error",data:t}),t}switch(e.type){case W:var c=e;if("number"==typeof c.delay)return void this.defer(c);c.to?this.sendTo(c._event,c.to):this.send(c._event);break;case Y:this.cancel(e.sendId);break;case G:var u=e.activity;if(!this.state.activities[u.id||u.type])break;if(u.type===t.ActionTypes.Invoke){var h=F(u.src),f=this.machine.options.services?this.machine.options.services[h.type]:void 0,l=u.id,d=u.data,p="autoForward"in u?u.autoForward:!!u.forward;if(!f)return;var v=d?S(d,i,o):void 0,y=T(f)?f(i,o.data,{data:v,src:h}):f;w(y)?this.spawnPromise(Promise.resolve(y),l):T(y)?this.spawnCallback(y,l):A(y)?this.spawnObservable(y,l):k(y)&&this.spawnMachine(v?y.withContext(v):y,{id:l,autoForward:p})}else this.spawnActivity(u);break;case K:this.stopChild(e.activity.id);break;case et:var g=e.label,m=e.value;g?this.logger(g,m):this.logger(m)}},n.prototype.removeChild=function(t){this.children.delete(t),this.forwardTo.delete(t),delete this.state.children[t]},n.prototype.stopChild=function(t){var e=this.children.get(t);e&&(this.removeChild(t),T(e.stop)&&e.stop())},n.prototype.spawn=function(t,n,r){if(w(t))return this.spawnPromise(Promise.resolve(t),n);if(T(t))return this.spawnCallback(t,n);if(function(t){try{return"function"==typeof t.send}catch(t){return!1}}(i=t)&&"id"in i)return this.spawnActor(t);if(A(t))return this.spawnObservable(t,n);if(k(t))return this.spawnMachine(t,e(e({},r),{id:n}));throw new Error('Unable to spawn entity "'+n+'" of type "'+typeof t+'".');var i},n.prototype.spawnMachine=function(t,r){var i=this;void 0===r&&(r={});var o=new n(t,e(e({},this.options),{parent:this,id:r.id||t.id})),a=e(e({},Gt),r);a.sync&&o.onTransition((function(t){i.send(at,{state:t,id:o.id})}));var s=o;return this.children.set(o.id,s),a.autoForward&&this.forwardTo.add(o.id),o.onDone((function(t){i.removeChild(o.id),i.send(D(t,{origin:o.id}))})).start(),s},n.prototype.spawnPromise=function(t,e){var n=this,r=!1;t.then((function(t){r||(n.removeChild(e),n.send(D(Tt(e,t),{origin:e})))}),(function(t){if(!r){n.removeChild(e);var i=Nt(e,t);try{n.send(D(i,{origin:e}))}catch(t){n.devTools&&n.devTools.send(i,n.state),n.machine.strict&&n.stop()}}}));var i={id:e,send:function(){},subscribe:function(e,n,r){var i=function(t,e,n){if("object"==typeof t)return t;var r=function(){};return{next:t,error:e||r,complete:n||r}}(e,n,r),o=!1;return t.then((function(t){o||(i.next(t),o||i.complete())}),(function(t){o||i.error(t)})),{unsubscribe:function(){return o=!0}}},stop:function(){r=!0},toJSON:function(){return{id:e}}};return this.children.set(e,i),i},n.prototype.spawnCallback=function(t,e){var n,r=this,i=!1,o=new Set,a=new Set;try{n=t((function(t){a.forEach((function(e){return e(t)})),i||r.send(D(t,{origin:e}))}),(function(t){o.add(t)}))}catch(t){this.send(Nt(e,t))}if(w(n))return this.spawnPromise(n,e);var s={id:e,send:function(t){return o.forEach((function(e){return e(t)}))},subscribe:function(t){return a.add(t),{unsubscribe:function(){a.delete(t)}}},stop:function(){i=!0,T(n)&&n()},toJSON:function(){return{id:e}}};return this.children.set(e,s),s},n.prototype.spawnObservable=function(t,e){var n=this,r=t.subscribe((function(t){n.send(D(t,{origin:e}))}),(function(t){n.removeChild(e),n.send(D(Nt(e,t),{origin:e}))}),(function(){n.removeChild(e),n.send(D(Tt(e),{origin:e}))})),i={id:e,send:function(){},subscribe:function(e,n,r){return t.subscribe(e,n,r)},stop:function(){return r.unsubscribe()},toJSON:function(){return{id:e}}};return this.children.set(e,i),i},n.prototype.spawnActor=function(t){return this.children.set(t.id,t),t},n.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)}},n.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}}})},n.prototype.attachDev=function(){if(this.options.devTools&&"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__){var t="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=window.__REDUX_DEVTOOLS_EXTENSION__.connect(e(e({name:this.id,autoPause:!0,stateSanitizer:function(t){return{value:t.value,context:t.context,actions:t.actions}}},t),{features:e({jump:!1,skip:!1},t?t.features:void 0)}),this.machine),this.devTools.init(this.state)}},n.prototype.toJSON=function(){return{id:this.id}},n.prototype[P]=function(){return this},n.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),n.interpret=Qt,n}();function Qt(t,e){return new Kt(t,e)}var Wt={raise:pt,send:vt,sendParent:yt,sendUpdate:gt,log:function(t,e){return void 0===t&&(t=mt),{type:et,label:e,expr:t}},cancel:xt,start:St,stop:wt,assign:bt,after:_t,done:Et,respond:function(t,n){return vt(t,e(e({},n),{to:function(t,e,n){return n._event.origin}}))},forwardTo:Ot,escalate:function(n,r){return yt((function(t,e,r){return{type:ot,data:T(n)?n(t,e,r):n}}),e(e({},r),{to:t.SpecialTargets.Parent}))},choose:function(e){return{type:t.ActionTypes.Choose,conds:e}},pure:function(e){return{type:t.ActionTypes.Pure,get:e}}};t.Interpreter=Kt,t.Machine=function(t,e,n){void 0===n&&(n=t.context);var r="function"==typeof n?n():n;return new Rt(t,e,r)},t.State=Pt,t.StateNode=Rt,t.actions=Wt,t.assign=bt,t.createMachine=function(t,e){var n="function"==typeof t.context?t.context():t.context;return new Rt(t,e,n)},t.doneInvoke=Tt,t.forwardTo=Ot,t.interpret=Qt,t.mapState=function(t,e){var n,i,o;try{for(var a=r(s(t)),u=a.next();!u.done;u=a.next()){var h=u.value;c(h,e)&&(!o||e.length>o.length)&&(o=h)}}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return t[o]},t.matchState=function(t,e,n){var o,a,s=Pt.from(t,t instanceof Pt?t.context:void 0);try{for(var c=r(e),u=c.next();!u.done;u=c.next()){var h=i(u.value,2),f=h[0],l=h[1];if(s.matches(f))return l(s)}}catch(t){o={error:t}}finally{try{u&&!u.done&&(a=c.return)&&a.call(c)}finally{if(o)throw o.error}}return n(s)},t.matchesState=c,t.send=vt,t.sendParent=yt,t.sendUpdate=gt,t.spawn=function(t,n){var r=function(t){return N(t)?e(e({},Gt),{name:t}):e(e(e({},Gt),{name:V()}),t)}(n);return function(e){return e?e.spawn(t,r.name,r):Ct(t,r.name)}(kt[kt.length-1])},Object.defineProperty(t,"__esModule",{value:!0})}));