1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,807574,847616,397374,t=>{"use strict";var e,n,r;let s=e=>{if("undefined"==typeof window)return;let n=function(){let e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:t.g;if(e.__xstate__)return e.__xstate__}();n&&n.register(e)};t.s(["devToolsAdapter",()=>s],847616);class i{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 o="xstate.init",a="xstate.stop";function c(t,e){return{type:`xstate.done.state.${t}`,output:e}}function u(t,e){return{type:`xstate.error.actor.${t}`,error:e,actorId:t}}function l(t){return{type:o,input:t}}function f(t){setTimeout(()=>{throw t})}let h="function"==typeof Symbol&&Symbol.observable||"@@observable";function p(t){if(m(t))return t;let e=[],n="";for(let r=0;r<t.length;r++){switch(t.charCodeAt(r)){case 92:n+=t[r+1],r++;continue;case 46:e.push(n),n="";continue}n+=t[r]}return e.push(n),e}function d(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={},n=e;for(let e=0;e<t.length-1;e++)if(e===t.length-2)n[t[e]]=t[e+1];else{let r=n;n={},r[t[e]]=n}return e}(p(t))}function y(t,e){let n={},r=Object.keys(t);for(let s=0;s<r.length;s++){let i=r[s];n[i]=e(t[i],i,t,s)}return n}function v(t){var e;return void 0===t?[]:m(e=t)?e:[e]}function g(t,e,n,r){return"function"==typeof t?t({context:e,event:n,self:r}):t}function m(t){return Array.isArray(t)}function b(t){var e;return(m(e=t)?e:[e]).map(t=>void 0===t||"string"==typeof t?{target:t}:t)}function _(t){if(void 0!==t&&""!==t)return v(t)}function S(t,e,n){let r="object"==typeof t,s=r?t:void 0;return{next:(r?t.next:t)?.bind(s),error:(r?t.error:e)?.bind(s),complete:(r?t.complete:n)?.bind(s)}}function x(t,e){return`${e}.${t}`}function w(t,e){let n=e.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return t.implementations.actors[e];let[,r,s]=n,i=t.getStateNodeById(s).config.invoke;return(Array.isArray(i)?i[r]:i).src}function k(t,e){if(e===t||"*"===e)return!0;if(!e.endsWith(".*"))return!1;let n=e.split("."),r=t.split(".");for(let t=0;t<n.length;t++){let e=n[t],s=r[t];if("*"===e)return t===n.length-1;if(e!==s)return!1}return!0}function E(t,e){return`${t.sessionId}.${e}`}let I=0,T=!1,O=((e={})[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e),A={clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class ${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 i(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=O.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 n={...A,...e},{clock:r,logger:s,parent:o,syncSnapshot:a,id:c,systemId:u,inspect:l}=n;this.system=o?o.system:function(t,e){let n=new Map,r=new Map,s=new WeakMap,i=new Set,o={},{clock:a,logger:c}=e,u={schedule:(t,e,n,r,s=Math.random().toString(36).slice(2))=>{let i={source:t,target:e,event:n,delay:r,id:s,startedAt:Date.now()},c=E(t,s);l._snapshot._scheduledEvents[c]=i;let u=a.setTimeout(()=>{delete o[c],delete l._snapshot._scheduledEvents[c],l._relay(t,e,n)},r);o[c]=u},cancel:(t,e)=>{let n=E(t,e),r=o[n];delete o[n],delete l._snapshot._scheduledEvents[n],void 0!==r&&a.clearTimeout(r)},cancelAll:t=>{for(let e in l._snapshot._scheduledEvents){let n=l._snapshot._scheduledEvents[e];n.source===t&&u.cancel(t,n.id)}}},l={_snapshot:{_scheduledEvents:(e?.snapshot&&e.snapshot.scheduler)??{}},_bookId:()=>`x:${I++}`,_register:(t,e)=>(n.set(t,e),t),_unregister:t=>{n.delete(t.sessionId);let e=s.get(t);void 0!==e&&(r.delete(e),s.delete(t))},get:t=>r.get(t),getAll:()=>Object.fromEntries(r.entries()),_set:(t,e)=>{let n=r.get(t);if(n&&n!==e)throw Error(`Actor with system ID '${t}' already exists.`);r.set(t,e),s.set(e,t)},inspect:t=>{let e=S(t);return i.add(e),{unsubscribe(){i.delete(e)}}},_sendInspectionEvent:e=>{if(!i.size)return;let n={...e,rootId:t.sessionId};
1i.forEach(t=>t.next?.(n))},_relay:(t,e,n)=>{l._sendInspectionEvent({type:"@xstate.event",sourceRef:t,actorRef:e,event:n}),e._send(n)},scheduler:u,getSnapshot:()=>({_scheduledEvents:{...l._snapshot._scheduledEvents}}),start:()=>{let t=l._snapshot._scheduledEvents;for(let e in l._snapshot._scheduledEvents={},t){let{source:n,target:r,event:s,delay:i,id:o}=t[e];u.schedule(n,r,s,i,o)}},_clock:a,_logger:c};return l}(this,{clock:r,logger:s}),l&&!o&&this.system.inspect(S(l)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=e?.logger??this.system._logger,this.clock=e?.clock??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=n,this.src=n.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),n=this.eventListeners.get("*");if(e||n)for(let r of[...e?e.values():[],...n?n.values():[]])try{r(t)}catch(t){f(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=T;try{T=!0,t.exec(t.info,t.params)}finally{T=e}};this._processingStatus===O.Running?e():this._deferred.push(e)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),u&&(this.systemId=u,this.system._set(u,this)),this._initState(e?.snapshot??e?.state),u&&"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 n;for(this._snapshot=t;n=this._deferred.shift();)try{n()}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.next?.(t)}catch(t){f(t)}break;case"done":var r;for(let e of this.observers)try{e.next?.(t)}catch(t){f(t)}this._stopProcedure(),this._complete(),this._doneEvent=(r=this.id,{type:`xstate.done.actor.${r}`,output:this._snapshot.output,actorId:r}),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,n){let r=S(t,e,n);if(this._processingStatus!==O.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{r.complete?.()}catch(t){f(t)}break;case"error":{let t=this._snapshot.error;if(r.error)try{r.error(t)}catch(t){f(t)}else f(t)}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(t,e){let n=this.eventListeners.get(t);n||(n=new Set,this.eventListeners.set(t,n));let r=e.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}select(t,e=Object.is){return{subscribe:n=>{let r=S(n),s=t(this.getSnapshot());return this.subscribe(n=>{let i=t(n);e(s,i)||(s=i,r.next?.(i))})},get:()=>t(this.getSnapshot())}}start(){if(this._processingStatus===O.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=O.Running;let t=l(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,n;try{e=this.logic.transition(this._snapshot,t,this._actorScope)}catch(t){n={err:t}}if(n){let{err:t}=n;this._snapshot={...this._snapshot,status:"error",error:t},this._error(t);return}this.update(e,t),t.type===a&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===O.Stopped||((this.mailbox.clear(),this._processingStatus===O.NotStarted)?this._processingStatus=O.Stopped:this.mailbox.enqueue({type:a})),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){f(t)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||f(t),this.eventListeners.clear();return}let e=!1;for(let n of this.observers){let r=n.error;e||=!r;try{r?.(t)}catch(t){f(t)}}this.observers.clear(),this.eventListeners.clear(),e&&f(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,u(this.id,t))}_stopProcedure(){return this._processingStatus!==O.Running||(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new i(this._process.bind(this)),this._processingStatus=O.Stopped,this.system._unregister(this)),this}_send(t){this._processingStatus!==O.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:s)(this)}toJSON(){return{xstate$$type:1,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[h](){return this}getSnapshot(){return this._snapshot}}function j(t,...[e]){return new $(t,e)}function P(t,e,n,r,{sendId:s}){return[e,{sendId:"function"==typeof s?s(n,r):s},void 0]}function R(t,e){t.defer(()=>{t.system.scheduler.cancel(t.self,e.sendId)})}function M(t){function e(t,e){}return e.type="xstate.cancel",e.sendId=t,e.resolve=P,e.execute=R,e}function q(t,e,n,r,{id:s,systemId:i,src:o,input:a,syncSnapshot:c}){let u,l,f="string"==typeof o?w(e.machine,o):o,h="function"==typeof s?s(n):s;return f&&(l="function"==typeof a?a({context:e.context,event:n.event,self:t.self}):a,u=j(f,{id:h,src:o,parent:t.self,syncSnapshot:c,systemId:i,input:l})),[tA(e,{children:{...e.children,[h]:u}}),{id:s,systemId:i,actorRef:u,src:o,input:l},void 0]}function N(t,{actorRef:e}){e&&t.defer(()=>{e._processingStatus!==O.Stopped&&e.start()})}function C(...[t,{id:e,systemId:n,input:r,syncSnapshot:s=!1}={}]){function i(t,e){}return i.type="xstate.spawnChild",i.id=e,i.systemId=n,i.src=t,i.input=r,i.syncSnapshot=s,i.resolve=q,i.execute=N,i}function L(t,e,n,r,{actorRef:s}){let i="function"==typeof s?s(n,r):s,o="string"==typeof i?e.children[i]:i,a=e.children;return o&&(a={...a},delete a[o.id]),[tA(e,{children:a}),o,void 0]}function D(t,e){if(e){if(!function t(e,n){let r=n.getSnapshot();if(r&&"children"in r)for(let n of Object.values(r.children))t(e,n);e.system._unregister(n)}(t,e),e._processingStatus!==O.Running)return void t.stopChild(e);t.defer(()=>{t.stopChild(e)})}}function U(t){function e(t,e){}return e.type="xstate.stopChild",e.actorRef=t,e.resolve=L,e.execute=D,e}function B(t,e,n,r){let{machine:s}=r,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 B(o,e,n,r);let a={context:e,event:n},c=i||"string"==typeof t?void 0:"params"in t?"function"==typeof t.params?t.params({context:e,event:n}):t.params:void 0;return"check"in o?o.check(r,a,o):o(a,c)}function z(t){return"atomic"===t.type||"final"===t.type}function V(t){return Object.values(t.states).filter(t=>"history"!==t.type)}function W(t,e){let n=[];if(e===t)return n;let r=t.parent;for(;r&&r!==e;)n.push(r),r=r.parent;return n}function G(t){let e=new Set(t),n=J(e);for(let t of e)if("compound"!==t.type||n.get(t)&&n.get(t).length){if("parallel"===t.type){for(let n of V(t))if("history"!==n.type&&!e.has(n))for(let t of ts(n))e.add(t)}}else ts(t).forEach(t=>e.add(t));for(let t of e){let n=t.parent;for(;n;)e.add(n),n=n.parent}return e}function J(t){let e=new Map;for(let n of t)e.has(n)||e.set(n,[]),n.parent&&(e.has(n.parent)||e.set(n.parent,[]),e.get(n.parent).push(n));return e}function K(t,e){return function t(e,n){let r=n.get(e);if(!r)return{};if("compound"===e.type){let t=r[0];if(!t)return{};if(z(t))return t.key}let s={};for(let e of r)s[e.key]=t(e,n);return s}(t,J(G(e)))}function Y(t,e){return"compound"===e.type?V(e).some(e=>"final"===e.type&&t.has(e)):"parallel"===e.type?V(e).every(e=>Y(t,e)):"final"===e.type}let H=t=>"#"===t[0];function F(t,e){return t.transitions.get(e)||[...t.transitions.keys()].filter(t=>k(e,t)).sort((t,e)=>e.length-t.length).flatMap(e=>t.transitions.get(e))}function Q(t){let e=t.config.after;return e?Object.keys(e).flatMap(n=>{var r;let s,i,o=e[n],a=Number.isNaN(+n)?n:+n,c=(r=t.id,i=(s={type:`xstate.after.${a}.${r}`}).type,t.entry.push(tR(s,{id:i,delay:a})),t.exit.push(M(i)),i);return v("string"==typeof o?{target:o}:o).map(t=>({...t,event:c,delay:a}))}).map(e=>{let{delay:n}=e;return{...Z(t,e.event,e),delay:n}}):[]}function Z(t,e,n){let r=_(n.target),s=n.reenter??!1,i=function(t,e){if(void 0!==e)return e.map(e=>{if("string"!=typeof e)return e;if(H(e))return t.machine.getStateNodeById(e);let n="."===e[0];if(n&&!t.parent)return ta(t,e.slice(1));let r=n?t.key+e:e;if(t.parent)try{return ta(t.parent,r)}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,r),o={...n,actions:v(n.actions),guard:n.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 X(t){let e=new Map;if(t.config.on)for(let n of Object.keys(t.config.on)){if(""===n)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=t.config.on[n];e.set(n,b(r).map(e=>Z(t,n,e)))}if(t.config.onDone){let n=`xstate.done.state.${t.id}`;e.set(n,b(t.config.onDone).map(e=>Z(t,n,e)))}for(let n of t.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;e.set(r,b(n.onDone).map(e=>Z(t,r,e)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;e.set(r,b(n.onError).map(e=>Z(t,r,e)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;e.set(r,b(n.onSnapshot).map(e=>Z(t,r,e)))}}for(let n of t.after){let t=e.get(n.eventType);t||(t=[],e.set(n.eventType,t)),t.push(n)}return e}function tt(t){let e=[],n=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let n=r.config.id,s=r.config.route.guard,i={...r.config.route,guard:(t,e)=>t.event.to===`#${n}`&&(!s||"function"!=typeof s||s(t,e)),target:`#${n}`};e.push(Z(t,"xstate.route",i))}r.states&&n(r.states)})};n(t.states),e.length>0&&t.transitions.set("xstate.route",e)}function te(t,e){let n="string"==typeof e?t.states[e]:e?t.states[e.target]:void 0;if(!n&&e)throw Error(`Initial state node "${e}" not found on parent state node #${t.id}`);let r={source:t,actions:e&&"string"!=typeof e?v(e.actions):[],eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...r,source:`#${t.id}`,target:n?[`#${n.id}`]:[]})};return r}function tn(t){let e=_(t.config.target);return e?{target:e.map(e=>"string"==typeof e?ta(t.parent,e):e)}:t.parent.initial}function tr(t){return"history"===t.type}function ts(t){let e=ti(t);for(let n of e)for(let r of W(n,t))e.add(r);return e}function ti(t){let e=new Set;return!function t(n){if(!e.has(n)){if(e.add(n),"compound"===n.type)t(n.initial.target[0]);else if("parallel"===n.type)for(let e of V(n))t(e)}}(t),e}function to(t,e){if(H(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 n=t.states[e];if(!n)throw Error(`Child state '${e}' does not exist on '${t.id}'`);return n}function ta(t,e){if("string"==typeof e&&H(e))try{return t.machine.getStateNodeById(e)}catch{}let n=p(e).slice(),r=t;for(;n.length;){let t=n.shift();if(!t.length)break;r=to(r,t)}return r}function tc(t,e){if("string"==typeof e){let n=t.states[e];if(!n)throw Error(`State '${e}' does not exist on '${t.id}'`);return[t,n]}let n=Object.keys(e),r=n.map(e=>to(t,e)).filter(Boolean);return[t.machine.root,t].concat(r,n.reduce((n,r)=>{let s=to(t,r);if(!s)return n;let i=tc(s,e[r]);return n.concat(i)},[]))}function tu(t,e){let n=t;for(;n.parent&&n.parent!==e;)n=n.parent;return n.parent===e}function tl(t,e,n){let r=new Set;for(let s of t){let t=!1,i=new Set;for(let o of r)if(function(t,e){let n=new Set(t),r=new Set(e);for(let t of n)if(r.has(t))return!0;for(let t of r)if(n.has(t))return!0;return!1}(tp([s],e,n),tp([o],e,n)))if(tu(s.source,o.source))i.add(o);else{t=!0;break}if(!t){for(let t of i)r.delete(t);r.add(s)}}return Array.from(r)}function tf(t,e){if(!t.target)return[];let n=new Set;for(let r of t.target)if(tr(r))if(e[r.id])for(let t of e[r.id])n.add(t);else for(let t of tf(tn(r),e))n.add(t);else n.add(r);return[...n]}function th(t,e){let n=tf(t,e);if(!n)return;if(!t.reenter&&n.every(e=>e===t.source||tu(e,t.source)))return t.source;let r=function(t){let[e,...n]=t;for(let t of W(e,void 0))if(n.every(e=>tu(e,t)))return t}(n.concat(t.source));return r||(t.reenter?void 0:t.source.machine.root)}function tp(t,e,n){let r=new Set;for(let s of t)if(s.target?.length){let t=th(s,n);for(let n of(s.reenter&&s.source===t&&r.add(t),e))tu(n,t)&&r.add(n)}return[...r]}function td(t,e,n,r,s){return ty([{target:[...ti(t)],source:t,reenter:!0,actions:[],eventType:null,toJSON:null}],e,n,r,!0,s)}function ty(t,e,n,r,s,i){let o=[];if(!t.length)return[e,o];let a=n.actionExecutor;n.actionExecutor=t=>{o.push(t),a(t)};try{let a=new Set(e._nodes),u=e.historyValue,l=tl(t,a,u),f=e;s||([f,u]=function(t,e,n,r,s,i,o,a){let c,u=t,l=tp(r,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 n;n="deep"===e.history?e=>z(e)&&tu(e,t):e=>e.parent===t,(c??={...i})[e.id]=Array.from(s).filter(n)}for(let t of l)u=tm(u,e,n,[...t.exit,...t.invoke.map(t=>U(t.id))],o,void 0),s.delete(t);return[u,c||i]}(f,r,n,l,a,u,i,n.actionExecutor)),f=tm(f,r,n,l.flatMap(t=>t.actions),i,void 0),f=function(t,e,n,r,s,i,o,a){let u=t,l=new Set,f=new Set;(function(t,e,n,r){for(let s of t){let t=th(s,e);for(let i of s.target||[])!tr(i)&&(s.source!==i||s.source!==t||s.reenter)&&(r.add(i),n.add(i)),tv(i,e,
2n,r);for(let i of tf(s,e)){let o=W(i,t);t?.type==="parallel"&&o.push(t),tg(r,e,n,o,!s.source.parent&&s.reenter?void 0:t)}}})(r,o,f,l),a&&f.add(t.machine.root);let h=new Set;for(let t of[...l].sort((t,e)=>t.order-e.order)){s.add(t);let r=[];for(let e of(r.push(...t.entry),t.invoke))r.push(C(e.src,{...e,syncSnapshot:!!e.onSnapshot}));if(f.has(t)){let e=t.initial.actions;r.push(...e)}if(u=tm(u,e,n,r,i,t.invoke.map(t=>t.id)),"final"===t.type){let r=t.parent,o=r?.type==="parallel"?r:r?.parent,a=o||t;for(r?.type==="compound"&&i.push(c(r.id,void 0!==t.output?g(t.output,u.context,e,n.self):void 0));o?.type==="parallel"&&!h.has(o)&&Y(s,o);)h.add(o),i.push(c(o.id)),a=o,o=o.parent;if(o)continue;u=tA(u,{status:"done",output:function(t,e,n,r,s){if(void 0===r.output)return;let i=c(s.id,void 0!==s.output&&s.parent?g(s.output,t.context,e,n.self):void 0);return g(r.output,t.context,i,n.self)}(u,e,n,u.machine.root,a)})}}return u}(f,r,n,l,a,i,u,s);let h=[...a];"done"===f.status&&(f=tm(f,r,n,h.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 n of t)if(!e.has(n))return!1;return!0}(e._nodes,a))return[f,o];return[tA(f,{_nodes:h,historyValue:u}),o]}catch(t){throw t}}finally{n.actionExecutor=a}}function tv(t,e,n,r){var s,i,o,a;if(tr(t))if(e[t.id]){let o=e[t.id];for(let t of o)r.add(t),tv(t,e,n,r);for(let a of o){s=a,i=t.parent,tg(r,e,n,W(s,i))}}else{let s=tn(t);for(let i of s.target)r.add(i),s===t.parent?.initial&&n.add(t.parent),tv(i,e,n,r);for(let i of s.target){o=i,a=t.parent,tg(r,e,n,W(o,a))}}else if("compound"===t.type){let[s]=t.initial.target;tr(s)||(r.add(s),n.add(s)),tv(s,e,n,r),tg(r,e,n,W(s,t))}else if("parallel"===t.type)for(let s of V(t).filter(t=>!tr(t)))[...r].some(t=>tu(t,s))||(tr(s)||(r.add(s),n.add(s)),tv(s,e,n,r))}function tg(t,e,n,r,s){for(let i of r)if((!s||tu(i,s))&&t.add(i),"parallel"===i.type)for(let r of V(i).filter(t=>!tr(t)))[...t].some(t=>tu(t,r))||(t.add(r),tv(r,e,n,t))}function tm(t,e,n,r,s,i){let o=i?[]:void 0,a=function t(e,n,r,s,i,o){let{machine:a}=e,c=e;for(let e of s){var u;let s="function"==typeof e,l=s?e:(u="string"==typeof e?e:e.type,a.implementations.actions[u]),f={context:c.context,event:n,self:r.self,system:r.system},h=s||"string"==typeof e?void 0:"params"in e?"function"==typeof e.params?e.params({context:c.context,event:n}):e.params:void 0;if(!l||!("resolve"in l)){r.actionExecutor({type:"string"==typeof e?e:"object"==typeof e?e.type:e.name||"(anonymous)",info:f,params:h,exec:l});continue}let[p,d,y]=l.resolve(r,c,f,h,l,i);c=p,"retryResolve"in l&&o?.push([l,d]),"execute"in l&&r.actionExecutor({type:l.type,info:f,params:d,exec:l.execute.bind(null,r,d)}),y&&(c=t(c,n,r,y,i,o))}return c}(t,e,n,r,{internalQueue:s,deferredActorIds:i},o);return o?.forEach(([t,e])=>{t.retryResolve(n,a,e)}),a}function tb(t,e,n,r){let s=t,i=[];function c(t,e,r){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:e,snapshot:t[0],_transitions:r}),i.push(t)}if(e.type===a)return c([s=tA(t_(s,e,n),{status:"stopped"}),[]],e,[]),{snapshot:s,microsteps:i};let u=e;if(u.type!==o){let e=u,o=e.type.startsWith("xstate.error.actor"),a=tS(e,s);if(o&&!a.length)return c([s=tA(t,{status:"error",error:e.error}),[]],e,[]),{snapshot:s,microsteps:i};let l=ty(a,t,n,u,!1,r);s=l[0],c(l,e,a)}let l=!0;for(;"active"===s.status;){let t=l?function(t,e){let n=new Set;for(let r of t._nodes.filter(z))t:for(let s of[r].concat(W(r,void 0)))if(s.always){for(let r of s.always)if(void 0===r.guard||B(r.guard,t.context,e,t)){n.add(r);break t}}return tl(Array.from(n),new Set(t._nodes),t.historyValue)}(s,u):[],e=t.length?s:void 0;if(!t.length){if(!r.length)break;t=tS(u=r.shift(),s)}let i=ty(t,s,n,u,!1,r);l=(s=i[0])!==e,c(i,u,t)}return"active"!==s.status&&t_(s,u,n),{snapshot:s,microsteps:i}}function t_(t,e,n){return tm(t,e,n,Object.values(t.children).map(t=>U(t)),[],void 0)}function tS(t,e){return e.machine.getTransitionData(e,t)}function tx(t,e){let n=G(tc(t,e));return K(t,[...n])}let tw=function(t){return function t(e,n){let r=d(e),s=d(n);return"string"==typeof s?"string"==typeof r&&s===r:"string"==typeof r?r in s:Object.keys(r).every(e=>e in s&&t(r[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:n,getMeta:r,toJSON:s,can:i,hasTag:o,matches:a,...c}=this;return{...c,tags:Array.from(e)}},tT=function(){return this._nodes.reduce((t,e)=>(void 0!==e.meta&&(t[e.id]=e.meta),t),{})};function tO(t,e){return{status:t.status,output:t.output,error:t.error,machine:e,context:t.context,_nodes:t._nodes,value:K(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 tA(t,e={}){return tO({...t,...e},t.machine)}function t$(t,e){let{_nodes:n,tags:r,machine:s,children:i,context:o,can:a,hasTag:c,matches:u,getMeta:l,toJSON:f,...h}=t,p={};for(let t in i){let n=i[t];p[t]={snapshot:n.getPersistedSnapshot(e),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...h,context:function t(e){let n;for(let r in e){let s=e[r];if(s&&"object"==typeof s)if("sessionId"in s&&"send"in s&&"ref"in s)(n??=Array.isArray(e)?e.slice():{...e})[r]={xstate$$type:1,id:s.id};else{let i=t(s);i!==s&&((n??=Array.isArray(e)?e.slice():{...e})[r]=i)}}return n??e}(o),children:p,historyValue:function(t){if("object"!=typeof t||null===t)return{};let e={};for(let n in t){let r=t[n];Array.isArray(r)&&(e[n]=r.map(t=>({id:t.id})))}return e}(h.historyValue)}}function tj(t,e,n,r,{event:s,id:i,delay:o},{internalQueue:a}){let c,u=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(n,r):s;if("string"==typeof o){let t=u&&u[o];c="function"==typeof t?t(n,r):t}else c="function"==typeof o?o(n,r):o;return"number"!=typeof c&&a.push(l),[e,{event:l,id:i,delay:c},void 0]}function tP(t,e){let{event:n,delay:r,id:s}=e;if("number"==typeof r)return void t.defer(()=>{let e=t.self;t.system.scheduler.schedule(e,e,n,r,s)})}function tR(t,e){function n(t,e){}return n.type="xstate.raise",n.event=t,n.id=e?.id,n.delay=e?.delay,n.resolve=tj,n.execute=tP,n}t.s(["$",()=>1,"B",()=>b,"C",()=>Z,"D",()=>B,"E",()=>x,"F",()=>Q,"G",()=>te,"H",()=>F,"I",()=>tt,"J",()=>tx,"K",()=>G,"L",()=>tO,"M",()=>Y,"N",()=>"","O",()=>function t(e,n,r,s){if("string"==typeof n){let t;
2return(t=to(e,n).next(r,s))&&t.length?t:e.next(r,s)}if(1===Object.keys(n).length){let i,o;return(o=t(to(e,(i=Object.keys(n))[0]),n[i[0]],r,s))&&o.length?o:e.next(r,s)}let i=[];for(let o of Object.keys(n)){let a=n[o];if(!a)continue;let c=t(to(e,o),a,r,s);c&&i.push(...c)}return i.length?i:e.next(r,s)},"P",()=>tm,"Q",()=>p,"R",()=>H,"S",()=>".","T",()=>ta,"U",()=>t$,"V",()=>w,"W",()=>"xstate.error","X",()=>a,"Y",()=>u,"Z",()=>O,"_",()=>tA,"a",()=>M,"b",()=>C,"c",()=>j,"d",()=>tb,"e",()=>l,"f",()=>z,"g",()=>W,"i",()=>td,"m",()=>k,"p",()=>tc,"r",()=>tR,"s",()=>U,"t",()=>v,"y",()=>y,"z",()=>X],397374);let tM=new WeakMap;function tq(t){return{config:t,start:(e,n)=>{let{self:r,system:s,emit:i}=n,o={receivers:void 0,dispose:void 0};tM.set(r,o),o.dispose=t({input:e.input,system:s,self:r,sendBack:t=>{"stopped"!==r.getSnapshot().status&&r._parent&&s._relay(r,r._parent,t)},receive:t=>{o.receivers??=new Set,o.receivers.add(t)},emit:i})},transition:(t,e,n)=>{let r=tM.get(n.self);return e.type===a?(t={...t,status:"stopped",error:void 0},tM.delete(n.self),r.receivers?.clear(),r.dispose?.()):r.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 tN="xstate.observable.error",tC="xstate.observable.complete";function tL(t){return{config:t,transition:(t,e)=>{if("active"!==t.status)return t;switch(e.type){case tN:return{...t,status:"error",error:e.data,input:void 0,_subscription:void 0};case tC:return{...t,status:"done",input:void 0,_subscription:void 0};case a: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:n,system:r,emit:s})=>{"done"!==e.status&&(e._subscription=t({input:e.input,system:r,self:n,emit:s}).subscribe({next:t=>{n._parent&&r._relay(n,n._parent,t)},error:t=>{r._relay(n,n,{type:tN,data:t})},complete:()=>{r._relay(n,n,{type:tC})}}))},getPersistedSnapshot:({_subscription:t,...e})=>e,restoreSnapshot:t=>({...t,_subscription:void 0})}}let tD="xstate.promise.resolve",tU="xstate.promise.reject",tB=new WeakMap;function tz(t){return{config:t,transition:(t,e,n)=>{if("active"!==t.status)return t;switch(e.type){case tD:{let n=e.data;return{...t,status:"done",output:n,input:void 0}}case tU:return{...t,status:"error",error:e.data,input:void 0};case a:return tB.get(n.self)?.abort(),tB.delete(n.self),{...t,status:"stopped",input:void 0};default:return t}},start:(e,{self:n,system:r,emit:s})=>{if("active"!==e.status)return;let i=new AbortController;tB.set(n,i),Promise.resolve(t({input:e.input,system:r,self:n,signal:i.signal,emit:s})).then(t=>{"active"===n.getSnapshot().status&&(tB.delete(n),r._relay(n,n,{type:tD,data:t}))},t=>{"active"===n.getSnapshot().status&&(tB.delete(n),r._relay(n,n,{type:tU,data:t}))})},getInitialSnapshot:(t,e)=>({status:"active",output:void 0,error:void 0,input:e}),getPersistedSnapshot:t=>t,restoreSnapshot:t=>t}}let tV=(r=void 0,{config:n=t=>void 0,transition:(t,e,r)=>({...t,context:n(t.context,e,r)}),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 tW(){return j(tV)}t.s(["createEmptyActor",()=>tW,"fromCallback",()=>tq,"fromEventObservable",()=>tL,"fromPromise",()=>tz],807574)},54531,t=>{"use strict";let e,n="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),r=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(n&&!i&&!t)return n();var a=t,c=o;let u=(a=a||{}).random??a.rng?.()??function(){if(!e){if("undefined"==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(r)}();if(u.length<16)throw Error("Random bytes length must be >= 16");if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,i){if((c=c||0)<0||c+16>i.length)throw RangeError(`UUID byte range ${c}:${c+15} is out of buffer bounds`);for(let t=0;t<16;++t)i[c+t]=u[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()}(u)}],54531)},636536,8881,509820,1940,363144,334364,954878,37751,592776,290571,603752,842093,586903,909116,140260,240126,979165,282541,394426,987675,349449,717718,238331,254824,177650,23515,311902,220324,172441,902965,627608,94059,175436,484973,272383,722249,96623,881283,t=>{"use strict";
2var e,n=t.i(54531),r=t.i(807574),s=t.i(397374);function i(t,e,n,r,{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:n.event,spawn:function(t,{machine:e,context:n},r,i){return(o,a)=>{let c=((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 c=(0,s.V)(e,o);if(!c)throw Error(`Actor logic '${o}' not implemented in machine '${e.id}'`);let u=(0,s.c)(c,{id:a?.id,parent:t.self,syncSnapshot:a?.syncSnapshot,input:"function"==typeof a?.input?a.input({context:n,event:r,self:t.self}):a?.input,src:o,systemId:a?.systemId});return i[u.id]=u,u}})(o,a);return i[c.id]=c,t.defer(()=>{c._processingStatus!==s.Z.Stopped&&c.start()}),c}}(t,e,n.event,o),self:t.self,system:t.system},c={};if("function"==typeof i)c=i(a,r);else for(let t of Object.keys(i)){let e=i[t];c[t]="function"==typeof e?e(a,r):e}let u=Object.assign({},e.context,c);return[(0,s._)(e,{context:u,children:Object.keys(o).length?{...e.children,...o}:e.children}),void 0,void 0]}function o(t){function e(t,e){}return e.type="xstate.assign",e.assignment=t,e.resolve=i,e}let a=new WeakMap;function c(t,e,n){let r=a.get(t);return r?e in r||(r[e]=n()):(r={[e]:n()},a.set(t,r)),r[e]}let u={},l=t=>"string"==typeof t?{type:t}:"function"==typeof t?"resolve"in t?{type:t.type}:{type:t.name}:t;class f{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.y)(this.config.states,(t,e)=>new f(t,{_parent:this,_key:e,_machine:this.machine})):u,"compound"===this.type&&!this.config.initial)throw Error(`No initial state specified for compound 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.z)(this),this.config.always&&(this.always=(0,s.B)(this.config.always).map(t=>(0,s.C)(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.t
2ype,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(l),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(l),eventType:null})}:void 0,history:this.history,states:(0,s.y)(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(l)})),entry:this.entry.map(l),exit:this.exit.map(l),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 c(this,"invoke",()=>(0,s.t)(this.config.invoke).map((t,e)=>{let{src:n,systemId:r}=t,i=t.id??(0,s.E)(this.id,e),o="string"==typeof n?n:`xstate.invoke.${(0,s.E)(this.id,e)}`;return{...t,src:o,id:i,systemId:r,toJSON(){let{onDone:e,onError:n,...r}=t;return{...r,type:"xstate.invoke",src:o,id:i}}}}))}get on(){return c(this,"on",()=>[...this.transitions].flatMap(([t,e])=>e.map(e=>[t,e])).reduce((t,[e,n])=>(t[e]=t[e]||[],t[e].push(n),t),{}))}get after(){return c(this,"delayedTransitions",()=>(0,s.F)(this))}get initial(){return c(this,"initial",()=>(0,s.G)(this,this.config.initial))}next(t,e){let n,r=e.type,i=[];for(let o of c(this,`candidates-${r}`,()=>(0,s.H)(this,r))){let{guard:a}=o,c=t.context,u=!1;try{u=!a||(0,s.D)(a,c,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 '${r}' in state node '${this.id}': 3${e.message}`)}if(u){i.push(...o.actions),n=o;break}}return n?[n]:void 0}get events(){return c(this,"events",()=>{let{states:t}=this,e=new Set(this.ownEvents);if(t)for(let n of Object.keys(t)){let r=t[n];if(r.states)for(let t of r.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 h{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 f(t,{_key:this.id,_machine:this}),this.root._initialize(),(0,s.I)(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:e,guards:n,actors:r,delays:s}=this.implementations;return new h(this.config,{actions:{...e,...t.actions},guards:{...n,...t.guards},actors:{...r,...t.actors},delays:{...s,...t.delays}})}resolveState(t){let e=(0,s.J)(this.root,t.value),n=(0,s.K)((0,s.p)(this.root,e));return(0,s.L)({_nodes:[...n],context:t.context||{},children:{},status:(0,s.M)(n,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,e,n){return(0,s.d)(t,e,n,[]).snapshot}microstep(t,e,n){return(0,s.d)(t,e,n,[]).microsteps.map(([t])=>t)}getTransitionData(t,e){return(0,s.O)(this.root,t.value,t,e)||[]}_getPreInitialState(t,e,n){let{context:r}=this.config,i=(0,s.L)({context:"function"!=typeof r&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return"function"==typeof r?(0,s.P)(i,e,t,[o(({spawn:t,event:e,self:n})=>r({spawn:t,input:e.input,self:n}))],n,void 0):i}getInitialSnapshot(t,e){let n=(0,s.e)(e),r=[],i=this._getPreInitialState(t,n,r),[o]=(0,s.i)(this.root,i,t,n,r),{snapshot:a}=(0,s.d)(o,n,t,r);return a}start(t){Object.values(t.children).forEach(t=>{"active"===t.getSnapshot().status&&t.start()})}getStateNodeById(t){let e=(0,s.Q)(t),n=e.slice(1),r=(0,s.R)(e[0])?e[0].slice(1):e[0],i=this.idMap.get(r);if(!i)throw Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return(0,s.T)(i,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,e){return(0,s.U)(t,e)}restoreSnapshot(t,e){let n={},r=t.children;Object.keys(r).forEach(t=>{let i=r[t],o=i.snapshot,a=i.src,c="string"==typeof a?(0,s.V)(this,a):a;if(!c)return;let u=(0,s.c)(c,{id:t,parent:e.self,syncSnapshot:i.syncSnapshot,snapshot:o,src:a,systemId:i.systemId});n[t]=u});let i=function(t,e){if(!e||"object"!=typeof e)return{};let n={};for(let r in e)for(let s of e[r]){let e=function(t,e){if(e instanceof f)return e;try{return t.machine.getStateNodeById(e.id)}catch{}}
3(t,s);e&&(n[r]??=[],n[r].push(e))}return n}(this.root,t.historyValue),o=(0,s.L)({...t,children:n,_nodes:Array.from((0,s.K)((0,s.p)(this.root,t.value))),historyValue:i},this),a=new Set;return!function t(e,n){if(!a.has(e))for(let r in a.add(e),e){let i=e[r];if(i&&"object"==typeof i){if("xstate$$type"in i&&i.xstate$$type===s.$){e[r]=n[i.id];continue}t(i,n)}}}(o.context,n),o}}function p(t,e,n,r,{event:s}){return[e,{event:"function"==typeof s?s(n,r):s},void 0]}function d(t,{event:e}){t.defer(()=>t.emit(e))}function y(t){function e(t,e){}return e.type="xstate.emit",e.event=t,e.resolve=p,e.execute=d,e}let v=((e={}).Parent="#_parent",e.Internal="#_internal",e);function g(t,e,n,r,{to:s,event:i,id:o,delay:a},c){let u,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 h="function"==typeof i?i(n,r):i;if("string"==typeof a){let t=f&&f[a];u="function"==typeof t?t(n,r):t}else u="function"==typeof a?a(n,r):a;let p="function"==typeof s?s(n,r):s;if("string"==typeof p){if(!(l=p===v.Parent?t.self._parent:p===v.Internal?t.self:p.startsWith("#_")?e.children[p.slice(2)]:c.deferredActorIds?.includes(p)?p:e.children[p]))throw Error(`Unable to send event to actor '${p}' from machine '${e.machine.id}'.`)}else l=p||t.self;return[e,{to:l,targetId:"string"==typeof p?p:void 0,event:h,id:o,delay:u},void 0]}function m(t,e,n){"string"==typeof n.to&&(n.to=e.children[n.to])}function b(t,e){t.defer(()=>{let{to:n,event:r,delay:i,id:o}=e;"number"==typeof i?t.system.scheduler.schedule(t.self,n,r,i,o):t.system._relay(t.self,n,r.type===s.W?(0,s.Y)(t.self.id,r.data):r)})}function _(t,e,n){function r(t,e){}return r.type="xstate.sendTo",r.to=t,r.event=e,r.id=n?.id,r.delay=n?.delay,r.resolve=g,r.retryResolve=m,r.execute=b,r}function S(t,e){return _(v.Parent,t,e)}function x(t,e,n,r,{collect:i}){let a=[],c=function(t){a.push(t)};return c.assign=(...t)=>{a.push(o(...t))},c.cancel=(...t)=>{a.push((0,s.a)(...t))},c.raise=(...t)=>{a.push((0,s.r)(...t))},c.sendTo=(...t)=>{a.push(_(...t))},c.sendParent=(...t)=>{a.push(S(...t))},c.spawnChild=(...t)=>{a.push((0,s.b)(...t))},c.stopChild=(...t)=>{a.push((0,s.s)(...t))},c.emit=(...t)=>{a.push(y(...t))},i({context:n.context,event:n.event,enqueue:c,check:t=>(0,s.D)(t,e.context,n.event,e),self:t.self,system:t.system},r),[e,void 0,a]}function w(t){function e(t,e){}return e.type="xstate.enqueueActions",e.collect=t,e.resolve=x,e}function k(t,e,n,r,{value:s,label:i}){return[e,{value:"function"==typeof s?s(n,r):s,label:i},void 0]}function E({logger:t},{value:e,label:n}){n?t(n,e):t(e)}function I(t=({context:t,event:e})=>({context:t,event:e}),e){function n(t,e){}return n.type="xstate.log",n.value=t,n.label=e,n.resolve=k,n.execute=E,n}function T(t,e){let n=(0,s.t)(e);if(!n.some(e=>(0,s.m)(t.type,e))){let e=1===n.length?`type matching "${n[0]}"`:`one of types matching "${n.join('", "')}"`;throw Error(`Expected event ${JSON.stringify(t)} to have ${e}`)}}function O({schemas:t,actors:e,actions:n,guards:r,delays:i}){return{assign:o,sendTo:_,raise:s.r,log:I,cancel:s.a,stopChild:s.s,enqueueActions:w,emit:y,spawnChild:s.b,createStateConfig:t=>t,createAction:t=>t,createMachine:s=>new h({...s,schemas:t},{actors:e,actions:n,guards:r,delays:i}),extend:s=>O({schemas:t,actors:e,actions:{...n,...s.actions},guards:{...r,...s.guards},delays:{...i,...s.delays}})}}t.s(["a",()=>y,"b",()=>S,"e",()=>w,"l",()=>I,"s",()=>_],8881),t.i(847616),t.s(["assertEvent",()=>T,"setup",()=>O],509820),t.s(["assign",()=>o],1940);var A=s;t.s(["createActor",()=>A.c],363144);var A=s;t.s(["enqueueActions",()=>w],334364);var $=s;t.s(["raise",()=>$.r],954878);var $=s;t.s(["emit",()=>y],37751);var j=s;t.s(["stopChild",()=>j.s],592776);var j=s,P=function(t,e){return(P=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function R(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}P(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}
3function M(t,e,n,r){return new(n||(n=Promise))(function(s,i){function o(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?s(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(o,a)}c((r=r.apply(t,e||[])).next())})}function q(t,e){var n,r,s,i={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){var u=[a,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(s=2&u[0]?r.return:u[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,u[1])).done)return s;switch(r=0,s&&(u=[2&u[0],s.value]),u[0]){case 0:case 1:s=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(s=(s=i.trys).length>0&&s[s.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!s||u[1]>s[0]&&u[1]<s[3])){i.label=u[1];break}if(6===u[0]&&i.label<s[1]){i.label=s[1],s=u;break}if(s&&i.label<s[2]){i.label=s[2],i.ops.push(u);break}s[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=s=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function N(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw 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 r,s,i=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(t){s={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(s)throw s.error}}return o}function L(t,e,n){if(n||2==arguments.length)for(var r,s=0,i=e.length;s<i;s++)!r&&s in e||(r||(r=Array.prototype.slice.call(e,0,s)),r[s]=e[s]);return t.concat(r||Array.prototype.slice.call(e))}function D(t){return this instanceof D?(this.v=t,this):new D(t)}function U(t,e,n){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var r,s=n.apply(t,e||[]),i=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",function(t){return function(e){return Promise.resolve(e).then(t,u)}}),r[Symbol.asyncIterator]=function(){return this},r;function o(t,e){s[t]&&(r[t]=function(e){return new Promise(function(n,r){i.push([t,e,n,r])>1||a(t,e)})},e&&(r[t]=e(r[t])))}function a(t,e){try{var n;(n=s[t](e)).value instanceof D?Promise.resolve(n.value.v).then(c,u):l(i[0][2],n)}catch(t){l(i[0][3],t)}}function c(t){a("next",t)}function u(t){a("throw",t)}function l(t,e){t(e),i.shift(),i.length&&a(i[0][0],i[0][1])}}function B(t){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=N(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise(function(r,s){var i,o,a;i=r,o=s,a=(e=t[n](e)).done,Promise.resolve(e.value).then(function(t){i({value:t,done:a})},o)})}}}function z(t){return"function"==typeof t}function V(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}"function"==typeof SuppressedError&&SuppressedError,t.s(["__asyncGenerator",()=>U,"__asyncValues",()=>B,"__await",()=>D,"__awaiter",()=>M,"__extends",()=>R,"__generator",()=>q,"__read",()=>C,"__spreadArray",()=>L,"__values",()=>N],290571),t.s(["isFunction",()=>z],603752),t.s(["createErrorClass",()=>V],842093);var W=V(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 G(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}t.s(["arrRemove",()=>G],586903);var J=function(){var t;function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t,e,n,r,s,i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var o=N(i),a=o.next();!a.done;a=o.next())a.value.remove(this)}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=o.return)&&e.call(o)}finally{if(t)throw t.error}}else i.remove(this);var c=this.initialTeardown;
3if(z(c))try{c()}catch(t){s=t instanceof W?t.errors:[t]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var l=N(u),f=l.next();!f.done;f=l.next()){var h=f.value;try{H(h)}catch(t){s=null!=s?s:[],t instanceof W?s=L(L([],C(s)),C(t.errors)):s.push(t)}}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}}if(s)throw new W(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)H(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!=(n=this._finalizers)?n:[]).push(t)}},e.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},e.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},e.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&G(e,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&G(n,t),t instanceof e&&t._removeParent(this)},(t=new e).closed=!0,e.EMPTY=t,e}(),K=J.EMPTY;function Y(t){return t instanceof J||t&&"closed"in t&&z(t.remove)&&z(t.add)&&z(t.unsubscribe)}function H(t){z(t)?t():t.unsubscribe()}t.s(["EMPTY_SUBSCRIPTION",()=>K,"Subscription",()=>J,"isSubscription",()=>Y],909116);var F=void 0,Q={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var s=Q.delegate;return(null==s?void 0:s.setTimeout)?s.setTimeout.apply(s,L([t,e],C(n))):setTimeout.apply(void 0,L([t,e],C(n)))},clearTimeout:function(t){var e=Q.delegate;return((null==e?void 0:e.clearTimeout)||clearTimeout)(t)},delegate:void 0};function Z(t){Q.setTimeout(function(){!1;throw t})}function X(){}var tt=te("C",void 0,void 0);function te(t,e,n){return{kind:t,value:e,error:n}}var tn=null;function tr(t){var e,n,r,s;1;t()}function ts(t){}t.s(["captureError",()=>ts,"errorContext",()=>tr],140260);var ti=function(t){function e(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,Y(e)&&e.add(n)):n.destination=th,n}return R(e,t),e.create=function(t,e,n){return new tu(t,e,n)},e.prototype.next=function(t){this.isStopped?tf(te("N",t,void 0),this):this._next(t)},e.prototype.error=function(t){this.isStopped?tf(te("E",void 0,t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?tf(tt,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(J),to=Function.prototype.bind;function ta(t,e){return to.call(t,e)}var tc=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){tl(t)}},t.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(t){tl(t)}else tl(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){tl(t)}},t}(),tu=function(t){function e(e,n,r){var s,i,o=t.call(this)||this;return z(e)||!e?s={next:null!=e?e:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:s=e,o.destination=new tc(s),o}return R(e,t),e}(ti);function tl(t){Z(t)}function tf(t,e){}var th={closed:!0,next:X,error:function(t){throw t},complete:X};t.s(["SafeSubscriber",()=>tu,"Subscriber",()=>ti],240126);var tp="function"==typeof Symbol&&Symbol.observable||"@@observable";function td(t){return t}function ty(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return tv(t)}function tv(t){return 0===t.length?td:1===t.length?t[0]:function(e){return t.reduce(function(t,e){return e(t)},e)}}t.s(["identity",()=>td],979165),t.s(["pipe",()=>ty,"pipeFromArray",()=>tv],282541);var tg=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var r=this,s=!function(t){return t&&t instanceof ti||t&&z(t.next)&&z(t.error)&&z(t.complete)&&Y(t)}(t)?new tu(t,e,n):t;return tr(function(){var t=r.operator,e=r.source;s.add(t?t.call(s,e):e?r._subscribe(s):r._trySubscribe(s))}),s},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},t.prototype.forEach=function(t,e){var n=this;return new(e=tm(e))(function(e,r){var s=new tu({next:function(e){try{t(e)}catch(t){r(t),s.unsubscribe()}},error:r,complete:e});n.subscribe(s)})},t.prototype._subscribe=function(t){var e;return null==(e=this.source)?void 0:e.subscribe(t)},t.prototype[tp]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return tv(t)(this)},t.prototype.toPromise=function(t){var e=this;return new(t=tm(t))(function(t,n){var r;e.subscribe(function(t){return r=t},function(t){return n(t)},function(){return t(r)})})},t.create=function(e){return new t(e)},t}();function tm(t){var e;return null!=(e=null!=t?t:F)?e:Promise}t.s(["Observable",()=>tg],394426);var tb=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function t_(t){return z(null==t?void 0:t.then)}function tS(t){return z(t[tp])}function tx(t){return Symbol.asyncIterator&&z(null==t?void 0:t[Symbol.asyncIterator])}function tw(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",()=>tb],987675),t.s(["isPromise",()=>t_],349449),t.s(["isInteropObservable",()=>tS],717718),t.s(["isAsyncIterable",()=>tx],238331),t.s(["createInvalidObservableTypeError",()=>tw],254824);var tk="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function tE(t){return z(null==t?void 0:t[tk])}function tI(t){return U(this,arguments,function(){var e,n,r;return q(this,function(s){switch(s.label){case 0:e=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,D(e.read())];case 3:if(r=(n=s.sent()).value,!n.done)return[3,5];return[4,D(void 0)];case 4:return[2,s.sent()];case 5:return[4,D(r)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function tT(t){return z(null==t?void 0:t.getReader)}function tO(t){if(t instanceof tg)return t;if(null!=t){var e,n,r,s;if(tS(t)){return e=t,new tg(function(t){var n=e[tp]();if(z(n.subscribe))return n.subscribe(t);throw TypeError("Provided object does not correctly implement Symbol.observable")})}if(tb(t)){return n=t,new tg(function(t){for(var e=0;e<n.length&&!t.closed;e++)t.next(n[e]);t.complete()})}if(t_(t)){return r=t,new tg(function(t){r.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,Z)})}if(tx(t))return tA(t);if(tE(t)){return s=t,new tg(function(t){var e,n;try{for(var r=N(s),i=r.next();!i.done;i=r.next()){var o=i.value;if(t.next(o),t.closed)return}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}t.complete()})}if(tT(t))return tA(tI(t))}throw tw(t)}function tA(t){return new tg(function(e){(function(t,e){var n,r,s,i;return M(this,void 0,void 0,function(){var o;return q(this,function(a){switch(a.label){case 0:a.trys.push([0,5,6,11]),n=B(t),a.label=1;case 1:return[4,n.next()];case 2:if((r=a.sent()).done)return[3,4];if(o=r.value,e.next(o),e.closed)return[2];a.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s={error:a.sent()},[3,11];case 6:if(a.trys.push([6,,9,10]),!(r&&!r.done&&(i=n.return)))return[3,8];return[4,i.call(n)];case 7:a.sent(),a.label=8;case 8:return[3,10];case 9:if(s)throw s.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})})(t,e).catch(function(t){return e.error(t)})})}function t$(t){return new tg(function(e){tO(t()).subscribe(e)})}function tj(t){return function(e){if(z(null==e?void 0:e.lift))return e.lift(function(e){try{return t(e,this)}catch(t){this.error(t)}});throw TypeError("Unable to lift unknown Observable type")}}function tP(t,e,n,r,s){return new tR(t,e,n,r,s)}t.s(["iterator",()=>tk],177650),t.s(["isIterable",()=>tE],23515),t.s(["isReadableStreamLike",()=>tT,"readableStreamLikeToAsyncGenerator",()=>tI],311902),t.s(["innerFrom",()=>tO],220324),t.s(["defer",()=>t$],172441),t.s(["operate",()=>tj],902965);var tR=function(t){function e(e,n,r,s,i,o){var a=t.call(this,e)||this;return a.onFinalize=i,a.shouldUnsubscribe=o,a._next=n?function(t){try{n(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=r?function(){try{r()}catch(t){e.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,a}return R(e,t),e.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),n||null==(e=this.onFinalize)||e.call(this)}},e}(ti);function tM(t,e){return tj(function(n,r){var s=0;n.subscribe(tP(r,function(n){r.next(t.call(e,n,s++))}))})}function tq(t,e,n,r,s){void 0===r&&(r=0),void 0===s&&(s=!1);var i=e.schedule(function(){n(),s?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(i),!s)return i}function tN(t,e,n){return(void 0===n&&(n=1/0),z(e))?tN(function(n,r){return tM(function(t,s){return e(n,t,r,s)})(tO(t(n,r)))},n):("number"==typeof e&&(n=e),tj(function(e,r){var s,i,o,a,c,u,l,f;return s=n,i=[],o=0,a=0,c=!1,u=function(){!c||i.length||o||r.complete()},l=function(t){return o<s?f(t):i.push(t)},f=function(e){o++;var n=!1;tO(t(e,a++)).subscribe(tP(r,function(t){r.next(t)},function(){n=!0},void 0,function(){if(n)try{for(o--;i.length&&o<s;)!function(){var t=i.shift();f(t)}();u()}catch(t){r.error(t)}}))},e.subscribe(tP(r,l,function(){c=!0,u()})),function(){}}))}t.s(["createOperatorSubscriber",()=>tP],627608),t.s(["map",()=>tM],94059),t.s(["executeSchedule",()=>tq],175436),t.s(["mergeMap",()=>tN],484973);var tC=Array.isArray;function tL(t){return tM(function(e){return tC(e)?t.apply(void 0,L([],C(e))):t(e)}
3)}t.s(["mapOneOrManyArgs",()=>tL],272383);var tD=["addListener","removeListener"],tU=["addEventListener","removeEventListener"],tB=["on","off"];function tz(t,e,n,r){if(z(n)&&(r=n,n=void 0),r)return tz(t,e,n).pipe(tL(r));var s,i,o,a=C(z((s=t).addEventListener)&&z(s.removeEventListener)?tU.map(function(r){return function(s){return t[r](e,s,n)}}):z((i=t).addListener)&&z(i.removeListener)?tD.map(tV(t,e)):z((o=t).on)&&z(o.off)?tB.map(tV(t,e)):[],2),c=a[0],u=a[1];if(!c&&tb(t))return tN(function(t){return tz(t,e,n)})(tO(t));if(!c)throw TypeError("Invalid event target");return new tg(function(t){var e=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.next(1<e.length?e:e[0])};return c(e),function(){return u(e)}})}function tV(t,e){return function(n){return function(r){return t[n](e,r)}}}function tW(t,e){return tj(function(n,r){var s=0;n.subscribe(tP(r,function(n){return t.call(e,n,s++)&&r.next(n)}))})}t.s(["filter",()=>tW],722249);var tG=new tg(function(t){return t.complete()});function tJ(t){return t<=0?function(){return tG}:tj(function(e,n){var r=0;e.subscribe(tP(n,function(e){++r<=t&&(n.next(e),t<=r&&n.complete())}))})}t.s(["EMPTY",()=>tG],96623);let tK=t=>({context:e})=>{let{count:n,include:r,exclude:s,responseType:i="message.received"}=t;return{count:n,domain:e.domain,from:e.connectTo,include:r?Array.isArray(r)?r:[r]:[],exclude:s?Array.isArray(s)?s:[s]:[],responseType:i,target:e.target,to:e.name}},tY=t$(()=>tz(window,"message")),tH=t=>(0,r.fromEventObservable)(({input:e})=>{var n,r,s;let i;return tY.pipe(t?tM(t):ty(),tW(t=>{let{data:n}=t;return(!e.include.length||e.include.includes(n.type))&&(!e.exclude.length||!e.exclude.includes(n.type))&&n.domain===e.domain&&n.from===e.from&&n.to===e.to&&(!e.target||t.source===e.target)}),tM((i=e.responseType,t=>({type:i,message:t}))),e.count?ty((n=e.count,void 0===r&&(r=null),r=null!=r?r:n,tj(function(t,e){var s=[],i=0;t.subscribe(tP(e,function(t){var o,a,c,u,l=null;i++%r==0&&s.push([]);try{for(var f=N(s),h=f.next();!h.done;h=f.next()){var p=h.value;p.push(t),n<=p.length&&(l=null!=l?l:[]).push(p)}}catch(t){o={error:t}}finally{try{h&&!h.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}if(l)try{for(var d=N(l),y=d.next();!y.done;y=d.next()){var p=y.value;G(s,p),e.next(p)}}catch(t){c={error:t}}finally{try{y&&!y.done&&(u=d.return)&&u.call(d)}finally{if(c)throw c.error}}},function(){var t,n;try{for(var r=N(s),i=r.next();!i.done;i=r.next()){var o=i.value;e.next(o)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}e.complete()},void 0,function(){s=null}))})),(s=t=>t,z(void 0)?tN(s,void 0,1):tN(s,1)),tJ(e.count)):ty())}),tF="sanity/comlink",tQ="comlink/response",tZ="comlink/heartbeat",tX="comlink/disconnect",t0="comlink/handshake/syn",t1="comlink/handshake/syn-ack",t2="comlink/handshake/ack",t3=()=>O({types:{},actors:{listen:(0,r.fromEventObservable)(({input:t})=>{let e,n=t.signal?tz(t.signal,"abort").pipe((e=`Request ${t.requestId} aborted`,t=>t.pipe(tJ(1),tM(()=>{throw Error(e)})))):tG;return tz(window,"message").pipe(tW(e=>e.data?.type===tQ&&e.data?.responseTo===t.requestId&&!!e.source&&t.sources.has(e.source)),tJ(t.sources.size),tj(function(t,e){tO(n).subscribe(tP(e,function(){return e.complete()},X)),e.closed||t.subscribe(e)}))})},actions:{"send message":({context:t},e)=>{let{sources:n,targetOrigin:r}=t,{message:s}=e;n.forEach(t=>{t.postMessage(s,{targetOrigin:r})})},"on success":_(({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":_(({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":_(({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,n.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:n,domain:r,from:s,id:i,responseTo:o,to:a,type:c}=t;return{message:{channelId:e,data:n,domain:r,from:s,id:i,to:a,type:c,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:o({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 n=()=>{t(e.event)};e.immediate&&n();let r=setInterval(n,e.interval);return()=>{clearInterval(r)}});let t4=()=>O({types:{},actors:{requestMachine:t3(),listen:tH()},actions:{"buffer handshake":o({handshakeBuffer:({event:t,context:e})=>(T(t,"message.received"),[...e.handshakeBuffer,t])}),"buffer message":w(({enqueue:t})=>{t.assign({buffer:({event:t,context:e})=>(T(t,"post"),[...e.buffer,{data:t.data,resolvable:t.resolvable,options:t.options}])}),t.emit(({event:t})=>(T(t,"post"),{type:"buffer.added",message:t.data}))}),"create request":o({requests:({context:t,event:e,self:r,spawn:s})=>{T(e,"request");let i=(Array.isArray(e.data)?e.data:[e.data]).map(e=>s("requestMachine",{id:`req-${(0,n.v4)()}`,input:{channelId:t.channelId,data:e.data,domain:t.domain,expectResponse:e.expectResponse,from:t.name,parentRef:r,resolvable:e.resolvable,responseTimeout:e.options?.responseTimeout,responseTo:e.responseTo,signal:e.options?.signal,sources:t.target,suppressWarnings:e.options?.suppressWarnings,targetOrigin:t.targetOrigin,to:t.connectTo,type:e.type}}));return[...t.requests,...i]}}),"emit heartbeat":y(()=>({type:"heartbeat"})),"emit received message":w(({enqueue:t})=>{t.emit(({event:t})=>(T(t,"message.received"),{type:"message",message:t.message.data}))}),"emit status":y((t,e)=>({type:"status",status:e.status})),"post message":(0,$.r)(({event:t})=>(T(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":w(({context:t,enqueue:e})=>{t.handshakeBuffer.forEach(t=>e.raise(t)),e.assign({handshakeBuffer:[]})}),"remove request":w(({context:t,enqueue:e,event:n})=>{T(n,["request.success","request.failed","request.aborted"]),(0,j.s)(n.requestId),e.assign({requests:t.requests.filter(({id:t})=>t!==n.requestId)})}),"send response":(0,$.r)(({event:t})=>(T(t,["message.received","heartbeat.received"]),{type:"request",data:{type:tQ,responseTo:t.message.data.id,data:void 0}})),"send handshake syn ack":(0,$.r)({type:"request",data:{type:t1}}),"send pending messages":w(({enqueue:t})=>{t.raise(({context:t})=>({type:"request",data:t.buffer.map(({data:t,resolvable:e,options:n})=>({data:t.data,type:t.type,expectResponse:!!e,resolvable:e,options:n}))})),t.emit(({context:t})=>({type:"buffer.flushed",messages:t.buffer.map(({data:t})=>t)})),t.assign({buffer:[]})}),"set connection config":o({channelId:({event:t})=>(T(t,"handshake.syn"),t.message.data.channelId),target:({event:t})=>(T(t,"handshake.syn"),t.message.source||void 0),targetOrigin:({event:t})=>(T(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??tF,handshakeBuffer:[],name:t.name,requests:[],target:void 0,targetOrigin:null}),invoke:{id:"listen for handshake syn",src:"listen",input:tK({include:t0,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:tK({include:t2,count:1,responseType:"handshake.complete"}),onDone:"connected"},{id:"listen for disconnect",src:"listen",input:tK({include:tX,count:1,responseType:"disconnect"})},{id:"listen for messages",src:"listen",input:tK({exclude:[tX,t0,t2,tZ,tQ]})}],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:tK({exclude:[tX,t0,t2,tZ,tQ]})},{id:"listen for heartbeat",src:"listen",input:tK({include:tZ,responseType:"heartbeat.received"})},{id:"listen for disconnect",src:"listen",input:tK({include:tX,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"]}}}}}),t6=(t,e=t4())=>
3{let n,r=(0,A.c)(e,{input:t}),s=new Map,i=new Map;r.on("message",({message:t})=>{let e=s.get(t.type);if(e)return void e.forEach(e=>e(t.data));let n=i.get(t.type);n?n.add(t):i.set(t.type,new Set([t]))});let o=()=>{r.stop()};return{actor:r,fetch:(t,e,n)=>{let s,i,{responseTimeout:o=1e4,signal:a,suppressWarnings:c}=n||{},u="function"==typeof Promise.withResolvers?Promise.withResolvers():{promise:new Promise((t,e)=>{s=t,i=e}),resolve:s,reject:i};return r.send({type:"post",data:{type:t,data:e},resolvable:u,options:{responseTimeout:o,signal:a,suppressWarnings:c}}),u.promise},machine:e,on:(t,e,n)=>{let r=s.get(t)||new Set;s.has(t)||s.set(t,r),r.add(e);let o=i.get(t);if(o){let r=n?.replay??1;Array.from(o).slice(-r).forEach(({data:t})=>e(t)),i.delete(t)}return()=>{r.delete(e)}},onStatus:(t,e)=>{let s=r.on("status",r=>{n=r.status,e&&r.status!==e||t(r.status)});return n&&t(n),()=>s.unsubscribe()},post:(t,e)=>{r.send({type:"post",data:{type:t,data:e}})},start:()=>(r.start(),o),stop:o}};t.s(["DOMAIN",()=>tF,"MSG_DISCONNECT",()=>tX,"MSG_HANDSHAKE_ACK",()=>t2,"MSG_HANDSHAKE_SYN",()=>t0,"MSG_HANDSHAKE_SYN_ACK",()=>t1,"MSG_HEARTBEAT",()=>tZ,"MSG_RESPONSE",()=>tQ,"createListenLogic",()=>tH,"createNode",()=>t6,"createNodeMachine",()=>t4,"createRequestMachine",()=>t3],881283);let t7={"handshake/syn":t0,"handshake/syn-ack":t1,"handshake/ack":t2,"channel/response":tQ,"channel/heartbeat":tZ,"channel/disconnect":tX,"overlay/focus":"visual-editing/focus","overlay/navigate":"visual-editing/navigate","overlay/toggle":"visual-editing/toggle","presentation/toggleOverlay":"presentation/toggle-overlay"},t5={[t0]:"handshake/syn",[t1]:"handshake/syn-ack",[t2]:"handshake/ack",[tQ]:"channel/response",[tZ]:"channel/heartbeat",[tX]:"channel/disconnect","visual-editing/focus":"overlay/focus","visual-editing/navigate":"overlay/navigate","visual-editing/toggle":"overlay/toggle","presentation/toggle-overlay":"presentation/toggleOverlay"},t9=t=>{let{data:e}=t;return e&&"object"==typeof e&&"domain"in e&&"type"in e&&"from"in e&&"to"in e&&("sanity/channels"===e.domain&&(e.domain=tF),"overlays"===e.to&&(e.to="visual-editing"),"overlays"===e.from&&(e.from="visual-editing"),e.channelId=e.connectionId,delete e.connectionId,e.type=t7[e.type]??e.type),t},t8=({context:t},e)=>{let{sources:n,targetOrigin:r}=t,s=(t=>{let{channelId:e,...n}=t,r={...n,connectionId:e};return r.domain===tF&&(r.domain="sanity/channels"),"visual-editing"===r.to&&(r.to="overlays"),"visual-editing"===r.from&&(r.from="overlays"),r.type=t5[r.type]??r.type,"channel/response"===r.type&&r.responseTo&&!r.data&&(r.data={responseTo:r.responseTo}),("handshake/syn"===r.type||"handshake/syn-ack"===r.type||"handshake/ack"===r.type)&&(r.data={id:r.connectionId}),r})(e.message);n.forEach(t=>{t.postMessage(s,{targetOrigin:r})})},et=()=>({listen:tH(t9),requestMachine:t3().provide({actions:{"send message":t8}})});function ee(){return window.self!==window.top}function en(){return!!window.opener}function er(){return ee()||en()}t.s(["createCompatibilityActors",()=>et,"isMaybePresentation",()=>er,"isMaybePreviewIframe",()=>ee,"isMaybePreviewWindow",()=>en],636536)}]);
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.