modified-dicom-pacs
Version:
A modified version of DICOM PACS implementation
2 lines • 63.4 kB
JavaScript
/*! For license information please see 835.bundle.a28b9d53a244c0a90ea2.js.LICENSE.txt */
"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[835],{6835:(t,e,n)=>{n.d(e,{zl:()=>d});var i=n(41766),r=n(33724),o=n(57593),a=n(96025);function s(t){var e=i.useRef();return e.current||(e.current={v:t()}),e.current.v}var c=function(){return c=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},c.apply(this,arguments)},u=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};function h(t,e){var n=s((function(){return"function"==typeof t?t():t})),i=e.context,r=e.guards,h=e.actions,f=e.activities,l=e.services,d=e.delays,v=(e.state,u(e,["context","guards","actions","activities","services","delays","state"])),p=s((function(){var t={context:i,guards:r,actions:h,activities:f,services:l,delays:d},e=n.withConfig(t,(function(){return c(c({},n.context),i)}));return(0,o.U4)(e,v)}));return(0,a.A)((function(){Object.assign(p.machine.options.actions,h),Object.assign(p.machine.options.guards,r),Object.assign(p.machine.options.activities,f),Object.assign(p.machine.options.services,l),Object.assign(p.machine.options.delays,d)}),[h,r,f,l,d]),p}var f=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)a.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 a};function l(t){return t}function d(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var a=f(e,1)[0],s=void 0===a?{}:a,c=h(t,s),u=(0,i.useCallback)((function(){return c.status===o.vy.NotStarted?s.state?o.Uw.create(s.state):c.machine.initialState:c.getSnapshot()}),[c]),d=(0,i.useCallback)((function(t,e){return function(t,e,n){if(t.status===o.vy.NotStarted)return!0;var i=void 0===n.changed&&(Object.keys(n.children).length>0||"boolean"==typeof e.changed);return!(n.changed||i)}(c,t,e)}),[c]),v=(0,i.useCallback)((function(t){return c.subscribe(t).unsubscribe}),[c]),p=(0,r.useSyncExternalStoreWithSelector)(v,u,u,l,d);return(0,i.useEffect)((function(){var t=s.state;return c.start(t?o.Uw.create(t):void 0),function(){c.stop(),c.status=o.vy.NotStarted}}),[]),[p,c.send,c]}},24846:(t,e,n)=>{var i=n(41766);var r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=i.useState,a=i.useEffect,s=i.useLayoutEffect,c=i.useDebugValue;function u(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!r(t,n)}catch(t){return!0}}var h="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),i=o({inst:{value:n,getSnapshot:e}}),r=i[0].inst,h=i[1];return s((function(){r.value=n,r.getSnapshot=e,u(r)&&h({inst:r})}),[t,n,e]),a((function(){return u(r)&&h({inst:r}),t((function(){u(r)&&h({inst:r})}))}),[t]),c(n),n};e.useSyncExternalStore=void 0!==i.useSyncExternalStore?i.useSyncExternalStore:h},2878:(t,e,n)=>{var i=n(41766),r=n(28178);var o="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},a=r.useSyncExternalStore,s=i.useRef,c=i.useEffect,u=i.useMemo,h=i.useDebugValue;e.useSyncExternalStoreWithSelector=function(t,e,n,i,r){var f=s(null);if(null===f.current){var l={hasValue:!1,value:null};f.current=l}else l=f.current;f=u((function(){function t(t){if(!c){if(c=!0,a=t,t=i(t),void 0!==r&&l.hasValue){var e=l.value;if(r(e,t))return s=e}return s=t}if(e=s,o(a,t))return e;var n=i(t);return void 0!==r&&r(e,n)?e:(a=t,s=n)}var a,s,c=!1,u=void 0===n?null:n;return[function(){return t(e())},null===u?void 0:function(){return t(u())}]}),[e,n,i,r]);var d=a(t,f[0],f[1]);return c((function(){l.hasValue=!0,l.value=d}),[d]),h(d),d}},28178:(t,e,n)=>{t.exports=n(24846)},33724:(t,e,n)=>{t.exports=n(2878)},57593:(t,e,n)=>{n.d(e,{vy:()=>$t,u5:()=>ne,Uw:()=>Vt,kp:()=>ie,U4:()=>Ht});var i,r,o=function(){return o=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},o.apply(this,arguments)};function a(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}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)a.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 a}function u(t,e,n){if(n||2===arguments.length)for(var i,r=0,o=e.length;r<o;r++)!i&&r in e||(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}!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"}(i||(i={})),function(t){t.Parent="#_parent",t.Internal="#_internal"}(r||(r={}));var h,f=i.Start,l=i.Stop,d=i.Raise,v=i.Send,p=i.Cancel,y=i.NullEvent,g=i.Assign,m=(i.After,i.DoneState,i.Log),b=i.Init,x=i.Invoke,S=(i.ErrorExecution,i.ErrorPlatform),w=i.ErrorCustom,_=i.Update,E=i.Choose,O=i.Pure,k={},j="xstate.guard",N=!0;function T(t,e,n){void 0===n&&(n=".");var i=C(t,n),r=C(e,n);return H(r)?!!H(i)&&r===i:H(i)?i in r:Object.keys(i).every((function(t){return t in r&&T(i[t],r[t])}))}function A(t){try{return H(t)||"number"==typeof t?"".concat(t):t.type}catch(t){throw new Error("Events must be strings or objects with a string event.type property.")}}function P(t,e){try{return X(t)?t:t.toString().split(e)}catch(e){throw new Error("'".concat(t,"' is not a valid state path."))}}function C(t,e){return"object"==typeof(n=t)&&"value"in n&&"context"in n&&"event"in n&&"_event"in n?t.value:X(t)?V(t):"string"!=typeof t?t:V(P(t,e));var n}function V(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 D(t,e){for(var n={},i=Object.keys(t),r=0;r<i.length;r++){var o=i[r];n[o]=e(t[o],o,t,r)}return n}function I(t,e,n){var i,r,o={};try{for(var a=s(Object.keys(t)),c=a.next();!c.done;c=a.next()){var u=c.value,h=t[u];n(h)&&(o[u]=e(h,u,t))}}catch(t){i={error:t}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}var L=function(t){return function(e){var n,i,r=e;try{for(var o=s(t),a=o.next();!a.done;a=o.next()){r=r[a.value]}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return r}};function R(t){return t?H(t)?[[t]]:M(Object.keys(t).map((function(e){var n=t[e];return"string"==typeof n||n&&Object.keys(n).length?R(t[e]).map((function(t){return[e].concat(t)})):[[e]]}))):[[]]}function M(t){var e;return(e=[]).concat.apply(e,u([],c(t),!1))}function U(t){return X(t)?t:[t]}function z(t){return void 0===t?[]:U(t)}function J(t,e,n){var i,r;if(Q(t))return t(e,n.data);var o={};try{for(var a=s(Object.keys(t)),c=a.next();!c.done;c=a.next()){var u=c.value,h=t[u];Q(h)?o[u]=h(e,n.data):o[u]=h}}catch(t){i={error:t}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}function B(t){return t instanceof Promise||!(null===t||!Q(t)&&"object"!=typeof t||!Q(t.then))}function F(t,e){return D(t.states,(function(t,n){if(t){var i=(H(e)?void 0:e[n])||(t?t.current:void 0);if(i)return{current:i,states:F(t,i)}}}))}function q(t,e,n,i){N||$(!!t,"Attempting to update undefined context");var r=t?n.reduce((function(t,n){var r,o,a=n.assignment,c={state:i,action:n,_event:e},u={};if(Q(a))u=a(t,e.data,c);else try{for(var h=s(Object.keys(a)),f=h.next();!f.done;f=h.next()){var l=f.value,d=a[l];u[l]=Q(d)?d(t,e.data,c):d}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}return Object.assign({},t,u)}),t):t;return r}var $=function(){};function X(t){return Array.isArray(t)}function Q(t){return"function"==typeof t}function H(t){return"string"==typeof t}function W(t,e){if(t)return H(t)?{type:j,name:t,predicate:e?e[t]:void 0}:Q(t)?{type:j,name:t.name,predicate:t}:t}N||($=function(t,e){var n=t instanceof Error?t:void 0;if((n||!t)&&void 0!==console){var i=["Warning: ".concat(e)];n&&i.push(n),console.warn.apply(console,i)}});var G=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();(h={})[G]=function(){return this},h[Symbol.observable]=function(){return this};function K(t){return!!t&&"__xstatenode"in t}function Y(t,e){return H(t)||"number"==typeof t?o({type:t},e):t}function Z(t,e){if(!H(t)&&"$$type"in t&&"scxml"===t.$$type)return t;var n=Y(t);return o({name:n.type,data:n,$$type:"scxml",type:"external"},e)}function tt(t,e){return U(e).map((function(e){return void 0===e||"string"==typeof e||K(e)?{target:e,event:t}:o(o({},e),{event:t})}))}function et(t,e,n,i,r){var o=t.options.guards,a={state:r,cond:e,_event:i};if(e.type===j)return((null==o?void 0:o[e.name])||e.predicate)(n,i.data,a);var s=null==o?void 0:o[e.type];if(!s)throw new Error("Guard '".concat(e.type,"' is not implemented on machine '").concat(t.id,"'."));return s(n,i.data,a)}function nt(t){return"string"==typeof t?{type:t}:t}function it(t,e,n){var i=function(){},r="object"==typeof t,o=r?t:null;return{next:((r?t.next:t)||i).bind(o),error:((r?t.error:e)||i).bind(o),complete:((r?t.complete:n)||i).bind(o)}}function rt(t,e){return"".concat(t,":invocation[").concat(e,"]")}function ot(t){return(t.type===d||t.type===v&&t.to===r.Internal)&&"number"!=typeof t.delay}var at=Z({type:b});function st(t,e){return e&&e[t]||void 0}function ct(t,e){var n;if(H(t)||"number"==typeof t)n=Q(i=st(t,e))?{type:t,exec:i}:i||{type:t,exec:void 0};else if(Q(t))n={type:t.name||t.toString(),exec:t};else{var i;if(Q(i=st(t.type,e)))n=o(o({},t),{exec:i});else if(i){var r=i.type||t.type;n=o(o(o({},i),t),{type:r})}else n=t}return n}var ut=function(t,e){return t?(X(t)?t:[t]).map((function(t){return ct(t,e)})):[]};function ht(t){var e=ct(t);return o(o({id:H(t)?t:e.id},e),{type:e.type})}function ft(t,e){return{to:e?e.to:void 0,type:v,event:Q(t)?t:Y(t),delay:e?e.delay:void 0,id:e&&void 0!==e.id?e.id:Q(t)?t.name:A(t)}}function lt(t,e){var n="".concat(i.DoneState,".").concat(t),r={type:n,data:e,toString:function(){return n}};return r}function dt(t,e){var n="".concat(i.DoneInvoke,".").concat(t),r={type:n,data:e,toString:function(){return n}};return r}function vt(t,e){var n="".concat(i.ErrorPlatform,".").concat(t),r={type:n,data:e,toString:function(){return n}};return r}function pt(t,e,n,a,h,f,p){void 0===p&&(p=!1);var y=p?[]:function(t){var e,n,i=[];try{for(var r=s(t),o=r.next();!o.done;o=r.next())for(var a=o.value,c=0;c<a.actions.length;)a.actions[c].type!==g?c++:(i.push(a.actions[c]),a.actions.splice(c,1))}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return i}(h),b=y.length?q(n,a,y,e):n,x=p?[n]:void 0,S=[];function w(s,h){var y;switch(h.type){case d:var w=function(t,e,n,i){var r,a={_event:n},s=Z(Q(t.event)?t.event(e,n.data,a):t.event);if(H(t.delay)){var c=i&&i[t.delay];r=Q(c)?c(e,n.data,a):c}else r=Q(t.delay)?t.delay(e,n.data,a):t.delay;return o(o({},t),{type:d,_event:s,delay:r})}(h,b,a,t.options.delays);return f&&"number"==typeof w.delay&&f(w,b,a),w;case v:var _=function(t,e,n,i){var r,a={_event:n},s=Z(Q(t.event)?t.event(e,n.data,a):t.event);if(H(t.delay)){var c=i&&i[t.delay];r=Q(c)?c(e,n.data,a):c}else r=Q(t.delay)?t.delay(e,n.data,a):t.delay;var u=Q(t.to)?t.to(e,n.data,a):t.to;return o(o({},t),{to:u,_event:s,event:s.data,delay:r})}(h,b,a,t.options.delays);if(!N){var k=h.delay;$(!H(k)||"number"==typeof _.delay,"No delay reference for delay expression '".concat(k,"' was found on machine '").concat(t.id,"'"))}return f&&_.to!==r.Internal&&("entry"===s?S.push(_):f(_,b,a)),_;case m:var j=function(t,e,n){return o(o({},t),{value:H(t.expr)?t.expr:t.expr(e,n.data,{_event:n})})}(h,b,a);return null==f||f(j,b,a),j;case E:if(!(C=null===(y=h.conds.find((function(n){var i=W(n.cond,t.options.guards);return!i||et(t,i,b,a,f?void 0:e)})))||void 0===y?void 0:y.actions))return[];var T=c(pt(t,e,b,a,[{type:s,actions:ut(z(C),t.options.actions)}],f,p),2),A=T[0],P=T[1];return b=P,null==x||x.push(b),A;case O:var C;if(!(C=h.get(b,a.data)))return[];var V=c(pt(t,e,b,a,[{type:s,actions:ut(z(C),t.options.actions)}],f,p),2),D=V[0],I=V[1];return b=I,null==x||x.push(b),D;case l:j=function(t,e,n){var r=Q(t.activity)?t.activity(e,n.data):t.activity,o="string"==typeof r?{id:r}:r;return{type:i.Stop,activity:o}}(h,b,a);return null==f||f(j,n,a),j;case g:b=q(b,a,[h],f?void 0:e),null==x||x.push(b);break;default:var L=ct(h,t.options.actions),R=L.exec;if(f)f(L,b,a);else if(R&&x){var M=x.length-1,U=o(o({},L),{exec:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];R.apply(void 0,u([x[M]],c(e),!1))}});L=U}return L}}var _=M(h.map((function(t){var e,n,i=[];try{for(var r=s(t.actions),o=r.next();!o.done;o=r.next()){var c=o.value,u=w(t.type,c);u&&(i=i.concat(u))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return S.forEach((function(t){f(t,b,a)})),S.length=0,i})));return[_,b]}var yt=[],gt=function(t,e){yt.push(t);var n=e(t);return yt.pop(),n};function mt(t){var e;return(e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}})[G]=function(){return this},e}function bt(t,e,n){var i=mt(e);if(i.deferred=!0,K(t)){var r=i.state=gt(void 0,(function(){return(n?t.withContext(n):t).initialState}));i.getSnapshot=function(){return r}}return i}var xt=function(t){return"atomic"===t.type||"final"===t.type};function St(t){return Object.keys(t.states).map((function(e){return t.states[e]}))}function wt(t){return St(t).filter((function(t){return"history"!==t.type}))}function _t(t){var e=[t];return xt(t)?e:e.concat(M(wt(t).map(_t)))}function Et(t,e){var n,i,r,o,a,c,u,h,f=kt(new Set(t)),l=new Set(e);try{for(var d=s(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=kt(l);try{for(var g=s(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 b=(a=void 0,s(wt(E))),x=b.next();!x.done;x=b.next()){var S=x.value;l.has(S)||(l.add(S),f.get(S)?f.get(S).forEach((function(t){return l.add(t)})):S.initialStateNodes.forEach((function(t){return l.add(t)})))}}catch(t){a={error:t}}finally{try{x&&!x.done&&(c=b.return)&&c.call(b)}finally{if(a)throw a.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){r={error:t}}finally{try{m&&!m.done&&(o=g.return)&&o.call(g)}finally{if(r)throw r.error}}try{for(var w=s(l),_=w.next();!_.done;_=w.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=w.return)&&h.call(w)}finally{if(u)throw u.error}}return l}function Ot(t,e){var n=e.get(t);if(!n)return{};if("compound"===t.type){var i=n[0];if(!i)return{};if(xt(i))return i.key}var r={};return n.forEach((function(t){r[t.key]=Ot(t,e)})),r}function kt(t){var e,n,i=new Map;try{for(var r=s(t),o=r.next();!o.done;o=r.next()){var a=o.value;i.has(a)||i.set(a,[]),a.parent&&(i.has(a.parent)||i.set(a.parent,[]),i.get(a.parent).push(a))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return i}function jt(t,e){return Ot(t,kt(Et([t],e)))}function Nt(t,e){return Array.isArray(t)?t.some((function(t){return t===e})):t instanceof Set&&t.has(e)}function Tt(t,e){return"compound"===e.type?wt(e).some((function(e){return"final"===e.type&&Nt(t,e)})):"parallel"===e.type&&wt(e).every((function(e){return Tt(t,e)}))}function At(t){return new Set(M(t.map((function(t){return t.tags}))))}function Pt(t,e){if(t===e)return!0;if(void 0===t||void 0===e)return!1;if(H(t)||H(e))return t===e;var n=Object.keys(t),i=Object.keys(e);return n.length===i.length&&n.every((function(n){return Pt(t[n],e[n])}))}function Ct(t){return"object"==typeof t&&null!==t&&("value"in t&&"_event"in t)}var Vt=function(){function t(t){var e,n,i=this;this.actions=[],this.activities=k,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||k,this.meta=(void 0===(n=t.configuration)&&(n=[]),n.reduce((function(t,e){return void 0!==e.meta&&(t[e.id]=e.meta),t}),{})),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,this.tags=null!==(e=Array.isArray(t.tags)?new Set(t.tags):t.tags)&&void 0!==e?e:new Set,this.machine=t.machine,Object.defineProperty(this,"nextEvents",{get:function(){return function(t){return u([],c(new Set(M(u([],c(t.map((function(t){return t.ownEvents}))),!1)))),!1)}(i.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:at,_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=at;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="."),H(t))return[t];var i=Object.keys(t);return i.concat.apply(i,u([],c(i.map((function(i){return n.toStrings(t[i],e).map((function(t){return i+e+t}))}))),!1))},t.prototype.toJSON=function(){var t=this;t.configuration,t.transitions;var e=t.tags;t.machine;var n=a(t,["configuration","transitions","tags","machine"]);return o(o({},n),{tags:Array.from(e)})},t.prototype.matches=function(t){return T(t,this.value)},t.prototype.hasTag=function(t){return this.tags.has(t)},t.prototype.can=function(t){var e;N&&$(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=null===(e=this.machine)||void 0===e?void 0:e.getTransitionData(this,t);return!!(null==n?void 0:n.transitions.length)&&n.transitions.some((function(t){return void 0!==t.target||t.actions.length}))},t}(),Dt={deferEvents:!1},It=function(){function t(t){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=o(o({},Dt),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}(),Lt=new Map,Rt=0,Mt=function(){return"x:".concat(Rt++)},Ut=function(t,e){return Lt.set(t,e),t},zt=function(t){return Lt.get(t)},Jt=function(t){Lt.delete(t)};function Bt(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n.g?n.g:void(N||console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues"))}function Ft(t){if(Bt()){var e=function(){var t=Bt();if(t&&"__xstate__"in t)return t.__xstate__}();e&&e.register(t)}}function qt(t,e){void 0===e&&(e={});var n=t.initialState,i=new Set,r=[],a=!1,s=function(t){var e;return o(((e={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}})[G]=function(){return this},e),t)}({id:e.id,send:function(e){r.push(e),function(){if(!a){for(a=!0;r.length>0;){var e=r.shift();n=t.transition(n,e,c),i.forEach((function(t){return t.next(n)}))}a=!1}}()},getSnapshot:function(){return n},subscribe:function(t,e,r){var o=it(t,e,r);return i.add(o),o.next(n),{unsubscribe:function(){i.delete(o)}}}}),c={parent:e.parent,self:s,id:e.id||"anonymous",observers:i};return n=t.start?t.start(c):n,s}var $t,Xt={sync:!1,autoForward:!1};!function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"}($t||($t={}));var Qt=function(){function t(e,n){void 0===n&&(n=t.defaultOptions);var a=this;this.machine=e,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.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(t,e){if(X(t))return a.batch(t),a.state;var n=Z(Y(t,e));if(a.status===$t.Stopped)return N||$(!1,'Event "'.concat(n.name,'" was sent to stopped service "').concat(a.machine.id,'". This service has already reached its final state, and will not transition.\nEvent: ').concat(JSON.stringify(n.data))),a.state;if(a.status!==$t.Running&&!a.options.deferEvents)throw new Error('Event "'.concat(n.name,'" was sent to uninitialized service "').concat(a.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.\nEvent: ').concat(JSON.stringify(n.data)));return a.scheduler.schedule((function(){a.forward(n);var t=a._nextState(n);a.update(t,n)})),a._state},this.sendTo=function(t,e,n){var i,s=a.parent&&(e===r.Parent||a.parent.id===e),c=s?a.parent:H(e)?e===r.Internal?a:a.children.get(e)||zt(e):(i=e)&&"function"==typeof i.send?e:void 0;if(c)if("machine"in c){if(a.status!==$t.Stopped||a.parent!==c||a.state.done){var u=o(o({},t),{name:t.name===w?"".concat(vt(a.id)):t.name,origin:a.sessionId});!n&&a.machine.config.predictableActionArguments?a._outgoingQueue.push([c,u]):c.send(u)}}else!n&&a.machine.config.predictableActionArguments?a._outgoingQueue.push([c,t.data]):c.send(t.data);else{if(!s)throw new Error("Unable to send event to child '".concat(e,"' from service '").concat(a.id,"'."));N||$(!1,"Service '".concat(a.id,"' has no parent: unable to send event ").concat(t.type))}},this._exec=function(t,e,n,r){void 0===r&&(r=a.machine.options.actions);var o=t.exec||st(t.type,r),s=Q(o)?o:o?o.exec:t.exec;if(s)try{return s(e,n.data,a.machine.config.predictableActionArguments?{action:t,_event:n}:{action:t,state:a.state,_event:n})}catch(t){throw a.parent&&a.parent.send({type:"xstate.error",data:t}),t}switch(t.type){case d:var c=t;a.defer(c);break;case v:var u=t;if("number"==typeof u.delay)return void a.defer(u);u.to?a.sendTo(u._event,u.to,n===at):a.send(u._event);break;case p:a.cancel(t.sendId);break;case f:if(a.status!==$t.Running)return;var h=t.activity;if(!a.machine.config.predictableActionArguments&&!a.state.activities[h.id||h.type])break;if(h.type===i.Invoke){var y=nt(h.src),g=a.machine.options.services?a.machine.options.services[y.type]:void 0,b=h.id,x=h.data;N||$(!("forward"in h),"`forward` property is deprecated (found in invocation of '".concat(h.src,"' in in machine '").concat(a.machine.id,"'). ")+"Please use `autoForward` instead.");var S="autoForward"in h?h.autoForward:!!h.forward;if(!g)return void(N||$(!1,"No service found for invocation '".concat(h.src,"' in machine '").concat(a.machine.id,"'.")));var w=x?J(x,e,n):void 0;if("string"==typeof g)return;var _=Q(g)?g(e,n.data,{data:w,src:y,meta:h.meta}):g;if(!_)return;var E=void 0;K(_)&&(_=w?_.withContext(w):_,E={autoForward:S}),a.spawn(_,b,E)}else a.spawnActivity(h);break;case l:a.stopChild(t.activity.id);break;case m:var O=t,k=O.label,j=O.value;k?a.logger(k,j):a.logger(j);break;default:N||$(!1,"No implementation found for action type '".concat(t.type,"'"))}};var s=o(o({},t.defaultOptions),n),c=s.clock,u=s.logger,h=s.parent,y=s.id,g=void 0!==y?y:e.id;this.id=g,this.logger=u,this.clock=c,this.parent=h,this.options=s,this.scheduler=new It({deferEvents:this.options.deferEvents}),this.sessionId=Mt()}return Object.defineProperty(t.prototype,"initialState",{get:function(){var t=this;return this._initialState?this._initialState:gt(this,(function(){return t._initialState=t.machine.initialState,t._initialState}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return N||$(this.status!==$t.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),t.prototype.execute=function(t,e){var n,i;try{for(var r=s(t.actions),o=r.next();!o.done;o=r.next()){var a=o.value;this.exec(a,t,e)}}catch(t){n={error:t}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(n)throw n.error}}},t.prototype.update=function(t,e){var n,i,r,o,a,c,u,h,f=this;if(t._sessionid=this.sessionId,this._state=t,this.machine.config.predictableActionArguments&&e!==at||!this.options.execute)for(var l=void 0;l=this._outgoingQueue.shift();)l[0].send(l[1]);else this.execute(this.state);if(this.children.forEach((function(t){f.state.children[t.id]=t})),this.devTools&&this.devTools.send(e.data,t),t.event)try{for(var d=s(this.eventListeners),v=d.next();!v.done;v=d.next()){(0,v.value)(t.event)}}catch(t){n={error:t}}finally{try{v&&!v.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}try{for(var p=s(this.listeners),y=p.next();!y.done;y=p.next()){(0,y.value)(t,t.event)}}catch(t){r={error:t}}finally{try{y&&!y.done&&(o=p.return)&&o.call(p)}finally{if(r)throw r.error}}try{for(var g=s(this.contextListeners),m=g.next();!m.done;m=g.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&&(c=g.return)&&c.call(g)}finally{if(a)throw a.error}}if(this.state.done){var b=t.configuration.find((function(t){return"final"===t.type&&t.parent===f.machine})),x=b&&b.doneData?J(b.doneData,t.context,e):void 0;this._doneEvent=dt(this.id,x);try{for(var S=s(this.doneListeners),w=S.next();!w.done;w=S.next()){(0,w.value)(this._doneEvent)}}catch(t){u={error:t}}finally{try{w&&!w.done&&(h=S.return)&&h.call(S)}finally{if(u)throw u.error}}this._stop(),this._stopChildren(),Jt(this.sessionId)}},t.prototype.onTransition=function(t){return this.listeners.add(t),this.status===$t.Running&&t(this.state,this.state.event),this},t.prototype.subscribe=function(t,e,n){var i=this,r=it(t,e,n);this.listeners.add(r.next),this.status!==$t.NotStarted&&r.next(this.state);var o=function(){i.doneListeners.delete(o),i.stopListeners.delete(o),r.complete()};return this.status===$t.Stopped?r.complete():(this.onDone(o),this.onStop(o)),{unsubscribe:function(){i.listeners.delete(r.next),i.doneListeners.delete(o),i.stopListeners.delete(o)}}},t.prototype.onEvent=function(t){return this.eventListeners.add(t),this},t.prototype.onSend=function(t){return this.sendListeners.add(t),this},t.prototype.onChange=function(t){return this.contextListeners.add(t),this},t.prototype.onStop=function(t){return this.stopListeners.add(t),this},t.prototype.onDone=function(t){return this.status===$t.Stopped&&this._doneEvent?t(this._doneEvent):this.doneListeners.add(t),this},t.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},t.prototype.start=function(t){var e=this;if(this.status===$t.Running)return this;this.machine._init(),Ut(this.sessionId,this),this.initialized=!0,this.status=$t.Running;var n=void 0===t?this.initialState:gt(this,(function(){return Ct(t)?e.machine.resolveState(t):e.machine.resolveState(Vt.from(t,e.machine.context))}));return this.options.devTools&&this.attachDev(),this.scheduler.initialize((function(){e.update(n,at)})),this},t.prototype._stopChildren=function(){this.children.forEach((function(t){Q(t.stop)&&t.stop()})),this.children.clear()},t.prototype._stop=function(){var t,e,n,i,r,o,a,c,u,h;try{for(var f=s(this.listeners),l=f.next();!l.done;l=f.next()){var d=l.value;this.listeners.delete(d)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(e=f.return)&&e.call(f)}finally{if(t)throw t.error}}try{for(var v=s(this.stopListeners),p=v.next();!p.done;p=v.next()){(d=p.value)(),this.stopListeners.delete(d)}}catch(t){n={error:t}}finally{try{p&&!p.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}try{for(var y=s(this.contextListeners),g=y.next();!g.done;g=y.next()){d=g.value;this.contextListeners.delete(d)}}catch(t){r={error:t}}finally{try{g&&!g.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}try{for(var m=s(this.doneListeners),b=m.next();!b.done;b=m.next()){d=b.value;this.doneListeners.delete(d)}}catch(t){a={error:t}}finally{try{b&&!b.done&&(c=m.return)&&c.call(m)}finally{if(a)throw a.error}}if(!this.initialized)return this;this.initialized=!1,this.status=$t.Stopped,this._initialState=void 0;try{for(var x=s(Object.keys(this.delayedEventsMap)),S=x.next();!S.done;S=x.next()){var w=S.value;this.clock.clearTimeout(this.delayedEventsMap[w])}}catch(t){u={error:t}}finally{try{S&&!S.done&&(h=x.return)&&h.call(x)}finally{if(u)throw u.error}}this.scheduler.clear(),this.scheduler=new It({deferEvents:this.options.deferEvents})},t.prototype.stop=function(){var t=this,e=this.scheduler;return this._stop(),e.schedule((function(){var e;if(!(null===(e=t._state)||void 0===e?void 0:e.done)){var n=Z({type:"xstate.stop"}),i=gt(t,(function(){var e=M(u([],c(t.state.configuration),!1).sort((function(t,e){return e.order-t.order})).map((function(e){return ut(e.onExit,t.machine.options.actions)}))),i=c(pt(t.machine,t.state,t.state.context,n,[{type:"exit",actions:e}],t.machine.config.predictableActionArguments?t._exec:void 0,t.machine.config.predictableActionArguments||t.machine.config.preserveActionOrder),2),r=i[0],o=i[1],a=new Vt({value:t.state.value,context:o,_event:n,_sessionid:t.sessionId,historyValue:void 0,history:t.state,actions:r.filter((function(t){return!ot(t)})),activities:{},events:[],configuration:[],transitions:[],children:{},done:t.state.done,tags:t.state.tags,machine:t.machine});return a.changed=!0,a}));t.update(i,n),t._stopChildren(),Jt(t.sessionId)}})),this},t.prototype.batch=function(t){var e=this;if(this.status===$t.NotStarted&&this.options.deferEvents)N||$(!1,"".concat(t.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'" and are deferred. Make sure .start() is called for this service.\nEvent: ').concat(JSON.stringify(event)));else if(this.status!==$t.Running)throw new Error("".concat(t.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));if(t.length){var n=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule((function(){var i,r,a=e.state,h=!1,f=[],l=function(t){var i=Z(t);e.forward(i),a=gt(e,(function(){return e.machine.transition(a,i,void 0,n||void 0)})),f.push.apply(f,u([],c(e.machine.config.predictableActionArguments?a.actions:a.actions.map((function(t){return function(t,e){var n=t.exec;return o(o({},t),{exec:void 0!==n?function(){return n(e.context,e.event,{action:t,state:e,_event:e._event})}:void 0})}(t,a)}))),!1)),h=h||!!a.changed};try{for(var d=s(t),v=d.next();!v.done;v=d.next()){l(v.value)}}catch(t){i={error:t}}finally{try{v&&!v.done&&(r=d.return)&&r.call(d)}finally{if(i)throw i.error}}a.changed=h,a.actions=f,e.update(a,Z(t[t.length-1]))}))}},t.prototype.sender=function(t){return this.send.bind(this,t)},t.prototype._nextState=function(t,e){var n=this;void 0===e&&(e=!!this.machine.config.predictableActionArguments&&this._exec);var i=Z(t);if(0===i.name.indexOf(S)&&!this.state.nextEvents.some((function(t){return 0===t.indexOf(S)})))throw i.data.data;return gt(this,(function(){return n.machine.transition(n.state,i,void 0,e||void 0)}))},t.prototype.nextState=function(t){return this._nextState(t,!1)},t.prototype.forward=function(t){var e,n;try{for(var i=s(this.forwardTo),r=i.next();!r.done;r=i.next()){var o=r.value,a=this.children.get(o);if(!a)throw new Error("Unable to forward event '".concat(t,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(o,"'."));a.send(t)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},t.prototype.defer=function(t){var e=this,n=this.clock.setTimeout((function(){"to"in t&&t.to?e.sendTo(t._event,t.to,!0):e.send(t._event)}),t.delay);t.id&&(this.delayedEventsMap[t.id]=n)},t.prototype.cancel=function(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]},t.prototype.exec=function(t,e,n){void 0===n&&(n=this.machine.options.actions),this._exec(t,e.context,e._event,n)},t.prototype.removeChild=function(t){var e;this.children.delete(t),this.forwardTo.delete(t),null===(e=this.state)||void 0===e||delete e.children[t]},t.prototype.stopChild=function(t){var e=this.children.get(t);e&&(this.removeChild(t),Q(e.stop)&&e.stop())},t.prototype.spawn=function(t,e,n){if(this.status!==$t.Running)return bt(t,e);if(B(t))return this.spawnPromise(Promise.resolve(t),e);if(Q(t))return this.spawnCallback(t,e);if(function(t){try{return"function"==typeof t.send}catch(t){return!1}}(r=t)&&"id"in r)return this.spawnActor(t,e);if(function(t){try{return"subscribe"in t&&Q(t.subscribe)}catch(t){return!1}}(t))return this.spawnObservable(t,e);if(K(t))return this.spawnMachine(t,o(o({},n),{id:e}));if(null!==(i=t)&&"object"==typeof i&&"transition"in i&&"function"==typeof i.transition)return this.spawnBehavior(t,e);throw new Error('Unable to spawn entity "'.concat(e,'" of type "').concat(typeof t,'".'));var i,r},t.prototype.spawnMachine=function(e,n){var i=this;void 0===n&&(n={});var r=new t(e,o(o({},this.options),{parent:this,id:n.id||e.id})),a=o(o({},Xt),n);a.sync&&r.onTransition((function(t){i.send(_,{state:t,id:r.id})}));var s=r;return this.children.set(r.id,s),a.autoForward&&this.forwardTo.add(r.id),r.onDone((function(t){i.removeChild(r.id),i.send(Z(t,{origin:r.id}))})).start(),s},t.prototype.spawnBehavior=function(t,e){var n=qt(t,{id:e,parent:this});return this.children.set(e,n),n},t.prototype.spawnPromise=function(t,e){var n,i,r=this,o=!1;t.then((function(t){o||(i=t,r.removeChild(e),r.send(Z(dt(e,t),{origin:e})))}),(function(t){if(!o){r.removeChild(e);var n=vt(e,t);try{r.send(Z(n,{origin:e}))}catch(i){!function(t,e,n){if(!N){var i=t.stack?" Stacktrace was '".concat(t.stack,"'"):"";if(t===e)console.error("Missing onError handler for invocation '".concat(n,"', error was '").concat(t,"'.").concat(i));else{var r=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(n,"'. ")+"Original error: '".concat(t,"'. ").concat(i," Current error is '").concat(e,"'.").concat(r))}}}(t,i,e),r.devTools&&r.devTools.send(n,r.state),r.machine.strict&&r.stop()}}}));var a=((n={id:e,send:function(){},subscribe:function(e,n,i){var r=it(e,n,i),o=!1;return t.then((function(t){o||(r.next(t),o||r.complete())}),(function(t){o||r.error(t)})),{unsubscribe:function(){return o=!0}}},stop:function(){o=!0},toJSON:function(){return{id:e}},getSnapshot:function(){return i}})[G]=function(){return this},n);return this.children.set(e,a),a},t.prototype.spawnCallback=function(t,e){var n,i,r,o=this,a=!1,s=new Set,c=new Set;try{r=t((function(t){i=t,c.forEach((function(e){return e(t)})),a||o.send(Z(t,{origin:e}))}),(function(t){s.add(t)}))}catch(t){this.send(vt(e,t))}if(B(r))return this.spawnPromise(r,e);var u=((n={id:e,send:function(t){return s.forEach((function(e){return e(t)}))},subscribe:function(t){var e=it(t);return c.add(e.next),{unsubscribe:function(){c.delete(e.next)}}},stop:function(){a=!0,Q(r)&&r()},toJSON:function(){return{id:e}},getSnapshot:function(){return i}})[G]=function(){return this},n);return this.children.set(e,u),u},t.prototype.spawnObservable=function(t,e){var n,i,r=this,o=t.subscribe((function(t){i=t,r.send(Z(t,{origin:e}))}),(function(t){r.removeChild(e),r.send(Z(vt(e,t),{origin:e}))}),(function(){r.removeChild(e),r.send(Z(dt(e),{origin:e}))})),a=((n={id:e,send:function(){},subscribe:function(e,n,i){return t.subscribe(e,n,i)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return i},toJSON:function(){return{id:e}}})[G]=function(){return this},n);return this.children.set(e,a),a},t.prototype.spawnActor=function(t,e){return this.children.set(e,t),t},t.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)}else N||$(!1,"No implementation found for activity '".concat(t.type,"'"))},t.prototype.spawnEffect=function(t,e){var n;this.children.set(t,((n={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:e||void 0,getSnapshot:function(){},toJSON:function(){return{id:t}}})[G]=function(){return this},n))},t.prototype.attachDev=function(){var t=Bt();if(this.options.devTools&&t){if(t.__REDUX_DEVTOOLS_EXTENSION__){var e="object"==typeof this.options.devTools?this.options.devTools:void 0;this.devTools=t.__REDUX_DEVTOOLS_EXTENSION__.connect(o(o({name:this.id,autoPause:!0,stateSanitizer:function(t){return{value:t.value,context:t.context,actions:t.actions}}},e),{features:o({jump:!1,skip:!1},e?e.features:void 0)}),this.machine),this.devTools.init(this.state)}Ft(this)}},t.prototype.toJSON=function(){return{id:this.id}},t.prototype[G]=function(){return this},t.prototype.getSnapshot=function(){return this.status===$t.NotStarted?this.initialState:this._state},t.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(t,e){return setTimeout(t,e)},clearTimeout:function(t){return clearTimeout(t)}},logger:console.log.bind(console),devTools:!1},t.interpret=Ht,t}();function Ht(t,e){return new Qt(t,e)}function Wt(t){if("string"==typeof t){var e={type:t,toString:function(){return t}};return e}return t}function Gt(t){return o(o({type:x},t),{toJSON:function(){t.onDone,t.onError;var e=a(t,["onDone","onError"]);return o(o({},e),{type:x,src:Wt(t.src)})}})}var Kt="",Yt="*",Zt={},te=function(t){return"#"===t[0]},ee=function(){function t(e,n,i,r){void 0===i&&(i="context"in e?e.context:void 0);var a,h=this;this.config=e,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.tags=[],this.options=Object.assign({actions:{},guards:{},services:{},activities:{},delays:{}},n),this.parent=null==r?void 0:r.parent,this.key=this.config.key||(null==r?void 0:r.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||u([this.machine.key],c(this.path),!1).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&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:null!==(a=this.config.schema)&&void 0!==a?a:{},this.description=this.config.description,N||$(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?D(this.config.states,(function(e,n){var i,r=new t(e,{},void 0,{parent:h,key:n});return Object.assign(h.idMap,o(((i={})[r.id]=r,i),r.idMap)),r})):Zt;var f=0;!function t(e){var n,i;e.order=f++;try{for(var r=s(St(e)),o=r.next();!o.done;o=r.next()){t(o.value)}}catch(t){n={error:t}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}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===Kt})):Kt in this.config.on),this.strict=!!this.config.strict,this.onEntry=z(this.config.entry||this.config.onEntry).map((function(t){return ct(t)})),this.onExit=z(this.config.exit||this.config.onExit).map((function(t){return ct(t)})),this.meta=this.config.meta,this.doneData="final"===this.type?this.config.data:void 0,this.invoke=z(this.config.invoke).map((function(t,e){var n,i;if(K(t)){var r=rt(h.id,e);return h.machine.options.services=o(((n={})[r]=t,n),h.machine.options.services),Gt({src:r,id:r})}if(H(t.src)){r=t.id||rt(h.id,e);return Gt(o(o({},t),{id:r,src:t.src}))}if(K(t.src)||Q(t.src)){r=t.id||rt(h.id,e);return h.machine.options.services=o(((i={})[r]=t.src,i),h.machine.options.services),Gt(o(o({id:r},t),{src:r}))}var a=t.src;return Gt(o(o({id:rt(h.id,e)},t),{src:a}))})),this.activities=z(this.config.activities).concat(this.invoke).map((function(t){return ht(t)})),this.transition=this.transition.bind(this),this.tags=z(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||_t(this).forEach((function(t){return t.on}))},t.prototype.withConfig=function(e,n){var i=this.options,r=i.actions,a=i.activities,s=i.guards,c=i.services,u=i.delays;return new t(this.config,{actions:o(o({},r),e.actions),activities:o(o({},a),e.activities),guards:o(o({},s),e.guards),services:o(o({},c),e.services),delays:o(o({},u),e.delays)},null!=n?n:this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return Q(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.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,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return this.definition},Object.defineProperty(t.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(t.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),t.prototype.getCandidates=function(t){if(this.__cache.candidates[t])return this.__cache.candidates[t];var e=t===Kt,n=this.transitions.filter((function(n){var i=n.eventType===t;return e?i:i||n.eventType===Yt}));return this.__cache.candidates[t]=n,n},t.prototype.getDelayedTransitions=function(){var t=this,e=this.config.after;if(!e)return[];var n=function(e,n){var r=function(t,e){var n=e?"#".concat(e):"";return"".concat(i.After,"(").concat(t,")").concat(n)}(Q(e)?"".concat(t.id,":delay[").concat(n,"]"):e,t.id);return t.onEntry.push(ft(r,{delay:e})),t.onExit.push({type:p,sendId:r}),r};return(X(e)?e.map((function(t,e){var i=n(t.delay,e);return o(o({},t),{event:i})})):M(Object.keys(e).map((function(t,i){var r=e[t],a=H(r)?{target:r}:r,s=isNaN(+t)?t:+t,c=n(s,i);return z(a).map((function(t){return o(o({},t),{event:c,delay:s})}))})))).map((function(e){var n=e.delay;return o(o({},t.formatTransition(e)),{delay:n})}))},t.prototype.getStateNodes=function(t){var e,n=this;if(!t)return[];var i=t instanceof Vt?t.value:C(t,this.delimiter);if(H(i)){var r=this.getStateNode(i).initial;return void 0!==r?this.getStateNodes(((e={})[i]=r,e)):[this,this.states[i]]}var o=Object.keys(i),a=[this];return a.push.apply(a,u([],c(M(o.map((function(t){return n.getStateNode(t).getStateNodes(i[t])})))),!1)),a},t.prototype.handles=function(t){var e=A(t);return this.events.includes(e)},t.prototype.resolveState=function(t){var e=t instanceof Vt?t:Vt.create(t),n=Array.from(Et([],this.getStateNodes(e.value)));return new Vt(o(o({},e),{value:this.resolve(e.value),configuration:n,done:Tt(n,this),tags:At(n),machine:this.machine}))},t.prototype.transitionLeafNode=function(t,e,n){var i=this.getStateNode(t).next(e,n);return i&&i.transitions.length?i:this.next(e,n)},t.prototype.transitionCompoundNode=function(t,e,n){var i=Object.keys(t),r=this.getStateNode(i[0])._transition(t[i[0]],e,n);return r&&r.transitions.length?r:this.next(e,n)},t.prototype.transitionParallelNode=function(t,e,n){var i,r,o={};try{for(var a=s(Object.keys(t)),c=a.next();!c.done;c=a.next()){var u=c.value,h=t[u];if(h){var f=this.getStateNode(u)._transition(h,e,n);f&&(o[u]=f)}}}catch(t){i={error:t}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}var l=Object.keys(o).map((function(t){return o[t]})),d=M(l.map((function(t){return t.transitions})));if(!l.some((function(t){return t.transitions.length>0})))return this.next(e,n);var v=M(Object.keys(o).map((function(t){return o[t].configuration})));return{transitions:d,exitSet:M(l.map((function(t){return t.exitSet}))),configuration:v,source:e,actions:M(Object.keys(o).map((function(t){return o[t].actions})))}},t.prototype._transition=function(t,e,n){return H(t)?this.transitionLeafNode(t,e,n):1===Object.keys(t).length?this.transitionCompoundNode(t,e,n):this.transitionParallelNode(t,e,n)},t.prototype.getTransitionData=function(t,e){return this._transition(t.value,t,Z(e))},t.prototype.next=function(t,e){var n,i,r,o=this,a=e.name,h=[],f=[];try{for(var l=s(this.getCandidates(a)),d=l.next();!d.done;d=l.next()){var v=d.value,p=v.cond,y=v.in,g=t.context,m=!y||(H(y)&&te(y)?t.matches(C(this.getStateNodeById(y).path,this.delimiter)):T(C(y,this.delimiter),L(this.path.slice(0,-2))(t.value))),b=!1;try{b=!p||et(this.machine,p,g,e,t)}catch(t){throw new Error("Unable to evaluate guard '".concat(p.name||p.type,"' in transition for event '").concat(a,"' in state node '").concat(this.id,"':\n").concat(t.message))}if(b&&m){void 0!==v.target&&(f=v.target),h.push.apply(h,u([],c(v.actions),!1)),r=v;break}}}catch(t){n={error:t}}finally{try{d&&!d.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}if(r){if(!f.length)return{transitions:[r],exitSet:[],configuration:t.value?[this]:[],source:t,actions:h};var x=M(f.map((function(e){return o.getRelativeStateNodes(e,t.historyValue)})));return{transitions:[r],exitSet:!!r.internal?[]:M(f.map((function(t){return o.getPotentiallyReenteringNodes(t)}))),configuration:x,source:t,actions:h}}},t.prototype.getPotentiallyReenteringNodes=function(t){if(this.order<t.order)return[this];for(var e=[],n=this,i=t;n&&n!==i;)e.push(n),n=n.parent;return n!==i?[]:(e.push(i),e)},t.prototype.getActions=function(t,e,n,r,o,a,h){var f,l,v,p,y=this,g=a?Et([],this.getStateNodes(a.value)):[],m=new Set;try{for(var b=s(Array.from(t).sort((function(t,e){return t.order-e.order}))),x=b.next();!x.done;x=b.next()){(!Nt(g,_=x.value)||Nt(n.exitSet,_)||_.parent&&m.has(_.parent))&&m.add(_)}}catch(t){f={error:t}}finally{try{x&&!x.done&&(l=b.return)&&l.call(b)}finally{if(f)throw f.error}}try{for(var S=s(g),w=S.next();!w.done;w=S.next()){var _;Nt(t,_=w.value)&&!Nt(n.exitSet,_.parent)||n.exitSet.push(_)}}catch(t){v={error:t}}finally{try{w&&!w.done&&(p=S.return)&&p.call(S)}finally{if(v)throw v.error}}n.exitSet.sort((function(t,e){return e.order-t.order}));var E=Array.from(m).sort((function(t,e){return t.order-e.order})),O=new Set