@apolopay-sdk/ui 1.2.0 → 1.2.1

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.
@@ -3148,7 +3148,7 @@ var nr = class {
3148
3148
  extraHeaders: {
3149
3149
  "x-public-key": this.client.getPublicKey()
3150
3150
  },
3151
- transports: ["websocket", "polling"]
3151
+ transports: ["polling"]
3152
3152
  });
3153
3153
  const { processId: e } = s;
3154
3154
  this.socket.on("connect", () => this.socket?.emit("process:connect", { processId: e })), console.log(`Conectado a Socket.io para processId: ${e}`), this.socket.on("process:message", (t) => this.handleWebSocketMessage(t)), this.socket.on("connect_error", (t) => {
@@ -1,6 +1,6 @@
1
1
  (function(c,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(c=typeof globalThis<"u"?globalThis:c||self,x(c.ApoloPaySDK={}))})(this,(function(c){"use strict";const x=globalThis,vt=x.ShadowRoot&&(x.ShadyCSS===void 0||x.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,bt=Symbol(),qt=new WeakMap;let Gt=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==bt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(vt&&t===void 0){const r=e!==void 0&&e.length===1;r&&(t=qt.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&qt.set(e,t))}return t}toString(){return this.cssText}};const Ie=s=>new Gt(typeof s=="string"?s:s+"",void 0,bt),U=(s,...t)=>{const e=s.length===1?s[0]:t.reduce((r,i,n)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+s[n+1],s[0]);return new Gt(e,s,bt)},Qe=(s,t)=>{if(vt)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const r=document.createElement("style"),i=x.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=e.cssText,s.appendChild(r)}},Yt=vt?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const r of t.cssRules)e+=r.cssText;return Ie(e)})(s):s;const{is:Pe,defineProperty:Le,getOwnPropertyDescriptor:Ze,getOwnPropertyNames:Re,getOwnPropertySymbols:ze,getPrototypeOf:Me}=Object,it=globalThis,Ht=it.trustedTypes,De=Ht?Ht.emptyScript:"",Xe=it.reactiveElementPolyfillSupport,q=(s,t)=>s,nt={toAttribute(s,t){switch(t){case Boolean:s=s?De:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},St=(s,t)=>!Pe(s,t),_t={attribute:!0,type:String,converter:nt,reflect:!1,useDefault:!1,hasChanged:St};Symbol.metadata??=Symbol("metadata"),it.litPropertyMetadata??=new WeakMap;let X=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=_t){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const r=Symbol(),i=this.getPropertyDescriptor(t,r,e);i!==void 0&&Le(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){const{get:i,set:n}=Ze(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){const l=i?.call(this);n?.call(this,o),this.requestUpdate(t,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??_t}static _$Ei(){if(this.hasOwnProperty(q("elementProperties")))return;const t=Me(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(q("properties"))){const e=this.properties,r=[...Re(e),...ze(e)];for(const i of r)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[r,i]of e)this.elementProperties.set(r,i)}this._$Eh=new Map;for(const[e,r]of this.elementProperties){const i=this._$Eu(e,r);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const r=new Set(t.flat(1/0).reverse());for(const i of r)e.unshift(Yt(i))}else t!==void 0&&e.push(Yt(t));return e}static _$Eu(t,e){const r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Qe(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){const r=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,r);if(i!==void 0&&r.reflect===!0){const n=(r.converter?.toAttribute!==void 0?r.converter:nt).toAttribute(e,r.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const r=this.constructor,i=r._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const n=r.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:nt;this._$Em=i;const l=o.fromAttribute(e,n.type);this[i]=l??this._$Ej?.get(i)??l,this._$Em=null}}requestUpdate(t,e,r,i=!1,n){if(t!==void 0){const o=this.constructor;if(i===!1&&(n=this[t]),r??=o.getPropertyOptions(t),!((r.hasChanged??St)(n,e)||r.useDefault&&r.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:i,wrapped:n},o){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}const r=this.constructor.elementProperties;if(r.size>0)for(const[i,n]of r){const{wrapped:o}=n,l=this[i];o!==!0||this._$AL.has(i)||l===void 0||this.C(i,void 0,n,l)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(e)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}};X.elementStyles=[],X.shadowRootOptions={mode:"open"},X[q("elementProperties")]=new Map,X[q("finalized")]=new Map,Xe?.({ReactiveElement:X}),(it.reactiveElementVersions??=[]).push("2.1.2");const Ct=globalThis,$t=s=>s,ot=Ct.trustedTypes,te=ot?ot.createPolicy("lit-html",{createHTML:s=>s}):void 0,ee="$lit$",I=`lit$${Math.random().toFixed(9).slice(2)}$`,se="?"+I,Ve=`<${se}>`,Z=document,G=()=>Z.createComment(""),Y=s=>s===null||typeof s!="object"&&typeof s!="function",Et=Array.isArray,Fe=s=>Et(s)||typeof s?.[Symbol.iterator]=="function",Jt=`[
2
2
  \f\r]`,H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,re=/-->/g,ie=/>/g,R=RegExp(`>|${Jt}(?:([^\\s"'>=/]+)(${Jt}*=${Jt}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),ne=/'/g,oe=/"/g,ae=/^(?:script|style|textarea|title)$/i,We=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),f=We(1),z=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),le=new WeakMap,M=Z.createTreeWalker(Z,129);function ce(s,t){if(!Et(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return te!==void 0?te.createHTML(t):t}const je=(s,t)=>{const e=s.length-1,r=[];let i,n=t===2?"<svg>":t===3?"<math>":"",o=H;for(let l=0;l<e;l++){const a=s[l];let d,A,p=-1,E=0;for(;E<a.length&&(o.lastIndex=E,A=o.exec(a),A!==null);)E=o.lastIndex,o===H?A[1]==="!--"?o=re:A[1]!==void 0?o=ie:A[2]!==void 0?(ae.test(A[2])&&(i=RegExp("</"+A[2],"g")),o=R):A[3]!==void 0&&(o=R):o===R?A[0]===">"?(o=i??H,p=-1):A[1]===void 0?p=-2:(p=o.lastIndex-A[2].length,d=A[1],o=A[3]===void 0?R:A[3]==='"'?oe:ne):o===oe||o===ne?o=R:o===re||o===ie?o=H:(o=R,i=void 0);const N=o===R&&s[l+1].startsWith("/>")?" ":"";n+=o===H?a+Ve:p>=0?(r.push(d),a.slice(0,p)+ee+a.slice(p)+I+N):a+I+(p===-2?l:N)}return[ce(s,n+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]};class _{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let n=0,o=0;const l=t.length-1,a=this.parts,[d,A]=je(t,e);if(this.el=_.createElement(d,r),M.currentNode=this.el.content,e===2||e===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=M.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(ee)){const E=A[o++],N=i.getAttribute(p).split(I),j=/([.?@])?(.*)/.exec(E);a.push({type:1,index:n,name:j[2],strings:N,ctor:j[1]==="."?Ge:j[1]==="?"?Ye:j[1]==="@"?He:at}),i.removeAttribute(p)}else p.startsWith(I)&&(a.push({type:6,index:n}),i.removeAttribute(p));if(ae.test(i.tagName)){const p=i.textContent.split(I),E=p.length-1;if(E>0){i.textContent=ot?ot.emptyScript:"";for(let N=0;N<E;N++)i.append(p[N],G()),M.nextNode(),a.push({type:2,index:++n});i.append(p[E],G())}}}else if(i.nodeType===8)if(i.data===se)a.push({type:2,index:n});else{let p=-1;for(;(p=i.data.indexOf(I,p+1))!==-1;)a.push({type:7,index:n}),p+=I.length-1}n++}}static createElement(t,e){const r=Z.createElement("template");return r.innerHTML=t,r}}function V(s,t,e=s,r){if(t===z)return t;let i=r!==void 0?e._$Co?.[r]:e._$Cl;const n=Y(t)?void 0:t._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),n===void 0?i=void 0:(i=new n(s),i._$AT(s,e,r)),r!==void 0?(e._$Co??=[])[r]=i:e._$Cl=i),i!==void 0&&(t=V(s,i._$AS(s,t.values),i,r)),t}class qe{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,i=(t?.creationScope??Z).importNode(e,!0);M.currentNode=i;let n=M.nextNode(),o=0,l=0,a=r[0];for(;a!==void 0;){if(o===a.index){let d;a.type===2?d=new $(n,n.nextSibling,this,t):a.type===1?d=new a.ctor(n,a.name,a.strings,this,t):a.type===6&&(d=new _e(n,this,t)),this._$AV.push(d),a=r[++l]}o!==a?.index&&(n=M.nextNode(),o++)}return M.currentNode=Z,i}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}class ${get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=V(this,t,e),Y(t)?t===b||t==null||t===""?(this._$AH!==b&&this._$AR(),this._$AH=b):t!==this._$AH&&t!==z&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Fe(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==b&&Y(this._$AH)?this._$AA.nextSibling.data=t:this.T(Z.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=_.createElement(ce(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(e);else{const n=new qe(i,this),o=n.u(this.options);n.p(e),this.T(o),this._$AH=n}}_$AC(t){let e=le.get(t.strings);return e===void 0&&le.set(t.strings,e=new _(t)),e}k(t){Et(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,i=0;for(const n of t)i===e.length?e.push(r=new $(this.O(G()),this.O(G()),this,this.options)):r=e[i],r._$AI(n),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const r=$t(t).nextSibling;$t(t).remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}class at{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,n){this.type=1,this._$AH=b,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=b}_$AI(t,e=this,r,i){const n=this.strings;let o=!1;if(n===void 0)t=V(this,t,e,0),o=!Y(t)||t!==this._$AH&&t!==z,o&&(this._$AH=t);else{const l=t;let a,d;for(t=n[0],a=0;a<n.length-1;a++)d=V(this,l[r+a],e,a),d===z&&(d=this._$AH[a]),o||=!Y(d)||d!==this._$AH[a],d===b?t=b:t!==b&&(t+=(d??"")+n[a+1]),this._$AH[a]=d}o&&!i&&this.j(t)}j(t){t===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ge extends at{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===b?void 0:t}}class Ye extends at{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==b)}}class He extends at{constructor(t,e,r,i,n){super(t,e,r,i,n),this.type=5}_$AI(t,e=this){if((t=V(this,t,e,0)??b)===z)return;const r=this._$AH,i=t===b&&r!==b||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,n=t!==b&&(r===b||i);i&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class _e{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const $e=Ct.litHtmlPolyfillSupport;$e?.(_,$),(Ct.litHtmlVersions??=[]).push("3.3.2");const ts=(s,t,e)=>{const r=e?.renderBefore??t;let i=r._$litPart$;if(i===void 0){const n=e?.renderBefore??null;r._$litPart$=i=new $(t.insertBefore(G(),n),n,void 0,e??{})}return i._$AI(s),i};const wt=globalThis;let Q=class extends X{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=ts(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return z}};Q._$litElement$=!0,Q.finalized=!0,wt.litElementHydrateSupport?.({LitElement:Q});const es=wt.litElementPolyfillSupport;es?.({LitElement:Q}),(wt.litElementVersions??=[]).push("4.2.2");const lt=s=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(s,t)}):customElements.define(s,t)};const ss={attribute:!0,type:String,converter:nt,reflect:!1,hasChanged:St},rs=(s=ss,t,e)=>{const{kind:r,metadata:i}=e;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),r==="setter"&&((s=Object.create(s)).wrapped=!0),n.set(e.name,s),r==="accessor"){const{name:o}=e;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,a,s,!0,l)},init(l){return l!==void 0&&this.C(o,void 0,s,l),l}}}if(r==="setter"){const{name:o}=e;return function(l){const a=this[o];t.call(this,l),this.requestUpdate(o,a,s,!0,l)}}throw Error("Unsupported decorator location: "+r)};function u(s){return(t,e)=>typeof e=="object"?rs(s,t,e):((r,i,n)=>{const o=i.hasOwnProperty(n);return i.constructor.createProperty(n,r),o?Object.getOwnPropertyDescriptor(i,n):void 0})(s,t,e)}function S(s){return u({...s,state:!0,attribute:!1})}const is=(s,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(s,t,e),e);function ns(s,t){return(e,r,i)=>{const n=o=>o.renderRoot?.querySelector(s)??null;return is(e,r,{get(){return n(this)}})}}const T=Object.create(null);T.open="0",T.close="1",T.ping="2",T.pong="3",T.message="4",T.upgrade="5",T.noop="6";const ct=Object.create(null);Object.keys(T).forEach(s=>{ct[T[s]]=s});const Kt={type:"error",data:"parser error"},he=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",pe=typeof ArrayBuffer=="function",de=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,Tt=({type:s,data:t},e,r)=>he&&t instanceof Blob?e?r(t):ue(t,r):pe&&(t instanceof ArrayBuffer||de(t))?e?r(t):ue(new Blob([t]),r):r(T[s]+(t||"")),ue=(s,t)=>{const e=new FileReader;return e.onload=function(){const r=e.result.split(",")[1];t("b"+(r||""))},e.readAsDataURL(s)};function Ae(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Ot;function os(s,t){if(he&&s.data instanceof Blob)return s.data.arrayBuffer().then(Ae).then(t);if(pe&&(s.data instanceof ArrayBuffer||de(s.data)))return t(Ae(s.data));Tt(s,!1,e=>{Ot||(Ot=new TextEncoder),t(Ot.encode(e))})}const fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",tt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<fe.length;s++)tt[fe.charCodeAt(s)]=s;const as=s=>{let t=s.length*.75,e=s.length,r,i=0,n,o,l,a;s[s.length-1]==="="&&(t--,s[s.length-2]==="="&&t--);const d=new ArrayBuffer(t),A=new Uint8Array(d);for(r=0;r<e;r+=4)n=tt[s.charCodeAt(r)],o=tt[s.charCodeAt(r+1)],l=tt[s.charCodeAt(r+2)],a=tt[s.charCodeAt(r+3)],A[i++]=n<<2|o>>4,A[i++]=(o&15)<<4|l>>2,A[i++]=(l&3)<<6|a&63;return d},ls=typeof ArrayBuffer=="function",Bt=(s,t)=>{if(typeof s!="string")return{type:"message",data:me(s,t)};const e=s.charAt(0);return e==="b"?{type:"message",data:cs(s.substring(1),t)}:ct[e]?s.length>1?{type:ct[e],data:s.substring(1)}:{type:ct[e]}:Kt},cs=(s,t)=>{if(ls){const e=as(s);return me(e,t)}else return{base64:!0,data:s}},me=(s,t)=>t==="blob"?s instanceof Blob?s:new Blob([s]):s instanceof ArrayBuffer?s:s.buffer,ye="",hs=(s,t)=>{const e=s.length,r=new Array(e);let i=0;s.forEach((n,o)=>{Tt(n,!1,l=>{r[o]=l,++i===e&&t(r.join(ye))})})},ps=(s,t)=>{const e=s.split(ye),r=[];for(let i=0;i<e.length;i++){const n=Bt(e[i],t);if(r.push(n),n.type==="error")break}return r};function ds(){return new TransformStream({transform(s,t){os(s,e=>{const r=e.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const n=new DataView(i.buffer);n.setUint8(0,126),n.setUint16(1,r)}else{i=new Uint8Array(9);const n=new DataView(i.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(r))}s.data&&typeof s.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(e)})}})}let Ut;function ht(s){return s.reduce((t,e)=>t+e.length,0)}function pt(s,t){if(s[0].length===t)return s.shift();const e=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)e[i]=s[0][r++],r===s[0].length&&(s.shift(),r=0);return s.length&&r<s[0].length&&(s[0]=s[0].slice(r)),e}function us(s,t){Ut||(Ut=new TextDecoder);const e=[];let r=0,i=-1,n=!1;return new TransformStream({transform(o,l){for(e.push(o);;){if(r===0){if(ht(e)<1)break;const a=pt(e,1);n=(a[0]&128)===128,i=a[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(ht(e)<2)break;const a=pt(e,2);i=new DataView(a.buffer,a.byteOffset,a.length).getUint16(0),r=3}else if(r===2){if(ht(e)<8)break;const a=pt(e,8),d=new DataView(a.buffer,a.byteOffset,a.length),A=d.getUint32(0);if(A>Math.pow(2,21)-1){l.enqueue(Kt);break}i=A*Math.pow(2,32)+d.getUint32(4),r=3}else{if(ht(e)<i)break;const a=pt(e,i);l.enqueue(Bt(n?a:Ut.decode(a),t)),r=0}if(i===0||i>s){l.enqueue(Kt);break}}}})}const ge=4;function C(s){if(s)return As(s)}function As(s){for(var t in C.prototype)s[t]=C.prototype[t];return s}C.prototype.on=C.prototype.addEventListener=function(s,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(t),this},C.prototype.once=function(s,t){function e(){this.off(s,e),t.apply(this,arguments)}return e.fn=t,this.on(s,e),this},C.prototype.off=C.prototype.removeListener=C.prototype.removeAllListeners=C.prototype.removeEventListener=function(s,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var e=this._callbacks["$"+s];if(!e)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var r,i=0;i<e.length;i++)if(r=e[i],r===t||r.fn===t){e.splice(i,1);break}return e.length===0&&delete this._callbacks["$"+s],this},C.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),e=this._callbacks["$"+s],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(e){e=e.slice(0);for(var r=0,i=e.length;r<i;++r)e[r].apply(this,t)}return this},C.prototype.emitReserved=C.prototype.emit,C.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]},C.prototype.hasListeners=function(s){return!!this.listeners(s).length};const dt=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,e)=>e(t,0),w=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),fs="arraybuffer";function Er(){}function ke(s,...t){return t.reduce((e,r)=>(s.hasOwnProperty(r)&&(e[r]=s[r]),e),{})}const ms=w.setTimeout,ys=w.clearTimeout;function ut(s,t){t.useNativeTimers?(s.setTimeoutFn=ms.bind(w),s.clearTimeoutFn=ys.bind(w)):(s.setTimeoutFn=w.setTimeout.bind(w),s.clearTimeoutFn=w.clearTimeout.bind(w))}const gs=1.33;function ks(s){return typeof s=="string"?vs(s):Math.ceil((s.byteLength||s.size)*gs)}function vs(s){let t=0,e=0;for(let r=0,i=s.length;r<i;r++)t=s.charCodeAt(r),t<128?e+=1:t<2048?e+=2:t<55296||t>=57344?e+=3:(r++,e+=4);return e}function ve(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function bs(s){let t="";for(let e in s)s.hasOwnProperty(e)&&(t.length&&(t+="&"),t+=encodeURIComponent(e)+"="+encodeURIComponent(s[e]));return t}function Ss(s){let t={},e=s.split("&");for(let r=0,i=e.length;r<i;r++){let n=e[r].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}class Cs extends Error{constructor(t,e,r){super(t),this.description=e,this.context=r,this.type="TransportError"}}class Nt extends C{constructor(t){super(),this.writable=!1,ut(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,e,r){return super.emitReserved("error",new Cs(t,e,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=Bt(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const e=bs(t);return e.length?"?"+e:""}}class Es extends Nt{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||e()})),this.writable||(r++,this.once("drain",function(){--r||e()}))}else e()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const e=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};ps(t,this.socket.binaryType).forEach(e),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,hs(t,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=ve()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}}let be=!1;try{be=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Js=be;function ws(){}class Ks extends Es{constructor(t){if(super(t),typeof location<"u"){const e=location.protocol==="https:";let r=location.port;r||(r=e?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,e){const r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",(i,n)=>{this.onError("xhr post error",i,n)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(e,r)=>{this.onError("xhr poll error",e,r)}),this.pollXhr=t}}class O extends C{constructor(t,e,r){super(),this.createRequest=t,ut(this,r),this._opts=r,this._method=r.method||"GET",this._uri=e,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const e=ke(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(e);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=O.requestsCount++,O.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=ws,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete O.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(O.requestsCount=0,O.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Se);else if(typeof addEventListener=="function"){const s="onpagehide"in w?"pagehide":"unload";addEventListener(s,Se,!1)}}function Se(){for(let s in O.requests)O.requests.hasOwnProperty(s)&&O.requests[s].abort()}const Ts=(function(){const s=Ce({xdomain:!1});return s&&s.responseType!==null})();class Os extends Ks{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=Ts&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new O(Ce,this.uri(),t)}}function Ce(s){const t=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Js))return new XMLHttpRequest}catch{}if(!t)try{return new w[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ee=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Bs extends Nt{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,r=Ee?{}:ke(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,e,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],i=e===t.length-1;Tt(r,this.supportsBinary,n=>{try{this.doWrite(r,n)}catch{}i&&dt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=ve()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const xt=w.WebSocket||w.MozWebSocket;class Us extends Bs{createSocket(t,e,r){return Ee?new xt(t,e,r):e?new xt(t,e):new xt(t)}doWrite(t,e){this.ws.send(e)}}class Ns extends Nt{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const e=us(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(e).getReader(),i=ds();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();const n=()=>{r.read().then(({done:l,value:a})=>{l||(this.onPacket(a),n())}).catch(l=>{})};n();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],i=e===t.length-1;this._writer.write(r).then(()=>{i&&dt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const xs={websocket:Us,webtransport:Ns,polling:Os},Is=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Qs=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function It(s){if(s.length>8e3)throw"URI too long";const t=s,e=s.indexOf("["),r=s.indexOf("]");e!=-1&&r!=-1&&(s=s.substring(0,e)+s.substring(e,r).replace(/:/g,";")+s.substring(r,s.length));let i=Is.exec(s||""),n={},o=14;for(;o--;)n[Qs[o]]=i[o]||"";return e!=-1&&r!=-1&&(n.source=t,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=Ps(n,n.path),n.queryKey=Ls(n,n.query),n}function Ps(s,t){const e=/\/{2,9}/g,r=t.replace(e,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Ls(s,t){const e={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,n){i&&(e[i]=n)}),e}const Qt=typeof addEventListener=="function"&&typeof removeEventListener=="function",At=[];Qt&&addEventListener("offline",()=>{At.forEach(s=>s())},!1);class P extends C{constructor(t,e){if(super(),this.binaryType=fs,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(e=t,t=null),t){const r=It(t);e.hostname=r.host,e.secure=r.protocol==="https"||r.protocol==="wss",e.port=r.port,r.query&&(e.query=r.query)}else e.host&&(e.hostname=It(e.host).host);ut(this,e),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},e.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ss(this.opts.query)),Qt&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},At.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=ge,e.transport=t,this.id&&(e.sid=this.id);const r=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&P.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const e=this.createTransport(t);e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",P.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const e=new Error("server error");e.code=t.data,this._onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(e+=ks(i)),r>0&&e>this._maxPayload)return this.writeBuffer.slice(0,r);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,dt(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,e,r){return this._sendPacket("message",t,e,r),this}send(t,e,r){return this._sendPacket("message",t,e,r),this}_sendPacket(t,e,r,i){if(typeof e=="function"&&(i=e,e=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const n={type:t,data:e,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},r=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(P.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Qt&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=At.indexOf(this._offlineEventListener);r!==-1&&At.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}P.protocol=ge;class Zs extends P{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let e=this.createTransport(t),r=!1;P.priorWebsocketSuccess=!1;const i=()=>{r||(e.send([{type:"ping",data:"probe"}]),e.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;P.priorWebsocketSuccess=e.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(A(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{const E=new Error("probe error");E.transport=e.name,this.emitReserved("upgradeError",E)}}))};function n(){r||(r=!0,A(),e.close(),e=null)}const o=p=>{const E=new Error("probe error: "+p);E.transport=e.name,n(),this.emitReserved("upgradeError",E)};function l(){o("transport closed")}function a(){o("socket closed")}function d(p){e&&p.name!==e.name&&n()}const A=()=>{e.removeListener("open",i),e.removeListener("error",o),e.removeListener("close",l),this.off("close",a),this.off("upgrading",d)};e.once("open",i),e.once("error",o),e.once("close",l),this.once("close",a),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||e.open()},200):e.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const e=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&e.push(t[r]);return e}}let Rs=class extends Zs{constructor(t,e={}){const r=typeof t=="object"?t:e;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>xs[i]).filter(i=>!!i)),super(t,r)}};function zs(s,t="",e){let r=s;e=e||typeof location<"u"&&location,s==null&&(s=e.protocol+"//"+e.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=e.protocol+s:s=e.host+s),/^(https?|wss?):\/\//.test(s)||(typeof e<"u"?s=e.protocol+"//"+s:s="https://"+s),r=It(s)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const n=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+n+":"+r.port+t,r.href=r.protocol+"://"+n+(e&&e.port===r.port?"":":"+r.port),r}const Ms=typeof ArrayBuffer=="function",Ds=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,Je=Object.prototype.toString,Xs=typeof Blob=="function"||typeof Blob<"u"&&Je.call(Blob)==="[object BlobConstructor]",Vs=typeof File=="function"||typeof File<"u"&&Je.call(File)==="[object FileConstructor]";function Pt(s){return Ms&&(s instanceof ArrayBuffer||Ds(s))||Xs&&s instanceof Blob||Vs&&s instanceof File}function ft(s,t){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let e=0,r=s.length;e<r;e++)if(ft(s[e]))return!0;return!1}if(Pt(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return ft(s.toJSON(),!0);for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)&&ft(s[e]))return!0;return!1}function Fs(s){const t=[],e=s.data,r=s;return r.data=Lt(e,t),r.attachments=t.length,{packet:r,buffers:t}}function Lt(s,t){if(!s)return s;if(Pt(s)){const e={_placeholder:!0,num:t.length};return t.push(s),e}else if(Array.isArray(s)){const e=new Array(s.length);for(let r=0;r<s.length;r++)e[r]=Lt(s[r],t);return e}else if(typeof s=="object"&&!(s instanceof Date)){const e={};for(const r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=Lt(s[r],t));return e}return s}function Ws(s,t){return s.data=Zt(s.data,t),delete s.attachments,s}function Zt(s,t){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<t.length)return t[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let e=0;e<s.length;e++)s[e]=Zt(s[e],t);else if(typeof s=="object")for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]=Zt(s[e],t));return s}const we=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],js=5;var h;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(h||(h={}));class qs{constructor(t){this.replacer=t}encode(t){return(t.type===h.EVENT||t.type===h.ACK)&&ft(t)?this.encodeAsBinary({type:t.type===h.EVENT?h.BINARY_EVENT:h.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let e=""+t.type;return(t.type===h.BINARY_EVENT||t.type===h.BINARY_ACK)&&(e+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(e+=t.nsp+","),t.id!=null&&(e+=t.id),t.data!=null&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=Fs(t),r=this.encodeAsString(e.packet),i=e.buffers;return i.unshift(r),i}}class Rt extends C{constructor(t){super(),this.reviver=t}add(t){let e;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const r=e.type===h.BINARY_EVENT;r||e.type===h.BINARY_ACK?(e.type=r?h.EVENT:h.ACK,this.reconstructor=new Gs(e),e.attachments===0&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else if(Pt(t)||t.base64)if(this.reconstructor)e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(h[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===h.BINARY_EVENT||r.type===h.BINARY_ACK){const n=e+1;for(;t.charAt(++e)!=="-"&&e!=t.length;);const o=t.substring(n,e);if(o!=Number(o)||t.charAt(e)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(t.charAt(e+1)==="/"){const n=e+1;for(;++e&&!(t.charAt(e)===","||e===t.length););r.nsp=t.substring(n,e)}else r.nsp="/";const i=t.charAt(e+1);if(i!==""&&Number(i)==i){const n=e+1;for(;++e;){const o=t.charAt(e);if(o==null||Number(o)!=o){--e;break}if(e===t.length)break}r.id=Number(t.substring(n,e+1))}if(t.charAt(++e)){const n=this.tryParse(t.substr(e));if(Rt.isPayloadValid(r.type,n))r.data=n;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,e){switch(t){case h.CONNECT:return mt(e);case h.DISCONNECT:return e===void 0;case h.CONNECT_ERROR:return typeof e=="string"||mt(e);case h.EVENT:case h.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&we.indexOf(e[0])===-1);case h.ACK:case h.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Gs{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const e=Ws(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Ys(s){return typeof s=="string"}const Hs=Number.isInteger||function(s){return typeof s=="number"&&isFinite(s)&&Math.floor(s)===s};function _s(s){return s===void 0||Hs(s)}function mt(s){return Object.prototype.toString.call(s)==="[object Object]"}function $s(s,t){switch(s){case h.CONNECT:return t===void 0||mt(t);case h.DISCONNECT:return t===void 0;case h.EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&we.indexOf(t[0])===-1);case h.ACK:return Array.isArray(t);case h.CONNECT_ERROR:return typeof t=="string"||mt(t);default:return!1}}function tr(s){return Ys(s.nsp)&&_s(s.id)&&$s(s.type,s.data)}const er=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Rt,Encoder:qs,get PacketType(){return h},isPacketValid:tr,protocol:js},Symbol.toStringTag,{value:"Module"}));function K(s,t,e){return s.on(t,e),function(){s.off(t,e)}}const sr=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ke extends C{constructor(t,e,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[K(t,"open",this.onopen.bind(this)),K(t,"packet",this.onpacket.bind(this)),K(t,"error",this.onerror.bind(this)),K(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){var r,i,n;if(sr.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const o={type:h.EVENT,data:e};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof e[e.length-1]=="function"){const A=this.ids++,p=e.pop();this._registerAckCallback(A,p),o.id=A}const l=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,a=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!l||(a?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,e){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[t]=e;return}const n=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);e.call(this,new Error("operation has timed out"))},i),o=(...l)=>{this.io.clearTimeoutFn(n),e.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...e){return new Promise((r,i)=>{const n=(o,l)=>o?i(o):r(l);n.withError=!0,e.push(n),this.emit(t,...e)})}_addToQueue(t){let e;typeof t[t.length-1]=="function"&&(e=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...n)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(i)):(this._queue.shift(),e&&e(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:h.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case h.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case h.EVENT:case h.BINARY_EVENT:this.onevent(t);break;case h.ACK:case h.BINARY_ACK:this.onack(t);break;case h.DISCONNECT:this.ondisconnect();break;case h.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const e=t.data||[];t.id!=null&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const r of e)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let r=!1;return function(...i){r||(r=!0,e.packet({type:h.ACK,id:t,data:i}))}}onack(t){const e=this.acks[t.id];typeof e=="function"&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:h.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const r of e)r.apply(this,t.data)}}}function F(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}F.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),e=Math.floor(t*this.jitter*s);s=(Math.floor(t*10)&1)==0?s-e:s+e}return Math.min(s,this.max)|0},F.prototype.reset=function(){this.attempts=0},F.prototype.setMin=function(s){this.ms=s},F.prototype.setMax=function(s){this.max=s},F.prototype.setJitter=function(s){this.jitter=s};class zt extends C{constructor(t,e){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.opts=e,ut(this,e),this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor((r=e.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new F({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this._readyState="closed",this.uri=t;const i=e.parser||er;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=e.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(e=this.backoff)===null||e===void 0||e.setMin(t),this)}randomizationFactor(t){var e;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(e=this.backoff)===null||e===void 0||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(e=this.backoff)===null||e===void 0||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Rs(this.uri,this.opts);const e=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=K(e,"open",function(){r.onopen(),t&&t()}),n=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=K(e,"error",n);if(this._timeout!==!1){const l=this._timeout,a=this.setTimeoutFn(()=>{i(),n(new Error("timeout")),e.close()},l);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(i),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(K(t,"ping",this.onping.bind(this)),K(t,"data",this.ondata.bind(this)),K(t,"error",this.onerror.bind(this)),K(t,"close",this.onclose.bind(this)),K(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(e){this.onclose("parse error",e)}}ondecoded(t){dt(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Ke(this,t,e),this.nsps[t]=r),r}_destroy(t){const e=Object.keys(this.nsps);for(const r of e)if(this.nsps[r].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let r=0;r<e.length;r++)this.engine.write(e[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,e){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},e);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const et={};function yt(s,t){typeof s=="object"&&(t=s,s=void 0),t=t||{};const e=zs(s,t.path||"/socket.io"),r=e.source,i=e.id,n=e.path,o=et[i]&&n in et[i].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let a;return l?a=new zt(r,t):(et[i]||(et[i]=new zt(r,t)),a=et[i]),e.query&&!t.query&&(t.query=e.queryKey),a.socket(e.path,t)}Object.assign(yt,{Manager:zt,Socket:Ke,io:yt,connect:yt});var rr=class{constructor(s){this.publicKey=s.publicKey}getPublicKey(){return this.publicKey}},Te={trigger:{loading:"Cargando..."},modal:{titles:{selectAsset:'Selecciona el <span class="highlight">stablecoin</span>',selectNetwork:'Selecciona la <span class="highlight">red</span>',scanQr:'Depósito <span class="highlight">{symbol}</span>',success:'¡Gracias por <span class="highlight">tu compra!</span>',error:"Error en el Pago",idle:"Estado inesperado",processing:'¡Procesando <span class="highlight">tu pago!</span>'},subtitles:{selectAsset:"Selecciona la stablecoin con la que deseas pagar",selectNetwork:"Selecciona la red de tu preferencia",idle:"Ocurrio un error inesperado"},actions:{back:"Volver",close:"Cerrar",support:"Soporte",scanApp:'Escanea con tu celular y continua desde la app de <span style="color: var(--apolo-accent)">Apolo Pay</span>',copy:"Copiar",copied:"¡Copiado!",payFromDevice:"Pagar desde este dispositivo"},labels:{network:"Red",address:"Dirección de depósito",amount:"Monto",product:"Producto o Servicio",minutes:"min",seconds:"seg",amountSent:"Monto Enviado",paid:"Pagado",remainingToPay:"Restante por pagar"},info:{noReloadPageTitle:'¡Por favor no <span style="color: var(--apolo-accent)">recargues la página!</span>',noReloadPageSubTitle:"La pantalla se actualizara cuando confirmes tu pago",selectNetworkLater:"Luego podrás seleccionar la red de tu preferencia"},warnings:{networkMatch:"Asegúrate de que la <strong>red de tu wallet coincida</strong> con la red de destino.",noNFT:"No envíes NFTs a esta wallet.",onlyToken:"Solo se aceptan <strong>depósitos en {symbol}</strong>. El envío de otro tipo de token podría resultar en su pérdida.",timer:"Realiza el pago dentro del tiempo indicado. <strong>{time}</strong> De lo contrario, el código QR se vencerá."},success:{message:"Tu pago fue exitoso y en breve recibirás un correo",message2:"con los detalles.",details:"Detalles de la compra",support:"Cualquier duda o inquietud puedes comunicarte con soporte"}},successes:{success:"Éxito"},errors:{generic:"Ocurrió un error inesperado.",publicKeyMissing:"Falta la Public Key",config:"Error de Configuración",timeout:"El tiempo para realizar el pago ha expirado. Por favor genera una nueva orden.",paymentFailed:"El pago ha fallado. Por favor genera una nueva orden.",connectError:"Error de conexión.",socketConnectionError:"Error de conexión en el socket.",dataLoadError:"No se pudo cargar los datos de pago.",qrFetchError:"Fallo al obtener los detalles del código QR.",paymentProcessNotAvailable:"El proceso de pago no está disponible.",getAssetsError:"Error al obtener los activos.",unknownError:"Ocurrió un error inesperado."}},ir={trigger:{loading:"Loading..."},modal:{titles:{selectAsset:'Select <span class="highlight">stablecoin</span>',selectNetwork:'Select <span class="highlight">network</span>',scanQr:'Deposit <span class="highlight">{symbol}</span>',success:'Thanks for <span class="highlight">your purchase!</span>',error:"Payment Error",idle:"Unexpected state",processing:'Processing <span class="highlight">your payment!</span>'},subtitles:{selectAsset:"Select the stablecoin you want to pay with",selectNetwork:"Select your preferred network",idle:"An Unexpected error occurred"},actions:{back:"Back",close:"Close",support:"Support",scanApp:'Scan with your phone and continue from <br><span style="color: var(--apolo-accent)">Apolo Pay</span> app',copy:"Copy",copied:"Copied!",payFromDevice:"Pay from this device"},labels:{network:"Network",address:"Deposit Address",amount:"Amount",product:"Product or Service",minutes:"min",seconds:"sec",amountSent:"Amount sent",paid:"Paid",remainingToPay:"Remaining balance to pay"},info:{noReloadPageTitle:'Please do not <span style="color: var(--apolo-accent)">reload the page!</span>',noReloadPageSubTitle:"The screen will update when you confirm your payment",selectNetworkLater:"You will be able to select your preferred network later"},warnings:{networkMatch:"Ensure your <strong>wallet network matches</strong> the destination network.",noNFT:"Do not send NFTs to this wallet.",onlyToken:"Only <strong>{symbol} deposits</strong> are accepted. Sending other tokens may result in loss.",timer:"Complete payment within <strong>{time}</strong>. Otherwise, the QR code will expire."},success:{message:"Your payment was successful. You will receive an email",message2:"shortly.",details:"Purchase Details",support:"Any doubt or inquiry you can contact support"}},successes:{success:"Success"},errors:{generic:"An unexpected error occurred.",publicKeyMissing:"Public Key is missing",config:"Config Error",timeout:"The payment time has expired. Please generate a new order.",paymentFailed:"The payment has failed. Please generate a new order.",connectError:"Connection error in real time.",socketConnectionError:"Connection error in socket.",dataLoadError:"Could not load payment options.",qrFetchError:"Failed to get payment details.",paymentProcessNotAvailable:"The payment process is not available.",getAssetsError:"Failed to get assets.",unknownError:"An unexpected error occurred."}},y=class{static setLocale(s){this._currentLocale=s,this._dictionary=s==="en"?ir:Te}static get current(){return this._currentLocale}static get t(){return this._dictionary}static interpolate(s,t){return s.replace(/{(\w+)}/g,(e,r)=>typeof t[r]<"u"?String(t[r]):e)}};y._currentLocale="es",y._dictionary=Te;var D=(s=>(s.success="success",s.payment_success="payment_success",s.payment_failed="payment_failed",s.payment_partial="payment_partial",s.payment_timeout="payment_timeout",s.connect_error="connect_error",s.socket_connection_error="socket_connection_error",s.data_load_error="data_load_error",s.qr_fetch_error="qr_fetch_error",s.paymentProcessNotAvailable="payment_process_not_available",s.get_assets_error="get_assets_error",s.unknown_error="unknown_error",s))(D||{}),Mt=class{constructor({code:s,message:t}){this.code=s,this.message=t}},Dt=class xe extends Mt{constructor({code:t,message:e,result:r}){super({code:t,message:e}),this.result=r}static fromJson(t,{code:e,message:r,result:i}={}){const n=t.status||e||"success",o=t.message||r||y.t.successes.success,l=i?.(t.result)||t.result||t;return new xe({code:n,message:o,result:l})}},gt=class jt extends Mt{constructor({code:t,message:e,error:r}){super({code:t,message:e}),this.error=r}static fromError(t,{code:e,message:r}={}){if(t instanceof jt)return t;const i=e||t.statusCode||"unknown_error",n=r||t.message||y.t.errors.unknownError,o=t.error||t;return new jt({code:i,message:n,error:o})}},nr="https://p2p.apolopay.app",Oe="https://pb-api.apolopay.app",or="https://pb-ws.apolopay.app",Xt=class{static async getAssets(){try{const t=await(await fetch(`${Oe}/payment-button/assets`,{method:"GET",headers:this.headers()})).json();return Dt.fromJson(t)}catch(s){throw gt.fromError(s,{code:"get_assets_error",message:y.t.errors.getAssetsError})}}static async fetchQrCodeDetails({processId:s,assetId:t,networkId:e,publicKey:r}){try{const i=await fetch(`${Oe}/payment-button/process/confirm`,{method:"POST",headers:this.headers(r),body:JSON.stringify({processId:s,assetId:t,networkId:e})}),n=await i.json();if(!n.result)throw new gt({code:"payment_process_not_available",message:y.t.errors.paymentProcessNotAvailable});const o=n.result.wallet,a=n.result.network==="apolopay"?`${nr}/payment-process/${s}`:o;return Dt.fromJson(n,{result:d=>{const p=Date.now()+600*1e3;let E=d.expiresAtMs??d.expiresAt;const j=(rt=>{if(!rt)return p;let B=0;if(!isNaN(Number(rt)))B=Number(rt);else if(typeof rt=="string"){const Ne=new Date(rt).getTime();isNaN(Ne)||(B=Ne)}if(B===0)return p;if(B<1e10)B*=1e3;else if(B>1e13)for(;B>2e13;)B=Math.floor(B/1e3);return B})(E);return{...d,address:a,qrCodeUrl:`https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${a}&ecc=H`,paymentUrl:a.startsWith("http")?a:void 0,expiresAtMs:j}}})}catch(i){throw gt.fromError(i,{code:"qr_fetch_error",message:y.t.errors.qrFetchError})}}};Xt.headers=s=>{const t={"Content-Type":"application/json"};return s&&(t["x-public-key"]=s),t};var ar=class{constructor(s){this.sessionOptions=null,this.socket=null,this.client=s}connect(s){if(typeof window>"u")return;if(this.sessionOptions=s,this.socket&&this.socket.connected)return this.disconnect();this.socket=yt(or,{extraHeaders:{"x-public-key":this.client.getPublicKey()},transports:["websocket","polling"]});const{processId:t}=s;this.socket.on("connect",()=>this.socket?.emit("process:connect",{processId:t})),console.log(`Conectado a Socket.io para processId: ${t}`),this.socket.on("process:message",e=>this.handleWebSocketMessage(e)),this.socket.on("connect_error",e=>{console.error("Error en conexión Socket.io:",e),this.sessionOptions?.onError?.({code:"connect_error",message:y.t.errors.connectError,error:e}),this.disconnect()}),this.socket.on("disconnect",e=>{console.info(`Socket.io Desconectado: ${e}`),this.socket=null})}handleWebSocketMessage(s){if(!s.success)return this.sessionOptions?.onError?.({code:"payment_failed",message:s.message,error:s.result});if(s.event==="partial_payment")return this.sessionOptions?.onPartialPayment?.({code:"payment_partial",message:s.message,result:s.result});if(s.event==="funds_received")return this.sessionOptions?.onSuccess?.({code:"payment_success",message:s.message,result:s.result})}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null)}},Be=class{constructor(s){this.client=s,this.socket=new ar(this.client)}getPublicKey(){return this.client.getPublicKey()}async getAssets(){return(await Xt.getAssets()).result}async fetchQrCodeDetails(s,t){const e=await Xt.fetchQrCodeDetails({...s,processId:t.processId,publicKey:this.client.getPublicKey()});return this.socket.connect(t),e.result}disconnectWebSocket(){this.socket.disconnect()}},g=(s=>(s[s.SELECT_ASSET=0]="SELECT_ASSET",s[s.SELECT_NETWORK=1]="SELECT_NETWORK",s[s.SHOW_QR=2]="SHOW_QR",s[s.RESULT=3]="RESULT",s))(g||{});const Ue=U`
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),ne=/'/g,oe=/"/g,ae=/^(?:script|style|textarea|title)$/i,We=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),f=We(1),z=Symbol.for("lit-noChange"),b=Symbol.for("lit-nothing"),le=new WeakMap,M=Z.createTreeWalker(Z,129);function ce(s,t){if(!Et(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return te!==void 0?te.createHTML(t):t}const je=(s,t)=>{const e=s.length-1,r=[];let i,n=t===2?"<svg>":t===3?"<math>":"",o=H;for(let l=0;l<e;l++){const a=s[l];let d,A,p=-1,E=0;for(;E<a.length&&(o.lastIndex=E,A=o.exec(a),A!==null);)E=o.lastIndex,o===H?A[1]==="!--"?o=re:A[1]!==void 0?o=ie:A[2]!==void 0?(ae.test(A[2])&&(i=RegExp("</"+A[2],"g")),o=R):A[3]!==void 0&&(o=R):o===R?A[0]===">"?(o=i??H,p=-1):A[1]===void 0?p=-2:(p=o.lastIndex-A[2].length,d=A[1],o=A[3]===void 0?R:A[3]==='"'?oe:ne):o===oe||o===ne?o=R:o===re||o===ie?o=H:(o=R,i=void 0);const N=o===R&&s[l+1].startsWith("/>")?" ":"";n+=o===H?a+Ve:p>=0?(r.push(d),a.slice(0,p)+ee+a.slice(p)+I+N):a+I+(p===-2?l:N)}return[ce(s,n+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]};class _{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let n=0,o=0;const l=t.length-1,a=this.parts,[d,A]=je(t,e);if(this.el=_.createElement(d,r),M.currentNode=this.el.content,e===2||e===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(i=M.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const p of i.getAttributeNames())if(p.endsWith(ee)){const E=A[o++],N=i.getAttribute(p).split(I),j=/([.?@])?(.*)/.exec(E);a.push({type:1,index:n,name:j[2],strings:N,ctor:j[1]==="."?Ge:j[1]==="?"?Ye:j[1]==="@"?He:at}),i.removeAttribute(p)}else p.startsWith(I)&&(a.push({type:6,index:n}),i.removeAttribute(p));if(ae.test(i.tagName)){const p=i.textContent.split(I),E=p.length-1;if(E>0){i.textContent=ot?ot.emptyScript:"";for(let N=0;N<E;N++)i.append(p[N],G()),M.nextNode(),a.push({type:2,index:++n});i.append(p[E],G())}}}else if(i.nodeType===8)if(i.data===se)a.push({type:2,index:n});else{let p=-1;for(;(p=i.data.indexOf(I,p+1))!==-1;)a.push({type:7,index:n}),p+=I.length-1}n++}}static createElement(t,e){const r=Z.createElement("template");return r.innerHTML=t,r}}function V(s,t,e=s,r){if(t===z)return t;let i=r!==void 0?e._$Co?.[r]:e._$Cl;const n=Y(t)?void 0:t._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),n===void 0?i=void 0:(i=new n(s),i._$AT(s,e,r)),r!==void 0?(e._$Co??=[])[r]=i:e._$Cl=i),i!==void 0&&(t=V(s,i._$AS(s,t.values),i,r)),t}class qe{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,i=(t?.creationScope??Z).importNode(e,!0);M.currentNode=i;let n=M.nextNode(),o=0,l=0,a=r[0];for(;a!==void 0;){if(o===a.index){let d;a.type===2?d=new $(n,n.nextSibling,this,t):a.type===1?d=new a.ctor(n,a.name,a.strings,this,t):a.type===6&&(d=new _e(n,this,t)),this._$AV.push(d),a=r[++l]}o!==a?.index&&(n=M.nextNode(),o++)}return M.currentNode=Z,i}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}class ${get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,i){this.type=2,this._$AH=b,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=V(this,t,e),Y(t)?t===b||t==null||t===""?(this._$AH!==b&&this._$AR(),this._$AH=b):t!==this._$AH&&t!==z&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Fe(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==b&&Y(this._$AH)?this._$AA.nextSibling.data=t:this.T(Z.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=_.createElement(ce(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(e);else{const n=new qe(i,this),o=n.u(this.options);n.p(e),this.T(o),this._$AH=n}}_$AC(t){let e=le.get(t.strings);return e===void 0&&le.set(t.strings,e=new _(t)),e}k(t){Et(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,i=0;for(const n of t)i===e.length?e.push(r=new $(this.O(G()),this.O(G()),this,this.options)):r=e[i],r._$AI(n),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const r=$t(t).nextSibling;$t(t).remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}class at{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,n){this.type=1,this._$AH=b,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=b}_$AI(t,e=this,r,i){const n=this.strings;let o=!1;if(n===void 0)t=V(this,t,e,0),o=!Y(t)||t!==this._$AH&&t!==z,o&&(this._$AH=t);else{const l=t;let a,d;for(t=n[0],a=0;a<n.length-1;a++)d=V(this,l[r+a],e,a),d===z&&(d=this._$AH[a]),o||=!Y(d)||d!==this._$AH[a],d===b?t=b:t!==b&&(t+=(d??"")+n[a+1]),this._$AH[a]=d}o&&!i&&this.j(t)}j(t){t===b?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ge extends at{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===b?void 0:t}}class Ye extends at{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==b)}}class He extends at{constructor(t,e,r,i,n){super(t,e,r,i,n),this.type=5}_$AI(t,e=this){if((t=V(this,t,e,0)??b)===z)return;const r=this._$AH,i=t===b&&r!==b||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,n=t!==b&&(r===b||i);i&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class _e{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){V(this,t)}}const $e=Ct.litHtmlPolyfillSupport;$e?.(_,$),(Ct.litHtmlVersions??=[]).push("3.3.2");const ts=(s,t,e)=>{const r=e?.renderBefore??t;let i=r._$litPart$;if(i===void 0){const n=e?.renderBefore??null;r._$litPart$=i=new $(t.insertBefore(G(),n),n,void 0,e??{})}return i._$AI(s),i};const wt=globalThis;let Q=class extends X{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=ts(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return z}};Q._$litElement$=!0,Q.finalized=!0,wt.litElementHydrateSupport?.({LitElement:Q});const es=wt.litElementPolyfillSupport;es?.({LitElement:Q}),(wt.litElementVersions??=[]).push("4.2.2");const lt=s=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(s,t)}):customElements.define(s,t)};const ss={attribute:!0,type:String,converter:nt,reflect:!1,hasChanged:St},rs=(s=ss,t,e)=>{const{kind:r,metadata:i}=e;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),r==="setter"&&((s=Object.create(s)).wrapped=!0),n.set(e.name,s),r==="accessor"){const{name:o}=e;return{set(l){const a=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,a,s,!0,l)},init(l){return l!==void 0&&this.C(o,void 0,s,l),l}}}if(r==="setter"){const{name:o}=e;return function(l){const a=this[o];t.call(this,l),this.requestUpdate(o,a,s,!0,l)}}throw Error("Unsupported decorator location: "+r)};function u(s){return(t,e)=>typeof e=="object"?rs(s,t,e):((r,i,n)=>{const o=i.hasOwnProperty(n);return i.constructor.createProperty(n,r),o?Object.getOwnPropertyDescriptor(i,n):void 0})(s,t,e)}function S(s){return u({...s,state:!0,attribute:!1})}const is=(s,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(s,t,e),e);function ns(s,t){return(e,r,i)=>{const n=o=>o.renderRoot?.querySelector(s)??null;return is(e,r,{get(){return n(this)}})}}const T=Object.create(null);T.open="0",T.close="1",T.ping="2",T.pong="3",T.message="4",T.upgrade="5",T.noop="6";const ct=Object.create(null);Object.keys(T).forEach(s=>{ct[T[s]]=s});const Kt={type:"error",data:"parser error"},he=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",pe=typeof ArrayBuffer=="function",de=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,Tt=({type:s,data:t},e,r)=>he&&t instanceof Blob?e?r(t):ue(t,r):pe&&(t instanceof ArrayBuffer||de(t))?e?r(t):ue(new Blob([t]),r):r(T[s]+(t||"")),ue=(s,t)=>{const e=new FileReader;return e.onload=function(){const r=e.result.split(",")[1];t("b"+(r||""))},e.readAsDataURL(s)};function Ae(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let Ot;function os(s,t){if(he&&s.data instanceof Blob)return s.data.arrayBuffer().then(Ae).then(t);if(pe&&(s.data instanceof ArrayBuffer||de(s.data)))return t(Ae(s.data));Tt(s,!1,e=>{Ot||(Ot=new TextEncoder),t(Ot.encode(e))})}const fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",tt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<fe.length;s++)tt[fe.charCodeAt(s)]=s;const as=s=>{let t=s.length*.75,e=s.length,r,i=0,n,o,l,a;s[s.length-1]==="="&&(t--,s[s.length-2]==="="&&t--);const d=new ArrayBuffer(t),A=new Uint8Array(d);for(r=0;r<e;r+=4)n=tt[s.charCodeAt(r)],o=tt[s.charCodeAt(r+1)],l=tt[s.charCodeAt(r+2)],a=tt[s.charCodeAt(r+3)],A[i++]=n<<2|o>>4,A[i++]=(o&15)<<4|l>>2,A[i++]=(l&3)<<6|a&63;return d},ls=typeof ArrayBuffer=="function",Bt=(s,t)=>{if(typeof s!="string")return{type:"message",data:me(s,t)};const e=s.charAt(0);return e==="b"?{type:"message",data:cs(s.substring(1),t)}:ct[e]?s.length>1?{type:ct[e],data:s.substring(1)}:{type:ct[e]}:Kt},cs=(s,t)=>{if(ls){const e=as(s);return me(e,t)}else return{base64:!0,data:s}},me=(s,t)=>t==="blob"?s instanceof Blob?s:new Blob([s]):s instanceof ArrayBuffer?s:s.buffer,ye="",hs=(s,t)=>{const e=s.length,r=new Array(e);let i=0;s.forEach((n,o)=>{Tt(n,!1,l=>{r[o]=l,++i===e&&t(r.join(ye))})})},ps=(s,t)=>{const e=s.split(ye),r=[];for(let i=0;i<e.length;i++){const n=Bt(e[i],t);if(r.push(n),n.type==="error")break}return r};function ds(){return new TransformStream({transform(s,t){os(s,e=>{const r=e.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const n=new DataView(i.buffer);n.setUint8(0,126),n.setUint16(1,r)}else{i=new Uint8Array(9);const n=new DataView(i.buffer);n.setUint8(0,127),n.setBigUint64(1,BigInt(r))}s.data&&typeof s.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(e)})}})}let Ut;function ht(s){return s.reduce((t,e)=>t+e.length,0)}function pt(s,t){if(s[0].length===t)return s.shift();const e=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)e[i]=s[0][r++],r===s[0].length&&(s.shift(),r=0);return s.length&&r<s[0].length&&(s[0]=s[0].slice(r)),e}function us(s,t){Ut||(Ut=new TextDecoder);const e=[];let r=0,i=-1,n=!1;return new TransformStream({transform(o,l){for(e.push(o);;){if(r===0){if(ht(e)<1)break;const a=pt(e,1);n=(a[0]&128)===128,i=a[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(ht(e)<2)break;const a=pt(e,2);i=new DataView(a.buffer,a.byteOffset,a.length).getUint16(0),r=3}else if(r===2){if(ht(e)<8)break;const a=pt(e,8),d=new DataView(a.buffer,a.byteOffset,a.length),A=d.getUint32(0);if(A>Math.pow(2,21)-1){l.enqueue(Kt);break}i=A*Math.pow(2,32)+d.getUint32(4),r=3}else{if(ht(e)<i)break;const a=pt(e,i);l.enqueue(Bt(n?a:Ut.decode(a),t)),r=0}if(i===0||i>s){l.enqueue(Kt);break}}}})}const ge=4;function C(s){if(s)return As(s)}function As(s){for(var t in C.prototype)s[t]=C.prototype[t];return s}C.prototype.on=C.prototype.addEventListener=function(s,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(t),this},C.prototype.once=function(s,t){function e(){this.off(s,e),t.apply(this,arguments)}return e.fn=t,this.on(s,e),this},C.prototype.off=C.prototype.removeListener=C.prototype.removeAllListeners=C.prototype.removeEventListener=function(s,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var e=this._callbacks["$"+s];if(!e)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var r,i=0;i<e.length;i++)if(r=e[i],r===t||r.fn===t){e.splice(i,1);break}return e.length===0&&delete this._callbacks["$"+s],this},C.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),e=this._callbacks["$"+s],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(e){e=e.slice(0);for(var r=0,i=e.length;r<i;++r)e[r].apply(this,t)}return this},C.prototype.emitReserved=C.prototype.emit,C.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]},C.prototype.hasListeners=function(s){return!!this.listeners(s).length};const dt=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,e)=>e(t,0),w=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),fs="arraybuffer";function Er(){}function ke(s,...t){return t.reduce((e,r)=>(s.hasOwnProperty(r)&&(e[r]=s[r]),e),{})}const ms=w.setTimeout,ys=w.clearTimeout;function ut(s,t){t.useNativeTimers?(s.setTimeoutFn=ms.bind(w),s.clearTimeoutFn=ys.bind(w)):(s.setTimeoutFn=w.setTimeout.bind(w),s.clearTimeoutFn=w.clearTimeout.bind(w))}const gs=1.33;function ks(s){return typeof s=="string"?vs(s):Math.ceil((s.byteLength||s.size)*gs)}function vs(s){let t=0,e=0;for(let r=0,i=s.length;r<i;r++)t=s.charCodeAt(r),t<128?e+=1:t<2048?e+=2:t<55296||t>=57344?e+=3:(r++,e+=4);return e}function ve(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function bs(s){let t="";for(let e in s)s.hasOwnProperty(e)&&(t.length&&(t+="&"),t+=encodeURIComponent(e)+"="+encodeURIComponent(s[e]));return t}function Ss(s){let t={},e=s.split("&");for(let r=0,i=e.length;r<i;r++){let n=e[r].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}class Cs extends Error{constructor(t,e,r){super(t),this.description=e,this.context=r,this.type="TransportError"}}class Nt extends C{constructor(t){super(),this.writable=!1,ut(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,e,r){return super.emitReserved("error",new Cs(t,e,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=Bt(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const e=bs(t);return e.length?"?"+e:""}}class Es extends Nt{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||e()})),this.writable||(r++,this.once("drain",function(){--r||e()}))}else e()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const e=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};ps(t,this.socket.binaryType).forEach(e),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,hs(t,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=ve()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}}let be=!1;try{be=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Js=be;function ws(){}class Ks extends Es{constructor(t){if(super(t),typeof location<"u"){const e=location.protocol==="https:";let r=location.port;r||(r=e?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,e){const r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",(i,n)=>{this.onError("xhr post error",i,n)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(e,r)=>{this.onError("xhr poll error",e,r)}),this.pollXhr=t}}class O extends C{constructor(t,e,r){super(),this.createRequest=t,ut(this,r),this._opts=r,this._method=r.method||"GET",this._uri=e,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const e=ke(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(e);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=O.requestsCount++,O.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=ws,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete O.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(O.requestsCount=0,O.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Se);else if(typeof addEventListener=="function"){const s="onpagehide"in w?"pagehide":"unload";addEventListener(s,Se,!1)}}function Se(){for(let s in O.requests)O.requests.hasOwnProperty(s)&&O.requests[s].abort()}const Ts=(function(){const s=Ce({xdomain:!1});return s&&s.responseType!==null})();class Os extends Ks{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=Ts&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new O(Ce,this.uri(),t)}}function Ce(s){const t=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Js))return new XMLHttpRequest}catch{}if(!t)try{return new w[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ee=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Bs extends Nt{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,r=Ee?{}:ke(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,e,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],i=e===t.length-1;Tt(r,this.supportsBinary,n=>{try{this.doWrite(r,n)}catch{}i&&dt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=ve()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const xt=w.WebSocket||w.MozWebSocket;class Us extends Bs{createSocket(t,e,r){return Ee?new xt(t,e,r):e?new xt(t,e):new xt(t)}doWrite(t,e){this.ws.send(e)}}class Ns extends Nt{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const e=us(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(e).getReader(),i=ds();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();const n=()=>{r.read().then(({done:l,value:a})=>{l||(this.onPacket(a),n())}).catch(l=>{})};n();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],i=e===t.length-1;this._writer.write(r).then(()=>{i&&dt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const xs={websocket:Us,webtransport:Ns,polling:Os},Is=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Qs=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function It(s){if(s.length>8e3)throw"URI too long";const t=s,e=s.indexOf("["),r=s.indexOf("]");e!=-1&&r!=-1&&(s=s.substring(0,e)+s.substring(e,r).replace(/:/g,";")+s.substring(r,s.length));let i=Is.exec(s||""),n={},o=14;for(;o--;)n[Qs[o]]=i[o]||"";return e!=-1&&r!=-1&&(n.source=t,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=Ps(n,n.path),n.queryKey=Ls(n,n.query),n}function Ps(s,t){const e=/\/{2,9}/g,r=t.replace(e,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Ls(s,t){const e={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,n){i&&(e[i]=n)}),e}const Qt=typeof addEventListener=="function"&&typeof removeEventListener=="function",At=[];Qt&&addEventListener("offline",()=>{At.forEach(s=>s())},!1);class P extends C{constructor(t,e){if(super(),this.binaryType=fs,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(e=t,t=null),t){const r=It(t);e.hostname=r.host,e.secure=r.protocol==="https"||r.protocol==="wss",e.port=r.port,r.query&&(e.query=r.query)}else e.host&&(e.hostname=It(e.host).host);ut(this,e),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},e.transports.forEach(r=>{const i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ss(this.opts.query)),Qt&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},At.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=ge,e.transport=t,this.id&&(e.sid=this.id);const r=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&P.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const e=this.createTransport(t);e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",P.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const e=new Error("server error");e.code=t.data,this._onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(e+=ks(i)),r>0&&e>this._maxPayload)return this.writeBuffer.slice(0,r);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,dt(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,e,r){return this._sendPacket("message",t,e,r),this}send(t,e,r){return this._sendPacket("message",t,e,r),this}_sendPacket(t,e,r,i){if(typeof e=="function"&&(i=e,e=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const n={type:t,data:e,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},r=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(P.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Qt&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=At.indexOf(this._offlineEventListener);r!==-1&&At.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}P.protocol=ge;class Zs extends P{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let e=this.createTransport(t),r=!1;P.priorWebsocketSuccess=!1;const i=()=>{r||(e.send([{type:"ping",data:"probe"}]),e.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;P.priorWebsocketSuccess=e.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(A(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{const E=new Error("probe error");E.transport=e.name,this.emitReserved("upgradeError",E)}}))};function n(){r||(r=!0,A(),e.close(),e=null)}const o=p=>{const E=new Error("probe error: "+p);E.transport=e.name,n(),this.emitReserved("upgradeError",E)};function l(){o("transport closed")}function a(){o("socket closed")}function d(p){e&&p.name!==e.name&&n()}const A=()=>{e.removeListener("open",i),e.removeListener("error",o),e.removeListener("close",l),this.off("close",a),this.off("upgrading",d)};e.once("open",i),e.once("error",o),e.once("close",l),this.once("close",a),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||e.open()},200):e.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const e=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&e.push(t[r]);return e}}let Rs=class extends Zs{constructor(t,e={}){const r=typeof t=="object"?t:e;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>xs[i]).filter(i=>!!i)),super(t,r)}};function zs(s,t="",e){let r=s;e=e||typeof location<"u"&&location,s==null&&(s=e.protocol+"//"+e.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=e.protocol+s:s=e.host+s),/^(https?|wss?):\/\//.test(s)||(typeof e<"u"?s=e.protocol+"//"+s:s="https://"+s),r=It(s)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const n=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+n+":"+r.port+t,r.href=r.protocol+"://"+n+(e&&e.port===r.port?"":":"+r.port),r}const Ms=typeof ArrayBuffer=="function",Ds=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,Je=Object.prototype.toString,Xs=typeof Blob=="function"||typeof Blob<"u"&&Je.call(Blob)==="[object BlobConstructor]",Vs=typeof File=="function"||typeof File<"u"&&Je.call(File)==="[object FileConstructor]";function Pt(s){return Ms&&(s instanceof ArrayBuffer||Ds(s))||Xs&&s instanceof Blob||Vs&&s instanceof File}function ft(s,t){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let e=0,r=s.length;e<r;e++)if(ft(s[e]))return!0;return!1}if(Pt(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return ft(s.toJSON(),!0);for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)&&ft(s[e]))return!0;return!1}function Fs(s){const t=[],e=s.data,r=s;return r.data=Lt(e,t),r.attachments=t.length,{packet:r,buffers:t}}function Lt(s,t){if(!s)return s;if(Pt(s)){const e={_placeholder:!0,num:t.length};return t.push(s),e}else if(Array.isArray(s)){const e=new Array(s.length);for(let r=0;r<s.length;r++)e[r]=Lt(s[r],t);return e}else if(typeof s=="object"&&!(s instanceof Date)){const e={};for(const r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=Lt(s[r],t));return e}return s}function Ws(s,t){return s.data=Zt(s.data,t),delete s.attachments,s}function Zt(s,t){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<t.length)return t[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let e=0;e<s.length;e++)s[e]=Zt(s[e],t);else if(typeof s=="object")for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(s[e]=Zt(s[e],t));return s}const we=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],js=5;var h;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(h||(h={}));class qs{constructor(t){this.replacer=t}encode(t){return(t.type===h.EVENT||t.type===h.ACK)&&ft(t)?this.encodeAsBinary({type:t.type===h.EVENT?h.BINARY_EVENT:h.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let e=""+t.type;return(t.type===h.BINARY_EVENT||t.type===h.BINARY_ACK)&&(e+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(e+=t.nsp+","),t.id!=null&&(e+=t.id),t.data!=null&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=Fs(t),r=this.encodeAsString(e.packet),i=e.buffers;return i.unshift(r),i}}class Rt extends C{constructor(t){super(),this.reviver=t}add(t){let e;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const r=e.type===h.BINARY_EVENT;r||e.type===h.BINARY_ACK?(e.type=r?h.EVENT:h.ACK,this.reconstructor=new Gs(e),e.attachments===0&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else if(Pt(t)||t.base64)if(this.reconstructor)e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(h[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===h.BINARY_EVENT||r.type===h.BINARY_ACK){const n=e+1;for(;t.charAt(++e)!=="-"&&e!=t.length;);const o=t.substring(n,e);if(o!=Number(o)||t.charAt(e)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(t.charAt(e+1)==="/"){const n=e+1;for(;++e&&!(t.charAt(e)===","||e===t.length););r.nsp=t.substring(n,e)}else r.nsp="/";const i=t.charAt(e+1);if(i!==""&&Number(i)==i){const n=e+1;for(;++e;){const o=t.charAt(e);if(o==null||Number(o)!=o){--e;break}if(e===t.length)break}r.id=Number(t.substring(n,e+1))}if(t.charAt(++e)){const n=this.tryParse(t.substr(e));if(Rt.isPayloadValid(r.type,n))r.data=n;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,e){switch(t){case h.CONNECT:return mt(e);case h.DISCONNECT:return e===void 0;case h.CONNECT_ERROR:return typeof e=="string"||mt(e);case h.EVENT:case h.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&we.indexOf(e[0])===-1);case h.ACK:case h.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Gs{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const e=Ws(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function Ys(s){return typeof s=="string"}const Hs=Number.isInteger||function(s){return typeof s=="number"&&isFinite(s)&&Math.floor(s)===s};function _s(s){return s===void 0||Hs(s)}function mt(s){return Object.prototype.toString.call(s)==="[object Object]"}function $s(s,t){switch(s){case h.CONNECT:return t===void 0||mt(t);case h.DISCONNECT:return t===void 0;case h.EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&we.indexOf(t[0])===-1);case h.ACK:return Array.isArray(t);case h.CONNECT_ERROR:return typeof t=="string"||mt(t);default:return!1}}function tr(s){return Ys(s.nsp)&&_s(s.id)&&$s(s.type,s.data)}const er=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Rt,Encoder:qs,get PacketType(){return h},isPacketValid:tr,protocol:js},Symbol.toStringTag,{value:"Module"}));function K(s,t,e){return s.on(t,e),function(){s.off(t,e)}}const sr=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ke extends C{constructor(t,e,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[K(t,"open",this.onopen.bind(this)),K(t,"packet",this.onpacket.bind(this)),K(t,"error",this.onerror.bind(this)),K(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){var r,i,n;if(sr.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const o={type:h.EVENT,data:e};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof e[e.length-1]=="function"){const A=this.ids++,p=e.pop();this._registerAckCallback(A,p),o.id=A}const l=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,a=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!l||(a?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,e){var r;const i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[t]=e;return}const n=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let l=0;l<this.sendBuffer.length;l++)this.sendBuffer[l].id===t&&this.sendBuffer.splice(l,1);e.call(this,new Error("operation has timed out"))},i),o=(...l)=>{this.io.clearTimeoutFn(n),e.apply(this,l)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...e){return new Promise((r,i)=>{const n=(o,l)=>o?i(o):r(l);n.withError=!0,e.push(n),this.emit(t,...e)})}_addToQueue(t){let e;typeof t[t.length-1]=="function"&&(e=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...n)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(i)):(this._queue.shift(),e&&e(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:h.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case h.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case h.EVENT:case h.BINARY_EVENT:this.onevent(t);break;case h.ACK:case h.BINARY_ACK:this.onack(t);break;case h.DISCONNECT:this.ondisconnect();break;case h.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const e=t.data||[];t.id!=null&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const r of e)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let r=!1;return function(...i){r||(r=!0,e.packet({type:h.ACK,id:t,data:i}))}}onack(t){const e=this.acks[t.id];typeof e=="function"&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:h.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const r of e)r.apply(this,t.data)}}}function F(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}F.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),e=Math.floor(t*this.jitter*s);s=(Math.floor(t*10)&1)==0?s-e:s+e}return Math.min(s,this.max)|0},F.prototype.reset=function(){this.attempts=0},F.prototype.setMin=function(s){this.ms=s},F.prototype.setMax=function(s){this.max=s},F.prototype.setJitter=function(s){this.jitter=s};class zt extends C{constructor(t,e){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.opts=e,ut(this,e),this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor((r=e.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new F({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this._readyState="closed",this.uri=t;const i=e.parser||er;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=e.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(e=this.backoff)===null||e===void 0||e.setMin(t),this)}randomizationFactor(t){var e;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(e=this.backoff)===null||e===void 0||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(e=this.backoff)===null||e===void 0||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Rs(this.uri,this.opts);const e=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=K(e,"open",function(){r.onopen(),t&&t()}),n=l=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",l),t?t(l):this.maybeReconnectOnOpen()},o=K(e,"error",n);if(this._timeout!==!1){const l=this._timeout,a=this.setTimeoutFn(()=>{i(),n(new Error("timeout")),e.close()},l);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(i),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(K(t,"ping",this.onping.bind(this)),K(t,"data",this.ondata.bind(this)),K(t,"error",this.onerror.bind(this)),K(t,"close",this.onclose.bind(this)),K(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(e){this.onclose("parse error",e)}}ondecoded(t){dt(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Ke(this,t,e),this.nsps[t]=r),r}_destroy(t){const e=Object.keys(this.nsps);for(const r of e)if(this.nsps[r].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let r=0;r<e.length;r++)this.engine.write(e[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,e){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},e);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const et={};function yt(s,t){typeof s=="object"&&(t=s,s=void 0),t=t||{};const e=zs(s,t.path||"/socket.io"),r=e.source,i=e.id,n=e.path,o=et[i]&&n in et[i].nsps,l=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let a;return l?a=new zt(r,t):(et[i]||(et[i]=new zt(r,t)),a=et[i]),e.query&&!t.query&&(t.query=e.queryKey),a.socket(e.path,t)}Object.assign(yt,{Manager:zt,Socket:Ke,io:yt,connect:yt});var rr=class{constructor(s){this.publicKey=s.publicKey}getPublicKey(){return this.publicKey}},Te={trigger:{loading:"Cargando..."},modal:{titles:{selectAsset:'Selecciona el <span class="highlight">stablecoin</span>',selectNetwork:'Selecciona la <span class="highlight">red</span>',scanQr:'Depósito <span class="highlight">{symbol}</span>',success:'¡Gracias por <span class="highlight">tu compra!</span>',error:"Error en el Pago",idle:"Estado inesperado",processing:'¡Procesando <span class="highlight">tu pago!</span>'},subtitles:{selectAsset:"Selecciona la stablecoin con la que deseas pagar",selectNetwork:"Selecciona la red de tu preferencia",idle:"Ocurrio un error inesperado"},actions:{back:"Volver",close:"Cerrar",support:"Soporte",scanApp:'Escanea con tu celular y continua desde la app de <span style="color: var(--apolo-accent)">Apolo Pay</span>',copy:"Copiar",copied:"¡Copiado!",payFromDevice:"Pagar desde este dispositivo"},labels:{network:"Red",address:"Dirección de depósito",amount:"Monto",product:"Producto o Servicio",minutes:"min",seconds:"seg",amountSent:"Monto Enviado",paid:"Pagado",remainingToPay:"Restante por pagar"},info:{noReloadPageTitle:'¡Por favor no <span style="color: var(--apolo-accent)">recargues la página!</span>',noReloadPageSubTitle:"La pantalla se actualizara cuando confirmes tu pago",selectNetworkLater:"Luego podrás seleccionar la red de tu preferencia"},warnings:{networkMatch:"Asegúrate de que la <strong>red de tu wallet coincida</strong> con la red de destino.",noNFT:"No envíes NFTs a esta wallet.",onlyToken:"Solo se aceptan <strong>depósitos en {symbol}</strong>. El envío de otro tipo de token podría resultar en su pérdida.",timer:"Realiza el pago dentro del tiempo indicado. <strong>{time}</strong> De lo contrario, el código QR se vencerá."},success:{message:"Tu pago fue exitoso y en breve recibirás un correo",message2:"con los detalles.",details:"Detalles de la compra",support:"Cualquier duda o inquietud puedes comunicarte con soporte"}},successes:{success:"Éxito"},errors:{generic:"Ocurrió un error inesperado.",publicKeyMissing:"Falta la Public Key",config:"Error de Configuración",timeout:"El tiempo para realizar el pago ha expirado. Por favor genera una nueva orden.",paymentFailed:"El pago ha fallado. Por favor genera una nueva orden.",connectError:"Error de conexión.",socketConnectionError:"Error de conexión en el socket.",dataLoadError:"No se pudo cargar los datos de pago.",qrFetchError:"Fallo al obtener los detalles del código QR.",paymentProcessNotAvailable:"El proceso de pago no está disponible.",getAssetsError:"Error al obtener los activos.",unknownError:"Ocurrió un error inesperado."}},ir={trigger:{loading:"Loading..."},modal:{titles:{selectAsset:'Select <span class="highlight">stablecoin</span>',selectNetwork:'Select <span class="highlight">network</span>',scanQr:'Deposit <span class="highlight">{symbol}</span>',success:'Thanks for <span class="highlight">your purchase!</span>',error:"Payment Error",idle:"Unexpected state",processing:'Processing <span class="highlight">your payment!</span>'},subtitles:{selectAsset:"Select the stablecoin you want to pay with",selectNetwork:"Select your preferred network",idle:"An Unexpected error occurred"},actions:{back:"Back",close:"Close",support:"Support",scanApp:'Scan with your phone and continue from <br><span style="color: var(--apolo-accent)">Apolo Pay</span> app',copy:"Copy",copied:"Copied!",payFromDevice:"Pay from this device"},labels:{network:"Network",address:"Deposit Address",amount:"Amount",product:"Product or Service",minutes:"min",seconds:"sec",amountSent:"Amount sent",paid:"Paid",remainingToPay:"Remaining balance to pay"},info:{noReloadPageTitle:'Please do not <span style="color: var(--apolo-accent)">reload the page!</span>',noReloadPageSubTitle:"The screen will update when you confirm your payment",selectNetworkLater:"You will be able to select your preferred network later"},warnings:{networkMatch:"Ensure your <strong>wallet network matches</strong> the destination network.",noNFT:"Do not send NFTs to this wallet.",onlyToken:"Only <strong>{symbol} deposits</strong> are accepted. Sending other tokens may result in loss.",timer:"Complete payment within <strong>{time}</strong>. Otherwise, the QR code will expire."},success:{message:"Your payment was successful. You will receive an email",message2:"shortly.",details:"Purchase Details",support:"Any doubt or inquiry you can contact support"}},successes:{success:"Success"},errors:{generic:"An unexpected error occurred.",publicKeyMissing:"Public Key is missing",config:"Config Error",timeout:"The payment time has expired. Please generate a new order.",paymentFailed:"The payment has failed. Please generate a new order.",connectError:"Connection error in real time.",socketConnectionError:"Connection error in socket.",dataLoadError:"Could not load payment options.",qrFetchError:"Failed to get payment details.",paymentProcessNotAvailable:"The payment process is not available.",getAssetsError:"Failed to get assets.",unknownError:"An unexpected error occurred."}},y=class{static setLocale(s){this._currentLocale=s,this._dictionary=s==="en"?ir:Te}static get current(){return this._currentLocale}static get t(){return this._dictionary}static interpolate(s,t){return s.replace(/{(\w+)}/g,(e,r)=>typeof t[r]<"u"?String(t[r]):e)}};y._currentLocale="es",y._dictionary=Te;var D=(s=>(s.success="success",s.payment_success="payment_success",s.payment_failed="payment_failed",s.payment_partial="payment_partial",s.payment_timeout="payment_timeout",s.connect_error="connect_error",s.socket_connection_error="socket_connection_error",s.data_load_error="data_load_error",s.qr_fetch_error="qr_fetch_error",s.paymentProcessNotAvailable="payment_process_not_available",s.get_assets_error="get_assets_error",s.unknown_error="unknown_error",s))(D||{}),Mt=class{constructor({code:s,message:t}){this.code=s,this.message=t}},Dt=class xe extends Mt{constructor({code:t,message:e,result:r}){super({code:t,message:e}),this.result=r}static fromJson(t,{code:e,message:r,result:i}={}){const n=t.status||e||"success",o=t.message||r||y.t.successes.success,l=i?.(t.result)||t.result||t;return new xe({code:n,message:o,result:l})}},gt=class jt extends Mt{constructor({code:t,message:e,error:r}){super({code:t,message:e}),this.error=r}static fromError(t,{code:e,message:r}={}){if(t instanceof jt)return t;const i=e||t.statusCode||"unknown_error",n=r||t.message||y.t.errors.unknownError,o=t.error||t;return new jt({code:i,message:n,error:o})}},nr="https://p2p.apolopay.app",Oe="https://pb-api.apolopay.app",or="https://pb-ws.apolopay.app",Xt=class{static async getAssets(){try{const t=await(await fetch(`${Oe}/payment-button/assets`,{method:"GET",headers:this.headers()})).json();return Dt.fromJson(t)}catch(s){throw gt.fromError(s,{code:"get_assets_error",message:y.t.errors.getAssetsError})}}static async fetchQrCodeDetails({processId:s,assetId:t,networkId:e,publicKey:r}){try{const i=await fetch(`${Oe}/payment-button/process/confirm`,{method:"POST",headers:this.headers(r),body:JSON.stringify({processId:s,assetId:t,networkId:e})}),n=await i.json();if(!n.result)throw new gt({code:"payment_process_not_available",message:y.t.errors.paymentProcessNotAvailable});const o=n.result.wallet,a=n.result.network==="apolopay"?`${nr}/payment-process/${s}`:o;return Dt.fromJson(n,{result:d=>{const p=Date.now()+600*1e3;let E=d.expiresAtMs??d.expiresAt;const j=(rt=>{if(!rt)return p;let B=0;if(!isNaN(Number(rt)))B=Number(rt);else if(typeof rt=="string"){const Ne=new Date(rt).getTime();isNaN(Ne)||(B=Ne)}if(B===0)return p;if(B<1e10)B*=1e3;else if(B>1e13)for(;B>2e13;)B=Math.floor(B/1e3);return B})(E);return{...d,address:a,qrCodeUrl:`https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${a}&ecc=H`,paymentUrl:a.startsWith("http")?a:void 0,expiresAtMs:j}}})}catch(i){throw gt.fromError(i,{code:"qr_fetch_error",message:y.t.errors.qrFetchError})}}};Xt.headers=s=>{const t={"Content-Type":"application/json"};return s&&(t["x-public-key"]=s),t};var ar=class{constructor(s){this.sessionOptions=null,this.socket=null,this.client=s}connect(s){if(typeof window>"u")return;if(this.sessionOptions=s,this.socket&&this.socket.connected)return this.disconnect();this.socket=yt(or,{extraHeaders:{"x-public-key":this.client.getPublicKey()},transports:["polling"]});const{processId:t}=s;this.socket.on("connect",()=>this.socket?.emit("process:connect",{processId:t})),console.log(`Conectado a Socket.io para processId: ${t}`),this.socket.on("process:message",e=>this.handleWebSocketMessage(e)),this.socket.on("connect_error",e=>{console.error("Error en conexión Socket.io:",e),this.sessionOptions?.onError?.({code:"connect_error",message:y.t.errors.connectError,error:e}),this.disconnect()}),this.socket.on("disconnect",e=>{console.info(`Socket.io Desconectado: ${e}`),this.socket=null})}handleWebSocketMessage(s){if(!s.success)return this.sessionOptions?.onError?.({code:"payment_failed",message:s.message,error:s.result});if(s.event==="partial_payment")return this.sessionOptions?.onPartialPayment?.({code:"payment_partial",message:s.message,result:s.result});if(s.event==="funds_received")return this.sessionOptions?.onSuccess?.({code:"payment_success",message:s.message,result:s.result})}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null)}},Be=class{constructor(s){this.client=s,this.socket=new ar(this.client)}getPublicKey(){return this.client.getPublicKey()}async getAssets(){return(await Xt.getAssets()).result}async fetchQrCodeDetails(s,t){const e=await Xt.fetchQrCodeDetails({...s,processId:t.processId,publicKey:this.client.getPublicKey()});return this.socket.connect(t),e.result}disconnectWebSocket(){this.socket.disconnect()}},g=(s=>(s[s.SELECT_ASSET=0]="SELECT_ASSET",s[s.SELECT_NETWORK=1]="SELECT_NETWORK",s[s.SHOW_QR=2]="SHOW_QR",s[s.RESULT=3]="RESULT",s))(g||{});const Ue=U`
4
4
  :host {
5
5
  /* --- API PÚBLICA DE COLORES (THEMING) --- */
6
6
  --apolo-primary: var(--payment-button-primary, #0388c0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolopay-sdk/ui",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "UI Components (Web Components) for payment button",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "lit": "3.0.0",
22
22
  "tslib": "2.8.1",
23
- "@apolopay-sdk/core": "1.2.0"
23
+ "@apolopay-sdk/core": "1.2.1"
24
24
  },
25
25
  "exports": {
26
26
  ".": {