@clicktap/state 0.13.13 → 0.13.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,42 +1,16 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Xs=require("react/jsx-runtime"),ct=require("react");function P_(n,i){for(var r=0;r<i.length;r++){const o=i[r];if(typeof o!="string"&&!Array.isArray(o)){for(const a in o)if(a!=="default"&&!(a in n)){const f=Object.getOwnPropertyDescriptor(o,a);f&&Object.defineProperty(n,a,f.get?f:{enumerable:!0,get:()=>o[a]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}function F_(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function U_(){const n=F_();if(n.__xstate__)return n.__xstate__}const B_=n=>{if(typeof window>"u")return;const i=U_();i&&i.register(n)};class Ga{constructor(i){this._process=i,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(i){const r={value:i,next:null};if(this._current){this._last.next=r,this._last=r;return}this._current=r,this._last=r,this._active&&this.flush()}flush(){for(;this._current;){const i=this._current;this._process(i.value),this._current=i.next}this._last=null}}const dc=".",q_="",pc="",$_="#",W_="*",gc="xstate.init",H_="xstate.error",jn="xstate.stop";function G_(n,i){return{type:`xstate.after.${n}.${i}`}}function Bs(n,i){return{type:`xstate.done.state.${n}`,output:i}}function V_(n,i){return{type:`xstate.done.actor.${n}`,output:i}}function _c(n,i){return{type:`xstate.error.actor.${n}`,error:i}}function vc(n){return{type:gc,input:n}}function At(n){setTimeout(()=>{throw n})}const z_=(()=>typeof Symbol=="function"&&Symbol.observable||"@@observable")();function Va(n,i){return`${n.sessionId}.${i}`}let Y_=0;function J_(n,i){const r=new Map,o=new Map,a=new WeakMap,f=new Set,d={},{clock:g,logger:m}=i,E={schedule:(S,D,R,F,H=Math.random().toString(36).slice(2))=>{const ie={source:S,target:D,event:R,delay:F,id:H,startedAt:Date.now()},De=Va(S,H);x._snapshot._scheduledEvents[De]=ie;const le=g.setTimeout(()=>{delete d[De],delete x._snapshot._scheduledEvents[De],x._relay(S,D,R)},F);d[De]=le},cancel:(S,D)=>{const R=Va(S,D),F=d[R];delete d[R],delete x._snapshot._scheduledEvents[R],g.clearTimeout(F)},cancelAll:S=>{for(const D in x._snapshot._scheduledEvents){const R=x._snapshot._scheduledEvents[D];R.source===S&&E.cancel(S,R.id)}}},I=S=>{if(!f.size)return;const D={...S,rootId:n.sessionId};f.forEach(R=>{var F;return(F=R.next)==null?void 0:F.call(R,D)})},x={_snapshot:{_scheduledEvents:((i==null?void 0:i.snapshot)&&i.snapshot.scheduler)??{}},_bookId:()=>`x:${Y_++}`,_register:(S,D)=>(r.set(S,D),S),_unregister:S=>{r.delete(S.sessionId);const D=a.get(S);D!==void 0&&(o.delete(D),a.delete(S))},get:S=>o.get(S),_set:(S,D)=>{const R=o.get(S);if(R&&R!==D)throw new Error(`Actor with system ID '${S}' already exists.`);o.set(S,D),a.set(D,S)},inspect:S=>{f.add(S)},_sendInspectionEvent:I,_relay:(S,D,R)=>{x._sendInspectionEvent({type:"@xstate.event",sourceRef:S,actorRef:D,event:R}),D._send(R)},scheduler:E,getSnapshot:()=>({_scheduledEvents:{...x._snapshot._scheduledEvents}}),start:()=>{const S=x._snapshot._scheduledEvents;x._snapshot._scheduledEvents={};for(const D in S){const{source:R,target:F,event:H,delay:ie,id:De}=S[D];E.schedule(R,F,H,ie,De)}},_clock:g,_logger:m};return x}function yc(n,i){const r=za(n),o=za(i);return typeof o=="string"?typeof r=="string"?o===r:!1:typeof r=="string"?r in o:Object.keys(r).every(a=>a in o?yc(r[a],o[a]):!1)}function Ks(n){if(Ec(n))return n;let i=[],r="";for(let o=0;o<n.length;o++){switch(n.charCodeAt(o)){case 92:r+=n[o+1],o++;continue;case 46:i.push(r),r="";continue}r+=n[o]}return i.push(r),i}function za(n){if(Iv(n))return n.value;if(typeof n!="string")return n;const i=Ks(n);return X_(i)}function X_(n){if(n.length===1)return n[0];const i={};let r=i;for(let o=0;o<n.length-1;o++)if(o===n.length-2)r[n[o]]=n[o+1];else{const a=r;r={},a[n[o]]=r}return i}function Ya(n,i){const r={},o=Object.keys(n);for(let a=0;a<o.length;a++){const f=o[a];r[f]=i(n[f],f,n,a)}return r}function mc(n){return Ec(n)?n:[n]}function kt(n){return n===void 0?[]:mc(n)}function qs(n,i,r,o){return typeof n=="function"?n({context:i,event:r,self:o}):n}function Ec(n){return Array.isArray(n)}function K_(n){return n.type.startsWith("xstate.error.actor")}function gn(n){return mc(n).map(i=>typeof i>"u"||typeof i=="string"?{target:i}:i)}function Tc(n){if(!(n===void 0||n===q_))return kt(n)}function Ja(n,i,r){var f,d,g;const o=typeof n=="object",a=o?n:void 0;return{next:(f=o?n.next:n)==null?void 0:f.bind(a),error:(d=o?n.error:i)==null?void 0:d.bind(a),complete:(g=o?n.complete:r)==null?void 0:g.bind(a)}}function Xa(n,i){return`${i}.${n}`}function Qs(n,i){const r=i.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!r)return n.implementations.actors[i];const[,o,a]=r,d=n.getStateNodeById(a).config.invoke;return(Array.isArray(d)?d[o]:d).src}const js=1;let Ne=function(n){return n[n.NotStarted=0]="NotStarted",n[n.Running=1]="Running",n[n.Stopped=2]="Stopped",n}({});const Q_={clock:{setTimeout:(n,i)=>setTimeout(n,i),clearTimeout:n=>clearTimeout(n)},logger:console.log.bind(console),devTools:!1};class j_{constructor(i,r){this.logic=i,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new Ga(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=Ne.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 o={...Q_,...r},{clock:a,logger:f,parent:d,syncSnapshot:g,id:m,systemId:E,inspect:I}=o;this.system=d?d.system:J_(this,{clock:a,logger:f}),I&&!d&&this.system.inspect(Ja(I)),this.sessionId=this.system._bookId(),this.id=m??this.sessionId,this.logger=(r==null?void 0:r.logger)??this.system._logger,this.clock=(r==null?void 0:r.clock)??this.system._clock,this._parent=d,this._syncSnapshot=g,this.options=o,this.src=o.src??i,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:x=>{this._deferred.push(x)},system:this.system,stopChild:x=>{if(x._parent!==this)throw new Error(`Cannot stop child actor ${x.id} of ${this.id} because it is not a child`);x._stop()},emit:x=>{const S=this.eventListeners.get(x.type);if(S)for(const D of Array.from(S))D(x)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),E&&(this._systemId=E,this.system._set(E,this)),this._initState((r==null?void 0:r.snapshot)??(r==null?void 0:r.state)),E&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(i){var r;try{this._snapshot=i?this.logic.restoreSnapshot?this.logic.restoreSnapshot(i,this._actorScope):i:this.logic.getInitialSnapshot(this._actorScope,(r=this.options)==null?void 0:r.input)}catch(o){this._snapshot={status:"error",output:void 0,error:o}}}update(i,r){var a,f;this._snapshot=i;let o;for(;o=this._deferred.shift();)try{o()}catch(d){this._deferred.length=0,this._snapshot={...i,status:"error",error:d}}switch(this._snapshot.status){case"active":for(const d of this.observers)try{(a=d.next)==null||a.call(d,i)}catch(g){At(g)}break;case"done":for(const d of this.observers)try{(f=d.next)==null||f.call(d,i)}catch(g){At(g)}this._stopProcedure(),this._complete(),this._doneEvent=V_(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:r,snapshot:i})}subscribe(i,r,o){var f;const a=Ja(i,r,o);if(this._processingStatus!==Ne.Stopped)this.observers.add(a);else switch(this._snapshot.status){case"done":try{(f=a.complete)==null||f.call(a)}catch(d){At(d)}break;case"error":{const d=this._snapshot.error;if(!a.error)At(d);else try{a.error(d)}catch(g){At(g)}break}}return{unsubscribe:()=>{this.observers.delete(a)}}}on(i,r){let o=this.eventListeners.get(i);o||(o=new Set,this.eventListeners.set(i,o));const a=r.bind(void 0);return o.add(a),{unsubscribe:()=>{o.delete(a)}}}start(){if(this._processingStatus===Ne.Running)return this;this._syncSnapshot&&this.subscribe({next:o=>{o.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:o})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=Ne.Running;const i=vc(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:i}),this._snapshot.status){case"done":return this.update(this._snapshot,i),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(o){return this._snapshot={...this._snapshot,status:"error",error:o},this._error(o),this}return this.update(this._snapshot,i),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(i){let r,o;try{r=this.logic.transition(this._snapshot,i,this._actorScope)}catch(a){o={err:a}}if(o){const{err:a}=o;this._snapshot={...this._snapshot,status:"error",error:a},this._error(a);return}this.update(r,i),i.type===jn&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===Ne.Stopped?this:(this.mailbox.clear(),this._processingStatus===Ne.NotStarted?(this._processingStatus=Ne.Stopped,this):(this.mailbox.enqueue({type:jn}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){var i;for(const r of this.observers)try{(i=r.complete)==null||i.call(r)}catch(o){At(o)}this.observers.clear()}_reportError(i){if(!this.observers.size){this._parent||At(i);return}let r=!1;for(const o of this.observers){const a=o.error;r||(r=!a);try{a==null||a(i)}catch(f){At(f)}}this.observers.clear(),r&&At(i)}_error(i){this._stopProcedure(),this._reportError(i),this._parent&&this.system._relay(this,this._parent,_c(this.id,i))}_stopProcedure(){return this._processingStatus!==Ne.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new Ga(this._process.bind(this)),this._processingStatus=Ne.Stopped,this.system._unregister(this),this)}_send(i){this._processingStatus!==Ne.Stopped&&this.mailbox.enqueue(i)}send(i){this.system._relay(void 0,this,i)}attachDevTools(){const{devTools:i}=this.options;i&&(typeof i=="function"?i:B_)(this)}toJSON(){return{xstate$$type:js,id:this.id}}getPersistedSnapshot(i){return this.logic.getPersistedSnapshot(this._snapshot,i)}[z_](){return this}getSnapshot(){return this._snapshot}}function Mt(n,...[i]){return new j_(n,i)}function Z_(n,i,r,o,{sendId:a}){const f=typeof a=="function"?a(r,o):a;return[i,f]}function ev(n,i){n.defer(()=>{n.system.scheduler.cancel(n.self,i)})}function tv(n){function i(r,o){}return i.type="xstate.cancel",i.sendId=n,i.resolve=Z_,i.execute=ev,i}function nv(n,i,r,o,{id:a,systemId:f,src:d,input:g,syncSnapshot:m}){const E=typeof d=="string"?Qs(i.machine,d):d,I=typeof a=="function"?a(r):a;let x;return E&&(x=Mt(E,{id:I,src:d,parent:n.self,syncSnapshot:m,systemId:f,input:typeof g=="function"?g({context:i.context,event:r.event,self:n.self}):g})),[Jt(i,{children:{...i.children,[I]:x}}),{id:a,actorRef:x}]}function rv(n,{id:i,actorRef:r}){r&&n.defer(()=>{r._processingStatus!==Ne.Stopped&&r.start()})}function iv(...[n,{id:i,systemId:r,input:o,syncSnapshot:a=!1}={}]){function f(d,g){}return f.type="snapshot.spawnChild",f.id=i,f.systemId=r,f.src=n,f.input=o,f.syncSnapshot=a,f.resolve=nv,f.execute=rv,f}function sv(n,i,r,o,{actorRef:a}){const f=typeof a=="function"?a(r,o):a,d=typeof f=="string"?i.children[f]:f;let g=i.children;return d&&(g={...g},delete g[d.id]),[Jt(i,{children:g}),d]}function ov(n,i){if(i){if(n.system._unregister(i),i._processingStatus!==Ne.Running){n.stopChild(i);return}n.defer(()=>{n.stopChild(i)})}}function xc(n){function i(r,o){}return i.type="xstate.stopChild",i.actorRef=n,i.resolve=sv,i.execute=ov,i}function Zs(n,i,r,o){const{machine:a}=o,f=typeof n=="function",d=f?n:a.implementations.guards[typeof n=="string"?n:n.type];if(!f&&!d)throw new Error(`Guard '${typeof n=="string"?n:n.type}' is not implemented.'.`);if(typeof d!="function")return Zs(d,i,r,o);const g={context:i,event:r},m=f||typeof n=="string"?void 0:"params"in n?typeof n.params=="function"?n.params({context:i,event:r}):n.params:void 0;return"check"in d?d.check(o,g,d):d(g,m)}const eo=n=>n.type==="atomic"||n.type==="final";function En(n){return Object.values(n.states).filter(i=>i.type!=="history")}function er(n,i){const r=[];if(i===n)return r;let o=n.parent;for(;o&&o!==i;)r.push(o),o=o.parent;return r}function Zr(n){const i=new Set(n),r=Ac(i);for(const o of i)if(o.type==="compound"&&(!r.get(o)||!r.get(o).length))Ka(o).forEach(a=>i.add(a));else if(o.type==="parallel"){for(const a of En(o))if(a.type!=="history"&&!i.has(a)){const f=Ka(a);for(const d of f)i.add(d)}}for(const o of i){let a=o.parent;for(;a;)i.add(a),a=a.parent}return i}function wc(n,i){const r=i.get(n);if(!r)return{};if(n.type==="compound"){const a=r[0];if(a){if(eo(a))return a.key}else return{}}const o={};for(const a of r)o[a.key]=wc(a,i);return o}function Ac(n){const i=new Map;for(const r of n)i.has(r)||i.set(r,[]),r.parent&&(i.has(r.parent)||i.set(r.parent,[]),i.get(r.parent).push(r));return i}function Ic(n,i){const r=Zr(i);return wc(n,Ac(r))}function to(n,i){return i.type==="compound"?En(i).some(r=>r.type==="final"&&n.has(r)):i.type==="parallel"?En(i).every(r=>to(n,r)):i.type==="final"}const ii=n=>n[0]===$_;function uv(n,i){return n.transitions.get(i)||[...n.transitions.keys()].filter(o=>{if(o===W_)return!0;if(!o.endsWith(".*"))return!1;const a=o.split("."),f=i.split(".");for(let d=0;d<a.length;d++){const g=a[d],m=f[d];if(g==="*")return d===a.length-1;if(g!==m)return!1}return!0}).sort((o,a)=>a.length-o.length).flatMap(o=>n.transitions.get(o))}function av(n){const i=n.config.after;if(!i)return[];const r=(a,f)=>{const d=G_(a,n.id),g=d.type;return n.entry.push(kv(d,{id:g,delay:a})),n.exit.push(tv(g)),g};return Object.keys(i).flatMap((a,f)=>{const d=i[a],g=typeof d=="string"?{target:d}:d,m=Number.isNaN(+a)?a:+a,E=r(m);return kt(g).map(I=>({...I,event:E,delay:m}))}).map(a=>{const{delay:f}=a;return{...zt(n,a.event,a),delay:f}})}function zt(n,i,r){const o=Tc(r.target),a=r.reenter??!1,f=lv(n,o),d={...r,actions:kt(r.actions),guard:r.guard,target:f,source:n,reenter:a,eventType:i,toJSON:()=>({...d,source:`#${n.id}`,target:f?f.map(g=>`#${g.id}`):void 0})};return d}function cv(n){const i=new Map;if(n.config.on)for(const r of Object.keys(n.config.on)){if(r===pc)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const o=n.config.on[r];i.set(r,gn(o).map(a=>zt(n,r,a)))}if(n.config.onDone){const r=`xstate.done.state.${n.id}`;i.set(r,gn(n.config.onDone).map(o=>zt(n,r,o)))}for(const r of n.invoke){if(r.onDone){const o=`xstate.done.actor.${r.id}`;i.set(o,gn(r.onDone).map(a=>zt(n,o,a)))}if(r.onError){const o=`xstate.error.actor.${r.id}`;i.set(o,gn(r.onError).map(a=>zt(n,o,a)))}if(r.onSnapshot){const o=`xstate.snapshot.${r.id}`;i.set(o,gn(r.onSnapshot).map(a=>zt(n,o,a)))}}for(const r of n.after){let o=i.get(r.eventType);o||(o=[],i.set(r.eventType,o)),o.push(r)}return i}function fv(n,i){const r=typeof i=="string"?n.states[i]:i?n.states[i.target]:void 0;if(!r&&i)throw new Error(`Initial state node "${i}" not found on parent state node #${n.id}`);const o={source:n,actions:!i||typeof i=="string"?[]:kt(i.actions),eventType:null,reenter:!1,target:r?[r]:[],toJSON:()=>({...o,source:`#${n.id}`,target:r?[`#${r.id}`]:[]})};return o}function lv(n,i){if(i!==void 0)return i.map(r=>{if(typeof r!="string")return r;if(ii(r))return n.machine.getStateNodeById(r);const o=r[0]===dc;if(o&&!n.parent)return ei(n,r.slice(1));const a=o?n.key+r:r;if(n.parent)try{return ei(n.parent,a)}catch(f){throw new Error(`Invalid transition definition for state node '${n.id}':
2
- ${f.message}`)}else throw new Error(`Invalid target: "${r}" is not a valid target from the root node. Did you mean ".${r}"?`)})}function Sc(n){const i=Tc(n.config.target);return i?{target:i.map(r=>typeof r=="string"?ei(n.parent,r):r)}:n.parent.initial}function Yt(n){return n.type==="history"}function Ka(n){const i=Oc(n);for(const r of i)for(const o of er(r,n))i.add(o);return i}function Oc(n){const i=new Set;function r(o){if(!i.has(o)){if(i.add(o),o.type==="compound")r(o.initial.target[0]);else if(o.type==="parallel")for(const a of En(o))r(a)}}return r(n),i}function Tn(n,i){if(ii(i))return n.machine.getStateNodeById(i);if(!n.states)throw new Error(`Unable to retrieve child state '${i}' from '${n.id}'; no child states exist.`);const r=n.states[i];if(!r)throw new Error(`Child state '${i}' does not exist on '${n.id}'`);return r}function ei(n,i){if(typeof i=="string"&&ii(i))try{return n.machine.getStateNodeById(i)}catch{}const r=Ks(i).slice();let o=n;for(;r.length;){const a=r.shift();if(!a.length)break;o=Tn(o,a)}return o}function ti(n,i){if(typeof i=="string"){const a=n.states[i];if(!a)throw new Error(`State '${i}' does not exist on '${n.id}'`);return[n,a]}const r=Object.keys(i),o=r.map(a=>Tn(n,a)).filter(Boolean);return[n.machine.root,n].concat(o,r.reduce((a,f)=>{const d=Tn(n,f);if(!d)return a;const g=ti(d,i[f]);return a.concat(g)},[]))}function hv(n,i,r,o){const f=Tn(n,i).next(r,o);return!f||!f.length?n.next(r,o):f}function dv(n,i,r,o){const a=Object.keys(i),f=Tn(n,a[0]),d=no(f,i[a[0]],r,o);return!d||!d.length?n.next(r,o):d}function pv(n,i,r,o){const a=[];for(const f of Object.keys(i)){const d=i[f];if(!d)continue;const g=Tn(n,f),m=no(g,d,r,o);m&&a.push(...m)}return a.length?a:n.next(r,o)}function no(n,i,r,o){return typeof i=="string"?hv(n,i,r,o):Object.keys(i).length===1?dv(n,i,r,o):pv(n,i,r,o)}function gv(n){return Object.keys(n.states).map(i=>n.states[i]).filter(i=>i.type==="history")}function Pt(n,i){let r=n;for(;r.parent&&r.parent!==i;)r=r.parent;return r.parent===i}function _v(n,i){const r=new Set(n),o=new Set(i);for(const a of r)if(o.has(a))return!0;for(const a of o)if(r.has(a))return!0;return!1}function bc(n,i,r){const o=new Set;for(const a of n){let f=!1;const d=new Set;for(const g of o)if(_v($s([a],i,r),$s([g],i,r)))if(Pt(a.source,g.source))d.add(g);else{f=!0;break}if(!f){for(const g of d)o.delete(g);o.add(a)}}return Array.from(o)}function vv(n){const[i,...r]=n;for(const o of er(i,void 0))if(r.every(a=>Pt(a,o)))return o}function ro(n,i){if(!n.target)return[];const r=new Set;for(const o of n.target)if(Yt(o))if(i[o.id])for(const a of i[o.id])r.add(a);else for(const a of ro(Sc(o),i))r.add(a);else r.add(o);return[...r]}function Cc(n,i){const r=ro(n,i);if(!r)return;if(!n.reenter&&r.every(a=>a===n.source||Pt(a,n.source)))return n.source;const o=vv(r.concat(n.source));if(o)return o;if(!n.reenter)return n.source.machine.root}function $s(n,i,r){var a;const o=new Set;for(const f of n)if((a=f.target)!=null&&a.length){const d=Cc(f,r);f.reenter&&f.source===d&&o.add(d);for(const g of i)Pt(g,d)&&o.add(g)}return[...o]}function yv(n,i){if(n.length!==i.size)return!1;for(const r of n)if(!i.has(r))return!1;return!0}function Ws(n,i,r,o,a,f){if(!n.length)return i;const d=new Set(i._nodes);let g=i.historyValue;const m=bc(n,d,g);let E=i;a||([E,g]=xv(E,o,r,m,d,g,f)),E=xn(E,o,r,m.flatMap(x=>x.actions),f),E=Ev(E,o,r,m,d,f,g,a);const I=[...d];E.status==="done"&&(E=xn(E,o,r,I.sort((x,S)=>S.order-x.order).flatMap(x=>x.exit),f));try{return g===i.historyValue&&yv(i._nodes,d)?E:Jt(E,{_nodes:I,historyValue:g})}catch(x){throw x}}function mv(n,i,r,o,a){if(o.output===void 0)return;const f=Bs(a.id,a.output!==void 0&&a.parent?qs(a.output,n.context,i,r.self):void 0);return qs(o.output,n.context,f,r.self)}function Ev(n,i,r,o,a,f,d,g){let m=n;const E=new Set,I=new Set;Tv(o,d,I,E),g&&I.add(n.machine.root);const x=new Set;for(const S of[...E].sort((D,R)=>D.order-R.order)){a.add(S);const D=[];D.push(...S.entry);for(const R of S.invoke)D.push(iv(R.src,{...R,syncSnapshot:!!R.onSnapshot}));if(I.has(S)){const R=S.initial.actions;D.push(...R)}if(m=xn(m,i,r,D,f,S.invoke.map(R=>R.id)),S.type==="final"){const R=S.parent;let F=(R==null?void 0:R.type)==="parallel"?R:R==null?void 0:R.parent,H=F||S;for((R==null?void 0:R.type)==="compound"&&f.push(Bs(R.id,S.output!==void 0?qs(S.output,m.context,i,r.self):void 0));(F==null?void 0:F.type)==="parallel"&&!x.has(F)&&to(a,F);)x.add(F),f.push(Bs(F.id)),H=F,F=F.parent;if(F)continue;m=Jt(m,{status:"done",output:mv(m,i,r,m.machine.root,H)})}}return m}function Tv(n,i,r,o){for(const a of n){const f=Cc(a,i);for(const g of a.target||[])!Yt(g)&&(a.source!==g||a.source!==f||a.reenter)&&(o.add(g),r.add(g)),vn(g,i,r,o);const d=ro(a,i);for(const g of d){const m=er(g,f);(f==null?void 0:f.type)==="parallel"&&m.push(f),Rc(o,i,r,m,!a.source.parent&&a.reenter?void 0:f)}}}function vn(n,i,r,o){var a;if(Yt(n))if(i[n.id]){const f=i[n.id];for(const d of f)o.add(d),vn(d,i,r,o);for(const d of f)Ns(d,n.parent,o,i,r)}else{const f=Sc(n);for(const d of f.target)o.add(d),f===((a=n.parent)==null?void 0:a.initial)&&r.add(n.parent),vn(d,i,r,o);for(const d of f.target)Ns(d,n.parent,o,i,r)}else if(n.type==="compound"){const[f]=n.initial.target;Yt(f)||(o.add(f),r.add(f)),vn(f,i,r,o),Ns(f,n,o,i,r)}else if(n.type==="parallel")for(const f of En(n).filter(d=>!Yt(d)))[...o].some(d=>Pt(d,f))||(Yt(f)||(o.add(f),r.add(f)),vn(f,i,r,o))}function Rc(n,i,r,o,a){for(const f of o)if((!a||Pt(f,a))&&n.add(f),f.type==="parallel")for(const d of En(f).filter(g=>!Yt(g)))[...n].some(g=>Pt(g,d))||(n.add(d),vn(d,i,r,n))}function Ns(n,i,r,o,a){Rc(r,o,a,er(n,i))}function xv(n,i,r,o,a,f,d){let g=n;const m=$s(o,a,f);m.sort((I,x)=>x.order-I.order);let E;for(const I of m)for(const x of gv(I)){let S;x.history==="deep"?S=D=>eo(D)&&Pt(D,I):S=D=>D.parent===I,E??(E={...f}),E[x.id]=Array.from(a).filter(S)}for(const I of m)g=xn(g,i,r,[...I.exit,...I.invoke.map(x=>xc(x.id))],d),a.delete(I);return[g,E||f]}let Qa=!1;function Nc(n,i,r,o,a,f){const{machine:d}=n;let g=n;for(const m of o){let D=function(){r.system._sendInspectionEvent({type:"@xstate.action",actorRef:r.self,action:{type:typeof m=="string"?m:typeof m=="object"?m.type:m.name||"(anonymous)",params:S}});try{Qa=I,I(x,S)}finally{Qa=!1}};const E=typeof m=="function",I=E?m:d.implementations.actions[typeof m=="string"?m:m.type];if(!I)continue;const x={context:g.context,event:i,self:r.self,system:r.system},S=E||typeof m=="string"?void 0:"params"in m?typeof m.params=="function"?m.params({context:g.context,event:i}):m.params:void 0;if(!("resolve"in I)){r.self._processingStatus===Ne.Running?D():r.defer(()=>{D()});continue}const R=I,[F,H,ie]=R.resolve(r,g,x,S,I,a);g=F,"retryResolve"in R&&(f==null||f.push([R,H])),"execute"in R&&(r.self._processingStatus===Ne.Running?R.execute(r,H):r.defer(R.execute.bind(null,r,H))),ie&&(g=Nc(g,i,r,ie,a,f))}return g}function xn(n,i,r,o,a,f){const d=f?[]:void 0,g=Nc(n,i,r,o,{internalQueue:a,deferredActorIds:f},d);return d==null||d.forEach(([m,E])=>{m.retryResolve(r,g,E)}),g}function Ds(n,i,r,o=[]){let a=n;const f=[];function d(E,I,x){r.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:r.self,event:I,snapshot:E,_transitions:x}),f.push(E)}if(i.type===jn)return a=Jt(ja(a,i,r),{status:"stopped"}),d(a,i,[]),{snapshot:a,microstates:f};let g=i;if(g.type!==gc){const E=g,I=K_(E),x=Za(E,a);if(I&&!x.length)return a=Jt(n,{status:"error",error:E.error}),d(a,E,[]),{snapshot:a,microstates:f};a=Ws(x,n,r,g,!1,o),d(a,E,x)}let m=!0;for(;a.status==="active";){let E=m?wv(a,g):[];const I=E.length?a:void 0;if(!E.length){if(!o.length)break;g=o.shift(),E=Za(g,a)}a=Ws(E,a,r,g,!1,o),m=a!==I,d(a,g,E)}return a.status!=="active"&&ja(a,g,r),{snapshot:a,microstates:f}}function ja(n,i,r){return xn(n,i,r,Object.values(n.children).map(o=>xc(o)),[])}function Za(n,i){return i.machine.getTransitionData(i,n)}function wv(n,i){const r=new Set,o=n._nodes.filter(eo);for(const a of o)e:for(const f of[a].concat(er(a,void 0)))if(f.always){for(const d of f.always)if(d.guard===void 0||Zs(d.guard,n.context,i,n)){r.add(d);break e}}return bc(Array.from(r),new Set(n._nodes),n.historyValue)}function Av(n,i){const r=Zr(ti(n,i));return Ic(n,[...r])}function Iv(n){return!!n&&typeof n=="object"&&"machine"in n&&"value"in n}const Sv=function(i){return yc(i,this.value)},Ov=function(i){return this.tags.has(i)},bv=function(i){const r=this.machine.getTransitionData(this,i);return!!(r!=null&&r.length)&&r.some(o=>o.target!==void 0||o.actions.length)},Cv=function(){const{_nodes:i,tags:r,machine:o,getMeta:a,toJSON:f,can:d,hasTag:g,matches:m,...E}=this;return{...E,tags:Array.from(r)}},Rv=function(){return this._nodes.reduce((i,r)=>(r.meta!==void 0&&(i[r.id]=r.meta),i),{})};function Xr(n,i){return{status:n.status,output:n.output,error:n.error,machine:i,context:n.context,_nodes:n._nodes,value:Ic(i.root,n._nodes),tags:new Set(n._nodes.flatMap(r=>r.tags)),children:n.children,historyValue:n.historyValue||{},matches:Sv,hasTag:Ov,can:bv,getMeta:Rv,toJSON:Cv}}function Jt(n,i={}){return Xr({...n,...i},n.machine)}function Nv(n,i){const{_nodes:r,tags:o,machine:a,children:f,context:d,can:g,hasTag:m,matches:E,getMeta:I,toJSON:x,...S}=n,D={};for(const F in f){const H=f[F];D[F]={snapshot:H.getPersistedSnapshot(i),src:H.src,systemId:H._systemId,syncSnapshot:H._syncSnapshot}}return{...S,context:Dc(d),children:D}}function Dc(n){let i;for(const r in n){const o=n[r];if(o&&typeof o=="object")if("sessionId"in o&&"send"in o&&"ref"in o)i??(i=Array.isArray(n)?n.slice():{...n}),i[r]={xstate$$type:js,id:o.id};else{const a=Dc(o);a!==o&&(i??(i=Array.isArray(n)?n.slice():{...n}),i[r]=a)}}return i??n}function Dv(n,i,r,o,{event:a,id:f,delay:d},{internalQueue:g}){const m=i.machine.implementations.delays;if(typeof a=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${a}" }) instead`);const E=typeof a=="function"?a(r,o):a;let I;if(typeof d=="string"){const x=m&&m[d];I=typeof x=="function"?x(r,o):x}else I=typeof d=="function"?d(r,o):d;return typeof I!="number"&&g.push(E),[i,{event:E,id:f,delay:I}]}function Lv(n,i){const{event:r,delay:o,id:a}=i;if(typeof o=="number"){n.defer(()=>{const f=n.self;n.system.scheduler.schedule(f,f,r,o,a)});return}}function kv(n,i){function r(o,a){}return r.type="xstate.raise",r.event=n,r.id=i==null?void 0:i.id,r.delay=i==null?void 0:i.delay,r.resolve=Dv,r.execute=Lv,r}const ec=new WeakMap;function Mv(n){return{config:n,start:(r,o)=>{const{self:a,system:f}=o,d={receivers:void 0,dispose:void 0};ec.set(a,d),d.dispose=n({input:r.input,system:f,self:a,sendBack:g=>{a.getSnapshot().status!=="stopped"&&a._parent&&f._relay(a,a._parent,g)},receive:g=>{d.receivers??(d.receivers=new Set),d.receivers.add(g)}})},transition:(r,o,a)=>{var d,g;const f=ec.get(a.self);return o.type===jn?(r={...r,status:"stopped",error:void 0},(d=f.dispose)==null||d.call(f),r):((g=f.receivers)==null||g.forEach(m=>m(o)),r)},getInitialSnapshot:(r,o)=>({status:"active",output:void 0,error:void 0,input:o}),getPersistedSnapshot:r=>r,restoreSnapshot:r=>r}}const tc="xstate.promise.resolve",nc="xstate.promise.reject",Yr=new WeakMap;function mn(n){return{config:n,transition:(r,o,a)=>{var f;if(r.status!=="active")return r;switch(o.type){case tc:{const d=o.data;return{...r,status:"done",output:d,input:void 0}}case nc:return{...r,status:"error",error:o.data,input:void 0};case jn:return(f=Yr.get(a.self))==null||f.abort(),{...r,status:"stopped",input:void 0};default:return r}},start:(r,{self:o,system:a})=>{if(r.status!=="active")return;const f=new AbortController;Yr.set(o,f),Promise.resolve(n({input:r.input,system:a,self:o,signal:f.signal})).then(g=>{o.getSnapshot().status==="active"&&(Yr.delete(o),a._relay(o,o,{type:tc,data:g}))},g=>{o.getSnapshot().status==="active"&&(Yr.delete(o),a._relay(o,o,{type:nc,data:g}))})},getInitialSnapshot:(r,o)=>({status:"active",output:void 0,error:void 0,input:o}),getPersistedSnapshot:r=>r,restoreSnapshot:r=>r}}function Pv(n,{machine:i,context:r},o,a){const f=(d,g={})=>{const{systemId:m,input:E}=g;if(typeof d=="string"){const I=Qs(i,d);if(!I)throw new Error(`Actor logic '${d}' not implemented in machine '${i.id}'`);const x=Mt(I,{id:g.id,parent:n.self,syncSnapshot:g.syncSnapshot,input:typeof E=="function"?E({context:r,event:o,self:n.self}):E,src:d,systemId:m});return a[x.id]=x,x}else return Mt(d,{id:g.id,parent:n.self,syncSnapshot:g.syncSnapshot,input:g.input,src:d,systemId:m})};return(d,g)=>{const m=f(d,g);return a[m.id]=m,n.defer(()=>{m._processingStatus!==Ne.Stopped&&m.start()}),m}}function Fv(n,i,r,o,{assignment:a}){if(!i.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const f={},d={context:i.context,event:r.event,spawn:Pv(n,i,r.event,f),self:n.self,system:n.system};let g={};if(typeof a=="function")g=a(d,o);else for(const E of Object.keys(a)){const I=a[E];g[E]=typeof I=="function"?I(d,o):I}const m=Object.assign({},i.context,g);return[Jt(i,{context:m,children:Object.keys(f).length?{...i.children,...f}:i.children})]}function Ue(n){function i(r,o){}return i.type="xstate.assign",i.assignment=n,i.resolve=Fv,i}let rc=function(n){return n.Parent="#_parent",n.Internal="#_internal",n}({});function Uv(n,i,r,o,{to:a,event:f,id:d,delay:g},m){var R;const E=i.machine.implementations.delays;if(typeof f=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${f}" }) instead`);const I=typeof f=="function"?f(r,o):f;let x;if(typeof g=="string"){const F=E&&E[g];x=typeof F=="function"?F(r,o):F}else x=typeof g=="function"?g(r,o):g;const S=typeof a=="function"?a(r,o):a;let D;if(typeof S=="string"){if(S===rc.Parent?D=n.self._parent:S===rc.Internal?D=n.self:S.startsWith("#_")?D=i.children[S.slice(2)]:D=(R=m.deferredActorIds)!=null&&R.includes(S)?S:i.children[S],!D)throw new Error(`Unable to send event to actor '${S}' from machine '${i.machine.id}'.`)}else D=S||n.self;return[i,{to:D,event:I,id:d,delay:x}]}function Bv(n,i,r){typeof r.to=="string"&&(r.to=i.children[r.to])}function qv(n,i){n.defer(()=>{const{to:r,event:o,delay:a,id:f}=i;if(typeof a=="number"){n.system.scheduler.schedule(n.self,r,o,a,f);return}n.system._relay(n.self,r,o.type===H_?_c(n.self.id,o.data):o)})}function ic(n,i,r){function o(a,f){}return o.type="xsnapshot.sendTo",o.to=n,o.event=i,o.id=r==null?void 0:r.id,o.delay=r==null?void 0:r.delay,o.resolve=Uv,o.retryResolve=Bv,o.execute=qv,o}const sc=new WeakMap;function dn(n,i,r){let o=sc.get(n);return o?i in o||(o[i]=r()):(o={[i]:r()},sc.set(n,o)),o[i]}const $v={},Xn=n=>typeof n=="string"?{type:n}:typeof n=="function"?"resolve"in n?{type:n.type}:{type:n.name}:n;class io{constructor(i,r){if(this.config=i,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=r._parent,this.key=r._key,this.machine=r._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(dc),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?Ya(this.config.states,(o,a)=>new io(o,{_parent:this,_key:a,_machine:this.machine})):$v,this.type==="compound"&&!this.config.initial)throw new 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=this.config.history===!0?"shallow":this.config.history||!1,this.entry=kt(this.config.entry).slice(),this.exit=kt(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=kt(i.tags).slice()}_initialize(){this.transitions=cv(this),this.config.always&&(this.always=gn(this.config.always).map(i=>zt(this,pc,i))),Object.keys(this.states).forEach(i=>{this.states[i]._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(Xn),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(i=>`#${i.id}`),source:`#${this.id}`,actions:this.initial.actions.map(Xn),eventType:null})}:void 0,history:this.history,states:Ya(this.states,i=>i.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(i=>({...i,actions:i.actions.map(Xn)})),entry:this.entry.map(Xn),exit:this.exit.map(Xn),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 dn(this,"invoke",()=>kt(this.config.invoke).map((i,r)=>{const{src:o,systemId:a}=i,f=i.id??Xa(this.id,r),d=typeof o=="string"?o:`xstate.invoke.${Xa(this.id,r)}`;return{...i,src:d,id:f,systemId:a,toJSON(){const{onDone:g,onError:m,...E}=i;return{...E,type:"xstate.invoke",src:d,id:f}}}}))}get on(){return dn(this,"on",()=>[...this.transitions].flatMap(([r,o])=>o.map(a=>[r,a])).reduce((r,[o,a])=>(r[o]=r[o]||[],r[o].push(a),r),{}))}get after(){return dn(this,"delayedTransitions",()=>av(this))}get initial(){return dn(this,"initial",()=>fv(this,this.config.initial))}next(i,r){const o=r.type,a=[];let f;const d=dn(this,`candidates-${o}`,()=>uv(this,o));for(const g of d){const{guard:m}=g,E=i.context;let I=!1;try{I=!m||Zs(m,E,r,i)}catch(x){const S=typeof m=="string"?m:typeof m=="object"?m.type:void 0;throw new Error(`Unable to evaluate guard ${S?`'${S}' `:""}in transition for event '${o}' in state node '${this.id}':
3
- ${x.message}`)}if(I){a.push(...g.actions),f=g;break}}return f?[f]:void 0}get events(){return dn(this,"events",()=>{const{states:i}=this,r=new Set(this.ownEvents);if(i)for(const o of Object.keys(i)){const a=i[o];if(a.states)for(const f of a.events)r.add(`${f}`)}return Array.from(r)})}get ownEvents(){const i=new Set([...this.transitions.keys()].filter(r=>this.transitions.get(r).some(o=>!(!o.target&&!o.actions.length&&!o.reenter))));return Array.from(i)}}const Wv="#";class so{constructor(i,r){this.config=i,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.__TResolvedTypesMeta=void 0,this.id=i.id||"(machine)",this.implementations={actors:(r==null?void 0:r.actors)??{},actions:(r==null?void 0:r.actions)??{},delays:(r==null?void 0:r.delays)??{},guards:(r==null?void 0:r.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 io(i,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(i){const{actions:r,guards:o,actors:a,delays:f}=this.implementations;return new so(this.config,{actions:{...r,...i.actions},guards:{...o,...i.guards},actors:{...a,...i.actors},delays:{...f,...i.delays}})}resolveState(i){const r=Av(this.root,i.value),o=Zr(ti(this.root,r));return Xr({_nodes:[...o],context:i.context||{},children:{},status:to(o,this.root)?"done":i.status||"active",output:i.output,error:i.error,historyValue:i.historyValue},this)}transition(i,r,o){return Ds(i,r,o).snapshot}microstep(i,r,o){return Ds(i,r,o).microstates}getTransitionData(i,r){return no(this.root,i.value,i,r)||[]}getPreInitialState(i,r,o){const{context:a}=this.config,f=Xr({context:typeof a!="function"&&a?a:{},_nodes:[this.root],children:{},status:"active"},this);return typeof a=="function"?xn(f,r,i,[Ue(({spawn:g,event:m,self:E})=>a({spawn:g,input:m.input,self:E}))],o):f}getInitialSnapshot(i,r){const o=vc(r),a=[],f=this.getPreInitialState(i,o,a),d=Ws([{target:[...Oc(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],f,i,o,!0,a),{snapshot:g}=Ds(d,o,i,a);return g}start(i){Object.values(i.children).forEach(r=>{r.getSnapshot().status==="active"&&r.start()})}getStateNodeById(i){const r=Ks(i),o=r.slice(1),a=ii(r[0])?r[0].slice(Wv.length):r[0],f=this.idMap.get(a);if(!f)throw new Error(`Child state node '#${a}' does not exist on machine '${this.id}'`);return ei(f,o)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(i,r){return Nv(i,r)}restoreSnapshot(i,r){const o={},a=i.children;Object.keys(a).forEach(m=>{const E=a[m],I=E.snapshot,x=E.src,S=typeof x=="string"?Qs(this,x):x;if(!S)return;const D=Mt(S,{id:m,parent:r.self,syncSnapshot:E.syncSnapshot,snapshot:I,src:x,systemId:E.systemId});o[m]=D});const f=Xr({...i,children:o,_nodes:Array.from(Zr(ti(this.root,i.value)))},this);let d=new Set;function g(m,E){if(!d.has(m)){d.add(m);for(let I in m){const x=m[I];if(x&&typeof x=="object"){if("xstate$$type"in x&&x.xstate$$type===js){m[I]=E[x.id];continue}g(x,E)}}}}return g(f.context,o),f}}function Hv(n,i){return new so(n,i)}function si({schemas:n,actors:i,actions:r,guards:o,delays:a}){return{createMachine:f=>Hv({...f,schemas:n},{actors:i,actions:r,guards:o,delays:a})}}async function Ls(n,i){const r=await fetch(n,i);return r.status===200?r.json():Promise.resolve({message:r.statusText,success:!1})}const Hs=si({types:{context:{},events:{},input:{}},actions:{setUserContext:Ue(({context:n,event:i})=>{if(!i.type.includes("xstate.done.actor"))return n;const r=i;return r.output.type!=="AUTHENTICATE_SUCCESS"?n:{accessToken:r.output.accessToken,ignoreRefreshToken:!1}}),unsetUserContext:Ue(()=>({user:null,accessToken:"",refreshToken:"",ignoreRefreshToken:!1})),setAccessToken:Ue(({context:n,event:i})=>{if(!i.type.includes("xstate.done.actor"))return n;const r=i;return r.output.type!=="REFRESH_TOKEN_SUCCESS"?n:{accessToken:r.output.accessToken,ignoreRefreshToken:!1}}),unsetRefreshToken:Ue(()=>({refreshToken:""})),setIgnoreRefreshToken:Ue(()=>({ignoreRefreshToken:!0})),addError:Ue(({context:n,event:i})=>{if(!i.type.includes("xstate.error.actor"))return n;const r=i;return{errors:[...n.errors,String(r.error).replace("Error: ","")]}}),clearErrors:Ue(()=>({errors:[]}))},actors:{refreshAccessToken:mn(async({input:n})=>{let i;if(typeof window>"u"){if(n.context.refreshToken==="")throw new Error("Unauthorized.");try{const o=await Ls(n.context.endpoints.ssrRefresh,{method:"POST",mode:"cors",credentials:"include",headers:{Cookie:`refresh_token=${n.context.refreshToken}`,"Content-Type":"application/json","clicktap-scope":"view","clicktap-scope-id":"default"}});if(typeof o.accessToken>"u")throw new Error("Unauthorized.");return{type:"REFRESH_TOKEN_SUCCESS",accessToken:o.accessToken}}catch(r){throw console.log(r),new Error("Could not complete refresh request (server)")}}else{i=await Ls(n.context.endpoints.refresh,{method:"POST",mode:"cors",credentials:"include",headers:{"Content-Type":"application/json","clicktap-scope":"view","clicktap-scope-id":"default"},body:JSON.stringify({grant_type:"refresh_token"}).toString()});const r=i;if(typeof r.accessToken>"u")throw new Error("Unauthorized.");return{type:"REFRESH_TOKEN_SUCCESS",accessToken:r.accessToken}}}),authenticate:mn(async({input:n})=>{var o;const r=await Ls(n.context.endpoints.login,{method:"POST",mode:"cors",credentials:"include",headers:{"Content-Type":"application/json","clicktap-scope":"view","clicktap-scope-id":"default"},body:JSON.stringify({username:n.username,password:n.password}).toString()});if(!r.success)throw new Error(((o=r.message)==null?void 0:o.toString())??"Sign in failed. Please try again.");return{type:"AUTHENTICATE_SUCCESS",accessToken:r.accessToken}}),unauthenticate:mn(async({input:n})=>(await fetch(n.context.endpoints.logout,{method:"POST",mode:"cors",credentials:"include",headers:{"clicktap-scope":"view","clicktap-scope-id":"default"}}),{type:"UNAUTHENTICATE"}))}}).createMachine({id:"auth",context:({input:n})=>{var i,r;return{user:null,accessToken:"",refreshToken:((i=n==null?void 0:n.initialContext)==null?void 0:i.refreshToken)??"",ignoreRefreshToken:!1,endpoints:((r=n==null?void 0:n.initialContext)==null?void 0:r.endpoints)??{login:"",logout:"",refresh:"",ssrRefresh:""},errors:[]}},initial:"refreshing",states:{authenticating:{invoke:{src:"authenticate",input:({context:n,event:i})=>i.type!=="LOGIN"?{context:n,username:"",password:""}:{context:n,username:i.username,password:i.password},onDone:[{actions:"setUserContext",target:"loggedIn"}],onError:[{actions:"addError",target:"loggedOut"}]}},unauthenticating:{invoke:{src:"unauthenticate",input:({context:n})=>({context:n}),onDone:[{actions:"unsetUserContext",target:"loggedOut"}],onError:[{actions:["unsetUserContext","setIgnoreRefreshToken"],target:"loggedOut"}]}},refreshing:{invoke:{src:"refreshAccessToken",input:({context:n})=>({context:n}),onDone:[{actions:["unsetRefreshToken","setAccessToken"],target:"loggedIn"}],onError:[{actions:"unsetRefreshToken",target:"unauthenticating"}]}},loggedOut:{on:{LOGIN:{target:"authenticating"},CLEAR_ERRORS:{actions:"clearErrors"}}},loggedIn:{after:{84e4:{guard:()=>typeof window<"u",target:"refreshing"}},on:{LOGOUT:{target:"unauthenticating"},CLEAR_ERRORS:{actions:"clearErrors"}}}}}),oo=ct.createContext({}),Gv=()=>{const n=ct.useContext(oo),[i,r]=ct.useState(typeof window<"u"&&n.getSnapshot().value==="loggedIn");return ct.useEffect(()=>{if(typeof window>"u")return;const o=n.subscribe(a=>{(a.value==="loggedIn"||a.value==="loggedOut")&&r(a.value==="loggedIn")});return()=>{o.unsubscribe()}},[n]),{authActor:n,isLoggedIn:i}},Vv=async(n="",i={inspect:void 0,endpoints:{login:"",logout:"",refresh:"",ssrRefresh:""}})=>typeof window<"u"?(console.warn("App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."),Mt(Hs,{inspect:i.inspect,input:{initialContext:{endpoints:i.endpoints}}}).start()):Mt(Hs,{input:{initialContext:{endpoints:i.endpoints,refreshToken:n}},inspect:i.inspect}).start();function zv({actor:n,children:i}){return Xs.jsx(oo.Provider,{value:n,children:i})}let Yv=(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((i,r)=>(r&=63,r<36?i+=r.toString(36):r<62?i+=(r-26).toString(36).toUpperCase():r>62?i+="-":i+="_",i),"");const Lc=si({actors:{tick:Mv(({sendBack:n,input:i})=>{const r=setInterval(()=>{n({type:"TICK"})},i.interval);return()=>{clearInterval(r)}})},types:{context:{},events:{},input:{}}}).createMachine({id:"timer",initial:"running",context:({input:n})=>({elapsed:0,duration:n.initialContext.duration??3e3,interval:100,intervalId:null}),states:{paused:{on:{RESUME_TIMER:{target:"running",guard:({context:n})=>n.elapsed<n.duration}}},running:{invoke:{input:({context:n})=>({interval:n.interval}),src:"tick"},always:[{target:"completed",guard:({context:n})=>n.elapsed>=n.duration}],on:{TICK:{actions:Ue(({context:n,event:i})=>i.type!=="TICK"?n:{elapsed:n.elapsed+n.interval})},PAUSE_TIMER:{target:"paused"}}},completed:{type:"final"}}}),Jv=si({actors:{timer:Lc},types:{context:{},events:{},input:{}},actions:{addItem:Ue(({context:n,event:i})=>{if(i.type!=="ADD_ITEM")return n;const r=`notification-${Yv()}`,o=i.duration??n.duration,a=ct.cloneElement(i.item,{duration:o,id:r,key:i.item.key??r,...i.item.props}),f={duration:o,id:r,element:a},d=n.items;return n.order==="desc"?d.push(f):d.unshift(f),{items:d,activeItem:r}}),removeItem:Ue(({context:n,event:i})=>{if(i.type!=="REMOVE_ITEM"&&i.type!=="xstate.done.actor.timer")return n;const r=n.items;return n.order==="desc"?(r.pop(),{items:r,activeItem:r.length>0?r[r.length-1].id:null}):(r.shift(),{items:r,activeItem:r.length>0?r[0].id:null})})},delays:{ITEM_TIMEOUT:({context:n})=>n.items[n.items.length-1].duration??n.duration},guards:{itemHasTimeout:({context:n})=>n.items[n.items.length-1].duration>0||n.duration>0}}).createMachine({id:"toast",context:{items:[],order:"desc",duration:0,activeItem:null},initial:"idle",states:{idle:{on:{ADD_ITEM:{target:"adding"}}},active:{invoke:{id:"timer",src:"timer",input:({context:n})=>({initialContext:{duration:n.items[n.items.length-1].duration??n.duration}}),onDone:{target:"removing",guard:"itemHasTimeout"}},on:{ADD_ITEM:{target:"adding"},REMOVE_ITEM:{target:"removing"},SET_IDLE:{target:"idle"},RESUME_TIMER:{actions:ic("timer",{type:"RESUME_TIMER"})},PAUSE_TIMER:{actions:ic("timer",{type:"PAUSE_TIMER"})}}},adding:{entry:["addItem"],on:{SET_IDLE:{target:"idle"},SET_ACTIVE:{target:"active"}}},removing:{entry:"removeItem",on:{SET_IDLE:{target:"idle"},SET_ACTIVE:{target:"active"}}}}}),uo=ct.createContext({}),Xv=()=>ct.useContext(uo);function Kv({children:n,actor:i}){return Xs.jsx(uo.Provider,{value:i,children:n})}var _n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ni={exports:{}};/**
4
- * @license
5
- * Lodash <https://lodash.com/>
6
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
7
- * Released under MIT license <https://lodash.com/license>
8
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
9
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
10
- */ni.exports;(function(n,i){(function(){var r,o="4.17.21",a=200,f="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",d="Expected a function",g="Invalid `variable` option passed into `_.template`",m="__lodash_hash_undefined__",E=500,I="__lodash_placeholder__",x=1,S=2,D=4,R=1,F=2,H=1,ie=2,De=4,le=8,me=16,xe=32,tt=64,Le=128,Be=256,An=512,ai=30,ze="...",ci=800,In=16,w=1,L=2,Y=3,ce=1/0,oe=9007199254740991,ne=17976931348623157e292,dt=0/0,Ie=4294967295,Sn=Ie-1,Jc=Ie>>>1,Xc=[["ary",Le],["bind",H],["bindKey",ie],["curry",le],["curryRight",me],["flip",An],["partial",xe],["partialRight",tt],["rearg",Be]],Kt="[object Arguments]",tr="[object Array]",Kc="[object AsyncFunction]",On="[object Boolean]",bn="[object Date]",Qc="[object DOMException]",nr="[object Error]",rr="[object Function]",ho="[object GeneratorFunction]",nt="[object Map]",Cn="[object Number]",jc="[object Null]",pt="[object Object]",po="[object Promise]",Zc="[object Proxy]",Rn="[object RegExp]",rt="[object Set]",Nn="[object String]",ir="[object Symbol]",ef="[object Undefined]",Dn="[object WeakMap]",tf="[object WeakSet]",Ln="[object ArrayBuffer]",Qt="[object DataView]",fi="[object Float32Array]",li="[object Float64Array]",hi="[object Int8Array]",di="[object Int16Array]",pi="[object Int32Array]",gi="[object Uint8Array]",_i="[object Uint8ClampedArray]",vi="[object Uint16Array]",yi="[object Uint32Array]",nf=/\b__p \+= '';/g,rf=/\b(__p \+=) '' \+/g,sf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,go=/&(?:amp|lt|gt|quot|#39);/g,_o=/[&<>"']/g,of=RegExp(go.source),uf=RegExp(_o.source),af=/<%-([\s\S]+?)%>/g,cf=/<%([\s\S]+?)%>/g,vo=/<%=([\s\S]+?)%>/g,ff=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,lf=/^\w*$/,hf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,mi=/[\\^$.*+?()[\]{}|]/g,df=RegExp(mi.source),Ei=/^\s+/,pf=/\s/,gf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,_f=/\{\n\/\* \[wrapped with (.+)\] \*/,vf=/,? & /,yf=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,mf=/[()=,{}\[\]\/\s]/,Ef=/\\(\\)?/g,Tf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yo=/\w*$/,xf=/^[-+]0x[0-9a-f]+$/i,wf=/^0b[01]+$/i,Af=/^\[object .+?Constructor\]$/,If=/^0o[0-7]+$/i,Sf=/^(?:0|[1-9]\d*)$/,Of=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,sr=/($^)/,bf=/['\n\r\u2028\u2029\\]/g,or="\\ud800-\\udfff",Cf="\\u0300-\\u036f",Rf="\\ufe20-\\ufe2f",Nf="\\u20d0-\\u20ff",mo=Cf+Rf+Nf,Eo="\\u2700-\\u27bf",To="a-z\\xdf-\\xf6\\xf8-\\xff",Df="\\xac\\xb1\\xd7\\xf7",Lf="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",kf="\\u2000-\\u206f",Mf=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",xo="A-Z\\xc0-\\xd6\\xd8-\\xde",wo="\\ufe0e\\ufe0f",Ao=Df+Lf+kf+Mf,Ti="['’]",Pf="["+or+"]",Io="["+Ao+"]",ur="["+mo+"]",So="\\d+",Ff="["+Eo+"]",Oo="["+To+"]",bo="[^"+or+Ao+So+Eo+To+xo+"]",xi="\\ud83c[\\udffb-\\udfff]",Uf="(?:"+ur+"|"+xi+")",Co="[^"+or+"]",wi="(?:\\ud83c[\\udde6-\\uddff]){2}",Ai="[\\ud800-\\udbff][\\udc00-\\udfff]",jt="["+xo+"]",Ro="\\u200d",No="(?:"+Oo+"|"+bo+")",Bf="(?:"+jt+"|"+bo+")",Do="(?:"+Ti+"(?:d|ll|m|re|s|t|ve))?",Lo="(?:"+Ti+"(?:D|LL|M|RE|S|T|VE))?",ko=Uf+"?",Mo="["+wo+"]?",qf="(?:"+Ro+"(?:"+[Co,wi,Ai].join("|")+")"+Mo+ko+")*",$f="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Wf="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Po=Mo+ko+qf,Hf="(?:"+[Ff,wi,Ai].join("|")+")"+Po,Gf="(?:"+[Co+ur+"?",ur,wi,Ai,Pf].join("|")+")",Vf=RegExp(Ti,"g"),zf=RegExp(ur,"g"),Ii=RegExp(xi+"(?="+xi+")|"+Gf+Po,"g"),Yf=RegExp([jt+"?"+Oo+"+"+Do+"(?="+[Io,jt,"$"].join("|")+")",Bf+"+"+Lo+"(?="+[Io,jt+No,"$"].join("|")+")",jt+"?"+No+"+"+Do,jt+"+"+Lo,Wf,$f,So,Hf].join("|"),"g"),Jf=RegExp("["+Ro+or+mo+wo+"]"),Xf=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Kf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Qf=-1,ae={};ae[fi]=ae[li]=ae[hi]=ae[di]=ae[pi]=ae[gi]=ae[_i]=ae[vi]=ae[yi]=!0,ae[Kt]=ae[tr]=ae[Ln]=ae[On]=ae[Qt]=ae[bn]=ae[nr]=ae[rr]=ae[nt]=ae[Cn]=ae[pt]=ae[Rn]=ae[rt]=ae[Nn]=ae[Dn]=!1;var ue={};ue[Kt]=ue[tr]=ue[Ln]=ue[Qt]=ue[On]=ue[bn]=ue[fi]=ue[li]=ue[hi]=ue[di]=ue[pi]=ue[nt]=ue[Cn]=ue[pt]=ue[Rn]=ue[rt]=ue[Nn]=ue[ir]=ue[gi]=ue[_i]=ue[vi]=ue[yi]=!0,ue[nr]=ue[rr]=ue[Dn]=!1;var jf={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Zf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},el={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},tl={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},nl=parseFloat,rl=parseInt,Fo=typeof _n=="object"&&_n&&_n.Object===Object&&_n,il=typeof self=="object"&&self&&self.Object===Object&&self,we=Fo||il||Function("return this")(),Si=i&&!i.nodeType&&i,Ft=Si&&!0&&n&&!n.nodeType&&n,Uo=Ft&&Ft.exports===Si,Oi=Uo&&Fo.process,Ye=function(){try{var v=Ft&&Ft.require&&Ft.require("util").types;return v||Oi&&Oi.binding&&Oi.binding("util")}catch{}}(),Bo=Ye&&Ye.isArrayBuffer,qo=Ye&&Ye.isDate,$o=Ye&&Ye.isMap,Wo=Ye&&Ye.isRegExp,Ho=Ye&&Ye.isSet,Go=Ye&&Ye.isTypedArray;function qe(v,A,T){switch(T.length){case 0:return v.call(A);case 1:return v.call(A,T[0]);case 2:return v.call(A,T[0],T[1]);case 3:return v.call(A,T[0],T[1],T[2])}return v.apply(A,T)}function sl(v,A,T,M){for(var G=-1,ee=v==null?0:v.length;++G<ee;){var ve=v[G];A(M,ve,T(ve),v)}return M}function Je(v,A){for(var T=-1,M=v==null?0:v.length;++T<M&&A(v[T],T,v)!==!1;);return v}function ol(v,A){for(var T=v==null?0:v.length;T--&&A(v[T],T,v)!==!1;);return v}function Vo(v,A){for(var T=-1,M=v==null?0:v.length;++T<M;)if(!A(v[T],T,v))return!1;return!0}function It(v,A){for(var T=-1,M=v==null?0:v.length,G=0,ee=[];++T<M;){var ve=v[T];A(ve,T,v)&&(ee[G++]=ve)}return ee}function ar(v,A){var T=v==null?0:v.length;return!!T&&Zt(v,A,0)>-1}function bi(v,A,T){for(var M=-1,G=v==null?0:v.length;++M<G;)if(T(A,v[M]))return!0;return!1}function fe(v,A){for(var T=-1,M=v==null?0:v.length,G=Array(M);++T<M;)G[T]=A(v[T],T,v);return G}function St(v,A){for(var T=-1,M=A.length,G=v.length;++T<M;)v[G+T]=A[T];return v}function Ci(v,A,T,M){var G=-1,ee=v==null?0:v.length;for(M&&ee&&(T=v[++G]);++G<ee;)T=A(T,v[G],G,v);return T}function ul(v,A,T,M){var G=v==null?0:v.length;for(M&&G&&(T=v[--G]);G--;)T=A(T,v[G],G,v);return T}function Ri(v,A){for(var T=-1,M=v==null?0:v.length;++T<M;)if(A(v[T],T,v))return!0;return!1}var al=Ni("length");function cl(v){return v.split("")}function fl(v){return v.match(yf)||[]}function zo(v,A,T){var M;return T(v,function(G,ee,ve){if(A(G,ee,ve))return M=ee,!1}),M}function cr(v,A,T,M){for(var G=v.length,ee=T+(M?1:-1);M?ee--:++ee<G;)if(A(v[ee],ee,v))return ee;return-1}function Zt(v,A,T){return A===A?xl(v,A,T):cr(v,Yo,T)}function ll(v,A,T,M){for(var G=T-1,ee=v.length;++G<ee;)if(M(v[G],A))return G;return-1}function Yo(v){return v!==v}function Jo(v,A){var T=v==null?0:v.length;return T?Li(v,A)/T:dt}function Ni(v){return function(A){return A==null?r:A[v]}}function Di(v){return function(A){return v==null?r:v[A]}}function Xo(v,A,T,M,G){return G(v,function(ee,ve,se){T=M?(M=!1,ee):A(T,ee,ve,se)}),T}function hl(v,A){var T=v.length;for(v.sort(A);T--;)v[T]=v[T].value;return v}function Li(v,A){for(var T,M=-1,G=v.length;++M<G;){var ee=A(v[M]);ee!==r&&(T=T===r?ee:T+ee)}return T}function ki(v,A){for(var T=-1,M=Array(v);++T<v;)M[T]=A(T);return M}function dl(v,A){return fe(A,function(T){return[T,v[T]]})}function Ko(v){return v&&v.slice(0,eu(v)+1).replace(Ei,"")}function $e(v){return function(A){return v(A)}}function Mi(v,A){return fe(A,function(T){return v[T]})}function kn(v,A){return v.has(A)}function Qo(v,A){for(var T=-1,M=v.length;++T<M&&Zt(A,v[T],0)>-1;);return T}function jo(v,A){for(var T=v.length;T--&&Zt(A,v[T],0)>-1;);return T}function pl(v,A){for(var T=v.length,M=0;T--;)v[T]===A&&++M;return M}var gl=Di(jf),_l=Di(Zf);function vl(v){return"\\"+tl[v]}function yl(v,A){return v==null?r:v[A]}function en(v){return Jf.test(v)}function ml(v){return Xf.test(v)}function El(v){for(var A,T=[];!(A=v.next()).done;)T.push(A.value);return T}function Pi(v){var A=-1,T=Array(v.size);return v.forEach(function(M,G){T[++A]=[G,M]}),T}function Zo(v,A){return function(T){return v(A(T))}}function Ot(v,A){for(var T=-1,M=v.length,G=0,ee=[];++T<M;){var ve=v[T];(ve===A||ve===I)&&(v[T]=I,ee[G++]=T)}return ee}function fr(v){var A=-1,T=Array(v.size);return v.forEach(function(M){T[++A]=M}),T}function Tl(v){var A=-1,T=Array(v.size);return v.forEach(function(M){T[++A]=[M,M]}),T}function xl(v,A,T){for(var M=T-1,G=v.length;++M<G;)if(v[M]===A)return M;return-1}function wl(v,A,T){for(var M=T+1;M--;)if(v[M]===A)return M;return M}function tn(v){return en(v)?Il(v):al(v)}function it(v){return en(v)?Sl(v):cl(v)}function eu(v){for(var A=v.length;A--&&pf.test(v.charAt(A)););return A}var Al=Di(el);function Il(v){for(var A=Ii.lastIndex=0;Ii.test(v);)++A;return A}function Sl(v){return v.match(Ii)||[]}function Ol(v){return v.match(Yf)||[]}var bl=function v(A){A=A==null?we:nn.defaults(we.Object(),A,nn.pick(we,Kf));var T=A.Array,M=A.Date,G=A.Error,ee=A.Function,ve=A.Math,se=A.Object,Fi=A.RegExp,Cl=A.String,Xe=A.TypeError,lr=T.prototype,Rl=ee.prototype,rn=se.prototype,hr=A["__core-js_shared__"],dr=Rl.toString,re=rn.hasOwnProperty,Nl=0,tu=function(){var e=/[^.]+$/.exec(hr&&hr.keys&&hr.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),pr=rn.toString,Dl=dr.call(se),Ll=we._,kl=Fi("^"+dr.call(re).replace(mi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),gr=Uo?A.Buffer:r,bt=A.Symbol,_r=A.Uint8Array,nu=gr?gr.allocUnsafe:r,vr=Zo(se.getPrototypeOf,se),ru=se.create,iu=rn.propertyIsEnumerable,yr=lr.splice,su=bt?bt.isConcatSpreadable:r,Mn=bt?bt.iterator:r,Ut=bt?bt.toStringTag:r,mr=function(){try{var e=Ht(se,"defineProperty");return e({},"",{}),e}catch{}}(),Ml=A.clearTimeout!==we.clearTimeout&&A.clearTimeout,Pl=M&&M.now!==we.Date.now&&M.now,Fl=A.setTimeout!==we.setTimeout&&A.setTimeout,Er=ve.ceil,Tr=ve.floor,Ui=se.getOwnPropertySymbols,Ul=gr?gr.isBuffer:r,ou=A.isFinite,Bl=lr.join,ql=Zo(se.keys,se),ye=ve.max,Se=ve.min,$l=M.now,Wl=A.parseInt,uu=ve.random,Hl=lr.reverse,Bi=Ht(A,"DataView"),Pn=Ht(A,"Map"),qi=Ht(A,"Promise"),sn=Ht(A,"Set"),Fn=Ht(A,"WeakMap"),Un=Ht(se,"create"),xr=Fn&&new Fn,on={},Gl=Gt(Bi),Vl=Gt(Pn),zl=Gt(qi),Yl=Gt(sn),Jl=Gt(Fn),wr=bt?bt.prototype:r,Bn=wr?wr.valueOf:r,au=wr?wr.toString:r;function l(e){if(de(e)&&!V(e)&&!(e instanceof Q)){if(e instanceof Ke)return e;if(re.call(e,"__wrapped__"))return ca(e)}return new Ke(e)}var un=function(){function e(){}return function(t){if(!he(t))return{};if(ru)return ru(t);e.prototype=t;var s=new e;return e.prototype=r,s}}();function Ar(){}function Ke(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}l.templateSettings={escape:af,evaluate:cf,interpolate:vo,variable:"",imports:{_:l}},l.prototype=Ar.prototype,l.prototype.constructor=l,Ke.prototype=un(Ar.prototype),Ke.prototype.constructor=Ke;function Q(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ie,this.__views__=[]}function Xl(){var e=new Q(this.__wrapped__);return e.__actions__=ke(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=ke(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=ke(this.__views__),e}function Kl(){if(this.__filtered__){var e=new Q(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Ql(){var e=this.__wrapped__.value(),t=this.__dir__,s=V(e),u=t<0,c=s?e.length:0,h=cd(0,c,this.__views__),p=h.start,_=h.end,y=_-p,O=u?_:p-1,b=this.__iteratees__,N=b.length,k=0,U=Se(y,this.__takeCount__);if(!s||!u&&c==y&&U==y)return Du(e,this.__actions__);var q=[];e:for(;y--&&k<U;){O+=t;for(var J=-1,$=e[O];++J<N;){var K=b[J],Z=K.iteratee,Ge=K.type,Re=Z($);if(Ge==L)$=Re;else if(!Re){if(Ge==w)continue e;break e}}q[k++]=$}return q}Q.prototype=un(Ar.prototype),Q.prototype.constructor=Q;function Bt(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var u=e[t];this.set(u[0],u[1])}}function jl(){this.__data__=Un?Un(null):{},this.size=0}function Zl(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function eh(e){var t=this.__data__;if(Un){var s=t[e];return s===m?r:s}return re.call(t,e)?t[e]:r}function th(e){var t=this.__data__;return Un?t[e]!==r:re.call(t,e)}function nh(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=Un&&t===r?m:t,this}Bt.prototype.clear=jl,Bt.prototype.delete=Zl,Bt.prototype.get=eh,Bt.prototype.has=th,Bt.prototype.set=nh;function gt(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var u=e[t];this.set(u[0],u[1])}}function rh(){this.__data__=[],this.size=0}function ih(e){var t=this.__data__,s=Ir(t,e);if(s<0)return!1;var u=t.length-1;return s==u?t.pop():yr.call(t,s,1),--this.size,!0}function sh(e){var t=this.__data__,s=Ir(t,e);return s<0?r:t[s][1]}function oh(e){return Ir(this.__data__,e)>-1}function uh(e,t){var s=this.__data__,u=Ir(s,e);return u<0?(++this.size,s.push([e,t])):s[u][1]=t,this}gt.prototype.clear=rh,gt.prototype.delete=ih,gt.prototype.get=sh,gt.prototype.has=oh,gt.prototype.set=uh;function _t(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t<s;){var u=e[t];this.set(u[0],u[1])}}function ah(){this.size=0,this.__data__={hash:new Bt,map:new(Pn||gt),string:new Bt}}function ch(e){var t=Fr(this,e).delete(e);return this.size-=t?1:0,t}function fh(e){return Fr(this,e).get(e)}function lh(e){return Fr(this,e).has(e)}function hh(e,t){var s=Fr(this,e),u=s.size;return s.set(e,t),this.size+=s.size==u?0:1,this}_t.prototype.clear=ah,_t.prototype.delete=ch,_t.prototype.get=fh,_t.prototype.has=lh,_t.prototype.set=hh;function qt(e){var t=-1,s=e==null?0:e.length;for(this.__data__=new _t;++t<s;)this.add(e[t])}function dh(e){return this.__data__.set(e,m),this}function ph(e){return this.__data__.has(e)}qt.prototype.add=qt.prototype.push=dh,qt.prototype.has=ph;function st(e){var t=this.__data__=new gt(e);this.size=t.size}function gh(){this.__data__=new gt,this.size=0}function _h(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s}function vh(e){return this.__data__.get(e)}function yh(e){return this.__data__.has(e)}function mh(e,t){var s=this.__data__;if(s instanceof gt){var u=s.__data__;if(!Pn||u.length<a-1)return u.push([e,t]),this.size=++s.size,this;s=this.__data__=new _t(u)}return s.set(e,t),this.size=s.size,this}st.prototype.clear=gh,st.prototype.delete=_h,st.prototype.get=vh,st.prototype.has=yh,st.prototype.set=mh;function cu(e,t){var s=V(e),u=!s&&Vt(e),c=!s&&!u&&Lt(e),h=!s&&!u&&!c&&ln(e),p=s||u||c||h,_=p?ki(e.length,Cl):[],y=_.length;for(var O in e)(t||re.call(e,O))&&!(p&&(O=="length"||c&&(O=="offset"||O=="parent")||h&&(O=="buffer"||O=="byteLength"||O=="byteOffset")||Et(O,y)))&&_.push(O);return _}function fu(e){var t=e.length;return t?e[Qi(0,t-1)]:r}function Eh(e,t){return Ur(ke(e),$t(t,0,e.length))}function Th(e){return Ur(ke(e))}function $i(e,t,s){(s!==r&&!ot(e[t],s)||s===r&&!(t in e))&&vt(e,t,s)}function qn(e,t,s){var u=e[t];(!(re.call(e,t)&&ot(u,s))||s===r&&!(t in e))&&vt(e,t,s)}function Ir(e,t){for(var s=e.length;s--;)if(ot(e[s][0],t))return s;return-1}function xh(e,t,s,u){return Ct(e,function(c,h,p){t(u,c,s(c),p)}),u}function lu(e,t){return e&&lt(t,Ee(t),e)}function wh(e,t){return e&&lt(t,Pe(t),e)}function vt(e,t,s){t=="__proto__"&&mr?mr(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s}function Wi(e,t){for(var s=-1,u=t.length,c=T(u),h=e==null;++s<u;)c[s]=h?r:xs(e,t[s]);return c}function $t(e,t,s){return e===e&&(s!==r&&(e=e<=s?e:s),t!==r&&(e=e>=t?e:t)),e}function Qe(e,t,s,u,c,h){var p,_=t&x,y=t&S,O=t&D;if(s&&(p=c?s(e,u,c,h):s(e)),p!==r)return p;if(!he(e))return e;var b=V(e);if(b){if(p=ld(e),!_)return ke(e,p)}else{var N=Oe(e),k=N==rr||N==ho;if(Lt(e))return Mu(e,_);if(N==pt||N==Kt||k&&!c){if(p=y||k?{}:ea(e),!_)return y?ed(e,wh(p,e)):Zh(e,lu(p,e))}else{if(!ue[N])return c?e:{};p=hd(e,N,_)}}h||(h=new st);var U=h.get(e);if(U)return U;h.set(e,p),Ca(e)?e.forEach(function($){p.add(Qe($,t,s,$,e,h))}):Oa(e)&&e.forEach(function($,K){p.set(K,Qe($,t,s,K,e,h))});var q=O?y?as:us:y?Pe:Ee,J=b?r:q(e);return Je(J||e,function($,K){J&&(K=$,$=e[K]),qn(p,K,Qe($,t,s,K,e,h))}),p}function Ah(e){var t=Ee(e);return function(s){return hu(s,e,t)}}function hu(e,t,s){var u=s.length;if(e==null)return!u;for(e=se(e);u--;){var c=s[u],h=t[c],p=e[c];if(p===r&&!(c in e)||!h(p))return!1}return!0}function du(e,t,s){if(typeof e!="function")throw new Xe(d);return Yn(function(){e.apply(r,s)},t)}function $n(e,t,s,u){var c=-1,h=ar,p=!0,_=e.length,y=[],O=t.length;if(!_)return y;s&&(t=fe(t,$e(s))),u?(h=bi,p=!1):t.length>=a&&(h=kn,p=!1,t=new qt(t));e:for(;++c<_;){var b=e[c],N=s==null?b:s(b);if(b=u||b!==0?b:0,p&&N===N){for(var k=O;k--;)if(t[k]===N)continue e;y.push(b)}else h(t,N,u)||y.push(b)}return y}var Ct=qu(ft),pu=qu(Gi,!0);function Ih(e,t){var s=!0;return Ct(e,function(u,c,h){return s=!!t(u,c,h),s}),s}function Sr(e,t,s){for(var u=-1,c=e.length;++u<c;){var h=e[u],p=t(h);if(p!=null&&(_===r?p===p&&!He(p):s(p,_)))var _=p,y=h}return y}function Sh(e,t,s,u){var c=e.length;for(s=z(s),s<0&&(s=-s>c?0:c+s),u=u===r||u>c?c:z(u),u<0&&(u+=c),u=s>u?0:Na(u);s<u;)e[s++]=t;return e}function gu(e,t){var s=[];return Ct(e,function(u,c,h){t(u,c,h)&&s.push(u)}),s}function Ae(e,t,s,u,c){var h=-1,p=e.length;for(s||(s=pd),c||(c=[]);++h<p;){var _=e[h];t>0&&s(_)?t>1?Ae(_,t-1,s,u,c):St(c,_):u||(c[c.length]=_)}return c}var Hi=$u(),_u=$u(!0);function ft(e,t){return e&&Hi(e,t,Ee)}function Gi(e,t){return e&&_u(e,t,Ee)}function Or(e,t){return It(t,function(s){return Tt(e[s])})}function Wt(e,t){t=Nt(t,e);for(var s=0,u=t.length;e!=null&&s<u;)e=e[ht(t[s++])];return s&&s==u?e:r}function vu(e,t,s){var u=t(e);return V(e)?u:St(u,s(e))}function be(e){return e==null?e===r?ef:jc:Ut&&Ut in se(e)?ad(e):Td(e)}function Vi(e,t){return e>t}function Oh(e,t){return e!=null&&re.call(e,t)}function bh(e,t){return e!=null&&t in se(e)}function Ch(e,t,s){return e>=Se(t,s)&&e<ye(t,s)}function zi(e,t,s){for(var u=s?bi:ar,c=e[0].length,h=e.length,p=h,_=T(h),y=1/0,O=[];p--;){var b=e[p];p&&t&&(b=fe(b,$e(t))),y=Se(b.length,y),_[p]=!s&&(t||c>=120&&b.length>=120)?new qt(p&&b):r}b=e[0];var N=-1,k=_[0];e:for(;++N<c&&O.length<y;){var U=b[N],q=t?t(U):U;if(U=s||U!==0?U:0,!(k?kn(k,q):u(O,q,s))){for(p=h;--p;){var J=_[p];if(!(J?kn(J,q):u(e[p],q,s)))continue e}k&&k.push(q),O.push(U)}}return O}function Rh(e,t,s,u){return ft(e,function(c,h,p){t(u,s(c),h,p)}),u}function Wn(e,t,s){t=Nt(t,e),e=ia(e,t);var u=e==null?e:e[ht(Ze(t))];return u==null?r:qe(u,e,s)}function yu(e){return de(e)&&be(e)==Kt}function Nh(e){return de(e)&&be(e)==Ln}function Dh(e){return de(e)&&be(e)==bn}function Hn(e,t,s,u,c){return e===t?!0:e==null||t==null||!de(e)&&!de(t)?e!==e&&t!==t:Lh(e,t,s,u,Hn,c)}function Lh(e,t,s,u,c,h){var p=V(e),_=V(t),y=p?tr:Oe(e),O=_?tr:Oe(t);y=y==Kt?pt:y,O=O==Kt?pt:O;var b=y==pt,N=O==pt,k=y==O;if(k&&Lt(e)){if(!Lt(t))return!1;p=!0,b=!1}if(k&&!b)return h||(h=new st),p||ln(e)?Qu(e,t,s,u,c,h):od(e,t,y,s,u,c,h);if(!(s&R)){var U=b&&re.call(e,"__wrapped__"),q=N&&re.call(t,"__wrapped__");if(U||q){var J=U?e.value():e,$=q?t.value():t;return h||(h=new st),c(J,$,s,u,h)}}return k?(h||(h=new st),ud(e,t,s,u,c,h)):!1}function kh(e){return de(e)&&Oe(e)==nt}function Yi(e,t,s,u){var c=s.length,h=c,p=!u;if(e==null)return!h;for(e=se(e);c--;){var _=s[c];if(p&&_[2]?_[1]!==e[_[0]]:!(_[0]in e))return!1}for(;++c<h;){_=s[c];var y=_[0],O=e[y],b=_[1];if(p&&_[2]){if(O===r&&!(y in e))return!1}else{var N=new st;if(u)var k=u(O,b,y,e,t,N);if(!(k===r?Hn(b,O,R|F,u,N):k))return!1}}return!0}function mu(e){if(!he(e)||_d(e))return!1;var t=Tt(e)?kl:Af;return t.test(Gt(e))}function Mh(e){return de(e)&&be(e)==Rn}function Ph(e){return de(e)&&Oe(e)==rt}function Fh(e){return de(e)&&Gr(e.length)&&!!ae[be(e)]}function Eu(e){return typeof e=="function"?e:e==null?Fe:typeof e=="object"?V(e)?wu(e[0],e[1]):xu(e):Wa(e)}function Ji(e){if(!zn(e))return ql(e);var t=[];for(var s in se(e))re.call(e,s)&&s!="constructor"&&t.push(s);return t}function Uh(e){if(!he(e))return Ed(e);var t=zn(e),s=[];for(var u in e)u=="constructor"&&(t||!re.call(e,u))||s.push(u);return s}function Xi(e,t){return e<t}function Tu(e,t){var s=-1,u=Me(e)?T(e.length):[];return Ct(e,function(c,h,p){u[++s]=t(c,h,p)}),u}function xu(e){var t=fs(e);return t.length==1&&t[0][2]?na(t[0][0],t[0][1]):function(s){return s===e||Yi(s,e,t)}}function wu(e,t){return hs(e)&&ta(t)?na(ht(e),t):function(s){var u=xs(s,e);return u===r&&u===t?ws(s,e):Hn(t,u,R|F)}}function br(e,t,s,u,c){e!==t&&Hi(t,function(h,p){if(c||(c=new st),he(h))Bh(e,t,p,s,br,u,c);else{var _=u?u(ps(e,p),h,p+"",e,t,c):r;_===r&&(_=h),$i(e,p,_)}},Pe)}function Bh(e,t,s,u,c,h,p){var _=ps(e,s),y=ps(t,s),O=p.get(y);if(O){$i(e,s,O);return}var b=h?h(_,y,s+"",e,t,p):r,N=b===r;if(N){var k=V(y),U=!k&&Lt(y),q=!k&&!U&&ln(y);b=y,k||U||q?V(_)?b=_:pe(_)?b=ke(_):U?(N=!1,b=Mu(y,!0)):q?(N=!1,b=Pu(y,!0)):b=[]:Jn(y)||Vt(y)?(b=_,Vt(_)?b=Da(_):(!he(_)||Tt(_))&&(b=ea(y))):N=!1}N&&(p.set(y,b),c(b,y,u,h,p),p.delete(y)),$i(e,s,b)}function Au(e,t){var s=e.length;if(s)return t+=t<0?s:0,Et(t,s)?e[t]:r}function Iu(e,t,s){t.length?t=fe(t,function(h){return V(h)?function(p){return Wt(p,h.length===1?h[0]:h)}:h}):t=[Fe];var u=-1;t=fe(t,$e(B()));var c=Tu(e,function(h,p,_){var y=fe(t,function(O){return O(h)});return{criteria:y,index:++u,value:h}});return hl(c,function(h,p){return jh(h,p,s)})}function qh(e,t){return Su(e,t,function(s,u){return ws(e,u)})}function Su(e,t,s){for(var u=-1,c=t.length,h={};++u<c;){var p=t[u],_=Wt(e,p);s(_,p)&&Gn(h,Nt(p,e),_)}return h}function $h(e){return function(t){return Wt(t,e)}}function Ki(e,t,s,u){var c=u?ll:Zt,h=-1,p=t.length,_=e;for(e===t&&(t=ke(t)),s&&(_=fe(e,$e(s)));++h<p;)for(var y=0,O=t[h],b=s?s(O):O;(y=c(_,b,y,u))>-1;)_!==e&&yr.call(_,y,1),yr.call(e,y,1);return e}function Ou(e,t){for(var s=e?t.length:0,u=s-1;s--;){var c=t[s];if(s==u||c!==h){var h=c;Et(c)?yr.call(e,c,1):es(e,c)}}return e}function Qi(e,t){return e+Tr(uu()*(t-e+1))}function Wh(e,t,s,u){for(var c=-1,h=ye(Er((t-e)/(s||1)),0),p=T(h);h--;)p[u?h:++c]=e,e+=s;return p}function ji(e,t){var s="";if(!e||t<1||t>oe)return s;do t%2&&(s+=e),t=Tr(t/2),t&&(e+=e);while(t);return s}function X(e,t){return gs(ra(e,t,Fe),e+"")}function Hh(e){return fu(hn(e))}function Gh(e,t){var s=hn(e);return Ur(s,$t(t,0,s.length))}function Gn(e,t,s,u){if(!he(e))return e;t=Nt(t,e);for(var c=-1,h=t.length,p=h-1,_=e;_!=null&&++c<h;){var y=ht(t[c]),O=s;if(y==="__proto__"||y==="constructor"||y==="prototype")return e;if(c!=p){var b=_[y];O=u?u(b,y,_):r,O===r&&(O=he(b)?b:Et(t[c+1])?[]:{})}qn(_,y,O),_=_[y]}return e}var bu=xr?function(e,t){return xr.set(e,t),e}:Fe,Vh=mr?function(e,t){return mr(e,"toString",{configurable:!0,enumerable:!1,value:Is(t),writable:!0})}:Fe;function zh(e){return Ur(hn(e))}function je(e,t,s){var u=-1,c=e.length;t<0&&(t=-t>c?0:c+t),s=s>c?c:s,s<0&&(s+=c),c=t>s?0:s-t>>>0,t>>>=0;for(var h=T(c);++u<c;)h[u]=e[u+t];return h}function Yh(e,t){var s;return Ct(e,function(u,c,h){return s=t(u,c,h),!s}),!!s}function Cr(e,t,s){var u=0,c=e==null?u:e.length;if(typeof t=="number"&&t===t&&c<=Jc){for(;u<c;){var h=u+c>>>1,p=e[h];p!==null&&!He(p)&&(s?p<=t:p<t)?u=h+1:c=h}return c}return Zi(e,t,Fe,s)}function Zi(e,t,s,u){var c=0,h=e==null?0:e.length;if(h===0)return 0;t=s(t);for(var p=t!==t,_=t===null,y=He(t),O=t===r;c<h;){var b=Tr((c+h)/2),N=s(e[b]),k=N!==r,U=N===null,q=N===N,J=He(N);if(p)var $=u||q;else O?$=q&&(u||k):_?$=q&&k&&(u||!U):y?$=q&&k&&!U&&(u||!J):U||J?$=!1:$=u?N<=t:N<t;$?c=b+1:h=b}return Se(h,Sn)}function Cu(e,t){for(var s=-1,u=e.length,c=0,h=[];++s<u;){var p=e[s],_=t?t(p):p;if(!s||!ot(_,y)){var y=_;h[c++]=p===0?0:p}}return h}function Ru(e){return typeof e=="number"?e:He(e)?dt:+e}function We(e){if(typeof e=="string")return e;if(V(e))return fe(e,We)+"";if(He(e))return au?au.call(e):"";var t=e+"";return t=="0"&&1/e==-ce?"-0":t}function Rt(e,t,s){var u=-1,c=ar,h=e.length,p=!0,_=[],y=_;if(s)p=!1,c=bi;else if(h>=a){var O=t?null:id(e);if(O)return fr(O);p=!1,c=kn,y=new qt}else y=t?[]:_;e:for(;++u<h;){var b=e[u],N=t?t(b):b;if(b=s||b!==0?b:0,p&&N===N){for(var k=y.length;k--;)if(y[k]===N)continue e;t&&y.push(N),_.push(b)}else c(y,N,s)||(y!==_&&y.push(N),_.push(b))}return _}function es(e,t){return t=Nt(t,e),e=ia(e,t),e==null||delete e[ht(Ze(t))]}function Nu(e,t,s,u){return Gn(e,t,s(Wt(e,t)),u)}function Rr(e,t,s,u){for(var c=e.length,h=u?c:-1;(u?h--:++h<c)&&t(e[h],h,e););return s?je(e,u?0:h,u?h+1:c):je(e,u?h+1:0,u?c:h)}function Du(e,t){var s=e;return s instanceof Q&&(s=s.value()),Ci(t,function(u,c){return c.func.apply(c.thisArg,St([u],c.args))},s)}function ts(e,t,s){var u=e.length;if(u<2)return u?Rt(e[0]):[];for(var c=-1,h=T(u);++c<u;)for(var p=e[c],_=-1;++_<u;)_!=c&&(h[c]=$n(h[c]||p,e[_],t,s));return Rt(Ae(h,1),t,s)}function Lu(e,t,s){for(var u=-1,c=e.length,h=t.length,p={};++u<c;){var _=u<h?t[u]:r;s(p,e[u],_)}return p}function ns(e){return pe(e)?e:[]}function rs(e){return typeof e=="function"?e:Fe}function Nt(e,t){return V(e)?e:hs(e,t)?[e]:aa(te(e))}var Jh=X;function Dt(e,t,s){var u=e.length;return s=s===r?u:s,!t&&s>=u?e:je(e,t,s)}var ku=Ml||function(e){return we.clearTimeout(e)};function Mu(e,t){if(t)return e.slice();var s=e.length,u=nu?nu(s):new e.constructor(s);return e.copy(u),u}function is(e){var t=new e.constructor(e.byteLength);return new _r(t).set(new _r(e)),t}function Xh(e,t){var s=t?is(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.byteLength)}function Kh(e){var t=new e.constructor(e.source,yo.exec(e));return t.lastIndex=e.lastIndex,t}function Qh(e){return Bn?se(Bn.call(e)):{}}function Pu(e,t){var s=t?is(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function Fu(e,t){if(e!==t){var s=e!==r,u=e===null,c=e===e,h=He(e),p=t!==r,_=t===null,y=t===t,O=He(t);if(!_&&!O&&!h&&e>t||h&&p&&y&&!_&&!O||u&&p&&y||!s&&y||!c)return 1;if(!u&&!h&&!O&&e<t||O&&s&&c&&!u&&!h||_&&s&&c||!p&&c||!y)return-1}return 0}function jh(e,t,s){for(var u=-1,c=e.criteria,h=t.criteria,p=c.length,_=s.length;++u<p;){var y=Fu(c[u],h[u]);if(y){if(u>=_)return y;var O=s[u];return y*(O=="desc"?-1:1)}}return e.index-t.index}function Uu(e,t,s,u){for(var c=-1,h=e.length,p=s.length,_=-1,y=t.length,O=ye(h-p,0),b=T(y+O),N=!u;++_<y;)b[_]=t[_];for(;++c<p;)(N||c<h)&&(b[s[c]]=e[c]);for(;O--;)b[_++]=e[c++];return b}function Bu(e,t,s,u){for(var c=-1,h=e.length,p=-1,_=s.length,y=-1,O=t.length,b=ye(h-_,0),N=T(b+O),k=!u;++c<b;)N[c]=e[c];for(var U=c;++y<O;)N[U+y]=t[y];for(;++p<_;)(k||c<h)&&(N[U+s[p]]=e[c++]);return N}function ke(e,t){var s=-1,u=e.length;for(t||(t=T(u));++s<u;)t[s]=e[s];return t}function lt(e,t,s,u){var c=!s;s||(s={});for(var h=-1,p=t.length;++h<p;){var _=t[h],y=u?u(s[_],e[_],_,s,e):r;y===r&&(y=e[_]),c?vt(s,_,y):qn(s,_,y)}return s}function Zh(e,t){return lt(e,ls(e),t)}function ed(e,t){return lt(e,ju(e),t)}function Nr(e,t){return function(s,u){var c=V(s)?sl:xh,h=t?t():{};return c(s,e,B(u,2),h)}}function an(e){return X(function(t,s){var u=-1,c=s.length,h=c>1?s[c-1]:r,p=c>2?s[2]:r;for(h=e.length>3&&typeof h=="function"?(c--,h):r,p&&Ce(s[0],s[1],p)&&(h=c<3?r:h,c=1),t=se(t);++u<c;){var _=s[u];_&&e(t,_,u,h)}return t})}function qu(e,t){return function(s,u){if(s==null)return s;if(!Me(s))return e(s,u);for(var c=s.length,h=t?c:-1,p=se(s);(t?h--:++h<c)&&u(p[h],h,p)!==!1;);return s}}function $u(e){return function(t,s,u){for(var c=-1,h=se(t),p=u(t),_=p.length;_--;){var y=p[e?_:++c];if(s(h[y],y,h)===!1)break}return t}}function td(e,t,s){var u=t&H,c=Vn(e);function h(){var p=this&&this!==we&&this instanceof h?c:e;return p.apply(u?s:this,arguments)}return h}function Wu(e){return function(t){t=te(t);var s=en(t)?it(t):r,u=s?s[0]:t.charAt(0),c=s?Dt(s,1).join(""):t.slice(1);return u[e]()+c}}function cn(e){return function(t){return Ci(qa(Ba(t).replace(Vf,"")),e,"")}}function Vn(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var s=un(e.prototype),u=e.apply(s,t);return he(u)?u:s}}function nd(e,t,s){var u=Vn(e);function c(){for(var h=arguments.length,p=T(h),_=h,y=fn(c);_--;)p[_]=arguments[_];var O=h<3&&p[0]!==y&&p[h-1]!==y?[]:Ot(p,y);if(h-=O.length,h<s)return Yu(e,t,Dr,c.placeholder,r,p,O,r,r,s-h);var b=this&&this!==we&&this instanceof c?u:e;return qe(b,this,p)}return c}function Hu(e){return function(t,s,u){var c=se(t);if(!Me(t)){var h=B(s,3);t=Ee(t),s=function(_){return h(c[_],_,c)}}var p=e(t,s,u);return p>-1?c[h?t[p]:p]:r}}function Gu(e){return mt(function(t){var s=t.length,u=s,c=Ke.prototype.thru;for(e&&t.reverse();u--;){var h=t[u];if(typeof h!="function")throw new Xe(d);if(c&&!p&&Pr(h)=="wrapper")var p=new Ke([],!0)}for(u=p?u:s;++u<s;){h=t[u];var _=Pr(h),y=_=="wrapper"?cs(h):r;y&&ds(y[0])&&y[1]==(Le|le|xe|Be)&&!y[4].length&&y[9]==1?p=p[Pr(y[0])].apply(p,y[3]):p=h.length==1&&ds(h)?p[_]():p.thru(h)}return function(){var O=arguments,b=O[0];if(p&&O.length==1&&V(b))return p.plant(b).value();for(var N=0,k=s?t[N].apply(this,O):b;++N<s;)k=t[N].call(this,k);return k}})}function Dr(e,t,s,u,c,h,p,_,y,O){var b=t&Le,N=t&H,k=t&ie,U=t&(le|me),q=t&An,J=k?r:Vn(e);function $(){for(var K=arguments.length,Z=T(K),Ge=K;Ge--;)Z[Ge]=arguments[Ge];if(U)var Re=fn($),Ve=pl(Z,Re);if(u&&(Z=Uu(Z,u,c,U)),h&&(Z=Bu(Z,h,p,U)),K-=Ve,U&&K<O){var ge=Ot(Z,Re);return Yu(e,t,Dr,$.placeholder,s,Z,ge,_,y,O-K)}var ut=N?s:this,wt=k?ut[e]:e;return K=Z.length,_?Z=xd(Z,_):q&&K>1&&Z.reverse(),b&&y<K&&(Z.length=y),this&&this!==we&&this instanceof $&&(wt=J||Vn(wt)),wt.apply(ut,Z)}return $}function Vu(e,t){return function(s,u){return Rh(s,e,t(u),{})}}function Lr(e,t){return function(s,u){var c;if(s===r&&u===r)return t;if(s!==r&&(c=s),u!==r){if(c===r)return u;typeof s=="string"||typeof u=="string"?(s=We(s),u=We(u)):(s=Ru(s),u=Ru(u)),c=e(s,u)}return c}}function ss(e){return mt(function(t){return t=fe(t,$e(B())),X(function(s){var u=this;return e(t,function(c){return qe(c,u,s)})})})}function kr(e,t){t=t===r?" ":We(t);var s=t.length;if(s<2)return s?ji(t,e):t;var u=ji(t,Er(e/tn(t)));return en(t)?Dt(it(u),0,e).join(""):u.slice(0,e)}function rd(e,t,s,u){var c=t&H,h=Vn(e);function p(){for(var _=-1,y=arguments.length,O=-1,b=u.length,N=T(b+y),k=this&&this!==we&&this instanceof p?h:e;++O<b;)N[O]=u[O];for(;y--;)N[O++]=arguments[++_];return qe(k,c?s:this,N)}return p}function zu(e){return function(t,s,u){return u&&typeof u!="number"&&Ce(t,s,u)&&(s=u=r),t=xt(t),s===r?(s=t,t=0):s=xt(s),u=u===r?t<s?1:-1:xt(u),Wh(t,s,u,e)}}function Mr(e){return function(t,s){return typeof t=="string"&&typeof s=="string"||(t=et(t),s=et(s)),e(t,s)}}function Yu(e,t,s,u,c,h,p,_,y,O){var b=t&le,N=b?p:r,k=b?r:p,U=b?h:r,q=b?r:h;t|=b?xe:tt,t&=~(b?tt:xe),t&De||(t&=~(H|ie));var J=[e,t,c,U,N,q,k,_,y,O],$=s.apply(r,J);return ds(e)&&sa($,J),$.placeholder=u,oa($,e,t)}function os(e){var t=ve[e];return function(s,u){if(s=et(s),u=u==null?0:Se(z(u),292),u&&ou(s)){var c=(te(s)+"e").split("e"),h=t(c[0]+"e"+(+c[1]+u));return c=(te(h)+"e").split("e"),+(c[0]+"e"+(+c[1]-u))}return t(s)}}var id=sn&&1/fr(new sn([,-0]))[1]==ce?function(e){return new sn(e)}:bs;function Ju(e){return function(t){var s=Oe(t);return s==nt?Pi(t):s==rt?Tl(t):dl(t,e(t))}}function yt(e,t,s,u,c,h,p,_){var y=t&ie;if(!y&&typeof e!="function")throw new Xe(d);var O=u?u.length:0;if(O||(t&=~(xe|tt),u=c=r),p=p===r?p:ye(z(p),0),_=_===r?_:z(_),O-=c?c.length:0,t&tt){var b=u,N=c;u=c=r}var k=y?r:cs(e),U=[e,t,s,u,c,b,N,h,p,_];if(k&&md(U,k),e=U[0],t=U[1],s=U[2],u=U[3],c=U[4],_=U[9]=U[9]===r?y?0:e.length:ye(U[9]-O,0),!_&&t&(le|me)&&(t&=~(le|me)),!t||t==H)var q=td(e,t,s);else t==le||t==me?q=nd(e,t,_):(t==xe||t==(H|xe))&&!c.length?q=rd(e,t,s,u):q=Dr.apply(r,U);var J=k?bu:sa;return oa(J(q,U),e,t)}function Xu(e,t,s,u){return e===r||ot(e,rn[s])&&!re.call(u,s)?t:e}function Ku(e,t,s,u,c,h){return he(e)&&he(t)&&(h.set(t,e),br(e,t,r,Ku,h),h.delete(t)),e}function sd(e){return Jn(e)?r:e}function Qu(e,t,s,u,c,h){var p=s&R,_=e.length,y=t.length;if(_!=y&&!(p&&y>_))return!1;var O=h.get(e),b=h.get(t);if(O&&b)return O==t&&b==e;var N=-1,k=!0,U=s&F?new qt:r;for(h.set(e,t),h.set(t,e);++N<_;){var q=e[N],J=t[N];if(u)var $=p?u(J,q,N,t,e,h):u(q,J,N,e,t,h);if($!==r){if($)continue;k=!1;break}if(U){if(!Ri(t,function(K,Z){if(!kn(U,Z)&&(q===K||c(q,K,s,u,h)))return U.push(Z)})){k=!1;break}}else if(!(q===J||c(q,J,s,u,h))){k=!1;break}}return h.delete(e),h.delete(t),k}function od(e,t,s,u,c,h,p){switch(s){case Qt:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Ln:return!(e.byteLength!=t.byteLength||!h(new _r(e),new _r(t)));case On:case bn:case Cn:return ot(+e,+t);case nr:return e.name==t.name&&e.message==t.message;case Rn:case Nn:return e==t+"";case nt:var _=Pi;case rt:var y=u&R;if(_||(_=fr),e.size!=t.size&&!y)return!1;var O=p.get(e);if(O)return O==t;u|=F,p.set(e,t);var b=Qu(_(e),_(t),u,c,h,p);return p.delete(e),b;case ir:if(Bn)return Bn.call(e)==Bn.call(t)}return!1}function ud(e,t,s,u,c,h){var p=s&R,_=us(e),y=_.length,O=us(t),b=O.length;if(y!=b&&!p)return!1;for(var N=y;N--;){var k=_[N];if(!(p?k in t:re.call(t,k)))return!1}var U=h.get(e),q=h.get(t);if(U&&q)return U==t&&q==e;var J=!0;h.set(e,t),h.set(t,e);for(var $=p;++N<y;){k=_[N];var K=e[k],Z=t[k];if(u)var Ge=p?u(Z,K,k,t,e,h):u(K,Z,k,e,t,h);if(!(Ge===r?K===Z||c(K,Z,s,u,h):Ge)){J=!1;break}$||($=k=="constructor")}if(J&&!$){var Re=e.constructor,Ve=t.constructor;Re!=Ve&&"constructor"in e&&"constructor"in t&&!(typeof Re=="function"&&Re instanceof Re&&typeof Ve=="function"&&Ve instanceof Ve)&&(J=!1)}return h.delete(e),h.delete(t),J}function mt(e){return gs(ra(e,r,ha),e+"")}function us(e){return vu(e,Ee,ls)}function as(e){return vu(e,Pe,ju)}var cs=xr?function(e){return xr.get(e)}:bs;function Pr(e){for(var t=e.name+"",s=on[t],u=re.call(on,t)?s.length:0;u--;){var c=s[u],h=c.func;if(h==null||h==e)return c.name}return t}function fn(e){var t=re.call(l,"placeholder")?l:e;return t.placeholder}function B(){var e=l.iteratee||Ss;return e=e===Ss?Eu:e,arguments.length?e(arguments[0],arguments[1]):e}function Fr(e,t){var s=e.__data__;return gd(t)?s[typeof t=="string"?"string":"hash"]:s.map}function fs(e){for(var t=Ee(e),s=t.length;s--;){var u=t[s],c=e[u];t[s]=[u,c,ta(c)]}return t}function Ht(e,t){var s=yl(e,t);return mu(s)?s:r}function ad(e){var t=re.call(e,Ut),s=e[Ut];try{e[Ut]=r;var u=!0}catch{}var c=pr.call(e);return u&&(t?e[Ut]=s:delete e[Ut]),c}var ls=Ui?function(e){return e==null?[]:(e=se(e),It(Ui(e),function(t){return iu.call(e,t)}))}:Cs,ju=Ui?function(e){for(var t=[];e;)St(t,ls(e)),e=vr(e);return t}:Cs,Oe=be;(Bi&&Oe(new Bi(new ArrayBuffer(1)))!=Qt||Pn&&Oe(new Pn)!=nt||qi&&Oe(qi.resolve())!=po||sn&&Oe(new sn)!=rt||Fn&&Oe(new Fn)!=Dn)&&(Oe=function(e){var t=be(e),s=t==pt?e.constructor:r,u=s?Gt(s):"";if(u)switch(u){case Gl:return Qt;case Vl:return nt;case zl:return po;case Yl:return rt;case Jl:return Dn}return t});function cd(e,t,s){for(var u=-1,c=s.length;++u<c;){var h=s[u],p=h.size;switch(h.type){case"drop":e+=p;break;case"dropRight":t-=p;break;case"take":t=Se(t,e+p);break;case"takeRight":e=ye(e,t-p);break}}return{start:e,end:t}}function fd(e){var t=e.match(_f);return t?t[1].split(vf):[]}function Zu(e,t,s){t=Nt(t,e);for(var u=-1,c=t.length,h=!1;++u<c;){var p=ht(t[u]);if(!(h=e!=null&&s(e,p)))break;e=e[p]}return h||++u!=c?h:(c=e==null?0:e.length,!!c&&Gr(c)&&Et(p,c)&&(V(e)||Vt(e)))}function ld(e){var t=e.length,s=new e.constructor(t);return t&&typeof e[0]=="string"&&re.call(e,"index")&&(s.index=e.index,s.input=e.input),s}function ea(e){return typeof e.constructor=="function"&&!zn(e)?un(vr(e)):{}}function hd(e,t,s){var u=e.constructor;switch(t){case Ln:return is(e);case On:case bn:return new u(+e);case Qt:return Xh(e,s);case fi:case li:case hi:case di:case pi:case gi:case _i:case vi:case yi:return Pu(e,s);case nt:return new u;case Cn:case Nn:return new u(e);case Rn:return Kh(e);case rt:return new u;case ir:return Qh(e)}}function dd(e,t){var s=t.length;if(!s)return e;var u=s-1;return t[u]=(s>1?"& ":"")+t[u],t=t.join(s>2?", ":" "),e.replace(gf,`{
11
- /* [wrapped with `+t+`] */
12
- `)}function pd(e){return V(e)||Vt(e)||!!(su&&e&&e[su])}function Et(e,t){var s=typeof e;return t=t??oe,!!t&&(s=="number"||s!="symbol"&&Sf.test(e))&&e>-1&&e%1==0&&e<t}function Ce(e,t,s){if(!he(s))return!1;var u=typeof t;return(u=="number"?Me(s)&&Et(t,s.length):u=="string"&&t in s)?ot(s[t],e):!1}function hs(e,t){if(V(e))return!1;var s=typeof e;return s=="number"||s=="symbol"||s=="boolean"||e==null||He(e)?!0:lf.test(e)||!ff.test(e)||t!=null&&e in se(t)}function gd(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function ds(e){var t=Pr(e),s=l[t];if(typeof s!="function"||!(t in Q.prototype))return!1;if(e===s)return!0;var u=cs(s);return!!u&&e===u[0]}function _d(e){return!!tu&&tu in e}var vd=hr?Tt:Rs;function zn(e){var t=e&&e.constructor,s=typeof t=="function"&&t.prototype||rn;return e===s}function ta(e){return e===e&&!he(e)}function na(e,t){return function(s){return s==null?!1:s[e]===t&&(t!==r||e in se(s))}}function yd(e){var t=Wr(e,function(u){return s.size===E&&s.clear(),u}),s=t.cache;return t}function md(e,t){var s=e[1],u=t[1],c=s|u,h=c<(H|ie|Le),p=u==Le&&s==le||u==Le&&s==Be&&e[7].length<=t[8]||u==(Le|Be)&&t[7].length<=t[8]&&s==le;if(!(h||p))return e;u&H&&(e[2]=t[2],c|=s&H?0:De);var _=t[3];if(_){var y=e[3];e[3]=y?Uu(y,_,t[4]):_,e[4]=y?Ot(e[3],I):t[4]}return _=t[5],_&&(y=e[5],e[5]=y?Bu(y,_,t[6]):_,e[6]=y?Ot(e[5],I):t[6]),_=t[7],_&&(e[7]=_),u&Le&&(e[8]=e[8]==null?t[8]:Se(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=c,e}function Ed(e){var t=[];if(e!=null)for(var s in se(e))t.push(s);return t}function Td(e){return pr.call(e)}function ra(e,t,s){return t=ye(t===r?e.length-1:t,0),function(){for(var u=arguments,c=-1,h=ye(u.length-t,0),p=T(h);++c<h;)p[c]=u[t+c];c=-1;for(var _=T(t+1);++c<t;)_[c]=u[c];return _[t]=s(p),qe(e,this,_)}}function ia(e,t){return t.length<2?e:Wt(e,je(t,0,-1))}function xd(e,t){for(var s=e.length,u=Se(t.length,s),c=ke(e);u--;){var h=t[u];e[u]=Et(h,s)?c[h]:r}return e}function ps(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var sa=ua(bu),Yn=Fl||function(e,t){return we.setTimeout(e,t)},gs=ua(Vh);function oa(e,t,s){var u=t+"";return gs(e,dd(u,wd(fd(u),s)))}function ua(e){var t=0,s=0;return function(){var u=$l(),c=In-(u-s);if(s=u,c>0){if(++t>=ci)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Ur(e,t){var s=-1,u=e.length,c=u-1;for(t=t===r?u:t;++s<t;){var h=Qi(s,c),p=e[h];e[h]=e[s],e[s]=p}return e.length=t,e}var aa=yd(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(hf,function(s,u,c,h){t.push(c?h.replace(Ef,"$1"):u||s)}),t});function ht(e){if(typeof e=="string"||He(e))return e;var t=e+"";return t=="0"&&1/e==-ce?"-0":t}function Gt(e){if(e!=null){try{return dr.call(e)}catch{}try{return e+""}catch{}}return""}function wd(e,t){return Je(Xc,function(s){var u="_."+s[0];t&s[1]&&!ar(e,u)&&e.push(u)}),e.sort()}function ca(e){if(e instanceof Q)return e.clone();var t=new Ke(e.__wrapped__,e.__chain__);return t.__actions__=ke(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Ad(e,t,s){(s?Ce(e,t,s):t===r)?t=1:t=ye(z(t),0);var u=e==null?0:e.length;if(!u||t<1)return[];for(var c=0,h=0,p=T(Er(u/t));c<u;)p[h++]=je(e,c,c+=t);return p}function Id(e){for(var t=-1,s=e==null?0:e.length,u=0,c=[];++t<s;){var h=e[t];h&&(c[u++]=h)}return c}function Sd(){var e=arguments.length;if(!e)return[];for(var t=T(e-1),s=arguments[0],u=e;u--;)t[u-1]=arguments[u];return St(V(s)?ke(s):[s],Ae(t,1))}var Od=X(function(e,t){return pe(e)?$n(e,Ae(t,1,pe,!0)):[]}),bd=X(function(e,t){var s=Ze(t);return pe(s)&&(s=r),pe(e)?$n(e,Ae(t,1,pe,!0),B(s,2)):[]}),Cd=X(function(e,t){var s=Ze(t);return pe(s)&&(s=r),pe(e)?$n(e,Ae(t,1,pe,!0),r,s):[]});function Rd(e,t,s){var u=e==null?0:e.length;return u?(t=s||t===r?1:z(t),je(e,t<0?0:t,u)):[]}function Nd(e,t,s){var u=e==null?0:e.length;return u?(t=s||t===r?1:z(t),t=u-t,je(e,0,t<0?0:t)):[]}function Dd(e,t){return e&&e.length?Rr(e,B(t,3),!0,!0):[]}function Ld(e,t){return e&&e.length?Rr(e,B(t,3),!0):[]}function kd(e,t,s,u){var c=e==null?0:e.length;return c?(s&&typeof s!="number"&&Ce(e,t,s)&&(s=0,u=c),Sh(e,t,s,u)):[]}function fa(e,t,s){var u=e==null?0:e.length;if(!u)return-1;var c=s==null?0:z(s);return c<0&&(c=ye(u+c,0)),cr(e,B(t,3),c)}function la(e,t,s){var u=e==null?0:e.length;if(!u)return-1;var c=u-1;return s!==r&&(c=z(s),c=s<0?ye(u+c,0):Se(c,u-1)),cr(e,B(t,3),c,!0)}function ha(e){var t=e==null?0:e.length;return t?Ae(e,1):[]}function Md(e){var t=e==null?0:e.length;return t?Ae(e,ce):[]}function Pd(e,t){var s=e==null?0:e.length;return s?(t=t===r?1:z(t),Ae(e,t)):[]}function Fd(e){for(var t=-1,s=e==null?0:e.length,u={};++t<s;){var c=e[t];u[c[0]]=c[1]}return u}function da(e){return e&&e.length?e[0]:r}function Ud(e,t,s){var u=e==null?0:e.length;if(!u)return-1;var c=s==null?0:z(s);return c<0&&(c=ye(u+c,0)),Zt(e,t,c)}function Bd(e){var t=e==null?0:e.length;return t?je(e,0,-1):[]}var qd=X(function(e){var t=fe(e,ns);return t.length&&t[0]===e[0]?zi(t):[]}),$d=X(function(e){var t=Ze(e),s=fe(e,ns);return t===Ze(s)?t=r:s.pop(),s.length&&s[0]===e[0]?zi(s,B(t,2)):[]}),Wd=X(function(e){var t=Ze(e),s=fe(e,ns);return t=typeof t=="function"?t:r,t&&s.pop(),s.length&&s[0]===e[0]?zi(s,r,t):[]});function Hd(e,t){return e==null?"":Bl.call(e,t)}function Ze(e){var t=e==null?0:e.length;return t?e[t-1]:r}function Gd(e,t,s){var u=e==null?0:e.length;if(!u)return-1;var c=u;return s!==r&&(c=z(s),c=c<0?ye(u+c,0):Se(c,u-1)),t===t?wl(e,t,c):cr(e,Yo,c,!0)}function Vd(e,t){return e&&e.length?Au(e,z(t)):r}var zd=X(pa);function pa(e,t){return e&&e.length&&t&&t.length?Ki(e,t):e}function Yd(e,t,s){return e&&e.length&&t&&t.length?Ki(e,t,B(s,2)):e}function Jd(e,t,s){return e&&e.length&&t&&t.length?Ki(e,t,r,s):e}var Xd=mt(function(e,t){var s=e==null?0:e.length,u=Wi(e,t);return Ou(e,fe(t,function(c){return Et(c,s)?+c:c}).sort(Fu)),u});function Kd(e,t){var s=[];if(!(e&&e.length))return s;var u=-1,c=[],h=e.length;for(t=B(t,3);++u<h;){var p=e[u];t(p,u,e)&&(s.push(p),c.push(u))}return Ou(e,c),s}function _s(e){return e==null?e:Hl.call(e)}function Qd(e,t,s){var u=e==null?0:e.length;return u?(s&&typeof s!="number"&&Ce(e,t,s)?(t=0,s=u):(t=t==null?0:z(t),s=s===r?u:z(s)),je(e,t,s)):[]}function jd(e,t){return Cr(e,t)}function Zd(e,t,s){return Zi(e,t,B(s,2))}function ep(e,t){var s=e==null?0:e.length;if(s){var u=Cr(e,t);if(u<s&&ot(e[u],t))return u}return-1}function tp(e,t){return Cr(e,t,!0)}function np(e,t,s){return Zi(e,t,B(s,2),!0)}function rp(e,t){var s=e==null?0:e.length;if(s){var u=Cr(e,t,!0)-1;if(ot(e[u],t))return u}return-1}function ip(e){return e&&e.length?Cu(e):[]}function sp(e,t){return e&&e.length?Cu(e,B(t,2)):[]}function op(e){var t=e==null?0:e.length;return t?je(e,1,t):[]}function up(e,t,s){return e&&e.length?(t=s||t===r?1:z(t),je(e,0,t<0?0:t)):[]}function ap(e,t,s){var u=e==null?0:e.length;return u?(t=s||t===r?1:z(t),t=u-t,je(e,t<0?0:t,u)):[]}function cp(e,t){return e&&e.length?Rr(e,B(t,3),!1,!0):[]}function fp(e,t){return e&&e.length?Rr(e,B(t,3)):[]}var lp=X(function(e){return Rt(Ae(e,1,pe,!0))}),hp=X(function(e){var t=Ze(e);return pe(t)&&(t=r),Rt(Ae(e,1,pe,!0),B(t,2))}),dp=X(function(e){var t=Ze(e);return t=typeof t=="function"?t:r,Rt(Ae(e,1,pe,!0),r,t)});function pp(e){return e&&e.length?Rt(e):[]}function gp(e,t){return e&&e.length?Rt(e,B(t,2)):[]}function _p(e,t){return t=typeof t=="function"?t:r,e&&e.length?Rt(e,r,t):[]}function vs(e){if(!(e&&e.length))return[];var t=0;return e=It(e,function(s){if(pe(s))return t=ye(s.length,t),!0}),ki(t,function(s){return fe(e,Ni(s))})}function ga(e,t){if(!(e&&e.length))return[];var s=vs(e);return t==null?s:fe(s,function(u){return qe(t,r,u)})}var vp=X(function(e,t){return pe(e)?$n(e,t):[]}),yp=X(function(e){return ts(It(e,pe))}),mp=X(function(e){var t=Ze(e);return pe(t)&&(t=r),ts(It(e,pe),B(t,2))}),Ep=X(function(e){var t=Ze(e);return t=typeof t=="function"?t:r,ts(It(e,pe),r,t)}),Tp=X(vs);function xp(e,t){return Lu(e||[],t||[],qn)}function wp(e,t){return Lu(e||[],t||[],Gn)}var Ap=X(function(e){var t=e.length,s=t>1?e[t-1]:r;return s=typeof s=="function"?(e.pop(),s):r,ga(e,s)});function _a(e){var t=l(e);return t.__chain__=!0,t}function Ip(e,t){return t(e),e}function Br(e,t){return t(e)}var Sp=mt(function(e){var t=e.length,s=t?e[0]:0,u=this.__wrapped__,c=function(h){return Wi(h,e)};return t>1||this.__actions__.length||!(u instanceof Q)||!Et(s)?this.thru(c):(u=u.slice(s,+s+(t?1:0)),u.__actions__.push({func:Br,args:[c],thisArg:r}),new Ke(u,this.__chain__).thru(function(h){return t&&!h.length&&h.push(r),h}))});function Op(){return _a(this)}function bp(){return new Ke(this.value(),this.__chain__)}function Cp(){this.__values__===r&&(this.__values__=Ra(this.value()));var e=this.__index__>=this.__values__.length,t=e?r:this.__values__[this.__index__++];return{done:e,value:t}}function Rp(){return this}function Np(e){for(var t,s=this;s instanceof Ar;){var u=ca(s);u.__index__=0,u.__values__=r,t?c.__wrapped__=u:t=u;var c=u;s=s.__wrapped__}return c.__wrapped__=e,t}function Dp(){var e=this.__wrapped__;if(e instanceof Q){var t=e;return this.__actions__.length&&(t=new Q(this)),t=t.reverse(),t.__actions__.push({func:Br,args:[_s],thisArg:r}),new Ke(t,this.__chain__)}return this.thru(_s)}function Lp(){return Du(this.__wrapped__,this.__actions__)}var kp=Nr(function(e,t,s){re.call(e,s)?++e[s]:vt(e,s,1)});function Mp(e,t,s){var u=V(e)?Vo:Ih;return s&&Ce(e,t,s)&&(t=r),u(e,B(t,3))}function Pp(e,t){var s=V(e)?It:gu;return s(e,B(t,3))}var Fp=Hu(fa),Up=Hu(la);function Bp(e,t){return Ae(qr(e,t),1)}function qp(e,t){return Ae(qr(e,t),ce)}function $p(e,t,s){return s=s===r?1:z(s),Ae(qr(e,t),s)}function va(e,t){var s=V(e)?Je:Ct;return s(e,B(t,3))}function ya(e,t){var s=V(e)?ol:pu;return s(e,B(t,3))}var Wp=Nr(function(e,t,s){re.call(e,s)?e[s].push(t):vt(e,s,[t])});function Hp(e,t,s,u){e=Me(e)?e:hn(e),s=s&&!u?z(s):0;var c=e.length;return s<0&&(s=ye(c+s,0)),Vr(e)?s<=c&&e.indexOf(t,s)>-1:!!c&&Zt(e,t,s)>-1}var Gp=X(function(e,t,s){var u=-1,c=typeof t=="function",h=Me(e)?T(e.length):[];return Ct(e,function(p){h[++u]=c?qe(t,p,s):Wn(p,t,s)}),h}),Vp=Nr(function(e,t,s){vt(e,s,t)});function qr(e,t){var s=V(e)?fe:Tu;return s(e,B(t,3))}function zp(e,t,s,u){return e==null?[]:(V(t)||(t=t==null?[]:[t]),s=u?r:s,V(s)||(s=s==null?[]:[s]),Iu(e,t,s))}var Yp=Nr(function(e,t,s){e[s?0:1].push(t)},function(){return[[],[]]});function Jp(e,t,s){var u=V(e)?Ci:Xo,c=arguments.length<3;return u(e,B(t,4),s,c,Ct)}function Xp(e,t,s){var u=V(e)?ul:Xo,c=arguments.length<3;return u(e,B(t,4),s,c,pu)}function Kp(e,t){var s=V(e)?It:gu;return s(e,Hr(B(t,3)))}function Qp(e){var t=V(e)?fu:Hh;return t(e)}function jp(e,t,s){(s?Ce(e,t,s):t===r)?t=1:t=z(t);var u=V(e)?Eh:Gh;return u(e,t)}function Zp(e){var t=V(e)?Th:zh;return t(e)}function eg(e){if(e==null)return 0;if(Me(e))return Vr(e)?tn(e):e.length;var t=Oe(e);return t==nt||t==rt?e.size:Ji(e).length}function tg(e,t,s){var u=V(e)?Ri:Yh;return s&&Ce(e,t,s)&&(t=r),u(e,B(t,3))}var ng=X(function(e,t){if(e==null)return[];var s=t.length;return s>1&&Ce(e,t[0],t[1])?t=[]:s>2&&Ce(t[0],t[1],t[2])&&(t=[t[0]]),Iu(e,Ae(t,1),[])}),$r=Pl||function(){return we.Date.now()};function rg(e,t){if(typeof t!="function")throw new Xe(d);return e=z(e),function(){if(--e<1)return t.apply(this,arguments)}}function ma(e,t,s){return t=s?r:t,t=e&&t==null?e.length:t,yt(e,Le,r,r,r,r,t)}function Ea(e,t){var s;if(typeof t!="function")throw new Xe(d);return e=z(e),function(){return--e>0&&(s=t.apply(this,arguments)),e<=1&&(t=r),s}}var ys=X(function(e,t,s){var u=H;if(s.length){var c=Ot(s,fn(ys));u|=xe}return yt(e,u,t,s,c)}),Ta=X(function(e,t,s){var u=H|ie;if(s.length){var c=Ot(s,fn(Ta));u|=xe}return yt(t,u,e,s,c)});function xa(e,t,s){t=s?r:t;var u=yt(e,le,r,r,r,r,r,t);return u.placeholder=xa.placeholder,u}function wa(e,t,s){t=s?r:t;var u=yt(e,me,r,r,r,r,r,t);return u.placeholder=wa.placeholder,u}function Aa(e,t,s){var u,c,h,p,_,y,O=0,b=!1,N=!1,k=!0;if(typeof e!="function")throw new Xe(d);t=et(t)||0,he(s)&&(b=!!s.leading,N="maxWait"in s,h=N?ye(et(s.maxWait)||0,t):h,k="trailing"in s?!!s.trailing:k);function U(ge){var ut=u,wt=c;return u=c=r,O=ge,p=e.apply(wt,ut),p}function q(ge){return O=ge,_=Yn(K,t),b?U(ge):p}function J(ge){var ut=ge-y,wt=ge-O,Ha=t-ut;return N?Se(Ha,h-wt):Ha}function $(ge){var ut=ge-y,wt=ge-O;return y===r||ut>=t||ut<0||N&&wt>=h}function K(){var ge=$r();if($(ge))return Z(ge);_=Yn(K,J(ge))}function Z(ge){return _=r,k&&u?U(ge):(u=c=r,p)}function Ge(){_!==r&&ku(_),O=0,u=y=c=_=r}function Re(){return _===r?p:Z($r())}function Ve(){var ge=$r(),ut=$(ge);if(u=arguments,c=this,y=ge,ut){if(_===r)return q(y);if(N)return ku(_),_=Yn(K,t),U(y)}return _===r&&(_=Yn(K,t)),p}return Ve.cancel=Ge,Ve.flush=Re,Ve}var ig=X(function(e,t){return du(e,1,t)}),sg=X(function(e,t,s){return du(e,et(t)||0,s)});function og(e){return yt(e,An)}function Wr(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new Xe(d);var s=function(){var u=arguments,c=t?t.apply(this,u):u[0],h=s.cache;if(h.has(c))return h.get(c);var p=e.apply(this,u);return s.cache=h.set(c,p)||h,p};return s.cache=new(Wr.Cache||_t),s}Wr.Cache=_t;function Hr(e){if(typeof e!="function")throw new Xe(d);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function ug(e){return Ea(2,e)}var ag=Jh(function(e,t){t=t.length==1&&V(t[0])?fe(t[0],$e(B())):fe(Ae(t,1),$e(B()));var s=t.length;return X(function(u){for(var c=-1,h=Se(u.length,s);++c<h;)u[c]=t[c].call(this,u[c]);return qe(e,this,u)})}),ms=X(function(e,t){var s=Ot(t,fn(ms));return yt(e,xe,r,t,s)}),Ia=X(function(e,t){var s=Ot(t,fn(Ia));return yt(e,tt,r,t,s)}),cg=mt(function(e,t){return yt(e,Be,r,r,r,t)});function fg(e,t){if(typeof e!="function")throw new Xe(d);return t=t===r?t:z(t),X(e,t)}function lg(e,t){if(typeof e!="function")throw new Xe(d);return t=t==null?0:ye(z(t),0),X(function(s){var u=s[t],c=Dt(s,0,t);return u&&St(c,u),qe(e,this,c)})}function hg(e,t,s){var u=!0,c=!0;if(typeof e!="function")throw new Xe(d);return he(s)&&(u="leading"in s?!!s.leading:u,c="trailing"in s?!!s.trailing:c),Aa(e,t,{leading:u,maxWait:t,trailing:c})}function dg(e){return ma(e,1)}function pg(e,t){return ms(rs(t),e)}function gg(){if(!arguments.length)return[];var e=arguments[0];return V(e)?e:[e]}function _g(e){return Qe(e,D)}function vg(e,t){return t=typeof t=="function"?t:r,Qe(e,D,t)}function yg(e){return Qe(e,x|D)}function mg(e,t){return t=typeof t=="function"?t:r,Qe(e,x|D,t)}function Eg(e,t){return t==null||hu(e,t,Ee(t))}function ot(e,t){return e===t||e!==e&&t!==t}var Tg=Mr(Vi),xg=Mr(function(e,t){return e>=t}),Vt=yu(function(){return arguments}())?yu:function(e){return de(e)&&re.call(e,"callee")&&!iu.call(e,"callee")},V=T.isArray,wg=Bo?$e(Bo):Nh;function Me(e){return e!=null&&Gr(e.length)&&!Tt(e)}function pe(e){return de(e)&&Me(e)}function Ag(e){return e===!0||e===!1||de(e)&&be(e)==On}var Lt=Ul||Rs,Ig=qo?$e(qo):Dh;function Sg(e){return de(e)&&e.nodeType===1&&!Jn(e)}function Og(e){if(e==null)return!0;if(Me(e)&&(V(e)||typeof e=="string"||typeof e.splice=="function"||Lt(e)||ln(e)||Vt(e)))return!e.length;var t=Oe(e);if(t==nt||t==rt)return!e.size;if(zn(e))return!Ji(e).length;for(var s in e)if(re.call(e,s))return!1;return!0}function bg(e,t){return Hn(e,t)}function Cg(e,t,s){s=typeof s=="function"?s:r;var u=s?s(e,t):r;return u===r?Hn(e,t,r,s):!!u}function Es(e){if(!de(e))return!1;var t=be(e);return t==nr||t==Qc||typeof e.message=="string"&&typeof e.name=="string"&&!Jn(e)}function Rg(e){return typeof e=="number"&&ou(e)}function Tt(e){if(!he(e))return!1;var t=be(e);return t==rr||t==ho||t==Kc||t==Zc}function Sa(e){return typeof e=="number"&&e==z(e)}function Gr(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=oe}function he(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function de(e){return e!=null&&typeof e=="object"}var Oa=$o?$e($o):kh;function Ng(e,t){return e===t||Yi(e,t,fs(t))}function Dg(e,t,s){return s=typeof s=="function"?s:r,Yi(e,t,fs(t),s)}function Lg(e){return ba(e)&&e!=+e}function kg(e){if(vd(e))throw new G(f);return mu(e)}function Mg(e){return e===null}function Pg(e){return e==null}function ba(e){return typeof e=="number"||de(e)&&be(e)==Cn}function Jn(e){if(!de(e)||be(e)!=pt)return!1;var t=vr(e);if(t===null)return!0;var s=re.call(t,"constructor")&&t.constructor;return typeof s=="function"&&s instanceof s&&dr.call(s)==Dl}var Ts=Wo?$e(Wo):Mh;function Fg(e){return Sa(e)&&e>=-oe&&e<=oe}var Ca=Ho?$e(Ho):Ph;function Vr(e){return typeof e=="string"||!V(e)&&de(e)&&be(e)==Nn}function He(e){return typeof e=="symbol"||de(e)&&be(e)==ir}var ln=Go?$e(Go):Fh;function Ug(e){return e===r}function Bg(e){return de(e)&&Oe(e)==Dn}function qg(e){return de(e)&&be(e)==tf}var $g=Mr(Xi),Wg=Mr(function(e,t){return e<=t});function Ra(e){if(!e)return[];if(Me(e))return Vr(e)?it(e):ke(e);if(Mn&&e[Mn])return El(e[Mn]());var t=Oe(e),s=t==nt?Pi:t==rt?fr:hn;return s(e)}function xt(e){if(!e)return e===0?e:0;if(e=et(e),e===ce||e===-ce){var t=e<0?-1:1;return t*ne}return e===e?e:0}function z(e){var t=xt(e),s=t%1;return t===t?s?t-s:t:0}function Na(e){return e?$t(z(e),0,Ie):0}function et(e){if(typeof e=="number")return e;if(He(e))return dt;if(he(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=he(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Ko(e);var s=wf.test(e);return s||If.test(e)?rl(e.slice(2),s?2:8):xf.test(e)?dt:+e}function Da(e){return lt(e,Pe(e))}function Hg(e){return e?$t(z(e),-oe,oe):e===0?e:0}function te(e){return e==null?"":We(e)}var Gg=an(function(e,t){if(zn(t)||Me(t)){lt(t,Ee(t),e);return}for(var s in t)re.call(t,s)&&qn(e,s,t[s])}),La=an(function(e,t){lt(t,Pe(t),e)}),zr=an(function(e,t,s,u){lt(t,Pe(t),e,u)}),Vg=an(function(e,t,s,u){lt(t,Ee(t),e,u)}),zg=mt(Wi);function Yg(e,t){var s=un(e);return t==null?s:lu(s,t)}var Jg=X(function(e,t){e=se(e);var s=-1,u=t.length,c=u>2?t[2]:r;for(c&&Ce(t[0],t[1],c)&&(u=1);++s<u;)for(var h=t[s],p=Pe(h),_=-1,y=p.length;++_<y;){var O=p[_],b=e[O];(b===r||ot(b,rn[O])&&!re.call(e,O))&&(e[O]=h[O])}return e}),Xg=X(function(e){return e.push(r,Ku),qe(ka,r,e)});function Kg(e,t){return zo(e,B(t,3),ft)}function Qg(e,t){return zo(e,B(t,3),Gi)}function jg(e,t){return e==null?e:Hi(e,B(t,3),Pe)}function Zg(e,t){return e==null?e:_u(e,B(t,3),Pe)}function e0(e,t){return e&&ft(e,B(t,3))}function t0(e,t){return e&&Gi(e,B(t,3))}function n0(e){return e==null?[]:Or(e,Ee(e))}function r0(e){return e==null?[]:Or(e,Pe(e))}function xs(e,t,s){var u=e==null?r:Wt(e,t);return u===r?s:u}function i0(e,t){return e!=null&&Zu(e,t,Oh)}function ws(e,t){return e!=null&&Zu(e,t,bh)}var s0=Vu(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=pr.call(t)),e[t]=s},Is(Fe)),o0=Vu(function(e,t,s){t!=null&&typeof t.toString!="function"&&(t=pr.call(t)),re.call(e,t)?e[t].push(s):e[t]=[s]},B),u0=X(Wn);function Ee(e){return Me(e)?cu(e):Ji(e)}function Pe(e){return Me(e)?cu(e,!0):Uh(e)}function a0(e,t){var s={};return t=B(t,3),ft(e,function(u,c,h){vt(s,t(u,c,h),u)}),s}function c0(e,t){var s={};return t=B(t,3),ft(e,function(u,c,h){vt(s,c,t(u,c,h))}),s}var f0=an(function(e,t,s){br(e,t,s)}),ka=an(function(e,t,s,u){br(e,t,s,u)}),l0=mt(function(e,t){var s={};if(e==null)return s;var u=!1;t=fe(t,function(h){return h=Nt(h,e),u||(u=h.length>1),h}),lt(e,as(e),s),u&&(s=Qe(s,x|S|D,sd));for(var c=t.length;c--;)es(s,t[c]);return s});function h0(e,t){return Ma(e,Hr(B(t)))}var d0=mt(function(e,t){return e==null?{}:qh(e,t)});function Ma(e,t){if(e==null)return{};var s=fe(as(e),function(u){return[u]});return t=B(t),Su(e,s,function(u,c){return t(u,c[0])})}function p0(e,t,s){t=Nt(t,e);var u=-1,c=t.length;for(c||(c=1,e=r);++u<c;){var h=e==null?r:e[ht(t[u])];h===r&&(u=c,h=s),e=Tt(h)?h.call(e):h}return e}function g0(e,t,s){return e==null?e:Gn(e,t,s)}function _0(e,t,s,u){return u=typeof u=="function"?u:r,e==null?e:Gn(e,t,s,u)}var Pa=Ju(Ee),Fa=Ju(Pe);function v0(e,t,s){var u=V(e),c=u||Lt(e)||ln(e);if(t=B(t,4),s==null){var h=e&&e.constructor;c?s=u?new h:[]:he(e)?s=Tt(h)?un(vr(e)):{}:s={}}return(c?Je:ft)(e,function(p,_,y){return t(s,p,_,y)}),s}function y0(e,t){return e==null?!0:es(e,t)}function m0(e,t,s){return e==null?e:Nu(e,t,rs(s))}function E0(e,t,s,u){return u=typeof u=="function"?u:r,e==null?e:Nu(e,t,rs(s),u)}function hn(e){return e==null?[]:Mi(e,Ee(e))}function T0(e){return e==null?[]:Mi(e,Pe(e))}function x0(e,t,s){return s===r&&(s=t,t=r),s!==r&&(s=et(s),s=s===s?s:0),t!==r&&(t=et(t),t=t===t?t:0),$t(et(e),t,s)}function w0(e,t,s){return t=xt(t),s===r?(s=t,t=0):s=xt(s),e=et(e),Ch(e,t,s)}function A0(e,t,s){if(s&&typeof s!="boolean"&&Ce(e,t,s)&&(t=s=r),s===r&&(typeof t=="boolean"?(s=t,t=r):typeof e=="boolean"&&(s=e,e=r)),e===r&&t===r?(e=0,t=1):(e=xt(e),t===r?(t=e,e=0):t=xt(t)),e>t){var u=e;e=t,t=u}if(s||e%1||t%1){var c=uu();return Se(e+c*(t-e+nl("1e-"+((c+"").length-1))),t)}return Qi(e,t)}var I0=cn(function(e,t,s){return t=t.toLowerCase(),e+(s?Ua(t):t)});function Ua(e){return As(te(e).toLowerCase())}function Ba(e){return e=te(e),e&&e.replace(Of,gl).replace(zf,"")}function S0(e,t,s){e=te(e),t=We(t);var u=e.length;s=s===r?u:$t(z(s),0,u);var c=s;return s-=t.length,s>=0&&e.slice(s,c)==t}function O0(e){return e=te(e),e&&uf.test(e)?e.replace(_o,_l):e}function b0(e){return e=te(e),e&&df.test(e)?e.replace(mi,"\\$&"):e}var C0=cn(function(e,t,s){return e+(s?"-":"")+t.toLowerCase()}),R0=cn(function(e,t,s){return e+(s?" ":"")+t.toLowerCase()}),N0=Wu("toLowerCase");function D0(e,t,s){e=te(e),t=z(t);var u=t?tn(e):0;if(!t||u>=t)return e;var c=(t-u)/2;return kr(Tr(c),s)+e+kr(Er(c),s)}function L0(e,t,s){e=te(e),t=z(t);var u=t?tn(e):0;return t&&u<t?e+kr(t-u,s):e}function k0(e,t,s){e=te(e),t=z(t);var u=t?tn(e):0;return t&&u<t?kr(t-u,s)+e:e}function M0(e,t,s){return s||t==null?t=0:t&&(t=+t),Wl(te(e).replace(Ei,""),t||0)}function P0(e,t,s){return(s?Ce(e,t,s):t===r)?t=1:t=z(t),ji(te(e),t)}function F0(){var e=arguments,t=te(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var U0=cn(function(e,t,s){return e+(s?"_":"")+t.toLowerCase()});function B0(e,t,s){return s&&typeof s!="number"&&Ce(e,t,s)&&(t=s=r),s=s===r?Ie:s>>>0,s?(e=te(e),e&&(typeof t=="string"||t!=null&&!Ts(t))&&(t=We(t),!t&&en(e))?Dt(it(e),0,s):e.split(t,s)):[]}var q0=cn(function(e,t,s){return e+(s?" ":"")+As(t)});function $0(e,t,s){return e=te(e),s=s==null?0:$t(z(s),0,e.length),t=We(t),e.slice(s,s+t.length)==t}function W0(e,t,s){var u=l.templateSettings;s&&Ce(e,t,s)&&(t=r),e=te(e),t=zr({},t,u,Xu);var c=zr({},t.imports,u.imports,Xu),h=Ee(c),p=Mi(c,h),_,y,O=0,b=t.interpolate||sr,N="__p += '",k=Fi((t.escape||sr).source+"|"+b.source+"|"+(b===vo?Tf:sr).source+"|"+(t.evaluate||sr).source+"|$","g"),U="//# sourceURL="+(re.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Qf+"]")+`
13
- `;e.replace(k,function($,K,Z,Ge,Re,Ve){return Z||(Z=Ge),N+=e.slice(O,Ve).replace(bf,vl),K&&(_=!0,N+=`' +
14
- __e(`+K+`) +
15
- '`),Re&&(y=!0,N+=`';
16
- `+Re+`;
17
- __p += '`),Z&&(N+=`' +
18
- ((__t = (`+Z+`)) == null ? '' : __t) +
19
- '`),O=Ve+$.length,$}),N+=`';
20
- `;var q=re.call(t,"variable")&&t.variable;if(!q)N=`with (obj) {
21
- `+N+`
22
- }
23
- `;else if(mf.test(q))throw new G(g);N=(y?N.replace(nf,""):N).replace(rf,"$1").replace(sf,"$1;"),N="function("+(q||"obj")+`) {
24
- `+(q?"":`obj || (obj = {});
25
- `)+"var __t, __p = ''"+(_?", __e = _.escape":"")+(y?`, __j = Array.prototype.join;
26
- function print() { __p += __j.call(arguments, '') }
27
- `:`;
28
- `)+N+`return __p
29
- }`;var J=$a(function(){return ee(h,U+"return "+N).apply(r,p)});if(J.source=N,Es(J))throw J;return J}function H0(e){return te(e).toLowerCase()}function G0(e){return te(e).toUpperCase()}function V0(e,t,s){if(e=te(e),e&&(s||t===r))return Ko(e);if(!e||!(t=We(t)))return e;var u=it(e),c=it(t),h=Qo(u,c),p=jo(u,c)+1;return Dt(u,h,p).join("")}function z0(e,t,s){if(e=te(e),e&&(s||t===r))return e.slice(0,eu(e)+1);if(!e||!(t=We(t)))return e;var u=it(e),c=jo(u,it(t))+1;return Dt(u,0,c).join("")}function Y0(e,t,s){if(e=te(e),e&&(s||t===r))return e.replace(Ei,"");if(!e||!(t=We(t)))return e;var u=it(e),c=Qo(u,it(t));return Dt(u,c).join("")}function J0(e,t){var s=ai,u=ze;if(he(t)){var c="separator"in t?t.separator:c;s="length"in t?z(t.length):s,u="omission"in t?We(t.omission):u}e=te(e);var h=e.length;if(en(e)){var p=it(e);h=p.length}if(s>=h)return e;var _=s-tn(u);if(_<1)return u;var y=p?Dt(p,0,_).join(""):e.slice(0,_);if(c===r)return y+u;if(p&&(_+=y.length-_),Ts(c)){if(e.slice(_).search(c)){var O,b=y;for(c.global||(c=Fi(c.source,te(yo.exec(c))+"g")),c.lastIndex=0;O=c.exec(b);)var N=O.index;y=y.slice(0,N===r?_:N)}}else if(e.indexOf(We(c),_)!=_){var k=y.lastIndexOf(c);k>-1&&(y=y.slice(0,k))}return y+u}function X0(e){return e=te(e),e&&of.test(e)?e.replace(go,Al):e}var K0=cn(function(e,t,s){return e+(s?" ":"")+t.toUpperCase()}),As=Wu("toUpperCase");function qa(e,t,s){return e=te(e),t=s?r:t,t===r?ml(e)?Ol(e):fl(e):e.match(t)||[]}var $a=X(function(e,t){try{return qe(e,r,t)}catch(s){return Es(s)?s:new G(s)}}),Q0=mt(function(e,t){return Je(t,function(s){s=ht(s),vt(e,s,ys(e[s],e))}),e});function j0(e){var t=e==null?0:e.length,s=B();return e=t?fe(e,function(u){if(typeof u[1]!="function")throw new Xe(d);return[s(u[0]),u[1]]}):[],X(function(u){for(var c=-1;++c<t;){var h=e[c];if(qe(h[0],this,u))return qe(h[1],this,u)}})}function Z0(e){return Ah(Qe(e,x))}function Is(e){return function(){return e}}function e_(e,t){return e==null||e!==e?t:e}var t_=Gu(),n_=Gu(!0);function Fe(e){return e}function Ss(e){return Eu(typeof e=="function"?e:Qe(e,x))}function r_(e){return xu(Qe(e,x))}function i_(e,t){return wu(e,Qe(t,x))}var s_=X(function(e,t){return function(s){return Wn(s,e,t)}}),o_=X(function(e,t){return function(s){return Wn(e,s,t)}});function Os(e,t,s){var u=Ee(t),c=Or(t,u);s==null&&!(he(t)&&(c.length||!u.length))&&(s=t,t=e,e=this,c=Or(t,Ee(t)));var h=!(he(s)&&"chain"in s)||!!s.chain,p=Tt(e);return Je(c,function(_){var y=t[_];e[_]=y,p&&(e.prototype[_]=function(){var O=this.__chain__;if(h||O){var b=e(this.__wrapped__),N=b.__actions__=ke(this.__actions__);return N.push({func:y,args:arguments,thisArg:e}),b.__chain__=O,b}return y.apply(e,St([this.value()],arguments))})}),e}function u_(){return we._===this&&(we._=Ll),this}function bs(){}function a_(e){return e=z(e),X(function(t){return Au(t,e)})}var c_=ss(fe),f_=ss(Vo),l_=ss(Ri);function Wa(e){return hs(e)?Ni(ht(e)):$h(e)}function h_(e){return function(t){return e==null?r:Wt(e,t)}}var d_=zu(),p_=zu(!0);function Cs(){return[]}function Rs(){return!1}function g_(){return{}}function __(){return""}function v_(){return!0}function y_(e,t){if(e=z(e),e<1||e>oe)return[];var s=Ie,u=Se(e,Ie);t=B(t),e-=Ie;for(var c=ki(u,t);++s<e;)t(s);return c}function m_(e){return V(e)?fe(e,ht):He(e)?[e]:ke(aa(te(e)))}function E_(e){var t=++Nl;return te(e)+t}var T_=Lr(function(e,t){return e+t},0),x_=os("ceil"),w_=Lr(function(e,t){return e/t},1),A_=os("floor");function I_(e){return e&&e.length?Sr(e,Fe,Vi):r}function S_(e,t){return e&&e.length?Sr(e,B(t,2),Vi):r}function O_(e){return Jo(e,Fe)}function b_(e,t){return Jo(e,B(t,2))}function C_(e){return e&&e.length?Sr(e,Fe,Xi):r}function R_(e,t){return e&&e.length?Sr(e,B(t,2),Xi):r}var N_=Lr(function(e,t){return e*t},1),D_=os("round"),L_=Lr(function(e,t){return e-t},0);function k_(e){return e&&e.length?Li(e,Fe):0}function M_(e,t){return e&&e.length?Li(e,B(t,2)):0}return l.after=rg,l.ary=ma,l.assign=Gg,l.assignIn=La,l.assignInWith=zr,l.assignWith=Vg,l.at=zg,l.before=Ea,l.bind=ys,l.bindAll=Q0,l.bindKey=Ta,l.castArray=gg,l.chain=_a,l.chunk=Ad,l.compact=Id,l.concat=Sd,l.cond=j0,l.conforms=Z0,l.constant=Is,l.countBy=kp,l.create=Yg,l.curry=xa,l.curryRight=wa,l.debounce=Aa,l.defaults=Jg,l.defaultsDeep=Xg,l.defer=ig,l.delay=sg,l.difference=Od,l.differenceBy=bd,l.differenceWith=Cd,l.drop=Rd,l.dropRight=Nd,l.dropRightWhile=Dd,l.dropWhile=Ld,l.fill=kd,l.filter=Pp,l.flatMap=Bp,l.flatMapDeep=qp,l.flatMapDepth=$p,l.flatten=ha,l.flattenDeep=Md,l.flattenDepth=Pd,l.flip=og,l.flow=t_,l.flowRight=n_,l.fromPairs=Fd,l.functions=n0,l.functionsIn=r0,l.groupBy=Wp,l.initial=Bd,l.intersection=qd,l.intersectionBy=$d,l.intersectionWith=Wd,l.invert=s0,l.invertBy=o0,l.invokeMap=Gp,l.iteratee=Ss,l.keyBy=Vp,l.keys=Ee,l.keysIn=Pe,l.map=qr,l.mapKeys=a0,l.mapValues=c0,l.matches=r_,l.matchesProperty=i_,l.memoize=Wr,l.merge=f0,l.mergeWith=ka,l.method=s_,l.methodOf=o_,l.mixin=Os,l.negate=Hr,l.nthArg=a_,l.omit=l0,l.omitBy=h0,l.once=ug,l.orderBy=zp,l.over=c_,l.overArgs=ag,l.overEvery=f_,l.overSome=l_,l.partial=ms,l.partialRight=Ia,l.partition=Yp,l.pick=d0,l.pickBy=Ma,l.property=Wa,l.propertyOf=h_,l.pull=zd,l.pullAll=pa,l.pullAllBy=Yd,l.pullAllWith=Jd,l.pullAt=Xd,l.range=d_,l.rangeRight=p_,l.rearg=cg,l.reject=Kp,l.remove=Kd,l.rest=fg,l.reverse=_s,l.sampleSize=jp,l.set=g0,l.setWith=_0,l.shuffle=Zp,l.slice=Qd,l.sortBy=ng,l.sortedUniq=ip,l.sortedUniqBy=sp,l.split=B0,l.spread=lg,l.tail=op,l.take=up,l.takeRight=ap,l.takeRightWhile=cp,l.takeWhile=fp,l.tap=Ip,l.throttle=hg,l.thru=Br,l.toArray=Ra,l.toPairs=Pa,l.toPairsIn=Fa,l.toPath=m_,l.toPlainObject=Da,l.transform=v0,l.unary=dg,l.union=lp,l.unionBy=hp,l.unionWith=dp,l.uniq=pp,l.uniqBy=gp,l.uniqWith=_p,l.unset=y0,l.unzip=vs,l.unzipWith=ga,l.update=m0,l.updateWith=E0,l.values=hn,l.valuesIn=T0,l.without=vp,l.words=qa,l.wrap=pg,l.xor=yp,l.xorBy=mp,l.xorWith=Ep,l.zip=Tp,l.zipObject=xp,l.zipObjectDeep=wp,l.zipWith=Ap,l.entries=Pa,l.entriesIn=Fa,l.extend=La,l.extendWith=zr,Os(l,l),l.add=T_,l.attempt=$a,l.camelCase=I0,l.capitalize=Ua,l.ceil=x_,l.clamp=x0,l.clone=_g,l.cloneDeep=yg,l.cloneDeepWith=mg,l.cloneWith=vg,l.conformsTo=Eg,l.deburr=Ba,l.defaultTo=e_,l.divide=w_,l.endsWith=S0,l.eq=ot,l.escape=O0,l.escapeRegExp=b0,l.every=Mp,l.find=Fp,l.findIndex=fa,l.findKey=Kg,l.findLast=Up,l.findLastIndex=la,l.findLastKey=Qg,l.floor=A_,l.forEach=va,l.forEachRight=ya,l.forIn=jg,l.forInRight=Zg,l.forOwn=e0,l.forOwnRight=t0,l.get=xs,l.gt=Tg,l.gte=xg,l.has=i0,l.hasIn=ws,l.head=da,l.identity=Fe,l.includes=Hp,l.indexOf=Ud,l.inRange=w0,l.invoke=u0,l.isArguments=Vt,l.isArray=V,l.isArrayBuffer=wg,l.isArrayLike=Me,l.isArrayLikeObject=pe,l.isBoolean=Ag,l.isBuffer=Lt,l.isDate=Ig,l.isElement=Sg,l.isEmpty=Og,l.isEqual=bg,l.isEqualWith=Cg,l.isError=Es,l.isFinite=Rg,l.isFunction=Tt,l.isInteger=Sa,l.isLength=Gr,l.isMap=Oa,l.isMatch=Ng,l.isMatchWith=Dg,l.isNaN=Lg,l.isNative=kg,l.isNil=Pg,l.isNull=Mg,l.isNumber=ba,l.isObject=he,l.isObjectLike=de,l.isPlainObject=Jn,l.isRegExp=Ts,l.isSafeInteger=Fg,l.isSet=Ca,l.isString=Vr,l.isSymbol=He,l.isTypedArray=ln,l.isUndefined=Ug,l.isWeakMap=Bg,l.isWeakSet=qg,l.join=Hd,l.kebabCase=C0,l.last=Ze,l.lastIndexOf=Gd,l.lowerCase=R0,l.lowerFirst=N0,l.lt=$g,l.lte=Wg,l.max=I_,l.maxBy=S_,l.mean=O_,l.meanBy=b_,l.min=C_,l.minBy=R_,l.stubArray=Cs,l.stubFalse=Rs,l.stubObject=g_,l.stubString=__,l.stubTrue=v_,l.multiply=N_,l.nth=Vd,l.noConflict=u_,l.noop=bs,l.now=$r,l.pad=D0,l.padEnd=L0,l.padStart=k0,l.parseInt=M0,l.random=A0,l.reduce=Jp,l.reduceRight=Xp,l.repeat=P0,l.replace=F0,l.result=p0,l.round=D_,l.runInContext=v,l.sample=Qp,l.size=eg,l.snakeCase=U0,l.some=tg,l.sortedIndex=jd,l.sortedIndexBy=Zd,l.sortedIndexOf=ep,l.sortedLastIndex=tp,l.sortedLastIndexBy=np,l.sortedLastIndexOf=rp,l.startCase=q0,l.startsWith=$0,l.subtract=L_,l.sum=k_,l.sumBy=M_,l.template=W0,l.times=y_,l.toFinite=xt,l.toInteger=z,l.toLength=Na,l.toLower=H0,l.toNumber=et,l.toSafeInteger=Hg,l.toString=te,l.toUpper=G0,l.trim=V0,l.trimEnd=z0,l.trimStart=Y0,l.truncate=J0,l.unescape=X0,l.uniqueId=E_,l.upperCase=K0,l.upperFirst=As,l.each=va,l.eachRight=ya,l.first=da,Os(l,function(){var e={};return ft(l,function(t,s){re.call(l.prototype,s)||(e[s]=t)}),e}(),{chain:!1}),l.VERSION=o,Je(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){l[e].placeholder=l}),Je(["drop","take"],function(e,t){Q.prototype[e]=function(s){s=s===r?1:ye(z(s),0);var u=this.__filtered__&&!t?new Q(this):this.clone();return u.__filtered__?u.__takeCount__=Se(s,u.__takeCount__):u.__views__.push({size:Se(s,Ie),type:e+(u.__dir__<0?"Right":"")}),u},Q.prototype[e+"Right"]=function(s){return this.reverse()[e](s).reverse()}}),Je(["filter","map","takeWhile"],function(e,t){var s=t+1,u=s==w||s==Y;Q.prototype[e]=function(c){var h=this.clone();return h.__iteratees__.push({iteratee:B(c,3),type:s}),h.__filtered__=h.__filtered__||u,h}}),Je(["head","last"],function(e,t){var s="take"+(t?"Right":"");Q.prototype[e]=function(){return this[s](1).value()[0]}}),Je(["initial","tail"],function(e,t){var s="drop"+(t?"":"Right");Q.prototype[e]=function(){return this.__filtered__?new Q(this):this[s](1)}}),Q.prototype.compact=function(){return this.filter(Fe)},Q.prototype.find=function(e){return this.filter(e).head()},Q.prototype.findLast=function(e){return this.reverse().find(e)},Q.prototype.invokeMap=X(function(e,t){return typeof e=="function"?new Q(this):this.map(function(s){return Wn(s,e,t)})}),Q.prototype.reject=function(e){return this.filter(Hr(B(e)))},Q.prototype.slice=function(e,t){e=z(e);var s=this;return s.__filtered__&&(e>0||t<0)?new Q(s):(e<0?s=s.takeRight(-e):e&&(s=s.drop(e)),t!==r&&(t=z(t),s=t<0?s.dropRight(-t):s.take(t-e)),s)},Q.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Q.prototype.toArray=function(){return this.take(Ie)},ft(Q.prototype,function(e,t){var s=/^(?:filter|find|map|reject)|While$/.test(t),u=/^(?:head|last)$/.test(t),c=l[u?"take"+(t=="last"?"Right":""):t],h=u||/^find/.test(t);c&&(l.prototype[t]=function(){var p=this.__wrapped__,_=u?[1]:arguments,y=p instanceof Q,O=_[0],b=y||V(p),N=function(K){var Z=c.apply(l,St([K],_));return u&&k?Z[0]:Z};b&&s&&typeof O=="function"&&O.length!=1&&(y=b=!1);var k=this.__chain__,U=!!this.__actions__.length,q=h&&!k,J=y&&!U;if(!h&&b){p=J?p:new Q(this);var $=e.apply(p,_);return $.__actions__.push({func:Br,args:[N],thisArg:r}),new Ke($,k)}return q&&J?e.apply(this,_):($=this.thru(N),q?u?$.value()[0]:$.value():$)})}),Je(["pop","push","shift","sort","splice","unshift"],function(e){var t=lr[e],s=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",u=/^(?:pop|shift)$/.test(e);l.prototype[e]=function(){var c=arguments;if(u&&!this.__chain__){var h=this.value();return t.apply(V(h)?h:[],c)}return this[s](function(p){return t.apply(V(p)?p:[],c)})}}),ft(Q.prototype,function(e,t){var s=l[t];if(s){var u=s.name+"";re.call(on,u)||(on[u]=[]),on[u].push({name:t,func:s})}}),on[Dr(r,ie).name]=[{name:"wrapper",func:r}],Q.prototype.clone=Xl,Q.prototype.reverse=Kl,Q.prototype.value=Ql,l.prototype.at=Sp,l.prototype.chain=Op,l.prototype.commit=bp,l.prototype.next=Cp,l.prototype.plant=Np,l.prototype.reverse=Dp,l.prototype.toJSON=l.prototype.valueOf=l.prototype.value=Lp,l.prototype.first=l.prototype.head,Mn&&(l.prototype[Mn]=Rp),l},nn=bl();Ft?((Ft.exports=nn)._=nn,Si._=nn):we._=nn}).call(_n)})(ni,ni.exports);var kc=ni.exports;function jv({context:n,event:i}){if(!i.type.includes("xstate.done.actor"))return n;const r=i;return r.output.type!=="ADD_ITEMS_SUCCESS"?n:kc.merge(n.quote,r.output.quote)}function Zv({context:n,event:i}){if(!i.type.includes("xstate.done.actor"))return n;const r=i;return r.output.type!=="REMOVE_ITEMS_SUCCESS"?n:{...n.quote,...r.output.quote}}function ey({context:n,event:i}){if(!i.type.includes("xstate.done.actor"))return n;const r=i;return r.output.type!=="REFRESH_SUCCESS"?n:kc.merge(n.quote,r.output.quote)}const ao=JSON,ty=n=>n.toUpperCase(),ny=n=>{const i={};return n.forEach((r,o)=>{i[o]=r}),i},ry=(n,i,r)=>n.document?n:{document:n,variables:i,requestHeaders:r,signal:void 0},iy=(n,i,r)=>n.query?n:{query:n,variables:i,requestHeaders:r,signal:void 0},sy=(n,i)=>n.documents?n:{documents:n,requestHeaders:i,signal:void 0},oy=(n,i,...r)=>{const[o,a]=r;return n.document?n:{url:n,document:i,variables:o,requestHeaders:a,signal:void 0}};function Kr(n,i){if(!!!n)throw new Error(i)}function uy(n){return typeof n=="object"&&n!==null}function ay(n,i){if(!!!n)throw new Error(i??"Unexpected invariant triggered.")}const cy=/\r\n|[\n\r]/g;function Gs(n,i){let r=0,o=1;for(const a of n.body.matchAll(cy)){if(typeof a.index=="number"||ay(!1),a.index>=i)break;r=a.index+a[0].length,o+=1}return{line:o,column:i+1-r}}function fy(n){return Mc(n.source,Gs(n.source,n.start))}function Mc(n,i){const r=n.locationOffset.column-1,o="".padStart(r)+n.body,a=i.line-1,f=n.locationOffset.line-1,d=i.line+f,g=i.line===1?r:0,m=i.column+g,E=`${n.name}:${d}:${m}
30
- `,I=o.split(/\r\n|[\n\r]/g),x=I[a];if(x.length>120){const S=Math.floor(m/80),D=m%80,R=[];for(let F=0;F<x.length;F+=80)R.push(x.slice(F,F+80));return E+oc([[`${d} |`,R[0]],...R.slice(1,S+1).map(F=>["|",F]),["|","^".padStart(D)],["|",R[S+1]]])}return E+oc([[`${d-1} |`,I[a-1]],[`${d} |`,x],["|","^".padStart(m)],[`${d+1} |`,I[a+1]]])}function oc(n){const i=n.filter(([o,a])=>a!==void 0),r=Math.max(...i.map(([o])=>o.length));return i.map(([o,a])=>o.padStart(r)+(a?" "+a:"")).join(`
31
- `)}function ly(n){const i=n[0];return i==null||"kind"in i||"length"in i?{nodes:i,source:n[1],positions:n[2],path:n[3],originalError:n[4],extensions:n[5]}:i}class co extends Error{constructor(i,...r){var o,a,f;const{nodes:d,source:g,positions:m,path:E,originalError:I,extensions:x}=ly(r);super(i),this.name="GraphQLError",this.path=E??void 0,this.originalError=I??void 0,this.nodes=uc(Array.isArray(d)?d:d?[d]:void 0);const S=uc((o=this.nodes)===null||o===void 0?void 0:o.map(R=>R.loc).filter(R=>R!=null));this.source=g??(S==null||(a=S[0])===null||a===void 0?void 0:a.source),this.positions=m??(S==null?void 0:S.map(R=>R.start)),this.locations=m&&g?m.map(R=>Gs(g,R)):S==null?void 0:S.map(R=>Gs(R.source,R.start));const D=uy(I==null?void 0:I.extensions)?I==null?void 0:I.extensions:void 0;this.extensions=(f=x??D)!==null&&f!==void 0?f:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),I!=null&&I.stack?Object.defineProperty(this,"stack",{value:I.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,co):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let i=this.message;if(this.nodes)for(const r of this.nodes)r.loc&&(i+=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ye=require("react/jsx-runtime"),P=require("react");function En(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in e)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function vn(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function Tn(){const e=vn();if(e.__xstate__)return e.__xstate__}const _n=e=>{if(typeof window>"u")return;const t=Tn();t&&t.register(e)};class lt{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){const n={value:t,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){const t=this._current;this._process(t.value),this._current=t.next}this._last=null}}const Lt=".",In="",Mt="",Sn="#",xn="*",Pt="xstate.init",An="xstate.error",ce="xstate.stop";function wn(e,t){return{type:`xstate.after.${e}.${t}`}}function Fe(e,t){return{type:`xstate.done.state.${e}`,output:t}}function bn(e,t){return{type:`xstate.done.actor.${e}`,output:t}}function qt(e,t){return{type:`xstate.error.actor.${e}`,error:t}}function Ft(e){return{type:Pt,input:e}}function F(e){setTimeout(()=>{throw e})}const On=(()=>typeof Symbol=="function"&&Symbol.observable||"@@observable")();function ht(e,t){return`${e.sessionId}.${t}`}let Nn=0;function kn(e,t){const n=new Map,s=new Map,r=new WeakMap,i=new Set,o={},{clock:a,logger:c}=t,u={schedule:(f,m,y,v,S=Math.random().toString(36).slice(2))=>{const A={source:f,target:m,event:y,delay:v,id:S,startedAt:Date.now()},R=ht(f,S);d._snapshot._scheduledEvents[R]=A;const D=a.setTimeout(()=>{delete o[R],delete d._snapshot._scheduledEvents[R],d._relay(f,m,y)},v);o[R]=D},cancel:(f,m)=>{const y=ht(f,m),v=o[y];delete o[y],delete d._snapshot._scheduledEvents[y],a.clearTimeout(v)},cancelAll:f=>{for(const m in d._snapshot._scheduledEvents){const y=d._snapshot._scheduledEvents[m];y.source===f&&u.cancel(f,y.id)}}},h=f=>{if(!i.size)return;const m={...f,rootId:e.sessionId};i.forEach(y=>{var v;return(v=y.next)==null?void 0:v.call(y,m)})},d={_snapshot:{_scheduledEvents:((t==null?void 0:t.snapshot)&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${Nn++}`,_register:(f,m)=>(n.set(f,m),f),_unregister:f=>{n.delete(f.sessionId);const m=r.get(f);m!==void 0&&(s.delete(m),r.delete(f))},get:f=>s.get(f),_set:(f,m)=>{const y=s.get(f);if(y&&y!==m)throw new Error(`Actor with system ID '${f}' already exists.`);s.set(f,m),r.set(m,f)},inspect:f=>{i.add(f)},_sendInspectionEvent:h,_relay:(f,m,y)=>{d._sendInspectionEvent({type:"@xstate.event",sourceRef:f,actorRef:m,event:y}),m._send(y)},scheduler:u,getSnapshot:()=>({_scheduledEvents:{...d._snapshot._scheduledEvents}}),start:()=>{const f=d._snapshot._scheduledEvents;d._snapshot._scheduledEvents={};for(const m in f){const{source:y,target:v,event:S,delay:A,id:R}=f[m];u.schedule(y,v,S,A,R)}},_clock:a,_logger:c};return d}function Ut(e,t){const n=ft(e),s=ft(t);return typeof s=="string"?typeof n=="string"?s===n:!1:typeof n=="string"?n in s:Object.keys(n).every(r=>r in s?Ut(n[r],s[r]):!1)}function Qe(e){if(jt(e))return e;let t=[],n="";for(let s=0;s<e.length;s++){switch(e.charCodeAt(s)){case 92:n+=e[s+1],s++;continue;case 46:t.push(n),n="";continue}n+=e[s]}return t.push(n),t}function ft(e){if(as(e))return e.value;if(typeof e!="string")return e;const t=Qe(e);return Cn(t)}function Cn(e){if(e.length===1)return e[0];const t={};let n=t;for(let s=0;s<e.length-1;s++)if(s===e.length-2)n[e[s]]=e[s+1];else{const r=n;n={},r[e[s]]=n}return t}function pt(e,t){const n={},s=Object.keys(e);for(let r=0;r<s.length;r++){const i=s[r];n[i]=t(e[i],i,e,r)}return n}function Bt(e){return jt(e)?e:[e]}function U(e){return e===void 0?[]:Bt(e)}function Ue(e,t,n,s){return typeof e=="function"?e({context:t,event:n,self:s}):e}function jt(e){return Array.isArray(e)}function Dn(e){return e.type.startsWith("xstate.error.actor")}function X(e){return Bt(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function $t(e){if(!(e===void 0||e===In))return U(e)}function yt(e,t,n){var i,o,a;const s=typeof e=="object",r=s?e:void 0;return{next:(i=s?e.next:e)==null?void 0:i.bind(r),error:(o=s?e.error:t)==null?void 0:o.bind(r),complete:(a=s?e.complete:n)==null?void 0:a.bind(r)}}function mt(e,t){return`${t}.${e}`}function Xe(e,t){const n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];const[,s,r]=n,o=e.getStateNodeById(r).config.invoke;return(Array.isArray(o)?o[s]:o).src}const We=1;let k=function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e}({});const Rn={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1};class Ln{constructor(t,n){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new lt(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=k.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 s={...Rn,...n},{clock:r,logger:i,parent:o,syncSnapshot:a,id:c,systemId:u,inspect:h}=s;this.system=o?o.system:kn(this,{clock:r,logger:i}),h&&!o&&this.system.inspect(yt(h)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=(n==null?void 0:n.logger)??this.system._logger,this.clock=(n==null?void 0:n.clock)??this.system._clock,this._parent=o,this._syncSnapshot=a,this.options=s,this.src=s.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:d=>{this._deferred.push(d)},system:this.system,stopChild:d=>{if(d._parent!==this)throw new Error(`Cannot stop child actor ${d.id} of ${this.id} because it is not a child`);d._stop()},emit:d=>{const f=this.eventListeners.get(d.type);if(f)for(const m of Array.from(f))m(d)}},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((n==null?void 0:n.snapshot)??(n==null?void 0:n.state)),u&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){var n;try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,(n=this.options)==null?void 0:n.input)}catch(s){this._snapshot={status:"error",output:void 0,error:s}}}update(t,n){var r,i;this._snapshot=t;let s;for(;s=this._deferred.shift();)try{s()}catch(o){this._deferred.length=0,this._snapshot={...t,status:"error",error:o}}switch(this._snapshot.status){case"active":for(const o of this.observers)try{(r=o.next)==null||r.call(o,t)}catch(a){F(a)}break;case"done":for(const o of this.observers)try{(i=o.next)==null||i.call(o,t)}catch(a){F(a)}this._stopProcedure(),this._complete(),this._doneEvent=bn(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:t})}subscribe(t,n,s){var i;const r=yt(t,n,s);if(this._processingStatus!==k.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{(i=r.complete)==null||i.call(r)}catch(o){F(o)}break;case"error":{const o=this._snapshot.error;if(!r.error)F(o);else try{r.error(o)}catch(a){F(a)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(t,n){let s=this.eventListeners.get(t);s||(s=new Set,this.eventListeners.set(t,s));const r=n.bind(void 0);return s.add(r),{unsubscribe:()=>{s.delete(r)}}}start(){if(this._processingStatus===k.Running)return this;this._syncSnapshot&&this.subscribe({next:s=>{s.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:s})},error:()=>{}}),this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this._processingStatus=k.Running;const t=Ft(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(s){return this._snapshot={...this._snapshot,status:"error",error:s},this._error(s),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let n,s;try{n=this.logic.transition(this._snapshot,t,this._actorScope)}catch(r){s={err:r}}if(s){const{err:r}=s;this._snapshot={...this._snapshot,status:"error",error:r},this._error(r);return}this.update(n,t),t.type===ce&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===k.Stopped?this:(this.mailbox.clear(),this._processingStatus===k.NotStarted?(this._processingStatus=k.Stopped,this):(this.mailbox.enqueue({type:ce}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){var t;for(const n of this.observers)try{(t=n.complete)==null||t.call(n)}catch(s){F(s)}this.observers.clear()}_reportError(t){if(!this.observers.size){this._parent||F(t);return}let n=!1;for(const s of this.observers){const r=s.error;n||(n=!r);try{r==null||r(t)}catch(i){F(i)}}this.observers.clear(),n&&F(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,qt(this.id,t))}_stopProcedure(){return this._processingStatus!==k.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new lt(this._process.bind(this)),this._processingStatus=k.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==k.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){const{devTools:t}=this.options;t&&(typeof t=="function"?t:_n)(this)}toJSON(){return{xstate$$type:We,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[On](){return this}getSnapshot(){return this._snapshot}}function B(e,...[t]){return new Ln(e,t)}function Mn(e,t,n,s,{sendId:r}){const i=typeof r=="function"?r(n,s):r;return[t,i]}function Pn(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t)})}function qn(e){function t(n,s){}return t.type="xstate.cancel",t.sendId=e,t.resolve=Mn,t.execute=Pn,t}function Fn(e,t,n,s,{id:r,systemId:i,src:o,input:a,syncSnapshot:c}){const u=typeof o=="string"?Xe(t.machine,o):o,h=typeof r=="function"?r(n):r;let d;return u&&(d=B(u,{id:h,src:o,parent:e.self,syncSnapshot:c,systemId:i,input:typeof a=="function"?a({context:t.context,event:n.event,self:e.self}):a})),[G(t,{children:{...t.children,[h]:d}}),{id:r,actorRef:d}]}function Un(e,{id:t,actorRef:n}){n&&e.defer(()=>{n._processingStatus!==k.Stopped&&n.start()})}function Bn(...[e,{id:t,systemId:n,input:s,syncSnapshot:r=!1}={}]){function i(o,a){}return i.type="snapshot.spawnChild",i.id=t,i.systemId=n,i.src=e,i.input=s,i.syncSnapshot=r,i.resolve=Fn,i.execute=Un,i}function jn(e,t,n,s,{actorRef:r}){const i=typeof r=="function"?r(n,s):r,o=typeof i=="string"?t.children[i]:i;let a=t.children;return o&&(a={...a},delete a[o.id]),[G(t,{children:a}),o]}function $n(e,t){if(t){if(e.system._unregister(t),t._processingStatus!==k.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Vt(e){function t(n,s){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=jn,t.execute=$n,t}function Ke(e,t,n,s){const{machine:r}=s,i=typeof e=="function",o=i?e:r.implementations.guards[typeof e=="string"?e:e.type];if(!i&&!o)throw new Error(`Guard '${typeof e=="string"?e:e.type}' is not implemented.'.`);if(typeof o!="function")return Ke(o,t,n,s);const a={context:t,event:n},c=i||typeof e=="string"?void 0:"params"in e?typeof e.params=="function"?e.params({context:t,event:n}):e.params:void 0;return"check"in o?o.check(s,a,o):o(a,c)}const Ze=e=>e.type==="atomic"||e.type==="final";function ee(e){return Object.values(e.states).filter(t=>t.type!=="history")}function de(e,t){const n=[];if(t===e)return n;let s=e.parent;for(;s&&s!==t;)n.push(s),s=s.parent;return n}function Te(e){const t=new Set(e),n=Gt(t);for(const s of t)if(s.type==="compound"&&(!n.get(s)||!n.get(s).length))gt(s).forEach(r=>t.add(r));else if(s.type==="parallel"){for(const r of ee(s))if(r.type!=="history"&&!t.has(r)){const i=gt(r);for(const o of i)t.add(o)}}for(const s of t){let r=s.parent;for(;r;)t.add(r),r=r.parent}return t}function Ht(e,t){const n=t.get(e);if(!n)return{};if(e.type==="compound"){const r=n[0];if(r){if(Ze(r))return r.key}else return{}}const s={};for(const r of n)s[r.key]=Ht(r,t);return s}function Gt(e){const t=new Map;for(const n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function zt(e,t){const n=Te(t);return Ht(e,Gt(n))}function et(e,t){return t.type==="compound"?ee(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?ee(t).every(n=>et(e,n)):t.type==="final"}const xe=e=>e[0]===Sn;function Vn(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(s=>{if(s===xn)return!0;if(!s.endsWith(".*"))return!1;const r=s.split("."),i=t.split(".");for(let o=0;o<r.length;o++){const a=r[o],c=i[o];if(a==="*")return o===r.length-1;if(a!==c)return!1}return!0}).sort((s,r)=>r.length-s.length).flatMap(s=>e.transitions.get(s))}function Hn(e){const t=e.config.after;if(!t)return[];const n=(r,i)=>{const o=wn(r,e.id),a=o.type;return e.entry.push(ms(o,{id:a,delay:r})),e.exit.push(qn(a)),a};return Object.keys(t).flatMap((r,i)=>{const o=t[r],a=typeof o=="string"?{target:o}:o,c=Number.isNaN(+r)?r:+r,u=n(c);return U(a).map(h=>({...h,event:u,delay:c}))}).map(r=>{const{delay:i}=r;return{...V(e,r.event,r),delay:i}})}function V(e,t,n){const s=$t(n.target),r=n.reenter??!1,i=Jn(e,s),o={...n,actions:U(n.actions),guard:n.guard,target:i,source:e,reenter:r,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:i?i.map(a=>`#${a.id}`):void 0})};return o}function Gn(e){const t=new Map;if(e.config.on)for(const n of Object.keys(e.config.on)){if(n===Mt)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const s=e.config.on[n];t.set(n,X(s).map(r=>V(e,n,r)))}if(e.config.onDone){const n=`xstate.done.state.${e.id}`;t.set(n,X(e.config.onDone).map(s=>V(e,n,s)))}for(const n of e.invoke){if(n.onDone){const s=`xstate.done.actor.${n.id}`;t.set(s,X(n.onDone).map(r=>V(e,s,r)))}if(n.onError){const s=`xstate.error.actor.${n.id}`;t.set(s,X(n.onError).map(r=>V(e,s,r)))}if(n.onSnapshot){const s=`xstate.snapshot.${n.id}`;t.set(s,X(n.onSnapshot).map(r=>V(e,s,r)))}}for(const n of e.after){let s=t.get(n.eventType);s||(s=[],t.set(n.eventType,s)),s.push(n)}return t}function zn(e,t){const n=typeof t=="string"?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);const s={source:e,actions:!t||typeof t=="string"?[]:U(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...s,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return s}function Jn(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(xe(n))return e.machine.getStateNodeById(n);const s=n[0]===Lt;if(s&&!e.parent)return _e(e,n.slice(1));const r=s?e.key+n:n;if(e.parent)try{return _e(e.parent,r)}catch(i){throw new Error(`Invalid transition definition for state node '${e.id}':
2
+ ${i.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function Jt(e){const t=$t(e.config.target);return t?{target:t.map(n=>typeof n=="string"?_e(e.parent,n):n)}:e.parent.initial}function H(e){return e.type==="history"}function gt(e){const t=Yt(e);for(const n of t)for(const s of de(n,e))t.add(s);return t}function Yt(e){const t=new Set;function n(s){if(!t.has(s)){if(t.add(s),s.type==="compound")n(s.initial.target[0]);else if(s.type==="parallel")for(const r of ee(s))n(r)}}return n(e),t}function te(e,t){if(xe(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);const n=e.states[t];if(!n)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function _e(e,t){if(typeof t=="string"&&xe(t))try{return e.machine.getStateNodeById(t)}catch{}const n=Qe(t).slice();let s=e;for(;n.length;){const r=n.shift();if(!r.length)break;s=te(s,r)}return s}function Ie(e,t){if(typeof t=="string"){const r=e.states[t];if(!r)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,r]}const n=Object.keys(t),s=n.map(r=>te(e,r)).filter(Boolean);return[e.machine.root,e].concat(s,n.reduce((r,i)=>{const o=te(e,i);if(!o)return r;const a=Ie(o,t[i]);return r.concat(a)},[]))}function Yn(e,t,n,s){const i=te(e,t).next(n,s);return!i||!i.length?e.next(n,s):i}function Qn(e,t,n,s){const r=Object.keys(t),i=te(e,r[0]),o=tt(i,t[r[0]],n,s);return!o||!o.length?e.next(n,s):o}function Xn(e,t,n,s){const r=[];for(const i of Object.keys(t)){const o=t[i];if(!o)continue;const a=te(e,i),c=tt(a,o,n,s);c&&r.push(...c)}return r.length?r:e.next(n,s)}function tt(e,t,n,s){return typeof t=="string"?Yn(e,t,n,s):Object.keys(t).length===1?Qn(e,t,n,s):Xn(e,t,n,s)}function Wn(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function j(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function Kn(e,t){const n=new Set(e),s=new Set(t);for(const r of n)if(s.has(r))return!0;for(const r of s)if(n.has(r))return!0;return!1}function Qt(e,t,n){const s=new Set;for(const r of e){let i=!1;const o=new Set;for(const a of s)if(Kn(Be([r],t,n),Be([a],t,n)))if(j(r.source,a.source))o.add(a);else{i=!0;break}if(!i){for(const a of o)s.delete(a);s.add(r)}}return Array.from(s)}function Zn(e){const[t,...n]=e;for(const s of de(t,void 0))if(n.every(r=>j(r,s)))return s}function nt(e,t){if(!e.target)return[];const n=new Set;for(const s of e.target)if(H(s))if(t[s.id])for(const r of t[s.id])n.add(r);else for(const r of nt(Jt(s),t))n.add(r);else n.add(s);return[...n]}function Xt(e,t){const n=nt(e,t);if(!n)return;if(!e.reenter&&n.every(r=>r===e.source||j(r,e.source)))return e.source;const s=Zn(n.concat(e.source));if(s)return s;if(!e.reenter)return e.source.machine.root}function Be(e,t,n){var r;const s=new Set;for(const i of e)if((r=i.target)!=null&&r.length){const o=Xt(i,n);i.reenter&&i.source===o&&s.add(o);for(const a of t)j(a,o)&&s.add(a)}return[...s]}function es(e,t){if(e.length!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function je(e,t,n,s,r,i){if(!e.length)return t;const o=new Set(t._nodes);let a=t.historyValue;const c=Qt(e,o,a);let u=t;r||([u,a]=rs(u,s,n,c,o,a,i)),u=ne(u,s,n,c.flatMap(d=>d.actions),i),u=ns(u,s,n,c,o,i,a,r);const h=[...o];u.status==="done"&&(u=ne(u,s,n,h.sort((d,f)=>f.order-d.order).flatMap(d=>d.exit),i));try{return a===t.historyValue&&es(t._nodes,o)?u:G(u,{_nodes:h,historyValue:a})}catch(d){throw d}}function ts(e,t,n,s,r){if(s.output===void 0)return;const i=Fe(r.id,r.output!==void 0&&r.parent?Ue(r.output,e.context,t,n.self):void 0);return Ue(s.output,e.context,i,n.self)}function ns(e,t,n,s,r,i,o,a){let c=e;const u=new Set,h=new Set;ss(s,o,h,u),a&&h.add(e.machine.root);const d=new Set;for(const f of[...u].sort((m,y)=>m.order-y.order)){r.add(f);const m=[];m.push(...f.entry);for(const y of f.invoke)m.push(Bn(y.src,{...y,syncSnapshot:!!y.onSnapshot}));if(h.has(f)){const y=f.initial.actions;m.push(...y)}if(c=ne(c,t,n,m,i,f.invoke.map(y=>y.id)),f.type==="final"){const y=f.parent;let v=(y==null?void 0:y.type)==="parallel"?y:y==null?void 0:y.parent,S=v||f;for((y==null?void 0:y.type)==="compound"&&i.push(Fe(y.id,f.output!==void 0?Ue(f.output,c.context,t,n.self):void 0));(v==null?void 0:v.type)==="parallel"&&!d.has(v)&&et(r,v);)d.add(v),i.push(Fe(v.id)),S=v,v=v.parent;if(v)continue;c=G(c,{status:"done",output:ts(c,t,n,c.machine.root,S)})}}return c}function ss(e,t,n,s){for(const r of e){const i=Xt(r,t);for(const a of r.target||[])!H(a)&&(r.source!==a||r.source!==i||r.reenter)&&(s.add(a),n.add(a)),W(a,t,n,s);const o=nt(r,t);for(const a of o){const c=de(a,i);(i==null?void 0:i.type)==="parallel"&&c.push(i),Wt(s,t,n,c,!r.source.parent&&r.reenter?void 0:i)}}}function W(e,t,n,s){var r;if(H(e))if(t[e.id]){const i=t[e.id];for(const o of i)s.add(o),W(o,t,n,s);for(const o of i)ke(o,e.parent,s,t,n)}else{const i=Jt(e);for(const o of i.target)s.add(o),i===((r=e.parent)==null?void 0:r.initial)&&n.add(e.parent),W(o,t,n,s);for(const o of i.target)ke(o,e.parent,s,t,n)}else if(e.type==="compound"){const[i]=e.initial.target;H(i)||(s.add(i),n.add(i)),W(i,t,n,s),ke(i,e,s,t,n)}else if(e.type==="parallel")for(const i of ee(e).filter(o=>!H(o)))[...s].some(o=>j(o,i))||(H(i)||(s.add(i),n.add(i)),W(i,t,n,s))}function Wt(e,t,n,s,r){for(const i of s)if((!r||j(i,r))&&e.add(i),i.type==="parallel")for(const o of ee(i).filter(a=>!H(a)))[...e].some(a=>j(a,o))||(e.add(o),W(o,t,n,e))}function ke(e,t,n,s,r){Wt(n,s,r,de(e,t))}function rs(e,t,n,s,r,i,o){let a=e;const c=Be(s,r,i);c.sort((h,d)=>d.order-h.order);let u;for(const h of c)for(const d of Wn(h)){let f;d.history==="deep"?f=m=>Ze(m)&&j(m,h):f=m=>m.parent===h,u??(u={...i}),u[d.id]=Array.from(r).filter(f)}for(const h of c)a=ne(a,t,n,[...h.exit,...h.invoke.map(d=>Vt(d.id))],o),r.delete(h);return[a,u||i]}let Et=!1;function Kt(e,t,n,s,r,i){const{machine:o}=e;let a=e;for(const c of s){let m=function(){n.system._sendInspectionEvent({type:"@xstate.action",actorRef:n.self,action:{type:typeof c=="string"?c:typeof c=="object"?c.type:c.name||"(anonymous)",params:f}});try{Et=h,h(d,f)}finally{Et=!1}};const u=typeof c=="function",h=u?c:o.implementations.actions[typeof c=="string"?c:c.type];if(!h)continue;const d={context:a.context,event:t,self:n.self,system:n.system},f=u||typeof c=="string"?void 0:"params"in c?typeof c.params=="function"?c.params({context:a.context,event:t}):c.params:void 0;if(!("resolve"in h)){n.self._processingStatus===k.Running?m():n.defer(()=>{m()});continue}const y=h,[v,S,A]=y.resolve(n,a,d,f,h,r);a=v,"retryResolve"in y&&(i==null||i.push([y,S])),"execute"in y&&(n.self._processingStatus===k.Running?y.execute(n,S):n.defer(y.execute.bind(null,n,S))),A&&(a=Kt(a,t,n,A,r,i))}return a}function ne(e,t,n,s,r,i){const o=i?[]:void 0,a=Kt(e,t,n,s,{internalQueue:r,deferredActorIds:i},o);return o==null||o.forEach(([c,u])=>{c.retryResolve(n,a,u)}),a}function Ce(e,t,n,s=[]){let r=e;const i=[];function o(u,h,d){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:h,snapshot:u,_transitions:d}),i.push(u)}if(t.type===ce)return r=G(vt(r,t,n),{status:"stopped"}),o(r,t,[]),{snapshot:r,microstates:i};let a=t;if(a.type!==Pt){const u=a,h=Dn(u),d=Tt(u,r);if(h&&!d.length)return r=G(e,{status:"error",error:u.error}),o(r,u,[]),{snapshot:r,microstates:i};r=je(d,e,n,a,!1,s),o(r,u,d)}let c=!0;for(;r.status==="active";){let u=c?is(r,a):[];const h=u.length?r:void 0;if(!u.length){if(!s.length)break;a=s.shift(),u=Tt(a,r)}r=je(u,r,n,a,!1,s),c=r!==h,o(r,a,u)}return r.status!=="active"&&vt(r,a,n),{snapshot:r,microstates:i}}function vt(e,t,n){return ne(e,t,n,Object.values(e.children).map(s=>Vt(s)),[])}function Tt(e,t){return t.machine.getTransitionData(t,e)}function is(e,t){const n=new Set,s=e._nodes.filter(Ze);for(const r of s)e:for(const i of[r].concat(de(r,void 0)))if(i.always){for(const o of i.always)if(o.guard===void 0||Ke(o.guard,e.context,t,e)){n.add(o);break e}}return Qt(Array.from(n),new Set(e._nodes),e.historyValue)}function os(e,t){const n=Te(Ie(e,t));return zt(e,[...n])}function as(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}const cs=function(t){return Ut(t,this.value)},us=function(t){return this.tags.has(t)},ds=function(t){const n=this.machine.getTransitionData(this,t);return!!(n!=null&&n.length)&&n.some(s=>s.target!==void 0||s.actions.length)},ls=function(){const{_nodes:t,tags:n,machine:s,getMeta:r,toJSON:i,can:o,hasTag:a,matches:c,...u}=this;return{...u,tags:Array.from(n)}},hs=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function me(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:zt(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:cs,hasTag:us,can:ds,getMeta:hs,toJSON:ls}}function G(e,t={}){return me({...e,...t},e.machine)}function fs(e,t){const{_nodes:n,tags:s,machine:r,children:i,context:o,can:a,hasTag:c,matches:u,getMeta:h,toJSON:d,...f}=e,m={};for(const v in i){const S=i[v];m[v]={snapshot:S.getPersistedSnapshot(t),src:S.src,systemId:S._systemId,syncSnapshot:S._syncSnapshot}}return{...f,context:Zt(o),children:m}}function Zt(e){let t;for(const n in e){const s=e[n];if(s&&typeof s=="object")if("sessionId"in s&&"send"in s&&"ref"in s)t??(t=Array.isArray(e)?e.slice():{...e}),t[n]={xstate$$type:We,id:s.id};else{const r=Zt(s);r!==s&&(t??(t=Array.isArray(e)?e.slice():{...e}),t[n]=r)}}return t??e}function ps(e,t,n,s,{event:r,id:i,delay:o},{internalQueue:a}){const c=t.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${r}" }) instead`);const u=typeof r=="function"?r(n,s):r;let h;if(typeof o=="string"){const d=c&&c[o];h=typeof d=="function"?d(n,s):d}else h=typeof o=="function"?o(n,s):o;return typeof h!="number"&&a.push(u),[t,{event:u,id:i,delay:h}]}function ys(e,t){const{event:n,delay:s,id:r}=t;if(typeof s=="number"){e.defer(()=>{const i=e.self;e.system.scheduler.schedule(i,i,n,s,r)});return}}function ms(e,t){function n(s,r){}return n.type="xstate.raise",n.event=e,n.id=t==null?void 0:t.id,n.delay=t==null?void 0:t.delay,n.resolve=ps,n.execute=ys,n}const _t=new WeakMap;function gs(e){return{config:e,start:(n,s)=>{const{self:r,system:i}=s,o={receivers:void 0,dispose:void 0};_t.set(r,o),o.dispose=e({input:n.input,system:i,self:r,sendBack:a=>{r.getSnapshot().status!=="stopped"&&r._parent&&i._relay(r,r._parent,a)},receive:a=>{o.receivers??(o.receivers=new Set),o.receivers.add(a)}})},transition:(n,s,r)=>{var o,a;const i=_t.get(r.self);return s.type===ce?(n={...n,status:"stopped",error:void 0},(o=i.dispose)==null||o.call(i),n):((a=i.receivers)==null||a.forEach(c=>c(s)),n)},getInitialSnapshot:(n,s)=>({status:"active",output:void 0,error:void 0,input:s}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}const It="xstate.promise.resolve",St="xstate.promise.reject",pe=new WeakMap;function Z(e){return{config:e,transition:(n,s,r)=>{var i;if(n.status!=="active")return n;switch(s.type){case It:{const o=s.data;return{...n,status:"done",output:o,input:void 0}}case St:return{...n,status:"error",error:s.data,input:void 0};case ce:return(i=pe.get(r.self))==null||i.abort(),{...n,status:"stopped",input:void 0};default:return n}},start:(n,{self:s,system:r})=>{if(n.status!=="active")return;const i=new AbortController;pe.set(s,i),Promise.resolve(e({input:n.input,system:r,self:s,signal:i.signal})).then(a=>{s.getSnapshot().status==="active"&&(pe.delete(s),r._relay(s,s,{type:It,data:a}))},a=>{s.getSnapshot().status==="active"&&(pe.delete(s),r._relay(s,s,{type:St,data:a}))})},getInitialSnapshot:(n,s)=>({status:"active",output:void 0,error:void 0,input:s}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}function Es(e,{machine:t,context:n},s,r){const i=(o,a={})=>{const{systemId:c,input:u}=a;if(typeof o=="string"){const h=Xe(t,o);if(!h)throw new Error(`Actor logic '${o}' not implemented in machine '${t.id}'`);const d=B(h,{id:a.id,parent:e.self,syncSnapshot:a.syncSnapshot,input:typeof u=="function"?u({context:n,event:s,self:e.self}):u,src:o,systemId:c});return r[d.id]=d,d}else return B(o,{id:a.id,parent:e.self,syncSnapshot:a.syncSnapshot,input:a.input,src:o,systemId:c})};return(o,a)=>{const c=i(o,a);return r[c.id]=c,e.defer(()=>{c._processingStatus!==k.Stopped&&c.start()}),c}}function vs(e,t,n,s,{assignment:r}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const i={},o={context:t.context,event:n.event,spawn:Es(e,t,n.event,i),self:e.self,system:e.system};let a={};if(typeof r=="function")a=r(o,s);else for(const u of Object.keys(r)){const h=r[u];a[u]=typeof h=="function"?h(o,s):h}const c=Object.assign({},t.context,a);return[G(t,{context:c,children:Object.keys(i).length?{...t.children,...i}:t.children})]}function C(e){function t(n,s){}return t.type="xstate.assign",t.assignment=e,t.resolve=vs,t}let xt=function(e){return e.Parent="#_parent",e.Internal="#_internal",e}({});function Ts(e,t,n,s,{to:r,event:i,id:o,delay:a},c){var y;const u=t.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);const h=typeof i=="function"?i(n,s):i;let d;if(typeof a=="string"){const v=u&&u[a];d=typeof v=="function"?v(n,s):v}else d=typeof a=="function"?a(n,s):a;const f=typeof r=="function"?r(n,s):r;let m;if(typeof f=="string"){if(f===xt.Parent?m=e.self._parent:f===xt.Internal?m=e.self:f.startsWith("#_")?m=t.children[f.slice(2)]:m=(y=c.deferredActorIds)!=null&&y.includes(f)?f:t.children[f],!m)throw new Error(`Unable to send event to actor '${f}' from machine '${t.machine.id}'.`)}else m=f||e.self;return[t,{to:m,event:h,id:o,delay:d}]}function _s(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function Is(e,t){e.defer(()=>{const{to:n,event:s,delay:r,id:i}=t;if(typeof r=="number"){e.system.scheduler.schedule(e.self,n,s,r,i);return}e.system._relay(e.self,n,s.type===An?qt(e.self.id,s.data):s)})}function At(e,t,n){function s(r,i){}return s.type="xsnapshot.sendTo",s.to=e,s.event=t,s.id=n==null?void 0:n.id,s.delay=n==null?void 0:n.delay,s.resolve=Ts,s.retryResolve=_s,s.execute=Is,s}const wt=new WeakMap;function Y(e,t,n){let s=wt.get(e);return s?t in s||(s[t]=n()):(s={[t]:n()},wt.set(e,s)),s[t]}const Ss={},ie=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e;class st{constructor(t,n){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=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(Lt),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?pt(this.config.states,(s,r)=>new st(s,{_parent:this,_key:r,_machine:this.machine})):Ss,this.type==="compound"&&!this.config.initial)throw new 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=this.config.history===!0?"shallow":this.config.history||!1,this.entry=U(this.config.entry).slice(),this.exit=U(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=U(t.tags).slice()}_initialize(){this.transitions=Gn(this),this.config.always&&(this.always=X(this.config.always).map(t=>V(this,Mt,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(ie),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(ie),eventType:null})}:void 0,history:this.history,states:pt(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(ie)})),entry:this.entry.map(ie),exit:this.exit.map(ie),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 Y(this,"invoke",()=>U(this.config.invoke).map((t,n)=>{const{src:s,systemId:r}=t,i=t.id??mt(this.id,n),o=typeof s=="string"?s:`xstate.invoke.${mt(this.id,n)}`;return{...t,src:o,id:i,systemId:r,toJSON(){const{onDone:a,onError:c,...u}=t;return{...u,type:"xstate.invoke",src:o,id:i}}}}))}get on(){return Y(this,"on",()=>[...this.transitions].flatMap(([n,s])=>s.map(r=>[n,r])).reduce((n,[s,r])=>(n[s]=n[s]||[],n[s].push(r),n),{}))}get after(){return Y(this,"delayedTransitions",()=>Hn(this))}get initial(){return Y(this,"initial",()=>zn(this,this.config.initial))}next(t,n){const s=n.type,r=[];let i;const o=Y(this,`candidates-${s}`,()=>Vn(this,s));for(const a of o){const{guard:c}=a,u=t.context;let h=!1;try{h=!c||Ke(c,u,n,t)}catch(d){const f=typeof c=="string"?c:typeof c=="object"?c.type:void 0;throw new Error(`Unable to evaluate guard ${f?`'${f}' `:""}in transition for event '${s}' in state node '${this.id}':
3
+ ${d.message}`)}if(h){r.push(...a.actions),i=a;break}}return i?[i]:void 0}get events(){return Y(this,"events",()=>{const{states:t}=this,n=new Set(this.ownEvents);if(t)for(const s of Object.keys(t)){const r=t[s];if(r.states)for(const i of r.events)n.add(`${i}`)}return Array.from(n)})}get ownEvents(){const t=new Set([...this.transitions.keys()].filter(n=>this.transitions.get(n).some(s=>!(!s.target&&!s.actions.length&&!s.reenter))));return Array.from(t)}}const xs="#";class rt{constructor(t,n){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.__TResolvedTypesMeta=void 0,this.id=t.id||"(machine)",this.implementations={actors:(n==null?void 0:n.actors)??{},actions:(n==null?void 0:n.actions)??{},delays:(n==null?void 0:n.delays)??{},guards:(n==null?void 0:n.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 st(t,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(t){const{actions:n,guards:s,actors:r,delays:i}=this.implementations;return new rt(this.config,{actions:{...n,...t.actions},guards:{...s,...t.guards},actors:{...r,...t.actors},delays:{...i,...t.delays}})}resolveState(t){const n=os(this.root,t.value),s=Te(Ie(this.root,n));return me({_nodes:[...s],context:t.context||{},children:{},status:et(s,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,s){return Ce(t,n,s).snapshot}microstep(t,n,s){return Ce(t,n,s).microstates}getTransitionData(t,n){return tt(this.root,t.value,t,n)||[]}getPreInitialState(t,n,s){const{context:r}=this.config,i=me({context:typeof r!="function"&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return typeof r=="function"?ne(i,n,t,[C(({spawn:a,event:c,self:u})=>r({spawn:a,input:c.input,self:u}))],s):i}getInitialSnapshot(t,n){const s=Ft(n),r=[],i=this.getPreInitialState(t,s,r),o=je([{target:[...Yt(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],i,t,s,!0,r),{snapshot:a}=Ce(o,s,t,r);return a}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){const n=Qe(t),s=n.slice(1),r=xe(n[0])?n[0].slice(xs.length):n[0],i=this.idMap.get(r);if(!i)throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return _e(i,s)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return fs(t,n)}restoreSnapshot(t,n){const s={},r=t.children;Object.keys(r).forEach(c=>{const u=r[c],h=u.snapshot,d=u.src,f=typeof d=="string"?Xe(this,d):d;if(!f)return;const m=B(f,{id:c,parent:n.self,syncSnapshot:u.syncSnapshot,snapshot:h,src:d,systemId:u.systemId});s[c]=m});const i=me({...t,children:s,_nodes:Array.from(Te(Ie(this.root,t.value)))},this);let o=new Set;function a(c,u){if(!o.has(c)){o.add(c);for(let h in c){const d=c[h];if(d&&typeof d=="object"){if("xstate$$type"in d&&d.xstate$$type===We){c[h]=u[d.id];continue}a(d,u)}}}}return a(i.context,s),i}}function As(e,t){return new rt(e,t)}function Ae({schemas:e,actors:t,actions:n,guards:s,delays:r}){return{createMachine:i=>As({...i,schemas:e},{actors:t,actions:n,guards:s,delays:r})}}async function De(e,t){const n=await fetch(e,t);return n.status===200?n.json():Promise.resolve({message:n.statusText,success:!1})}const $e=Ae({types:{context:{},events:{},input:{}},actions:{setUserContext:C(({context:e,event:t})=>{if(!t.type.includes("xstate.done.actor"))return e;const n=t;return n.output.type!=="AUTHENTICATE_SUCCESS"?e:{accessToken:n.output.accessToken,ignoreRefreshToken:!1}}),unsetUserContext:C(()=>({user:null,accessToken:"",refreshToken:"",ignoreRefreshToken:!1})),setAccessToken:C(({context:e,event:t})=>{if(!t.type.includes("xstate.done.actor"))return e;const n=t;return n.output.type!=="REFRESH_TOKEN_SUCCESS"?e:{accessToken:n.output.accessToken,ignoreRefreshToken:!1}}),unsetRefreshToken:C(()=>({refreshToken:""})),setIgnoreRefreshToken:C(()=>({ignoreRefreshToken:!0})),addError:C(({context:e,event:t})=>{if(!t.type.includes("xstate.error.actor"))return e;const n=t;return{errors:[...e.errors,String(n.error).replace("Error: ","")]}}),clearErrors:C(()=>({errors:[]}))},actors:{refreshAccessToken:Z(async({input:e})=>{let t;if(typeof window>"u"){if(e.context.refreshToken==="")throw new Error("Unauthorized.");try{const s=await De(e.context.endpoints.ssrRefresh,{method:"POST",mode:"cors",credentials:"include",headers:{Cookie:`refresh_token=${e.context.refreshToken}`,"Content-Type":"application/json","clicktap-scope":"view","clicktap-scope-id":"default"}});if(typeof s.accessToken>"u")throw new Error("Unauthorized.");return{type:"REFRESH_TOKEN_SUCCESS",accessToken:s.accessToken}}catch(n){throw console.log(n),new Error("Could not complete refresh request (server)")}}else{t=await De(e.context.endpoints.refresh,{method:"POST",mode:"cors",credentials:"include",headers:{"Content-Type":"application/json","clicktap-scope":"view","clicktap-scope-id":"default"},body:JSON.stringify({grant_type:"refresh_token"}).toString()});const n=t;if(typeof n.accessToken>"u")throw new Error("Unauthorized.");return{type:"REFRESH_TOKEN_SUCCESS",accessToken:n.accessToken}}}),authenticate:Z(async({input:e})=>{var s;const n=await De(e.context.endpoints.login,{method:"POST",mode:"cors",credentials:"include",headers:{"Content-Type":"application/json","clicktap-scope":"view","clicktap-scope-id":"default"},body:JSON.stringify({username:e.username,password:e.password}).toString()});if(!n.success)throw new Error(((s=n.message)==null?void 0:s.toString())??"Sign in failed. Please try again.");return{type:"AUTHENTICATE_SUCCESS",accessToken:n.accessToken}}),unauthenticate:Z(async({input:e})=>(await fetch(e.context.endpoints.logout,{method:"POST",mode:"cors",credentials:"include",headers:{"clicktap-scope":"view","clicktap-scope-id":"default"}}),{type:"UNAUTHENTICATE"}))}}).createMachine({id:"auth",context:({input:e})=>{var t,n;return{user:null,accessToken:"",refreshToken:((t=e==null?void 0:e.initialContext)==null?void 0:t.refreshToken)??"",ignoreRefreshToken:!1,endpoints:((n=e==null?void 0:e.initialContext)==null?void 0:n.endpoints)??{login:"",logout:"",refresh:"",ssrRefresh:""},errors:[]}},initial:"refreshing",states:{authenticating:{invoke:{src:"authenticate",input:({context:e,event:t})=>t.type!=="LOGIN"?{context:e,username:"",password:""}:{context:e,username:t.username,password:t.password},onDone:[{actions:"setUserContext",target:"loggedIn"}],onError:[{actions:"addError",target:"loggedOut"}]}},unauthenticating:{invoke:{src:"unauthenticate",input:({context:e})=>({context:e}),onDone:[{actions:"unsetUserContext",target:"loggedOut"}],onError:[{actions:["unsetUserContext","setIgnoreRefreshToken"],target:"loggedOut"}]}},refreshing:{invoke:{src:"refreshAccessToken",input:({context:e})=>({context:e}),onDone:[{actions:["unsetRefreshToken","setAccessToken"],target:"loggedIn"}],onError:[{actions:"unsetRefreshToken",target:"unauthenticating"}]}},loggedOut:{on:{LOGIN:{target:"authenticating"},CLEAR_ERRORS:{actions:"clearErrors"}}},loggedIn:{after:{84e4:{guard:()=>typeof window<"u",target:"refreshing"}},on:{LOGOUT:{target:"unauthenticating"},CLEAR_ERRORS:{actions:"clearErrors"}}}}}),it=P.createContext({}),ws=()=>{const e=P.useContext(it),[t,n]=P.useState(typeof window<"u"&&e.getSnapshot().value==="loggedIn");return P.useEffect(()=>{if(typeof window>"u")return;const s=e.subscribe(r=>{(r.value==="loggedIn"||r.value==="loggedOut")&&n(r.value==="loggedIn")});return()=>{s.unsubscribe()}},[e]),{authActor:e,isLoggedIn:t}},bs=async(e="",t={inspect:void 0,endpoints:{login:"",logout:"",refresh:"",ssrRefresh:""}})=>typeof window<"u"?(console.warn("App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."),B($e,{inspect:t.inspect,input:{initialContext:{endpoints:t.endpoints}}}).start()):B($e,{input:{initialContext:{endpoints:t.endpoints,refreshToken:e}},inspect:t.inspect}).start();function Os({actor:e,children:t}){return Ye.jsx(it.Provider,{value:e,children:t})}let Ns=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");const en=Ae({actors:{tick:gs(({sendBack:e,input:t})=>{const n=setInterval(()=>{e({type:"TICK"})},t.interval);return()=>{clearInterval(n)}})},types:{context:{},events:{},input:{}}}).createMachine({id:"timer",initial:"running",context:({input:e})=>({elapsed:0,duration:e.initialContext.duration??3e3,interval:100,intervalId:null}),states:{paused:{on:{RESUME_TIMER:{target:"running",guard:({context:e})=>e.elapsed<e.duration}}},running:{invoke:{input:({context:e})=>({interval:e.interval}),src:"tick"},always:[{target:"completed",guard:({context:e})=>e.elapsed>=e.duration}],on:{TICK:{actions:C(({context:e,event:t})=>t.type!=="TICK"?e:{elapsed:e.elapsed+e.interval})},PAUSE_TIMER:{target:"paused"}}},completed:{type:"final"}}}),ks=Ae({actors:{timer:en},types:{context:{},events:{},input:{}},actions:{addItem:C(({context:e,event:t})=>{if(t.type!=="ADD_ITEM")return e;const n=`notification-${Ns()}`,s=t.duration??e.duration,r=P.cloneElement(t.item,{duration:s,id:n,key:t.item.key??n,...t.item.props}),i={duration:s,id:n,element:r},o=e.items;return e.order==="desc"?o.push(i):o.unshift(i),{items:o,activeItem:n}}),removeItem:C(({context:e,event:t})=>{if(t.type!=="REMOVE_ITEM"&&t.type!=="xstate.done.actor.timer")return e;const n=e.items;return e.order==="desc"?(n.pop(),{items:n,activeItem:n.length>0?n[n.length-1].id:null}):(n.shift(),{items:n,activeItem:n.length>0?n[0].id:null})})},delays:{ITEM_TIMEOUT:({context:e})=>e.items[e.items.length-1].duration??e.duration},guards:{itemHasTimeout:({context:e})=>e.items[e.items.length-1].duration>0||e.duration>0}}).createMachine({id:"toast",context:{items:[],order:"desc",duration:0,activeItem:null},initial:"idle",states:{idle:{on:{ADD_ITEM:{target:"adding"}}},active:{invoke:{id:"timer",src:"timer",input:({context:e})=>({initialContext:{duration:e.items[e.items.length-1].duration??e.duration}}),onDone:{target:"removing",guard:"itemHasTimeout"}},on:{ADD_ITEM:{target:"adding"},REMOVE_ITEM:{target:"removing"},SET_IDLE:{target:"idle"},RESUME_TIMER:{actions:At("timer",{type:"RESUME_TIMER"})},PAUSE_TIMER:{actions:At("timer",{type:"PAUSE_TIMER"})}}},adding:{entry:["addItem"],on:{SET_IDLE:{target:"idle"},SET_ACTIVE:{target:"active"}}},removing:{entry:"removeItem",on:{SET_IDLE:{target:"idle"},SET_ACTIVE:{target:"active"}}}}}),ot=P.createContext({}),Cs=()=>P.useContext(ot);function Ds({children:e,actor:t}){return Ye.jsx(ot.Provider,{value:t,children:e})}function Rs({context:e,event:t}){if(!t.type.includes("xstate.done.actor"))return e;const n=t;return n.output.type!=="ADD_ITEMS_SUCCESS"?e:{quote:{...e.quote,...n.output.quote}}}function Ls({context:e,event:t}){if(!t.type.includes("xstate.done.actor"))return e;const n=t;return n.output.type!=="REMOVE_ITEMS_SUCCESS"?e:{quote:{...e.quote,...n.output.quote}}}function Ms({context:e,event:t}){if(!t.type.includes("xstate.done.actor"))return e;const n=t;return n.output.type!=="REFRESH_SUCCESS"?e:{quote:{...e.quote,...n.output.quote}}}const at=JSON,Ps=e=>e.toUpperCase(),qs=e=>{const t={};return e.forEach((n,s)=>{t[s]=n}),t},Fs=(e,t,n)=>e.document?e:{document:e,variables:t,requestHeaders:n,signal:void 0},Us=(e,t,n)=>e.query?e:{query:e,variables:t,requestHeaders:n,signal:void 0},Bs=(e,t)=>e.documents?e:{documents:e,requestHeaders:t,signal:void 0},js=(e,t,...n)=>{const[s,r]=n;return e.document?e:{url:e,document:t,variables:s,requestHeaders:r,signal:void 0}};function ge(e,t){if(!!!e)throw new Error(t)}function $s(e){return typeof e=="object"&&e!==null}function Vs(e,t){if(!!!e)throw new Error(t??"Unexpected invariant triggered.")}const Hs=/\r\n|[\n\r]/g;function Ve(e,t){let n=0,s=1;for(const r of e.body.matchAll(Hs)){if(typeof r.index=="number"||Vs(!1),r.index>=t)break;n=r.index+r[0].length,s+=1}return{line:s,column:t+1-n}}function Gs(e){return tn(e.source,Ve(e.source,e.start))}function tn(e,t){const n=e.locationOffset.column-1,s="".padStart(n)+e.body,r=t.line-1,i=e.locationOffset.line-1,o=t.line+i,a=t.line===1?n:0,c=t.column+a,u=`${e.name}:${o}:${c}
4
+ `,h=s.split(/\r\n|[\n\r]/g),d=h[r];if(d.length>120){const f=Math.floor(c/80),m=c%80,y=[];for(let v=0;v<d.length;v+=80)y.push(d.slice(v,v+80));return u+bt([[`${o} |`,y[0]],...y.slice(1,f+1).map(v=>["|",v]),["|","^".padStart(m)],["|",y[f+1]]])}return u+bt([[`${o-1} |`,h[r-1]],[`${o} |`,d],["|","^".padStart(c)],[`${o+1} |`,h[r+1]]])}function bt(e){const t=e.filter(([s,r])=>r!==void 0),n=Math.max(...t.map(([s])=>s.length));return t.map(([s,r])=>s.padStart(n)+(r?" "+r:"")).join(`
5
+ `)}function zs(e){const t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}class ct extends Error{constructor(t,...n){var s,r,i;const{nodes:o,source:a,positions:c,path:u,originalError:h,extensions:d}=zs(n);super(t),this.name="GraphQLError",this.path=u??void 0,this.originalError=h??void 0,this.nodes=Ot(Array.isArray(o)?o:o?[o]:void 0);const f=Ot((s=this.nodes)===null||s===void 0?void 0:s.map(y=>y.loc).filter(y=>y!=null));this.source=a??(f==null||(r=f[0])===null||r===void 0?void 0:r.source),this.positions=c??(f==null?void 0:f.map(y=>y.start)),this.locations=c&&a?c.map(y=>Ve(a,y)):f==null?void 0:f.map(y=>Ve(y.source,y.start));const m=$s(h==null?void 0:h.extensions)?h==null?void 0:h.extensions:void 0;this.extensions=(i=d??m)!==null&&i!==void 0?i:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),h!=null&&h.stack?Object.defineProperty(this,"stack",{value:h.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,ct):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let t=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(t+=`
32
6
 
33
- `+fy(r.loc));else if(this.source&&this.locations)for(const r of this.locations)i+=`
7
+ `+Gs(n.loc));else if(this.source&&this.locations)for(const n of this.locations)t+=`
34
8
 
35
- `+Mc(this.source,r);return i}toJSON(){const i={message:this.message};return this.locations!=null&&(i.locations=this.locations),this.path!=null&&(i.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(i.extensions=this.extensions),i}}function uc(n){return n===void 0||n.length===0?void 0:n}function Te(n,i,r){return new co(`Syntax Error: ${r}`,{source:n,positions:[i]})}class hy{constructor(i,r,o){this.start=i.start,this.end=r.end,this.startToken=i,this.endToken=r,this.source=o}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class Pc{constructor(i,r,o,a,f,d){this.kind=i,this.start=r,this.end=o,this.line=a,this.column=f,this.value=d,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const Fc={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},dy=new Set(Object.keys(Fc));function ac(n){const i=n==null?void 0:n.kind;return typeof i=="string"&&dy.has(i)}var yn;(function(n){n.QUERY="query",n.MUTATION="mutation",n.SUBSCRIPTION="subscription"})(yn||(yn={}));var Vs;(function(n){n.QUERY="QUERY",n.MUTATION="MUTATION",n.SUBSCRIPTION="SUBSCRIPTION",n.FIELD="FIELD",n.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",n.FRAGMENT_SPREAD="FRAGMENT_SPREAD",n.INLINE_FRAGMENT="INLINE_FRAGMENT",n.VARIABLE_DEFINITION="VARIABLE_DEFINITION",n.SCHEMA="SCHEMA",n.SCALAR="SCALAR",n.OBJECT="OBJECT",n.FIELD_DEFINITION="FIELD_DEFINITION",n.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",n.INTERFACE="INTERFACE",n.UNION="UNION",n.ENUM="ENUM",n.ENUM_VALUE="ENUM_VALUE",n.INPUT_OBJECT="INPUT_OBJECT",n.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"})(Vs||(Vs={}));var W;(function(n){n.NAME="Name",n.DOCUMENT="Document",n.OPERATION_DEFINITION="OperationDefinition",n.VARIABLE_DEFINITION="VariableDefinition",n.SELECTION_SET="SelectionSet",n.FIELD="Field",n.ARGUMENT="Argument",n.FRAGMENT_SPREAD="FragmentSpread",n.INLINE_FRAGMENT="InlineFragment",n.FRAGMENT_DEFINITION="FragmentDefinition",n.VARIABLE="Variable",n.INT="IntValue",n.FLOAT="FloatValue",n.STRING="StringValue",n.BOOLEAN="BooleanValue",n.NULL="NullValue",n.ENUM="EnumValue",n.LIST="ListValue",n.OBJECT="ObjectValue",n.OBJECT_FIELD="ObjectField",n.DIRECTIVE="Directive",n.NAMED_TYPE="NamedType",n.LIST_TYPE="ListType",n.NON_NULL_TYPE="NonNullType",n.SCHEMA_DEFINITION="SchemaDefinition",n.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",n.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",n.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",n.FIELD_DEFINITION="FieldDefinition",n.INPUT_VALUE_DEFINITION="InputValueDefinition",n.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",n.UNION_TYPE_DEFINITION="UnionTypeDefinition",n.ENUM_TYPE_DEFINITION="EnumTypeDefinition",n.ENUM_VALUE_DEFINITION="EnumValueDefinition",n.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",n.DIRECTIVE_DEFINITION="DirectiveDefinition",n.SCHEMA_EXTENSION="SchemaExtension",n.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",n.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",n.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",n.UNION_TYPE_EXTENSION="UnionTypeExtension",n.ENUM_TYPE_EXTENSION="EnumTypeExtension",n.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(W||(W={}));function zs(n){return n===9||n===32}function Zn(n){return n>=48&&n<=57}function Uc(n){return n>=97&&n<=122||n>=65&&n<=90}function Bc(n){return Uc(n)||n===95}function py(n){return Uc(n)||Zn(n)||n===95}function gy(n){var i;let r=Number.MAX_SAFE_INTEGER,o=null,a=-1;for(let d=0;d<n.length;++d){var f;const g=n[d],m=_y(g);m!==g.length&&(o=(f=o)!==null&&f!==void 0?f:d,a=d,d!==0&&m<r&&(r=m))}return n.map((d,g)=>g===0?d:d.slice(r)).slice((i=o)!==null&&i!==void 0?i:0,a+1)}function _y(n){let i=0;for(;i<n.length&&zs(n.charCodeAt(i));)++i;return i}function vy(n,i){const r=n.replace(/"""/g,'\\"""'),o=r.split(/\r\n|[\n\r]/g),a=o.length===1,f=o.length>1&&o.slice(1).every(D=>D.length===0||zs(D.charCodeAt(0))),d=r.endsWith('\\"""'),g=n.endsWith('"')&&!d,m=n.endsWith("\\"),E=g||m,I=!(i!=null&&i.minimize)&&(!a||n.length>70||E||f||d);let x="";const S=a&&zs(n.charCodeAt(0));return(I&&!S||f)&&(x+=`
36
- `),x+=r,(I||E)&&(x+=`
37
- `),'"""'+x+'"""'}var C;(function(n){n.SOF="<SOF>",n.EOF="<EOF>",n.BANG="!",n.DOLLAR="$",n.AMP="&",n.PAREN_L="(",n.PAREN_R=")",n.SPREAD="...",n.COLON=":",n.EQUALS="=",n.AT="@",n.BRACKET_L="[",n.BRACKET_R="]",n.BRACE_L="{",n.PIPE="|",n.BRACE_R="}",n.NAME="Name",n.INT="Int",n.FLOAT="Float",n.STRING="String",n.BLOCK_STRING="BlockString",n.COMMENT="Comment"})(C||(C={}));class yy{constructor(i){const r=new Pc(C.SOF,0,0,0,0);this.source=i,this.lastToken=r,this.token=r,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let i=this.token;if(i.kind!==C.EOF)do if(i.next)i=i.next;else{const r=Ey(this,i.end);i.next=r,r.prev=i,i=r}while(i.kind===C.COMMENT);return i}}function my(n){return n===C.BANG||n===C.DOLLAR||n===C.AMP||n===C.PAREN_L||n===C.PAREN_R||n===C.SPREAD||n===C.COLON||n===C.EQUALS||n===C.AT||n===C.BRACKET_L||n===C.BRACKET_R||n===C.BRACE_L||n===C.PIPE||n===C.BRACE_R}function wn(n){return n>=0&&n<=55295||n>=57344&&n<=1114111}function oi(n,i){return qc(n.charCodeAt(i))&&$c(n.charCodeAt(i+1))}function qc(n){return n>=55296&&n<=56319}function $c(n){return n>=56320&&n<=57343}function Xt(n,i){const r=n.source.body.codePointAt(i);if(r===void 0)return C.EOF;if(r>=32&&r<=126){const o=String.fromCodePoint(r);return o==='"'?`'"'`:`"${o}"`}return"U+"+r.toString(16).toUpperCase().padStart(4,"0")}function _e(n,i,r,o,a){const f=n.line,d=1+r-n.lineStart;return new Pc(i,r,o,f,d,a)}function Ey(n,i){const r=n.source.body,o=r.length;let a=i;for(;a<o;){const f=r.charCodeAt(a);switch(f){case 65279:case 9:case 32:case 44:++a;continue;case 10:++a,++n.line,n.lineStart=a;continue;case 13:r.charCodeAt(a+1)===10?a+=2:++a,++n.line,n.lineStart=a;continue;case 35:return Ty(n,a);case 33:return _e(n,C.BANG,a,a+1);case 36:return _e(n,C.DOLLAR,a,a+1);case 38:return _e(n,C.AMP,a,a+1);case 40:return _e(n,C.PAREN_L,a,a+1);case 41:return _e(n,C.PAREN_R,a,a+1);case 46:if(r.charCodeAt(a+1)===46&&r.charCodeAt(a+2)===46)return _e(n,C.SPREAD,a,a+3);break;case 58:return _e(n,C.COLON,a,a+1);case 61:return _e(n,C.EQUALS,a,a+1);case 64:return _e(n,C.AT,a,a+1);case 91:return _e(n,C.BRACKET_L,a,a+1);case 93:return _e(n,C.BRACKET_R,a,a+1);case 123:return _e(n,C.BRACE_L,a,a+1);case 124:return _e(n,C.PIPE,a,a+1);case 125:return _e(n,C.BRACE_R,a,a+1);case 34:return r.charCodeAt(a+1)===34&&r.charCodeAt(a+2)===34?Oy(n,a):wy(n,a)}if(Zn(f)||f===45)return xy(n,a,f);if(Bc(f))return by(n,a);throw Te(n.source,a,f===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:wn(f)||oi(r,a)?`Unexpected character: ${Xt(n,a)}.`:`Invalid character: ${Xt(n,a)}.`)}return _e(n,C.EOF,o,o)}function Ty(n,i){const r=n.source.body,o=r.length;let a=i+1;for(;a<o;){const f=r.charCodeAt(a);if(f===10||f===13)break;if(wn(f))++a;else if(oi(r,a))a+=2;else break}return _e(n,C.COMMENT,i,a,r.slice(i+1,a))}function xy(n,i,r){const o=n.source.body;let a=i,f=r,d=!1;if(f===45&&(f=o.charCodeAt(++a)),f===48){if(f=o.charCodeAt(++a),Zn(f))throw Te(n.source,a,`Invalid number, unexpected digit after 0: ${Xt(n,a)}.`)}else a=ks(n,a,f),f=o.charCodeAt(a);if(f===46&&(d=!0,f=o.charCodeAt(++a),a=ks(n,a,f),f=o.charCodeAt(a)),(f===69||f===101)&&(d=!0,f=o.charCodeAt(++a),(f===43||f===45)&&(f=o.charCodeAt(++a)),a=ks(n,a,f),f=o.charCodeAt(a)),f===46||Bc(f))throw Te(n.source,a,`Invalid number, expected digit but got: ${Xt(n,a)}.`);return _e(n,d?C.FLOAT:C.INT,i,a,o.slice(i,a))}function ks(n,i,r){if(!Zn(r))throw Te(n.source,i,`Invalid number, expected digit but got: ${Xt(n,i)}.`);const o=n.source.body;let a=i+1;for(;Zn(o.charCodeAt(a));)++a;return a}function wy(n,i){const r=n.source.body,o=r.length;let a=i+1,f=a,d="";for(;a<o;){const g=r.charCodeAt(a);if(g===34)return d+=r.slice(f,a),_e(n,C.STRING,i,a+1,d);if(g===92){d+=r.slice(f,a);const m=r.charCodeAt(a+1)===117?r.charCodeAt(a+2)===123?Ay(n,a):Iy(n,a):Sy(n,a);d+=m.value,a+=m.size,f=a;continue}if(g===10||g===13)break;if(wn(g))++a;else if(oi(r,a))a+=2;else throw Te(n.source,a,`Invalid character within String: ${Xt(n,a)}.`)}throw Te(n.source,a,"Unterminated string.")}function Ay(n,i){const r=n.source.body;let o=0,a=3;for(;a<12;){const f=r.charCodeAt(i+a++);if(f===125){if(a<5||!wn(o))break;return{value:String.fromCodePoint(o),size:a}}if(o=o<<4|Kn(f),o<0)break}throw Te(n.source,i,`Invalid Unicode escape sequence: "${r.slice(i,i+a)}".`)}function Iy(n,i){const r=n.source.body,o=cc(r,i+2);if(wn(o))return{value:String.fromCodePoint(o),size:6};if(qc(o)&&r.charCodeAt(i+6)===92&&r.charCodeAt(i+7)===117){const a=cc(r,i+8);if($c(a))return{value:String.fromCodePoint(o,a),size:12}}throw Te(n.source,i,`Invalid Unicode escape sequence: "${r.slice(i,i+6)}".`)}function cc(n,i){return Kn(n.charCodeAt(i))<<12|Kn(n.charCodeAt(i+1))<<8|Kn(n.charCodeAt(i+2))<<4|Kn(n.charCodeAt(i+3))}function Kn(n){return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:-1}function Sy(n,i){const r=n.source.body;switch(r.charCodeAt(i+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:`
38
- `,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw Te(n.source,i,`Invalid character escape sequence: "${r.slice(i,i+2)}".`)}function Oy(n,i){const r=n.source.body,o=r.length;let a=n.lineStart,f=i+3,d=f,g="";const m=[];for(;f<o;){const E=r.charCodeAt(f);if(E===34&&r.charCodeAt(f+1)===34&&r.charCodeAt(f+2)===34){g+=r.slice(d,f),m.push(g);const I=_e(n,C.BLOCK_STRING,i,f+3,gy(m).join(`
39
- `));return n.line+=m.length-1,n.lineStart=a,I}if(E===92&&r.charCodeAt(f+1)===34&&r.charCodeAt(f+2)===34&&r.charCodeAt(f+3)===34){g+=r.slice(d,f),d=f+1,f+=4;continue}if(E===10||E===13){g+=r.slice(d,f),m.push(g),E===13&&r.charCodeAt(f+1)===10?f+=2:++f,g="",d=f,a=f;continue}if(wn(E))++f;else if(oi(r,f))f+=2;else throw Te(n.source,f,`Invalid character within String: ${Xt(n,f)}.`)}throw Te(n.source,f,"Unterminated string.")}function by(n,i){const r=n.source.body,o=r.length;let a=i+1;for(;a<o;){const f=r.charCodeAt(a);if(py(f))++a;else break}return _e(n,C.NAME,i,a,r.slice(i,a))}const Cy=10,Wc=2;function fo(n){return ui(n,[])}function ui(n,i){switch(typeof n){case"string":return JSON.stringify(n);case"function":return n.name?`[function ${n.name}]`:"[function]";case"object":return Ry(n,i);default:return String(n)}}function Ry(n,i){if(n===null)return"null";if(i.includes(n))return"[Circular]";const r=[...i,n];if(Ny(n)){const o=n.toJSON();if(o!==n)return typeof o=="string"?o:ui(o,r)}else if(Array.isArray(n))return Ly(n,r);return Dy(n,r)}function Ny(n){return typeof n.toJSON=="function"}function Dy(n,i){const r=Object.entries(n);return r.length===0?"{}":i.length>Wc?"["+ky(n)+"]":"{ "+r.map(([a,f])=>a+": "+ui(f,i)).join(", ")+" }"}function Ly(n,i){if(n.length===0)return"[]";if(i.length>Wc)return"[Array]";const r=Math.min(Cy,n.length),o=n.length-r,a=[];for(let f=0;f<r;++f)a.push(ui(n[f],i));return o===1?a.push("... 1 more item"):o>1&&a.push(`... ${o} more items`),"["+a.join(", ")+"]"}function ky(n){const i=Object.prototype.toString.call(n).replace(/^\[object /,"").replace(/]$/,"");if(i==="Object"&&typeof n.constructor=="function"){const r=n.constructor.name;if(typeof r=="string"&&r!=="")return r}return i}const My=globalThis.process&&globalThis.process.env.NODE_ENV==="production"?function(i,r){return i instanceof r}:function(i,r){if(i instanceof r)return!0;if(typeof i=="object"&&i!==null){var o;const a=r.prototype[Symbol.toStringTag],f=Symbol.toStringTag in i?i[Symbol.toStringTag]:(o=i.constructor)===null||o===void 0?void 0:o.name;if(a===f){const d=fo(i);throw new Error(`Cannot use ${a} "${d}" from another module or realm.
9
+ `+tn(this.source,n);return t}toJSON(){const t={message:this.message};return this.locations!=null&&(t.locations=this.locations),this.path!=null&&(t.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(t.extensions=this.extensions),t}}function Ot(e){return e===void 0||e.length===0?void 0:e}function b(e,t,n){return new ct(`Syntax Error: ${n}`,{source:e,positions:[t]})}class Js{constructor(t,n,s){this.start=t.start,this.end=n.end,this.startToken=t,this.endToken=n,this.source=s}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class nn{constructor(t,n,s,r,i,o){this.kind=t,this.start=n,this.end=s,this.line=r,this.column=i,this.value=o,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const sn={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Ys=new Set(Object.keys(sn));function Nt(e){const t=e==null?void 0:e.kind;return typeof t=="string"&&Ys.has(t)}var K;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"})(K||(K={}));var He;(function(e){e.QUERY="QUERY",e.MUTATION="MUTATION",e.SUBSCRIPTION="SUBSCRIPTION",e.FIELD="FIELD",e.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",e.FRAGMENT_SPREAD="FRAGMENT_SPREAD",e.INLINE_FRAGMENT="INLINE_FRAGMENT",e.VARIABLE_DEFINITION="VARIABLE_DEFINITION",e.SCHEMA="SCHEMA",e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.FIELD_DEFINITION="FIELD_DEFINITION",e.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.ENUM_VALUE="ENUM_VALUE",e.INPUT_OBJECT="INPUT_OBJECT",e.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"})(He||(He={}));var T;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(T||(T={}));function Ge(e){return e===9||e===32}function ue(e){return e>=48&&e<=57}function rn(e){return e>=97&&e<=122||e>=65&&e<=90}function on(e){return rn(e)||e===95}function Qs(e){return rn(e)||ue(e)||e===95}function Xs(e){var t;let n=Number.MAX_SAFE_INTEGER,s=null,r=-1;for(let o=0;o<e.length;++o){var i;const a=e[o],c=Ws(a);c!==a.length&&(s=(i=s)!==null&&i!==void 0?i:o,r=o,o!==0&&c<n&&(n=c))}return e.map((o,a)=>a===0?o:o.slice(n)).slice((t=s)!==null&&t!==void 0?t:0,r+1)}function Ws(e){let t=0;for(;t<e.length&&Ge(e.charCodeAt(t));)++t;return t}function Ks(e,t){const n=e.replace(/"""/g,'\\"""'),s=n.split(/\r\n|[\n\r]/g),r=s.length===1,i=s.length>1&&s.slice(1).every(m=>m.length===0||Ge(m.charCodeAt(0))),o=n.endsWith('\\"""'),a=e.endsWith('"')&&!o,c=e.endsWith("\\"),u=a||c,h=!(t!=null&&t.minimize)&&(!r||e.length>70||u||i||o);let d="";const f=r&&Ge(e.charCodeAt(0));return(h&&!f||i)&&(d+=`
10
+ `),d+=n,(h||u)&&(d+=`
11
+ `),'"""'+d+'"""'}var p;(function(e){e.SOF="<SOF>",e.EOF="<EOF>",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"})(p||(p={}));class Zs{constructor(t){const n=new nn(p.SOF,0,0,0,0);this.source=t,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let t=this.token;if(t.kind!==p.EOF)do if(t.next)t=t.next;else{const n=tr(this,t.end);t.next=n,n.prev=t,t=n}while(t.kind===p.COMMENT);return t}}function er(e){return e===p.BANG||e===p.DOLLAR||e===p.AMP||e===p.PAREN_L||e===p.PAREN_R||e===p.SPREAD||e===p.COLON||e===p.EQUALS||e===p.AT||e===p.BRACKET_L||e===p.BRACKET_R||e===p.BRACE_L||e===p.PIPE||e===p.BRACE_R}function se(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function we(e,t){return an(e.charCodeAt(t))&&cn(e.charCodeAt(t+1))}function an(e){return e>=55296&&e<=56319}function cn(e){return e>=56320&&e<=57343}function z(e,t){const n=e.source.body.codePointAt(t);if(n===void 0)return p.EOF;if(n>=32&&n<=126){const s=String.fromCodePoint(n);return s==='"'?`'"'`:`"${s}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function w(e,t,n,s,r){const i=e.line,o=1+n-e.lineStart;return new nn(t,n,s,i,o,r)}function tr(e,t){const n=e.source.body,s=n.length;let r=t;for(;r<s;){const i=n.charCodeAt(r);switch(i){case 65279:case 9:case 32:case 44:++r;continue;case 10:++r,++e.line,e.lineStart=r;continue;case 13:n.charCodeAt(r+1)===10?r+=2:++r,++e.line,e.lineStart=r;continue;case 35:return nr(e,r);case 33:return w(e,p.BANG,r,r+1);case 36:return w(e,p.DOLLAR,r,r+1);case 38:return w(e,p.AMP,r,r+1);case 40:return w(e,p.PAREN_L,r,r+1);case 41:return w(e,p.PAREN_R,r,r+1);case 46:if(n.charCodeAt(r+1)===46&&n.charCodeAt(r+2)===46)return w(e,p.SPREAD,r,r+3);break;case 58:return w(e,p.COLON,r,r+1);case 61:return w(e,p.EQUALS,r,r+1);case 64:return w(e,p.AT,r,r+1);case 91:return w(e,p.BRACKET_L,r,r+1);case 93:return w(e,p.BRACKET_R,r,r+1);case 123:return w(e,p.BRACE_L,r,r+1);case 124:return w(e,p.PIPE,r,r+1);case 125:return w(e,p.BRACE_R,r,r+1);case 34:return n.charCodeAt(r+1)===34&&n.charCodeAt(r+2)===34?cr(e,r):rr(e,r)}if(ue(i)||i===45)return sr(e,r,i);if(on(i))return ur(e,r);throw b(e.source,r,i===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:se(i)||we(n,r)?`Unexpected character: ${z(e,r)}.`:`Invalid character: ${z(e,r)}.`)}return w(e,p.EOF,s,s)}function nr(e,t){const n=e.source.body,s=n.length;let r=t+1;for(;r<s;){const i=n.charCodeAt(r);if(i===10||i===13)break;if(se(i))++r;else if(we(n,r))r+=2;else break}return w(e,p.COMMENT,t,r,n.slice(t+1,r))}function sr(e,t,n){const s=e.source.body;let r=t,i=n,o=!1;if(i===45&&(i=s.charCodeAt(++r)),i===48){if(i=s.charCodeAt(++r),ue(i))throw b(e.source,r,`Invalid number, unexpected digit after 0: ${z(e,r)}.`)}else r=Re(e,r,i),i=s.charCodeAt(r);if(i===46&&(o=!0,i=s.charCodeAt(++r),r=Re(e,r,i),i=s.charCodeAt(r)),(i===69||i===101)&&(o=!0,i=s.charCodeAt(++r),(i===43||i===45)&&(i=s.charCodeAt(++r)),r=Re(e,r,i),i=s.charCodeAt(r)),i===46||on(i))throw b(e.source,r,`Invalid number, expected digit but got: ${z(e,r)}.`);return w(e,o?p.FLOAT:p.INT,t,r,s.slice(t,r))}function Re(e,t,n){if(!ue(n))throw b(e.source,t,`Invalid number, expected digit but got: ${z(e,t)}.`);const s=e.source.body;let r=t+1;for(;ue(s.charCodeAt(r));)++r;return r}function rr(e,t){const n=e.source.body,s=n.length;let r=t+1,i=r,o="";for(;r<s;){const a=n.charCodeAt(r);if(a===34)return o+=n.slice(i,r),w(e,p.STRING,t,r+1,o);if(a===92){o+=n.slice(i,r);const c=n.charCodeAt(r+1)===117?n.charCodeAt(r+2)===123?ir(e,r):or(e,r):ar(e,r);o+=c.value,r+=c.size,i=r;continue}if(a===10||a===13)break;if(se(a))++r;else if(we(n,r))r+=2;else throw b(e.source,r,`Invalid character within String: ${z(e,r)}.`)}throw b(e.source,r,"Unterminated string.")}function ir(e,t){const n=e.source.body;let s=0,r=3;for(;r<12;){const i=n.charCodeAt(t+r++);if(i===125){if(r<5||!se(s))break;return{value:String.fromCodePoint(s),size:r}}if(s=s<<4|oe(i),s<0)break}throw b(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+r)}".`)}function or(e,t){const n=e.source.body,s=kt(n,t+2);if(se(s))return{value:String.fromCodePoint(s),size:6};if(an(s)&&n.charCodeAt(t+6)===92&&n.charCodeAt(t+7)===117){const r=kt(n,t+8);if(cn(r))return{value:String.fromCodePoint(s,r),size:12}}throw b(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function kt(e,t){return oe(e.charCodeAt(t))<<12|oe(e.charCodeAt(t+1))<<8|oe(e.charCodeAt(t+2))<<4|oe(e.charCodeAt(t+3))}function oe(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function ar(e,t){const n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:`
12
+ `,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw b(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function cr(e,t){const n=e.source.body,s=n.length;let r=e.lineStart,i=t+3,o=i,a="";const c=[];for(;i<s;){const u=n.charCodeAt(i);if(u===34&&n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34){a+=n.slice(o,i),c.push(a);const h=w(e,p.BLOCK_STRING,t,i+3,Xs(c).join(`
13
+ `));return e.line+=c.length-1,e.lineStart=r,h}if(u===92&&n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34&&n.charCodeAt(i+3)===34){a+=n.slice(o,i),o=i+1,i+=4;continue}if(u===10||u===13){a+=n.slice(o,i),c.push(a),u===13&&n.charCodeAt(i+1)===10?i+=2:++i,a="",o=i,r=i;continue}if(se(u))++i;else if(we(n,i))i+=2;else throw b(e.source,i,`Invalid character within String: ${z(e,i)}.`)}throw b(e.source,i,"Unterminated string.")}function ur(e,t){const n=e.source.body,s=n.length;let r=t+1;for(;r<s;){const i=n.charCodeAt(r);if(Qs(i))++r;else break}return w(e,p.NAME,t,r,n.slice(t,r))}const dr=10,un=2;function ut(e){return be(e,[])}function be(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return lr(e,t);default:return String(e)}}function lr(e,t){if(e===null)return"null";if(t.includes(e))return"[Circular]";const n=[...t,e];if(hr(e)){const s=e.toJSON();if(s!==e)return typeof s=="string"?s:be(s,n)}else if(Array.isArray(e))return pr(e,n);return fr(e,n)}function hr(e){return typeof e.toJSON=="function"}function fr(e,t){const n=Object.entries(e);return n.length===0?"{}":t.length>un?"["+yr(e)+"]":"{ "+n.map(([r,i])=>r+": "+be(i,t)).join(", ")+" }"}function pr(e,t){if(e.length===0)return"[]";if(t.length>un)return"[Array]";const n=Math.min(dr,e.length),s=e.length-n,r=[];for(let i=0;i<n;++i)r.push(be(e[i],t));return s===1?r.push("... 1 more item"):s>1&&r.push(`... ${s} more items`),"["+r.join(", ")+"]"}function yr(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(t==="Object"&&typeof e.constructor=="function"){const n=e.constructor.name;if(typeof n=="string"&&n!=="")return n}return t}const mr=globalThis.process&&globalThis.process.env.NODE_ENV==="production"?function(t,n){return t instanceof n}:function(t,n){if(t instanceof n)return!0;if(typeof t=="object"&&t!==null){var s;const r=n.prototype[Symbol.toStringTag],i=Symbol.toStringTag in t?t[Symbol.toStringTag]:(s=t.constructor)===null||s===void 0?void 0:s.name;if(r===i){const o=ut(t);throw new Error(`Cannot use ${r} "${o}" from another module or realm.
40
14
 
41
15
  Ensure that there is only one instance of "graphql" in the node_modules
42
16
  directory. If different versions of "graphql" are the dependencies of other
@@ -47,31 +21,31 @@ https://yarnpkg.com/en/docs/selective-version-resolutions
47
21
  Duplicate "graphql" modules cannot be used at the same time since different
48
22
  versions may have different capabilities and behavior. The data from one
49
23
  version used in the function from another could produce confusing and
50
- spurious results.`)}}return!1};class Hc{constructor(i,r="GraphQL request",o={line:1,column:1}){typeof i=="string"||Kr(!1,`Body must be a string. Received: ${fo(i)}.`),this.body=i,this.name=r,this.locationOffset=o,this.locationOffset.line>0||Kr(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Kr(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function Py(n){return My(n,Hc)}function Fy(n,i){return new Uy(n,i).parseDocument()}class Uy{constructor(i,r={}){const o=Py(i)?i:new Hc(i);this._lexer=new yy(o),this._options=r,this._tokenCounter=0}parseName(){const i=this.expectToken(C.NAME);return this.node(i,{kind:W.NAME,value:i.value})}parseDocument(){return this.node(this._lexer.token,{kind:W.DOCUMENT,definitions:this.many(C.SOF,this.parseDefinition,C.EOF)})}parseDefinition(){if(this.peek(C.BRACE_L))return this.parseOperationDefinition();const i=this.peekDescription(),r=i?this._lexer.lookahead():this._lexer.token;if(r.kind===C.NAME){switch(r.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(i)throw Te(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(r.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(r)}parseOperationDefinition(){const i=this._lexer.token;if(this.peek(C.BRACE_L))return this.node(i,{kind:W.OPERATION_DEFINITION,operation:yn.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const r=this.parseOperationType();let o;return this.peek(C.NAME)&&(o=this.parseName()),this.node(i,{kind:W.OPERATION_DEFINITION,operation:r,name:o,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const i=this.expectToken(C.NAME);switch(i.value){case"query":return yn.QUERY;case"mutation":return yn.MUTATION;case"subscription":return yn.SUBSCRIPTION}throw this.unexpected(i)}parseVariableDefinitions(){return this.optionalMany(C.PAREN_L,this.parseVariableDefinition,C.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:W.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(C.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(C.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const i=this._lexer.token;return this.expectToken(C.DOLLAR),this.node(i,{kind:W.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:W.SELECTION_SET,selections:this.many(C.BRACE_L,this.parseSelection,C.BRACE_R)})}parseSelection(){return this.peek(C.SPREAD)?this.parseFragment():this.parseField()}parseField(){const i=this._lexer.token,r=this.parseName();let o,a;return this.expectOptionalToken(C.COLON)?(o=r,a=this.parseName()):a=r,this.node(i,{kind:W.FIELD,alias:o,name:a,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(C.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(i){const r=i?this.parseConstArgument:this.parseArgument;return this.optionalMany(C.PAREN_L,r,C.PAREN_R)}parseArgument(i=!1){const r=this._lexer.token,o=this.parseName();return this.expectToken(C.COLON),this.node(r,{kind:W.ARGUMENT,name:o,value:this.parseValueLiteral(i)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const i=this._lexer.token;this.expectToken(C.SPREAD);const r=this.expectOptionalKeyword("on");return!r&&this.peek(C.NAME)?this.node(i,{kind:W.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(i,{kind:W.INLINE_FRAGMENT,typeCondition:r?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const i=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(i,{kind:W.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(i,{kind:W.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(i){const r=this._lexer.token;switch(r.kind){case C.BRACKET_L:return this.parseList(i);case C.BRACE_L:return this.parseObject(i);case C.INT:return this.advanceLexer(),this.node(r,{kind:W.INT,value:r.value});case C.FLOAT:return this.advanceLexer(),this.node(r,{kind:W.FLOAT,value:r.value});case C.STRING:case C.BLOCK_STRING:return this.parseStringLiteral();case C.NAME:switch(this.advanceLexer(),r.value){case"true":return this.node(r,{kind:W.BOOLEAN,value:!0});case"false":return this.node(r,{kind:W.BOOLEAN,value:!1});case"null":return this.node(r,{kind:W.NULL});default:return this.node(r,{kind:W.ENUM,value:r.value})}case C.DOLLAR:if(i)if(this.expectToken(C.DOLLAR),this._lexer.token.kind===C.NAME){const o=this._lexer.token.value;throw Te(this._lexer.source,r.start,`Unexpected variable "$${o}" in constant value.`)}else throw this.unexpected(r);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const i=this._lexer.token;return this.advanceLexer(),this.node(i,{kind:W.STRING,value:i.value,block:i.kind===C.BLOCK_STRING})}parseList(i){const r=()=>this.parseValueLiteral(i);return this.node(this._lexer.token,{kind:W.LIST,values:this.any(C.BRACKET_L,r,C.BRACKET_R)})}parseObject(i){const r=()=>this.parseObjectField(i);return this.node(this._lexer.token,{kind:W.OBJECT,fields:this.any(C.BRACE_L,r,C.BRACE_R)})}parseObjectField(i){const r=this._lexer.token,o=this.parseName();return this.expectToken(C.COLON),this.node(r,{kind:W.OBJECT_FIELD,name:o,value:this.parseValueLiteral(i)})}parseDirectives(i){const r=[];for(;this.peek(C.AT);)r.push(this.parseDirective(i));return r}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(i){const r=this._lexer.token;return this.expectToken(C.AT),this.node(r,{kind:W.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(i)})}parseTypeReference(){const i=this._lexer.token;let r;if(this.expectOptionalToken(C.BRACKET_L)){const o=this.parseTypeReference();this.expectToken(C.BRACKET_R),r=this.node(i,{kind:W.LIST_TYPE,type:o})}else r=this.parseNamedType();return this.expectOptionalToken(C.BANG)?this.node(i,{kind:W.NON_NULL_TYPE,type:r}):r}parseNamedType(){return this.node(this._lexer.token,{kind:W.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(C.STRING)||this.peek(C.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const i=this._lexer.token,r=this.parseDescription();this.expectKeyword("schema");const o=this.parseConstDirectives(),a=this.many(C.BRACE_L,this.parseOperationTypeDefinition,C.BRACE_R);return this.node(i,{kind:W.SCHEMA_DEFINITION,description:r,directives:o,operationTypes:a})}parseOperationTypeDefinition(){const i=this._lexer.token,r=this.parseOperationType();this.expectToken(C.COLON);const o=this.parseNamedType();return this.node(i,{kind:W.OPERATION_TYPE_DEFINITION,operation:r,type:o})}parseScalarTypeDefinition(){const i=this._lexer.token,r=this.parseDescription();this.expectKeyword("scalar");const o=this.parseName(),a=this.parseConstDirectives();return this.node(i,{kind:W.SCALAR_TYPE_DEFINITION,description:r,name:o,directives:a})}parseObjectTypeDefinition(){const i=this._lexer.token,r=this.parseDescription();this.expectKeyword("type");const o=this.parseName(),a=this.parseImplementsInterfaces(),f=this.parseConstDirectives(),d=this.parseFieldsDefinition();return this.node(i,{kind:W.OBJECT_TYPE_DEFINITION,description:r,name:o,interfaces:a,directives:f,fields:d})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(C.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(C.BRACE_L,this.parseFieldDefinition,C.BRACE_R)}parseFieldDefinition(){const i=this._lexer.token,r=this.parseDescription(),o=this.parseName(),a=this.parseArgumentDefs();this.expectToken(C.COLON);const f=this.parseTypeReference(),d=this.parseConstDirectives();return this.node(i,{kind:W.FIELD_DEFINITION,description:r,name:o,arguments:a,type:f,directives:d})}parseArgumentDefs(){return this.optionalMany(C.PAREN_L,this.parseInputValueDef,C.PAREN_R)}parseInputValueDef(){const i=this._lexer.token,r=this.parseDescription(),o=this.parseName();this.expectToken(C.COLON);const a=this.parseTypeReference();let f;this.expectOptionalToken(C.EQUALS)&&(f=this.parseConstValueLiteral());const d=this.parseConstDirectives();return this.node(i,{kind:W.INPUT_VALUE_DEFINITION,description:r,name:o,type:a,defaultValue:f,directives:d})}parseInterfaceTypeDefinition(){const i=this._lexer.token,r=this.parseDescription();this.expectKeyword("interface");const o=this.parseName(),a=this.parseImplementsInterfaces(),f=this.parseConstDirectives(),d=this.parseFieldsDefinition();return this.node(i,{kind:W.INTERFACE_TYPE_DEFINITION,description:r,name:o,interfaces:a,directives:f,fields:d})}parseUnionTypeDefinition(){const i=this._lexer.token,r=this.parseDescription();this.expectKeyword("union");const o=this.parseName(),a=this.parseConstDirectives(),f=this.parseUnionMemberTypes();return this.node(i,{kind:W.UNION_TYPE_DEFINITION,description:r,name:o,directives:a,types:f})}parseUnionMemberTypes(){return this.expectOptionalToken(C.EQUALS)?this.delimitedMany(C.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const i=this._lexer.token,r=this.parseDescription();this.expectKeyword("enum");const o=this.parseName(),a=this.parseConstDirectives(),f=this.parseEnumValuesDefinition();return this.node(i,{kind:W.ENUM_TYPE_DEFINITION,description:r,name:o,directives:a,values:f})}parseEnumValuesDefinition(){return this.optionalMany(C.BRACE_L,this.parseEnumValueDefinition,C.BRACE_R)}parseEnumValueDefinition(){const i=this._lexer.token,r=this.parseDescription(),o=this.parseEnumValueName(),a=this.parseConstDirectives();return this.node(i,{kind:W.ENUM_VALUE_DEFINITION,description:r,name:o,directives:a})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw Te(this._lexer.source,this._lexer.token.start,`${Jr(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const i=this._lexer.token,r=this.parseDescription();this.expectKeyword("input");const o=this.parseName(),a=this.parseConstDirectives(),f=this.parseInputFieldsDefinition();return this.node(i,{kind:W.INPUT_OBJECT_TYPE_DEFINITION,description:r,name:o,directives:a,fields:f})}parseInputFieldsDefinition(){return this.optionalMany(C.BRACE_L,this.parseInputValueDef,C.BRACE_R)}parseTypeSystemExtension(){const i=this._lexer.lookahead();if(i.kind===C.NAME)switch(i.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(i)}parseSchemaExtension(){const i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const r=this.parseConstDirectives(),o=this.optionalMany(C.BRACE_L,this.parseOperationTypeDefinition,C.BRACE_R);if(r.length===0&&o.length===0)throw this.unexpected();return this.node(i,{kind:W.SCHEMA_EXTENSION,directives:r,operationTypes:o})}parseScalarTypeExtension(){const i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const r=this.parseName(),o=this.parseConstDirectives();if(o.length===0)throw this.unexpected();return this.node(i,{kind:W.SCALAR_TYPE_EXTENSION,name:r,directives:o})}parseObjectTypeExtension(){const i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const r=this.parseName(),o=this.parseImplementsInterfaces(),a=this.parseConstDirectives(),f=this.parseFieldsDefinition();if(o.length===0&&a.length===0&&f.length===0)throw this.unexpected();return this.node(i,{kind:W.OBJECT_TYPE_EXTENSION,name:r,interfaces:o,directives:a,fields:f})}parseInterfaceTypeExtension(){const i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const r=this.parseName(),o=this.parseImplementsInterfaces(),a=this.parseConstDirectives(),f=this.parseFieldsDefinition();if(o.length===0&&a.length===0&&f.length===0)throw this.unexpected();return this.node(i,{kind:W.INTERFACE_TYPE_EXTENSION,name:r,interfaces:o,directives:a,fields:f})}parseUnionTypeExtension(){const i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const r=this.parseName(),o=this.parseConstDirectives(),a=this.parseUnionMemberTypes();if(o.length===0&&a.length===0)throw this.unexpected();return this.node(i,{kind:W.UNION_TYPE_EXTENSION,name:r,directives:o,types:a})}parseEnumTypeExtension(){const i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const r=this.parseName(),o=this.parseConstDirectives(),a=this.parseEnumValuesDefinition();if(o.length===0&&a.length===0)throw this.unexpected();return this.node(i,{kind:W.ENUM_TYPE_EXTENSION,name:r,directives:o,values:a})}parseInputObjectTypeExtension(){const i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const r=this.parseName(),o=this.parseConstDirectives(),a=this.parseInputFieldsDefinition();if(o.length===0&&a.length===0)throw this.unexpected();return this.node(i,{kind:W.INPUT_OBJECT_TYPE_EXTENSION,name:r,directives:o,fields:a})}parseDirectiveDefinition(){const i=this._lexer.token,r=this.parseDescription();this.expectKeyword("directive"),this.expectToken(C.AT);const o=this.parseName(),a=this.parseArgumentDefs(),f=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const d=this.parseDirectiveLocations();return this.node(i,{kind:W.DIRECTIVE_DEFINITION,description:r,name:o,arguments:a,repeatable:f,locations:d})}parseDirectiveLocations(){return this.delimitedMany(C.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const i=this._lexer.token,r=this.parseName();if(Object.prototype.hasOwnProperty.call(Vs,r.value))return r;throw this.unexpected(i)}node(i,r){return this._options.noLocation!==!0&&(r.loc=new hy(i,this._lexer.lastToken,this._lexer.source)),r}peek(i){return this._lexer.token.kind===i}expectToken(i){const r=this._lexer.token;if(r.kind===i)return this.advanceLexer(),r;throw Te(this._lexer.source,r.start,`Expected ${Gc(i)}, found ${Jr(r)}.`)}expectOptionalToken(i){return this._lexer.token.kind===i?(this.advanceLexer(),!0):!1}expectKeyword(i){const r=this._lexer.token;if(r.kind===C.NAME&&r.value===i)this.advanceLexer();else throw Te(this._lexer.source,r.start,`Expected "${i}", found ${Jr(r)}.`)}expectOptionalKeyword(i){const r=this._lexer.token;return r.kind===C.NAME&&r.value===i?(this.advanceLexer(),!0):!1}unexpected(i){const r=i??this._lexer.token;return Te(this._lexer.source,r.start,`Unexpected ${Jr(r)}.`)}any(i,r,o){this.expectToken(i);const a=[];for(;!this.expectOptionalToken(o);)a.push(r.call(this));return a}optionalMany(i,r,o){if(this.expectOptionalToken(i)){const a=[];do a.push(r.call(this));while(!this.expectOptionalToken(o));return a}return[]}many(i,r,o){this.expectToken(i);const a=[];do a.push(r.call(this));while(!this.expectOptionalToken(o));return a}delimitedMany(i,r){this.expectOptionalToken(i);const o=[];do o.push(r.call(this));while(this.expectOptionalToken(i));return o}advanceLexer(){const{maxTokens:i}=this._options,r=this._lexer.advance();if(i!==void 0&&r.kind!==C.EOF&&(++this._tokenCounter,this._tokenCounter>i))throw Te(this._lexer.source,r.start,`Document contains more that ${i} tokens. Parsing aborted.`)}}function Jr(n){const i=n.value;return Gc(n.kind)+(i!=null?` "${i}"`:"")}function Gc(n){return my(n)?`"${n}"`:n}function By(n){return`"${n.replace(qy,$y)}"`}const qy=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function $y(n){return Wy[n.charCodeAt(0)]}const Wy=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"],Hy=Object.freeze({});function Gy(n,i,r=Fc){const o=new Map;for(const ie of Object.values(W))o.set(ie,Vy(i,ie));let a,f=Array.isArray(n),d=[n],g=-1,m=[],E=n,I,x;const S=[],D=[];do{g++;const ie=g===d.length,De=ie&&m.length!==0;if(ie){if(I=D.length===0?void 0:S[S.length-1],E=x,x=D.pop(),De)if(f){E=E.slice();let me=0;for(const[xe,tt]of m){const Le=xe-me;tt===null?(E.splice(Le,1),me++):E[Le]=tt}}else{E=Object.defineProperties({},Object.getOwnPropertyDescriptors(E));for(const[me,xe]of m)E[me]=xe}g=a.index,d=a.keys,m=a.edits,f=a.inArray,a=a.prev}else if(x){if(I=f?g:d[g],E=x[I],E==null)continue;S.push(I)}let le;if(!Array.isArray(E)){var R,F;ac(E)||Kr(!1,`Invalid AST Node: ${fo(E)}.`);const me=ie?(R=o.get(E.kind))===null||R===void 0?void 0:R.leave:(F=o.get(E.kind))===null||F===void 0?void 0:F.enter;if(le=me==null?void 0:me.call(i,E,I,x,S,D),le===Hy)break;if(le===!1){if(!ie){S.pop();continue}}else if(le!==void 0&&(m.push([I,le]),!ie))if(ac(le))E=le;else{S.pop();continue}}if(le===void 0&&De&&m.push([I,E]),ie)S.pop();else{var H;a={inArray:f,index:g,keys:d,edits:m,prev:a},f=Array.isArray(E),d=f?E:(H=r[E.kind])!==null&&H!==void 0?H:[],g=-1,m=[],x&&D.push(x),x=E}}while(a!==void 0);return m.length!==0?m[m.length-1][1]:n}function Vy(n,i){const r=n[i];return typeof r=="object"?r:typeof r=="function"?{enter:r,leave:void 0}:{enter:n.enter,leave:n.leave}}function Vc(n){return Gy(n,Yy)}const zy=80,Yy={Name:{leave:n=>n.value},Variable:{leave:n=>"$"+n.name},Document:{leave:n=>P(n.definitions,`
24
+ spurious results.`)}}return!1};class dn{constructor(t,n="GraphQL request",s={line:1,column:1}){typeof t=="string"||ge(!1,`Body must be a string. Received: ${ut(t)}.`),this.body=t,this.name=n,this.locationOffset=s,this.locationOffset.line>0||ge(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||ge(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function gr(e){return mr(e,dn)}function Er(e,t){return new vr(e,t).parseDocument()}class vr{constructor(t,n={}){const s=gr(t)?t:new dn(t);this._lexer=new Zs(s),this._options=n,this._tokenCounter=0}parseName(){const t=this.expectToken(p.NAME);return this.node(t,{kind:T.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:T.DOCUMENT,definitions:this.many(p.SOF,this.parseDefinition,p.EOF)})}parseDefinition(){if(this.peek(p.BRACE_L))return this.parseOperationDefinition();const t=this.peekDescription(),n=t?this._lexer.lookahead():this._lexer.token;if(n.kind===p.NAME){switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(t)throw b(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(n.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(n)}parseOperationDefinition(){const t=this._lexer.token;if(this.peek(p.BRACE_L))return this.node(t,{kind:T.OPERATION_DEFINITION,operation:K.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const n=this.parseOperationType();let s;return this.peek(p.NAME)&&(s=this.parseName()),this.node(t,{kind:T.OPERATION_DEFINITION,operation:n,name:s,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const t=this.expectToken(p.NAME);switch(t.value){case"query":return K.QUERY;case"mutation":return K.MUTATION;case"subscription":return K.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(p.PAREN_L,this.parseVariableDefinition,p.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:T.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(p.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(p.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const t=this._lexer.token;return this.expectToken(p.DOLLAR),this.node(t,{kind:T.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:T.SELECTION_SET,selections:this.many(p.BRACE_L,this.parseSelection,p.BRACE_R)})}parseSelection(){return this.peek(p.SPREAD)?this.parseFragment():this.parseField()}parseField(){const t=this._lexer.token,n=this.parseName();let s,r;return this.expectOptionalToken(p.COLON)?(s=n,r=this.parseName()):r=n,this.node(t,{kind:T.FIELD,alias:s,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(p.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){const n=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(p.PAREN_L,n,p.PAREN_R)}parseArgument(t=!1){const n=this._lexer.token,s=this.parseName();return this.expectToken(p.COLON),this.node(n,{kind:T.ARGUMENT,name:s,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const t=this._lexer.token;this.expectToken(p.SPREAD);const n=this.expectOptionalKeyword("on");return!n&&this.peek(p.NAME)?this.node(t,{kind:T.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(t,{kind:T.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const t=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(t,{kind:T.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:T.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(t){const n=this._lexer.token;switch(n.kind){case p.BRACKET_L:return this.parseList(t);case p.BRACE_L:return this.parseObject(t);case p.INT:return this.advanceLexer(),this.node(n,{kind:T.INT,value:n.value});case p.FLOAT:return this.advanceLexer(),this.node(n,{kind:T.FLOAT,value:n.value});case p.STRING:case p.BLOCK_STRING:return this.parseStringLiteral();case p.NAME:switch(this.advanceLexer(),n.value){case"true":return this.node(n,{kind:T.BOOLEAN,value:!0});case"false":return this.node(n,{kind:T.BOOLEAN,value:!1});case"null":return this.node(n,{kind:T.NULL});default:return this.node(n,{kind:T.ENUM,value:n.value})}case p.DOLLAR:if(t)if(this.expectToken(p.DOLLAR),this._lexer.token.kind===p.NAME){const s=this._lexer.token.value;throw b(this._lexer.source,n.start,`Unexpected variable "$${s}" in constant value.`)}else throw this.unexpected(n);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const t=this._lexer.token;return this.advanceLexer(),this.node(t,{kind:T.STRING,value:t.value,block:t.kind===p.BLOCK_STRING})}parseList(t){const n=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:T.LIST,values:this.any(p.BRACKET_L,n,p.BRACKET_R)})}parseObject(t){const n=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:T.OBJECT,fields:this.any(p.BRACE_L,n,p.BRACE_R)})}parseObjectField(t){const n=this._lexer.token,s=this.parseName();return this.expectToken(p.COLON),this.node(n,{kind:T.OBJECT_FIELD,name:s,value:this.parseValueLiteral(t)})}parseDirectives(t){const n=[];for(;this.peek(p.AT);)n.push(this.parseDirective(t));return n}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){const n=this._lexer.token;return this.expectToken(p.AT),this.node(n,{kind:T.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){const t=this._lexer.token;let n;if(this.expectOptionalToken(p.BRACKET_L)){const s=this.parseTypeReference();this.expectToken(p.BRACKET_R),n=this.node(t,{kind:T.LIST_TYPE,type:s})}else n=this.parseNamedType();return this.expectOptionalToken(p.BANG)?this.node(t,{kind:T.NON_NULL_TYPE,type:n}):n}parseNamedType(){return this.node(this._lexer.token,{kind:T.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(p.STRING)||this.peek(p.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");const s=this.parseConstDirectives(),r=this.many(p.BRACE_L,this.parseOperationTypeDefinition,p.BRACE_R);return this.node(t,{kind:T.SCHEMA_DEFINITION,description:n,directives:s,operationTypes:r})}parseOperationTypeDefinition(){const t=this._lexer.token,n=this.parseOperationType();this.expectToken(p.COLON);const s=this.parseNamedType();return this.node(t,{kind:T.OPERATION_TYPE_DEFINITION,operation:n,type:s})}parseScalarTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");const s=this.parseName(),r=this.parseConstDirectives();return this.node(t,{kind:T.SCALAR_TYPE_DEFINITION,description:n,name:s,directives:r})}parseObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");const s=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(t,{kind:T.OBJECT_TYPE_DEFINITION,description:n,name:s,interfaces:r,directives:i,fields:o})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(p.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(p.BRACE_L,this.parseFieldDefinition,p.BRACE_R)}parseFieldDefinition(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseName(),r=this.parseArgumentDefs();this.expectToken(p.COLON);const i=this.parseTypeReference(),o=this.parseConstDirectives();return this.node(t,{kind:T.FIELD_DEFINITION,description:n,name:s,arguments:r,type:i,directives:o})}parseArgumentDefs(){return this.optionalMany(p.PAREN_L,this.parseInputValueDef,p.PAREN_R)}parseInputValueDef(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseName();this.expectToken(p.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(p.EQUALS)&&(i=this.parseConstValueLiteral());const o=this.parseConstDirectives();return this.node(t,{kind:T.INPUT_VALUE_DEFINITION,description:n,name:s,type:r,defaultValue:i,directives:o})}parseInterfaceTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");const s=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(t,{kind:T.INTERFACE_TYPE_DEFINITION,description:n,name:s,interfaces:r,directives:i,fields:o})}parseUnionTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");const s=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(t,{kind:T.UNION_TYPE_DEFINITION,description:n,name:s,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(p.EQUALS)?this.delimitedMany(p.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");const s=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(t,{kind:T.ENUM_TYPE_DEFINITION,description:n,name:s,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(p.BRACE_L,this.parseEnumValueDefinition,p.BRACE_R)}parseEnumValueDefinition(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(t,{kind:T.ENUM_VALUE_DEFINITION,description:n,name:s,directives:r})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw b(this._lexer.source,this._lexer.token.start,`${ye(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");const s=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(t,{kind:T.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:s,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(p.BRACE_L,this.parseInputValueDef,p.BRACE_R)}parseTypeSystemExtension(){const t=this._lexer.lookahead();if(t.kind===p.NAME)switch(t.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(t)}parseSchemaExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const n=this.parseConstDirectives(),s=this.optionalMany(p.BRACE_L,this.parseOperationTypeDefinition,p.BRACE_R);if(n.length===0&&s.length===0)throw this.unexpected();return this.node(t,{kind:T.SCHEMA_EXTENSION,directives:n,operationTypes:s})}parseScalarTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const n=this.parseName(),s=this.parseConstDirectives();if(s.length===0)throw this.unexpected();return this.node(t,{kind:T.SCALAR_TYPE_EXTENSION,name:n,directives:s})}parseObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const n=this.parseName(),s=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(s.length===0&&r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:T.OBJECT_TYPE_EXTENSION,name:n,interfaces:s,directives:r,fields:i})}parseInterfaceTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const n=this.parseName(),s=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(s.length===0&&r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:T.INTERFACE_TYPE_EXTENSION,name:n,interfaces:s,directives:r,fields:i})}parseUnionTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const n=this.parseName(),s=this.parseConstDirectives(),r=this.parseUnionMemberTypes();if(s.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:T.UNION_TYPE_EXTENSION,name:n,directives:s,types:r})}parseEnumTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const n=this.parseName(),s=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();if(s.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:T.ENUM_TYPE_EXTENSION,name:n,directives:s,values:r})}parseInputObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const n=this.parseName(),s=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();if(s.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:T.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:s,fields:r})}parseDirectiveDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(p.AT);const s=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const o=this.parseDirectiveLocations();return this.node(t,{kind:T.DIRECTIVE_DEFINITION,description:n,name:s,arguments:r,repeatable:i,locations:o})}parseDirectiveLocations(){return this.delimitedMany(p.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const t=this._lexer.token,n=this.parseName();if(Object.prototype.hasOwnProperty.call(He,n.value))return n;throw this.unexpected(t)}node(t,n){return this._options.noLocation!==!0&&(n.loc=new Js(t,this._lexer.lastToken,this._lexer.source)),n}peek(t){return this._lexer.token.kind===t}expectToken(t){const n=this._lexer.token;if(n.kind===t)return this.advanceLexer(),n;throw b(this._lexer.source,n.start,`Expected ${ln(t)}, found ${ye(n)}.`)}expectOptionalToken(t){return this._lexer.token.kind===t?(this.advanceLexer(),!0):!1}expectKeyword(t){const n=this._lexer.token;if(n.kind===p.NAME&&n.value===t)this.advanceLexer();else throw b(this._lexer.source,n.start,`Expected "${t}", found ${ye(n)}.`)}expectOptionalKeyword(t){const n=this._lexer.token;return n.kind===p.NAME&&n.value===t?(this.advanceLexer(),!0):!1}unexpected(t){const n=t??this._lexer.token;return b(this._lexer.source,n.start,`Unexpected ${ye(n)}.`)}any(t,n,s){this.expectToken(t);const r=[];for(;!this.expectOptionalToken(s);)r.push(n.call(this));return r}optionalMany(t,n,s){if(this.expectOptionalToken(t)){const r=[];do r.push(n.call(this));while(!this.expectOptionalToken(s));return r}return[]}many(t,n,s){this.expectToken(t);const r=[];do r.push(n.call(this));while(!this.expectOptionalToken(s));return r}delimitedMany(t,n){this.expectOptionalToken(t);const s=[];do s.push(n.call(this));while(this.expectOptionalToken(t));return s}advanceLexer(){const{maxTokens:t}=this._options,n=this._lexer.advance();if(t!==void 0&&n.kind!==p.EOF&&(++this._tokenCounter,this._tokenCounter>t))throw b(this._lexer.source,n.start,`Document contains more that ${t} tokens. Parsing aborted.`)}}function ye(e){const t=e.value;return ln(e.kind)+(t!=null?` "${t}"`:"")}function ln(e){return er(e)?`"${e}"`:e}function Tr(e){return`"${e.replace(_r,Ir)}"`}const _r=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Ir(e){return Sr[e.charCodeAt(0)]}const Sr=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"],xr=Object.freeze({});function Ar(e,t,n=sn){const s=new Map;for(const A of Object.values(T))s.set(A,wr(t,A));let r,i=Array.isArray(e),o=[e],a=-1,c=[],u=e,h,d;const f=[],m=[];do{a++;const A=a===o.length,R=A&&c.length!==0;if(A){if(h=m.length===0?void 0:f[f.length-1],u=d,d=m.pop(),R)if(i){u=u.slice();let L=0;for(const[J,le]of c){const he=J-L;le===null?(u.splice(he,1),L++):u[he]=le}}else{u=Object.defineProperties({},Object.getOwnPropertyDescriptors(u));for(const[L,J]of c)u[L]=J}a=r.index,o=r.keys,c=r.edits,i=r.inArray,r=r.prev}else if(d){if(h=i?a:o[a],u=d[h],u==null)continue;f.push(h)}let D;if(!Array.isArray(u)){var y,v;Nt(u)||ge(!1,`Invalid AST Node: ${ut(u)}.`);const L=A?(y=s.get(u.kind))===null||y===void 0?void 0:y.leave:(v=s.get(u.kind))===null||v===void 0?void 0:v.enter;if(D=L==null?void 0:L.call(t,u,h,d,f,m),D===xr)break;if(D===!1){if(!A){f.pop();continue}}else if(D!==void 0&&(c.push([h,D]),!A))if(Nt(D))u=D;else{f.pop();continue}}if(D===void 0&&R&&c.push([h,u]),A)f.pop();else{var S;r={inArray:i,index:a,keys:o,edits:c,prev:r},i=Array.isArray(u),o=i?u:(S=n[u.kind])!==null&&S!==void 0?S:[],a=-1,c=[],d&&m.push(d),d=u}}while(r!==void 0);return c.length!==0?c[c.length-1][1]:e}function wr(e,t){const n=e[t];return typeof n=="object"?n:typeof n=="function"?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function hn(e){return Ar(e,Or)}const br=80,Or={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>E(e.definitions,`
51
25
 
52
- `)},OperationDefinition:{leave(n){const i=j("(",P(n.variableDefinitions,", "),")"),r=P([n.operation,P([n.name,i]),P(n.directives," ")]," ");return(r==="query"?"":r+" ")+n.selectionSet}},VariableDefinition:{leave:({variable:n,type:i,defaultValue:r,directives:o})=>n+": "+i+j(" = ",r)+j(" ",P(o," "))},SelectionSet:{leave:({selections:n})=>at(n)},Field:{leave({alias:n,name:i,arguments:r,directives:o,selectionSet:a}){const f=j("",n,": ")+i;let d=f+j("(",P(r,", "),")");return d.length>zy&&(d=f+j(`(
53
- `,Qr(P(r,`
26
+ `)},OperationDefinition:{leave(e){const t=I("(",E(e.variableDefinitions,", "),")"),n=E([e.operation,E([e.name,t]),E(e.directives," ")]," ");return(n==="query"?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:s})=>e+": "+t+I(" = ",n)+I(" ",E(s," "))},SelectionSet:{leave:({selections:e})=>M(e)},Field:{leave({alias:e,name:t,arguments:n,directives:s,selectionSet:r}){const i=I("",e,": ")+t;let o=i+I("(",E(n,", "),")");return o.length>br&&(o=i+I(`(
27
+ `,Ee(E(n,`
54
28
  `)),`
55
- )`)),P([d,P(o," "),a]," ")}},Argument:{leave:({name:n,value:i})=>n+": "+i},FragmentSpread:{leave:({name:n,directives:i})=>"..."+n+j(" ",P(i," "))},InlineFragment:{leave:({typeCondition:n,directives:i,selectionSet:r})=>P(["...",j("on ",n),P(i," "),r]," ")},FragmentDefinition:{leave:({name:n,typeCondition:i,variableDefinitions:r,directives:o,selectionSet:a})=>`fragment ${n}${j("(",P(r,", "),")")} on ${i} ${j("",P(o," ")," ")}`+a},IntValue:{leave:({value:n})=>n},FloatValue:{leave:({value:n})=>n},StringValue:{leave:({value:n,block:i})=>i?vy(n):By(n)},BooleanValue:{leave:({value:n})=>n?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:n})=>n},ListValue:{leave:({values:n})=>"["+P(n,", ")+"]"},ObjectValue:{leave:({fields:n})=>"{"+P(n,", ")+"}"},ObjectField:{leave:({name:n,value:i})=>n+": "+i},Directive:{leave:({name:n,arguments:i})=>"@"+n+j("(",P(i,", "),")")},NamedType:{leave:({name:n})=>n},ListType:{leave:({type:n})=>"["+n+"]"},NonNullType:{leave:({type:n})=>n+"!"},SchemaDefinition:{leave:({description:n,directives:i,operationTypes:r})=>j("",n,`
56
- `)+P(["schema",P(i," "),at(r)]," ")},OperationTypeDefinition:{leave:({operation:n,type:i})=>n+": "+i},ScalarTypeDefinition:{leave:({description:n,name:i,directives:r})=>j("",n,`
57
- `)+P(["scalar",i,P(r," ")]," ")},ObjectTypeDefinition:{leave:({description:n,name:i,interfaces:r,directives:o,fields:a})=>j("",n,`
58
- `)+P(["type",i,j("implements ",P(r," & ")),P(o," "),at(a)]," ")},FieldDefinition:{leave:({description:n,name:i,arguments:r,type:o,directives:a})=>j("",n,`
59
- `)+i+(fc(r)?j(`(
60
- `,Qr(P(r,`
29
+ )`)),E([o,E(s," "),r]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+I(" ",E(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>E(["...",I("on ",e),E(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:s,selectionSet:r})=>`fragment ${e}${I("(",E(n,", "),")")} on ${t} ${I("",E(s," ")," ")}`+r},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?Ks(e):Tr(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+E(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+E(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+I("(",E(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>I("",e,`
30
+ `)+E(["schema",E(t," "),M(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>I("",e,`
31
+ `)+E(["scalar",t,E(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:s,fields:r})=>I("",e,`
32
+ `)+E(["type",t,I("implements ",E(n," & ")),E(s," "),M(r)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:s,directives:r})=>I("",e,`
33
+ `)+t+(Ct(n)?I(`(
34
+ `,Ee(E(n,`
61
35
  `)),`
62
- )`):j("(",P(r,", "),")"))+": "+o+j(" ",P(a," "))},InputValueDefinition:{leave:({description:n,name:i,type:r,defaultValue:o,directives:a})=>j("",n,`
63
- `)+P([i+": "+r,j("= ",o),P(a," ")]," ")},InterfaceTypeDefinition:{leave:({description:n,name:i,interfaces:r,directives:o,fields:a})=>j("",n,`
64
- `)+P(["interface",i,j("implements ",P(r," & ")),P(o," "),at(a)]," ")},UnionTypeDefinition:{leave:({description:n,name:i,directives:r,types:o})=>j("",n,`
65
- `)+P(["union",i,P(r," "),j("= ",P(o," | "))]," ")},EnumTypeDefinition:{leave:({description:n,name:i,directives:r,values:o})=>j("",n,`
66
- `)+P(["enum",i,P(r," "),at(o)]," ")},EnumValueDefinition:{leave:({description:n,name:i,directives:r})=>j("",n,`
67
- `)+P([i,P(r," ")]," ")},InputObjectTypeDefinition:{leave:({description:n,name:i,directives:r,fields:o})=>j("",n,`
68
- `)+P(["input",i,P(r," "),at(o)]," ")},DirectiveDefinition:{leave:({description:n,name:i,arguments:r,repeatable:o,locations:a})=>j("",n,`
69
- `)+"directive @"+i+(fc(r)?j(`(
70
- `,Qr(P(r,`
36
+ )`):I("(",E(n,", "),")"))+": "+s+I(" ",E(r," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:s,directives:r})=>I("",e,`
37
+ `)+E([t+": "+n,I("= ",s),E(r," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:s,fields:r})=>I("",e,`
38
+ `)+E(["interface",t,I("implements ",E(n," & ")),E(s," "),M(r)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:s})=>I("",e,`
39
+ `)+E(["union",t,E(n," "),I("= ",E(s," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:s})=>I("",e,`
40
+ `)+E(["enum",t,E(n," "),M(s)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>I("",e,`
41
+ `)+E([t,E(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:s})=>I("",e,`
42
+ `)+E(["input",t,E(n," "),M(s)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:s,locations:r})=>I("",e,`
43
+ `)+"directive @"+t+(Ct(n)?I(`(
44
+ `,Ee(E(n,`
71
45
  `)),`
72
- )`):j("(",P(r,", "),")"))+(o?" repeatable":"")+" on "+P(a," | ")},SchemaExtension:{leave:({directives:n,operationTypes:i})=>P(["extend schema",P(n," "),at(i)]," ")},ScalarTypeExtension:{leave:({name:n,directives:i})=>P(["extend scalar",n,P(i," ")]," ")},ObjectTypeExtension:{leave:({name:n,interfaces:i,directives:r,fields:o})=>P(["extend type",n,j("implements ",P(i," & ")),P(r," "),at(o)]," ")},InterfaceTypeExtension:{leave:({name:n,interfaces:i,directives:r,fields:o})=>P(["extend interface",n,j("implements ",P(i," & ")),P(r," "),at(o)]," ")},UnionTypeExtension:{leave:({name:n,directives:i,types:r})=>P(["extend union",n,P(i," "),j("= ",P(r," | "))]," ")},EnumTypeExtension:{leave:({name:n,directives:i,values:r})=>P(["extend enum",n,P(i," "),at(r)]," ")},InputObjectTypeExtension:{leave:({name:n,directives:i,fields:r})=>P(["extend input",n,P(i," "),at(r)]," ")}};function P(n,i=""){var r;return(r=n==null?void 0:n.filter(o=>o).join(i))!==null&&r!==void 0?r:""}function at(n){return j(`{
73
- `,Qr(P(n,`
46
+ )`):I("(",E(n,", "),")"))+(s?" repeatable":"")+" on "+E(r," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>E(["extend schema",E(e," "),M(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>E(["extend scalar",e,E(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:s})=>E(["extend type",e,I("implements ",E(t," & ")),E(n," "),M(s)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:s})=>E(["extend interface",e,I("implements ",E(t," & ")),E(n," "),M(s)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>E(["extend union",e,E(t," "),I("= ",E(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>E(["extend enum",e,E(t," "),M(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>E(["extend input",e,E(t," "),M(n)]," ")}};function E(e,t=""){var n;return(n=e==null?void 0:e.filter(s=>s).join(t))!==null&&n!==void 0?n:""}function M(e){return I(`{
47
+ `,Ee(E(e,`
74
48
  `)),`
75
- }`)}function j(n,i,r=""){return i!=null&&i!==""?n+i+r:""}function Qr(n){return j(" ",n.replace(/\n/g,`
76
- `))}function fc(n){var i;return(i=n==null?void 0:n.some(r=>r.includes(`
77
- `)))!==null&&i!==void 0?i:!1}const lc=n=>{var o,a;let i;const r=n.definitions.filter(f=>f.kind==="OperationDefinition");return r.length===1&&(i=(a=(o=r[0])==null?void 0:o.name)==null?void 0:a.value),i},Ms=n=>{if(typeof n=="string"){let r;try{const o=Fy(n);r=lc(o)}catch{}return{query:n,operationName:r}}const i=lc(n);return{query:Vc(n),operationName:i}};class Qn extends Error{constructor(i,r){const o=`${Qn.extractMessage(i)}: ${JSON.stringify({response:i,request:r})}`;super(o),Object.setPrototypeOf(this,Qn.prototype),this.response=i,this.request=r,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Qn)}static extractMessage(i){var r,o;return((o=(r=i.errors)==null?void 0:r[0])==null?void 0:o.message)??`GraphQL Error (Code: ${i.status})`}}var Ys={exports:{}};(function(n,i){var r=typeof self<"u"?self:_n,o=function(){function f(){this.fetch=!1,this.DOMException=r.DOMException}return f.prototype=r,new f}();(function(f){(function(d){var g={searchParams:"URLSearchParams"in f,iterable:"Symbol"in f&&"iterator"in Symbol,blob:"FileReader"in f&&"Blob"in f&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in f,arrayBuffer:"ArrayBuffer"in f};function m(w){return w&&DataView.prototype.isPrototypeOf(w)}if(g.arrayBuffer)var E=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],I=ArrayBuffer.isView||function(w){return w&&E.indexOf(Object.prototype.toString.call(w))>-1};function x(w){if(typeof w!="string"&&(w=String(w)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(w))throw new TypeError("Invalid character in header field name");return w.toLowerCase()}function S(w){return typeof w!="string"&&(w=String(w)),w}function D(w){var L={next:function(){var Y=w.shift();return{done:Y===void 0,value:Y}}};return g.iterable&&(L[Symbol.iterator]=function(){return L}),L}function R(w){this.map={},w instanceof R?w.forEach(function(L,Y){this.append(Y,L)},this):Array.isArray(w)?w.forEach(function(L){this.append(L[0],L[1])},this):w&&Object.getOwnPropertyNames(w).forEach(function(L){this.append(L,w[L])},this)}R.prototype.append=function(w,L){w=x(w),L=S(L);var Y=this.map[w];this.map[w]=Y?Y+", "+L:L},R.prototype.delete=function(w){delete this.map[x(w)]},R.prototype.get=function(w){return w=x(w),this.has(w)?this.map[w]:null},R.prototype.has=function(w){return this.map.hasOwnProperty(x(w))},R.prototype.set=function(w,L){this.map[x(w)]=S(L)},R.prototype.forEach=function(w,L){for(var Y in this.map)this.map.hasOwnProperty(Y)&&w.call(L,this.map[Y],Y,this)},R.prototype.keys=function(){var w=[];return this.forEach(function(L,Y){w.push(Y)}),D(w)},R.prototype.values=function(){var w=[];return this.forEach(function(L){w.push(L)}),D(w)},R.prototype.entries=function(){var w=[];return this.forEach(function(L,Y){w.push([Y,L])}),D(w)},g.iterable&&(R.prototype[Symbol.iterator]=R.prototype.entries);function F(w){if(w.bodyUsed)return Promise.reject(new TypeError("Already read"));w.bodyUsed=!0}function H(w){return new Promise(function(L,Y){w.onload=function(){L(w.result)},w.onerror=function(){Y(w.error)}})}function ie(w){var L=new FileReader,Y=H(L);return L.readAsArrayBuffer(w),Y}function De(w){var L=new FileReader,Y=H(L);return L.readAsText(w),Y}function le(w){for(var L=new Uint8Array(w),Y=new Array(L.length),ce=0;ce<L.length;ce++)Y[ce]=String.fromCharCode(L[ce]);return Y.join("")}function me(w){if(w.slice)return w.slice(0);var L=new Uint8Array(w.byteLength);return L.set(new Uint8Array(w)),L.buffer}function xe(){return this.bodyUsed=!1,this._initBody=function(w){this._bodyInit=w,w?typeof w=="string"?this._bodyText=w:g.blob&&Blob.prototype.isPrototypeOf(w)?this._bodyBlob=w:g.formData&&FormData.prototype.isPrototypeOf(w)?this._bodyFormData=w:g.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)?this._bodyText=w.toString():g.arrayBuffer&&g.blob&&m(w)?(this._bodyArrayBuffer=me(w.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):g.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(w)||I(w))?this._bodyArrayBuffer=me(w):this._bodyText=w=Object.prototype.toString.call(w):this._bodyText="",this.headers.get("content-type")||(typeof w=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):g.searchParams&&URLSearchParams.prototype.isPrototypeOf(w)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},g.blob&&(this.blob=function(){var w=F(this);if(w)return w;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?F(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(ie)}),this.text=function(){var w=F(this);if(w)return w;if(this._bodyBlob)return De(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(le(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},g.formData&&(this.formData=function(){return this.text().then(An)}),this.json=function(){return this.text().then(JSON.parse)},this}var tt=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function Le(w){var L=w.toUpperCase();return tt.indexOf(L)>-1?L:w}function Be(w,L){L=L||{};var Y=L.body;if(w instanceof Be){if(w.bodyUsed)throw new TypeError("Already read");this.url=w.url,this.credentials=w.credentials,L.headers||(this.headers=new R(w.headers)),this.method=w.method,this.mode=w.mode,this.signal=w.signal,!Y&&w._bodyInit!=null&&(Y=w._bodyInit,w.bodyUsed=!0)}else this.url=String(w);if(this.credentials=L.credentials||this.credentials||"same-origin",(L.headers||!this.headers)&&(this.headers=new R(L.headers)),this.method=Le(L.method||this.method||"GET"),this.mode=L.mode||this.mode||null,this.signal=L.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&Y)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(Y)}Be.prototype.clone=function(){return new Be(this,{body:this._bodyInit})};function An(w){var L=new FormData;return w.trim().split("&").forEach(function(Y){if(Y){var ce=Y.split("="),oe=ce.shift().replace(/\+/g," "),ne=ce.join("=").replace(/\+/g," ");L.append(decodeURIComponent(oe),decodeURIComponent(ne))}}),L}function ai(w){var L=new R,Y=w.replace(/\r?\n[\t ]+/g," ");return Y.split(/\r?\n/).forEach(function(ce){var oe=ce.split(":"),ne=oe.shift().trim();if(ne){var dt=oe.join(":").trim();L.append(ne,dt)}}),L}xe.call(Be.prototype);function ze(w,L){L||(L={}),this.type="default",this.status=L.status===void 0?200:L.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in L?L.statusText:"OK",this.headers=new R(L.headers),this.url=L.url||"",this._initBody(w)}xe.call(ze.prototype),ze.prototype.clone=function(){return new ze(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new R(this.headers),url:this.url})},ze.error=function(){var w=new ze(null,{status:0,statusText:""});return w.type="error",w};var ci=[301,302,303,307,308];ze.redirect=function(w,L){if(ci.indexOf(L)===-1)throw new RangeError("Invalid status code");return new ze(null,{status:L,headers:{location:w}})},d.DOMException=f.DOMException;try{new d.DOMException}catch{d.DOMException=function(L,Y){this.message=L,this.name=Y;var ce=Error(L);this.stack=ce.stack},d.DOMException.prototype=Object.create(Error.prototype),d.DOMException.prototype.constructor=d.DOMException}function In(w,L){return new Promise(function(Y,ce){var oe=new Be(w,L);if(oe.signal&&oe.signal.aborted)return ce(new d.DOMException("Aborted","AbortError"));var ne=new XMLHttpRequest;function dt(){ne.abort()}ne.onload=function(){var Ie={status:ne.status,statusText:ne.statusText,headers:ai(ne.getAllResponseHeaders()||"")};Ie.url="responseURL"in ne?ne.responseURL:Ie.headers.get("X-Request-URL");var Sn="response"in ne?ne.response:ne.responseText;Y(new ze(Sn,Ie))},ne.onerror=function(){ce(new TypeError("Network request failed"))},ne.ontimeout=function(){ce(new TypeError("Network request failed"))},ne.onabort=function(){ce(new d.DOMException("Aborted","AbortError"))},ne.open(oe.method,oe.url,!0),oe.credentials==="include"?ne.withCredentials=!0:oe.credentials==="omit"&&(ne.withCredentials=!1),"responseType"in ne&&g.blob&&(ne.responseType="blob"),oe.headers.forEach(function(Ie,Sn){ne.setRequestHeader(Sn,Ie)}),oe.signal&&(oe.signal.addEventListener("abort",dt),ne.onreadystatechange=function(){ne.readyState===4&&oe.signal.removeEventListener("abort",dt)}),ne.send(typeof oe._bodyInit>"u"?null:oe._bodyInit)})}return In.polyfill=!0,f.fetch||(f.fetch=In,f.Headers=R,f.Request=Be,f.Response=ze),d.Headers=R,d.Request=Be,d.Response=ze,d.fetch=In,Object.defineProperty(d,"__esModule",{value:!0}),d})({})})(o),o.fetch.ponyfill=!0,delete o.fetch.polyfill;var a=o;i=a.fetch,i.default=a.fetch,i.fetch=a.fetch,i.Headers=a.Headers,i.Request=a.Request,i.Response=a.Response,n.exports=i})(Ys,Ys.exports);var ri=Ys.exports;const jr=Qv(ri),Jy=P_({__proto__:null,default:jr},[ri]),pn=n=>{let i={};return n&&(typeof Headers<"u"&&n instanceof Headers||Jy&&ri.Headers&&n instanceof ri.Headers?i=ny(n):Array.isArray(n)?n.forEach(([r,o])=>{r&&o!==void 0&&(i[r]=o)}):i=n),i},hc=n=>n.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),Xy=n=>{if(!Array.isArray(n.query)){const o=n,a=[`query=${encodeURIComponent(hc(o.query))}`];return n.variables&&a.push(`variables=${encodeURIComponent(o.jsonSerializer.stringify(o.variables))}`),o.operationName&&a.push(`operationName=${encodeURIComponent(o.operationName)}`),a.join("&")}if(typeof n.variables<"u"&&!Array.isArray(n.variables))throw new Error("Cannot create query with given variable type, array expected");const i=n,r=n.query.reduce((o,a,f)=>(o.push({query:hc(a),variables:i.variables?i.jsonSerializer.stringify(i.variables[f]):void 0}),o),[]);return`query=${encodeURIComponent(i.jsonSerializer.stringify(r))}`},Ky=n=>async i=>{const{url:r,query:o,variables:a,operationName:f,fetch:d,fetchOptions:g,middleware:m}=i,E={...i.headers};let I="",x;n==="POST"?(x=Qy(o,a,f,g.jsonSerializer),typeof x=="string"&&(E["Content-Type"]="application/json")):I=Xy({query:o,variables:a,operationName:f,jsonSerializer:g.jsonSerializer??ao});const S={method:n,headers:E,body:x,...g};let D=r,R=S;if(m){const F=await Promise.resolve(m({...S,url:r,operationName:f,variables:a})),{url:H,...ie}=F;D=H,R=ie}return I&&(D=`${D}?${I}`),await d(D,R)};class zc{constructor(i,r={}){this.url=i,this.requestConfig=r,this.rawRequest=async(...o)=>{const[a,f,d]=o,g=iy(a,f,d),{headers:m,fetch:E=jr,method:I="POST",requestMiddleware:x,responseMiddleware:S,...D}=this.requestConfig,{url:R}=this;g.signal!==void 0&&(D.signal=g.signal);const{operationName:F}=Ms(g.query);return Ps({url:R,query:g.query,variables:g.variables,headers:{...pn(Fs(m)),...pn(g.requestHeaders)},operationName:F,fetch:E,method:I,fetchOptions:D,middleware:x}).then(H=>(S&&S(H),H)).catch(H=>{throw S&&S(H),H})}}async request(i,...r){const[o,a]=r,f=ry(i,o,a),{headers:d,fetch:g=jr,method:m="POST",requestMiddleware:E,responseMiddleware:I,...x}=this.requestConfig,{url:S}=this;f.signal!==void 0&&(x.signal=f.signal);const{query:D,operationName:R}=Ms(f.document);return Ps({url:S,query:D,variables:f.variables,headers:{...pn(Fs(d)),...pn(f.requestHeaders)},operationName:R,fetch:g,method:m,fetchOptions:x,middleware:E}).then(F=>(I&&I(F),F.data)).catch(F=>{throw I&&I(F),F})}batchRequests(i,r){const o=sy(i,r),{headers:a,...f}=this.requestConfig;o.signal!==void 0&&(f.signal=o.signal);const d=o.documents.map(({document:m})=>Ms(m).query),g=o.documents.map(({variables:m})=>m);return Ps({url:this.url,query:d,variables:g,headers:{...pn(Fs(a)),...pn(o.requestHeaders)},operationName:void 0,fetch:this.requestConfig.fetch??jr,method:this.requestConfig.method||"POST",fetchOptions:f,middleware:this.requestConfig.requestMiddleware}).then(m=>(this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(m),m.data)).catch(m=>{throw this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(m),m})}setHeaders(i){return this.requestConfig.headers=i,this}setHeader(i,r){const{headers:o}=this.requestConfig;return o?o[i]=r:this.requestConfig.headers={[i]:r},this}setEndpoint(i){return this.url=i,this}}const Ps=async n=>{const{query:i,variables:r,fetchOptions:o}=n,a=Ky(ty(n.method??"post")),f=Array.isArray(n.query),d=await a(n),g=await jy(d,o.jsonSerializer??ao),m=Array.isArray(g)?!g.some(({data:I})=>!I):!!g.data,E=Array.isArray(g)||!g.errors||Array.isArray(g.errors)&&!g.errors.length||o.errorPolicy==="all"||o.errorPolicy==="ignore";if(d.ok&&E&&m){const{errors:I,...x}=(Array.isArray(g),g),S=o.errorPolicy==="ignore"?x:g;return{...f?{data:S}:S,headers:d.headers,status:d.status}}else{const I=typeof g=="string"?{error:g}:g;throw new Qn({...I,status:d.status,headers:d.headers},{query:i,variables:r})}};async function Yc(n,i,...r){const o=oy(n,i,...r);return new zc(o.url).request({...o})}const Qy=(n,i,r,o)=>{const a=o??ao;if(!Array.isArray(n))return a.stringify({query:n,variables:i,operationName:r});if(typeof i<"u"&&!Array.isArray(i))throw new Error("Cannot create request body with given variable type, array expected");const f=n.reduce((d,g,m)=>(d.push({query:g,variables:i?i[m]:void 0}),d),[]);return a.stringify(f)},jy=async(n,i)=>{let r;return n.headers.forEach((o,a)=>{a.toLowerCase()==="content-type"&&(r=o)}),r&&(r.toLowerCase().startsWith("application/json")||r.toLowerCase().startsWith("application/graphql+json")||r.toLowerCase().startsWith("application/graphql-response+json"))?i.parse(await n.text()):n.text()},Fs=n=>typeof n=="function"?n():n,Zy=mn(async({input:n})=>{var i;if(!n.endpoint||n.endpoint==="")throw new Error("No endpoint provided.");if(n.items.length<1)throw new Error("No items provided.");if(!n.document)throw new Error("No request document provided.");if(!n.requestHeaders)throw new Error("No request headers provided.");try{const r=await Yc(n.endpoint,n.document,{items:n.items},n.requestHeaders);if(!((i=r.quoteAddItem)!=null&&i.quote))throw new Error("Could not add items to quote.");return{type:"ADD_ITEMS_SUCCESS",quote:r.quoteAddItem.quote}}catch{throw new Error("Request to add item(s) failed.")}}),em=mn(async({input:n})=>{var i;if(!n.endpoint||n.endpoint==="")throw new Error("No endpoint provided.");if(n.items.length<1)throw new Error("No items provided.");try{const r=await Yc(n.endpoint,"");if(!((i=r.quoteRemoveItem)!=null&&i.quote))throw new Error("Could not remove items from quote.");return{type:"REMOVE_ITEMS_SUCCESS",quote:r.quoteRemoveItem.quote}}catch{throw new Error("Request to remove item(s) failed.")}}),Us=typeof window>"u",tm=mn(async({input:n})=>{var r,o,a,f;if(!n.endpoint)throw console.log("no endpoint"),new Error("No endpoint provided.");if(!n.endpointSsr)throw console.log("no endpoint ssr"),new Error("No SSR endpoint provided.");if(!n.locale)throw console.log("no locale"),new Error("No locale provided.");if(!n.document)throw console.log("no request document"),new Error("No request document provided.");if(!n.requestHeaders)throw console.log("no headers"),new Error("No request headers provided.");const i=new zc(Us?n.endpointSsr:n.endpoint,Us?{fetch,method:"POST"}:{credentials:"include",method:"POST",mode:"cors"});try{const{data:d,headers:g,status:m,errors:E,extensions:I}=await i.rawRequest(Vc(n.document),{},Us?{...n.requestHeaders,Cookie:`quote_${n.locale}=${n.quoteId??""}`}:n.requestHeaders),x=d;if(!((r=x.refreshQuote)!=null&&r.quote))throw console.log("userError: ",(o=x.refreshQuote)==null?void 0:o.userErrors[0].code,(a=x.refreshQuote)==null?void 0:a.userErrors[0].field,(f=x.refreshQuote)==null?void 0:f.userErrors[0].message),new Error("Could not add items to quote.");return{type:"REFRESH_SUCCESS",quote:x.refreshQuote.quote}}catch(d){throw console.log("refresh error",d),new Error("Request to add item(s) failed.")}}),nm=({context:n})=>typeof window>"u"&&n.quote.id!==""||typeof window<"u",rm=({context:n})=>!!n.quote.items&&n.quote.items.length>0,Js=si({types:{context:{},events:{},input:{}},actions:{addItems:Ue(jv),removeItems:Ue(Zv),refresh:Ue(ey)},actors:{addItems:Zy,removeItems:em,refresh:tm},guards:{canRefresh:nm,hasItems:rm}}).createMachine({id:"quote",initial:"initializing",context:({input:n})=>{var i,r,o,a,f,d,g,m,E,I,x,S,D,R;return{quote:{id:"",locale:"",baseCurrency:"USD",currencyConversionRate:1,dateCreated:null,dateLastUpdated:null,currency:"USD",items:[],promotions:[],shippingAddresses:{available:[],selected:null},totals:{discount:0,tax:0,shipping:0,shippingTax:0,subtotal:0,grandTotal:0},appliedPriceRules:[],appliedPromotions:[],shippingMethods:[],paymentMethods:[],storeCredit:[],rewards:[],giftCards:[],...(i=n==null?void 0:n.initialContext)==null?void 0:i.quote},endpoints:{client:"",server:"",...(r=n==null?void 0:n.initialContext)==null?void 0:r.endpoints},graphql:{refresh:{document:((f=(a=(o=n==null?void 0:n.initialContext)==null?void 0:o.graphql)==null?void 0:a.refresh)==null?void 0:f.document)??"",requestHeaders:((m=(g=(d=n==null?void 0:n.initialContext)==null?void 0:d.graphql)==null?void 0:g.refresh)==null?void 0:m.requestHeaders)??void 0},addItems:{document:((x=(I=(E=n==null?void 0:n.initialContext)==null?void 0:E.graphql)==null?void 0:I.addItems)==null?void 0:x.document)??"",requestHeaders:((R=(D=(S=n==null?void 0:n.initialContext)==null?void 0:S.graphql)==null?void 0:D.addItems)==null?void 0:R.requestHeaders)??void 0}},errors:[]}},states:{uninitialized:{on:{REFRESH:"refreshing"}},empty:{on:{ADD_ITEMS:"addingItems"}},active:{on:{ADD_ITEMS:"addingItems",REMOVE_ITEMS:"removingItems",REFRESH:"refreshing"}},initializing:{always:[{target:"refreshing",guard:"canRefresh"},{target:"uninitialized"}]},refreshing:{invoke:{input:({context:n})=>({endpoint:n.endpoints.client,endpointSsr:n.endpoints.server,quoteId:n.quote.id,locale:n.quote.locale,document:n.graphql.refresh.document,requestHeaders:n.graphql.refresh.requestHeaders}),src:"refresh",onDone:[{actions:["refresh"],target:"checkingItems"}],onError:{target:"empty"}}},checkingItems:{always:[{guard:"hasItems",target:"active"},{target:"empty"}]},addingItems:{invoke:{input:({context:n,event:i})=>{var r,o;return{endpoint:n.endpoints.client,items:i.type==="ADD_ITEMS"?i.items:[],document:(r=n.graphql.addItems)==null?void 0:r.document,requestHeaders:(o=n.graphql.addItems)==null?void 0:o.requestHeaders}},src:"addItems",onDone:[{actions:["addItems"],target:"active"}],onError:[{guard:"hasItems",target:"active"},{target:"empty"}]}},removingItems:{}}}),lo=ct.createContext({}),im=()=>{var m;const n=ct.useContext(lo);if(!n||!n.getSnapshot)throw new Error("quoteActor is not properly initialized");const[i,r]=ct.useState(()=>n.getSnapshot());ct.useEffect(()=>{if(!n||!n.getSnapshot){console.error("quoteActor is not properly initialized");return}(()=>{r(n.getSnapshot())})();const I=n.subscribe(x=>{r(x)});return()=>{I.unsubscribe()}},[n]),console.log("useQuote context",i.context.quote);const o=i.context.quote.items??[],a=((m=i.context.quote.items)==null?void 0:m.length)??0,f=i.matches("addingItems"),d=i.matches("removingItems"),g=i.matches("addingItems")||i.matches("removingItems");return{quoteActor:n,items:o,itemsCount:a,isAddingItems:f,isRemovingItems:d,isUpdatingItems:g}},sm=async(n={inspect:void 0,quote:{id:"",locale:""},endpoints:{client:"",server:""},graphql:{}})=>typeof window<"u"?(console.warn("App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."),Mt(Js,{inspect:n.inspect,input:{initialContext:{endpoints:n.endpoints}}}).start()):Mt(Js,{input:{initialContext:{endpoints:n.endpoints,graphql:n.graphql,quote:{id:n.quote.id??"",locale:n.quote.locale??""}}},inspect:n.inspect}).start();function om({actor:n,children:i}){return Xs.jsx(lo.Provider,{value:n,children:i})}exports.AuthContext=oo;exports.AuthProvider=zv;exports.QuoteContext=lo;exports.QuoteProvider=om;exports.ToastContext=uo;exports.ToastProvider=Kv;exports.authMachine=Hs;exports.getAuth=Vv;exports.getQuote=sm;exports.quoteMachine=Js;exports.timerMachine=Lc;exports.toastMachine=Jv;exports.useAuth=Gv;exports.useQuote=im;exports.useToast=Xv;
49
+ }`)}function I(e,t,n=""){return t!=null&&t!==""?e+t+n:""}function Ee(e){return I(" ",e.replace(/\n/g,`
50
+ `))}function Ct(e){var t;return(t=e==null?void 0:e.some(n=>n.includes(`
51
+ `)))!==null&&t!==void 0?t:!1}const Dt=e=>{var s,r;let t;const n=e.definitions.filter(i=>i.kind==="OperationDefinition");return n.length===1&&(t=(r=(s=n[0])==null?void 0:s.name)==null?void 0:r.value),t},Le=e=>{if(typeof e=="string"){let n;try{const s=Er(e);n=Dt(s)}catch{}return{query:e,operationName:n}}const t=Dt(e);return{query:hn(e),operationName:t}};class ae extends Error{constructor(t,n){const s=`${ae.extractMessage(t)}: ${JSON.stringify({response:t,request:n})}`;super(s),Object.setPrototypeOf(this,ae.prototype),this.response=t,this.request=n,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ae)}static extractMessage(t){var n,s;return((s=(n=t.errors)==null?void 0:n[0])==null?void 0:s.message)??`GraphQL Error (Code: ${t.status})`}}var Nr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function kr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ze={exports:{}};(function(e,t){var n=typeof self<"u"?self:Nr,s=function(){function i(){this.fetch=!1,this.DOMException=n.DOMException}return i.prototype=n,new i}();(function(i){(function(o){var a={searchParams:"URLSearchParams"in i,iterable:"Symbol"in i&&"iterator"in Symbol,blob:"FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in i,arrayBuffer:"ArrayBuffer"in i};function c(l){return l&&DataView.prototype.isPrototypeOf(l)}if(a.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(l){return l&&u.indexOf(Object.prototype.toString.call(l))>-1};function d(l){if(typeof l!="string"&&(l=String(l)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(l))throw new TypeError("Invalid character in header field name");return l.toLowerCase()}function f(l){return typeof l!="string"&&(l=String(l)),l}function m(l){var g={next:function(){var _=l.shift();return{done:_===void 0,value:_}}};return a.iterable&&(g[Symbol.iterator]=function(){return g}),g}function y(l){this.map={},l instanceof y?l.forEach(function(g,_){this.append(_,g)},this):Array.isArray(l)?l.forEach(function(g){this.append(g[0],g[1])},this):l&&Object.getOwnPropertyNames(l).forEach(function(g){this.append(g,l[g])},this)}y.prototype.append=function(l,g){l=d(l),g=f(g);var _=this.map[l];this.map[l]=_?_+", "+g:g},y.prototype.delete=function(l){delete this.map[d(l)]},y.prototype.get=function(l){return l=d(l),this.has(l)?this.map[l]:null},y.prototype.has=function(l){return this.map.hasOwnProperty(d(l))},y.prototype.set=function(l,g){this.map[d(l)]=f(g)},y.prototype.forEach=function(l,g){for(var _ in this.map)this.map.hasOwnProperty(_)&&l.call(g,this.map[_],_,this)},y.prototype.keys=function(){var l=[];return this.forEach(function(g,_){l.push(_)}),m(l)},y.prototype.values=function(){var l=[];return this.forEach(function(g){l.push(g)}),m(l)},y.prototype.entries=function(){var l=[];return this.forEach(function(g,_){l.push([_,g])}),m(l)},a.iterable&&(y.prototype[Symbol.iterator]=y.prototype.entries);function v(l){if(l.bodyUsed)return Promise.reject(new TypeError("Already read"));l.bodyUsed=!0}function S(l){return new Promise(function(g,_){l.onload=function(){g(l.result)},l.onerror=function(){_(l.error)}})}function A(l){var g=new FileReader,_=S(g);return g.readAsArrayBuffer(l),_}function R(l){var g=new FileReader,_=S(g);return g.readAsText(l),_}function D(l){for(var g=new Uint8Array(l),_=new Array(g.length),N=0;N<g.length;N++)_[N]=String.fromCharCode(g[N]);return _.join("")}function L(l){if(l.slice)return l.slice(0);var g=new Uint8Array(l.byteLength);return g.set(new Uint8Array(l)),g.buffer}function J(){return this.bodyUsed=!1,this._initBody=function(l){this._bodyInit=l,l?typeof l=="string"?this._bodyText=l:a.blob&&Blob.prototype.isPrototypeOf(l)?this._bodyBlob=l:a.formData&&FormData.prototype.isPrototypeOf(l)?this._bodyFormData=l:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)?this._bodyText=l.toString():a.arrayBuffer&&a.blob&&c(l)?(this._bodyArrayBuffer=L(l.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(l)||h(l))?this._bodyArrayBuffer=L(l):this._bodyText=l=Object.prototype.toString.call(l):this._bodyText="",this.headers.get("content-type")||(typeof l=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var l=v(this);if(l)return l;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?v(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(A)}),this.text=function(){var l=v(this);if(l)return l;if(this._bodyBlob)return R(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(D(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(yn)}),this.json=function(){return this.text().then(JSON.parse)},this}var le=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function he(l){var g=l.toUpperCase();return le.indexOf(g)>-1?g:l}function $(l,g){g=g||{};var _=g.body;if(l instanceof $){if(l.bodyUsed)throw new TypeError("Already read");this.url=l.url,this.credentials=l.credentials,g.headers||(this.headers=new y(l.headers)),this.method=l.method,this.mode=l.mode,this.signal=l.signal,!_&&l._bodyInit!=null&&(_=l._bodyInit,l.bodyUsed=!0)}else this.url=String(l);if(this.credentials=g.credentials||this.credentials||"same-origin",(g.headers||!this.headers)&&(this.headers=new y(g.headers)),this.method=he(g.method||this.method||"GET"),this.mode=g.mode||this.mode||null,this.signal=g.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&_)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(_)}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function yn(l){var g=new FormData;return l.trim().split("&").forEach(function(_){if(_){var N=_.split("="),O=N.shift().replace(/\+/g," "),x=N.join("=").replace(/\+/g," ");g.append(decodeURIComponent(O),decodeURIComponent(x))}}),g}function mn(l){var g=new y,_=l.replace(/\r?\n[\t ]+/g," ");return _.split(/\r?\n/).forEach(function(N){var O=N.split(":"),x=O.shift().trim();if(x){var fe=O.join(":").trim();g.append(x,fe)}}),g}J.call($.prototype);function q(l,g){g||(g={}),this.type="default",this.status=g.status===void 0?200:g.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in g?g.statusText:"OK",this.headers=new y(g.headers),this.url=g.url||"",this._initBody(l)}J.call(q.prototype),q.prototype.clone=function(){return new q(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new y(this.headers),url:this.url})},q.error=function(){var l=new q(null,{status:0,statusText:""});return l.type="error",l};var gn=[301,302,303,307,308];q.redirect=function(l,g){if(gn.indexOf(g)===-1)throw new RangeError("Invalid status code");return new q(null,{status:g,headers:{location:l}})},o.DOMException=i.DOMException;try{new o.DOMException}catch{o.DOMException=function(g,_){this.message=g,this.name=_;var N=Error(g);this.stack=N.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function Oe(l,g){return new Promise(function(_,N){var O=new $(l,g);if(O.signal&&O.signal.aborted)return N(new o.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function fe(){x.abort()}x.onload=function(){var re={status:x.status,statusText:x.statusText,headers:mn(x.getAllResponseHeaders()||"")};re.url="responseURL"in x?x.responseURL:re.headers.get("X-Request-URL");var Ne="response"in x?x.response:x.responseText;_(new q(Ne,re))},x.onerror=function(){N(new TypeError("Network request failed"))},x.ontimeout=function(){N(new TypeError("Network request failed"))},x.onabort=function(){N(new o.DOMException("Aborted","AbortError"))},x.open(O.method,O.url,!0),O.credentials==="include"?x.withCredentials=!0:O.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&a.blob&&(x.responseType="blob"),O.headers.forEach(function(re,Ne){x.setRequestHeader(Ne,re)}),O.signal&&(O.signal.addEventListener("abort",fe),x.onreadystatechange=function(){x.readyState===4&&O.signal.removeEventListener("abort",fe)}),x.send(typeof O._bodyInit>"u"?null:O._bodyInit)})}return Oe.polyfill=!0,i.fetch||(i.fetch=Oe,i.Headers=y,i.Request=$,i.Response=q),o.Headers=y,o.Request=$,o.Response=q,o.fetch=Oe,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(s),s.fetch.ponyfill=!0,delete s.fetch.polyfill;var r=s;t=r.fetch,t.default=r.fetch,t.fetch=r.fetch,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,e.exports=t})(ze,ze.exports);var Se=ze.exports;const ve=kr(Se),Cr=En({__proto__:null,default:ve},[Se]),Q=e=>{let t={};return e&&(typeof Headers<"u"&&e instanceof Headers||Cr&&Se.Headers&&e instanceof Se.Headers?t=qs(e):Array.isArray(e)?e.forEach(([n,s])=>{n&&s!==void 0&&(t[n]=s)}):t=e),t},Rt=e=>e.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),Dr=e=>{if(!Array.isArray(e.query)){const s=e,r=[`query=${encodeURIComponent(Rt(s.query))}`];return e.variables&&r.push(`variables=${encodeURIComponent(s.jsonSerializer.stringify(s.variables))}`),s.operationName&&r.push(`operationName=${encodeURIComponent(s.operationName)}`),r.join("&")}if(typeof e.variables<"u"&&!Array.isArray(e.variables))throw new Error("Cannot create query with given variable type, array expected");const t=e,n=e.query.reduce((s,r,i)=>(s.push({query:Rt(r),variables:t.variables?t.jsonSerializer.stringify(t.variables[i]):void 0}),s),[]);return`query=${encodeURIComponent(t.jsonSerializer.stringify(n))}`},Rr=e=>async t=>{const{url:n,query:s,variables:r,operationName:i,fetch:o,fetchOptions:a,middleware:c}=t,u={...t.headers};let h="",d;e==="POST"?(d=Lr(s,r,i,a.jsonSerializer),typeof d=="string"&&(u["Content-Type"]="application/json")):h=Dr({query:s,variables:r,operationName:i,jsonSerializer:a.jsonSerializer??at});const f={method:e,headers:u,body:d,...a};let m=n,y=f;if(c){const v=await Promise.resolve(c({...f,url:n,operationName:i,variables:r})),{url:S,...A}=v;m=S,y=A}return h&&(m=`${m}?${h}`),await o(m,y)};class fn{constructor(t,n={}){this.url=t,this.requestConfig=n,this.rawRequest=async(...s)=>{const[r,i,o]=s,a=Us(r,i,o),{headers:c,fetch:u=ve,method:h="POST",requestMiddleware:d,responseMiddleware:f,...m}=this.requestConfig,{url:y}=this;a.signal!==void 0&&(m.signal=a.signal);const{operationName:v}=Le(a.query);return Me({url:y,query:a.query,variables:a.variables,headers:{...Q(Pe(c)),...Q(a.requestHeaders)},operationName:v,fetch:u,method:h,fetchOptions:m,middleware:d}).then(S=>(f&&f(S),S)).catch(S=>{throw f&&f(S),S})}}async request(t,...n){const[s,r]=n,i=Fs(t,s,r),{headers:o,fetch:a=ve,method:c="POST",requestMiddleware:u,responseMiddleware:h,...d}=this.requestConfig,{url:f}=this;i.signal!==void 0&&(d.signal=i.signal);const{query:m,operationName:y}=Le(i.document);return Me({url:f,query:m,variables:i.variables,headers:{...Q(Pe(o)),...Q(i.requestHeaders)},operationName:y,fetch:a,method:c,fetchOptions:d,middleware:u}).then(v=>(h&&h(v),v.data)).catch(v=>{throw h&&h(v),v})}batchRequests(t,n){const s=Bs(t,n),{headers:r,...i}=this.requestConfig;s.signal!==void 0&&(i.signal=s.signal);const o=s.documents.map(({document:c})=>Le(c).query),a=s.documents.map(({variables:c})=>c);return Me({url:this.url,query:o,variables:a,headers:{...Q(Pe(r)),...Q(s.requestHeaders)},operationName:void 0,fetch:this.requestConfig.fetch??ve,method:this.requestConfig.method||"POST",fetchOptions:i,middleware:this.requestConfig.requestMiddleware}).then(c=>(this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(c),c.data)).catch(c=>{throw this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(c),c})}setHeaders(t){return this.requestConfig.headers=t,this}setHeader(t,n){const{headers:s}=this.requestConfig;return s?s[t]=n:this.requestConfig.headers={[t]:n},this}setEndpoint(t){return this.url=t,this}}const Me=async e=>{const{query:t,variables:n,fetchOptions:s}=e,r=Rr(Ps(e.method??"post")),i=Array.isArray(e.query),o=await r(e),a=await Mr(o,s.jsonSerializer??at),c=Array.isArray(a)?!a.some(({data:h})=>!h):!!a.data,u=Array.isArray(a)||!a.errors||Array.isArray(a.errors)&&!a.errors.length||s.errorPolicy==="all"||s.errorPolicy==="ignore";if(o.ok&&u&&c){const{errors:h,...d}=(Array.isArray(a),a),f=s.errorPolicy==="ignore"?d:a;return{...i?{data:f}:f,headers:o.headers,status:o.status}}else{const h=typeof a=="string"?{error:a}:a;throw new ae({...h,status:o.status,headers:o.headers},{query:t,variables:n})}};async function pn(e,t,...n){const s=js(e,t,...n);return new fn(s.url).request({...s})}const Lr=(e,t,n,s)=>{const r=s??at;if(!Array.isArray(e))return r.stringify({query:e,variables:t,operationName:n});if(typeof t<"u"&&!Array.isArray(t))throw new Error("Cannot create request body with given variable type, array expected");const i=e.reduce((o,a,c)=>(o.push({query:a,variables:t?t[c]:void 0}),o),[]);return r.stringify(i)},Mr=async(e,t)=>{let n;return e.headers.forEach((s,r)=>{r.toLowerCase()==="content-type"&&(n=s)}),n&&(n.toLowerCase().startsWith("application/json")||n.toLowerCase().startsWith("application/graphql+json")||n.toLowerCase().startsWith("application/graphql-response+json"))?t.parse(await e.text()):e.text()},Pe=e=>typeof e=="function"?e():e,Pr=Z(async({input:e})=>{var t;if(!e.endpoint||e.endpoint==="")throw new Error("No endpoint provided.");if(e.items.length<1)throw new Error("No items provided.");if(!e.document)throw new Error("No request document provided.");if(!e.requestHeaders)throw new Error("No request headers provided.");try{const n=await pn(e.endpoint,e.document,{items:e.items},e.requestHeaders);if(!((t=n.quoteAddItem)!=null&&t.quote))throw new Error("Could not add items to quote.");return{type:"ADD_ITEMS_SUCCESS",quote:n.quoteAddItem.quote}}catch{throw new Error("Request to add item(s) failed.")}}),qr=Z(async({input:e})=>{var t;if(!e.endpoint||e.endpoint==="")throw new Error("No endpoint provided.");if(e.items.length<1)throw new Error("No items provided.");try{const n=await pn(e.endpoint,"");if(!((t=n.quoteRemoveItem)!=null&&t.quote))throw new Error("Could not remove items from quote.");return{type:"REMOVE_ITEMS_SUCCESS",quote:n.quoteRemoveItem.quote}}catch{throw new Error("Request to remove item(s) failed.")}}),qe=typeof window>"u",Fr=Z(async({input:e})=>{var n,s,r,i;if(!e.endpoint)throw console.log("no endpoint"),new Error("No endpoint provided.");if(!e.endpointSsr)throw console.log("no endpoint ssr"),new Error("No SSR endpoint provided.");if(!e.locale)throw console.log("no locale"),new Error("No locale provided.");if(!e.document)throw console.log("no request document"),new Error("No request document provided.");if(!e.requestHeaders)throw console.log("no headers"),new Error("No request headers provided.");const t=new fn(qe?e.endpointSsr:e.endpoint,qe?{fetch,method:"POST"}:{credentials:"include",method:"POST",mode:"cors"});try{const{data:o,headers:a,status:c,errors:u,extensions:h}=await t.rawRequest(hn(e.document),{},qe?{...e.requestHeaders,Cookie:`quote_${e.locale}=${e.quoteId??""}`}:e.requestHeaders),d=o;if(!((n=d.refreshQuote)!=null&&n.quote))throw console.log("userError: ",(s=d.refreshQuote)==null?void 0:s.userErrors[0].code,(r=d.refreshQuote)==null?void 0:r.userErrors[0].field,(i=d.refreshQuote)==null?void 0:i.userErrors[0].message),new Error("Could not add items to quote.");return{type:"REFRESH_SUCCESS",quote:d.refreshQuote.quote}}catch(o){throw console.log("refresh error",o),new Error("Request to add item(s) failed.")}}),Ur=({context:e})=>typeof window>"u"&&e.quote.id!==""||typeof window<"u",Br=({context:e})=>!!e.quote.items&&e.quote.items.length>0,Je=Ae({types:{context:{},events:{},input:{}},actions:{addItems:C(Rs),removeItems:C(Ls),refresh:C(Ms)},actors:{addItems:Pr,removeItems:qr,refresh:Fr},guards:{canRefresh:Ur,hasItems:Br}}).createMachine({id:"quote",initial:"initializing",context:({input:e})=>{var t,n,s,r,i,o,a,c,u,h,d,f,m,y;return{quote:{id:"",locale:"",baseCurrency:"USD",currencyConversionRate:1,dateCreated:null,dateLastUpdated:null,currency:"USD",items:[],promotions:[],shippingAddresses:{available:[],selected:null},totals:{discount:0,tax:0,shipping:0,shippingTax:0,subtotal:0,grandTotal:0},appliedPriceRules:[],appliedPromotions:[],shippingMethods:[],paymentMethods:[],storeCredit:[],rewards:[],giftCards:[],...(t=e==null?void 0:e.initialContext)==null?void 0:t.quote},endpoints:{client:"",server:"",...(n=e==null?void 0:e.initialContext)==null?void 0:n.endpoints},graphql:{refresh:{document:((i=(r=(s=e==null?void 0:e.initialContext)==null?void 0:s.graphql)==null?void 0:r.refresh)==null?void 0:i.document)??"",requestHeaders:((c=(a=(o=e==null?void 0:e.initialContext)==null?void 0:o.graphql)==null?void 0:a.refresh)==null?void 0:c.requestHeaders)??void 0},addItems:{document:((d=(h=(u=e==null?void 0:e.initialContext)==null?void 0:u.graphql)==null?void 0:h.addItems)==null?void 0:d.document)??"",requestHeaders:((y=(m=(f=e==null?void 0:e.initialContext)==null?void 0:f.graphql)==null?void 0:m.addItems)==null?void 0:y.requestHeaders)??void 0}},errors:[]}},states:{uninitialized:{on:{REFRESH:"refreshing"}},empty:{on:{ADD_ITEMS:"addingItems"}},active:{on:{ADD_ITEMS:"addingItems",REMOVE_ITEMS:"removingItems",REFRESH:"refreshing"}},initializing:{always:[{target:"refreshing",guard:"canRefresh"},{target:"uninitialized"}]},refreshing:{invoke:{input:({context:e})=>({endpoint:e.endpoints.client,endpointSsr:e.endpoints.server,quoteId:e.quote.id,locale:e.quote.locale,document:e.graphql.refresh.document,requestHeaders:e.graphql.refresh.requestHeaders}),src:"refresh",onDone:[{actions:["refresh"],target:"checkingItems"}],onError:{target:"empty"}}},checkingItems:{always:[{guard:"hasItems",target:"active"},{target:"empty"}]},addingItems:{invoke:{input:({context:e,event:t})=>{var n,s;return{endpoint:e.endpoints.client,items:t.type==="ADD_ITEMS"?t.items:[],document:(n=e.graphql.addItems)==null?void 0:n.document,requestHeaders:(s=e.graphql.addItems)==null?void 0:s.requestHeaders}},src:"addItems",onDone:[{actions:["addItems"],target:"active"}],onError:[{guard:"hasItems",target:"active"},{target:"empty"}]}},removingItems:{}}}),dt=P.createContext({}),jr=()=>{var c;const e=P.useContext(dt);if(!e||!e.getSnapshot)throw new Error("quoteActor is not properly initialized");const[t,n]=P.useState(()=>e.getSnapshot());P.useEffect(()=>{if(!e||!e.getSnapshot){console.error("quoteActor is not properly initialized");return}(()=>{n(e.getSnapshot())})();const h=e.subscribe(d=>{n(d)});return()=>{h.unsubscribe()}},[e]);const s=t.context.quote.items??[],r=((c=t.context.quote.items)==null?void 0:c.length)??0,i=t.matches("addingItems"),o=t.matches("removingItems"),a=t.matches("addingItems")||t.matches("removingItems");return{quoteActor:e,items:s,itemsCount:r,isAddingItems:i,isRemovingItems:o,isUpdatingItems:a}},$r=async(e={inspect:void 0,quote:{id:"",locale:""},endpoints:{client:"",server:""},graphql:{}})=>typeof window<"u"?(console.warn("App.getInitialProps::getAuth should not be run on the frontend. You are probably missing getServerSideProps in your page."),B(Je,{inspect:e.inspect,input:{initialContext:{endpoints:e.endpoints}}}).start()):B(Je,{input:{initialContext:{endpoints:e.endpoints,graphql:e.graphql,quote:{id:e.quote.id??"",locale:e.quote.locale??""}}},inspect:e.inspect}).start();function Vr({actor:e,children:t}){return Ye.jsx(dt.Provider,{value:e,children:t})}exports.AuthContext=it;exports.AuthProvider=Os;exports.QuoteContext=dt;exports.QuoteProvider=Vr;exports.ToastContext=ot;exports.ToastProvider=Ds;exports.authMachine=$e;exports.getAuth=bs;exports.getQuote=$r;exports.quoteMachine=Je;exports.timerMachine=en;exports.toastMachine=ks;exports.useAuth=ws;exports.useQuote=jr;exports.useToast=Cs;