@sawport/peers-caller
Version:
WebRTC multi-peer video call library with mesh architecture supporting up to 4 participants
7 lines • 205 kB
JavaScript
(function(Y,ae){typeof exports=="object"&&typeof module!="undefined"?ae(exports,require("socket.io-client"),require("zustand"),require("react")):typeof define=="function"&&define.amd?define(["exports","socket.io-client","zustand","react"],ae):(Y=typeof globalThis!="undefined"?globalThis:Y||self,ae(Y.PeersCaller={},Y.io,Y.zustand,Y.React))})(this,function(Y,ae,ye,Q){"use strict";var Us=Object.defineProperty,qs=Object.defineProperties;var xs=Object.getOwnPropertyDescriptors;var pt=Object.getOwnPropertySymbols;var Co=Object.prototype.hasOwnProperty,Eo=Object.prototype.propertyIsEnumerable;var oe=Math.pow,on=(Y,ae,ye)=>ae in Y?Us(Y,ae,{enumerable:!0,configurable:!0,writable:!0,value:ye}):Y[ae]=ye,Qe=(Y,ae)=>{for(var ye in ae||(ae={}))Co.call(ae,ye)&&on(Y,ye,ae[ye]);if(pt)for(var ye of pt(ae))Eo.call(ae,ye)&&on(Y,ye,ae[ye]);return Y},an=(Y,ae)=>qs(Y,xs(ae));var sn=(Y,ae)=>{var ye={};for(var Q in Y)Co.call(Y,Q)&&ae.indexOf(Q)<0&&(ye[Q]=Y[Q]);if(Y!=null&&pt)for(var Q of pt(Y))ae.indexOf(Q)<0&&Eo.call(Y,Q)&&(ye[Q]=Y[Q]);return ye};var Ae=(Y,ae,ye)=>on(Y,typeof ae!="symbol"?ae+"":ae,ye);var gt={};typeof gt=="undefined"?globalThis.process={env:{},browser:!0,version:"v18.0.0",nextTick:(n,...e)=>{setTimeout(()=>n(...e),0)}}:typeof gt.nextTick=="undefined"&&(gt.nextTick=(n,...e)=>{setTimeout(()=>n(...e),0)}),typeof globalThis=="undefined"&&(globalThis.global=globalThis);var Ro=Object.defineProperty,Po=(n,e,t)=>e in n?Ro(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ne=(n,e,t)=>Po(n,typeof e!="symbol"?e+"":e,t),ke=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});class ln{constructor(e,t,o="/apis/video-call"){Ne(this,"socket",null),Ne(this,"serverUrl"),Ne(this,"socketPath"),Ne(this,"token"),Ne(this,"connected",!1),Ne(this,"reconnectAttempts",0),Ne(this,"maxReconnectAttempts",5),this.serverUrl=e,this.token=t,this.socketPath=o}connect(){return ke(this,null,function*(){return this.socket&&this.socket.connected?Promise.resolve():(this.socket&&(this.socket.removeAllListeners(),this.socket.disconnect(),this.socket=null),new Promise((e,t)=>{try{this.socket=ae.io(this.serverUrl,{path:this.socketPath,transports:["websocket","polling"],timeout:1e4,forceNew:!0,auth:{token:this.token}}),this.socket.on("connect",()=>{this.connected=!0,this.reconnectAttempts=0,console.log("[CallSocket] Connected to signaling server"),e()}),this.socket.on("disconnect",o=>{this.connected=!1,console.log("[CallSocket] Disconnected:",o),this.handleDisconnection(o)}),this.socket.on("connect_error",o=>{console.error("[CallSocket] Connection error:",o),this.reconnectAttempts++,this.reconnectAttempts>=this.maxReconnectAttempts&&t(new Error(`Failed to connect after ${this.maxReconnectAttempts} attempts`))})}catch(o){t(o)}}))})}disconnect(){this.socket&&(this.socket.removeAllListeners(),this.socket.disconnect(),this.socket=null,this.connected=!1)}isConnected(){var e;return this.connected&&((e=this.socket)==null?void 0:e.connected)===!0}emit(e,t){var o;if(!this.isConnected())throw new Error("Socket not connected");console.log(`[CallSocket] Emitting ${e}:`,t),(o=this.socket)==null||o.emit(e,t,l=>{l!=null&&l.error&&console.error(`[CallSocket] Error in ${e}:`,l.error)})}emitWithResponse(e,t,o=1e4){return ke(this,null,function*(){if(!this.isConnected())throw new Error("Socket not connected");return console.log(`[CallSocket] Emitting ${e} with response:`,t),new Promise((l,c)=>{var E;const a=setTimeout(()=>{c(new Error(`Timeout waiting for response to ${e}`))},o);console.log(`[CallSocket] about to emit: ${e}...`),(E=this.socket)==null||E.emit(e,t,f=>{clearTimeout(a),f!=null&&f.error?(console.error(`[CallSocket] Error in ${e}:`,f.error),c(new Error(f.error))):(console.log(`[CallSocket] Response for ${e}:`,f),l(f))})})})}on(e,t){if(!this.socket)throw new Error("Socket not connected");this.socket.on(e,t)}off(e,t){this.socket&&(t?this.socket.off(e,t):this.socket.removeAllListeners(e))}startCall(e,t){return ke(this,null,function*(){return this.emitWithResponse("call.start",{conversationId:e,userId:t})})}joinRoom(e,t){return ke(this,null,function*(){return this.emitWithResponse("call.join",{conversationId:e,userId:t})})}leaveCall(e,t){return ke(this,null,function*(){return this.emitWithResponse("call.leave",{conversationId:e,userId:t})})}sendOffer(e,t,o,l){this.emit("call.offer",{to:e,from:t,offer:o,conversationId:l})}sendAnswer(e,t,o,l){this.emit("call.answer",{to:e,from:t,answer:o,conversationId:l})}sendCandidate(e,t,o,l){this.emit("call.candidate",{to:e,from:t,candidate:o,conversationId:l})}sendStateUpdate(e,t,o,l){this.emit("call.state",{to:e,from:t,state:o,conversationId:l})}endCall(e,t,o){this.emit("call.end",{conversationId:o,targetUserId:e})}endCallForAll(e){return ke(this,null,function*(){this.emit("call.end",{conversationId:e})})}startRecording(e,t){return ke(this,null,function*(){return this.emitWithResponse("call.recording.start",{conversationId:e,recordingId:t})})}sendRecordingChunk(e,t,o){this.emit("call.recording.chunk",{conversationId:e,recordingId:t,chunk:o})}endRecording(e,t){return ke(this,null,function*(){return this.emitWithResponse("call.recording.end",{conversationId:e,recordingId:t})})}sendTranscript(e,t,o){this.emit("call.transcript",{conversationId:e,userId:t,transcript:o,timestamp:Date.now()})}checkCallStatus(e,t){return ke(this,null,function*(){return this.emitWithResponse("call.status",{conversationId:e,userId:t})})}handleDisconnection(e){["transport close","transport error","io server disconnect"].includes(e)&&this.reconnectAttempts<this.maxReconnectAttempts&&setTimeout(()=>{this.connected||(console.log(`[CallSocket] Attempting to reconnect... (${this.reconnectAttempts+1}/${this.maxReconnectAttempts})`),this.connect().catch(console.error))},Math.pow(2,this.reconnectAttempts)*1e3)}getConnectionInfo(){var e,t;return{connected:this.connected,socketId:(e=this.socket)==null?void 0:e.id,transport:(t=this.socket)==null?void 0:t.io.engine.transport.name,reconnectAttempts:this.reconnectAttempts}}}var Ao=Object.defineProperty,To=(n,e,t)=>e in n?Ao(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,et=(n,e,t)=>To(n,typeof e!="symbol"?e+"":e,t),tt=(n,e,t)=>new Promise((o,l)=>{var c=f=>{try{a(t.next(f))}catch(u){l(u)}},E=f=>{try{a(t.throw(f))}catch(u){l(u)}},a=f=>f.done?o(f.value):Promise.resolve(f.value).then(c,E);a((t=t.apply(n,e)).next())});class cn{constructor(e={video:!0,audio:!0}){et(this,"stream",null),et(this,"videoElement",null),et(this,"constraints"),et(this,"isScreenShare",!1),this.constraints=e}initialize(){return tt(this,null,function*(){try{return console.log("[CallMediaStream] Initializing media stream with constraints:",this.constraints),this.stream=yield navigator.mediaDevices.getUserMedia(this.constraints),console.log("[CallMediaStream] Media stream initialized successfully"),this.stream}catch(e){throw console.error("[CallMediaStream] Failed to initialize media stream:",e),this.handleMediaError(e)}})}startScreenShare(){return tt(this,arguments,function*(e={video:!0,audio:!1}){try{console.log("[CallMediaStream] Starting screen share");const t=yield navigator.mediaDevices.getDisplayMedia({video:e.video,audio:e.audio}),o=this.stream;return this.stream=t,this.isScreenShare=!0,t.getVideoTracks()[0].addEventListener("ended",()=>{console.log("[CallMediaStream] Screen share ended by user"),this.stopScreenShare(o)}),console.log("[CallMediaStream] Screen share started successfully"),t}catch(t){throw console.error("[CallMediaStream] Failed to start screen share:",t),this.handleMediaError(t)}})}stopScreenShare(e){return tt(this,null,function*(){try{return console.log("[CallMediaStream] Stopping screen share"),this.stream&&this.isScreenShare&&this.stream.getTracks().forEach(t=>t.stop()),e?this.stream=e:this.stream=yield this.initialize(),this.isScreenShare=!1,console.log("[CallMediaStream] Reverted to camera stream"),this.stream}catch(t){throw console.error("[CallMediaStream] Failed to stop screen share:",t),this.handleMediaError(t)}})}toggleAudio(e){if(!this.stream){console.warn("[CallMediaStream] No stream available for audio toggle");return}this.stream.getAudioTracks().forEach(o=>{o.enabled=e}),console.log(`[CallMediaStream] Audio ${e?"enabled":"disabled"}`)}toggleVideo(e){if(!this.stream){console.warn("[CallMediaStream] No stream available for video toggle");return}this.stream.getVideoTracks().forEach(o=>{o.enabled=e}),console.log(`[CallMediaStream] Video ${e?"enabled":"disabled"}`)}createVideoElement(){const e=document.createElement("video");return e.autoplay=!0,e.playsInline=!0,e.muted=!0,this.stream&&(e.srcObject=this.stream),this.videoElement=e,e}attachToVideoElement(e){this.stream&&(e.srcObject=this.stream,this.videoElement=e)}replaceStream(e){this.stream&&this.stream.getTracks().forEach(t=>t.stop()),this.stream=e,this.videoElement&&(this.videoElement.srcObject=e),console.log("[CallMediaStream] Stream replaced successfully")}getStream(){return this.stream}getVideoElement(){return this.videoElement}getIsScreenShare(){return this.isScreenShare}isAudioEnabled(){if(!this.stream)return!1;const e=this.stream.getAudioTracks();return e.length>0&&e[0].enabled}isVideoEnabled(){if(!this.stream)return!1;const e=this.stream.getVideoTracks();return e.length>0&&e[0].enabled}getStreamInfo(){if(!this.stream)return null;const e=this.stream.getVideoTracks(),t=this.stream.getAudioTracks();return{id:this.stream.id,videoTracks:e.length,audioTracks:t.length,isScreenShare:this.isScreenShare,videoEnabled:e.length>0?e[0].enabled:!1,audioEnabled:t.length>0?t[0].enabled:!1,videoConstraints:e.length>0?e[0].getSettings():null,audioConstraints:t.length>0?t[0].getSettings():null}}cleanup(){console.log("[CallMediaStream] Cleaning up media stream"),this.stream&&(this.stream.getTracks().forEach(e=>{e.stop()}),this.stream=null),this.videoElement&&(this.videoElement.srcObject=null,this.videoElement=null),this.isScreenShare=!1}handleMediaError(e){let t="Unknown media error";return e.name==="NotAllowedError"?t="Permission denied. Please allow camera and microphone access.":e.name==="NotFoundError"?t="No camera or microphone found. Please check your devices.":e.name==="NotReadableError"?t="Camera or microphone is already in use by another application.":e.name==="OverconstrainedError"?t="Camera or microphone does not support the requested constraints.":e.name==="SecurityError"?t="Media access blocked due to security restrictions.":e.name==="AbortError"&&(t="Media access was aborted."),new Error(`${t} (${e.name})`)}static getAvailableDevices(){return tt(this,null,function*(){try{const e=yield navigator.mediaDevices.enumerateDevices();return{videoDevices:e.filter(t=>t.kind==="videoinput"),audioDevices:e.filter(t=>t.kind==="audioinput")}}catch(e){throw console.error("[CallMediaStream] Failed to get available devices:",e),e}})}static checkBrowserSupport(){return{getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),webRTC:!!window.RTCPeerConnection}}}function yt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var rt={exports:{}},mt,un;function Io(){if(un)return mt;un=1;var n=1e3,e=n*60,t=e*60,o=t*24,l=o*7,c=o*365.25;mt=function(w,A){A=A||{};var C=typeof w;if(C==="string"&&w.length>0)return E(w);if(C==="number"&&isFinite(w))return A.long?f(w):a(w);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(w))};function E(w){if(w=String(w),!(w.length>100)){var A=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(w);if(A){var C=parseFloat(A[1]),j=(A[2]||"ms").toLowerCase();switch(j){case"years":case"year":case"yrs":case"yr":case"y":return C*c;case"weeks":case"week":case"w":return C*l;case"days":case"day":case"d":return C*o;case"hours":case"hour":case"hrs":case"hr":case"h":return C*t;case"minutes":case"minute":case"mins":case"min":case"m":return C*e;case"seconds":case"second":case"secs":case"sec":case"s":return C*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return C;default:return}}}}function a(w){var A=Math.abs(w);return A>=o?Math.round(w/o)+"d":A>=t?Math.round(w/t)+"h":A>=e?Math.round(w/e)+"m":A>=n?Math.round(w/n)+"s":w+"ms"}function f(w){var A=Math.abs(w);return A>=o?u(w,A,o,"day"):A>=t?u(w,A,t,"hour"):A>=e?u(w,A,e,"minute"):A>=n?u(w,A,n,"second"):w+" ms"}function u(w,A,C,j){var y=A>=C*1.5;return Math.round(w/C)+" "+j+(y?"s":"")}return mt}var vt,fn;function Oo(){if(fn)return vt;fn=1;function n(e){o.debug=o,o.default=o,o.coerce=u,o.disable=a,o.enable=c,o.enabled=f,o.humanize=Io(),o.destroy=w,Object.keys(e).forEach(A=>{o[A]=e[A]}),o.names=[],o.skips=[],o.formatters={};function t(A){let C=0;for(let j=0;j<A.length;j++)C=(C<<5)-C+A.charCodeAt(j),C|=0;return o.colors[Math.abs(C)%o.colors.length]}o.selectColor=t;function o(A){let C,j=null,y,I;function S(...h){if(!S.enabled)return;const b=S,P=Number(new Date),_=P-(C||P);b.diff=_,b.prev=C,b.curr=P,C=P,h[0]=o.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let R=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(g,B)=>{if(g==="%%")return"%";R++;const U=o.formatters[B];if(typeof U=="function"){const F=h[R];g=U.call(b,F),h.splice(R,1),R--}return g}),o.formatArgs.call(b,h),(b.log||o.log).apply(b,h)}return S.namespace=A,S.useColors=o.useColors(),S.color=o.selectColor(A),S.extend=l,S.destroy=o.destroy,Object.defineProperty(S,"enabled",{enumerable:!0,configurable:!1,get:()=>j!==null?j:(y!==o.namespaces&&(y=o.namespaces,I=o.enabled(A)),I),set:h=>{j=h}}),typeof o.init=="function"&&o.init(S),S}function l(A,C){const j=o(this.namespace+(typeof C=="undefined"?":":C)+A);return j.log=this.log,j}function c(A){o.save(A),o.namespaces=A,o.names=[],o.skips=[];const C=(typeof A=="string"?A:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const j of C)j[0]==="-"?o.skips.push(j.slice(1)):o.names.push(j)}function E(A,C){let j=0,y=0,I=-1,S=0;for(;j<A.length;)if(y<C.length&&(C[y]===A[j]||C[y]==="*"))C[y]==="*"?(I=y,S=j,y++):(j++,y++);else if(I!==-1)y=I+1,S++,j=S;else return!1;for(;y<C.length&&C[y]==="*";)y++;return y===C.length}function a(){const A=[...o.names,...o.skips.map(C=>"-"+C)].join(",");return o.enable(""),A}function f(A){for(const C of o.skips)if(E(A,C))return!1;for(const C of o.names)if(E(A,C))return!0;return!1}function u(A){return A instanceof Error?A.stack||A.message:A}function w(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.enable(o.load()),o}return vt=n,vt}var dn;function ko(){return dn||(dn=1,function(n,e){var t={env:{}};e.formatArgs=l,e.save=c,e.load=E,e.useColors=o,e.storage=a(),e.destroy=(()=>{let u=!1;return()=>{u||(u=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function o(){if(typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let u;return typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&(u=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(u[1],10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function l(u){if(u[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+u[0]+(this.useColors?"%c ":" ")+"+"+n.exports.humanize(this.diff),!this.useColors)return;const w="color: "+this.color;u.splice(1,0,w,"color: inherit");let A=0,C=0;u[0].replace(/%[a-zA-Z%]/g,j=>{j!=="%%"&&(A++,j==="%c"&&(C=A))}),u.splice(C,0,w)}e.log=console.debug||console.log||(()=>{});function c(u){try{u?e.storage.setItem("debug",u):e.storage.removeItem("debug")}catch(w){}}function E(){let u;try{u=e.storage.getItem("debug")||e.storage.getItem("DEBUG")}catch(w){}return!u&&typeof t!="undefined"&&"env"in t&&(u=t.env.DEBUG),u}function a(){try{return localStorage}catch(u){}}n.exports=Oo()(e);const{formatters:f}=n.exports;f.j=function(u){try{return JSON.stringify(u)}catch(w){return"[UnexpectedJSONParseError]: "+w.message}}}(rt,rt.exports)),rt.exports}var bt,hn;function Mo(){return hn||(hn=1,bt=function(){if(typeof globalThis=="undefined")return null;var e={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}),bt}var nt={exports:{}},it={exports:{}},wt={},pn;function He(){return pn||(pn=1,function(n){Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},t={};t.byteLength=w,t.toByteArray=C,t.fromByteArray=I;for(var o=[],l=[],c=typeof Uint8Array!="undefined"?Uint8Array:Array,E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,f=E.length;a<f;++a)o[a]=E[a],l[E.charCodeAt(a)]=a;l[45]=62,l[95]=63;function u(b){var P=b.length;if(P%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=b.indexOf("=");_===-1&&(_=P);var R=_===P?0:4-_%4;return[_,R]}function w(b){var P=u(b),_=P[0],R=P[1];return(_+R)*3/4-R}function A(b,P,_){return(P+_)*3/4-_}function C(b){var P,_=u(b),R=_[0],v=_[1],g=new c(A(b,R,v)),B=0,U=v>0?R-4:R,F;for(F=0;F<U;F+=4)P=l[b.charCodeAt(F)]<<18|l[b.charCodeAt(F+1)]<<12|l[b.charCodeAt(F+2)]<<6|l[b.charCodeAt(F+3)],g[B++]=P>>16&255,g[B++]=P>>8&255,g[B++]=P&255;return v===2&&(P=l[b.charCodeAt(F)]<<2|l[b.charCodeAt(F+1)]>>4,g[B++]=P&255),v===1&&(P=l[b.charCodeAt(F)]<<10|l[b.charCodeAt(F+1)]<<4|l[b.charCodeAt(F+2)]>>2,g[B++]=P>>8&255,g[B++]=P&255),g}function j(b){return o[b>>18&63]+o[b>>12&63]+o[b>>6&63]+o[b&63]}function y(b,P,_){for(var R,v=[],g=P;g<_;g+=3)R=(b[g]<<16&16711680)+(b[g+1]<<8&65280)+(b[g+2]&255),v.push(j(R));return v.join("")}function I(b){for(var P,_=b.length,R=_%3,v=[],g=16383,B=0,U=_-R;B<U;B+=g)v.push(y(b,B,B+g>U?U:B+g));return R===1?(P=b[_-1],v.push(o[P>>2]+o[P<<4&63]+"==")):R===2&&(P=(b[_-2]<<8)+b[_-1],v.push(o[P>>10]+o[P>>4&63]+o[P<<2&63]+"=")),v.join("")}var S={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */S.read=function(b,P,_,R,v){var g,B,U=v*8-R-1,F=(1<<U)-1,J=F>>1,k=-7,ne=_?v-1:0,re=_?-1:1,ce=b[P+ne];for(ne+=re,g=ce&(1<<-k)-1,ce>>=-k,k+=U;k>0;g=g*256+b[P+ne],ne+=re,k-=8);for(B=g&(1<<-k)-1,g>>=-k,k+=R;k>0;B=B*256+b[P+ne],ne+=re,k-=8);if(g===0)g=1-J;else{if(g===F)return B?NaN:(ce?-1:1)*(1/0);B=B+Math.pow(2,R),g=g-J}return(ce?-1:1)*B*Math.pow(2,g-R)},S.write=function(b,P,_,R,v,g){var B,U,F,J=g*8-v-1,k=(1<<J)-1,ne=k>>1,re=v===23?Math.pow(2,-24)-Math.pow(2,-77):0,ce=R?0:g-1,fe=R?1:-1,Se=P<0||P===0&&1/P<0?1:0;for(P=Math.abs(P),isNaN(P)||P===1/0?(U=isNaN(P)?1:0,B=k):(B=Math.floor(Math.log(P)/Math.LN2),P*(F=Math.pow(2,-B))<1&&(B--,F*=2),B+ne>=1?P+=re/F:P+=re*Math.pow(2,1-ne),P*F>=2&&(B++,F/=2),B+ne>=k?(U=0,B=k):B+ne>=1?(U=(P*F-1)*Math.pow(2,v),B=B+ne):(U=P*Math.pow(2,ne-1)*Math.pow(2,v),B=0));v>=8;b[_+ce]=U&255,ce+=fe,U/=256,v-=8);for(B=B<<v|U,J+=v;J>0;b[_+ce]=B&255,ce+=fe,B/=256,J-=8);b[_+ce-fe]|=Se*128};/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/(function(b){const P=t,_=S,R=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;b.Buffer=k,b.SlowBuffer=L,b.INSPECT_MAX_BYTES=50;const v=2147483647;b.kMaxLength=v;const{Uint8Array:g,ArrayBuffer:B,SharedArrayBuffer:U}=globalThis;k.TYPED_ARRAY_SUPPORT=F(),!k.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function F(){try{const s=new g(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,g.prototype),Object.setPrototypeOf(s,r),s.foo()===42}catch(s){return!1}}Object.defineProperty(k.prototype,"parent",{enumerable:!0,get:function(){if(k.isBuffer(this))return this.buffer}}),Object.defineProperty(k.prototype,"offset",{enumerable:!0,get:function(){if(k.isBuffer(this))return this.byteOffset}});function J(s){if(s>v)throw new RangeError('The value "'+s+'" is invalid for option "size"');const r=new g(s);return Object.setPrototypeOf(r,k.prototype),r}function k(s,r,i){if(typeof s=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return fe(s)}return ne(s,r,i)}k.poolSize=8192;function ne(s,r,i){if(typeof s=="string")return Se(s,r);if(B.isView(s))return ve(s);if(s==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s);if(Oe(s,B)||s&&Oe(s.buffer,B)||typeof U!="undefined"&&(Oe(s,U)||s&&Oe(s.buffer,U)))return se(s,r,i);if(typeof s=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const m=s.valueOf&&s.valueOf();if(m!=null&&m!==s)return k.from(m,r,i);const T=Ee(s);if(T)return T;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof s[Symbol.toPrimitive]=="function")return k.from(s[Symbol.toPrimitive]("string"),r,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s)}k.from=function(s,r,i){return ne(s,r,i)},Object.setPrototypeOf(k.prototype,g.prototype),Object.setPrototypeOf(k,g);function re(s){if(typeof s!="number")throw new TypeError('"size" argument must be of type number');if(s<0)throw new RangeError('The value "'+s+'" is invalid for option "size"')}function ce(s,r,i){return re(s),s<=0?J(s):r!==void 0?typeof i=="string"?J(s).fill(r,i):J(s).fill(r):J(s)}k.alloc=function(s,r,i){return ce(s,r,i)};function fe(s){return re(s),J(s<0?0:me(s)|0)}k.allocUnsafe=function(s){return fe(s)},k.allocUnsafeSlow=function(s){return fe(s)};function Se(s,r){if((typeof r!="string"||r==="")&&(r="utf8"),!k.isEncoding(r))throw new TypeError("Unknown encoding: "+r);const i=$(s,r)|0;let m=J(i);const T=m.write(s,r);return T!==i&&(m=m.slice(0,T)),m}function de(s){const r=s.length<0?0:me(s.length)|0,i=J(r);for(let m=0;m<r;m+=1)i[m]=s[m]&255;return i}function ve(s){if(Oe(s,g)){const r=new g(s);return se(r.buffer,r.byteOffset,r.byteLength)}return de(s)}function se(s,r,i){if(r<0||s.byteLength<r)throw new RangeError('"offset" is outside of buffer bounds');if(s.byteLength<r+(i||0))throw new RangeError('"length" is outside of buffer bounds');let m;return r===void 0&&i===void 0?m=new g(s):i===void 0?m=new g(s,r):m=new g(s,r,i),Object.setPrototypeOf(m,k.prototype),m}function Ee(s){if(k.isBuffer(s)){const r=me(s.length)|0,i=J(r);return i.length===0||s.copy(i,0,0,r),i}if(s.length!==void 0)return typeof s.length!="number"||nn(s.length)?J(0):de(s);if(s.type==="Buffer"&&Array.isArray(s.data))return de(s.data)}function me(s){if(s>=v)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+v.toString(16)+" bytes");return s|0}function L(s){return+s!=s&&(s=0),k.alloc(+s)}k.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==k.prototype},k.compare=function(r,i){if(Oe(r,g)&&(r=k.from(r,r.offset,r.byteLength)),Oe(i,g)&&(i=k.from(i,i.offset,i.byteLength)),!k.isBuffer(r)||!k.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===i)return 0;let m=r.length,T=i.length;for(let N=0,W=Math.min(m,T);N<W;++N)if(r[N]!==i[N]){m=r[N],T=i[N];break}return m<T?-1:T<m?1:0},k.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},k.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return k.alloc(0);let m;if(i===void 0)for(i=0,m=0;m<r.length;++m)i+=r[m].length;const T=k.allocUnsafe(i);let N=0;for(m=0;m<r.length;++m){let W=r[m];if(Oe(W,g))N+W.length>T.length?(k.isBuffer(W)||(W=k.from(W)),W.copy(T,N)):g.prototype.set.call(T,W,N);else if(k.isBuffer(W))W.copy(T,N);else throw new TypeError('"list" argument must be an Array of Buffers');N+=W.length}return T};function $(s,r){if(k.isBuffer(s))return s.length;if(B.isView(s)||Oe(s,B))return s.byteLength;if(typeof s!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof s);const i=s.length,m=arguments.length>2&&arguments[2]===!0;if(!m&&i===0)return 0;let T=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return rn(s).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return So(s).length;default:if(T)return m?-1:rn(s).length;r=(""+r).toLowerCase(),T=!0}}k.byteLength=$;function G(s,r,i){let m=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(s||(s="utf8");;)switch(s){case"hex":return Ce(this,r,i);case"utf8":case"utf-8":return H(this,r,i);case"ascii":return te(this,r,i);case"latin1":case"binary":return q(this,r,i);case"base64":return x(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _e(this,r,i);default:if(m)throw new TypeError("Unknown encoding: "+s);s=(s+"").toLowerCase(),m=!0}}k.prototype._isBuffer=!0;function K(s,r,i){const m=s[r];s[r]=s[i],s[i]=m}k.prototype.swap16=function(){const r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let i=0;i<r;i+=2)K(this,i,i+1);return this},k.prototype.swap32=function(){const r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let i=0;i<r;i+=4)K(this,i,i+3),K(this,i+1,i+2);return this},k.prototype.swap64=function(){const r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let i=0;i<r;i+=8)K(this,i,i+7),K(this,i+1,i+6),K(this,i+2,i+5),K(this,i+3,i+4);return this},k.prototype.toString=function(){const r=this.length;return r===0?"":arguments.length===0?H(this,0,r):G.apply(this,arguments)},k.prototype.toLocaleString=k.prototype.toString,k.prototype.equals=function(r){if(!k.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:k.compare(this,r)===0},k.prototype.inspect=function(){let r="";const i=b.INSPECT_MAX_BYTES;return r=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(r+=" ... "),"<Buffer "+r+">"},R&&(k.prototype[R]=k.prototype.inspect),k.prototype.compare=function(r,i,m,T,N){if(Oe(r,g)&&(r=k.from(r,r.offset,r.byteLength)),!k.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(i===void 0&&(i=0),m===void 0&&(m=r?r.length:0),T===void 0&&(T=0),N===void 0&&(N=this.length),i<0||m>r.length||T<0||N>this.length)throw new RangeError("out of range index");if(T>=N&&i>=m)return 0;if(T>=N)return-1;if(i>=m)return 1;if(i>>>=0,m>>>=0,T>>>=0,N>>>=0,this===r)return 0;let W=N-T,ee=m-i;const pe=Math.min(W,ee),ue=this.slice(T,N),ge=r.slice(i,m);for(let ie=0;ie<pe;++ie)if(ue[ie]!==ge[ie]){W=ue[ie],ee=ge[ie];break}return W<ee?-1:ee<W?1:0};function M(s,r,i,m,T){if(s.length===0)return-1;if(typeof i=="string"?(m=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,nn(i)&&(i=T?0:s.length-1),i<0&&(i=s.length+i),i>=s.length){if(T)return-1;i=s.length-1}else if(i<0)if(T)i=0;else return-1;if(typeof r=="string"&&(r=k.from(r,m)),k.isBuffer(r))return r.length===0?-1:O(s,r,i,m,T);if(typeof r=="number")return r=r&255,typeof g.prototype.indexOf=="function"?T?g.prototype.indexOf.call(s,r,i):g.prototype.lastIndexOf.call(s,r,i):O(s,[r],i,m,T);throw new TypeError("val must be string, number or Buffer")}function O(s,r,i,m,T){let N=1,W=s.length,ee=r.length;if(m!==void 0&&(m=String(m).toLowerCase(),m==="ucs2"||m==="ucs-2"||m==="utf16le"||m==="utf-16le")){if(s.length<2||r.length<2)return-1;N=2,W/=2,ee/=2,i/=2}function pe(ge,ie){return N===1?ge[ie]:ge.readUInt16BE(ie*N)}let ue;if(T){let ge=-1;for(ue=i;ue<W;ue++)if(pe(s,ue)===pe(r,ge===-1?0:ue-ge)){if(ge===-1&&(ge=ue),ue-ge+1===ee)return ge*N}else ge!==-1&&(ue-=ue-ge),ge=-1}else for(i+ee>W&&(i=W-ee),ue=i;ue>=0;ue--){let ge=!0;for(let ie=0;ie<ee;ie++)if(pe(s,ue+ie)!==pe(r,ie)){ge=!1;break}if(ge)return ue}return-1}k.prototype.includes=function(r,i,m){return this.indexOf(r,i,m)!==-1},k.prototype.indexOf=function(r,i,m){return M(this,r,i,m,!0)},k.prototype.lastIndexOf=function(r,i,m){return M(this,r,i,m,!1)};function D(s,r,i,m){i=Number(i)||0;const T=s.length-i;m?(m=Number(m),m>T&&(m=T)):m=T;const N=r.length;m>N/2&&(m=N/2);let W;for(W=0;W<m;++W){const ee=parseInt(r.substr(W*2,2),16);if(nn(ee))return W;s[i+W]=ee}return W}function z(s,r,i,m){return ht(rn(r,s.length-i),s,i,m)}function V(s,r,i,m){return ht(Ds(r),s,i,m)}function d(s,r,i,m){return ht(So(r),s,i,m)}function p(s,r,i,m){return ht(Fs(r,s.length-i),s,i,m)}k.prototype.write=function(r,i,m,T){if(i===void 0)T="utf8",m=this.length,i=0;else if(m===void 0&&typeof i=="string")T=i,m=this.length,i=0;else if(isFinite(i))i=i>>>0,isFinite(m)?(m=m>>>0,T===void 0&&(T="utf8")):(T=m,m=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const N=this.length-i;if((m===void 0||m>N)&&(m=N),r.length>0&&(m<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");T||(T="utf8");let W=!1;for(;;)switch(T){case"hex":return D(this,r,i,m);case"utf8":case"utf-8":return z(this,r,i,m);case"ascii":case"latin1":case"binary":return V(this,r,i,m);case"base64":return d(this,r,i,m);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p(this,r,i,m);default:if(W)throw new TypeError("Unknown encoding: "+T);T=(""+T).toLowerCase(),W=!0}},k.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(s,r,i){return r===0&&i===s.length?P.fromByteArray(s):P.fromByteArray(s.slice(r,i))}function H(s,r,i){i=Math.min(s.length,i);const m=[];let T=r;for(;T<i;){const N=s[T];let W=null,ee=N>239?4:N>223?3:N>191?2:1;if(T+ee<=i){let pe,ue,ge,ie;switch(ee){case 1:N<128&&(W=N);break;case 2:pe=s[T+1],(pe&192)===128&&(ie=(N&31)<<6|pe&63,ie>127&&(W=ie));break;case 3:pe=s[T+1],ue=s[T+2],(pe&192)===128&&(ue&192)===128&&(ie=(N&15)<<12|(pe&63)<<6|ue&63,ie>2047&&(ie<55296||ie>57343)&&(W=ie));break;case 4:pe=s[T+1],ue=s[T+2],ge=s[T+3],(pe&192)===128&&(ue&192)===128&&(ge&192)===128&&(ie=(N&15)<<18|(pe&63)<<12|(ue&63)<<6|ge&63,ie>65535&&ie<1114112&&(W=ie))}}W===null?(W=65533,ee=1):W>65535&&(W-=65536,m.push(W>>>10&1023|55296),W=56320|W&1023),m.push(W),T+=ee}return Z(m)}const X=4096;function Z(s){const r=s.length;if(r<=X)return String.fromCharCode.apply(String,s);let i="",m=0;for(;m<r;)i+=String.fromCharCode.apply(String,s.slice(m,m+=X));return i}function te(s,r,i){let m="";i=Math.min(s.length,i);for(let T=r;T<i;++T)m+=String.fromCharCode(s[T]&127);return m}function q(s,r,i){let m="";i=Math.min(s.length,i);for(let T=r;T<i;++T)m+=String.fromCharCode(s[T]);return m}function Ce(s,r,i){const m=s.length;(!r||r<0)&&(r=0),(!i||i<0||i>m)&&(i=m);let T="";for(let N=r;N<i;++N)T+=js[s[N]];return T}function _e(s,r,i){const m=s.slice(r,i);let T="";for(let N=0;N<m.length-1;N+=2)T+=String.fromCharCode(m[N]+m[N+1]*256);return T}k.prototype.slice=function(r,i){const m=this.length;r=~~r,i=i===void 0?m:~~i,r<0?(r+=m,r<0&&(r=0)):r>m&&(r=m),i<0?(i+=m,i<0&&(i=0)):i>m&&(i=m),i<r&&(i=r);const T=this.subarray(r,i);return Object.setPrototypeOf(T,k.prototype),T};function le(s,r,i){if(s%1!==0||s<0)throw new RangeError("offset is not uint");if(s+r>i)throw new RangeError("Trying to access beyond buffer length")}k.prototype.readUintLE=k.prototype.readUIntLE=function(r,i,m){r=r>>>0,i=i>>>0,m||le(r,i,this.length);let T=this[r],N=1,W=0;for(;++W<i&&(N*=256);)T+=this[r+W]*N;return T},k.prototype.readUintBE=k.prototype.readUIntBE=function(r,i,m){r=r>>>0,i=i>>>0,m||le(r,i,this.length);let T=this[r+--i],N=1;for(;i>0&&(N*=256);)T+=this[r+--i]*N;return T},k.prototype.readUint8=k.prototype.readUInt8=function(r,i){return r=r>>>0,i||le(r,1,this.length),this[r]},k.prototype.readUint16LE=k.prototype.readUInt16LE=function(r,i){return r=r>>>0,i||le(r,2,this.length),this[r]|this[r+1]<<8},k.prototype.readUint16BE=k.prototype.readUInt16BE=function(r,i){return r=r>>>0,i||le(r,2,this.length),this[r]<<8|this[r+1]},k.prototype.readUint32LE=k.prototype.readUInt32LE=function(r,i){return r=r>>>0,i||le(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216},k.prototype.readUint32BE=k.prototype.readUInt32BE=function(r,i){return r=r>>>0,i||le(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])},k.prototype.readBigUInt64LE=Le(function(r){r=r>>>0,Ve(r,"offset");const i=this[r],m=this[r+7];(i===void 0||m===void 0)&&Ze(r,this.length-8);const T=i+this[++r]*oe(2,8)+this[++r]*oe(2,16)+this[++r]*oe(2,24),N=this[++r]+this[++r]*oe(2,8)+this[++r]*oe(2,16)+m*oe(2,24);return BigInt(T)+(BigInt(N)<<BigInt(32))}),k.prototype.readBigUInt64BE=Le(function(r){r=r>>>0,Ve(r,"offset");const i=this[r],m=this[r+7];(i===void 0||m===void 0)&&Ze(r,this.length-8);const T=i*oe(2,24)+this[++r]*oe(2,16)+this[++r]*oe(2,8)+this[++r],N=this[++r]*oe(2,24)+this[++r]*oe(2,16)+this[++r]*oe(2,8)+m;return(BigInt(T)<<BigInt(32))+BigInt(N)}),k.prototype.readIntLE=function(r,i,m){r=r>>>0,i=i>>>0,m||le(r,i,this.length);let T=this[r],N=1,W=0;for(;++W<i&&(N*=256);)T+=this[r+W]*N;return N*=128,T>=N&&(T-=Math.pow(2,8*i)),T},k.prototype.readIntBE=function(r,i,m){r=r>>>0,i=i>>>0,m||le(r,i,this.length);let T=i,N=1,W=this[r+--T];for(;T>0&&(N*=256);)W+=this[r+--T]*N;return N*=128,W>=N&&(W-=Math.pow(2,8*i)),W},k.prototype.readInt8=function(r,i){return r=r>>>0,i||le(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]},k.prototype.readInt16LE=function(r,i){r=r>>>0,i||le(r,2,this.length);const m=this[r]|this[r+1]<<8;return m&32768?m|4294901760:m},k.prototype.readInt16BE=function(r,i){r=r>>>0,i||le(r,2,this.length);const m=this[r+1]|this[r]<<8;return m&32768?m|4294901760:m},k.prototype.readInt32LE=function(r,i){return r=r>>>0,i||le(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},k.prototype.readInt32BE=function(r,i){return r=r>>>0,i||le(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},k.prototype.readBigInt64LE=Le(function(r){r=r>>>0,Ve(r,"offset");const i=this[r],m=this[r+7];(i===void 0||m===void 0)&&Ze(r,this.length-8);const T=this[r+4]+this[r+5]*oe(2,8)+this[r+6]*oe(2,16)+(m<<24);return(BigInt(T)<<BigInt(32))+BigInt(i+this[++r]*oe(2,8)+this[++r]*oe(2,16)+this[++r]*oe(2,24))}),k.prototype.readBigInt64BE=Le(function(r){r=r>>>0,Ve(r,"offset");const i=this[r],m=this[r+7];(i===void 0||m===void 0)&&Ze(r,this.length-8);const T=(i<<24)+this[++r]*oe(2,16)+this[++r]*oe(2,8)+this[++r];return(BigInt(T)<<BigInt(32))+BigInt(this[++r]*oe(2,24)+this[++r]*oe(2,16)+this[++r]*oe(2,8)+m)}),k.prototype.readFloatLE=function(r,i){return r=r>>>0,i||le(r,4,this.length),_.read(this,r,!0,23,4)},k.prototype.readFloatBE=function(r,i){return r=r>>>0,i||le(r,4,this.length),_.read(this,r,!1,23,4)},k.prototype.readDoubleLE=function(r,i){return r=r>>>0,i||le(r,8,this.length),_.read(this,r,!0,52,8)},k.prototype.readDoubleBE=function(r,i){return r=r>>>0,i||le(r,8,this.length),_.read(this,r,!1,52,8)};function he(s,r,i,m,T,N){if(!k.isBuffer(s))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>T||r<N)throw new RangeError('"value" argument is out of bounds');if(i+m>s.length)throw new RangeError("Index out of range")}k.prototype.writeUintLE=k.prototype.writeUIntLE=function(r,i,m,T){if(r=+r,i=i>>>0,m=m>>>0,!T){const ee=Math.pow(2,8*m)-1;he(this,r,i,m,ee,0)}let N=1,W=0;for(this[i]=r&255;++W<m&&(N*=256);)this[i+W]=r/N&255;return i+m},k.prototype.writeUintBE=k.prototype.writeUIntBE=function(r,i,m,T){if(r=+r,i=i>>>0,m=m>>>0,!T){const ee=Math.pow(2,8*m)-1;he(this,r,i,m,ee,0)}let N=m-1,W=1;for(this[i+N]=r&255;--N>=0&&(W*=256);)this[i+N]=r/W&255;return i+m},k.prototype.writeUint8=k.prototype.writeUInt8=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,1,255,0),this[i]=r&255,i+1},k.prototype.writeUint16LE=k.prototype.writeUInt16LE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,2,65535,0),this[i]=r&255,this[i+1]=r>>>8,i+2},k.prototype.writeUint16BE=k.prototype.writeUInt16BE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,2,65535,0),this[i]=r>>>8,this[i+1]=r&255,i+2},k.prototype.writeUint32LE=k.prototype.writeUInt32LE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,4,4294967295,0),this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255,i+4},k.prototype.writeUint32BE=k.prototype.writeUInt32BE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,4,4294967295,0),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4};function Pe(s,r,i,m,T){_o(r,m,T,s,i,7);let N=Number(r&BigInt(4294967295));s[i++]=N,N=N>>8,s[i++]=N,N=N>>8,s[i++]=N,N=N>>8,s[i++]=N;let W=Number(r>>BigInt(32)&BigInt(4294967295));return s[i++]=W,W=W>>8,s[i++]=W,W=W>>8,s[i++]=W,W=W>>8,s[i++]=W,i}function ze(s,r,i,m,T){_o(r,m,T,s,i,7);let N=Number(r&BigInt(4294967295));s[i+7]=N,N=N>>8,s[i+6]=N,N=N>>8,s[i+5]=N,N=N>>8,s[i+4]=N;let W=Number(r>>BigInt(32)&BigInt(4294967295));return s[i+3]=W,W=W>>8,s[i+2]=W,W=W>>8,s[i+1]=W,W=W>>8,s[i]=W,i+8}k.prototype.writeBigUInt64LE=Le(function(r,i=0){return Pe(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),k.prototype.writeBigUInt64BE=Le(function(r,i=0){return ze(this,r,i,BigInt(0),BigInt("0xffffffffffffffff"))}),k.prototype.writeIntLE=function(r,i,m,T){if(r=+r,i=i>>>0,!T){const pe=Math.pow(2,8*m-1);he(this,r,i,m,pe-1,-pe)}let N=0,W=1,ee=0;for(this[i]=r&255;++N<m&&(W*=256);)r<0&&ee===0&&this[i+N-1]!==0&&(ee=1),this[i+N]=(r/W>>0)-ee&255;return i+m},k.prototype.writeIntBE=function(r,i,m,T){if(r=+r,i=i>>>0,!T){const pe=Math.pow(2,8*m-1);he(this,r,i,m,pe-1,-pe)}let N=m-1,W=1,ee=0;for(this[i+N]=r&255;--N>=0&&(W*=256);)r<0&&ee===0&&this[i+N+1]!==0&&(ee=1),this[i+N]=(r/W>>0)-ee&255;return i+m},k.prototype.writeInt8=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,1,127,-128),r<0&&(r=255+r+1),this[i]=r&255,i+1},k.prototype.writeInt16LE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,2,32767,-32768),this[i]=r&255,this[i+1]=r>>>8,i+2},k.prototype.writeInt16BE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,2,32767,-32768),this[i]=r>>>8,this[i+1]=r&255,i+2},k.prototype.writeInt32LE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,4,2147483647,-2147483648),this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24,i+4},k.prototype.writeInt32BE=function(r,i,m){return r=+r,i=i>>>0,m||he(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255,i+4},k.prototype.writeBigInt64LE=Le(function(r,i=0){return Pe(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),k.prototype.writeBigInt64BE=Le(function(r,i=0){return ze(this,r,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ge(s,r,i,m,T,N){if(i+m>s.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function Be(s,r,i,m,T){return r=+r,i=i>>>0,T||Ge(s,r,i,4),_.write(s,r,i,m,23,4),i+4}k.prototype.writeFloatLE=function(r,i,m){return Be(this,r,i,!0,m)},k.prototype.writeFloatBE=function(r,i,m){return Be(this,r,i,!1,m)};function Me(s,r,i,m,T){return r=+r,i=i>>>0,T||Ge(s,r,i,8),_.write(s,r,i,m,52,8),i+8}k.prototype.writeDoubleLE=function(r,i,m){return Me(this,r,i,!0,m)},k.prototype.writeDoubleBE=function(r,i,m){return Me(this,r,i,!1,m)},k.prototype.copy=function(r,i,m,T){if(!k.isBuffer(r))throw new TypeError("argument should be a Buffer");if(m||(m=0),!T&&T!==0&&(T=this.length),i>=r.length&&(i=r.length),i||(i=0),T>0&&T<m&&(T=m),T===m||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(m<0||m>=this.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("sourceEnd out of bounds");T>this.length&&(T=this.length),r.length-i<T-m&&(T=r.length-i+m);const N=T-m;return this===r&&typeof g.prototype.copyWithin=="function"?this.copyWithin(i,m,T):g.prototype.set.call(r,this.subarray(m,T),i),N},k.prototype.fill=function(r,i,m,T){if(typeof r=="string"){if(typeof i=="string"?(T=i,i=0,m=this.length):typeof m=="string"&&(T=m,m=this.length),T!==void 0&&typeof T!="string")throw new TypeError("encoding must be a string");if(typeof T=="string"&&!k.isEncoding(T))throw new TypeError("Unknown encoding: "+T);if(r.length===1){const W=r.charCodeAt(0);(T==="utf8"&&W<128||T==="latin1")&&(r=W)}}else typeof r=="number"?r=r&255:typeof r=="boolean"&&(r=Number(r));if(i<0||this.length<i||this.length<m)throw new RangeError("Out of range index");if(m<=i)return this;i=i>>>0,m=m===void 0?this.length:m>>>0,r||(r=0);let N;if(typeof r=="number")for(N=i;N<m;++N)this[N]=r;else{const W=k.isBuffer(r)?r:k.from(r,T),ee=W.length;if(ee===0)throw new TypeError('The value "'+r+'" is invalid for argument "value"');for(N=0;N<m-i;++N)this[N+i]=W[N%ee]}return this};const Re={};function tn(s,r,i){Re[s]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:r.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${s}]`,this.stack,delete this.name}get code(){return s}set code(T){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:T,writable:!0})}toString(){return`${this.name} [${s}]: ${this.message}`}}}tn("ERR_BUFFER_OUT_OF_BOUNDS",function(s){return s?`${s} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),tn("ERR_INVALID_ARG_TYPE",function(s,r){return`The "${s}" argument must be of type number. Received type ${typeof r}`},TypeError),tn("ERR_OUT_OF_RANGE",function(s,r,i){let m=`The value of "${s}" is out of range.`,T=i;return Number.isInteger(i)&&Math.abs(i)>oe(2,32)?T=wo(String(i)):typeof i=="bigint"&&(T=String(i),(i>oe(BigInt(2),BigInt(32))||i<-oe(BigInt(2),BigInt(32)))&&(T=wo(T)),T+="n"),m+=` It must be ${r}. Received ${T}`,m},RangeError);function wo(s){let r="",i=s.length;const m=s[0]==="-"?1:0;for(;i>=m+4;i-=3)r=`_${s.slice(i-3,i)}${r}`;return`${s.slice(0,i)}${r}`}function Bs(s,r,i){Ve(r,"offset"),(s[r]===void 0||s[r+i]===void 0)&&Ze(r,s.length-(i+1))}function _o(s,r,i,m,T,N){if(s>i||s<r){const W=typeof r=="bigint"?"n":"";let ee;throw r===0||r===BigInt(0)?ee=`>= 0${W} and < 2${W} ** ${(N+1)*8}${W}`:ee=`>= -(2${W} ** ${(N+1)*8-1}${W}) and < 2 ** ${(N+1)*8-1}${W}`,new Re.ERR_OUT_OF_RANGE("value",ee,s)}Bs(m,T,N)}function Ve(s,r){if(typeof s!="number")throw new Re.ERR_INVALID_ARG_TYPE(r,"number",s)}function Ze(s,r,i){throw Math.floor(s)!==s?(Ve(s,i),new Re.ERR_OUT_OF_RANGE("offset","an integer",s)):r<0?new Re.ERR_BUFFER_OUT_OF_BOUNDS:new Re.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${r}`,s)}const Ls=/[^+/0-9A-Za-z-_]/g;function Ns(s){if(s=s.split("=")[0],s=s.trim().replace(Ls,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function rn(s,r){r=r||1/0;let i;const m=s.length;let T=null;const N=[];for(let W=0;W<m;++W){if(i=s.charCodeAt(W),i>55295&&i<57344){if(!T){if(i>56319){(r-=3)>-1&&N.push(239,191,189);continue}else if(W+1===m){(r-=3)>-1&&N.push(239,191,189);continue}T=i;continue}if(i<56320){(r-=3)>-1&&N.push(239,191,189),T=i;continue}i=(T-55296<<10|i-56320)+65536}else T&&(r-=3)>-1&&N.push(239,191,189);if(T=null,i<128){if((r-=1)<0)break;N.push(i)}else if(i<2048){if((r-=2)<0)break;N.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;N.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;N.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return N}function Ds(s){const r=[];for(let i=0;i<s.length;++i)r.push(s.charCodeAt(i)&255);return r}function Fs(s,r){let i,m,T;const N=[];for(let W=0;W<s.length&&!((r-=2)<0);++W)i=s.charCodeAt(W),m=i>>8,T=i%256,N.push(T),N.push(m);return N}function So(s){return P.toByteArray(Ns(s))}function ht(s,r,i,m){let T;for(T=0;T<m&&!(T+i>=r.length||T>=s.length);++T)r[T+i]=s[T];return T}function Oe(s,r){return s instanceof r||s!=null&&s.constructor!=null&&s.constructor.name!=null&&s.constructor.name===r.name}function nn(s){return s!==s}const js=function(){const s="0123456789abcdef",r=new Array(256);for(let i=0;i<16;++i){const m=i*16;for(let T=0;T<16;++T)r[m+T]=s[i]+s[T]}return r}();function Le(s){return typeof BigInt=="undefined"?$s:s}function $s(){throw new Error("BigInt not supported")}})(e);const h=e.Buffer;n.Blob=e.Blob,n.BlobOptions=e.BlobOptions,n.Buffer=e.Buffer,n.File=e.File,n.FileOptions=e.FileOptions,n.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,n.SlowBuffer=e.SlowBuffer,n.TranscodeEncoding=e.TranscodeEncoding,n.atob=e.atob,n.btoa=e.btoa,n.constants=e.constants,n.default=h,n.isAscii=e.isAscii,n.isUtf8=e.isUtf8,n.kMaxLength=e.kMaxLength,n.kStringMaxLength=e.kStringMaxLength,n.resolveObjectURL=e.resolveObjectURL,n.transcode=e.transcode}(wt)),wt}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var gn;function yn(){return gn||(gn=1,function(n,e){var t=He(),o=t.Buffer;function l(E,a){for(var f in E)a[f]=E[f]}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?n.exports=t:(l(t,e),e.Buffer=c);function c(E,a,f){return o(E,a,f)}c.prototype=Object.create(o.prototype),l(o,c),c.from=function(E,a,f){if(typeof E=="number")throw new TypeError("Argument must not be a number");return o(E,a,f)},c.alloc=function(E,a,f){if(typeof E!="number")throw new TypeError("Argument must be a number");var u=o(E);return a!==void 0?typeof f=="string"?u.fill(a,f):u.fill(a):u.fill(0),u},c.allocUnsafe=function(E){if(typeof E!="number")throw new TypeError("Argument must be a number");return o(E)},c.allocUnsafeSlow=function(E){if(typeof E!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(E)}}(it,it.exports)),it.exports}var mn;function Bo(){if(mn)return nt.exports;mn=1;var n={env:{}},e=65536,t=4294967295;function o(){throw new Error(`Secure random number generation is not supported by this browser.
Use Chrome, Firefox or Internet Explorer 11`)}var l=yn().Buffer,c=globalThis.crypto||globalThis.msCrypto;c&&c.getRandomValues?nt.exports=E:nt.exports=o;function E(a,f){if(a>t)throw new RangeError("requested too many random bytes");var u=l.allocUnsafe(a);if(a>0)if(a>e)for(var w=0;w<a;w+=e)c.getRandomValues(u.slice(w,w+e));else c.getRandomValues(u);return typeof f=="function"?n.nextTick(function(){f(null,u)}):u}return nt.exports}var ot={exports:{}},at={exports:{}},vn;function _t(){if(vn)return at.exports;vn=1;var n=typeof Reflect=="object"?Reflect:null,e=n&&typeof n.apply=="function"?n.apply:function(R,v,g){return Function.prototype.apply.call(R,v,g)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(R){return Object.getOwnPropertyNames(R).concat(Object.getOwnPropertySymbols(R))}:t=function(R){return Object.getOwnPropertyNames(R)};function o(_){console&&console.warn&&console.warn(_)}var l=Number.isNaN||function(R){return R!==R};function c(){c.init.call(this)}at.exports=c,at.exports.once=h,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var E=10;function a(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return E},set:function(_){if(typeof _!="number"||_<0||l(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");E=_}}),c.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(R){if(typeof R!="number"||R<0||l(R))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+R+".");return this._maxListeners=R,this};function f(_){return _._maxListeners===void 0?c.defaultMaxListeners:_._maxListeners}c.prototype.getMaxListeners=function(){return f(this)},c.prototype.emit=function(R){for(var v=[],g=1;g<arguments.length;g++)v.push(arguments[g]);var B=R==="error",U=this._events;if(U!==void 0)B=B&&U.error===void 0;else if(!B)return!1;if(B){var F;if(v.length>0&&(F=v[0]),F instanceof Error)throw F;var J=new Error("Unhandled error."+(F?" ("+F.message+")":""));throw J.context=F,J}var k=U[R];if(k===void 0)return!1