1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,627897,t=>{"use strict";let e,r="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),n=new Uint8Array(16),s=[];for(let t=0;t<256;++t)s.push((t+256).toString(16).slice(1));t.s(["v4",0,function(t,i,o){if(r&&!i&&!t)return r();var a=t,u=o;let c=(a=a||{}).random??a.rng?.()??function(){if(!e){if("u"<typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");e=crypto.getRandomValues.bind(crypto)}return e(n)}();if(c.length<16)throw Error("Random bytes length must be >= 16");if(c[6]=15&c[6]|64,c[8]=63&c[8]|128,i){if((u=u||0)<0||u+16>i.length)throw RangeError(`UUID byte range ${u}:${u+15} is out of buffer bounds`);for(let t=0;t<16;++t)i[u+t]=c[t];return i}return function(t,e=0){return(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase()}(c)}],627897)},574640,297017,t=>{"use strict";var e;let r=e=>{if("u"<typeof window)return;let r=function(){let e="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:t.g;if(e.__xstate__)return e.__xstate__}();r&&r.register(e)};t.s(["devToolsAdapter",()=>r],297017);class n{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){let e={value:t,next:null};if(this._current){this._last.next=e,this._last=e;return}this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){let t=this._current;this._process(t.value),this._current=t.next}this._last=null}}let s="xstate.init",i="xstate.stop";function o(t,e){return{type:`xstate.done.state.${t}`,output:e}}function a(t,e){return{type:`xstate.error.actor.${t}`,error:e,actorId:t}}function u(t){return{type:s,input:t}}function c(t){setTimeout(()=>{throw t})}let l="function"==typeof Symbol&&Symbol.observable||"@@observable";function f(t){if(v(t))return t;let e=[],r="";for(let n=0;n<t.length;n++){switch(t.charCodeAt(n)){case 92:r+=t[n+1],n++;continue;case 46:e.push(r),r="";
1continue}r+=t[n]}return e.push(r),e}function p(t){var e;return(e=t)&&"object"==typeof e&&"machine"in e&&"value"in e?t.value:"string"!=typeof t?t:function(t){if(1===t.length)return t[0];let e={},r=e;for(let e=0;e<t.length-1;e++)if(e===t.length-2)r[t[e]]=t[e+1];else{let n=r;r={},n[t[e]]=r}return e}(f(t))}function h(t,e){let r={},n=Object.keys(t);for(let s=0;s<n.length;s++){let i=n[s];r[i]=e(t[i],i,t,s)}return r}function d(t){var e;return void 0===t?[]:v(e=t)?e:[e]}function y(t,e,r,n){return"function"==typeof t?t({context:e,event:r,self:n}):t}function v(t){return Array.isArray(t)}function g(t){var e;return(v(e=t)?e:[e]).map(t=>void 0===t||"string"==typeof t?{target:t}:t)}function m(t){if(void 0!==t&&""!==t)return d(t)}function b(t,e,r){let n="object"==typeof t,s=n?t:void 0;return{next:(n?t.next:t)?.bind(s),error:(n?t.error:e)?.bind(s),complete:(n?t.complete:r)?.bind(s)}}function _(t,e){return`${e}.${t}`}function S(t,e){let r=e.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!r)return t.implementations.actors[e];let[,n,s]=r,i=t.getStateNodeById(s).config.invoke;return(Array.isArray(i)?i[n]:i).src}function x(t,e){if(e===t||"*"===e)return!0;if(!e.endsWith(".*"))return!1;let r=e.split("."),n=t.split(".");for(let t=0;t<r.length;t++){let e=r[t],s=n[t];if("*"===e)return t===r.length-1;if(e!==s)return!1}return!0}function w(t,e){return`${t.sessionId}.${e}`}let k=0,E=!1,I=((e={})[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e),T={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class A{constructor(t,e){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new n(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=I.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const r={...T,...e},{clock:s,logger:i,parent:o,syncSnapshot:a,id:u,systemId:l,inspect:f}=r;this.system=o?o.system:function(t,e){let r=new Map,n=new Map,s=new WeakMap,i=new Set,o={},{clock:a,logger:u}=e,c={schedule:(t,e,r,n,s=Math.random().toString(36).slice(2))=>{let i={source:t,target:e,event:r,delay:n,id:s,startedAt:Date.now()},u=w(t,s);l._snapshot._scheduledEvents[u]=i;let c=a.setTimeout(()=>{delete o[u],delete l._snapshot._scheduledEvents[u],l._relay(t,e,r)},n);o[u]=c},cancel:(t,e)=>{let r=w(t,e),n=o[r];delete o[r],delete l._snapshot._scheduledEvents[r],void 0!==n&&a.clearTimeout(n)},cancelAll:t=>{for(let e in l._snapshot._scheduledEvents){let r=l._snapshot._scheduledEvents[e];r.source===t&&c.cancel(t,r.id)}}},l={_snapshot:{_scheduledEvents:(e?.snapshot&&e.snapshot.scheduler)??{}},_bookId:()=>`x:${k++}`,_register:(t,e)=>(r.set(t,e),t),_unregister:t=>{r.delete(t.sessionId);let e=s.get(t);void 0!==e&&(n.delete(e),s.delete(t))},get:t=>n.get(t),getAll:()=>Object.fromEntries(n.entries()),_set:(t,e)=>{let r=n.get(t);if(r&&r!==e)throw Error(`Actor with system ID '${t}' already exists.`);n.set(t,e),s.set(e,t)},inspect:t=>{let e=b(t);return i.add(e),{unsubscribe(){i.delete(e)}}},_sendInspectionEvent:e=>{if(!i.size)return;let r={...e,rootId:t.sessionId};i.forEach(t=>t.next?.(r))},_relay:(t,e,r)=>{l._sendInspectionEvent({type:"@xstate.event",sourceRef:t,actorRef:e,event:r}),e._send(r)},scheduler:c,getSnapshot:()=>({_scheduledEvents:{...l._snapshot._scheduledEvents}}),start:()=>{let t=l._snapshot._scheduledEvents;for(let e in l._snapshot._scheduledEvents={},t){let{source:r,target:n,event:s,delay:i,id:o}=t[e];c.schedule(r,n,s,i,o)}},_clock:a,_logger:u};return l}(this,{clock:s,logger:i}),f&&!o&&this.system.inspect(b(f)),this.sessionId=this.system._bookId(),this.id=u??this.sessionId,this.logger=e?.logger??this.system._logger,this.clock=e?.clock??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=r,this.src=r.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:t=>{this._deferred.push(t)},system:this.system,stopChild:t=>{if(t._parent!==this)throw Error(`Cannot stop child actor ${t.id} of ${this.id} because it is not a child`);t._stop()},emit:t=>{let e=this.eventListeners.get(t.type),r=this.eventListeners.get("*");if(e||r)for(let n of[...e?e.values():[],...r?r.values():[]])try{n(t)}catch(t){c(t)}},actionExecutor:t=>{let e=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:t.type,params:t.params}}),!t.exec)return;let e=E;try{E=!0,t.exec(t.info,t.params)}finally{E=e}};this._processingStatus===I.Running?e():this._deferred.push(e)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),l&&(this.systemId=l,this.system._set(l,this)),this._initState(e?.snapshot??e?.state),l&&"active"!==this._snapshot.status&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(t){this._snapshot={status:"error",output:void 0,error:t}}}update(t,e){let r;for(this._snapshot=t;r=this._deferred.shift();)try{r()}catch(e){this._deferred.length=0,this._snapshot={...t,status:"error",error:e}}switch(this._snapshot.status){case"active":for(let e of this.observers)try{e.
1next?.(t)}catch(t){c(t)}break;case"done":var n;for(let e of this.observers)try{e.next?.(t)}catch(t){c(t)}this._stopProcedure(),this._complete(),this._doneEvent=(n=this.id,{type:`xstate.done.actor.${n}`,output:this._snapshot.output,actorId:n}),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error)}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:e,snapshot:t})}subscribe(t,e,r){let n=b(t,e,r);if(this._processingStatus!==I.Stopped)this.observers.add(n);else switch(this._snapshot.status){case"done":try{n.complete?.()}catch(t){c(t)}break;case"error":{let t=this._snapshot.error;if(n.error)try{n.error(t)}catch(t){c(t)}else c(t)}}return{unsubscribe:()=>{this.observers.delete(n)}}}on(t,e){let r=this.eventListeners.get(t);r||(r=new Set,this.eventListeners.set(t,r));let n=e.bind(void 0);return r.add(n),{unsubscribe:()=>{r.delete(n)}}}start(){if(this._processingStatus===I.Running)return this;this._syncSnapshot&&this.subscribe({next:t=>{"active"===t.status&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:t})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=I.Running;let t=u(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(t){return this._snapshot={...this._snapshot,status:"error",error:t},this._error(t),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let e,r;try{e=this.logic.transition(this._snapshot,t,this._actorScope)}catch(t){r={err:t}}if(r){let{err:t}=r;this._snapshot={...this._snapshot,status:"error",error:t},this._error(t);return}this.update(e,t),t.type===i&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===I.Stopped||((this.mailbox.clear(),this._processingStatus===I.NotStarted)?this._processingStatus=I.Stopped:this.mailbox.enqueue({type:i})),this}stop(){if(this._parent)throw Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let t of this.observers)try{t.complete?.()}catch(t){c(t)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||c(t),this.eventListeners.clear();return}let e=!1;for(let r of this.observers){let n=r.error;e||=!n;try{n?.(t)}catch(t){c(t)}}this.observers.clear(),this.eventListeners.clear(),e&&c(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,a(this.id,t))}_stopProcedure(){return this._processingStatus!==I.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new n(this._process.bind(this)),this._processingStatus=I.Stopped,this.system._unregister(this)),this}_send(t){this._processingStatus!==I.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){let{devTools:t}=this.options;t&&("function"==typeof t?t:r)(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[l](){return this}getSnapshot(){return this._snapshot}}function O(t,...[e]){return new A(t,e)}function $(t,e,r,n,{sendId:s}){return[e,{sendId:"function"==typeof s?s(r,n):s},void 0]}function R(t,e){t.defer(()=>{t.system.scheduler.cancel(t.self,e.sendId)})}function q(t){function e(t,e){}return e.type="xstate.cancel",e.sendId=t,e.resolve=$,e.execute=R,e}function M(t,e,r,n,{id:s,systemId:i,src:o,input:a,syncSnapshot:u}){let c,l,f="string"==typeof o?S(e.machine,o):o,p="function"==typeof s?s(r):s;return f&&(l="function"==typeof a?a({context:e.context,event:r.event,self:t.self}):a,c=O(f,{id:p,src:o,parent:t.self,syncSnapshot:u,systemId:i,input:l})),[tO(e,{children:{...e.children,[p]:c}}),{id:s,systemId:i,actorRef:c,src:o,input:l},void 0]}function j(t,{actorRef:e}){e&&t.defer(()=>{e._processingStatus!==I.Stopped&&e.start()})}function P(...[t,{id:e,systemId:r,input:n,syncSnapshot:s=!1}={}]){function i(t,e){}return i.type="xstate.spawnChild",i.id=e,i.systemId=r,i.src=t,i.input=n,i.syncSnapshot=s,i.resolve=M,i.execute=j,i}function N(t,e,r,n,{actorRef:s}){let i="function"==typeof s?s(r,n):s,o="string"==typeof i?e.children[i]:i,a=e.children;return o&&(a={...a},delete a[o.id]),[tO(e,{children:a}),o,void 0]}function C(t,e){if(e){if(!function t(e,r){let n=r.getSnapshot();if(n&&"children"in n)for(let r of Object.values(n.children))t(e,r);e.system._unregister(r)}(t,e),e._processingStatus!==I.Running)return void t.stopChild(e);t.defer(()=>{t.stopChild(e)})}}function L(t){function e(t,e){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=N,e.execute=C,e}function D(t,{context:e,event:r},{guards:n}){return!z(n[0],e,r,t)}function F(t){function e(t,e){return!1}return e.check=D,e.guards=[t],e}function U(t,{context:e,event:r},{guards:n}){return n.every(n=>z(n,e,r,t))}function B(t){function e(t,e){return!1}return e.check=U,e.guards=t,e}function z(t,e,r,n){let{machine:s}=n,i="function"==typeof t,o=i?t:s.implementations.guards["string"==typeof t?t:t.type];if(!i&&!o)throw Error(`Guard '${"string"==typeof t?t:t.type}' is not implemented.'.`);if("function"!=typeof o)return z(o,e,r,n);let a={context:e,event:r},u=i||"string"==typeof t?void 0:"params"in t?"function"==typeof t.params?t.params({context:e,event:r}):t.params:void 0;return"check"in o?o.check(n,a,o):o(a,u)}function V(t){return"atomic"===t.type||"final"===t.type}function J(t){return Object.values(t.states).filter(t=>"history"!==t.type)}function W(t,e){let r=[];if(e===t)return r;let n=t.parent;for(;n&&n!==e;)r.push(n),n=n.parent;return r}function G(t){let e=new Set(t),r=H(e);for(let t of e)if("compound"!==t.type||r.get(t)&&r.get(t).length){if("parallel"===t.type){for(let r of J(t))if("history"!==r.type&&!e.has(r))for(let t of ti(r))e.add(t)}}else ti(t).forEach(t=>e.add(t));for(let t of e){let r=t.parent;for(;r;)e.add(r),r=r.parent}return e}function H(t){let e=new Map;for(let r of t)e.has(r)||e.set(r,[]),r.parent&&(e.has(r.parent)||e.set(r.parent,[]),e.get(r.parent).push(r));return e}function Y(t,e){return function t(e,r){let n=r.get(e);if(!n)return{};if("compound"===e.type){let t=n[0];if(!t)return{};if(V(t))return t.key}let s={};for(let e of n)s[e.key]=t(e,r);return s}(t,H(G(e)))}function K(t,e){return"compound"===e.type?J(e).some(e=>"final"===e.type&&t.has(e)):"parallel"===e.type?J(e).every(e=>K(t,e)):"final"===e.type}let X=t=>"#"===t[0];function Q(t,e){return t.transitions.get(e)||[...t.transitions.keys()].filter(t=>x(e,t)).sort((t,e)=>e.length-t.length).flatMap(e=>t.transitions.get(e))}function Z(t){let e=t.config.after;return e?Object.keys(e).flatMap(r=>{var n;let s,i,o=e[r],a=Number.isNaN(+r)?r:+r,u=(n=t.id,i=(s={type:`xstate.after.${a}.${n}`}).type,t.entry.push(tM(s,{id:i,delay:a})),t.exit.push(q(i)),i);return d("string"==typeof o?{target:o}:o).map(t=>({...t,event:u,delay:a}))}).map(e=>{let{delay:r}=e;return{...tt(t,e.event,e),delay:r}}):[]}function tt(t,e,r){let n=m(r.target),s=r.reenter??!1,i=function(t,e){if(void 0!==e)return e.map(e=>{if("string"!=typeof e)return e;if(X(e))return t.machine.getStateNodeById(e);let r="."===e[0];if(r&&!t.parent)return tu(t,e.slice(1));let n=r?t.key+e:e;if(t.parent)try{return tu(t.parent,n)}catch(e){throw Error(`Invalid transition definition for state node '${t.id}': 2${e.message}`)}throw Error(`Invalid target: "${e}" is not a valid target from the root node. Did you mean ".${e}"?`)})}(t,n),o={...r,actions:d(r.actions),guard:r.guard,target:i,source:t,reenter
2:s,eventType:e,toJSON:()=>({...o,source:`#${t.id}`,target:i?i.map(t=>`#${t.id}`):void 0})};return o}function te(t){let e=new Map;if(t.config.on)for(let r of Object.keys(t.config.on)){if(""===r)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let n=t.config.on[r];e.set(r,g(n).map(e=>tt(t,r,e)))}if(t.config.onDone){let r=`xstate.done.state.${t.id}`;e.set(r,g(t.config.onDone).map(e=>tt(t,r,e)))}for(let r of t.invoke){if(r.onDone){let n=`xstate.done.actor.${r.id}`;e.set(n,g(r.onDone).map(e=>tt(t,n,e)))}if(r.onError){let n=`xstate.error.actor.${r.id}`;e.set(n,g(r.onError).map(e=>tt(t,n,e)))}if(r.onSnapshot){let n=`xstate.snapshot.${r.id}`;e.set(n,g(r.onSnapshot).map(e=>tt(t,n,e)))}}for(let r of t.after){let t=e.get(r.eventType);t||(t=[],e.set(r.eventType,t)),t.push(r)}return e}function tr(t,e){let r="string"==typeof e?t.states[e]:e?t.states[e.target]:void 0;if(!r&&e)throw Error(`Initial state node "${e}" not found on parent state node #${t.id}`);let n={source:t,actions:e&&"string"!=typeof e?d(e.actions):[],eventType:null,reenter:!1,target:r?[r]:[],toJSON:()=>({...n,source:`#${t.id}`,target:r?[`#${r.id}`]:[]})};return n}function tn(t){let e=m(t.config.target);return e?{target:e.map(e=>"string"==typeof e?tu(t.parent,e):e)}:t.parent.initial}function ts(t){return"history"===t.type}function ti(t){let e=to(t);for(let r of e)for(let n of W(r,t))e.add(n);return e}function to(t){let e=new Set;return!function t(r){if(!e.has(r)){if(e.add(r),"compound"===r.type)t(r.initial.target[0]);else if("parallel"===r.type)for(let e of J(r))t(e)}}(t),e}function ta(t,e){if(X(e))return t.machine.getStateNodeById(e);if(!t.states)throw Error(`Unable to retrieve child state '${e}' from '${t.id}'; no child states exist.`);let r=t.states[e];if(!r)throw Error(`Child state '${e}' does not exist on '${t.id}'`);return r}function tu(t,e){if("string"==typeof e&&X(e))try{return t.machine.getStateNodeById(e)}catch{}let r=f(e).slice(),n=t;for(;r.length;){let t=r.shift();if(!t.length)break;n=ta(n,t)}return n}function tc(t,e){if("string"==typeof e){let r=t.states[e];if(!r)throw Error(`State '${e}' does not exist on '${t.id}'`);return[t,r]}let r=Object.keys(e),n=r.map(e=>ta(t,e)).filter(Boolean);return[t.machine.root,t].concat(n,r.reduce((r,n)=>{let s=ta(t,n);if(!s)return r;let i=tc(s,e[n]);return r.concat(i)},[]))}function tl(t,e){let r=t;for(;r.parent&&r.parent!==e;)r=r.parent;return r.parent===e}function tf(t,e,r){let n=new Set;for(let s of t){let t=!1,i=new Set;for(let o of n)if(function(t,e){let r=new Set(t),n=new Set(e);for(let t of r)if(n.has(t))return!0;for(let t of n)if(r.has(t))return!0;return!1}(td([s],e,r),td([o],e,r)))if(tl(s.source,o.source))i.add(o);else{t=!0;break}if(!t){for(let t of i)n.delete(t);n.add(s)}}return Array.from(n)}function tp(t,e){if(!t.target)return[];let r=new Set;for(let n of t.target)if(ts(n))if(e[n.id])for(let t of e[n.id])r.add(t);else for(let t of tp(tn(n),e))r.add(t);else r.add(n);return[...r]}function th(t,e){let r=tp(t,e);if(!r)return;if(!t.reenter&&r.every(e=>e===t.source||tl(e,t.source)))return t.source;let n=function(t){let[e,...r]=t;for(let t of W(e,void 0))if(r.every(e=>tl(e,t)))return t}(r.concat(t.source));return n||(t.reenter?void 0:t.source.machine.root)}function td(t,e,r){let n=new Set;for(let s of t)if(s.target?.length){let t=th(s,r);for(let r of(s.reenter&&s.source===t&&n.add(t),e))tl(r,t)&&n.add(r)}return[...n]}function ty(t,e,r,n,s,i){if(!t.length)return e;let a=new Set(e._nodes),u=e.historyValue,c=tf(t,a,u),l=e;s||([l,u]=function(t,e,r,n,s,i,o,a){let u,c=t,l=td(n,s,i);for(let t of(l.sort((t,e)=>e.order-t.order),l))for(let e of function(t){return Object.keys(t.states).map(e=>t.states[e]).filter(t=>"history"===t.type)}(t)){let r;r="deep"===e.history?e=>V(e)&&tl(e,t):e=>e.parent===t,(u??={...i})[e.id]=Array.from(s).filter(r)}for(let t of l)c=tm(c,e,r,[...t.exit,...t.invoke.map(t=>L(t.id))],o,void 0),s.delete(t);return[c,u||i]}(l,n,r,c,a,u,i,r.actionExecutor)),l=function(t,e,r,n,s,i,a,u){let c=t,l=new Set,f=new Set;(function(t,e,r,n){for(let s of t){let t=th(s,e);for(let i of s.target||[])!ts(i)&&(s.source!==i||s.source!==t||s.reenter)&&(n.add(i),r.add(i)),tv(i,e,r,n);for(let i of tp(s,e)){let o=W(i,t);t?.type==="parallel"&&o.push(t),tg(n,e,r,o,!s.source.parent&&s.reenter?void 0:t)}}})(n,a,f,l),u&&f.add(t.machine.root);let p=new Set;for(let t of[...l].sort((t,e)=>t.order-e.order)){s.add(t);let n=[];for(let e of(n.push(...t.entry),t.invoke))n.push(P(e.src,{...e,syncSnapshot:!!e.onSnapshot}));if(f.has(t)){let e=t.initial.actions;n.push(...e)}if(c=tm(c,e,r,n,i,t.invoke.map(t=>
2t.id)),"final"===t.type){let n=t.parent,a=n?.type==="parallel"?n:n?.parent,u=a||t;for(n?.type==="compound"&&i.push(o(n.id,void 0!==t.output?y(t.output,c.context,e,r.self):void 0));a?.type==="parallel"&&!p.has(a)&&K(s,a);)p.add(a),i.push(o(a.id)),u=a,a=a.parent;if(a)continue;c=tO(c,{status:"done",output:function(t,e,r,n,s){if(void 0===n.output)return;let i=o(s.id,void 0!==s.output&&s.parent?y(s.output,t.context,e,r.self):void 0);return y(n.output,t.context,i,r.self)}(c,e,r,c.machine.root,u)})}}return c}(l=tm(l,n,r,c.flatMap(t=>t.actions),i,void 0),n,r,c,a,i,u,s);let f=[...a];"done"===l.status&&(l=tm(l,n,r,f.sort((t,e)=>e.order-t.order).flatMap(t=>t.exit),i,void 0));try{if(u===e.historyValue&&function(t,e){if(t.length!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;return!0}(e._nodes,a))return l;return tO(l,{_nodes:f,historyValue:u})}catch(t){throw t}}function tv(t,e,r,n){var s,i,o,a;if(ts(t))if(e[t.id]){let o=e[t.id];for(let t of o)n.add(t),tv(t,e,r,n);for(let a of o){s=a,i=t.parent,tg(n,e,r,W(s,i))}}else{let s=tn(t);for(let i of s.target)n.add(i),s===t.parent?.initial&&r.add(t.parent),tv(i,e,r,n);for(let i of s.target){o=i,a=t.parent,tg(n,e,r,W(o,a))}}else if("compound"===t.type){let[s]=t.initial.target;ts(s)||(n.add(s),r.add(s)),tv(s,e,r,n),tg(n,e,r,W(s,t))}else if("parallel"===t.type)for(let s of J(t).filter(t=>!ts(t)))[...n].some(t=>tl(t,s))||(ts(s)||(n.add(s),r.add(s)),tv(s,e,r,n))}function tg(t,e,r,n,s){for(let i of n)if((!s||tl(i,s))&&t.add(i),"parallel"===i.type)for(let n of J(i).filter(t=>!ts(t)))[...t].some(t=>tl(t,n))||(t.add(n),tv(n,e,r,t))}function tm(t,e,r,n,s,i){let o=i?[]:void 0,a=function t(e,r,n,s,i,o){let{machine:a}=e,u=e;for(let e of s){var c;let s="function"==typeof e,l=s?e:(c="string"==typeof e?e:e.type,a.implementations.actions[c]),f={context:u.context,event:r,self:n.self,system:n.system},p=s||"string"==typeof e?void 0:"params"in e?"function"==typeof e.params?e.params({context:u.context,event:r}):e.params:void 0;if(!l||!("resolve"in l)){n.actionExecutor({type:"string"==typeof e?e:"object"==typeof e?e.type:e.name||"(anonymous)",info:f,params:p,exec:l});continue}let[h,d,y]=l.resolve(n,u,f,p,l,i);u=h,"retryResolve"in l&&o?.push([l,d]),"execute"in l&&n.actionExecutor({type:l.type,info:f,params:d,exec:l.execute.bind(null,n,d)}),y&&(u=t(u,r,n,y,i,o))}return u}(t,e,r,n,{internalQueue:s,deferredActorIds:i},o);return o?.forEach(([t,e])=>{t.retryResolve(r,a,e)}),a}function tb(t,e,r,n){let o=t,a=[];function u(t,e,n){r.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:r.self,event:e,snapshot:t,_transitions:n}),a.push(t)}if(e.type===i)return u(o=tO(t_(o,e,r),{status:"stopped"}),e,[]),{snapshot:o,microstates:a};let c=e;if(c.type!==s){let e=c,s=e.type.startsWith("xstate.error.actor"),i=tS(e,o);if(s&&!i.length)return u(o=tO(t,{status:"error",error:e.error}),e,[]),{snapshot:o,microstates:a};u(o=ty(i,t,r,c,!1,n),e,i)}let l=!0;for(;"active"===o.status;){let t=l?function(t,e){let r=new Set;for(let n of t._nodes.filter(V))t:for(let s of[n].concat(W(n,void 0)))if(s.always){for(let n of s.always)if(void 0===n.guard||z(n.guard,t.context,e,t)){r.add(n);break t}}return tf(Array.from(r),new Set(t._nodes),t.historyValue)}(o,c):[],e=t.length?o:void 0;if(!t.length){if(!n.length)break;t=tS(c=n.shift(),o)}l=(o=ty(t,o,r,c,!1,n))!==e,u(o,c,t)}return"active"!==o.status&&t_(o,c,r),{snapshot:o,microstates:a}}function t_(t,e,r){return tm(t,e,r,Object.values(t.children).map(t=>L(t)),[],void 0)}function tS(t,e){return e.machine.getTransitionData(e,t)}function tx(t,e){let r=G(tc(t,e));return Y(t,[...r])}let tw=function(t){return function t(e,r){let n=p(e),s=p(r);return"string"==typeof s?"string"==typeof n&&s===n:"string"==typeof n?n in s:Object.keys(n).every(e=>e in s&&t(n[e],s[e]))}(t,this.value)},tk=function(t){return this.tags.has(t)},tE=function(t){let e=this.machine.getTransitionData(this,t);return!!e?.length&&e.some(t=>void 0!==t.target||t.actions.length)},tI=function(){let{_nodes:t,tags:e,machine:r,getMeta:n,toJSON:s,can:i,hasTag:o,matches:a,...u}=this;return{...u,tags:Array.from(e)}},tT=function(){return this._nodes.reduce((t,e)=>(void 0!==e.meta&&(t[e.id]=e.meta),t),{})};function tA(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:Y(e.root,t._nodes),tags:new Set(t._nodes.flatMap(t=>t.tags)),children:t.children,historyValue:t.historyValue||{},matches:tw,hasTag:tk,can:tE,getMeta:tT,toJSON:tI}}function tO(t,e={}){return tA({...t,...e},t.machine)}function t$(t,e){let{_nodes:r,tags:n,machine:s,children:i,context:o,can:a,hasTag:u,matches:c,getMeta:l,toJSON:f,...p}=t,h={};for(let t in i){let r=i[t];h[t]={snapshot:r.getPersistedSnapshot(e),src:r.src,systemId:r.systemId,syncSnapshot:r._syncSnapshot}}return{...p,context:function t(e){let r;for(let n in e){let s=e[n];if(s&&"object"==typeof s)if("sessionId"in s&&"send"in s&&"ref"in s)(r??=Array.isArray(e)?e.slice():{...e})[n]={xstate$$type:1,id:s.id};else{let i=t(s);i!==s&&((r??=Array.isArray(e)?e.slice():{...e})[n]=i)}}return r??e}(o),children:h,historyValue:function(t){if("object"!=typeof t||null===t)return{};let e={};for(let r in t){let n=t[r];Array.isArray(n)&&(e[r]=n.map(t=>({id:t.id})))}return e}(p.historyValue)}}function tR(t,e,r,n,{event:s,id:i,delay:o},{internalQueue:a}){let u,c=e.machine.implementations.delays;if("string"==typeof s)throw Error(`Only event objects may be used with raise; use raise({ type: "${s}" }) instead`);let l="function"==typeof s?s(r,n):s;if("string"==typeof o){let t=c&&c[o];u="function"==typeof t?t(r,n):t}else u="function"==typeof o?o(r,n):o;return"number"!=typeof u&&a.push(l),[e,{event:l,id:i,delay:u},void 0]}function tq(t,e){let{event:r,delay:n,id:s}=e;if("number"==typeof n)return void t.defer(()=>{let e=t.self;t.system.scheduler.schedule(e,e,r,n,s)})}function tM(t,e){function r(t,e){}return r.type="xstate.raise",r.event=t,r.id=e?.id,r.delay=e?.delay,r.resolve=tR,r.execute=tq,r}t.s(["$",()=>1,"B",()=>_,"C",()=>Z,"D",()=>tr,"E",()=>Q,"F",()=>tx,"G",()=>G,"H",()=>tA,"I",()=>K,"J",()=>tb,"K",()=>function t(e,r,n,s){if("string"==typeof r){let t;return(t=ta(e,r).next(n,s))&&t.length?t:e.next(n,s)}if(1===Object.keys(r).length){let i,o;
2return(o=t(ta(e,(i=Object.keys(r))[0]),r[i[0]],n,s))&&o.length?o:e.next(n,s)}let i=[];for(let o of Object.keys(r)){let a=r[o];if(!a)continue;let u=t(ta(e,o),a,n,s);u&&i.push(...u)}return i.length?i:e.next(n,s)},"L",()=>tm,"M",()=>u,"N",()=>"","O",()=>ty,"P",()=>to,"Q",()=>f,"R",()=>X,"S",()=>".","T",()=>tu,"U",()=>t$,"V",()=>S,"W",()=>"xstate.error","X",()=>i,"Y",()=>a,"Z",()=>I,"_",()=>tO,"a",()=>q,"b",()=>P,"c",()=>O,"e",()=>B,"g",()=>W,"i",()=>V,"j",()=>tc,"m",()=>x,"n",()=>F,"q",()=>b,"r",()=>tM,"s",()=>L,"t",()=>d,"v",()=>h,"w",()=>te,"x",()=>g,"y",()=>tt,"z",()=>z],574640)},747675,840603,369084,915520,t=>{"use strict";var e,r,n,s=t.i(574640);t.i(297017);let i=new WeakMap;function o(t){return{config:t,start:(e,r)=>{let{self:n,system:s,emit:o}=r,a={receivers:void 0,dispose:void 0};i.set(n,a),a.dispose=t({input:e.input,system:s,self:n,sendBack:t=>{"stopped"!==n.getSnapshot().status&&n._parent&&s._relay(n,n._parent,t)},receive:t=>{a.receivers??=new Set,a.receivers.add(t)},emit:o})},transition:(t,e,r)=>{let n=i.get(r.self);return e.type===s.X?(t={...t,status:"stopped",error:void 0},i.delete(r.self),n.receivers?.clear(),n.dispose?.()):n.receivers?.forEach(t=>t(e)),t},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t}}let a="xstate.observable.error",u="xstate.observable.complete";function c(t){return{config:t,transition:(t,e)=>{if("active"!==t.status)return t;switch(e.type){case a:return{...t,status:"error",error:e.data,input:void 0,_subscription:void 0};case u:return{...t,status:"done",input:void 0,_subscription:void 0};case s.X:return t._subscription.unsubscribe(),{...t,status:"stopped",input:void 0,_subscription:void 0};default:return t}},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,context:void 0,input:e,_subscription:void 0}),start:(e,{self:r,system:n,emit:s})=>{"done"!==e.status&&(e._subscription=t({input:e.input,system:n,self:r,emit:s}).subscribe({next:t=>{r._parent&&n._relay(r,r._parent,t)},error:t=>{n._relay(r,r,{type:a,data:t})},complete:()=>{n._relay(r,r,{type:u})}}))},getPersistedSnapshot:({_subscription:t,...e})=>e,restoreSnapshot:t=>({...t,_subscription:void 0})}}let l="xstate.promise.resolve",f="xstate.promise.reject",p=new WeakMap;function h(t){return{config:t,transition:(t,e,r)=>{if("active"!==t.status)return t;switch(e.type){case l:{let r=e.data;return{...t,status:"done",output:r,input:void 0}}case f:return{...t,status:"error",error:e.data,input:void 0};case s.X:return p.get(r.self)?.abort(),p.delete(r.self),{...t,status:"stopped",input:void 0};default:return t}},start:(e,{self:r,system:n,emit:s})=>{if("active"!==e.status)return;let i=new AbortController;p.set(r,i),Promise.resolve(t({input:e.input,system:n,self:r,signal:i.signal,emit:s})).then(t=>{"active"===r.getSnapshot().status&&(p.delete(r),n._relay(r,r,{type:l,data:t}))},t=>{"active"===r.getSnapshot().status&&(p.delete(r),n._relay(r,r,{type:f,data:t}))})},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t}}let d=(r=void 0,{config:e=t=>void 0,transition:(t,r,n)=>({...t,context:e(t.context,r,n)}),getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,context:"function"==typeof r?r({input:e}):r}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t});function y(){return(0,s.c)(d)}function v(t,e,r,n,{assignment:i}){if(!e.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let o={},a={context:e.context,event:r.event,spawn:function(t,{machine:e,context:r},n,i){return(o,a)=>{let u=((o,a)=>{if("string"!=typeof o)return(0,s.c)(o,{id:a?.id,parent:t.self,syncSnapshot:a?.syncSnapshot,input:a?.input,src:o,systemId:a?.systemId});{let u=(0,s.V)(e,o);if(!u)throw Error(`Actor logic '${o}' not implemented in machine '${e.id}'`);let c=(0,s.c)(u,{id:a?.id,parent:t.self,syncSnapshot:a?.syncSnapshot,input:"function"==typeof a?.input?a.input({context:r,event:n,self:t.self}):a?.input,src:o,systemId:a?.systemId});return i[c.id]=c,c}})(o,a);return i[u.id]=u,t.defer(()=>{u._processingStatus!==s.Z.Stopped&&u.start()}),u}}(t,e,r.event,o),self:t.self,system:t.system},u={};if("function"==typeof i)u=i(a,n);else for(let t of Object.keys(i)){let e=i[t];u[t]="function"==typeof e?e(a,n):e}let c=Object.assign({},e.context,u);return[(0,s._)(e,{context:c,children:Object.keys(o).length?{...e.children,...o}:e.children}),void 0,void 0]}function g(t){function e(t,e){}return e.type="xstate.assign",e.assignment=t,e.resolve=v,e}t.s(["createEmptyActor",()=>y,"fromCallback",()=>o,"fromEventObservable",()=>c,"fromPromise",()=>h],840603),t.s(["a",()=>g],369084);let m=new WeakMap;function b(t,e,r){let n=m.get(t);return n?e in n||(n[e]=r()):(n={[e]:r()},m.set(t,n)),n[e]}let _={},S=t=>"string"==typeof t?{type:t}:"function"==typeof t?"resolve"in t?{type:t.type}:{type:t.name}:t;class x{constructor(t,e){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=e._parent,this.key=e._key,this.machine=e._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(s.S),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?(0,s.v)(this.config.states,(t,e)=>new x(t,{_parent:this,_key:e,_machine:this.machine})):_,"compound"===this.type&&!this.config.initial)throw Error(`No initial state specified for c
2ompound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=!0===this.config.history?"shallow":this.config.history||!1,this.entry=(0,s.t)(this.config.entry).slice(),this.exit=(0,s.t)(this.config.exit).slice(),this.meta=this.config.meta,this.output="final"!==this.type&&this.parent?void 0:this.config.output,this.tags=(0,s.t)(t.tags).slice()}_initialize(){this.transitions=(0,s.w)(this),this.config.always&&(this.always=(0,s.x)(this.config.always).map(t=>(0,s.y)(this,s.N,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(S),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(S),eventType:null})}:void 0,history:this.history,states:(0,s.v)(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(S)})),entry:this.entry.map(S),exit:this.exit.map(S),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return b(this,"invoke",()=>(0,s.t)(this.config.invoke).map((t,e)=>{let{src:r,systemId:n}=t,i=t.id??(0,s.B)(this.id,e),o="string"==typeof r?r:`xstate.invoke.${(0,s.B)(this.id,e)}`;return{...t,src:o,id:i,systemId:n,toJSON(){let{onDone:e,onError:r,...n}=t;return{...n,type:"xstate.invoke",src:o,id:i}}}}))}get on(){return b(this,"on",()=>[...this.transitions].flatMap(([t,e])=>e.map(e=>[t,e])).reduce((t,[e,r])=>(t[e]=t[e]||[],t[e].push(r),t),{}))}get after(){return b(this,"delayedTransitions",()=>(0,s.C)(this))}get initial(){return b(this,"initial",()=>(0,s.D)(this,this.config.initial))}next(t,e){let r,n=e.type,i=[];for(let o of b(this,`candidates-${n}`,()=>(0,s.E)(this,n))){let{guard:a}=o,u=t.context,c=!1;try{c=!a||(0,s.z)(a,u,e,t)}catch(e){let t="string"==typeof a?a:"object"==typeof a?a.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:""}in transition for event '${n}' in state node '${this.id}': 3${e.message}`)}if(c){i.push(...o.actions),r=o;break}}return r?[r]:void 0}get events(){return b(this,"events",()=>{let{states:t}=this,e=new Set(this.ownEvents);if(t)for(let r of Object.keys(t)){let n=t[r];if(n.states)for(let t of n.events)e.add(`${t}`)}return Array.from(e)})}get ownEvents(){return Array.from(new Set(Object.keys(Object.fromEntries(this.transitions)).filter(t=>this.transitions.get(t).some(t=>!(!t.target&&!t.actions.length&&!t.reenter)))))}}class w{constructor(t,e){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:e?.actors??{},actions:e?.actions??{},delays:e?.delays??{},guards:e?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new x(t,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:e,guards:r,actors:n,delays:s}=this.implementations;return new w(this.config,{actions:{...e,...t.actions},guards:{...r,...t.guards},actors:{...n,...t.actors},delays:{...s,...t.delays}})}resolveState(t){let e=(0,s.F)(this.root,t.value),r=(0,s.G)((0,s.j)(this.root,e));return(0,s.H)({_nodes:[...r],context:t.context||{},children:{},status:(0,s.I)(r,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,r){return(0,s.J)(t,e,r,[]).snapshot}microstep(t,e,r){return(0,s.J)(t,e,r,[]).microstates}getTransitionData(t,e){return(0,s.K)(this.root,t.value,t,e)||[]}
3getPreInitialState(t,e,r){let{context:n}=this.config,i=(0,s.H)({context:"function"!=typeof n&&n?n:{},_nodes:[this.root],children:{},status:"active"},this);return"function"==typeof n?(0,s.L)(i,e,t,[g(({spawn:t,event:e,self:r})=>n({spawn:t,input:e.input,self:r}))],r,void 0):i}getInitialSnapshot(t,e){let r=(0,s.M)(e),n=[],i=this.getPreInitialState(t,r,n),o=(0,s.O)([{target:[...(0,s.P)(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],i,t,r,!0,n),{snapshot:a}=(0,s.J)(o,r,t,n);return a}start(t){Object.values(t.children).forEach(t=>{"active"===t.getSnapshot().status&&t.start()})}getStateNodeById(t){let e=(0,s.Q)(t),r=e.slice(1),n=(0,s.R)(e[0])?e[0].slice(1):e[0],i=this.idMap.get(n);if(!i)throw Error(`Child state node '#${n}' does not exist on machine '${this.id}'`);return(0,s.T)(i,r)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,e){return(0,s.U)(t,e)}restoreSnapshot(t,e){let r={},n=t.children;Object.keys(n).forEach(t=>{let i=n[t],o=i.snapshot,a=i.src,u="string"==typeof a?(0,s.V)(this,a):a;if(!u)return;let c=(0,s.c)(u,{id:t,parent:e.self,syncSnapshot:i.syncSnapshot,snapshot:o,src:a,systemId:i.systemId});r[t]=c});let i=function(t,e){if(!e||"object"!=typeof e)return{};let r={};for(let n in e)for(let s of e[n]){let e=function(t,e){if(e instanceof x)return e;try{return t.machine.getStateNodeById(e.id)}catch{}}(t,s);e&&(r[n]??=[],r[n].push(e))}return r}(this.root,t.historyValue),o=(0,s.H)({...t,children:r,_nodes:Array.from((0,s.G)((0,s.j)(this.root,t.value))),historyValue:i},this),a=new Set;return!function t(e,r){if(!a.has(e))for(let n in a.add(e),e){let i=e[n];if(i&&"object"==typeof i){if("xstate$$type"in i&&i.xstate$$type===s.$){e[n]=r[i.id];continue}t(i,r)}}}(o.context,r),o}}function k(t,e,r,n,{event:s}){return[e,{event:"function"==typeof s?s(r,n):s},void 0]}function E(t,{event:e}){t.defer(()=>t.emit(e))}function I(t){function e(t,e){}return e.type="xstate.emit",e.event=t,e.resolve=k,e.execute=E,e}let T=((n={}).Parent="#_parent",n.Internal="#_internal",n);function A(t,e,r,n,{to:s,event:i,id:o,delay:a},u){let c,l,f=e.machine.implementations.delays;if("string"==typeof i)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);let p="function"==typeof i?i(r,n):i;if("string"==typeof a){let t=f&&f[a];c="function"==typeof t?t(r,n):t}else c="function"==typeof a?a(r,n):a;let h="function"==typeof s?s(r,n):s;if("string"==typeof h){if(!(l=h===T.Parent?t.self._parent:h===T.Internal?t.self:h.startsWith("#_")?e.children[h.slice(2)]:u.deferredActorIds?.includes(h)?h:e.children[h]))throw Error(`Unable to send event to actor '${h}' from machine '${e.machine.id}'.`)}else l=h||t.self;return[e,{to:l,targetId:"string"==typeof h?h:void 0,event:p,id:o,delay:c},void 0]}function O(t,e,r){"string"==typeof r.to&&(r.to=e.children[r.to])}function $(t,e){t.defer(()=>{let{to:r,event:n,delay:i,id:o}=e;"number"==typeof i?t.system.scheduler.schedule(t.self,r,n,i,o):t.system._relay(t.self,r,n.type===s.W?(0,s.Y)(t.self.id,n.data):n)})}function R(t,e,r){function n(t,e){}return n.type="xstate.sendTo",n.to=t,n.event=e,n.id=r?.id,n.delay=r?.delay,n.resolve=A,n.retryResolve=O,n.execute=$,n}function q(t,e){return R(T.Parent,t,e)}function M(t,e,r,n,{collect:i}){let o=[],a=function(t){o.push(t)};return a.assign=(...t)=>{o.push(g(...t))},a.cancel=(...t)=>{o.push((0,s.a)(...t))},a.raise=(...t)=>{o.push((0,s.r)(...t))},a.sendTo=(...t)=>{o.push(R(...t))},a.sendParent=(...t)=>{o.push(q(...t))},a.spawnChild=(...t)=>{o.push((0,s.b)(...t))},a.stopChild=(...t)=>{o.push((0,s.s)(...t))},a.emit=(...t)=>{o.push(I(...t))},i({context:r.context,event:r.event,enqueue:a,check:t=>(0,s.z)(t,e.context,r.event,e),self:t.self,system:t.system},n),[e,void 0,o]}function j(t){function e(t,e){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=M,e}function P(t,e,r,n,{value:s,label:i}){return[e,{value:"function"==typeof s?s(r,n):s,label:i},void 0]}function N({logger:t},{value:e,label:r}){r?t(r,e):t(e)}function C(t=({context:t,event:e})=>({context:t,event:e}),e){function r(t,e){}return r.type="xstate.log",r.value=t,r.label=e,r.resolve=P,r.execute=N,r}function L(t,e){let r=(0,s.t)(e);if(!r.some(e=>(0,s.m)(t.type,e))){let e=1===r.length?`type matching "${r[0]}
3"`:`one of types matching "${r.join('", "')}"`;throw Error(`Expected event ${JSON.stringify(t)} to have ${e}`)}}t.s(["a",()=>I,"b",()=>q,"e",()=>j,"l",()=>C,"s",()=>R],915520),t.s(["assertEvent",()=>L,"setup",()=>function t({schemas:e,actors:r,actions:n,guards:i,delays:o}){return{assign:g,sendTo:R,raise:s.r,log:C,cancel:s.a,stopChild:s.s,enqueueActions:j,emit:I,spawnChild:s.b,createStateConfig:t=>t,createAction:t=>t,createMachine:t=>new w({...t,schemas:e},{actors:r,actions:n,guards:i,delays:o}),extend:s=>t({schemas:e,actors:r,actions:{...n,...s.actions},guards:{...i,...s.guards},delays:{...o,...s.delays}})}}],747675)},507295,t=>{"use strict";var e=t.i(915520);t.s(["sendTo",()=>e.s])},408110,t=>{"use strict";var e=t.i(369084);t.s(["assign",()=>e.a])},984750,t=>{"use strict";var e=t.i(574640);t.s(["createActor",()=>e.c])},912721,t=>{"use strict";var e=t.i(915520);t.s(["enqueueActions",()=>e.e])},308441,t=>{"use strict";var e=t.i(574640);t.s(["raise",()=>e.r])},428971,t=>{"use strict";var e=t.i(915520);t.s(["emit",()=>e.a])},961108,t=>{"use strict";var e=t.i(574640);t.s(["stopChild",()=>e.s])},516165,827540,949918,907844,337902,450363,558869,521879,448971,913072,602435,902190,411844,939584,841471,43533,990156,12436,633482,t=>{"use strict";var e=t.i(824627);function r(t){return"function"==typeof t}function n(t){var e=t(function(t){Error.call(t),t.stack=Error().stack});return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}t.s(["isFunction",()=>r],827540),t.s(["createErrorClass",()=>n],949918);var s=n(function(t){return function(e){t(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}});function i(t,e){if(t){var r=t.indexOf(e);0<=r&&t.splice(r,1)}}t.s(["arrRemove",()=>i],907844);var o=function(){var t;function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t,n,i,o,a,u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var l=(0,e.__values)(u),f=l.next();!f.done;f=l.next())f.value.remove(this)}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}else u.remove(this);var p=this.initialTeardown;if(r(p))try{p()}catch(t){a=t instanceof s?t.errors:[t]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var d=(0,e.__values)(h),y=d.next();!y.done;y=d.next()){var v=y.value;try{c(v)}catch(t){a=null!=a?a:[],t instanceof s?a=(0,e.__spreadArray)((0,e.__spreadArray)([],(0,e.__read)(a)),(0,e.__read)(t.errors)):a.push(t)}}}catch(t){i={error:t}}finally{try{y&&!y.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}if(a)throw new s(a)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)c(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!=(e=this._finalizers)?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&i(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&i(e,t),t instanceof n&&t._removeParent(this)},(t=new n).closed=!0,n.EMPTY=t,n}(),a=o.EMPTY;function u(t){return t instanceof o||t&&"closed"in t&&r(t.remove)&&r(t.add)&&r(t.unsubscribe)}function c(t){r(t)?t():t.unsubscribe()}t.s(["EMPTY_SUBSCRIPTION",()=>a,"Subscription",()=>o,"isSubscription",()=>u],337902);var l=void 0,f={setTimeout:function(t,r){for(var n=[],s=2;s<arguments.length;s++)n[s-2]=arguments[s];var i=f.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,(0,e.__spreadArray)([t,r],(0,e.__read)(n))):setTimeout.apply(void 0,(0,e.__spreadArray)([t,r],(0,e.__read)(n)))},clearTimeout:function(t){var e=f.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function p(t){f.setTimeout(function(){!1;throw t})}function h(){}t.s(["noop",()=>h],450363);var d=y("C",void 0,void 0);function y(t,e,r){return{kind:t,value:e,error:r}}var v=null;function g(t){var e,r,n,s;1;t()}function m(t){}t.s(["captureError",()=>m,"errorContext",()=>g],558869);var b=function(t){function r(e){var r=t.call(this)||this;return r.isStopped=!1,e?(r.destination=e,u(e)&&e.add(r)):r.destination=I,r}return(0,e.__extends)(r,t),r.create=function(t,e,r){return new w(t,e,r)},r.prototype.next=function(t){this.isStopped?E(y("N",t,void 0),this):this._next(t)},r.prototype.error=function(t){this.isStopped?E(y("E",void 0,t),this):(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped?E(d,this):(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(o),_=Function.prototype.bind;function S(t,e){return _.call(t,e)}var x=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(t){k(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){k(t)}else k(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){k(t)}},t}(),w=function(t){function n(e,n,s){var i,o,a=t.call(this)||this;return r(e)||!e?i={next:null!=e?e:void 0,error:null!=n?n:void 0,complete:null!=s?s:void 0}:i=e,a.destination=new x(i),a}return(0,e.__extends)(n,t),n}(b);function k(t){p(t)}function E(t,e){}var I={closed:!0,next:h,error:function(t){throw t},complete:h};t.s(["SafeSubscriber",()=>w,"Subscriber",()=>b],521879);var T="function"==typeof Symbol&&Symbol.observable||"@@observable";function A(t){return t}function O(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return $(t)}function $(t){return 0===t.length?A:1===t.length?t[0]:function(e){return t.reduce(function(t,e){return e(t)},e)}}t.s(["identity",()=>A],448971),t.s(["pipe",()=>O,"pipeFromArray",()=>$],913072);var R=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,n){var s=this,i=!function(t){return t&&t instanceof b||t&&r(t.next)&&r(t.error)&&r(t.complete)&&u(t)}(t)?new w(t,e,n):t;return g(function(){var t=s.operator,e=s.source;i.add(t?t.call(i,e):e?s._subscribe(i):s._trySubscribe(i))}),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=q(e))(function(e,n){var s=new w({next:function(e){try{t(e)}catch(t){n(t),s.unsubscribe()}},error:n,complete:e});r.subscribe(s)})},t.prototype._subscribe=function(t){var e;return null==(e=this.source)?void 0:e.subscribe(t)},t.prototype[T]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return $(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=q(t))(function(t,r){var n;e.subscribe(function(t){return n=t},function(t){return r(t)},function(){return t(n)})})},t.create=function(e){return new t(e)},t}();function q(t){var e;return null!=(e=null!=t?t:l)?e:Promise}t.s(["Observable",()=>R],516165);var M=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function j(t){return r(null==t?void 0:t.then)}function P(t){return r(t[T])}function N(t){return Symbol.asyncIterator&&r(null==t?void 0:t[Symbol.asyncIterator])}function C(t){return TypeError("You provided "+(null!==t&&"object"==typeof t?"an invali
3d object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}t.s(["isArrayLike",()=>M],602435),t.s(["isPromise",()=>j],902190),t.s(["isInteropObservable",()=>P],411844),t.s(["isAsyncIterable",()=>N],939584),t.s(["createInvalidObservableTypeError",()=>C],841471);var L="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function D(t){return r(null==t?void 0:t[L])}function F(t){return(0,e.__asyncGenerator)(this,arguments,function(){var r,n,s;return(0,e.__generator)(this,function(i){switch(i.label){case 0:r=t.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,(0,e.__await)(r.read())];case 3:if(s=(n=i.sent()).value,!n.done)return[3,5];return[4,(0,e.__await)(void 0)];case 4:return[2,i.sent()];case 5:return[4,(0,e.__await)(s)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function U(t){return r(null==t?void 0:t.getReader)}function B(t){if(t instanceof R)return t;if(null!=t){var n,s,i,o;if(P(t)){return n=t,new R(function(t){var e=n[T]();if(r(e.subscribe))return e.subscribe(t);throw TypeError("Provided object does not correctly implement Symbol.observable")})}if(M(t)){return s=t,new R(function(t){for(var e=0;e<s.length&&!t.closed;e++)t.next(s[e]);t.complete()})}if(j(t)){return i=t,new R(function(t){i.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,p)})}if(N(t))return z(t);if(D(t)){return o=t,new R(function(t){var r,n;try{for(var s=(0,e.__values)(o),i=s.next();!i.done;i=s.next()){var a=i.value;if(t.next(a),t.closed)return}}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}t.complete()})}if(U(t))return z(F(t))}throw C(t)}function z(t){return new R(function(r){(function(t,r){var n,s,i,o;return(0,e.__awaiter)(this,void 0,void 0,function(){var a;return(0,e.__generator)(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=(0,e.__asyncValues)(t),u.label=1;case 1:return[4,n.next()];case 2:if((s=u.sent()).done)return[3,4];if(a=s.value,r.next(a),r.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return i={error:u.sent()},[3,11];case 6:if(u.trys.push([6,,9,10]),!(s&&!s.done&&(o=n.return)))return[3,8];return[4,o.call(n)];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})})(t,r).catch(function(t){return r.error(t)})})}t.s(["iterator",()=>L],43533),t.s(["isIterable",()=>D],990156),t.s(["isReadableStreamLike",()=>U,"readableStreamLikeToAsyncGenerator",()=>F],12436),t.s(["innerFrom",()=>B],633482)},159862,t=>{"use strict";var e=t.i(516165),r=t.i(633482);function n(t){return new e.Observable(function(e){(0,r.innerFrom)(t()).subscribe(e)})}t.s(["defer",()=>n])},913186,866312,7560,t=>{"use strict";var e=t.i(827540);function r(t){return(0,e.isFunction)(null==t?void 0:t.lift)}function n(t){return function(e){if(r(e))return e.lift(function(e){try{return t(e,this)}catch(t){this.error(t)}});throw TypeError("Unable to lift unknown Observable type")}}t.s(["hasLift",()=>r,"operate",()=>n],866312);var s=t.i(824627);function i(t,e,r,n,s){return new o(t,e,r,n,s)}var o=function(t){function e(e,r,n,s,i,o){var a=t.call(this,e)||this;return a.onFinalize=i,a.shouldUnsubscribe=o,a._next=r?function(t){try{r(t)}catch(t){e.error(t)}}:t.prototype._next,a._error=s?function(t){try{s(t)}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._error,a._complete=n?function(){try{n()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return(0,s.__extends)(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),r||null==(e=this.onFinalize)||e.call(this)}},e}(t.i(521879).Subscriber);function a(t,e){return n(function(r,n){var s=0;r.subscribe(i(n,function(r){n.next(t.call(e,r,s++))}))})}t.s(["OperatorSubscriber",()=>o,"createOperatorSubscriber",()=>i],7560),t.s(["map",()=>a],913186)},168,t=>{"use strict";function e(t,e,r,n,s){void 0===n&&(n=0),void 0===s&&(s=!1);var i=e.schedule(function(){r(),s?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(i),!s)return i}t.s(["executeSchedule",()=>e])},806298,484430,t=>{"use strict";var e=t.i(913186),r=t.i(633482),n=t.i(866312),s=t.i(168),i=t.i(7560);function o(t,e,n,o,a,u,c,l){var f=[],p=0,h=0,d=!1,y=function(){!d||f.length||p||e.complete()},v=function(t){return p<o?g(t):f.push(t)},g=function(t){u&&e.next(t),p++;var l=!1;(0,r.innerFrom)(n(t,h++)).subscribe((0,i.createOperatorSubscriber)(e,function(t){null==a||a(t),u?v(t):e.next(t)},function(){l=!0},void 0,function(){if(l)try{for(p--;f.length&&p<o;
3)!function(){var t=f.shift();c?(0,s.executeSchedule)(e,c,function(){return g(t)}):g(t)}();y()}catch(t){e.error(t)}}))};return t.subscribe((0,i.createOperatorSubscriber)(e,v,function(){d=!0,y()})),function(){null==l||l()}}t.s(["mergeInternals",()=>o],484430);var a=t.i(827540);t.s(["mergeMap",()=>function t(s,i,u){return(void 0===u&&(u=1/0),(0,a.isFunction)(i))?t(function(t,n){return(0,e.map)(function(e,r){return i(t,e,n,r)})((0,r.innerFrom)(s(t,n)))},u):("number"==typeof i&&(u=i),(0,n.operate)(function(t,e){return o(t,e,s,u)}))}],806298)},828640,591607,80205,t=>{"use strict";var e=t.i(824627),r=t.i(633482),n=t.i(516165),s=t.i(806298),i=t.i(602435),o=t.i(827540),a=t.i(913186),u=Array.isArray;function c(t){return(0,a.map)(function(r){return u(r)?t.apply(void 0,(0,e.__spreadArray)([],(0,e.__read)(r))):t(r)})}t.s(["mapOneOrManyArgs",()=>c],591607);var l=["addListener","removeListener"],f=["addEventListener","removeEventListener"],p=["on","off"];function h(t,e){return function(r){return function(n){return t[r](e,n)}}}t.s(["fromEvent",()=>function t(a,u,d,y){if((0,o.isFunction)(d)&&(y=d,d=void 0),y)return t(a,u,d).pipe(c(y));var v,g,m,b=(0,e.__read)((v=a,(0,o.isFunction)(v.addEventListener)&&(0,o.isFunction)(v.removeEventListener))?f.map(function(t){return function(e){return a[t](u,e,d)}}):(g=a,(0,o.isFunction)(g.addListener)&&(0,o.isFunction)(g.removeListener))?l.map(h(a,u)):(m=a,(0,o.isFunction)(m.on)&&(0,o.isFunction)(m.off))?p.map(h(a,u)):[],2),_=b[0],S=b[1];if(!_&&(0,i.isArrayLike)(a))return(0,s.mergeMap)(function(e){return t(e,u,d)})((0,r.innerFrom)(a));if(!_)throw TypeError("Invalid event target");return new n.Observable(function(t){var e=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.next(1<e.length?e:e[0])};return _(e),function(){return S(e)}})}],828640);var d=t.i(866312),y=t.i(7560);function v(t,e){return(0,d.operate)(function(r,n){var s=0;r.subscribe((0,y.createOperatorSubscriber)(n,function(r){return t.call(e,r,s++)&&n.next(r)}))})}t.s(["filter",()=>v],80205)},473948,t=>{"use strict";var e=t.i(824627),r=t.i(866312),n=t.i(7560),s=t.i(907844);function i(t,i){return void 0===i&&(i=null),i=null!=i?i:t,(0,r.operate)(function(r,o){var a=[],u=0;r.subscribe((0,n.createOperatorSubscriber)(o,function(r){var n,c,l,f,p=null;u++%i==0&&a.push([]);try{for(var h=(0,e.__values)(a),d=h.next();!d.done;d=h.next()){var y=d.value;y.push(r),t<=y.length&&(p=null!=p?p:[]).push(y)}}catch(t){n={error:t}}finally{try{d&&!d.done&&(c=h.return)&&c.call(h)}finally{if(n)throw n.error}}if(p)try{for(var v=(0,e.__values)(p),g=v.next();!g.done;g=v.next()){var y=g.value;(0,s.arrRemove)(a,y),o.next(y)}}catch(t){l={error:t}}finally{try{g&&!g.done&&(f=v.return)&&f.call(v)}finally{if(l)throw l.error}}},function(){var t,r;try{for(var n=(0,e.__values)(a),s=n.next();!s.done;s=n.next()){var i=s.value;o.next(i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}o.complete()},void 0,function(){a=null}))})}t.s(["bufferCount",()=>i])},262940,t=>{"use strict";var e=t.i(806298),r=t.i(827540);function n(t,n){return(0,r.isFunction)(n)?(0,e.mergeMap)(t,n,1):(0,e.mergeMap)(t,1)}t.s(["concatMap",()=>n])},83507,982100,t=>{"use strict";var e=new(t.i(516165)).Observable(function(t){return t.complete()});t.s(["EMPTY",()=>e],982100);var r=t.i(866312),n=t.i(7560);function s(t){return t<=0?function(){return e}:(0,r.operate)(function(e,r){var s=0;e.subscribe((0,n.createOperatorSubscriber)(r,function(e){++s<=t&&(r.next(e),t<=s&&r.complete())}))})}t.s(["take",()=>s],83507)},592110,t=>{"use strict";var e=t.i(866312),r=t.i(7560),n=t.i(633482),s=t.i(450363);function i(t){return(0,e.operate)(function(e,i){(0,n.innerFrom)(t).subscribe((0,r.createOperatorSubscriber)(i,function(){return i.complete()},s.noop)),i.closed||e.subscribe(i)})}t.s(["takeUntil",()=>i])},10412,t=>{"use strict";var e=t.i(627897),r=t.i(840603),n=t.i(747675),s=t.i(507295),i=t.i(408110),o=t.i(984750),a=t.i(912721),u=t.i(308441),c=t.i(428971),l=t.i(961108),f=t.i(159862),p=t.i(828640),h=t.i(913186),d=t.i(913072),y=t.i(80205),v=t.i(473948),g=t.i(262940),m=t.i(83507),b=t.i(982100),_=t.i(592110);let S=t=>({context:e})=>{let{count:r,include:n,exclude:s,responseType:i="message.received"}=t;return{count:r,domain:e.domain,from:e.connectTo,include:n?Array.isArray(n)?n:[n]:[],exclude:s?Array.isArray(s)?s:[s]:[],responseType:i,target:e.target,to:e.name}},x=(0,f.defer)(()=>(0,p.fromEvent)(window,"message")),w=t=>(0,r.fromEventObservable)(({input:e})=>{let r;return x.pipe(t?(0,h.map)(t):(0,d.pipe)(),(0,y.filter)(t=>{let{data:r}=t;return(!e.include.length||e.include.includes(r.type))&&(!e.exclude.length||!e.exclude.includes(r.type))&&r.domain===e.domain&&r.from===e.from&&r.to===e.to&&(!e.target||t.source===e.target)}),(0,h.map)((r=e.responseType,t=>({type:r,message:t}))),e.count?(0,d.pipe)((0,v.bufferCount)(e.count),(0,g.concatMap)(t=>t),(0,m.take)(e.count)):(0,d.pipe)())}),k="sanity/comlink",E="comlink/response",I="comlink/heartbeat",T="comlink/disconnect",A="comlink/handshake/syn",O="comlink/handshake/syn-ack",$="comlink/handshake/ack",R=()=>(0,n.setup)({types:{},actors:{listen:(0,r.fromEventObservable)(({input:t})=>{let e,r=t.signal?(0,p.fromEvent)(t.signal,"abort").pipe((e=`Request ${t.requestId} aborted`,t=>t.pipe((0,m.take)(1),(0,h.map)(()=>{throw Error(e)})))):b.EMPTY;return(0,p.fromEvent)(window,"message").pipe((0,y.filter)(e=>e.data?.type===E&&e.data?.responseTo===t.requestId&&!!e.source&&t.sources.has(e.source)),(0,m.take)(t.sources.size),(0,_.takeUntil)(r))})},actions:{"send message":({context:t},e)=>{let{sources:r,targetOrigin:n}=t,{message:s}=e;r.forEach(t=>{t.postMessage(s,{targetOrigin:n})})},"on success":(0,s.sendTo)(({context:t})=>t.parentRef,({context:t,self:e})=>(t.response&&t.resolvable?.resolve(t.response),{type:"request.success",requestId:e.id,response:t.response,responseTo:t.responseTo})),"on fail":(0,s.sendTo)(({context:t})=>t.parentRef,({context:t,self:e})=>(t.suppressWarnings||console.warn(`[@sanity/comlink] Received no response to message '${t.type}' on client '${t.from}' (ID: '${t.id}').`),t.resolvable?.reject(Error("No response received")),{type:"request.failed",requestId:e.id})),"on abort":(0,s.sendTo)(({context:t})=>t.parentRef,({context:t,self:e})=>(t.resolvable?.reject(Error("Request aborted")),{type:"request.aborted",requestId:e.id}))},guards:{expectsResponse:({context:t})=>t.expectResponse},delays:{initialTimeout:0,responseTimeout:({context:t})=>t.responseTimeout??3e3}}).createMachine({context:({input:t})=>({channelId:t.channelId,data:t.data,domain:t.domain,expectResponse:t.expectResponse??!1,from:t.from,id:`msg-${(0,e.v4)()}`,parentRef:t.parentRef,resolvable:t.resolvable,response:null,responseTimeout:t.responseTimeout,responseTo:t.responseTo,signal:t.signal,sources:t.sources instanceof Set?t.sources:new Set([t.sources]),suppressWarnings:t.suppressWarnings,targetOrigin:t.targetOrigin,to:t.to,type:t.type}),initial:"idle",on:{abort:".aborted"},states:{idle:{after:{initialTimeout:[{target:"sending"}]}},sending:{entry:{type:"send message",params:({context:t})=>{let{channelId:e,data:r,domain:n,from:s,id:i,responseTo:o,to:a,type:u}=t;return{message:{channelId:e,data:r,domain:n,from:s,id:i,to:a,type:u,responseTo:o}}}},always:[{guard:"expectsResponse",target:"awaiting"},"success"]},awaiting:{invoke:{id:"listen for response",src:"listen",input:({context:t})=>({requestId:t.id,sources:t.sources,signal:t.signal}),onError:"aborted"},after:{responseTimeout:"failed"},on:{message:{actions:(0,i.assign)({response:({event:t})=>t.data.data,responseTo:({event:t})=>t.data.responseTo}),target:"success"}}},failed:{type:"final",entry:"on fail"},success:{type:"final",entry:"on success"},aborted:{type:"final",entry:"on abort"}},output:({context:t,self:e})=>({requestId:e.id,response:t.response,responseTo:t.responseTo})});(0,r.fromCallback)(({sendBack:t,input:e})=>{let r=()=>{t(e.event)};e.immediate&&r();let n=setInterval(r,e.interval);return()=>{clearInterval(n)}});let q=()=>(0,n.setup)({types:{},actors:{requestMachine:R(),listen:w()},actions:{"buffer handshake":(0,i.assign)({handshakeBuffer:({event:t,context:e})=>((0,n.assertEvent)(t,"message.received"),[...e.handshakeBuffer,t])}),"buffer message":(0,a.enqueueActions)(({enqueue:t})=>{t.assign({buffer:({event:t,context:e})=>((0,n.assertEvent)(t,"post"),[...e.buffer,{data:t.data,resolvable:t.resolvable,options:t.options}])}),t.emit(({event:t})=>((0,n.assertEvent)(t,"post"),{type:"buffer.added",message:t.data}))}),"create request":(0,i.assign)({requests:({context:t,event:r,self:s,spawn:i})=>{(0,n.assertEvent)(r,"request");let o=(Array.isArray(r.data)?r.data:[r.data]).map(r=>i("requestMachine",{id:`req-${(0,e.v4)()}`,input:{channelId:t.channelId,data:r.data,domain:t.domain,expectResponse:r.expectResponse,from:t.name,parentRef:s,resolvable:r.resolvable,responseTimeout:r.options?.responseTimeout,responseTo:r.responseTo,signal:r.options?.signal,sources:t.target,suppressWarnings:r.options?.suppressWarnings,targetOrigin:t.targetOrigin,to:t.connectTo,type:r.type}}));return[...t.requests,...o]}}),"emit heartbeat":(0,c.emit)(()=>({type:"heartbeat"})),"emit received message":(0,a.enqueueActions)(({enqueue:t})=>{t.emit(({event:t})=>((0,n.assertEvent)(t,"message.received"),{type:"message",message:t.message.data}))}),"emit status":(0,c.emit)((t,e)=>({type:"status",status:e.status})),"post message":(0,u.raise)(({event:t})=>((0,n.assertEvent)(t,"post"),{type:"request",data:{data:t.data.data,expectResponse:!!t.resolvable,type:t.data.type,resolvable:t.resolvable,options:t.options}})),"process pending handshakes":(0,a.enqueueActions)(({context:t,enqueue:e})=>{t.handshakeBuffer.forEach(t=>e.raise(t)),e.assign({handshakeBuffer:[]})}),"remove request":(0,a.enqueueActions)(({context:t,enqueue:e,event:r})=>{(0,n.assertEvent)(r,["request.success","request.failed","request.aborted"]),(0,l.stopChild)(r.requestId),e.assign({requests:t.requests.filter(({id:t})=>t!==r.requestId)})}),"send response":(0,u.raise)(({event:t})=>((0,n.assertEvent)(t,["message.received","heartbeat.received"]),{type:"request",data:{type:E,responseTo:t.message.data.id,data:void 0}})),"send handshake syn ack":(0,u.raise)({type:"request",data:{type:O}}),"send pending messages":(0,a.enqueueActions)(({enqueue:t})=>{t.raise(({context:t})=>({type:"request",data:t.buffer.map(({data:t,resolvable:e,options:r})=>({data:t.data,type:t.type,expectResponse:!!e,resolvable:e,options:r}))})),t.emit(({context:t})=>({type:"buffer.flushed",messages:t.buffer.map(({data:t})=>t)})),t.assign({buffer:[]})}),"set connection config":(0,i.assign)({channelId:({event:t})=>((0,n.assertEvent)(t,"handshake.syn"),t.message.data.channelId),target:({event:t})=>((0,n.assertEvent)(t,"handshake.syn"),t.message.source||void 0),targetOrigin:({event:t})=>((0,n.assertEvent)(t,"handshake.syn"),t.message.origin)})},guards:{hasSource:({context:t})=>null!==t.target}}).createMachine({id:"node",context:({input:t})=>({buffer:[],channelId:null,connectTo:t.connectTo,domain:t.domain??k,handshakeBuffer:[],name:t.name,requests:[],target:void 0,targetOrigin:null}),invoke:{id:"listen for handshake syn",src:"listen",input:S({include:A,responseType:"handshake.syn"})},on:{"request.success":{actions:"remove request"},"request.failed":{actions:"remove request"},"request.aborted":{actions:"remove request"},"handshake.syn":{actions:"set connection config",target:".handshaking"}}
3,initial:"idle",states:{idle:{entry:[{type:"emit status",params:{status:"idle"}}],on:{post:{actions:"buffer message"}}},handshaking:{guard:"hasSource",entry:["send handshake syn ack",{type:"emit status",params:{status:"handshaking"}}],invoke:[{id:"listen for handshake ack",src:"listen",input:S({include:$,count:1,responseType:"handshake.complete"}),onDone:"connected"},{id:"listen for disconnect",src:"listen",input:S({include:T,count:1,responseType:"disconnect"})},{id:"listen for messages",src:"listen",input:S({exclude:[T,A,$,I,E]})}],on:{request:{actions:"create request"},post:{actions:"buffer message"},"message.received":{actions:"buffer handshake"},disconnect:{target:"idle"}}},connected:{entry:["process pending handshakes","send pending messages",{type:"emit status",params:{status:"connected"}}],invoke:[{id:"listen for messages",src:"listen",input:S({exclude:[T,A,$,I,E]})},{id:"listen for heartbeat",src:"listen",input:S({include:I,responseType:"heartbeat.received"})},{id:"listen for disconnect",src:"listen",input:S({include:T,count:1,responseType:"disconnect"})}],on:{request:{actions:"create request"},post:{actions:"post message"},disconnect:{target:"idle"},"message.received":{actions:["send response","emit received message"]},"heartbeat.received":{actions:["send response","emit heartbeat"]}}}}}),M=(t,e=q())=>{let r,n=(0,o.createActor)(e,{input:t}),s=new Map,i=new Map;n.on("message",({message:t})=>{let e=s.get(t.type);if(e)return void e.forEach(e=>e(t.data));let r=i.get(t.type);r?r.add(t):i.set(t.type,new Set([t]))});let a=()=>{n.stop()};return{actor:n,fetch:(t,e,r)=>{let s,i,{responseTimeout:o=1e4,signal:a,suppressWarnings:u}=r||{},c="function"==typeof Promise.withResolvers?Promise.withResolvers():{promise:new Promise((t,e)=>{s=t,i=e}),resolve:s,reject:i};return n.send({type:"post",data:{type:t,data:e},resolvable:c,options:{responseTimeout:o,signal:a,suppressWarnings:u}}),c.promise},machine:e,on:(t,e,r)=>{let n=s.get(t)||new Set;s.has(t)||s.set(t,n),n.add(e);let o=i.get(t);if(o){let n=r?.replay??1;Array.from(o).slice(-n).forEach(({data:t})=>e(t)),i.delete(t)}return()=>{n.delete(e)}},onStatus:(t,e)=>{let s=n.on("status",n=>{r=n.status,e&&n.status!==e||t(n.status)});return r&&t(r),()=>s.unsubscribe()},post:(t,e)=>{n.send({type:"post",data:{type:t,data:e}})},start:()=>(n.start(),a),stop:a}};t.s(["DOMAIN",()=>k,"MSG_DISCONNECT",()=>T,"MSG_HANDSHAKE_ACK",()=>$,"MSG_HANDSHAKE_SYN",()=>A,"MSG_HANDSHAKE_SYN_ACK",()=>O,"MSG_HEARTBEAT",()=>I,"MSG_RESPONSE",()=>E,"createListenLogic",()=>w,"createNode",()=>M,"createNodeMachine",()=>q,"createRequestMachine",()=>R])}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.