@sawport/peers-caller 1.0.0-alpha.2 → 1.0.0-beta.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.
@@ -1,10 +1,10 @@
1
- (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 Ws=Object.defineProperty,zs=Object.defineProperties;var Gs=Object.getOwnPropertyDescriptors;var pt=Object.getOwnPropertySymbols;var Co=Object.prototype.hasOwnProperty,Eo=Object.prototype.propertyIsEnumerable;var oe=Math.pow,an=(Y,ae,ye)=>ae in Y?Ws(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)&&an(Y,ye,ae[ye]);if(pt)for(var ye of pt(ae))Eo.call(ae,ye)&&an(Y,ye,ae[ye]);return Y},sn=(Y,ae)=>zs(Y,Gs(ae));var ln=(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 Te=(Y,ae,ye)=>an(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),Ie=(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,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 Ie(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 Ie(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){return Ie(this,null,function*(){return this.emitWithResponse("call.start",{roomId:e})})}joinRoom(e){return Ie(this,null,function*(){return this.emitWithResponse("call.join",{roomId:e})})}leaveCall(e){return Ie(this,null,function*(){return this.emitWithResponse("call.leave",{roomId:e})})}sendOffer(e,t,o){this.emit("call.offer",{to:e,offer:t,roomId:o})}sendAnswer(e,t,o){this.emit("call.answer",{to:e,answer:t,roomId:o})}sendCandidate(e,t,o){this.emit("call.candidate",{to:e,candidate:t,roomId:o})}sendStateUpdate(e,t,o){this.emit("call.state",{to:e,state:t,roomId:o})}endCall(e,t,o){this.emit("call.end",{roomId:o,targetUserId:e})}endCallForAll(e){return Ie(this,null,function*(){this.emit("call.end",{roomId:e})})}startRecording(e,t){return Ie(this,null,function*(){return this.emitWithResponse("call.recording.start",{roomId:e,recordingId:t})})}sendRecordingChunk(e,t,o){this.emit("call.recording.chunk",{roomId:e,recordingId:t,chunk:o})}endRecording(e,t){return Ie(this,null,function*(){return this.emitWithResponse("call.recording.end",{roomId:e,recordingId:t})})}sendTranscript(e,t){this.emit("call.transcript",{roomId:e,transcript:t,timestamp:Date.now()})}checkCallStatus(e){return Ie(this,null,function*(){return this.emitWithResponse("call.status",{roomId:e})})}getIceServers(e){return Ie(this,null,function*(){return this.emitWithResponse("call.ice-servers",{roomId:e})})}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 un{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,fn;function Io(){if(fn)return mt;fn=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,dn;function Oo(){if(dn)return vt;dn=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 hn;function ko(){return hn||(hn=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,pn;function Mo(){return pn||(pn=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={},gn;function He(){return gn||(gn=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};/*!
1
+ (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 Ws=Object.defineProperty,zs=Object.defineProperties;var Gs=Object.getOwnPropertyDescriptors;var pt=Object.getOwnPropertySymbols;var Co=Object.prototype.hasOwnProperty,Eo=Object.prototype.propertyIsEnumerable;var oe=Math.pow,an=(Y,ae,ye)=>ae in Y?Ws(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)&&an(Y,ye,ae[ye]);if(pt)for(var ye of pt(ae))Eo.call(ae,ye)&&an(Y,ye,ae[ye]);return Y},sn=(Y,ae)=>zs(Y,Gs(ae));var ln=(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 Te=(Y,ae,ye)=>an(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 cn{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){return ke(this,null,function*(){return this.emitWithResponse("call.start",{roomId:e})})}joinRoom(e){return ke(this,null,function*(){return this.emitWithResponse("call.join",{roomId:e})})}leaveCall(e){return ke(this,null,function*(){return this.emitWithResponse("call.leave",{roomId:e})})}sendOffer(e,t,o){this.emit("call.offer",{to:e,offer:t,roomId:o})}sendAnswer(e,t,o){this.emit("call.answer",{to:e,answer:t,roomId:o})}sendCandidate(e,t,o){this.emit("call.candidate",{to:e,candidate:t,roomId:o})}sendStateUpdate(e,t,o){this.emit("call.state",{to:e,state:t,roomId:o})}endCall(e,t,o){this.emit("call.end",{roomId:o,targetUserId:e})}endCallForAll(e){return ke(this,null,function*(){this.emit("call.end",{roomId:e})})}startRecording(e,t){return ke(this,null,function*(){return this.emitWithResponse("call.recording.start",{roomId:e,recordingId:t})})}sendRecordingChunk(e,t,o){this.emit("call.recording.chunk",{roomId:e,recordingId:t,chunk:o})}endRecording(e,t){return ke(this,null,function*(){return this.emitWithResponse("call.recording.end",{roomId:e,recordingId:t})})}sendTranscript(e,t){this.emit("call.transcript",{roomId:e,transcript:t,timestamp:Date.now()})}checkCallStatus(e){return ke(this,null,function*(){return this.emitWithResponse("call.status",{roomId:e})})}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 un{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,fn;function Io(){if(fn)return mt;fn=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,dn;function Oo(){if(dn)return vt;dn=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 hn;function ko(){return hn||(hn=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,pn;function Mo(){return pn||(pn=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={},gn;function He(){return gn||(gn=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};/*!
2
2
  * The buffer module from node.js, for the browser.
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */(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 be(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(ke(s,B)||s&&ke(s.buffer,B)||typeof U!="undefined"&&(ke(s,U)||s&&ke(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:ve(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:ve(s.length)|0,i=J(r);for(let m=0;m<r;m+=1)i[m]=s[m]&255;return i}function be(s){if(ke(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=ve(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"||on(s.length)?J(0):de(s);if(s.type==="Buffer"&&Array.isArray(s.data))return de(s.data)}function ve(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(ke(r,g)&&(r=k.from(r,r.offset,r.byteLength)),ke(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(ke(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)||ke(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 nn(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:nn(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(ke(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,on(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(on(ee))return W;s[i+W]=ee}return W}function z(s,r,i,m){return ht(nn(r,s.length-i),s,i,m)}function V(s,r,i,m){return ht($s(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(Us(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+=qs[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 Ae(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 Ae(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 Ae(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 rn(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}`}}}rn("ERR_BUFFER_OUT_OF_BOUNDS",function(s){return s?`${s} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),rn("ERR_INVALID_ARG_TYPE",function(s,r){return`The "${s}" argument must be of type number. Received type ${typeof r}`},TypeError),rn("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 Ds(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)}Ds(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 Fs=/[^+/0-9A-Za-z-_]/g;function js(s){if(s=s.split("=")[0],s=s.trim().replace(Fs,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function nn(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 $s(s){const r=[];for(let i=0;i<s.length;++i)r.push(s.charCodeAt(i)&255);return r}function Us(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(js(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 ke(s,r){return s instanceof r||s!=null&&s.constructor!=null&&s.constructor.name!=null&&s.constructor.name===r.name}function on(s){return s!==s}const qs=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"?xs:s}function xs(){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 yn;function mn(){return yn||(yn=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 vn;function Bo(){if(vn)return nt.exports;vn=1;var n={env:{}},e=65536,t=4294967295;function o(){throw new Error(`Secure random number generation is not supported by this browser.
7
- Use Chrome, Firefox or Internet Explorer 11`)}var l=mn().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:{}},bn;function _t(){if(bn)return at.exports;bn=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;if(typeof k=="function")e(k,this,v);else for(var ne=k.length,re=y(k,ne),g=0;g<ne;++g)e(re[g],this,v);return!0};function u(_,R,v,g){var B,U,F;if(a(v),U=_._events,U===void 0?(U=_._events=Object.create(null),_._eventsCount=0):(U.newListener!==void 0&&(_.emit("newListener",R,v.listener?v.listener:v),U=_._events),F=U[R]),F===void 0)F=U[R]=v,++_._eventsCount;else if(typeof F=="function"?F=U[R]=g?[v,F]:[F,v]:g?F.unshift(v):F.push(v),B=f(_),B>0&&F.length>B&&!F.warned){F.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+F.length+" "+String(R)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=_,J.type=R,J.count=F.length,o(J)}return _}c.prototype.addListener=function(R,v){return u(this,R,v,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(R,v){return u(this,R,v,!0)};function w(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function A(_,R,v){var g={fired:!1,wrapFn:void 0,target:_,type:R,listener:v},B=w.bind(g);return B.listener=v,g.wrapFn=B,B}c.prototype.once=function(R,v){return a(v),this.on(R,A(this,R,v)),this},c.prototype.prependOnceListener=function(R,v){return a(v),this.prependListener(R,A(this,R,v)),this},c.prototype.removeListener=function(R,v){var g,B,U,F,J;if(a(v),B=this._events,B===void 0)return this;if(g=B[R],g===void 0)return this;if(g===v||g.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete B[R],B.removeListener&&this.emit("removeListener",R,g.listener||v));else if(typeof g!="function"){for(U=-1,F=g.length-1;F>=0;F--)if(g[F]===v||g[F].listener===v){J=g[F].listener,U=F;break}if(U<0)return this;U===0?g.shift():I(g,U),g.length===1&&(B[R]=g[0]),B.removeListener!==void 0&&this.emit("removeListener",R,J||v)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(R){var v,g,B;if(g=this._events,g===void 0)return this;if(g.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):g[R]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete g[R]),this;if(arguments.length===0){var U=Object.keys(g),F;for(B=0;B<U.length;++B)F=U[B],F!=="removeListener"&&this.removeAllListeners(F);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(v=g[R],typeof v=="function")this.removeListener(R,v);else if(v!==void 0)for(B=v.length-1;B>=0;B--)this.removeListener(R,v[B]);return this};function C(_,R,v){var g=_._events;if(g===void 0)return[];var B=g[R];return B===void 0?[]:typeof B=="function"?v?[B.listener||B]:[B]:v?S(B):y(B,B.length)}c.prototype.listeners=function(R){return C(this,R,!0)},c.prototype.rawListeners=function(R){return C(this,R,!1)},c.listenerCount=function(_,R){return typeof _.listenerCount=="function"?_.listenerCount(R):j.call(_,R)},c.prototype.listenerCount=j;function j(_){var R=this._events;if(R!==void 0){var v=R[_];if(typeof v=="function")return 1;if(v!==void 0)return v.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function y(_,R){for(var v=new Array(R),g=0;g<R;++g)v[g]=_[g];return v}function I(_,R){for(;R+1<_.length;R++)_[R]=_[R+1];_.pop()}function S(_){for(var R=new Array(_.length),v=0;v<R.length;++v)R[v]=_[v].listener||_[v];return R}function h(_,R){return new Promise(function(v,g){function B(F){_.removeListener(R,U),g(F)}function U(){typeof _.removeListener=="function"&&_.removeListener("error",B),v([].slice.call(arguments))}P(_,R,U,{once:!0}),R!=="error"&&b(_,B,{once:!0})})}function b(_,R,v){typeof _.on=="function"&&P(_,"error",R,v)}function P(_,R,v,g){if(typeof _.on=="function")g.once?_.once(R,v):_.on(R,v);else if(typeof _.addEventListener=="function")_.addEventListener(R,function B(U){g.once&&_.removeEventListener(R,B),v(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return at.exports}var St,wn;function _n(){return wn||(wn=1,St=_t().EventEmitter),St}var Ct={},Et={},Rt,Sn;function Cn(){return Sn||(Sn=1,Rt=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),o=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(o)!=="[object Symbol]")return!1;var l=42;e[t]=l;for(var c in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var E=Object.getOwnPropertySymbols(e);if(E.length!==1||E[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==l||a.enumerable!==!0)return!1}return!0}),Rt}var Pt,En;function st(){if(En)return Pt;En=1;var n=Cn();return Pt=function(){return n()&&!!Symbol.toStringTag},Pt}var At,Rn;function Pn(){return Rn||(Rn=1,At=Object),At}var Tt,An;function Lo(){return An||(An=1,Tt=Error),Tt}var It,Tn;function No(){return Tn||(Tn=1,It=EvalError),It}var Ot,In;function Do(){return In||(In=1,Ot=RangeError),Ot}var kt,On;function Fo(){return On||(On=1,kt=ReferenceError),kt}var Mt,kn;function Mn(){return kn||(kn=1,Mt=SyntaxError),Mt}var Bt,Bn;function Je(){return Bn||(Bn=1,Bt=TypeError),Bt}var Lt,Ln;function jo(){return Ln||(Ln=1,Lt=URIError),Lt}var Nt,Nn;function $o(){return Nn||(Nn=1,Nt=Math.abs),Nt}var Dt,Dn;function Uo(){return Dn||(Dn=1,Dt=Math.floor),Dt}var Ft,Fn;function qo(){return Fn||(Fn=1,Ft=Math.max),Ft}var jt,jn;function xo(){return jn||(jn=1,jt=Math.min),jt}var $t,$n;function Wo(){return $n||($n=1,$t=Math.pow),$t}var Ut,Un;function zo(){return Un||(Un=1,Ut=Math.round),Ut}var qt,qn;function Go(){return qn||(qn=1,qt=Number.isNaN||function(e){return e!==e}),qt}var xt,xn;function Vo(){if(xn)return xt;xn=1;var n=Go();return xt=function(t){return n(t)||t===0?t:t<0?-1:1},xt}var Wt,Wn;function Ho(){return Wn||(Wn=1,Wt=Object.getOwnPropertyDescriptor),Wt}var zt,zn;function je(){if(zn)return zt;zn=1;var n=Ho();if(n)try{n([],"length")}catch(e){n=null}return zt=n,zt}var Gt,Gn;function lt(){if(Gn)return Gt;Gn=1;var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch(e){n=!1}return Gt=n,Gt}var Vt,Vn;function Jo(){if(Vn)return Vt;Vn=1;var n=typeof Symbol!="undefined"&&Symbol,e=Cn();return Vt=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Vt}var Ht,Hn;function Jn(){return Hn||(Hn=1,Ht=typeof Reflect!="undefined"&&Reflect.getPrototypeOf||null),Ht}var Jt,Yn;function Kn(){if(Yn)return Jt;Yn=1;var n=Pn();return Jt=n.getPrototypeOf||null,Jt}var Yt,Xn;function Yo(){if(Xn)return Yt;Xn=1;var n="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,t=Math.max,o="[object Function]",l=function(f,u){for(var w=[],A=0;A<f.length;A+=1)w[A]=f[A];for(var C=0;C<u.length;C+=1)w[C+f.length]=u[C];return w},c=function(f,u){for(var w=[],A=u,C=0;A<f.length;A+=1,C+=1)w[C]=f[A];return w},E=function(a,f){for(var u="",w=0;w<a.length;w+=1)u+=a[w],w+1<a.length&&(u+=f);return u};return Yt=function(f){var u=this;if(typeof u!="function"||e.apply(u)!==o)throw new TypeError(n+u);for(var w=c(arguments,1),A,C=function(){if(this instanceof A){var h=u.apply(this,l(w,arguments));return Object(h)===h?h:this}return u.apply(f,l(w,arguments))},j=t(0,u.length-w.length),y=[],I=0;I<j;I++)y[I]="$"+I;if(A=Function("binder","return function ("+E(y,",")+"){ return binder.apply(this,arguments); }")(C),u.prototype){var S=function(){};S.prototype=u.prototype,A.prototype=new S,S.prototype=null}return A},Yt}var Kt,Zn;function Ye(){if(Zn)return Kt;Zn=1;var n=Yo();return Kt=Function.prototype.bind||n,Kt}var Xt,Qn;function Zt(){return Qn||(Qn=1,Xt=Function.prototype.call),Xt}var Qt,ei;function er(){return ei||(ei=1,Qt=Function.prototype.apply),Qt}var tr,ti;function Ko(){return ti||(ti=1,tr=typeof Reflect!="undefined"&&Reflect&&Reflect.apply),tr}var rr,ri;function ni(){if(ri)return rr;ri=1;var n=Ye(),e=er(),t=Zt(),o=Ko();return rr=o||n.call(t,e),rr}var nr,ii;function ir(){if(ii)return nr;ii=1;var n=Ye(),e=Je(),t=Zt(),o=ni();return nr=function(c){if(c.length<1||typeof c[0]!="function")throw new e("a function is required");return o(n,t,c)},nr}var or,oi;function Xo(){if(oi)return or;oi=1;var n=ir(),e=je(),t;try{t=[].__proto__===Array.prototype}catch(E){if(!E||typeof E!="object"||!("code"in E)||E.code!=="ERR_PROTO_ACCESS")throw E}var o=!!t&&e&&e(Object.prototype,"__proto__"),l=Object,c=l.getPrototypeOf;return or=o&&typeof o.get=="function"?n([o.get]):typeof c=="function"?function(a){return c(a==null?a:l(a))}:!1,or}var ar,ai;function sr(){if(ai)return ar;ai=1;var n=Jn(),e=Kn(),t=Xo();return ar=n?function(l){return n(l)}:e?function(l){if(!l||typeof l!="object"&&typeof l!="function")throw new TypeError("getProto: not an object");return e(l)}:t?function(l){return t(l)}:null,ar}var lr,si;function li(){if(si)return lr;si=1;var n=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=Ye();return lr=t.call(n,e),lr}var cr,ci;function ui(){if(ci)return cr;ci=1;var n,e=Pn(),t=Lo(),o=No(),l=Do(),c=Fo(),E=Mn(),a=Je(),f=jo(),u=$o(),w=Uo(),A=qo(),C=xo(),j=Wo(),y=zo(),I=Vo(),S=Function,h=function(D){try{return S('"use strict"; return ('+D+").constructor;")()}catch(z){}},b=je(),P=lt(),_=function(){throw new a},R=b?function(){try{return arguments.callee,_}catch(D){try{return b(arguments,"callee").get}catch(z){return _}}}():_,v=Jo()(),g=sr(),B=Kn(),U=Jn(),F=er(),J=Zt(),k={},ne=typeof Uint8Array=="undefined"||!g?n:g(Uint8Array),re={__proto__:null,"%AggregateError%":typeof AggregateError=="undefined"?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?n:ArrayBuffer,"%ArrayIteratorPrototype%":v&&g?g([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":k,"%AsyncGenerator%":k,"%AsyncGeneratorFunction%":k,"%AsyncIteratorPrototype%":k,"%Atomics%":typeof Atomics=="undefined"?n:Atomics,"%BigInt%":typeof BigInt=="undefined"?n:BigInt,"%BigInt64Array%":typeof BigInt64Array=="undefined"?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array=="undefined"?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":o,"%Float16Array%":typeof Float16Array=="undefined"?n:Float16Array,"%Float32Array%":typeof Float32Array=="undefined"?n:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?n:FinalizationRegistry,"%Function%":S,"%GeneratorFunction%":k,"%Int8Array%":typeof Int8Array=="undefined"?n:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?n:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":v&&g?g(g([][Symbol.iterator]())):n,"%JSON%":typeof JSON=="object"?JSON:n,"%Map%":typeof Map=="undefined"?n:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!v||!g?n:g(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?n:Promise,"%Proxy%":typeof Proxy=="undefined"?n:Proxy,"%RangeError%":l,"%ReferenceError%":c,"%Reflect%":typeof Reflect=="undefined"?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?n:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!v||!g?n:g(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":v&&g?g(""[Symbol.iterator]()):n,"%Symbol%":v?Symbol:n,"%SyntaxError%":E,"%ThrowTypeError%":R,"%TypedArray%":ne,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array=="undefined"?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?n:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?n:Uint32Array,"%URIError%":f,"%WeakMap%":typeof WeakMap=="undefined"?n:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?n:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?n:WeakSet,"%Function.prototype.call%":J,"%Function.prototype.apply%":F,"%Object.defineProperty%":P,"%Object.getPrototypeOf%":B,"%Math.abs%":u,"%Math.floor%":w,"%Math.max%":A,"%Math.min%":C,"%Math.pow%":j,"%Math.round%":y,"%Math.sign%":I,"%Reflect.getPrototypeOf%":U};if(g)try{null.error}catch(D){var ce=g(g(D));re["%Error.prototype%"]=ce}var fe=function D(z){var V;if(z==="%AsyncFunction%")V=h("async function () {}");else if(z==="%GeneratorFunction%")V=h("function* () {}");else if(z==="%AsyncGeneratorFunction%")V=h("async function* () {}");else if(z==="%AsyncGenerator%"){var d=D("%AsyncGeneratorFunction%");d&&(V=d.prototype)}else if(z==="%AsyncIteratorPrototype%"){var p=D("%AsyncGenerator%");p&&g&&(V=g(p.prototype))}return re[z]=V,V},Se={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},de=Ye(),be=li(),se=de.call(J,Array.prototype.concat),Ee=de.call(F,Array.prototype.splice),ve=de.call(J,String.prototype.replace),L=de.call(J,String.prototype.slice),$=de.call(J,RegExp.prototype.exec),G=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,K=/\\(\\)?/g,M=function(z){var V=L(z,0,1),d=L(z,-1);if(V==="%"&&d!=="%")throw new E("invalid intrinsic syntax, expected closing `%`");if(d==="%"&&V!=="%")throw new E("invalid intrinsic syntax, expected opening `%`");var p=[];return ve(z,G,function(x,H,X,Z){p[p.length]=X?ve(Z,K,"$1"):H||x}),p},O=function(z,V){var d=z,p;if(be(Se,d)&&(p=Se[d],d="%"+p[0]+"%"),be(re,d)){var x=re[d];if(x===k&&(x=fe(d)),typeof x=="undefined"&&!V)throw new a("intrinsic "+z+" exists, but is not available. Please file an issue!");return{alias:p,name:d,value:x}}throw new E("intrinsic "+z+" does not exist!")};return cr=function(z,V){if(typeof z!="string"||z.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof V!="boolean")throw new a('"allowMissing" argument must be a boolean');if($(/^%?[^%]*%?$/,z)===null)throw new E("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var d=M(z),p=d.length>0?d[0]:"",x=O("%"+p+"%",V),H=x.name,X=x.value,Z=!1,te=x.alias;te&&(p=te[0],Ee(d,se([0,1],te)));for(var q=1,Ce=!0;q<d.length;q+=1){var _e=d[q],le=L(_e,0,1),he=L(_e,-1);if((le==='"'||le==="'"||le==="`"||he==='"'||he==="'"||he==="`")&&le!==he)throw new E("property names with quotes must have matching quotes");if((_e==="constructor"||!Ce)&&(Z=!0),p+="."+_e,H="%"+p+"%",be(re,H))X=re[H];else if(X!=null){if(!(_e in X)){if(!V)throw new a("base intrinsic for "+z+" exists, but the property is not available.");return}if(b&&q+1>=d.length){var Ae=b(X,_e);Ce=!!Ae,Ce&&"get"in Ae&&!("originalValue"in Ae.get)?X=Ae.get:X=X[_e]}else Ce=be(X,_e),X=X[_e];Ce&&!Z&&(re[H]=X)}}return X},cr}var ur,fi;function Ke(){if(fi)return ur;fi=1;var n=ui(),e=ir(),t=e([n("%String.prototype.indexOf%")]);return ur=function(l,c){var E=n(l,!!c);return typeof E=="function"&&t(l,".prototype.")>-1?e([E]):E},ur}var fr,di;function Zo(){if(di)return fr;di=1;var n=st()(),e=Ke(),t=e("Object.prototype.toString"),o=function(a){return n&&a&&typeof a=="object"&&Symbol.toStringTag in a?!1:t(a)==="[object Arguments]"},l=function(a){return o(a)?!0:a!==null&&typeof a=="object"&&"length"in a&&typeof a.length=="number"&&a.length>=0&&t(a)!=="[object Array]"&&"callee"in a&&t(a.callee)==="[object Function]"},c=function(){return o(arguments)}();return o.isLegacyArguments=l,fr=c?o:l,fr}var dr,hi;function Qo(){if(hi)return dr;hi=1;var n=Ke(),e=st()(),t=li(),o=je(),l;if(e){var c=n("RegExp.prototype.exec"),E={},a=function(){throw E},f={toString:a,valueOf:a};typeof Symbol.toPrimitive=="symbol"&&(f[Symbol.toPrimitive]=a),l=function(C){if(!C||typeof C!="object")return!1;var j=o(C,"lastIndex"),y=j&&t(j,"value");if(!y)return!1;try{c(C,f)}catch(I){return I===E}}}else{var u=n("Object.prototype.toString"),w="[object RegExp]";l=function(C){return!C||typeof C!="object"&&typeof C!="function"?!1:u(C)===w}}return dr=l,dr}var hr,pi;function ea(){if(pi)return hr;pi=1;var n=Ke(),e=Qo(),t=n("RegExp.prototype.exec"),o=Je();return hr=function(c){if(!e(c))throw new o("`regex` must be a RegExp");return function(a){return t(c,a)!==null}},hr}var pr,gi;function ta(){if(gi)return pr;gi=1;var n=Ke(),e=ea(),t=e(/^\s*(?:function)?\*/),o=st()(),l=sr(),c=n("Object.prototype.toString"),E=n("Function.prototype.toString"),a=function(){if(!o)return!1;try{return Function("return function*() {}")()}catch(u){}},f;return pr=function(w){if(typeof w!="function")return!1;if(t(E(w)))return!0;if(!o){var A=c(w);return A==="[object GeneratorFunction]"}if(!l)return!1;if(typeof f=="undefined"){var C=a();f=C?l(C):!1}return l(w)===f},pr}var gr,yi;function ra(){if(yi)return gr;yi=1;var n=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,t,o;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{t=Object.defineProperty({},"length",{get:function(){throw o}}),o={},e(function(){throw 42},null,t)}catch(b){b!==o&&(e=null)}else e=null;var l=/^\s*class\b/,c=function(P){try{var _=n.call(P);return l.test(_)}catch(R){return!1}},E=function(P){try{return c(P)?!1:(n.call(P),!0)}catch(_){return!1}},a=Object.prototype.toString,f="[object Object]",u="[object Function]",w="[object GeneratorFunction]",A="[object HTMLAllCollection]",C="[object HTML document.all class]",j="[object HTMLCollection]",y=typeof Symbol=="function"&&!!Symbol.toStringTag,I=!(0 in[,]),S=function(){return!1};if(typeof document=="object"){var h=document.all;a.call(h)===a.call(document.all)&&(S=function(P){if((I||!P)&&(typeof P=="undefined"||typeof P=="object"))try{var _=a.call(P);return(_===A||_===C||_===j||_===f)&&P("")==null}catch(R){}return!1})}return gr=e?function(P){if(S(P))return!0;if(!P||typeof P!="function"&&typeof P!="object")return!1;try{e(P,null,t)}catch(_){if(_!==o)return!1}return!c(P)&&E(P)}:function(P){if(S(P))return!0;if(!P||typeof P!="function"&&typeof P!="object")return!1;if(y)return E(P);if(c(P))return!1;var _=a.call(P);return _!==u&&_!==w&&!/^\[object HTML/.test(_)?!1:E(P)},gr}var yr,mi;function na(){if(mi)return yr;mi=1;var n=ra(),e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,o=function(f,u,w){for(var A=0,C=f.length;A<C;A++)t.call(f,A)&&(w==null?u(f[A],A,f):u.call(w,f[A],A,f))},l=function(f,u,w){for(var A=0,C=f.length;A<C;A++)w==null?u(f.charAt(A),A,f):u.call(w,f.charAt(A),A,f)},c=function(f,u,w){for(var A in f)t.call(f,A)&&(w==null?u(f[A],A,f):u.call(w,f[A],A,f))};function E(a){return e.call(a)==="[object Array]"}return yr=function(f,u,w){if(!n(u))throw new TypeError("iterator must be a function");var A;arguments.length>=3&&(A=w),E(f)?o(f,u,A):typeof f=="string"?l(f,u,A):c(f,u,A)},yr}var mr,vi;function ia(){return vi||(vi=1,mr=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),mr}var vr,bi;function oa(){if(bi)return vr;bi=1;var n=ia(),e=globalThis;return vr=function(){for(var o=[],l=0;l<n.length;l++)typeof e[n[l]]=="function"&&(o[o.length]=n[l]);return o},vr}var br={exports:{}},wr,wi;function aa(){if(wi)return wr;wi=1;var n=lt(),e=Mn(),t=Je(),o=je();return wr=function(c,E,a){if(!c||typeof c!="object"&&typeof c!="function")throw new t("`obj` must be an object or a function`");if(typeof E!="string"&&typeof E!="symbol")throw new t("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new t("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new t("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new t("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new t("`loose`, if provided, must be a boolean");var f=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,w=arguments.length>5?arguments[5]:null,A=arguments.length>6?arguments[6]:!1,C=!!o&&o(c,E);if(n)n(c,E,{configurable:w===null&&C?C.configurable:!w,enumerable:f===null&&C?C.enumerable:!f,value:a,writable:u===null&&C?C.writable:!u});else if(A||!f&&!u&&!w)c[E]=a;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},wr}var _r,_i;function sa(){if(_i)return _r;_i=1;var n=lt(),e=function(){return!!n};return e.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],"length",{value:1}).length!==1}catch(o){return!0}},_r=e,_r}var Sr,Si;function la(){if(Si)return Sr;Si=1;var n=ui(),e=aa(),t=sa()(),o=je(),l=Je(),c=n("%Math.floor%");return Sr=function(a,f){if(typeof a!="function")throw new l("`fn` is not a function");if(typeof f!="number"||f<0||f>4294967295||c(f)!==f)throw new l("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],w=!0,A=!0;if("length"in a&&o){var C=o(a,"length");C&&!C.configurable&&(w=!1),C&&!C.writable&&(A=!1)}return(w||A||!u)&&(t?e(a,"length",f,!0,!0):e(a,"length",f)),a},Sr}var Cr,Ci;function ca(){if(Ci)return Cr;Ci=1;var n=Ye(),e=er(),t=ni();return Cr=function(){return t(n,e,arguments)},Cr}var Ei;function ua(){return Ei||(Ei=1,function(n){var e=la(),t=lt(),o=ir(),l=ca();n.exports=function(E){var a=o(arguments),f=E.length-(arguments.length-1);return e(a,1+(f>0?f:0),!0)},t?t(n.exports,"apply",{value:l}):n.exports.apply=l}(br)),br.exports}var Er,Ri;function Pi(){if(Ri)return Er;Ri=1;var n=na(),e=oa(),t=ua(),o=Ke(),l=je(),c=sr(),E=o("Object.prototype.toString"),a=st()(),f=globalThis,u=e(),w=o("String.prototype.slice"),A=o("Array.prototype.indexOf",!0)||function(S,h){for(var b=0;b<S.length;b+=1)if(S[b]===h)return b;return-1},C={__proto__:null};a&&l&&c?n(u,function(I){var S=new f[I];if(Symbol.toStringTag in S&&c){var h=c(S),b=l(h,Symbol.toStringTag);if(!b&&h){var P=c(h);b=l(P,Symbol.toStringTag)}C["$"+I]=t(b.get)}}):n(u,function(I){var S=new f[I],h=S.slice||S.set;h&&(C["$"+I]=t(h))});var j=function(S){var h=!1;return n(C,function(b,P){if(!h)try{"$"+b(S)===P&&(h=w(P,1))}catch(_){}}),h},y=function(S){var h=!1;return n(C,function(b,P){if(!h)try{b(S),h=w(P,1)}catch(_){}}),h};return Er=function(S){if(!S||typeof S!="object")return!1;if(!a){var h=w(E(S),8,-1);return A(u,h)>-1?h:h!=="Object"?!1:y(S)}return l?j(S):null},Er}var Rr,Ai;function fa(){if(Ai)return Rr;Ai=1;var n=Pi();return Rr=function(t){return!!n(t)},Rr}var Ti;function da(){return Ti||(Ti=1,function(n){var e=Zo(),t=ta(),o=Pi(),l=fa();function c(q){return q.call.bind(q)}var E=typeof BigInt!="undefined",a=typeof Symbol!="undefined",f=c(Object.prototype.toString),u=c(Number.prototype.valueOf),w=c(String.prototype.valueOf),A=c(Boolean.prototype.valueOf);if(E)var C=c(BigInt.prototype.valueOf);if(a)var j=c(Symbol.prototype.valueOf);function y(q,Ce){if(typeof q!="object")return!1;try{return Ce(q),!0}catch(_e){return!1}}n.isArgumentsObject=e,n.isGeneratorFunction=t,n.isTypedArray=l;function I(q){return typeof Promise!="undefined"&&q instanceof Promise||q!==null&&typeof q=="object"&&typeof q.then=="function"&&typeof q.catch=="function"}n.isPromise=I;function S(q){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?ArrayBuffer.isView(q):l(q)||L(q)}n.isArrayBufferView=S;function h(q){return o(q)==="Uint8Array"}n.isUint8Array=h;function b(q){return o(q)==="Uint8ClampedArray"}n.isUint8ClampedArray=b;function P(q){return o(q)==="Uint16Array"}n.isUint16Array=P;function _(q){return o(q)==="Uint32Array"}n.isUint32Array=_;function R(q){return o(q)==="Int8Array"}n.isInt8Array=R;function v(q){return o(q)==="Int16Array"}n.isInt16Array=v;function g(q){return o(q)==="Int32Array"}n.isInt32Array=g;function B(q){return o(q)==="Float32Array"}n.isFloat32Array=B;function U(q){return o(q)==="Float64Array"}n.isFloat64Array=U;function F(q){return o(q)==="BigInt64Array"}n.isBigInt64Array=F;function J(q){return o(q)==="BigUint64Array"}n.isBigUint64Array=J;function k(q){return f(q)==="[object Map]"}k.working=typeof Map!="undefined"&&k(new Map);function ne(q){return typeof Map=="undefined"?!1:k.working?k(q):q instanceof Map}n.isMap=ne;function re(q){return f(q)==="[object Set]"}re.working=typeof Set!="undefined"&&re(new Set);function ce(q){return typeof Set=="undefined"?!1:re.working?re(q):q instanceof Set}n.isSet=ce;function fe(q){return f(q)==="[object WeakMap]"}fe.working=typeof WeakMap!="undefined"&&fe(new WeakMap);function Se(q){return typeof WeakMap=="undefined"?!1:fe.working?fe(q):q instanceof WeakMap}n.isWeakMap=Se;function de(q){return f(q)==="[object WeakSet]"}de.working=typeof WeakSet!="undefined"&&de(new WeakSet);function be(q){return de(q)}n.isWeakSet=be;function se(q){return f(q)==="[object ArrayBuffer]"}se.working=typeof ArrayBuffer!="undefined"&&se(new ArrayBuffer);function Ee(q){return typeof ArrayBuffer=="undefined"?!1:se.working?se(q):q instanceof ArrayBuffer}n.isArrayBuffer=Ee;function ve(q){return f(q)==="[object DataView]"}ve.working=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined"&&ve(new DataView(new ArrayBuffer(1),0,1));function L(q){return typeof DataView=="undefined"?!1:ve.working?ve(q):q instanceof DataView}n.isDataView=L;var $=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:void 0;function G(q){return f(q)==="[object SharedArrayBuffer]"}function K(q){return typeof $=="undefined"?!1:(typeof G.working=="undefined"&&(G.working=G(new $)),G.working?G(q):q instanceof $)}n.isSharedArrayBuffer=K;function M(q){return f(q)==="[object AsyncFunction]"}n.isAsyncFunction=M;function O(q){return f(q)==="[object Map Iterator]"}n.isMapIterator=O;function D(q){return f(q)==="[object Set Iterator]"}n.isSetIterator=D;function z(q){return f(q)==="[object Generator]"}n.isGeneratorObject=z;function V(q){return f(q)==="[object WebAssembly.Module]"}n.isWebAssemblyCompiledModule=V;function d(q){return y(q,u)}n.isNumberObject=d;function p(q){return y(q,w)}n.isStringObject=p;function x(q){return y(q,A)}n.isBooleanObject=x;function H(q){return E&&y(q,C)}n.isBigIntObject=H;function X(q){return a&&y(q,j)}n.isSymbolObject=X;function Z(q){return d(q)||p(q)||x(q)||H(q)||X(q)}n.isBoxedPrimitive=Z;function te(q){return typeof Uint8Array!="undefined"&&(Ee(q)||K(q))}n.isAnyArrayBuffer=te,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(q){Object.defineProperty(n,q,{enumerable:!1,value:function(){throw new Error(q+" is not supported in userland")}})})}(Et)),Et}var Pr,Ii;function ha(){return Ii||(Ii=1,Pr=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Pr}var ct={exports:{}},Oi;function $e(){return Oi||(Oi=1,typeof Object.create=="function"?ct.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ct.exports=function(e,t){if(t){e.super_=t;var o=function(){};o.prototype=t.prototype,e.prototype=new o,e.prototype.constructor=e}}),ct.exports}var ki;function Mi(){return ki||(ki=1,function(n){var e={env:{}},t=Object.getOwnPropertyDescriptors||function($){for(var G=Object.keys($),K={},M=0;M<G.length;M++)K[G[M]]=Object.getOwnPropertyDescriptor($,G[M]);return K},o=/%[sdj%]/g;n.format=function(L){if(!v(L)){for(var $=[],G=0;G<arguments.length;G++)$.push(a(arguments[G]));return $.join(" ")}for(var G=1,K=arguments,M=K.length,O=String(L).replace(o,function(z){if(z==="%%")return"%";if(G>=M)return z;switch(z){case"%s":return String(K[G++]);case"%d":return Number(K[G++]);case"%j":try{return JSON.stringify(K[G++])}catch(V){return"[Circular]"}default:return z}}),D=K[G];G<M;D=K[++G])P(D)||!F(D)?O+=" "+D:O+=" "+a(D);return O},n.deprecate=function(L,$){if(typeof e!="undefined"&&e.noDeprecation===!0)return L;if(typeof e=="undefined")return function(){return n.deprecate(L,$).apply(this,arguments)};var G=!1;function K(){if(!G){if(e.throwDeprecation)throw new Error($);e.traceDeprecation?console.trace($):console.error($),G=!0}return L.apply(this,arguments)}return K};var l={},c=/^$/;if(e.env.NODE_DEBUG){var E=e.env.NODE_DEBUG;E=E.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),c=new RegExp("^"+E+"$","i")}n.debuglog=function(L){if(L=L.toUpperCase(),!l[L])if(c.test(L)){var $=e.pid;l[L]=function(){var G=n.format.apply(n,arguments);console.error("%s %d: %s",L,$,G)}}else l[L]=function(){};return l[L]};function a(L,$){var G={seen:[],stylize:u};return arguments.length>=3&&(G.depth=arguments[2]),arguments.length>=4&&(G.colors=arguments[3]),b($)?G.showHidden=$:$&&n._extend(G,$),B(G.showHidden)&&(G.showHidden=!1),B(G.depth)&&(G.depth=2),B(G.colors)&&(G.colors=!1),B(G.customInspect)&&(G.customInspect=!0),G.colors&&(G.stylize=f),A(G,L,G.depth)}n.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function f(L,$){var G=a.styles[$];return G?"\x1B["+a.colors[G][0]+"m"+L+"\x1B["+a.colors[G][1]+"m":L}function u(L,$){return L}function w(L){var $={};return L.forEach(function(G,K){$[G]=!0}),$}function A(L,$,G){if(L.customInspect&&$&&ne($.inspect)&&$.inspect!==n.inspect&&!($.constructor&&$.constructor.prototype===$)){var K=$.inspect(G,L);return v(K)||(K=A(L,K,G)),K}var M=C(L,$);if(M)return M;var O=Object.keys($),D=w(O);if(L.showHidden&&(O=Object.getOwnPropertyNames($)),k($)&&(O.indexOf("message")>=0||O.indexOf("description")>=0))return j($);if(O.length===0){if(ne($)){var z=$.name?": "+$.name:"";return L.stylize("[Function"+z+"]","special")}if(U($))return L.stylize(RegExp.prototype.toString.call($),"regexp");if(J($))return L.stylize(Date.prototype.toString.call($),"date");if(k($))return j($)}var V="",d=!1,p=["{","}"];if(h($)&&(d=!0,p=["[","]"]),ne($)){var x=$.name?": "+$.name:"";V=" [Function"+x+"]"}if(U($)&&(V=" "+RegExp.prototype.toString.call($)),J($)&&(V=" "+Date.prototype.toUTCString.call($)),k($)&&(V=" "+j($)),O.length===0&&(!d||$.length==0))return p[0]+V+p[1];if(G<0)return U($)?L.stylize(RegExp.prototype.toString.call($),"regexp"):L.stylize("[Object]","special");L.seen.push($);var H;return d?H=y(L,$,G,D,O):H=O.map(function(X){return I(L,$,G,D,X,d)}),L.seen.pop(),S(H,V,p)}function C(L,$){if(B($))return L.stylize("undefined","undefined");if(v($)){var G="'"+JSON.stringify($).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return L.stylize(G,"string")}if(R($))return L.stylize(""+$,"number");if(b($))return L.stylize(""+$,"boolean");if(P($))return L.stylize("null","null")}function j(L){return"["+Error.prototype.toString.call(L)+"]"}function y(L,$,G,K,M){for(var O=[],D=0,z=$.length;D<z;++D)be($,String(D))?O.push(I(L,$,G,K,String(D),!0)):O.push("");return M.forEach(function(V){V.match(/^\d+$/)||O.push(I(L,$,G,K,V,!0))}),O}function I(L,$,G,K,M,O){var D,z,V;if(V=Object.getOwnPropertyDescriptor($,M)||{value:$[M]},V.get?V.set?z=L.stylize("[Getter/Setter]","special"):z=L.stylize("[Getter]","special"):V.set&&(z=L.stylize("[Setter]","special")),be(K,M)||(D="["+M+"]"),z||(L.seen.indexOf(V.value)<0?(P(G)?z=A(L,V.value,null):z=A(L,V.value,G-1),z.indexOf(`
6
+ */(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 be(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 be(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"||on(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 nn(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:nn(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,on(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(on(ee))return W;s[i+W]=ee}return W}function z(s,r,i,m){return ht(nn(r,s.length-i),s,i,m)}function V(s,r,i,m){return ht($s(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(Us(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+=qs[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 Ae(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 Ae(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 Ae(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 rn(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}`}}}rn("ERR_BUFFER_OUT_OF_BOUNDS",function(s){return s?`${s} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),rn("ERR_INVALID_ARG_TYPE",function(s,r){return`The "${s}" argument must be of type number. Received type ${typeof r}`},TypeError),rn("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 Ds(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)}Ds(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 Fs=/[^+/0-9A-Za-z-_]/g;function js(s){if(s=s.split("=")[0],s=s.trim().replace(Fs,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function nn(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 $s(s){const r=[];for(let i=0;i<s.length;++i)r.push(s.charCodeAt(i)&255);return r}function Us(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(js(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 on(s){return s!==s}const qs=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"?xs:s}function xs(){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 yn;function mn(){return yn||(yn=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 vn;function Bo(){if(vn)return nt.exports;vn=1;var n={env:{}},e=65536,t=4294967295;function o(){throw new Error(`Secure random number generation is not supported by this browser.
7
+ Use Chrome, Firefox or Internet Explorer 11`)}var l=mn().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:{}},bn;function _t(){if(bn)return at.exports;bn=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;if(typeof k=="function")e(k,this,v);else for(var ne=k.length,re=y(k,ne),g=0;g<ne;++g)e(re[g],this,v);return!0};function u(_,R,v,g){var B,U,F;if(a(v),U=_._events,U===void 0?(U=_._events=Object.create(null),_._eventsCount=0):(U.newListener!==void 0&&(_.emit("newListener",R,v.listener?v.listener:v),U=_._events),F=U[R]),F===void 0)F=U[R]=v,++_._eventsCount;else if(typeof F=="function"?F=U[R]=g?[v,F]:[F,v]:g?F.unshift(v):F.push(v),B=f(_),B>0&&F.length>B&&!F.warned){F.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+F.length+" "+String(R)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=_,J.type=R,J.count=F.length,o(J)}return _}c.prototype.addListener=function(R,v){return u(this,R,v,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(R,v){return u(this,R,v,!0)};function w(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function A(_,R,v){var g={fired:!1,wrapFn:void 0,target:_,type:R,listener:v},B=w.bind(g);return B.listener=v,g.wrapFn=B,B}c.prototype.once=function(R,v){return a(v),this.on(R,A(this,R,v)),this},c.prototype.prependOnceListener=function(R,v){return a(v),this.prependListener(R,A(this,R,v)),this},c.prototype.removeListener=function(R,v){var g,B,U,F,J;if(a(v),B=this._events,B===void 0)return this;if(g=B[R],g===void 0)return this;if(g===v||g.listener===v)--this._eventsCount===0?this._events=Object.create(null):(delete B[R],B.removeListener&&this.emit("removeListener",R,g.listener||v));else if(typeof g!="function"){for(U=-1,F=g.length-1;F>=0;F--)if(g[F]===v||g[F].listener===v){J=g[F].listener,U=F;break}if(U<0)return this;U===0?g.shift():I(g,U),g.length===1&&(B[R]=g[0]),B.removeListener!==void 0&&this.emit("removeListener",R,J||v)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(R){var v,g,B;if(g=this._events,g===void 0)return this;if(g.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):g[R]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete g[R]),this;if(arguments.length===0){var U=Object.keys(g),F;for(B=0;B<U.length;++B)F=U[B],F!=="removeListener"&&this.removeAllListeners(F);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(v=g[R],typeof v=="function")this.removeListener(R,v);else if(v!==void 0)for(B=v.length-1;B>=0;B--)this.removeListener(R,v[B]);return this};function C(_,R,v){var g=_._events;if(g===void 0)return[];var B=g[R];return B===void 0?[]:typeof B=="function"?v?[B.listener||B]:[B]:v?S(B):y(B,B.length)}c.prototype.listeners=function(R){return C(this,R,!0)},c.prototype.rawListeners=function(R){return C(this,R,!1)},c.listenerCount=function(_,R){return typeof _.listenerCount=="function"?_.listenerCount(R):j.call(_,R)},c.prototype.listenerCount=j;function j(_){var R=this._events;if(R!==void 0){var v=R[_];if(typeof v=="function")return 1;if(v!==void 0)return v.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function y(_,R){for(var v=new Array(R),g=0;g<R;++g)v[g]=_[g];return v}function I(_,R){for(;R+1<_.length;R++)_[R]=_[R+1];_.pop()}function S(_){for(var R=new Array(_.length),v=0;v<R.length;++v)R[v]=_[v].listener||_[v];return R}function h(_,R){return new Promise(function(v,g){function B(F){_.removeListener(R,U),g(F)}function U(){typeof _.removeListener=="function"&&_.removeListener("error",B),v([].slice.call(arguments))}P(_,R,U,{once:!0}),R!=="error"&&b(_,B,{once:!0})})}function b(_,R,v){typeof _.on=="function"&&P(_,"error",R,v)}function P(_,R,v,g){if(typeof _.on=="function")g.once?_.once(R,v):_.on(R,v);else if(typeof _.addEventListener=="function")_.addEventListener(R,function B(U){g.once&&_.removeEventListener(R,B),v(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return at.exports}var St,wn;function _n(){return wn||(wn=1,St=_t().EventEmitter),St}var Ct={},Et={},Rt,Sn;function Cn(){return Sn||(Sn=1,Rt=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),o=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(o)!=="[object Symbol]")return!1;var l=42;e[t]=l;for(var c in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var E=Object.getOwnPropertySymbols(e);if(E.length!==1||E[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,t);if(a.value!==l||a.enumerable!==!0)return!1}return!0}),Rt}var Pt,En;function st(){if(En)return Pt;En=1;var n=Cn();return Pt=function(){return n()&&!!Symbol.toStringTag},Pt}var At,Rn;function Pn(){return Rn||(Rn=1,At=Object),At}var Tt,An;function Lo(){return An||(An=1,Tt=Error),Tt}var It,Tn;function No(){return Tn||(Tn=1,It=EvalError),It}var Ot,In;function Do(){return In||(In=1,Ot=RangeError),Ot}var kt,On;function Fo(){return On||(On=1,kt=ReferenceError),kt}var Mt,kn;function Mn(){return kn||(kn=1,Mt=SyntaxError),Mt}var Bt,Bn;function Je(){return Bn||(Bn=1,Bt=TypeError),Bt}var Lt,Ln;function jo(){return Ln||(Ln=1,Lt=URIError),Lt}var Nt,Nn;function $o(){return Nn||(Nn=1,Nt=Math.abs),Nt}var Dt,Dn;function Uo(){return Dn||(Dn=1,Dt=Math.floor),Dt}var Ft,Fn;function qo(){return Fn||(Fn=1,Ft=Math.max),Ft}var jt,jn;function xo(){return jn||(jn=1,jt=Math.min),jt}var $t,$n;function Wo(){return $n||($n=1,$t=Math.pow),$t}var Ut,Un;function zo(){return Un||(Un=1,Ut=Math.round),Ut}var qt,qn;function Go(){return qn||(qn=1,qt=Number.isNaN||function(e){return e!==e}),qt}var xt,xn;function Vo(){if(xn)return xt;xn=1;var n=Go();return xt=function(t){return n(t)||t===0?t:t<0?-1:1},xt}var Wt,Wn;function Ho(){return Wn||(Wn=1,Wt=Object.getOwnPropertyDescriptor),Wt}var zt,zn;function je(){if(zn)return zt;zn=1;var n=Ho();if(n)try{n([],"length")}catch(e){n=null}return zt=n,zt}var Gt,Gn;function lt(){if(Gn)return Gt;Gn=1;var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch(e){n=!1}return Gt=n,Gt}var Vt,Vn;function Jo(){if(Vn)return Vt;Vn=1;var n=typeof Symbol!="undefined"&&Symbol,e=Cn();return Vt=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Vt}var Ht,Hn;function Jn(){return Hn||(Hn=1,Ht=typeof Reflect!="undefined"&&Reflect.getPrototypeOf||null),Ht}var Jt,Yn;function Kn(){if(Yn)return Jt;Yn=1;var n=Pn();return Jt=n.getPrototypeOf||null,Jt}var Yt,Xn;function Yo(){if(Xn)return Yt;Xn=1;var n="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,t=Math.max,o="[object Function]",l=function(f,u){for(var w=[],A=0;A<f.length;A+=1)w[A]=f[A];for(var C=0;C<u.length;C+=1)w[C+f.length]=u[C];return w},c=function(f,u){for(var w=[],A=u,C=0;A<f.length;A+=1,C+=1)w[C]=f[A];return w},E=function(a,f){for(var u="",w=0;w<a.length;w+=1)u+=a[w],w+1<a.length&&(u+=f);return u};return Yt=function(f){var u=this;if(typeof u!="function"||e.apply(u)!==o)throw new TypeError(n+u);for(var w=c(arguments,1),A,C=function(){if(this instanceof A){var h=u.apply(this,l(w,arguments));return Object(h)===h?h:this}return u.apply(f,l(w,arguments))},j=t(0,u.length-w.length),y=[],I=0;I<j;I++)y[I]="$"+I;if(A=Function("binder","return function ("+E(y,",")+"){ return binder.apply(this,arguments); }")(C),u.prototype){var S=function(){};S.prototype=u.prototype,A.prototype=new S,S.prototype=null}return A},Yt}var Kt,Zn;function Ye(){if(Zn)return Kt;Zn=1;var n=Yo();return Kt=Function.prototype.bind||n,Kt}var Xt,Qn;function Zt(){return Qn||(Qn=1,Xt=Function.prototype.call),Xt}var Qt,ei;function er(){return ei||(ei=1,Qt=Function.prototype.apply),Qt}var tr,ti;function Ko(){return ti||(ti=1,tr=typeof Reflect!="undefined"&&Reflect&&Reflect.apply),tr}var rr,ri;function ni(){if(ri)return rr;ri=1;var n=Ye(),e=er(),t=Zt(),o=Ko();return rr=o||n.call(t,e),rr}var nr,ii;function ir(){if(ii)return nr;ii=1;var n=Ye(),e=Je(),t=Zt(),o=ni();return nr=function(c){if(c.length<1||typeof c[0]!="function")throw new e("a function is required");return o(n,t,c)},nr}var or,oi;function Xo(){if(oi)return or;oi=1;var n=ir(),e=je(),t;try{t=[].__proto__===Array.prototype}catch(E){if(!E||typeof E!="object"||!("code"in E)||E.code!=="ERR_PROTO_ACCESS")throw E}var o=!!t&&e&&e(Object.prototype,"__proto__"),l=Object,c=l.getPrototypeOf;return or=o&&typeof o.get=="function"?n([o.get]):typeof c=="function"?function(a){return c(a==null?a:l(a))}:!1,or}var ar,ai;function sr(){if(ai)return ar;ai=1;var n=Jn(),e=Kn(),t=Xo();return ar=n?function(l){return n(l)}:e?function(l){if(!l||typeof l!="object"&&typeof l!="function")throw new TypeError("getProto: not an object");return e(l)}:t?function(l){return t(l)}:null,ar}var lr,si;function li(){if(si)return lr;si=1;var n=Function.prototype.call,e=Object.prototype.hasOwnProperty,t=Ye();return lr=t.call(n,e),lr}var cr,ci;function ui(){if(ci)return cr;ci=1;var n,e=Pn(),t=Lo(),o=No(),l=Do(),c=Fo(),E=Mn(),a=Je(),f=jo(),u=$o(),w=Uo(),A=qo(),C=xo(),j=Wo(),y=zo(),I=Vo(),S=Function,h=function(D){try{return S('"use strict"; return ('+D+").constructor;")()}catch(z){}},b=je(),P=lt(),_=function(){throw new a},R=b?function(){try{return arguments.callee,_}catch(D){try{return b(arguments,"callee").get}catch(z){return _}}}():_,v=Jo()(),g=sr(),B=Kn(),U=Jn(),F=er(),J=Zt(),k={},ne=typeof Uint8Array=="undefined"||!g?n:g(Uint8Array),re={__proto__:null,"%AggregateError%":typeof AggregateError=="undefined"?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?n:ArrayBuffer,"%ArrayIteratorPrototype%":v&&g?g([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":k,"%AsyncGenerator%":k,"%AsyncGeneratorFunction%":k,"%AsyncIteratorPrototype%":k,"%Atomics%":typeof Atomics=="undefined"?n:Atomics,"%BigInt%":typeof BigInt=="undefined"?n:BigInt,"%BigInt64Array%":typeof BigInt64Array=="undefined"?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array=="undefined"?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":t,"%eval%":eval,"%EvalError%":o,"%Float16Array%":typeof Float16Array=="undefined"?n:Float16Array,"%Float32Array%":typeof Float32Array=="undefined"?n:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?n:FinalizationRegistry,"%Function%":S,"%GeneratorFunction%":k,"%Int8Array%":typeof Int8Array=="undefined"?n:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?n:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":v&&g?g(g([][Symbol.iterator]())):n,"%JSON%":typeof JSON=="object"?JSON:n,"%Map%":typeof Map=="undefined"?n:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!v||!g?n:g(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?n:Promise,"%Proxy%":typeof Proxy=="undefined"?n:Proxy,"%RangeError%":l,"%ReferenceError%":c,"%Reflect%":typeof Reflect=="undefined"?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?n:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!v||!g?n:g(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":v&&g?g(""[Symbol.iterator]()):n,"%Symbol%":v?Symbol:n,"%SyntaxError%":E,"%ThrowTypeError%":R,"%TypedArray%":ne,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array=="undefined"?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?n:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?n:Uint32Array,"%URIError%":f,"%WeakMap%":typeof WeakMap=="undefined"?n:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?n:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?n:WeakSet,"%Function.prototype.call%":J,"%Function.prototype.apply%":F,"%Object.defineProperty%":P,"%Object.getPrototypeOf%":B,"%Math.abs%":u,"%Math.floor%":w,"%Math.max%":A,"%Math.min%":C,"%Math.pow%":j,"%Math.round%":y,"%Math.sign%":I,"%Reflect.getPrototypeOf%":U};if(g)try{null.error}catch(D){var ce=g(g(D));re["%Error.prototype%"]=ce}var fe=function D(z){var V;if(z==="%AsyncFunction%")V=h("async function () {}");else if(z==="%GeneratorFunction%")V=h("function* () {}");else if(z==="%AsyncGeneratorFunction%")V=h("async function* () {}");else if(z==="%AsyncGenerator%"){var d=D("%AsyncGeneratorFunction%");d&&(V=d.prototype)}else if(z==="%AsyncIteratorPrototype%"){var p=D("%AsyncGenerator%");p&&g&&(V=g(p.prototype))}return re[z]=V,V},Se={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},de=Ye(),be=li(),se=de.call(J,Array.prototype.concat),Ee=de.call(F,Array.prototype.splice),me=de.call(J,String.prototype.replace),L=de.call(J,String.prototype.slice),$=de.call(J,RegExp.prototype.exec),G=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,K=/\\(\\)?/g,M=function(z){var V=L(z,0,1),d=L(z,-1);if(V==="%"&&d!=="%")throw new E("invalid intrinsic syntax, expected closing `%`");if(d==="%"&&V!=="%")throw new E("invalid intrinsic syntax, expected opening `%`");var p=[];return me(z,G,function(x,H,X,Z){p[p.length]=X?me(Z,K,"$1"):H||x}),p},O=function(z,V){var d=z,p;if(be(Se,d)&&(p=Se[d],d="%"+p[0]+"%"),be(re,d)){var x=re[d];if(x===k&&(x=fe(d)),typeof x=="undefined"&&!V)throw new a("intrinsic "+z+" exists, but is not available. Please file an issue!");return{alias:p,name:d,value:x}}throw new E("intrinsic "+z+" does not exist!")};return cr=function(z,V){if(typeof z!="string"||z.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof V!="boolean")throw new a('"allowMissing" argument must be a boolean');if($(/^%?[^%]*%?$/,z)===null)throw new E("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var d=M(z),p=d.length>0?d[0]:"",x=O("%"+p+"%",V),H=x.name,X=x.value,Z=!1,te=x.alias;te&&(p=te[0],Ee(d,se([0,1],te)));for(var q=1,Ce=!0;q<d.length;q+=1){var _e=d[q],le=L(_e,0,1),he=L(_e,-1);if((le==='"'||le==="'"||le==="`"||he==='"'||he==="'"||he==="`")&&le!==he)throw new E("property names with quotes must have matching quotes");if((_e==="constructor"||!Ce)&&(Z=!0),p+="."+_e,H="%"+p+"%",be(re,H))X=re[H];else if(X!=null){if(!(_e in X)){if(!V)throw new a("base intrinsic for "+z+" exists, but the property is not available.");return}if(b&&q+1>=d.length){var Ae=b(X,_e);Ce=!!Ae,Ce&&"get"in Ae&&!("originalValue"in Ae.get)?X=Ae.get:X=X[_e]}else Ce=be(X,_e),X=X[_e];Ce&&!Z&&(re[H]=X)}}return X},cr}var ur,fi;function Ke(){if(fi)return ur;fi=1;var n=ui(),e=ir(),t=e([n("%String.prototype.indexOf%")]);return ur=function(l,c){var E=n(l,!!c);return typeof E=="function"&&t(l,".prototype.")>-1?e([E]):E},ur}var fr,di;function Zo(){if(di)return fr;di=1;var n=st()(),e=Ke(),t=e("Object.prototype.toString"),o=function(a){return n&&a&&typeof a=="object"&&Symbol.toStringTag in a?!1:t(a)==="[object Arguments]"},l=function(a){return o(a)?!0:a!==null&&typeof a=="object"&&"length"in a&&typeof a.length=="number"&&a.length>=0&&t(a)!=="[object Array]"&&"callee"in a&&t(a.callee)==="[object Function]"},c=function(){return o(arguments)}();return o.isLegacyArguments=l,fr=c?o:l,fr}var dr,hi;function Qo(){if(hi)return dr;hi=1;var n=Ke(),e=st()(),t=li(),o=je(),l;if(e){var c=n("RegExp.prototype.exec"),E={},a=function(){throw E},f={toString:a,valueOf:a};typeof Symbol.toPrimitive=="symbol"&&(f[Symbol.toPrimitive]=a),l=function(C){if(!C||typeof C!="object")return!1;var j=o(C,"lastIndex"),y=j&&t(j,"value");if(!y)return!1;try{c(C,f)}catch(I){return I===E}}}else{var u=n("Object.prototype.toString"),w="[object RegExp]";l=function(C){return!C||typeof C!="object"&&typeof C!="function"?!1:u(C)===w}}return dr=l,dr}var hr,pi;function ea(){if(pi)return hr;pi=1;var n=Ke(),e=Qo(),t=n("RegExp.prototype.exec"),o=Je();return hr=function(c){if(!e(c))throw new o("`regex` must be a RegExp");return function(a){return t(c,a)!==null}},hr}var pr,gi;function ta(){if(gi)return pr;gi=1;var n=Ke(),e=ea(),t=e(/^\s*(?:function)?\*/),o=st()(),l=sr(),c=n("Object.prototype.toString"),E=n("Function.prototype.toString"),a=function(){if(!o)return!1;try{return Function("return function*() {}")()}catch(u){}},f;return pr=function(w){if(typeof w!="function")return!1;if(t(E(w)))return!0;if(!o){var A=c(w);return A==="[object GeneratorFunction]"}if(!l)return!1;if(typeof f=="undefined"){var C=a();f=C?l(C):!1}return l(w)===f},pr}var gr,yi;function ra(){if(yi)return gr;yi=1;var n=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,t,o;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{t=Object.defineProperty({},"length",{get:function(){throw o}}),o={},e(function(){throw 42},null,t)}catch(b){b!==o&&(e=null)}else e=null;var l=/^\s*class\b/,c=function(P){try{var _=n.call(P);return l.test(_)}catch(R){return!1}},E=function(P){try{return c(P)?!1:(n.call(P),!0)}catch(_){return!1}},a=Object.prototype.toString,f="[object Object]",u="[object Function]",w="[object GeneratorFunction]",A="[object HTMLAllCollection]",C="[object HTML document.all class]",j="[object HTMLCollection]",y=typeof Symbol=="function"&&!!Symbol.toStringTag,I=!(0 in[,]),S=function(){return!1};if(typeof document=="object"){var h=document.all;a.call(h)===a.call(document.all)&&(S=function(P){if((I||!P)&&(typeof P=="undefined"||typeof P=="object"))try{var _=a.call(P);return(_===A||_===C||_===j||_===f)&&P("")==null}catch(R){}return!1})}return gr=e?function(P){if(S(P))return!0;if(!P||typeof P!="function"&&typeof P!="object")return!1;try{e(P,null,t)}catch(_){if(_!==o)return!1}return!c(P)&&E(P)}:function(P){if(S(P))return!0;if(!P||typeof P!="function"&&typeof P!="object")return!1;if(y)return E(P);if(c(P))return!1;var _=a.call(P);return _!==u&&_!==w&&!/^\[object HTML/.test(_)?!1:E(P)},gr}var yr,mi;function na(){if(mi)return yr;mi=1;var n=ra(),e=Object.prototype.toString,t=Object.prototype.hasOwnProperty,o=function(f,u,w){for(var A=0,C=f.length;A<C;A++)t.call(f,A)&&(w==null?u(f[A],A,f):u.call(w,f[A],A,f))},l=function(f,u,w){for(var A=0,C=f.length;A<C;A++)w==null?u(f.charAt(A),A,f):u.call(w,f.charAt(A),A,f)},c=function(f,u,w){for(var A in f)t.call(f,A)&&(w==null?u(f[A],A,f):u.call(w,f[A],A,f))};function E(a){return e.call(a)==="[object Array]"}return yr=function(f,u,w){if(!n(u))throw new TypeError("iterator must be a function");var A;arguments.length>=3&&(A=w),E(f)?o(f,u,A):typeof f=="string"?l(f,u,A):c(f,u,A)},yr}var mr,vi;function ia(){return vi||(vi=1,mr=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),mr}var vr,bi;function oa(){if(bi)return vr;bi=1;var n=ia(),e=globalThis;return vr=function(){for(var o=[],l=0;l<n.length;l++)typeof e[n[l]]=="function"&&(o[o.length]=n[l]);return o},vr}var br={exports:{}},wr,wi;function aa(){if(wi)return wr;wi=1;var n=lt(),e=Mn(),t=Je(),o=je();return wr=function(c,E,a){if(!c||typeof c!="object"&&typeof c!="function")throw new t("`obj` must be an object or a function`");if(typeof E!="string"&&typeof E!="symbol")throw new t("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new t("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new t("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new t("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new t("`loose`, if provided, must be a boolean");var f=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,w=arguments.length>5?arguments[5]:null,A=arguments.length>6?arguments[6]:!1,C=!!o&&o(c,E);if(n)n(c,E,{configurable:w===null&&C?C.configurable:!w,enumerable:f===null&&C?C.enumerable:!f,value:a,writable:u===null&&C?C.writable:!u});else if(A||!f&&!u&&!w)c[E]=a;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},wr}var _r,_i;function sa(){if(_i)return _r;_i=1;var n=lt(),e=function(){return!!n};return e.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],"length",{value:1}).length!==1}catch(o){return!0}},_r=e,_r}var Sr,Si;function la(){if(Si)return Sr;Si=1;var n=ui(),e=aa(),t=sa()(),o=je(),l=Je(),c=n("%Math.floor%");return Sr=function(a,f){if(typeof a!="function")throw new l("`fn` is not a function");if(typeof f!="number"||f<0||f>4294967295||c(f)!==f)throw new l("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],w=!0,A=!0;if("length"in a&&o){var C=o(a,"length");C&&!C.configurable&&(w=!1),C&&!C.writable&&(A=!1)}return(w||A||!u)&&(t?e(a,"length",f,!0,!0):e(a,"length",f)),a},Sr}var Cr,Ci;function ca(){if(Ci)return Cr;Ci=1;var n=Ye(),e=er(),t=ni();return Cr=function(){return t(n,e,arguments)},Cr}var Ei;function ua(){return Ei||(Ei=1,function(n){var e=la(),t=lt(),o=ir(),l=ca();n.exports=function(E){var a=o(arguments),f=E.length-(arguments.length-1);return e(a,1+(f>0?f:0),!0)},t?t(n.exports,"apply",{value:l}):n.exports.apply=l}(br)),br.exports}var Er,Ri;function Pi(){if(Ri)return Er;Ri=1;var n=na(),e=oa(),t=ua(),o=Ke(),l=je(),c=sr(),E=o("Object.prototype.toString"),a=st()(),f=globalThis,u=e(),w=o("String.prototype.slice"),A=o("Array.prototype.indexOf",!0)||function(S,h){for(var b=0;b<S.length;b+=1)if(S[b]===h)return b;return-1},C={__proto__:null};a&&l&&c?n(u,function(I){var S=new f[I];if(Symbol.toStringTag in S&&c){var h=c(S),b=l(h,Symbol.toStringTag);if(!b&&h){var P=c(h);b=l(P,Symbol.toStringTag)}C["$"+I]=t(b.get)}}):n(u,function(I){var S=new f[I],h=S.slice||S.set;h&&(C["$"+I]=t(h))});var j=function(S){var h=!1;return n(C,function(b,P){if(!h)try{"$"+b(S)===P&&(h=w(P,1))}catch(_){}}),h},y=function(S){var h=!1;return n(C,function(b,P){if(!h)try{b(S),h=w(P,1)}catch(_){}}),h};return Er=function(S){if(!S||typeof S!="object")return!1;if(!a){var h=w(E(S),8,-1);return A(u,h)>-1?h:h!=="Object"?!1:y(S)}return l?j(S):null},Er}var Rr,Ai;function fa(){if(Ai)return Rr;Ai=1;var n=Pi();return Rr=function(t){return!!n(t)},Rr}var Ti;function da(){return Ti||(Ti=1,function(n){var e=Zo(),t=ta(),o=Pi(),l=fa();function c(q){return q.call.bind(q)}var E=typeof BigInt!="undefined",a=typeof Symbol!="undefined",f=c(Object.prototype.toString),u=c(Number.prototype.valueOf),w=c(String.prototype.valueOf),A=c(Boolean.prototype.valueOf);if(E)var C=c(BigInt.prototype.valueOf);if(a)var j=c(Symbol.prototype.valueOf);function y(q,Ce){if(typeof q!="object")return!1;try{return Ce(q),!0}catch(_e){return!1}}n.isArgumentsObject=e,n.isGeneratorFunction=t,n.isTypedArray=l;function I(q){return typeof Promise!="undefined"&&q instanceof Promise||q!==null&&typeof q=="object"&&typeof q.then=="function"&&typeof q.catch=="function"}n.isPromise=I;function S(q){return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?ArrayBuffer.isView(q):l(q)||L(q)}n.isArrayBufferView=S;function h(q){return o(q)==="Uint8Array"}n.isUint8Array=h;function b(q){return o(q)==="Uint8ClampedArray"}n.isUint8ClampedArray=b;function P(q){return o(q)==="Uint16Array"}n.isUint16Array=P;function _(q){return o(q)==="Uint32Array"}n.isUint32Array=_;function R(q){return o(q)==="Int8Array"}n.isInt8Array=R;function v(q){return o(q)==="Int16Array"}n.isInt16Array=v;function g(q){return o(q)==="Int32Array"}n.isInt32Array=g;function B(q){return o(q)==="Float32Array"}n.isFloat32Array=B;function U(q){return o(q)==="Float64Array"}n.isFloat64Array=U;function F(q){return o(q)==="BigInt64Array"}n.isBigInt64Array=F;function J(q){return o(q)==="BigUint64Array"}n.isBigUint64Array=J;function k(q){return f(q)==="[object Map]"}k.working=typeof Map!="undefined"&&k(new Map);function ne(q){return typeof Map=="undefined"?!1:k.working?k(q):q instanceof Map}n.isMap=ne;function re(q){return f(q)==="[object Set]"}re.working=typeof Set!="undefined"&&re(new Set);function ce(q){return typeof Set=="undefined"?!1:re.working?re(q):q instanceof Set}n.isSet=ce;function fe(q){return f(q)==="[object WeakMap]"}fe.working=typeof WeakMap!="undefined"&&fe(new WeakMap);function Se(q){return typeof WeakMap=="undefined"?!1:fe.working?fe(q):q instanceof WeakMap}n.isWeakMap=Se;function de(q){return f(q)==="[object WeakSet]"}de.working=typeof WeakSet!="undefined"&&de(new WeakSet);function be(q){return de(q)}n.isWeakSet=be;function se(q){return f(q)==="[object ArrayBuffer]"}se.working=typeof ArrayBuffer!="undefined"&&se(new ArrayBuffer);function Ee(q){return typeof ArrayBuffer=="undefined"?!1:se.working?se(q):q instanceof ArrayBuffer}n.isArrayBuffer=Ee;function me(q){return f(q)==="[object DataView]"}me.working=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined"&&me(new DataView(new ArrayBuffer(1),0,1));function L(q){return typeof DataView=="undefined"?!1:me.working?me(q):q instanceof DataView}n.isDataView=L;var $=typeof SharedArrayBuffer!="undefined"?SharedArrayBuffer:void 0;function G(q){return f(q)==="[object SharedArrayBuffer]"}function K(q){return typeof $=="undefined"?!1:(typeof G.working=="undefined"&&(G.working=G(new $)),G.working?G(q):q instanceof $)}n.isSharedArrayBuffer=K;function M(q){return f(q)==="[object AsyncFunction]"}n.isAsyncFunction=M;function O(q){return f(q)==="[object Map Iterator]"}n.isMapIterator=O;function D(q){return f(q)==="[object Set Iterator]"}n.isSetIterator=D;function z(q){return f(q)==="[object Generator]"}n.isGeneratorObject=z;function V(q){return f(q)==="[object WebAssembly.Module]"}n.isWebAssemblyCompiledModule=V;function d(q){return y(q,u)}n.isNumberObject=d;function p(q){return y(q,w)}n.isStringObject=p;function x(q){return y(q,A)}n.isBooleanObject=x;function H(q){return E&&y(q,C)}n.isBigIntObject=H;function X(q){return a&&y(q,j)}n.isSymbolObject=X;function Z(q){return d(q)||p(q)||x(q)||H(q)||X(q)}n.isBoxedPrimitive=Z;function te(q){return typeof Uint8Array!="undefined"&&(Ee(q)||K(q))}n.isAnyArrayBuffer=te,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(q){Object.defineProperty(n,q,{enumerable:!1,value:function(){throw new Error(q+" is not supported in userland")}})})}(Et)),Et}var Pr,Ii;function ha(){return Ii||(Ii=1,Pr=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Pr}var ct={exports:{}},Oi;function $e(){return Oi||(Oi=1,typeof Object.create=="function"?ct.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ct.exports=function(e,t){if(t){e.super_=t;var o=function(){};o.prototype=t.prototype,e.prototype=new o,e.prototype.constructor=e}}),ct.exports}var ki;function Mi(){return ki||(ki=1,function(n){var e={env:{}},t=Object.getOwnPropertyDescriptors||function($){for(var G=Object.keys($),K={},M=0;M<G.length;M++)K[G[M]]=Object.getOwnPropertyDescriptor($,G[M]);return K},o=/%[sdj%]/g;n.format=function(L){if(!v(L)){for(var $=[],G=0;G<arguments.length;G++)$.push(a(arguments[G]));return $.join(" ")}for(var G=1,K=arguments,M=K.length,O=String(L).replace(o,function(z){if(z==="%%")return"%";if(G>=M)return z;switch(z){case"%s":return String(K[G++]);case"%d":return Number(K[G++]);case"%j":try{return JSON.stringify(K[G++])}catch(V){return"[Circular]"}default:return z}}),D=K[G];G<M;D=K[++G])P(D)||!F(D)?O+=" "+D:O+=" "+a(D);return O},n.deprecate=function(L,$){if(typeof e!="undefined"&&e.noDeprecation===!0)return L;if(typeof e=="undefined")return function(){return n.deprecate(L,$).apply(this,arguments)};var G=!1;function K(){if(!G){if(e.throwDeprecation)throw new Error($);e.traceDeprecation?console.trace($):console.error($),G=!0}return L.apply(this,arguments)}return K};var l={},c=/^$/;if(e.env.NODE_DEBUG){var E=e.env.NODE_DEBUG;E=E.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),c=new RegExp("^"+E+"$","i")}n.debuglog=function(L){if(L=L.toUpperCase(),!l[L])if(c.test(L)){var $=e.pid;l[L]=function(){var G=n.format.apply(n,arguments);console.error("%s %d: %s",L,$,G)}}else l[L]=function(){};return l[L]};function a(L,$){var G={seen:[],stylize:u};return arguments.length>=3&&(G.depth=arguments[2]),arguments.length>=4&&(G.colors=arguments[3]),b($)?G.showHidden=$:$&&n._extend(G,$),B(G.showHidden)&&(G.showHidden=!1),B(G.depth)&&(G.depth=2),B(G.colors)&&(G.colors=!1),B(G.customInspect)&&(G.customInspect=!0),G.colors&&(G.stylize=f),A(G,L,G.depth)}n.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function f(L,$){var G=a.styles[$];return G?"\x1B["+a.colors[G][0]+"m"+L+"\x1B["+a.colors[G][1]+"m":L}function u(L,$){return L}function w(L){var $={};return L.forEach(function(G,K){$[G]=!0}),$}function A(L,$,G){if(L.customInspect&&$&&ne($.inspect)&&$.inspect!==n.inspect&&!($.constructor&&$.constructor.prototype===$)){var K=$.inspect(G,L);return v(K)||(K=A(L,K,G)),K}var M=C(L,$);if(M)return M;var O=Object.keys($),D=w(O);if(L.showHidden&&(O=Object.getOwnPropertyNames($)),k($)&&(O.indexOf("message")>=0||O.indexOf("description")>=0))return j($);if(O.length===0){if(ne($)){var z=$.name?": "+$.name:"";return L.stylize("[Function"+z+"]","special")}if(U($))return L.stylize(RegExp.prototype.toString.call($),"regexp");if(J($))return L.stylize(Date.prototype.toString.call($),"date");if(k($))return j($)}var V="",d=!1,p=["{","}"];if(h($)&&(d=!0,p=["[","]"]),ne($)){var x=$.name?": "+$.name:"";V=" [Function"+x+"]"}if(U($)&&(V=" "+RegExp.prototype.toString.call($)),J($)&&(V=" "+Date.prototype.toUTCString.call($)),k($)&&(V=" "+j($)),O.length===0&&(!d||$.length==0))return p[0]+V+p[1];if(G<0)return U($)?L.stylize(RegExp.prototype.toString.call($),"regexp"):L.stylize("[Object]","special");L.seen.push($);var H;return d?H=y(L,$,G,D,O):H=O.map(function(X){return I(L,$,G,D,X,d)}),L.seen.pop(),S(H,V,p)}function C(L,$){if(B($))return L.stylize("undefined","undefined");if(v($)){var G="'"+JSON.stringify($).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return L.stylize(G,"string")}if(R($))return L.stylize(""+$,"number");if(b($))return L.stylize(""+$,"boolean");if(P($))return L.stylize("null","null")}function j(L){return"["+Error.prototype.toString.call(L)+"]"}function y(L,$,G,K,M){for(var O=[],D=0,z=$.length;D<z;++D)be($,String(D))?O.push(I(L,$,G,K,String(D),!0)):O.push("");return M.forEach(function(V){V.match(/^\d+$/)||O.push(I(L,$,G,K,V,!0))}),O}function I(L,$,G,K,M,O){var D,z,V;if(V=Object.getOwnPropertyDescriptor($,M)||{value:$[M]},V.get?V.set?z=L.stylize("[Getter/Setter]","special"):z=L.stylize("[Getter]","special"):V.set&&(z=L.stylize("[Setter]","special")),be(K,M)||(D="["+M+"]"),z||(L.seen.indexOf(V.value)<0?(P(G)?z=A(L,V.value,null):z=A(L,V.value,G-1),z.indexOf(`
8
8
  `)>-1&&(O?z=z.split(`
9
9
  `).map(function(d){return" "+d}).join(`
10
10
  `).slice(2):z=`
@@ -13,10 +13,10 @@ Use Chrome, Firefox or Internet Explorer 11`)}var l=mn().Buffer,c=globalThis.cry
13
13
  `))):z=L.stylize("[Circular]","special")),B(D)){if(O&&M.match(/^\d+$/))return z;D=JSON.stringify(""+M),D.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(D=D.slice(1,-1),D=L.stylize(D,"name")):(D=D.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),D=L.stylize(D,"string"))}return D+": "+z}function S(L,$,G){var K=L.reduce(function(M,O){return O.indexOf(`
14
14
  `)>=0,M+O.replace(/\u001b\[\d\d?m/g,"").length+1},0);return K>60?G[0]+($===""?"":$+`
15
15
  `)+" "+L.join(`,
16
- `)+" "+G[1]:G[0]+$+" "+L.join(", ")+" "+G[1]}n.types=da();function h(L){return Array.isArray(L)}n.isArray=h;function b(L){return typeof L=="boolean"}n.isBoolean=b;function P(L){return L===null}n.isNull=P;function _(L){return L==null}n.isNullOrUndefined=_;function R(L){return typeof L=="number"}n.isNumber=R;function v(L){return typeof L=="string"}n.isString=v;function g(L){return typeof L=="symbol"}n.isSymbol=g;function B(L){return L===void 0}n.isUndefined=B;function U(L){return F(L)&&ce(L)==="[object RegExp]"}n.isRegExp=U,n.types.isRegExp=U;function F(L){return typeof L=="object"&&L!==null}n.isObject=F;function J(L){return F(L)&&ce(L)==="[object Date]"}n.isDate=J,n.types.isDate=J;function k(L){return F(L)&&(ce(L)==="[object Error]"||L instanceof Error)}n.isError=k,n.types.isNativeError=k;function ne(L){return typeof L=="function"}n.isFunction=ne;function re(L){return L===null||typeof L=="boolean"||typeof L=="number"||typeof L=="string"||typeof L=="symbol"||typeof L=="undefined"}n.isPrimitive=re,n.isBuffer=ha();function ce(L){return Object.prototype.toString.call(L)}function fe(L){return L<10?"0"+L.toString(10):L.toString(10)}var Se=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(){var L=new Date,$=[fe(L.getHours()),fe(L.getMinutes()),fe(L.getSeconds())].join(":");return[L.getDate(),Se[L.getMonth()],$].join(" ")}n.log=function(){console.log("%s - %s",de(),n.format.apply(n,arguments))},n.inherits=$e(),n._extend=function(L,$){if(!$||!F($))return L;for(var G=Object.keys($),K=G.length;K--;)L[G[K]]=$[G[K]];return L};function be(L,$){return Object.prototype.hasOwnProperty.call(L,$)}var se=typeof Symbol!="undefined"?Symbol("util.promisify.custom"):void 0;n.promisify=function($){if(typeof $!="function")throw new TypeError('The "original" argument must be of type Function');if(se&&$[se]){var G=$[se];if(typeof G!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(G,se,{value:G,enumerable:!1,writable:!1,configurable:!0}),G}function G(){for(var K,M,O=new Promise(function(V,d){K=V,M=d}),D=[],z=0;z<arguments.length;z++)D.push(arguments[z]);D.push(function(V,d){V?M(V):K(d)});try{$.apply(this,D)}catch(V){M(V)}return O}return Object.setPrototypeOf(G,Object.getPrototypeOf($)),se&&Object.defineProperty(G,se,{value:G,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(G,t($))},n.promisify.custom=se;function Ee(L,$){if(!L){var G=new Error("Promise was rejected with a falsy value");G.reason=L,L=G}return $(L)}function ve(L){if(typeof L!="function")throw new TypeError('The "original" argument must be of type Function');function $(){for(var G=[],K=0;K<arguments.length;K++)G.push(arguments[K]);var M=G.pop();if(typeof M!="function")throw new TypeError("The last argument must be of type Function");var O=this,D=function(){return M.apply(O,arguments)};L.apply(this,G).then(function(z){e.nextTick(D.bind(null,null,z))},function(z){e.nextTick(Ee.bind(null,z,D))})}return Object.setPrototypeOf($,Object.getPrototypeOf(L)),Object.defineProperties($,t(L)),$}n.callbackify=ve}(Ct)),Ct}var Ar,Bi;function pa(){if(Bi)return Ar;Bi=1;function n(y,I){var S=Object.keys(y);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(y);I&&(h=h.filter(function(b){return Object.getOwnPropertyDescriptor(y,b).enumerable})),S.push.apply(S,h)}return S}function e(y){for(var I=1;I<arguments.length;I++){var S=arguments[I]!=null?arguments[I]:{};I%2?n(Object(S),!0).forEach(function(h){t(y,h,S[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(S)):n(Object(S)).forEach(function(h){Object.defineProperty(y,h,Object.getOwnPropertyDescriptor(S,h))})}return y}function t(y,I,S){return I=E(I),I in y?Object.defineProperty(y,I,{value:S,enumerable:!0,configurable:!0,writable:!0}):y[I]=S,y}function o(y,I){if(!(y instanceof I))throw new TypeError("Cannot call a class as a function")}function l(y,I){for(var S=0;S<I.length;S++){var h=I[S];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(y,E(h.key),h)}}function c(y,I,S){return I&&l(y.prototype,I),Object.defineProperty(y,"prototype",{writable:!1}),y}function E(y){var I=a(y,"string");return typeof I=="symbol"?I:String(I)}function a(y,I){if(typeof y!="object"||y===null)return y;var S=y[Symbol.toPrimitive];if(S!==void 0){var h=S.call(y,I);if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}var f=He(),u=f.Buffer,w=Mi(),A=w.inspect,C=A&&A.custom||"inspect";function j(y,I,S){u.prototype.copy.call(y,I,S)}return Ar=function(){function y(){o(this,y),this.head=null,this.tail=null,this.length=0}return c(y,[{key:"push",value:function(S){var h={data:S,next:null};this.length>0?this.tail.next=h:this.head=h,this.tail=h,++this.length}},{key:"unshift",value:function(S){var h={data:S,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length}},{key:"shift",value:function(){if(this.length!==0){var S=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,S}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(S){if(this.length===0)return"";for(var h=this.head,b=""+h.data;h=h.next;)b+=S+h.data;return b}},{key:"concat",value:function(S){if(this.length===0)return u.alloc(0);for(var h=u.allocUnsafe(S>>>0),b=this.head,P=0;b;)j(b.data,h,P),P+=b.data.length,b=b.next;return h}},{key:"consume",value:function(S,h){var b;return S<this.head.data.length?(b=this.head.data.slice(0,S),this.head.data=this.head.data.slice(S)):S===this.head.data.length?b=this.shift():b=h?this._getString(S):this._getBuffer(S),b}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(S){var h=this.head,b=1,P=h.data;for(S-=P.length;h=h.next;){var _=h.data,R=S>_.length?_.length:S;if(R===_.length?P+=_:P+=_.slice(0,S),S-=R,S===0){R===_.length?(++b,h.next?this.head=h.next:this.head=this.tail=null):(this.head=h,h.data=_.slice(R));break}++b}return this.length-=b,P}},{key:"_getBuffer",value:function(S){var h=u.allocUnsafe(S),b=this.head,P=1;for(b.data.copy(h),S-=b.data.length;b=b.next;){var _=b.data,R=S>_.length?_.length:S;if(_.copy(h,h.length-S,0,R),S-=R,S===0){R===_.length?(++P,b.next?this.head=b.next:this.head=this.tail=null):(this.head=b,b.data=_.slice(R));break}++P}return this.length-=P,h}},{key:C,value:function(S,h){return A(this,e(e({},h),{},{depth:0,customInspect:!1}))}}]),y}(),Ar}var Tr,Li;function Ni(){if(Li)return Tr;Li=1;var n={env:{}};function e(a,f){var u=this,w=this._readableState&&this._readableState.destroyed,A=this._writableState&&this._writableState.destroyed;return w||A?(f?f(a):a&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(c,this,a)):n.nextTick(c,this,a)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(a||null,function(C){!f&&C?u._writableState?u._writableState.errorEmitted?n.nextTick(o,u):(u._writableState.errorEmitted=!0,n.nextTick(t,u,C)):n.nextTick(t,u,C):f?(n.nextTick(o,u),f(C)):n.nextTick(o,u)}),this)}function t(a,f){c(a,f),o(a)}function o(a){a._writableState&&!a._writableState.emitClose||a._readableState&&!a._readableState.emitClose||a.emit("close")}function l(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function c(a,f){a.emit("error",f)}function E(a,f){var u=a._readableState,w=a._writableState;u&&u.autoDestroy||w&&w.autoDestroy?a.destroy(f):a.emit("error",f)}return Tr={destroy:e,undestroy:l,errorOrDestroy:E},Tr}var Ir={},Di;function Ue(){if(Di)return Ir;Di=1;function n(a,f){a.prototype=Object.create(f.prototype),a.prototype.constructor=a,a.__proto__=f}var e={};function t(a,f,u){u||(u=Error);function w(C,j,y){return typeof f=="string"?f:f(C,j,y)}var A=function(C){n(j,C);function j(y,I,S){return C.call(this,w(y,I,S))||this}return j}(u);A.prototype.name=u.name,A.prototype.code=a,e[a]=A}function o(a,f){if(Array.isArray(a)){var u=a.length;return a=a.map(function(w){return String(w)}),u>2?"one of ".concat(f," ").concat(a.slice(0,u-1).join(", "),", or ")+a[u-1]:u===2?"one of ".concat(f," ").concat(a[0]," or ").concat(a[1]):"of ".concat(f," ").concat(a[0])}else return"of ".concat(f," ").concat(String(a))}function l(a,f,u){return a.substr(0,f.length)===f}function c(a,f,u){return(u===void 0||u>a.length)&&(u=a.length),a.substring(u-f.length,u)===f}function E(a,f,u){return typeof u!="number"&&(u=0),u+f.length>a.length?!1:a.indexOf(f,u)!==-1}return t("ERR_INVALID_OPT_VALUE",function(a,f){return'The value "'+f+'" is invalid for option "'+a+'"'},TypeError),t("ERR_INVALID_ARG_TYPE",function(a,f,u){var w;typeof f=="string"&&l(f,"not ")?(w="must not be",f=f.replace(/^not /,"")):w="must be";var A;if(c(a," argument"))A="The ".concat(a," ").concat(w," ").concat(o(f,"type"));else{var C=E(a,".")?"property":"argument";A='The "'.concat(a,'" ').concat(C," ").concat(w," ").concat(o(f,"type"))}return A+=". Received type ".concat(typeof u),A},TypeError),t("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),t("ERR_METHOD_NOT_IMPLEMENTED",function(a){return"The "+a+" method is not implemented"}),t("ERR_STREAM_PREMATURE_CLOSE","Premature close"),t("ERR_STREAM_DESTROYED",function(a){return"Cannot call "+a+" after a stream was destroyed"}),t("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),t("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),t("ERR_STREAM_WRITE_AFTER_END","write after end"),t("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),t("ERR_UNKNOWN_ENCODING",function(a){return"Unknown encoding: "+a},TypeError),t("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Ir.codes=e,Ir}var Or,Fi;function ji(){if(Fi)return Or;Fi=1;var n=Ue().codes.ERR_INVALID_OPT_VALUE;function e(o,l,c){return o.highWaterMark!=null?o.highWaterMark:l?o[c]:null}function t(o,l,c,E){var a=e(l,E,c);if(a!=null){if(!(isFinite(a)&&Math.floor(a)===a)||a<0){var f=E?c:"highWaterMark";throw new n(f,a)}return Math.floor(a)}return o.objectMode?16:16*1024}return Or={getHighWaterMark:t},Or}var kr,$i;function ga(){if($i)return kr;$i=1,kr=n;function n(t,o){if(e("noDeprecation"))return t;var l=!1;function c(){if(!l){if(e("throwDeprecation"))throw new Error(o);e("traceDeprecation")?console.trace(o):console.warn(o),l=!0}return t.apply(this,arguments)}return c}function e(t){try{if(!globalThis.localStorage)return!1}catch(l){return!1}var o=globalThis.localStorage[t];return o==null?!1:String(o).toLowerCase()==="true"}return kr}var Mr,Ui;function qi(){if(Ui)return Mr;Ui=1;var n={env:{}};Mr=U;function e(M){var O=this;this.next=null,this.entry=null,this.finish=function(){K(O,M)}}var t;U.WritableState=g;var o={deprecate:ga()},l=_n(),c=He().Buffer,E=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function a(M){return c.from(M)}function f(M){return c.isBuffer(M)||M instanceof E}var u=Ni(),w=ji(),A=w.getHighWaterMark,C=Ue().codes,j=C.ERR_INVALID_ARG_TYPE,y=C.ERR_METHOD_NOT_IMPLEMENTED,I=C.ERR_MULTIPLE_CALLBACK,S=C.ERR_STREAM_CANNOT_PIPE,h=C.ERR_STREAM_DESTROYED,b=C.ERR_STREAM_NULL_VALUES,P=C.ERR_STREAM_WRITE_AFTER_END,_=C.ERR_UNKNOWN_ENCODING,R=u.errorOrDestroy;$e()(U,l);function v(){}function g(M,O,D){t=t||qe(),M=M||{},typeof D!="boolean"&&(D=O instanceof t),this.objectMode=!!M.objectMode,D&&(this.objectMode=this.objectMode||!!M.writableObjectMode),this.highWaterMark=A(this,M,"writableHighWaterMark",D),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var z=M.decodeStrings===!1;this.decodeStrings=!z,this.defaultEncoding=M.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(V){Se(O,V)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=M.emitClose!==!1,this.autoDestroy=!!M.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}g.prototype.getBuffer=function(){for(var O=this.bufferedRequest,D=[];O;)D.push(O),O=O.next;return D},function(){try{Object.defineProperty(g.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(M){}}();var B;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(B=Function.prototype[Symbol.hasInstance],Object.defineProperty(U,Symbol.hasInstance,{value:function(O){return B.call(this,O)?!0:this!==U?!1:O&&O._writableState instanceof g}})):B=function(O){return O instanceof this};function U(M){t=t||qe();var O=this instanceof t;if(!O&&!B.call(U,this))return new U(M);this._writableState=new g(M,this,O),this.writable=!0,M&&(typeof M.write=="function"&&(this._write=M.write),typeof M.writev=="function"&&(this._writev=M.writev),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.final=="function"&&(this._final=M.final)),l.call(this)}U.prototype.pipe=function(){R(this,new S)};function F(M,O){var D=new P;R(M,D),n.nextTick(O,D)}function J(M,O,D,z){var V;return D===null?V=new b:typeof D!="string"&&!O.objectMode&&(V=new j("chunk",["string","Buffer"],D)),V?(R(M,V),n.nextTick(z,V),!1):!0}U.prototype.write=function(M,O,D){var z=this._writableState,V=!1,d=!z.objectMode&&f(M);return d&&!c.isBuffer(M)&&(M=a(M)),typeof O=="function"&&(D=O,O=null),d?O="buffer":O||(O=z.defaultEncoding),typeof D!="function"&&(D=v),z.ending?F(this,D):(d||J(this,z,M,D))&&(z.pendingcb++,V=ne(this,z,d,M,O,D)),V},U.prototype.cork=function(){this._writableState.corked++},U.prototype.uncork=function(){var M=this._writableState;M.corked&&(M.corked--,!M.writing&&!M.corked&&!M.bufferProcessing&&M.bufferedRequest&&se(this,M))},U.prototype.setDefaultEncoding=function(O){if(typeof O=="string"&&(O=O.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((O+"").toLowerCase())>-1))throw new _(O);return this._writableState.defaultEncoding=O,this},Object.defineProperty(U.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function k(M,O,D){return!M.objectMode&&M.decodeStrings!==!1&&typeof O=="string"&&(O=c.from(O,D)),O}Object.defineProperty(U.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ne(M,O,D,z,V,d){if(!D){var p=k(O,z,V);z!==p&&(D=!0,V="buffer",z=p)}var x=O.objectMode?1:z.length;O.length+=x;var H=O.length<O.highWaterMark;if(H||(O.needDrain=!0),O.writing||O.corked){var X=O.lastBufferedRequest;O.lastBufferedRequest={chunk:z,encoding:V,isBuf:D,callback:d,next:null},X?X.next=O.lastBufferedRequest:O.bufferedRequest=O.lastBufferedRequest,O.bufferedRequestCount+=1}else re(M,O,!1,x,z,V,d);return H}function re(M,O,D,z,V,d,p){O.writelen=z,O.writecb=p,O.writing=!0,O.sync=!0,O.destroyed?O.onwrite(new h("write")):D?M._writev(V,O.onwrite):M._write(V,d,O.onwrite),O.sync=!1}function ce(M,O,D,z,V){--O.pendingcb,D?(n.nextTick(V,z),n.nextTick($,M,O),M._writableState.errorEmitted=!0,R(M,z)):(V(z),M._writableState.errorEmitted=!0,R(M,z),$(M,O))}function fe(M){M.writing=!1,M.writecb=null,M.length-=M.writelen,M.writelen=0}function Se(M,O){var D=M._writableState,z=D.sync,V=D.writecb;if(typeof V!="function")throw new I;if(fe(D),O)ce(M,D,z,O,V);else{var d=Ee(D)||M.destroyed;!d&&!D.corked&&!D.bufferProcessing&&D.bufferedRequest&&se(M,D),z?n.nextTick(de,M,D,d,V):de(M,D,d,V)}}function de(M,O,D,z){D||be(M,O),O.pendingcb--,z(),$(M,O)}function be(M,O){O.length===0&&O.needDrain&&(O.needDrain=!1,M.emit("drain"))}function se(M,O){O.bufferProcessing=!0;var D=O.bufferedRequest;if(M._writev&&D&&D.next){var z=O.bufferedRequestCount,V=new Array(z),d=O.corkedRequestsFree;d.entry=D;for(var p=0,x=!0;D;)V[p]=D,D.isBuf||(x=!1),D=D.next,p+=1;V.allBuffers=x,re(M,O,!0,O.length,V,"",d.finish),O.pendingcb++,O.lastBufferedRequest=null,d.next?(O.corkedRequestsFree=d.next,d.next=null):O.corkedRequestsFree=new e(O),O.bufferedRequestCount=0}else{for(;D;){var H=D.chunk,X=D.encoding,Z=D.callback,te=O.objectMode?1:H.length;if(re(M,O,!1,te,H,X,Z),D=D.next,O.bufferedRequestCount--,O.writing)break}D===null&&(O.lastBufferedRequest=null)}O.bufferedRequest=D,O.bufferProcessing=!1}U.prototype._write=function(M,O,D){D(new y("_write()"))},U.prototype._writev=null,U.prototype.end=function(M,O,D){var z=this._writableState;return typeof M=="function"?(D=M,M=null,O=null):typeof O=="function"&&(D=O,O=null),M!=null&&this.write(M,O),z.corked&&(z.corked=1,this.uncork()),z.ending||G(this,z,D),this},Object.defineProperty(U.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Ee(M){return M.ending&&M.length===0&&M.bufferedRequest===null&&!M.finished&&!M.writing}function ve(M,O){M._final(function(D){O.pendingcb--,D&&R(M,D),O.prefinished=!0,M.emit("prefinish"),$(M,O)})}function L(M,O){!O.prefinished&&!O.finalCalled&&(typeof M._final=="function"&&!O.destroyed?(O.pendingcb++,O.finalCalled=!0,n.nextTick(ve,M,O)):(O.prefinished=!0,M.emit("prefinish")))}function $(M,O){var D=Ee(O);if(D&&(L(M,O),O.pendingcb===0&&(O.finished=!0,M.emit("finish"),O.autoDestroy))){var z=M._readableState;(!z||z.autoDestroy&&z.endEmitted)&&M.destroy()}return D}function G(M,O,D){O.ending=!0,$(M,O),D&&(O.finished?n.nextTick(D):M.once("finish",D)),O.ended=!0,M.writable=!1}function K(M,O,D){var z=M.entry;for(M.entry=null;z;){var V=z.callback;O.pendingcb--,V(D),z=z.next}O.corkedRequestsFree.next=M}return Object.defineProperty(U.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(O){this._writableState&&(this._writableState.destroyed=O)}}),U.prototype.destroy=u.destroy,U.prototype._undestroy=u.undestroy,U.prototype._destroy=function(M,O){O(M)},Mr}var Br,xi;function qe(){if(xi)return Br;xi=1;var n={env:{}},e=Object.keys||function(w){var A=[];for(var C in w)A.push(C);return A};Br=a;var t=Yi(),o=qi();$e()(a,t);for(var l=e(o.prototype),c=0;c<l.length;c++){var E=l[c];a.prototype[E]||(a.prototype[E]=o.prototype[E])}function a(w){if(!(this instanceof a))return new a(w);t.call(this,w),o.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",f)))}Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(a.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function f(){this._writableState.ended||n.nextTick(u,this)}function u(w){w.end()}return Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(A){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=A,this._writableState.destroyed=A)}}),Br}var Lr={},Wi;function zi(){if(Wi)return Lr;Wi=1;var n=mn().Buffer,e=n.isEncoding||function(h){switch(h=""+h,h&&h.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function t(h){if(!h)return"utf8";for(var b;;)switch(h){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return h;default:if(b)return;h=(""+h).toLowerCase(),b=!0}}function o(h){var b=t(h);if(typeof b!="string"&&(n.isEncoding===e||!e(h)))throw new Error("Unknown encoding: "+h);return b||h}Lr.StringDecoder=l;function l(h){this.encoding=o(h);var b;switch(this.encoding){case"utf16le":this.text=A,this.end=C,b=4;break;case"utf8":this.fillLast=f,b=4;break;case"base64":this.text=j,this.end=y,b=3;break;default:this.write=I,this.end=S;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(b)}l.prototype.write=function(h){if(h.length===0)return"";var b,P;if(this.lastNeed){if(b=this.fillLast(h),b===void 0)return"";P=this.lastNeed,this.lastNeed=0}else P=0;return P<h.length?b?b+this.text(h,P):this.text(h,P):b||""},l.prototype.end=w,l.prototype.text=u,l.prototype.fillLast=function(h){if(this.lastNeed<=h.length)return h.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);h.copy(this.lastChar,this.lastTotal-this.lastNeed,0,h.length),this.lastNeed-=h.length};function c(h){return h<=127?0:h>>5===6?2:h>>4===14?3:h>>3===30?4:h>>6===2?-1:-2}function E(h,b,P){var _=b.length-1;if(_<P)return 0;var R=c(b[_]);return R>=0?(R>0&&(h.lastNeed=R-1),R):--_<P||R===-2?0:(R=c(b[_]),R>=0?(R>0&&(h.lastNeed=R-2),R):--_<P||R===-2?0:(R=c(b[_]),R>=0?(R>0&&(R===2?R=0:h.lastNeed=R-3),R):0))}function a(h,b,P){if((b[0]&192)!==128)return h.lastNeed=0,"�";if(h.lastNeed>1&&b.length>1){if((b[1]&192)!==128)return h.lastNeed=1,"�";if(h.lastNeed>2&&b.length>2&&(b[2]&192)!==128)return h.lastNeed=2,"�"}}function f(h){var b=this.lastTotal-this.lastNeed,P=a(this,h);if(P!==void 0)return P;if(this.lastNeed<=h.length)return h.copy(this.lastChar,b,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);h.copy(this.lastChar,b,0,h.length),this.lastNeed-=h.length}function u(h,b){var P=E(this,h,b);if(!this.lastNeed)return h.toString("utf8",b);this.lastTotal=P;var _=h.length-(P-this.lastNeed);return h.copy(this.lastChar,0,_),h.toString("utf8",b,_)}function w(h){var b=h&&h.length?this.write(h):"";return this.lastNeed?b+"�":b}function A(h,b){if((h.length-b)%2===0){var P=h.toString("utf16le",b);if(P){var _=P.charCodeAt(P.length-1);if(_>=55296&&_<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=h[h.length-2],this.lastChar[1]=h[h.length-1],P.slice(0,-1)}return P}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=h[h.length-1],h.toString("utf16le",b,h.length-1)}function C(h){var b=h&&h.length?this.write(h):"";if(this.lastNeed){var P=this.lastTotal-this.lastNeed;return b+this.lastChar.toString("utf16le",0,P)}return b}function j(h,b){var P=(h.length-b)%3;return P===0?h.toString("base64",b):(this.lastNeed=3-P,this.lastTotal=3,P===1?this.lastChar[0]=h[h.length-1]:(this.lastChar[0]=h[h.length-2],this.lastChar[1]=h[h.length-1]),h.toString("base64",b,h.length-P))}function y(h){var b=h&&h.length?this.write(h):"";return this.lastNeed?b+this.lastChar.toString("base64",0,3-this.lastNeed):b}function I(h){return h.toString(this.encoding)}function S(h){return h&&h.length?this.write(h):""}return Lr}var Nr,Gi;function Dr(){if(Gi)return Nr;Gi=1;var n=Ue().codes.ERR_STREAM_PREMATURE_CLOSE;function e(c){var E=!1;return function(){if(!E){E=!0;for(var a=arguments.length,f=new Array(a),u=0;u<a;u++)f[u]=arguments[u];c.apply(this,f)}}}function t(){}function o(c){return c.setHeader&&typeof c.abort=="function"}function l(c,E,a){if(typeof E=="function")return l(c,null,E);E||(E={}),a=e(a||t);var f=E.readable||E.readable!==!1&&c.readable,u=E.writable||E.writable!==!1&&c.writable,w=function(){c.writable||C()},A=c._writableState&&c._writableState.finished,C=function(){u=!1,A=!0,f||a.call(c)},j=c._readableState&&c._readableState.endEmitted,y=function(){f=!1,j=!0,u||a.call(c)},I=function(P){a.call(c,P)},S=function(){var P;if(f&&!j)return(!c._readableState||!c._readableState.ended)&&(P=new n),a.call(c,P);if(u&&!A)return(!c._writableState||!c._writableState.ended)&&(P=new n),a.call(c,P)},h=function(){c.req.on("finish",C)};return o(c)?(c.on("complete",C),c.on("abort",S),c.req?h():c.on("request",h)):u&&!c._writableState&&(c.on("end",w),c.on("close",w)),c.on("end",y),c.on("finish",C),E.error!==!1&&c.on("error",I),c.on("close",S),function(){c.removeListener("complete",C),c.removeListener("abort",S),c.removeListener("request",h),c.req&&c.req.removeListener("finish",C),c.removeListener("end",w),c.removeListener("close",w),c.removeListener("finish",C),c.removeListener("end",y),c.removeListener("error",I),c.removeListener("close",S)}}return Nr=l,Nr}var Fr,Vi;function ya(){if(Vi)return Fr;Vi=1;var n={env:{}},e;function t(_,R,v){return R=o(R),R in _?Object.defineProperty(_,R,{value:v,enumerable:!0,configurable:!0,writable:!0}):_[R]=v,_}function o(_){var R=l(_,"string");return typeof R=="symbol"?R:String(R)}function l(_,R){if(typeof _!="object"||_===null)return _;var v=_[Symbol.toPrimitive];if(v!==void 0){var g=v.call(_,R);if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(R==="string"?String:Number)(_)}var c=Dr(),E=Symbol("lastResolve"),a=Symbol("lastReject"),f=Symbol("error"),u=Symbol("ended"),w=Symbol("lastPromise"),A=Symbol("handlePromise"),C=Symbol("stream");function j(_,R){return{value:_,done:R}}function y(_){var R=_[E];if(R!==null){var v=_[C].read();v!==null&&(_[w]=null,_[E]=null,_[a]=null,R(j(v,!1)))}}function I(_){n.nextTick(y,_)}function S(_,R){return function(v,g){_.then(function(){if(R[u]){v(j(void 0,!0));return}R[A](v,g)},g)}}var h=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((e={get stream(){return this[C]},next:function(){var R=this,v=this[f];if(v!==null)return Promise.reject(v);if(this[u])return Promise.resolve(j(void 0,!0));if(this[C].destroyed)return new Promise(function(F,J){n.nextTick(function(){R[f]?J(R[f]):F(j(void 0,!0))})});var g=this[w],B;if(g)B=new Promise(S(g,this));else{var U=this[C].read();if(U!==null)return Promise.resolve(j(U,!1));B=new Promise(this[A])}return this[w]=B,B}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var R=this;return new Promise(function(v,g){R[C].destroy(null,function(B){if(B){g(B);return}v(j(void 0,!0))})})}),e),h),P=function(R){var v,g=Object.create(b,(v={},t(v,C,{value:R,writable:!0}),t(v,E,{value:null,writable:!0}),t(v,a,{value:null,writable:!0}),t(v,f,{value:null,writable:!0}),t(v,u,{value:R._readableState.endEmitted,writable:!0}),t(v,A,{value:function(U,F){var J=g[C].read();J?(g[w]=null,g[E]=null,g[a]=null,U(j(J,!1))):(g[E]=U,g[a]=F)},writable:!0}),v));return g[w]=null,c(R,function(B){if(B&&B.code!=="ERR_STREAM_PREMATURE_CLOSE"){var U=g[a];U!==null&&(g[w]=null,g[E]=null,g[a]=null,U(B)),g[f]=B;return}var F=g[E];F!==null&&(g[w]=null,g[E]=null,g[a]=null,F(j(void 0,!0))),g[u]=!0}),R.on("readable",I.bind(null,g)),g};return Fr=P,Fr}var jr,Hi;function ma(){return Hi||(Hi=1,jr=function(){throw new Error("Readable.from is not available in the browser")}),jr}var $r,Ji;function Yi(){if(Ji)return $r;Ji=1;var n={env:{}};$r=F;var e;F.ReadableState=U,_t().EventEmitter;var t=function(p,x){return p.listeners(x).length},o=_n(),l=He().Buffer,c=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function E(d){return l.from(d)}function a(d){return l.isBuffer(d)||d instanceof c}var f=Mi(),u;f&&f.debuglog?u=f.debuglog("stream"):u=function(){};var w=pa(),A=Ni(),C=ji(),j=C.getHighWaterMark,y=Ue().codes,I=y.ERR_INVALID_ARG_TYPE,S=y.ERR_STREAM_PUSH_AFTER_EOF,h=y.ERR_METHOD_NOT_IMPLEMENTED,b=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,P,_,R;$e()(F,o);var v=A.errorOrDestroy,g=["error","close","destroy","pause","resume"];function B(d,p,x){if(typeof d.prependListener=="function")return d.prependListener(p,x);!d._events||!d._events[p]?d.on(p,x):Array.isArray(d._events[p])?d._events[p].unshift(x):d._events[p]=[x,d._events[p]]}function U(d,p,x){e=e||qe(),d=d||{},typeof x!="boolean"&&(x=p instanceof e),this.objectMode=!!d.objectMode,x&&(this.objectMode=this.objectMode||!!d.readableObjectMode),this.highWaterMark=j(this,d,"readableHighWaterMark",x),this.buffer=new w,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=d.emitClose!==!1,this.autoDestroy=!!d.autoDestroy,this.destroyed=!1,this.defaultEncoding=d.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,d.encoding&&(P||(P=zi().StringDecoder),this.decoder=new P(d.encoding),this.encoding=d.encoding)}function F(d){if(e=e||qe(),!(this instanceof F))return new F(d);var p=this instanceof e;this._readableState=new U(d,this,p),this.readable=!0,d&&(typeof d.read=="function"&&(this._read=d.read),typeof d.destroy=="function"&&(this._destroy=d.destroy)),o.call(this)}Object.defineProperty(F.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(p){this._readableState&&(this._readableState.destroyed=p)}}),F.prototype.destroy=A.destroy,F.prototype._undestroy=A.undestroy,F.prototype._destroy=function(d,p){p(d)},F.prototype.push=function(d,p){var x=this._readableState,H;return x.objectMode?H=!0:typeof d=="string"&&(p=p||x.defaultEncoding,p!==x.encoding&&(d=l.from(d,p),p=""),H=!0),J(this,d,p,!1,H)},F.prototype.unshift=function(d){return J(this,d,null,!0,!1)};function J(d,p,x,H,X){u("readableAddChunk",p);var Z=d._readableState;if(p===null)Z.reading=!1,Se(d,Z);else{var te;if(X||(te=ne(Z,p)),te)v(d,te);else if(Z.objectMode||p&&p.length>0)if(typeof p!="string"&&!Z.objectMode&&Object.getPrototypeOf(p)!==l.prototype&&(p=E(p)),H)Z.endEmitted?v(d,new b):k(d,Z,p,!0);else if(Z.ended)v(d,new S);else{if(Z.destroyed)return!1;Z.reading=!1,Z.decoder&&!x?(p=Z.decoder.write(p),Z.objectMode||p.length!==0?k(d,Z,p,!1):se(d,Z)):k(d,Z,p,!1)}else H||(Z.reading=!1,se(d,Z))}return!Z.ended&&(Z.length<Z.highWaterMark||Z.length===0)}function k(d,p,x,H){p.flowing&&p.length===0&&!p.sync?(p.awaitDrain=0,d.emit("data",x)):(p.length+=p.objectMode?1:x.length,H?p.buffer.unshift(x):p.buffer.push(x),p.needReadable&&de(d)),se(d,p)}function ne(d,p){var x;return!a(p)&&typeof p!="string"&&p!==void 0&&!d.objectMode&&(x=new I("chunk",["string","Buffer","Uint8Array"],p)),x}F.prototype.isPaused=function(){return this._readableState.flowing===!1},F.prototype.setEncoding=function(d){P||(P=zi().StringDecoder);var p=new P(d);this._readableState.decoder=p,this._readableState.encoding=this._readableState.decoder.encoding;for(var x=this._readableState.buffer.head,H="";x!==null;)H+=p.write(x.data),x=x.next;return this._readableState.buffer.clear(),H!==""&&this._readableState.buffer.push(H),this._readableState.length=H.length,this};var re=1073741824;function ce(d){return d>=re?d=re:(d--,d|=d>>>1,d|=d>>>2,d|=d>>>4,d|=d>>>8,d|=d>>>16,d++),d}function fe(d,p){return d<=0||p.length===0&&p.ended?0:p.objectMode?1:d!==d?p.flowing&&p.length?p.buffer.head.data.length:p.length:(d>p.highWaterMark&&(p.highWaterMark=ce(d)),d<=p.length?d:p.ended?p.length:(p.needReadable=!0,0))}F.prototype.read=function(d){u("read",d),d=parseInt(d,10);var p=this._readableState,x=d;if(d!==0&&(p.emittedReadable=!1),d===0&&p.needReadable&&((p.highWaterMark!==0?p.length>=p.highWaterMark:p.length>0)||p.ended))return u("read: emitReadable",p.length,p.ended),p.length===0&&p.ended?D(this):de(this),null;if(d=fe(d,p),d===0&&p.ended)return p.length===0&&D(this),null;var H=p.needReadable;u("need readable",H),(p.length===0||p.length-d<p.highWaterMark)&&(H=!0,u("length less than watermark",H)),p.ended||p.reading?(H=!1,u("reading or ended",H)):H&&(u("do read"),p.reading=!0,p.sync=!0,p.length===0&&(p.needReadable=!0),this._read(p.highWaterMark),p.sync=!1,p.reading||(d=fe(x,p)));var X;return d>0?X=O(d,p):X=null,X===null?(p.needReadable=p.length<=p.highWaterMark,d=0):(p.length-=d,p.awaitDrain=0),p.length===0&&(p.ended||(p.needReadable=!0),x!==d&&p.ended&&D(this)),X!==null&&this.emit("data",X),X};function Se(d,p){if(u("onEofChunk"),!p.ended){if(p.decoder){var x=p.decoder.end();x&&x.length&&(p.buffer.push(x),p.length+=p.objectMode?1:x.length)}p.ended=!0,p.sync?de(d):(p.needReadable=!1,p.emittedReadable||(p.emittedReadable=!0,be(d)))}}function de(d){var p=d._readableState;u("emitReadable",p.needReadable,p.emittedReadable),p.needReadable=!1,p.emittedReadable||(u("emitReadable",p.flowing),p.emittedReadable=!0,n.nextTick(be,d))}function be(d){var p=d._readableState;u("emitReadable_",p.destroyed,p.length,p.ended),!p.destroyed&&(p.length||p.ended)&&(d.emit("readable"),p.emittedReadable=!1),p.needReadable=!p.flowing&&!p.ended&&p.length<=p.highWaterMark,M(d)}function se(d,p){p.readingMore||(p.readingMore=!0,n.nextTick(Ee,d,p))}function Ee(d,p){for(;!p.reading&&!p.ended&&(p.length<p.highWaterMark||p.flowing&&p.length===0);){var x=p.length;if(u("maybeReadMore read 0"),d.read(0),x===p.length)break}p.readingMore=!1}F.prototype._read=function(d){v(this,new h("_read()"))},F.prototype.pipe=function(d,p){var x=this,H=this._readableState;switch(H.pipesCount){case 0:H.pipes=d;break;case 1:H.pipes=[H.pipes,d];break;default:H.pipes.push(d);break}H.pipesCount+=1,u("pipe count=%d opts=%j",H.pipesCount,p);var X=(!p||p.end!==!1)&&d!==n.stdout&&d!==n.stderr,Z=X?q:Be;H.endEmitted?n.nextTick(Z):x.once("end",Z),d.on("unpipe",te);function te(Me,Re){u("onunpipe"),Me===x&&Re&&Re.hasUnpiped===!1&&(Re.hasUnpiped=!0,le())}function q(){u("onend"),d.end()}var Ce=ve(x);d.on("drain",Ce);var _e=!1;function le(){u("cleanup"),d.removeListener("close",ze),d.removeListener("finish",Ge),d.removeListener("drain",Ce),d.removeListener("error",Ae),d.removeListener("unpipe",te),x.removeListener("end",q),x.removeListener("end",Be),x.removeListener("data",he),_e=!0,H.awaitDrain&&(!d._writableState||d._writableState.needDrain)&&Ce()}x.on("data",he);function he(Me){u("ondata");var Re=d.write(Me);u("dest.write",Re),Re===!1&&((H.pipesCount===1&&H.pipes===d||H.pipesCount>1&&V(H.pipes,d)!==-1)&&!_e&&(u("false write response, pause",H.awaitDrain),H.awaitDrain++),x.pause())}function Ae(Me){u("onerror",Me),Be(),d.removeListener("error",Ae),t(d,"error")===0&&v(d,Me)}B(d,"error",Ae);function ze(){d.removeListener("finish",Ge),Be()}d.once("close",ze);function Ge(){u("onfinish"),d.removeListener("close",ze),Be()}d.once("finish",Ge);function Be(){u("unpipe"),x.unpipe(d)}return d.emit("pipe",x),H.flowing||(u("pipe resume"),x.resume()),d};function ve(d){return function(){var x=d._readableState;u("pipeOnDrain",x.awaitDrain),x.awaitDrain&&x.awaitDrain--,x.awaitDrain===0&&t(d,"data")&&(x.flowing=!0,M(d))}}F.prototype.unpipe=function(d){var p=this._readableState,x={hasUnpiped:!1};if(p.pipesCount===0)return this;if(p.pipesCount===1)return d&&d!==p.pipes?this:(d||(d=p.pipes),p.pipes=null,p.pipesCount=0,p.flowing=!1,d&&d.emit("unpipe",this,x),this);if(!d){var H=p.pipes,X=p.pipesCount;p.pipes=null,p.pipesCount=0,p.flowing=!1;for(var Z=0;Z<X;Z++)H[Z].emit("unpipe",this,{hasUnpiped:!1});return this}var te=V(p.pipes,d);return te===-1?this:(p.pipes.splice(te,1),p.pipesCount-=1,p.pipesCount===1&&(p.pipes=p.pipes[0]),d.emit("unpipe",this,x),this)},F.prototype.on=function(d,p){var x=o.prototype.on.call(this,d,p),H=this._readableState;return d==="data"?(H.readableListening=this.listenerCount("readable")>0,H.flowing!==!1&&this.resume()):d==="readable"&&!H.endEmitted&&!H.readableListening&&(H.readableListening=H.needReadable=!0,H.flowing=!1,H.emittedReadable=!1,u("on readable",H.length,H.reading),H.length?de(this):H.reading||n.nextTick($,this)),x},F.prototype.addListener=F.prototype.on,F.prototype.removeListener=function(d,p){var x=o.prototype.removeListener.call(this,d,p);return d==="readable"&&n.nextTick(L,this),x},F.prototype.removeAllListeners=function(d){var p=o.prototype.removeAllListeners.apply(this,arguments);return(d==="readable"||d===void 0)&&n.nextTick(L,this),p};function L(d){var p=d._readableState;p.readableListening=d.listenerCount("readable")>0,p.resumeScheduled&&!p.paused?p.flowing=!0:d.listenerCount("data")>0&&d.resume()}function $(d){u("readable nexttick read 0"),d.read(0)}F.prototype.resume=function(){var d=this._readableState;return d.flowing||(u("resume"),d.flowing=!d.readableListening,G(this,d)),d.paused=!1,this};function G(d,p){p.resumeScheduled||(p.resumeScheduled=!0,n.nextTick(K,d,p))}function K(d,p){u("resume",p.reading),p.reading||d.read(0),p.resumeScheduled=!1,d.emit("resume"),M(d),p.flowing&&!p.reading&&d.read(0)}F.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function M(d){var p=d._readableState;for(u("flow",p.flowing);p.flowing&&d.read()!==null;);}F.prototype.wrap=function(d){var p=this,x=this._readableState,H=!1;d.on("end",function(){if(u("wrapped end"),x.decoder&&!x.ended){var te=x.decoder.end();te&&te.length&&p.push(te)}p.push(null)}),d.on("data",function(te){if(u("wrapped data"),x.decoder&&(te=x.decoder.write(te)),!(x.objectMode&&te==null)&&!(!x.objectMode&&(!te||!te.length))){var q=p.push(te);q||(H=!0,d.pause())}});for(var X in d)this[X]===void 0&&typeof d[X]=="function"&&(this[X]=function(q){return function(){return d[q].apply(d,arguments)}}(X));for(var Z=0;Z<g.length;Z++)d.on(g[Z],this.emit.bind(this,g[Z]));return this._read=function(te){u("wrapped _read",te),H&&(H=!1,d.resume())},this},typeof Symbol=="function"&&(F.prototype[Symbol.asyncIterator]=function(){return _===void 0&&(_=ya()),_(this)}),Object.defineProperty(F.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(F.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(F.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(p){this._readableState&&(this._readableState.flowing=p)}}),F._fromList=O,Object.defineProperty(F.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function O(d,p){if(p.length===0)return null;var x;return p.objectMode?x=p.buffer.shift():!d||d>=p.length?(p.decoder?x=p.buffer.join(""):p.buffer.length===1?x=p.buffer.first():x=p.buffer.concat(p.length),p.buffer.clear()):x=p.buffer.consume(d,p.decoder),x}function D(d){var p=d._readableState;u("endReadable",p.endEmitted),p.endEmitted||(p.ended=!0,n.nextTick(z,p,d))}function z(d,p){if(u("endReadableNT",d.endEmitted,d.length),!d.endEmitted&&d.length===0&&(d.endEmitted=!0,p.readable=!1,p.emit("end"),d.autoDestroy)){var x=p._writableState;(!x||x.autoDestroy&&x.finished)&&p.destroy()}}typeof Symbol=="function"&&(F.from=function(d,p){return R===void 0&&(R=ma()),R(F,d,p)});function V(d,p){for(var x=0,H=d.length;x<H;x++)if(d[x]===p)return x;return-1}return $r}var Ur,Ki;function Xi(){if(Ki)return Ur;Ki=1,Ur=a;var n=Ue().codes,e=n.ERR_METHOD_NOT_IMPLEMENTED,t=n.ERR_MULTIPLE_CALLBACK,o=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,l=n.ERR_TRANSFORM_WITH_LENGTH_0,c=qe();$e()(a,c);function E(w,A){var C=this._transformState;C.transforming=!1;var j=C.writecb;if(j===null)return this.emit("error",new t);C.writechunk=null,C.writecb=null,A!=null&&this.push(A),j(w);var y=this._readableState;y.reading=!1,(y.needReadable||y.length<y.highWaterMark)&&this._read(y.highWaterMark)}function a(w){if(!(this instanceof a))return new a(w);c.call(this,w),this._transformState={afterTransform:E.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,w&&(typeof w.transform=="function"&&(this._transform=w.transform),typeof w.flush=="function"&&(this._flush=w.flush)),this.on("prefinish",f)}function f(){var w=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(A,C){u(w,A,C)}):u(this,null,null)}a.prototype.push=function(w,A){return this._transformState.needTransform=!1,c.prototype.push.call(this,w,A)},a.prototype._transform=function(w,A,C){C(new e("_transform()"))},a.prototype._write=function(w,A,C){var j=this._transformState;if(j.writecb=C,j.writechunk=w,j.writeencoding=A,!j.transforming){var y=this._readableState;(j.needTransform||y.needReadable||y.length<y.highWaterMark)&&this._read(y.highWaterMark)}},a.prototype._read=function(w){var A=this._transformState;A.writechunk!==null&&!A.transforming?(A.transforming=!0,this._transform(A.writechunk,A.writeencoding,A.afterTransform)):A.needTransform=!0},a.prototype._destroy=function(w,A){c.prototype._destroy.call(this,w,function(C){A(C)})};function u(w,A,C){if(A)return w.emit("error",A);if(C!=null&&w.push(C),w._writableState.length)throw new l;if(w._transformState.transforming)throw new o;return w.push(null)}return Ur}var qr,Zi;function va(){if(Zi)return qr;Zi=1,qr=e;var n=Xi();$e()(e,n);function e(t){if(!(this instanceof e))return new e(t);n.call(this,t)}return e.prototype._transform=function(t,o,l){l(null,t)},qr}var xr,Qi;function ba(){if(Qi)return xr;Qi=1;var n;function e(C){var j=!1;return function(){j||(j=!0,C.apply(void 0,arguments))}}var t=Ue().codes,o=t.ERR_MISSING_ARGS,l=t.ERR_STREAM_DESTROYED;function c(C){if(C)throw C}function E(C){return C.setHeader&&typeof C.abort=="function"}function a(C,j,y,I){I=e(I);var S=!1;C.on("close",function(){S=!0}),n===void 0&&(n=Dr()),n(C,{readable:j,writable:y},function(b){if(b)return I(b);S=!0,I()});var h=!1;return function(b){if(!S&&!h){if(h=!0,E(C))return C.abort();if(typeof C.destroy=="function")return C.destroy();I(b||new l("pipe"))}}}function f(C){C()}function u(C,j){return C.pipe(j)}function w(C){return!C.length||typeof C[C.length-1]!="function"?c:C.pop()}function A(){for(var C=arguments.length,j=new Array(C),y=0;y<C;y++)j[y]=arguments[y];var I=w(j);if(Array.isArray(j[0])&&(j=j[0]),j.length<2)throw new o("streams");var S,h=j.map(function(b,P){var _=P<j.length-1,R=P>0;return a(b,_,R,function(v){S||(S=v),v&&h.forEach(f),!_&&(h.forEach(f),I(S))})});return j.reduce(u)}return xr=A,xr}var eo;function wa(){return eo||(eo=1,function(n,e){e=n.exports=Yi(),e.Stream=e,e.Readable=e,e.Writable=qi(),e.Duplex=qe(),e.Transform=Xi(),e.PassThrough=va(),e.finished=Dr(),e.pipeline=ba()}(ot,ot.exports)),ot.exports}/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Wr,to;function _a(){if(to)return Wr;to=1;let n;return Wr=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window!="undefined"?window:globalThis):e=>(n||(n=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0)),Wr}var zr,ro;function Sa(){if(ro)return zr;ro=1;function n(t,o){for(const l in o)Object.defineProperty(t,l,{value:o[l],enumerable:!0,configurable:!0});return t}function e(t,o,l){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");l||(l={}),typeof o=="object"&&(l=o,o=""),o&&(l.code=o);try{return n(t,l)}catch(c){l.message=t.message,l.stack=t.stack;const E=function(){};return E.prototype=Object.create(Object.getPrototypeOf(t)),n(new E,l)}}return zr=e,zr}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Gr,no;function Ca(){if(no)return Gr;no=1;const n=ko()("simple-peer"),e=Mo(),t=Bo(),o=wa(),l=_a(),c=Sa(),{Buffer:E}=He(),a=64*1024,f=5*1e3,u=5*1e3;function w(j){return j.replace(/a=ice-options:trickle\s\n/g,"")}function A(j){console.warn(j)}class C extends o.Duplex{constructor(y){if(y=Object.assign({allowHalfOpen:!1},y),super(y),this._id=t(4).toString("hex").slice(0,7),this._debug("new peer %o",y),this.channelName=y.initiator?y.channelName||t(20).toString("hex"):null,this.initiator=y.initiator||!1,this.channelConfig=y.channelConfig||C.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},C.config,y.config),this.offerOptions=y.offerOptions||{},this.answerOptions=y.answerOptions||{},this.sdpTransform=y.sdpTransform||(I=>I),this.streams=y.streams||(y.stream?[y.stream]:[]),this.trickle=y.trickle!==void 0?y.trickle:!0,this.allowHalfTrickle=y.allowHalfTrickle!==void 0?y.allowHalfTrickle:!1,this.iceCompleteTimeout=y.iceCompleteTimeout||f,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=y.wrtc&&typeof y.wrtc=="object"?y.wrtc:e(),!this._wrtc)throw c(typeof window=="undefined"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(I){this.destroy(c(I,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=I=>{this._onIceCandidate(I)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(I=>{this.destroy(c(I,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=I=>{this._setupData(I)},this.streams&&this.streams.forEach(I=>{this.addStream(I)}),this._pc.ontrack=I=>{this._onTrack(I)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof y=="string")try{y=JSON.parse(y)}catch(I){y={}}this._debug("signal()"),y.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),y.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(y.transceiverRequest.kind,y.transceiverRequest.init)),y.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(y.candidate):this._pendingCandidates.push(y.candidate)),y.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(y)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(I=>{this._addIceCandidate(I)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(I=>{this.destroy(c(I,"ERR_SET_REMOTE_DESCRIPTION"))}),!y.sdp&&!y.candidate&&!y.renegotiate&&!y.transceiverRequest&&this.destroy(c(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(y){const I=new this._wrtc.RTCIceCandidate(y);this._pc.addIceCandidate(I).catch(S=>{!I.address||I.address.endsWith(".local")?A("Ignoring unsupported ICE candidate."):this.destroy(c(S,"ERR_ADD_ICE_CANDIDATE"))})}send(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(y)}}addTransceiver(y,I){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(y,I),this._needsNegotiation()}catch(S){this.destroy(c(S,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:y,init:I}})}}addStream(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),y.getTracks().forEach(I=>{this.addTrack(I,y)})}}addTrack(y,I){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const S=this._senderMap.get(y)||new Map;let h=S.get(I);if(!h)h=this._pc.addTrack(y,I),S.set(I,h),this._senderMap.set(y,S),this._needsNegotiation();else throw h.removed?c(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):c(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(y,I,S){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const h=this._senderMap.get(y),b=h?h.get(S):null;if(!b)throw c(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");I&&this._senderMap.set(I,h),b.replaceTrack!=null?b.replaceTrack(I):this.destroy(c(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(y,I){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const S=this._senderMap.get(y),h=S?S.get(I):null;if(!h)throw c(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{h.removed=!0,this._pc.removeTrack(h)}catch(b){b.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(h):this.destroy(c(b,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),y.getTracks().forEach(I=>{this.removeTrack(I,y)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,l(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(y){this._destroy(y,()=>{})}_destroy(y,I){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",y&&(y.message||y)),l(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",y&&(y.message||y)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(S){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(S){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,y&&this.emit("error",y),this.emit("close"),I()}))}_setupData(y){if(!y.channel)return this.destroy(c(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=y.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=a),this.channelName=this._channel.label,this._channel.onmessage=S=>{this._onChannelMessage(S)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=S=>{const h=S.error instanceof Error?S.error:new Error(`Datachannel error: ${S.message} ${S.filename}:${S.lineno}:${S.colno}`);this.destroy(c(h,"ERR_DATA_CHANNEL"))};let I=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(I&&this._onChannelClose(),I=!0):I=!1},u)}_read(){}_write(y,I,S){if(this.destroyed)return S(c(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(y)}catch(h){return this.destroy(c(h,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>a?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=S):S(null)}else this._debug("write before connect"),this._chunk=y,this._cb=S}_onFinish(){if(this.destroyed)return;const y=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?y():this.once("connect",y)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(y=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(y.sdp=w(y.sdp)),y.sdp=this.sdpTransform(y.sdp);const I=()=>{if(this.destroyed)return;const b=this._pc.localDescription||y;this._debug("signal"),this.emit("signal",{type:b.type,sdp:b.sdp})},S=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?I():this.once("_iceComplete",I))},h=b=>{this.destroy(c(b,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(y).then(S).catch(h)}).catch(y=>{this.destroy(c(y,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(y=>{!y.mid&&y.sender.track&&!y.requested&&(y.requested=!0,this.addTransceiver(y.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(y=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(y.sdp=w(y.sdp)),y.sdp=this.sdpTransform(y.sdp);const I=()=>{if(this.destroyed)return;const b=this._pc.localDescription||y;this._debug("signal"),this.emit("signal",{type:b.type,sdp:b.sdp}),this.initiator||this._requestMissingTransceivers()},S=()=>{this.destroyed||(this.trickle||this._iceComplete?I():this.once("_iceComplete",I))},h=b=>{this.destroy(c(b,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(y).then(S).catch(h)}).catch(y=>{this.destroy(c(y,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(c(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const y=this._pc.iceConnectionState,I=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",y,I),this.emit("iceStateChange",y,I),(y==="connected"||y==="completed")&&(this._pcReady=!0,this._maybeReady()),y==="failed"&&this.destroy(c(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),y==="closed"&&this.destroy(c(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(y){const I=S=>(Object.prototype.toString.call(S.values)==="[object Array]"&&S.values.forEach(h=>{Object.assign(S,h)}),S);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(S=>{const h=[];S.forEach(b=>{h.push(I(b))}),y(null,h)},S=>y(S)):this._pc.getStats.length>0?this._pc.getStats(S=>{if(this.destroyed)return;const h=[];S.result().forEach(b=>{const P={};b.names().forEach(_=>{P[_]=b.stat(_)}),P.id=b.id,P.type=b.type,P.timestamp=b.timestamp,h.push(I(P))}),y(null,h)},S=>y(S)):y(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const y=()=>{this.destroyed||this.getStats((I,S)=>{if(this.destroyed)return;I&&(S=[]);const h={},b={},P={};let _=!1;S.forEach(v=>{(v.type==="remotecandidate"||v.type==="remote-candidate")&&(h[v.id]=v),(v.type==="localcandidate"||v.type==="local-candidate")&&(b[v.id]=v),(v.type==="candidatepair"||v.type==="candidate-pair")&&(P[v.id]=v)});const R=v=>{_=!0;let g=b[v.localCandidateId];g&&(g.ip||g.address)?(this.localAddress=g.ip||g.address,this.localPort=Number(g.port)):g&&g.ipAddress?(this.localAddress=g.ipAddress,this.localPort=Number(g.portNumber)):typeof v.googLocalAddress=="string"&&(g=v.googLocalAddress.split(":"),this.localAddress=g[0],this.localPort=Number(g[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let B=h[v.remoteCandidateId];B&&(B.ip||B.address)?(this.remoteAddress=B.ip||B.address,this.remotePort=Number(B.port)):B&&B.ipAddress?(this.remoteAddress=B.ipAddress,this.remotePort=Number(B.portNumber)):typeof v.googRemoteAddress=="string"&&(B=v.googRemoteAddress.split(":"),this.remoteAddress=B[0],this.remotePort=Number(B[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(S.forEach(v=>{v.type==="transport"&&v.selectedCandidatePairId&&R(P[v.selectedCandidatePairId]),(v.type==="googCandidatePair"&&v.googActiveConnection==="true"||(v.type==="candidatepair"||v.type==="candidate-pair")&&v.selected)&&R(v)}),!_&&(!Object.keys(P).length||Object.keys(b).length)){setTimeout(y,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(g){return this.destroy(c(g,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const v=this._cb;this._cb=null,v(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};y()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>a||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(y=>{this._pc.removeTrack(y),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(y){this.destroyed||(y.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:y.candidate.candidate,sdpMLineIndex:y.candidate.sdpMLineIndex,sdpMid:y.candidate.sdpMid}}):!y.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),y.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(y){if(this.destroyed)return;let I=y.data;I instanceof ArrayBuffer&&(I=E.from(I)),this.push(I)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const y=this._cb;this._cb=null,y(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(y){this.destroyed||y.streams.forEach(I=>{this._debug("on track"),this.emit("track",y.track,I),this._remoteTracks.push({track:y.track,stream:I}),!this._remoteStreams.some(S=>S.id===I.id)&&(this._remoteStreams.push(I),l(()=>{this._debug("on stream"),this.emit("stream",I)}))})}_debug(){const y=[].slice.call(arguments);y[0]="["+this._id+"] "+y[0],n.apply(null,y)}}return C.WEBRTC_SUPPORT=!!e(),C.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},C.channelConfig={},Gr=C,Gr}var Ea=Ca();const Ra=yt(Ea);var Pa=Object.defineProperty,Aa=(n,e,t)=>e in n?Pa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t)=>Aa(n,typeof e!="symbol"?e+"":e,t),Vr=(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 io{constructor(e,t,o={}){De(this,"peer",null),De(this,"config"),De(this,"events"),De(this,"connectionState","new"),De(this,"isInitiator"),De(this,"remoteUserId"),De(this,"localStream",null),this.remoteUserId=e,this.config=t,this.events=o,this.isInitiator=t.initiator||!1}createConnection(e){return Vr(this,null,function*(){try{console.log(`[CallPeerConnection] Creating connection to ${this.remoteUserId}, initiator: ${this.isInitiator}`),this.localStream=e||null;const t={initiator:this.isInitiator,trickle:!0,stream:this.localStream||void 0,config:{iceServers:this.config.iceServers}};this.peer=new Ra(t),this.setupPeerEventListeners(),console.log(`[CallPeerConnection] Peer connection created for ${this.remoteUserId}`)}catch(t){throw console.error(`[CallPeerConnection] Failed to create connection to ${this.remoteUserId}:`,t),t}})}signal(e){var t,o;if(!this.peer){console.error(`[CallPeerConnection] Cannot signal to ${this.remoteUserId}: peer not initialized`);return}try{console.log(`[CallPeerConnection] Signaling to ${this.remoteUserId}:`,e.type),this.peer.signal(e)}catch(l){console.error(`[CallPeerConnection] Failed to signal to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}addStream(e){var t,o;if(!this.peer){console.error(`[CallPeerConnection] Cannot add stream to ${this.remoteUserId}: peer not initialized`);return}try{this.localStream&&this.removeStream(this.localStream),this.localStream=e,this.peer.addStream(e),console.log(`[CallPeerConnection] Stream added to ${this.remoteUserId}`)}catch(l){console.error(`[CallPeerConnection] Failed to add stream to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}removeStream(e){var t,o;if(!this.peer){console.error(`[CallPeerConnection] Cannot remove stream from ${this.remoteUserId}: peer not initialized`);return}try{this.peer.removeStream(e),this.localStream===e&&(this.localStream=null),console.log(`[CallPeerConnection] Stream removed from ${this.remoteUserId}`)}catch(l){console.error(`[CallPeerConnection] Failed to remove stream from ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}replaceTrack(e,t){var o,l;if(!this.peer){console.error(`[CallPeerConnection] Cannot replace track for ${this.remoteUserId}: peer not initialized`);return}try{this.peer.replaceTrack(e,t,this.localStream),console.log(`[CallPeerConnection] Track replaced for ${this.remoteUserId}`)}catch(c){console.error(`[CallPeerConnection] Failed to replace track for ${this.remoteUserId}:`,c),(l=(o=this.events).onError)==null||l.call(o,c)}}sendData(e){var t,o;if(!this.peer){console.error(`[CallPeerConnection] Cannot send data to ${this.remoteUserId}: peer not initialized`);return}if(!this.peer.connected){console.warn(`[CallPeerConnection] Cannot send data to ${this.remoteUserId}: not connected`);return}try{this.peer.send(JSON.stringify(e))}catch(l){console.error(`[CallPeerConnection] Failed to send data to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}setBandwidthLimit(e){return Vr(this,null,function*(){if(!this.peer){console.warn(`[CallPeerConnection] Cannot set bandwidth for ${this.remoteUserId}: peer connection not available`);return}try{const t=this.peer._pc;if(!t)return;const o=t.getSenders();for(const l of o)if(l.track){const c=l.getParameters();c.encodings||(c.encodings=[{}]),c.encodings[0].maxBitrate=e*1e3,yield l.setParameters(c)}console.log(`[CallPeerConnection] Bandwidth limit set to ${e}kbps for ${this.remoteUserId}`)}catch(t){console.error(`[CallPeerConnection] Failed to set bandwidth limit for ${this.remoteUserId}:`,t)}})}getConnectionState(){return this.connectionState}isConnected(){var e;return((e=this.peer)==null?void 0:e.connected)===!0}getStats(){return Vr(this,null,function*(){if(!this.peer)return null;try{const e=this.peer._pc;return e?yield e.getStats():null}catch(e){return console.error(`[CallPeerConnection] Failed to get stats for ${this.remoteUserId}:`,e),null}})}getRemoteUserId(){return this.remoteUserId}destroy(){if(console.log(`[CallPeerConnection] Destroying connection to ${this.remoteUserId}`),this.peer){try{this.peer.destroy()}catch(e){console.error(`[CallPeerConnection] Error destroying peer for ${this.remoteUserId}:`,e)}this.peer=null}this.localStream=null,this.connectionState="closed"}setupPeerEventListeners(){if(!this.peer)return;this.peer.on("signal",t=>{var o,l;console.log(`[CallPeerConnection] Signal from ${this.remoteUserId}:`,t.type),(l=(o=this.events).onSignal)==null||l.call(o,t)}),this.peer.on("connect",()=>{var t,o;console.log(`[CallPeerConnection] Connected to ${this.remoteUserId}`),this.connectionState="connected",(o=(t=this.events).onConnect)==null||o.call(t)}),this.peer.on("data",t=>{var o,l;try{const c=JSON.parse(t.toString());(l=(o=this.events).onData)==null||l.call(o,c)}catch(c){console.error(`[CallPeerConnection] Failed to parse data from ${this.remoteUserId}:`,c)}}),this.peer.on("stream",t=>{var o,l;console.log(`[CallPeerConnection] Stream received from ${this.remoteUserId}`),(l=(o=this.events).onStream)==null||l.call(o,t)}),this.peer.on("track",(t,o)=>{var l,c;console.log(`[CallPeerConnection] Track received from ${this.remoteUserId}:`,t.kind),(c=(l=this.events).onTrack)==null||c.call(l,t,o)}),this.peer.on("close",()=>{var t,o;console.log(`[CallPeerConnection] Connection closed with ${this.remoteUserId}`),this.connectionState="closed",(o=(t=this.events).onClose)==null||o.call(t)}),this.peer.on("error",t=>{var o,l;console.error(`[CallPeerConnection] Error with ${this.remoteUserId}:`,t),this.connectionState="failed",(l=(o=this.events).onError)==null||l.call(o,t)});const e=this.peer._pc;e&&e.addEventListener("connectionstatechange",()=>{if(this.peer){const t=this.peer._pc;t&&(this.connectionState=t.connectionState,console.log(`[CallPeerConnection] Connection state changed for ${this.remoteUserId}:`,this.connectionState))}})}getConnectionInfo(){return{remoteUserId:this.remoteUserId,isInitiator:this.isInitiator,connectionState:this.connectionState,connected:this.isConnected(),hasLocalStream:!!this.localStream,localStreamTracks:this.localStream?{video:this.localStream.getVideoTracks().length,audio:this.localStream.getAudioTracks().length}:null}}}const oo={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Xe=new Map,ut=n=>{const e=Xe.get(n);return e?Object.fromEntries(Object.entries(e.stores).map(([t,o])=>[t,o.getState()])):{}},Ta=(n,e,t)=>{if(n===void 0)return{type:"untracked",connection:e.connect(t)};const o=Xe.get(t.name);if(o)return Qe({type:"tracked",store:n},o);const l={connection:e.connect(t),stores:{}};return Xe.set(t.name,l),Qe({type:"tracked",store:n},l)},Ia=(n,e)=>{if(e===void 0)return;const t=Xe.get(n);t&&(delete t.stores[e],Object.keys(t.stores).length===0&&Xe.delete(n))},Oa=n=>{var e,t;if(!n)return;const o=n.split(`
16
+ `)+" "+G[1]:G[0]+$+" "+L.join(", ")+" "+G[1]}n.types=da();function h(L){return Array.isArray(L)}n.isArray=h;function b(L){return typeof L=="boolean"}n.isBoolean=b;function P(L){return L===null}n.isNull=P;function _(L){return L==null}n.isNullOrUndefined=_;function R(L){return typeof L=="number"}n.isNumber=R;function v(L){return typeof L=="string"}n.isString=v;function g(L){return typeof L=="symbol"}n.isSymbol=g;function B(L){return L===void 0}n.isUndefined=B;function U(L){return F(L)&&ce(L)==="[object RegExp]"}n.isRegExp=U,n.types.isRegExp=U;function F(L){return typeof L=="object"&&L!==null}n.isObject=F;function J(L){return F(L)&&ce(L)==="[object Date]"}n.isDate=J,n.types.isDate=J;function k(L){return F(L)&&(ce(L)==="[object Error]"||L instanceof Error)}n.isError=k,n.types.isNativeError=k;function ne(L){return typeof L=="function"}n.isFunction=ne;function re(L){return L===null||typeof L=="boolean"||typeof L=="number"||typeof L=="string"||typeof L=="symbol"||typeof L=="undefined"}n.isPrimitive=re,n.isBuffer=ha();function ce(L){return Object.prototype.toString.call(L)}function fe(L){return L<10?"0"+L.toString(10):L.toString(10)}var Se=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function de(){var L=new Date,$=[fe(L.getHours()),fe(L.getMinutes()),fe(L.getSeconds())].join(":");return[L.getDate(),Se[L.getMonth()],$].join(" ")}n.log=function(){console.log("%s - %s",de(),n.format.apply(n,arguments))},n.inherits=$e(),n._extend=function(L,$){if(!$||!F($))return L;for(var G=Object.keys($),K=G.length;K--;)L[G[K]]=$[G[K]];return L};function be(L,$){return Object.prototype.hasOwnProperty.call(L,$)}var se=typeof Symbol!="undefined"?Symbol("util.promisify.custom"):void 0;n.promisify=function($){if(typeof $!="function")throw new TypeError('The "original" argument must be of type Function');if(se&&$[se]){var G=$[se];if(typeof G!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(G,se,{value:G,enumerable:!1,writable:!1,configurable:!0}),G}function G(){for(var K,M,O=new Promise(function(V,d){K=V,M=d}),D=[],z=0;z<arguments.length;z++)D.push(arguments[z]);D.push(function(V,d){V?M(V):K(d)});try{$.apply(this,D)}catch(V){M(V)}return O}return Object.setPrototypeOf(G,Object.getPrototypeOf($)),se&&Object.defineProperty(G,se,{value:G,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(G,t($))},n.promisify.custom=se;function Ee(L,$){if(!L){var G=new Error("Promise was rejected with a falsy value");G.reason=L,L=G}return $(L)}function me(L){if(typeof L!="function")throw new TypeError('The "original" argument must be of type Function');function $(){for(var G=[],K=0;K<arguments.length;K++)G.push(arguments[K]);var M=G.pop();if(typeof M!="function")throw new TypeError("The last argument must be of type Function");var O=this,D=function(){return M.apply(O,arguments)};L.apply(this,G).then(function(z){e.nextTick(D.bind(null,null,z))},function(z){e.nextTick(Ee.bind(null,z,D))})}return Object.setPrototypeOf($,Object.getPrototypeOf(L)),Object.defineProperties($,t(L)),$}n.callbackify=me}(Ct)),Ct}var Ar,Bi;function pa(){if(Bi)return Ar;Bi=1;function n(y,I){var S=Object.keys(y);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(y);I&&(h=h.filter(function(b){return Object.getOwnPropertyDescriptor(y,b).enumerable})),S.push.apply(S,h)}return S}function e(y){for(var I=1;I<arguments.length;I++){var S=arguments[I]!=null?arguments[I]:{};I%2?n(Object(S),!0).forEach(function(h){t(y,h,S[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(y,Object.getOwnPropertyDescriptors(S)):n(Object(S)).forEach(function(h){Object.defineProperty(y,h,Object.getOwnPropertyDescriptor(S,h))})}return y}function t(y,I,S){return I=E(I),I in y?Object.defineProperty(y,I,{value:S,enumerable:!0,configurable:!0,writable:!0}):y[I]=S,y}function o(y,I){if(!(y instanceof I))throw new TypeError("Cannot call a class as a function")}function l(y,I){for(var S=0;S<I.length;S++){var h=I[S];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(y,E(h.key),h)}}function c(y,I,S){return I&&l(y.prototype,I),Object.defineProperty(y,"prototype",{writable:!1}),y}function E(y){var I=a(y,"string");return typeof I=="symbol"?I:String(I)}function a(y,I){if(typeof y!="object"||y===null)return y;var S=y[Symbol.toPrimitive];if(S!==void 0){var h=S.call(y,I);if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(y)}var f=He(),u=f.Buffer,w=Mi(),A=w.inspect,C=A&&A.custom||"inspect";function j(y,I,S){u.prototype.copy.call(y,I,S)}return Ar=function(){function y(){o(this,y),this.head=null,this.tail=null,this.length=0}return c(y,[{key:"push",value:function(S){var h={data:S,next:null};this.length>0?this.tail.next=h:this.head=h,this.tail=h,++this.length}},{key:"unshift",value:function(S){var h={data:S,next:this.head};this.length===0&&(this.tail=h),this.head=h,++this.length}},{key:"shift",value:function(){if(this.length!==0){var S=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,S}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(S){if(this.length===0)return"";for(var h=this.head,b=""+h.data;h=h.next;)b+=S+h.data;return b}},{key:"concat",value:function(S){if(this.length===0)return u.alloc(0);for(var h=u.allocUnsafe(S>>>0),b=this.head,P=0;b;)j(b.data,h,P),P+=b.data.length,b=b.next;return h}},{key:"consume",value:function(S,h){var b;return S<this.head.data.length?(b=this.head.data.slice(0,S),this.head.data=this.head.data.slice(S)):S===this.head.data.length?b=this.shift():b=h?this._getString(S):this._getBuffer(S),b}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(S){var h=this.head,b=1,P=h.data;for(S-=P.length;h=h.next;){var _=h.data,R=S>_.length?_.length:S;if(R===_.length?P+=_:P+=_.slice(0,S),S-=R,S===0){R===_.length?(++b,h.next?this.head=h.next:this.head=this.tail=null):(this.head=h,h.data=_.slice(R));break}++b}return this.length-=b,P}},{key:"_getBuffer",value:function(S){var h=u.allocUnsafe(S),b=this.head,P=1;for(b.data.copy(h),S-=b.data.length;b=b.next;){var _=b.data,R=S>_.length?_.length:S;if(_.copy(h,h.length-S,0,R),S-=R,S===0){R===_.length?(++P,b.next?this.head=b.next:this.head=this.tail=null):(this.head=b,b.data=_.slice(R));break}++P}return this.length-=P,h}},{key:C,value:function(S,h){return A(this,e(e({},h),{},{depth:0,customInspect:!1}))}}]),y}(),Ar}var Tr,Li;function Ni(){if(Li)return Tr;Li=1;var n={env:{}};function e(a,f){var u=this,w=this._readableState&&this._readableState.destroyed,A=this._writableState&&this._writableState.destroyed;return w||A?(f?f(a):a&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(c,this,a)):n.nextTick(c,this,a)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(a||null,function(C){!f&&C?u._writableState?u._writableState.errorEmitted?n.nextTick(o,u):(u._writableState.errorEmitted=!0,n.nextTick(t,u,C)):n.nextTick(t,u,C):f?(n.nextTick(o,u),f(C)):n.nextTick(o,u)}),this)}function t(a,f){c(a,f),o(a)}function o(a){a._writableState&&!a._writableState.emitClose||a._readableState&&!a._readableState.emitClose||a.emit("close")}function l(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function c(a,f){a.emit("error",f)}function E(a,f){var u=a._readableState,w=a._writableState;u&&u.autoDestroy||w&&w.autoDestroy?a.destroy(f):a.emit("error",f)}return Tr={destroy:e,undestroy:l,errorOrDestroy:E},Tr}var Ir={},Di;function Ue(){if(Di)return Ir;Di=1;function n(a,f){a.prototype=Object.create(f.prototype),a.prototype.constructor=a,a.__proto__=f}var e={};function t(a,f,u){u||(u=Error);function w(C,j,y){return typeof f=="string"?f:f(C,j,y)}var A=function(C){n(j,C);function j(y,I,S){return C.call(this,w(y,I,S))||this}return j}(u);A.prototype.name=u.name,A.prototype.code=a,e[a]=A}function o(a,f){if(Array.isArray(a)){var u=a.length;return a=a.map(function(w){return String(w)}),u>2?"one of ".concat(f," ").concat(a.slice(0,u-1).join(", "),", or ")+a[u-1]:u===2?"one of ".concat(f," ").concat(a[0]," or ").concat(a[1]):"of ".concat(f," ").concat(a[0])}else return"of ".concat(f," ").concat(String(a))}function l(a,f,u){return a.substr(0,f.length)===f}function c(a,f,u){return(u===void 0||u>a.length)&&(u=a.length),a.substring(u-f.length,u)===f}function E(a,f,u){return typeof u!="number"&&(u=0),u+f.length>a.length?!1:a.indexOf(f,u)!==-1}return t("ERR_INVALID_OPT_VALUE",function(a,f){return'The value "'+f+'" is invalid for option "'+a+'"'},TypeError),t("ERR_INVALID_ARG_TYPE",function(a,f,u){var w;typeof f=="string"&&l(f,"not ")?(w="must not be",f=f.replace(/^not /,"")):w="must be";var A;if(c(a," argument"))A="The ".concat(a," ").concat(w," ").concat(o(f,"type"));else{var C=E(a,".")?"property":"argument";A='The "'.concat(a,'" ').concat(C," ").concat(w," ").concat(o(f,"type"))}return A+=". Received type ".concat(typeof u),A},TypeError),t("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),t("ERR_METHOD_NOT_IMPLEMENTED",function(a){return"The "+a+" method is not implemented"}),t("ERR_STREAM_PREMATURE_CLOSE","Premature close"),t("ERR_STREAM_DESTROYED",function(a){return"Cannot call "+a+" after a stream was destroyed"}),t("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),t("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),t("ERR_STREAM_WRITE_AFTER_END","write after end"),t("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),t("ERR_UNKNOWN_ENCODING",function(a){return"Unknown encoding: "+a},TypeError),t("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Ir.codes=e,Ir}var Or,Fi;function ji(){if(Fi)return Or;Fi=1;var n=Ue().codes.ERR_INVALID_OPT_VALUE;function e(o,l,c){return o.highWaterMark!=null?o.highWaterMark:l?o[c]:null}function t(o,l,c,E){var a=e(l,E,c);if(a!=null){if(!(isFinite(a)&&Math.floor(a)===a)||a<0){var f=E?c:"highWaterMark";throw new n(f,a)}return Math.floor(a)}return o.objectMode?16:16*1024}return Or={getHighWaterMark:t},Or}var kr,$i;function ga(){if($i)return kr;$i=1,kr=n;function n(t,o){if(e("noDeprecation"))return t;var l=!1;function c(){if(!l){if(e("throwDeprecation"))throw new Error(o);e("traceDeprecation")?console.trace(o):console.warn(o),l=!0}return t.apply(this,arguments)}return c}function e(t){try{if(!globalThis.localStorage)return!1}catch(l){return!1}var o=globalThis.localStorage[t];return o==null?!1:String(o).toLowerCase()==="true"}return kr}var Mr,Ui;function qi(){if(Ui)return Mr;Ui=1;var n={env:{}};Mr=U;function e(M){var O=this;this.next=null,this.entry=null,this.finish=function(){K(O,M)}}var t;U.WritableState=g;var o={deprecate:ga()},l=_n(),c=He().Buffer,E=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function a(M){return c.from(M)}function f(M){return c.isBuffer(M)||M instanceof E}var u=Ni(),w=ji(),A=w.getHighWaterMark,C=Ue().codes,j=C.ERR_INVALID_ARG_TYPE,y=C.ERR_METHOD_NOT_IMPLEMENTED,I=C.ERR_MULTIPLE_CALLBACK,S=C.ERR_STREAM_CANNOT_PIPE,h=C.ERR_STREAM_DESTROYED,b=C.ERR_STREAM_NULL_VALUES,P=C.ERR_STREAM_WRITE_AFTER_END,_=C.ERR_UNKNOWN_ENCODING,R=u.errorOrDestroy;$e()(U,l);function v(){}function g(M,O,D){t=t||qe(),M=M||{},typeof D!="boolean"&&(D=O instanceof t),this.objectMode=!!M.objectMode,D&&(this.objectMode=this.objectMode||!!M.writableObjectMode),this.highWaterMark=A(this,M,"writableHighWaterMark",D),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var z=M.decodeStrings===!1;this.decodeStrings=!z,this.defaultEncoding=M.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(V){Se(O,V)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=M.emitClose!==!1,this.autoDestroy=!!M.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}g.prototype.getBuffer=function(){for(var O=this.bufferedRequest,D=[];O;)D.push(O),O=O.next;return D},function(){try{Object.defineProperty(g.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(M){}}();var B;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(B=Function.prototype[Symbol.hasInstance],Object.defineProperty(U,Symbol.hasInstance,{value:function(O){return B.call(this,O)?!0:this!==U?!1:O&&O._writableState instanceof g}})):B=function(O){return O instanceof this};function U(M){t=t||qe();var O=this instanceof t;if(!O&&!B.call(U,this))return new U(M);this._writableState=new g(M,this,O),this.writable=!0,M&&(typeof M.write=="function"&&(this._write=M.write),typeof M.writev=="function"&&(this._writev=M.writev),typeof M.destroy=="function"&&(this._destroy=M.destroy),typeof M.final=="function"&&(this._final=M.final)),l.call(this)}U.prototype.pipe=function(){R(this,new S)};function F(M,O){var D=new P;R(M,D),n.nextTick(O,D)}function J(M,O,D,z){var V;return D===null?V=new b:typeof D!="string"&&!O.objectMode&&(V=new j("chunk",["string","Buffer"],D)),V?(R(M,V),n.nextTick(z,V),!1):!0}U.prototype.write=function(M,O,D){var z=this._writableState,V=!1,d=!z.objectMode&&f(M);return d&&!c.isBuffer(M)&&(M=a(M)),typeof O=="function"&&(D=O,O=null),d?O="buffer":O||(O=z.defaultEncoding),typeof D!="function"&&(D=v),z.ending?F(this,D):(d||J(this,z,M,D))&&(z.pendingcb++,V=ne(this,z,d,M,O,D)),V},U.prototype.cork=function(){this._writableState.corked++},U.prototype.uncork=function(){var M=this._writableState;M.corked&&(M.corked--,!M.writing&&!M.corked&&!M.bufferProcessing&&M.bufferedRequest&&se(this,M))},U.prototype.setDefaultEncoding=function(O){if(typeof O=="string"&&(O=O.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((O+"").toLowerCase())>-1))throw new _(O);return this._writableState.defaultEncoding=O,this},Object.defineProperty(U.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function k(M,O,D){return!M.objectMode&&M.decodeStrings!==!1&&typeof O=="string"&&(O=c.from(O,D)),O}Object.defineProperty(U.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function ne(M,O,D,z,V,d){if(!D){var p=k(O,z,V);z!==p&&(D=!0,V="buffer",z=p)}var x=O.objectMode?1:z.length;O.length+=x;var H=O.length<O.highWaterMark;if(H||(O.needDrain=!0),O.writing||O.corked){var X=O.lastBufferedRequest;O.lastBufferedRequest={chunk:z,encoding:V,isBuf:D,callback:d,next:null},X?X.next=O.lastBufferedRequest:O.bufferedRequest=O.lastBufferedRequest,O.bufferedRequestCount+=1}else re(M,O,!1,x,z,V,d);return H}function re(M,O,D,z,V,d,p){O.writelen=z,O.writecb=p,O.writing=!0,O.sync=!0,O.destroyed?O.onwrite(new h("write")):D?M._writev(V,O.onwrite):M._write(V,d,O.onwrite),O.sync=!1}function ce(M,O,D,z,V){--O.pendingcb,D?(n.nextTick(V,z),n.nextTick($,M,O),M._writableState.errorEmitted=!0,R(M,z)):(V(z),M._writableState.errorEmitted=!0,R(M,z),$(M,O))}function fe(M){M.writing=!1,M.writecb=null,M.length-=M.writelen,M.writelen=0}function Se(M,O){var D=M._writableState,z=D.sync,V=D.writecb;if(typeof V!="function")throw new I;if(fe(D),O)ce(M,D,z,O,V);else{var d=Ee(D)||M.destroyed;!d&&!D.corked&&!D.bufferProcessing&&D.bufferedRequest&&se(M,D),z?n.nextTick(de,M,D,d,V):de(M,D,d,V)}}function de(M,O,D,z){D||be(M,O),O.pendingcb--,z(),$(M,O)}function be(M,O){O.length===0&&O.needDrain&&(O.needDrain=!1,M.emit("drain"))}function se(M,O){O.bufferProcessing=!0;var D=O.bufferedRequest;if(M._writev&&D&&D.next){var z=O.bufferedRequestCount,V=new Array(z),d=O.corkedRequestsFree;d.entry=D;for(var p=0,x=!0;D;)V[p]=D,D.isBuf||(x=!1),D=D.next,p+=1;V.allBuffers=x,re(M,O,!0,O.length,V,"",d.finish),O.pendingcb++,O.lastBufferedRequest=null,d.next?(O.corkedRequestsFree=d.next,d.next=null):O.corkedRequestsFree=new e(O),O.bufferedRequestCount=0}else{for(;D;){var H=D.chunk,X=D.encoding,Z=D.callback,te=O.objectMode?1:H.length;if(re(M,O,!1,te,H,X,Z),D=D.next,O.bufferedRequestCount--,O.writing)break}D===null&&(O.lastBufferedRequest=null)}O.bufferedRequest=D,O.bufferProcessing=!1}U.prototype._write=function(M,O,D){D(new y("_write()"))},U.prototype._writev=null,U.prototype.end=function(M,O,D){var z=this._writableState;return typeof M=="function"?(D=M,M=null,O=null):typeof O=="function"&&(D=O,O=null),M!=null&&this.write(M,O),z.corked&&(z.corked=1,this.uncork()),z.ending||G(this,z,D),this},Object.defineProperty(U.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function Ee(M){return M.ending&&M.length===0&&M.bufferedRequest===null&&!M.finished&&!M.writing}function me(M,O){M._final(function(D){O.pendingcb--,D&&R(M,D),O.prefinished=!0,M.emit("prefinish"),$(M,O)})}function L(M,O){!O.prefinished&&!O.finalCalled&&(typeof M._final=="function"&&!O.destroyed?(O.pendingcb++,O.finalCalled=!0,n.nextTick(me,M,O)):(O.prefinished=!0,M.emit("prefinish")))}function $(M,O){var D=Ee(O);if(D&&(L(M,O),O.pendingcb===0&&(O.finished=!0,M.emit("finish"),O.autoDestroy))){var z=M._readableState;(!z||z.autoDestroy&&z.endEmitted)&&M.destroy()}return D}function G(M,O,D){O.ending=!0,$(M,O),D&&(O.finished?n.nextTick(D):M.once("finish",D)),O.ended=!0,M.writable=!1}function K(M,O,D){var z=M.entry;for(M.entry=null;z;){var V=z.callback;O.pendingcb--,V(D),z=z.next}O.corkedRequestsFree.next=M}return Object.defineProperty(U.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(O){this._writableState&&(this._writableState.destroyed=O)}}),U.prototype.destroy=u.destroy,U.prototype._undestroy=u.undestroy,U.prototype._destroy=function(M,O){O(M)},Mr}var Br,xi;function qe(){if(xi)return Br;xi=1;var n={env:{}},e=Object.keys||function(w){var A=[];for(var C in w)A.push(C);return A};Br=a;var t=Yi(),o=qi();$e()(a,t);for(var l=e(o.prototype),c=0;c<l.length;c++){var E=l[c];a.prototype[E]||(a.prototype[E]=o.prototype[E])}function a(w){if(!(this instanceof a))return new a(w);t.call(this,w),o.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",f)))}Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(a.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function f(){this._writableState.ended||n.nextTick(u,this)}function u(w){w.end()}return Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(A){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=A,this._writableState.destroyed=A)}}),Br}var Lr={},Wi;function zi(){if(Wi)return Lr;Wi=1;var n=mn().Buffer,e=n.isEncoding||function(h){switch(h=""+h,h&&h.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function t(h){if(!h)return"utf8";for(var b;;)switch(h){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return h;default:if(b)return;h=(""+h).toLowerCase(),b=!0}}function o(h){var b=t(h);if(typeof b!="string"&&(n.isEncoding===e||!e(h)))throw new Error("Unknown encoding: "+h);return b||h}Lr.StringDecoder=l;function l(h){this.encoding=o(h);var b;switch(this.encoding){case"utf16le":this.text=A,this.end=C,b=4;break;case"utf8":this.fillLast=f,b=4;break;case"base64":this.text=j,this.end=y,b=3;break;default:this.write=I,this.end=S;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(b)}l.prototype.write=function(h){if(h.length===0)return"";var b,P;if(this.lastNeed){if(b=this.fillLast(h),b===void 0)return"";P=this.lastNeed,this.lastNeed=0}else P=0;return P<h.length?b?b+this.text(h,P):this.text(h,P):b||""},l.prototype.end=w,l.prototype.text=u,l.prototype.fillLast=function(h){if(this.lastNeed<=h.length)return h.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);h.copy(this.lastChar,this.lastTotal-this.lastNeed,0,h.length),this.lastNeed-=h.length};function c(h){return h<=127?0:h>>5===6?2:h>>4===14?3:h>>3===30?4:h>>6===2?-1:-2}function E(h,b,P){var _=b.length-1;if(_<P)return 0;var R=c(b[_]);return R>=0?(R>0&&(h.lastNeed=R-1),R):--_<P||R===-2?0:(R=c(b[_]),R>=0?(R>0&&(h.lastNeed=R-2),R):--_<P||R===-2?0:(R=c(b[_]),R>=0?(R>0&&(R===2?R=0:h.lastNeed=R-3),R):0))}function a(h,b,P){if((b[0]&192)!==128)return h.lastNeed=0,"�";if(h.lastNeed>1&&b.length>1){if((b[1]&192)!==128)return h.lastNeed=1,"�";if(h.lastNeed>2&&b.length>2&&(b[2]&192)!==128)return h.lastNeed=2,"�"}}function f(h){var b=this.lastTotal-this.lastNeed,P=a(this,h);if(P!==void 0)return P;if(this.lastNeed<=h.length)return h.copy(this.lastChar,b,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);h.copy(this.lastChar,b,0,h.length),this.lastNeed-=h.length}function u(h,b){var P=E(this,h,b);if(!this.lastNeed)return h.toString("utf8",b);this.lastTotal=P;var _=h.length-(P-this.lastNeed);return h.copy(this.lastChar,0,_),h.toString("utf8",b,_)}function w(h){var b=h&&h.length?this.write(h):"";return this.lastNeed?b+"�":b}function A(h,b){if((h.length-b)%2===0){var P=h.toString("utf16le",b);if(P){var _=P.charCodeAt(P.length-1);if(_>=55296&&_<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=h[h.length-2],this.lastChar[1]=h[h.length-1],P.slice(0,-1)}return P}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=h[h.length-1],h.toString("utf16le",b,h.length-1)}function C(h){var b=h&&h.length?this.write(h):"";if(this.lastNeed){var P=this.lastTotal-this.lastNeed;return b+this.lastChar.toString("utf16le",0,P)}return b}function j(h,b){var P=(h.length-b)%3;return P===0?h.toString("base64",b):(this.lastNeed=3-P,this.lastTotal=3,P===1?this.lastChar[0]=h[h.length-1]:(this.lastChar[0]=h[h.length-2],this.lastChar[1]=h[h.length-1]),h.toString("base64",b,h.length-P))}function y(h){var b=h&&h.length?this.write(h):"";return this.lastNeed?b+this.lastChar.toString("base64",0,3-this.lastNeed):b}function I(h){return h.toString(this.encoding)}function S(h){return h&&h.length?this.write(h):""}return Lr}var Nr,Gi;function Dr(){if(Gi)return Nr;Gi=1;var n=Ue().codes.ERR_STREAM_PREMATURE_CLOSE;function e(c){var E=!1;return function(){if(!E){E=!0;for(var a=arguments.length,f=new Array(a),u=0;u<a;u++)f[u]=arguments[u];c.apply(this,f)}}}function t(){}function o(c){return c.setHeader&&typeof c.abort=="function"}function l(c,E,a){if(typeof E=="function")return l(c,null,E);E||(E={}),a=e(a||t);var f=E.readable||E.readable!==!1&&c.readable,u=E.writable||E.writable!==!1&&c.writable,w=function(){c.writable||C()},A=c._writableState&&c._writableState.finished,C=function(){u=!1,A=!0,f||a.call(c)},j=c._readableState&&c._readableState.endEmitted,y=function(){f=!1,j=!0,u||a.call(c)},I=function(P){a.call(c,P)},S=function(){var P;if(f&&!j)return(!c._readableState||!c._readableState.ended)&&(P=new n),a.call(c,P);if(u&&!A)return(!c._writableState||!c._writableState.ended)&&(P=new n),a.call(c,P)},h=function(){c.req.on("finish",C)};return o(c)?(c.on("complete",C),c.on("abort",S),c.req?h():c.on("request",h)):u&&!c._writableState&&(c.on("end",w),c.on("close",w)),c.on("end",y),c.on("finish",C),E.error!==!1&&c.on("error",I),c.on("close",S),function(){c.removeListener("complete",C),c.removeListener("abort",S),c.removeListener("request",h),c.req&&c.req.removeListener("finish",C),c.removeListener("end",w),c.removeListener("close",w),c.removeListener("finish",C),c.removeListener("end",y),c.removeListener("error",I),c.removeListener("close",S)}}return Nr=l,Nr}var Fr,Vi;function ya(){if(Vi)return Fr;Vi=1;var n={env:{}},e;function t(_,R,v){return R=o(R),R in _?Object.defineProperty(_,R,{value:v,enumerable:!0,configurable:!0,writable:!0}):_[R]=v,_}function o(_){var R=l(_,"string");return typeof R=="symbol"?R:String(R)}function l(_,R){if(typeof _!="object"||_===null)return _;var v=_[Symbol.toPrimitive];if(v!==void 0){var g=v.call(_,R);if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(R==="string"?String:Number)(_)}var c=Dr(),E=Symbol("lastResolve"),a=Symbol("lastReject"),f=Symbol("error"),u=Symbol("ended"),w=Symbol("lastPromise"),A=Symbol("handlePromise"),C=Symbol("stream");function j(_,R){return{value:_,done:R}}function y(_){var R=_[E];if(R!==null){var v=_[C].read();v!==null&&(_[w]=null,_[E]=null,_[a]=null,R(j(v,!1)))}}function I(_){n.nextTick(y,_)}function S(_,R){return function(v,g){_.then(function(){if(R[u]){v(j(void 0,!0));return}R[A](v,g)},g)}}var h=Object.getPrototypeOf(function(){}),b=Object.setPrototypeOf((e={get stream(){return this[C]},next:function(){var R=this,v=this[f];if(v!==null)return Promise.reject(v);if(this[u])return Promise.resolve(j(void 0,!0));if(this[C].destroyed)return new Promise(function(F,J){n.nextTick(function(){R[f]?J(R[f]):F(j(void 0,!0))})});var g=this[w],B;if(g)B=new Promise(S(g,this));else{var U=this[C].read();if(U!==null)return Promise.resolve(j(U,!1));B=new Promise(this[A])}return this[w]=B,B}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var R=this;return new Promise(function(v,g){R[C].destroy(null,function(B){if(B){g(B);return}v(j(void 0,!0))})})}),e),h),P=function(R){var v,g=Object.create(b,(v={},t(v,C,{value:R,writable:!0}),t(v,E,{value:null,writable:!0}),t(v,a,{value:null,writable:!0}),t(v,f,{value:null,writable:!0}),t(v,u,{value:R._readableState.endEmitted,writable:!0}),t(v,A,{value:function(U,F){var J=g[C].read();J?(g[w]=null,g[E]=null,g[a]=null,U(j(J,!1))):(g[E]=U,g[a]=F)},writable:!0}),v));return g[w]=null,c(R,function(B){if(B&&B.code!=="ERR_STREAM_PREMATURE_CLOSE"){var U=g[a];U!==null&&(g[w]=null,g[E]=null,g[a]=null,U(B)),g[f]=B;return}var F=g[E];F!==null&&(g[w]=null,g[E]=null,g[a]=null,F(j(void 0,!0))),g[u]=!0}),R.on("readable",I.bind(null,g)),g};return Fr=P,Fr}var jr,Hi;function ma(){return Hi||(Hi=1,jr=function(){throw new Error("Readable.from is not available in the browser")}),jr}var $r,Ji;function Yi(){if(Ji)return $r;Ji=1;var n={env:{}};$r=F;var e;F.ReadableState=U,_t().EventEmitter;var t=function(p,x){return p.listeners(x).length},o=_n(),l=He().Buffer,c=(typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof self!="undefined"?self:{}).Uint8Array||function(){};function E(d){return l.from(d)}function a(d){return l.isBuffer(d)||d instanceof c}var f=Mi(),u;f&&f.debuglog?u=f.debuglog("stream"):u=function(){};var w=pa(),A=Ni(),C=ji(),j=C.getHighWaterMark,y=Ue().codes,I=y.ERR_INVALID_ARG_TYPE,S=y.ERR_STREAM_PUSH_AFTER_EOF,h=y.ERR_METHOD_NOT_IMPLEMENTED,b=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,P,_,R;$e()(F,o);var v=A.errorOrDestroy,g=["error","close","destroy","pause","resume"];function B(d,p,x){if(typeof d.prependListener=="function")return d.prependListener(p,x);!d._events||!d._events[p]?d.on(p,x):Array.isArray(d._events[p])?d._events[p].unshift(x):d._events[p]=[x,d._events[p]]}function U(d,p,x){e=e||qe(),d=d||{},typeof x!="boolean"&&(x=p instanceof e),this.objectMode=!!d.objectMode,x&&(this.objectMode=this.objectMode||!!d.readableObjectMode),this.highWaterMark=j(this,d,"readableHighWaterMark",x),this.buffer=new w,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=d.emitClose!==!1,this.autoDestroy=!!d.autoDestroy,this.destroyed=!1,this.defaultEncoding=d.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,d.encoding&&(P||(P=zi().StringDecoder),this.decoder=new P(d.encoding),this.encoding=d.encoding)}function F(d){if(e=e||qe(),!(this instanceof F))return new F(d);var p=this instanceof e;this._readableState=new U(d,this,p),this.readable=!0,d&&(typeof d.read=="function"&&(this._read=d.read),typeof d.destroy=="function"&&(this._destroy=d.destroy)),o.call(this)}Object.defineProperty(F.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(p){this._readableState&&(this._readableState.destroyed=p)}}),F.prototype.destroy=A.destroy,F.prototype._undestroy=A.undestroy,F.prototype._destroy=function(d,p){p(d)},F.prototype.push=function(d,p){var x=this._readableState,H;return x.objectMode?H=!0:typeof d=="string"&&(p=p||x.defaultEncoding,p!==x.encoding&&(d=l.from(d,p),p=""),H=!0),J(this,d,p,!1,H)},F.prototype.unshift=function(d){return J(this,d,null,!0,!1)};function J(d,p,x,H,X){u("readableAddChunk",p);var Z=d._readableState;if(p===null)Z.reading=!1,Se(d,Z);else{var te;if(X||(te=ne(Z,p)),te)v(d,te);else if(Z.objectMode||p&&p.length>0)if(typeof p!="string"&&!Z.objectMode&&Object.getPrototypeOf(p)!==l.prototype&&(p=E(p)),H)Z.endEmitted?v(d,new b):k(d,Z,p,!0);else if(Z.ended)v(d,new S);else{if(Z.destroyed)return!1;Z.reading=!1,Z.decoder&&!x?(p=Z.decoder.write(p),Z.objectMode||p.length!==0?k(d,Z,p,!1):se(d,Z)):k(d,Z,p,!1)}else H||(Z.reading=!1,se(d,Z))}return!Z.ended&&(Z.length<Z.highWaterMark||Z.length===0)}function k(d,p,x,H){p.flowing&&p.length===0&&!p.sync?(p.awaitDrain=0,d.emit("data",x)):(p.length+=p.objectMode?1:x.length,H?p.buffer.unshift(x):p.buffer.push(x),p.needReadable&&de(d)),se(d,p)}function ne(d,p){var x;return!a(p)&&typeof p!="string"&&p!==void 0&&!d.objectMode&&(x=new I("chunk",["string","Buffer","Uint8Array"],p)),x}F.prototype.isPaused=function(){return this._readableState.flowing===!1},F.prototype.setEncoding=function(d){P||(P=zi().StringDecoder);var p=new P(d);this._readableState.decoder=p,this._readableState.encoding=this._readableState.decoder.encoding;for(var x=this._readableState.buffer.head,H="";x!==null;)H+=p.write(x.data),x=x.next;return this._readableState.buffer.clear(),H!==""&&this._readableState.buffer.push(H),this._readableState.length=H.length,this};var re=1073741824;function ce(d){return d>=re?d=re:(d--,d|=d>>>1,d|=d>>>2,d|=d>>>4,d|=d>>>8,d|=d>>>16,d++),d}function fe(d,p){return d<=0||p.length===0&&p.ended?0:p.objectMode?1:d!==d?p.flowing&&p.length?p.buffer.head.data.length:p.length:(d>p.highWaterMark&&(p.highWaterMark=ce(d)),d<=p.length?d:p.ended?p.length:(p.needReadable=!0,0))}F.prototype.read=function(d){u("read",d),d=parseInt(d,10);var p=this._readableState,x=d;if(d!==0&&(p.emittedReadable=!1),d===0&&p.needReadable&&((p.highWaterMark!==0?p.length>=p.highWaterMark:p.length>0)||p.ended))return u("read: emitReadable",p.length,p.ended),p.length===0&&p.ended?D(this):de(this),null;if(d=fe(d,p),d===0&&p.ended)return p.length===0&&D(this),null;var H=p.needReadable;u("need readable",H),(p.length===0||p.length-d<p.highWaterMark)&&(H=!0,u("length less than watermark",H)),p.ended||p.reading?(H=!1,u("reading or ended",H)):H&&(u("do read"),p.reading=!0,p.sync=!0,p.length===0&&(p.needReadable=!0),this._read(p.highWaterMark),p.sync=!1,p.reading||(d=fe(x,p)));var X;return d>0?X=O(d,p):X=null,X===null?(p.needReadable=p.length<=p.highWaterMark,d=0):(p.length-=d,p.awaitDrain=0),p.length===0&&(p.ended||(p.needReadable=!0),x!==d&&p.ended&&D(this)),X!==null&&this.emit("data",X),X};function Se(d,p){if(u("onEofChunk"),!p.ended){if(p.decoder){var x=p.decoder.end();x&&x.length&&(p.buffer.push(x),p.length+=p.objectMode?1:x.length)}p.ended=!0,p.sync?de(d):(p.needReadable=!1,p.emittedReadable||(p.emittedReadable=!0,be(d)))}}function de(d){var p=d._readableState;u("emitReadable",p.needReadable,p.emittedReadable),p.needReadable=!1,p.emittedReadable||(u("emitReadable",p.flowing),p.emittedReadable=!0,n.nextTick(be,d))}function be(d){var p=d._readableState;u("emitReadable_",p.destroyed,p.length,p.ended),!p.destroyed&&(p.length||p.ended)&&(d.emit("readable"),p.emittedReadable=!1),p.needReadable=!p.flowing&&!p.ended&&p.length<=p.highWaterMark,M(d)}function se(d,p){p.readingMore||(p.readingMore=!0,n.nextTick(Ee,d,p))}function Ee(d,p){for(;!p.reading&&!p.ended&&(p.length<p.highWaterMark||p.flowing&&p.length===0);){var x=p.length;if(u("maybeReadMore read 0"),d.read(0),x===p.length)break}p.readingMore=!1}F.prototype._read=function(d){v(this,new h("_read()"))},F.prototype.pipe=function(d,p){var x=this,H=this._readableState;switch(H.pipesCount){case 0:H.pipes=d;break;case 1:H.pipes=[H.pipes,d];break;default:H.pipes.push(d);break}H.pipesCount+=1,u("pipe count=%d opts=%j",H.pipesCount,p);var X=(!p||p.end!==!1)&&d!==n.stdout&&d!==n.stderr,Z=X?q:Be;H.endEmitted?n.nextTick(Z):x.once("end",Z),d.on("unpipe",te);function te(Me,Re){u("onunpipe"),Me===x&&Re&&Re.hasUnpiped===!1&&(Re.hasUnpiped=!0,le())}function q(){u("onend"),d.end()}var Ce=me(x);d.on("drain",Ce);var _e=!1;function le(){u("cleanup"),d.removeListener("close",ze),d.removeListener("finish",Ge),d.removeListener("drain",Ce),d.removeListener("error",Ae),d.removeListener("unpipe",te),x.removeListener("end",q),x.removeListener("end",Be),x.removeListener("data",he),_e=!0,H.awaitDrain&&(!d._writableState||d._writableState.needDrain)&&Ce()}x.on("data",he);function he(Me){u("ondata");var Re=d.write(Me);u("dest.write",Re),Re===!1&&((H.pipesCount===1&&H.pipes===d||H.pipesCount>1&&V(H.pipes,d)!==-1)&&!_e&&(u("false write response, pause",H.awaitDrain),H.awaitDrain++),x.pause())}function Ae(Me){u("onerror",Me),Be(),d.removeListener("error",Ae),t(d,"error")===0&&v(d,Me)}B(d,"error",Ae);function ze(){d.removeListener("finish",Ge),Be()}d.once("close",ze);function Ge(){u("onfinish"),d.removeListener("close",ze),Be()}d.once("finish",Ge);function Be(){u("unpipe"),x.unpipe(d)}return d.emit("pipe",x),H.flowing||(u("pipe resume"),x.resume()),d};function me(d){return function(){var x=d._readableState;u("pipeOnDrain",x.awaitDrain),x.awaitDrain&&x.awaitDrain--,x.awaitDrain===0&&t(d,"data")&&(x.flowing=!0,M(d))}}F.prototype.unpipe=function(d){var p=this._readableState,x={hasUnpiped:!1};if(p.pipesCount===0)return this;if(p.pipesCount===1)return d&&d!==p.pipes?this:(d||(d=p.pipes),p.pipes=null,p.pipesCount=0,p.flowing=!1,d&&d.emit("unpipe",this,x),this);if(!d){var H=p.pipes,X=p.pipesCount;p.pipes=null,p.pipesCount=0,p.flowing=!1;for(var Z=0;Z<X;Z++)H[Z].emit("unpipe",this,{hasUnpiped:!1});return this}var te=V(p.pipes,d);return te===-1?this:(p.pipes.splice(te,1),p.pipesCount-=1,p.pipesCount===1&&(p.pipes=p.pipes[0]),d.emit("unpipe",this,x),this)},F.prototype.on=function(d,p){var x=o.prototype.on.call(this,d,p),H=this._readableState;return d==="data"?(H.readableListening=this.listenerCount("readable")>0,H.flowing!==!1&&this.resume()):d==="readable"&&!H.endEmitted&&!H.readableListening&&(H.readableListening=H.needReadable=!0,H.flowing=!1,H.emittedReadable=!1,u("on readable",H.length,H.reading),H.length?de(this):H.reading||n.nextTick($,this)),x},F.prototype.addListener=F.prototype.on,F.prototype.removeListener=function(d,p){var x=o.prototype.removeListener.call(this,d,p);return d==="readable"&&n.nextTick(L,this),x},F.prototype.removeAllListeners=function(d){var p=o.prototype.removeAllListeners.apply(this,arguments);return(d==="readable"||d===void 0)&&n.nextTick(L,this),p};function L(d){var p=d._readableState;p.readableListening=d.listenerCount("readable")>0,p.resumeScheduled&&!p.paused?p.flowing=!0:d.listenerCount("data")>0&&d.resume()}function $(d){u("readable nexttick read 0"),d.read(0)}F.prototype.resume=function(){var d=this._readableState;return d.flowing||(u("resume"),d.flowing=!d.readableListening,G(this,d)),d.paused=!1,this};function G(d,p){p.resumeScheduled||(p.resumeScheduled=!0,n.nextTick(K,d,p))}function K(d,p){u("resume",p.reading),p.reading||d.read(0),p.resumeScheduled=!1,d.emit("resume"),M(d),p.flowing&&!p.reading&&d.read(0)}F.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function M(d){var p=d._readableState;for(u("flow",p.flowing);p.flowing&&d.read()!==null;);}F.prototype.wrap=function(d){var p=this,x=this._readableState,H=!1;d.on("end",function(){if(u("wrapped end"),x.decoder&&!x.ended){var te=x.decoder.end();te&&te.length&&p.push(te)}p.push(null)}),d.on("data",function(te){if(u("wrapped data"),x.decoder&&(te=x.decoder.write(te)),!(x.objectMode&&te==null)&&!(!x.objectMode&&(!te||!te.length))){var q=p.push(te);q||(H=!0,d.pause())}});for(var X in d)this[X]===void 0&&typeof d[X]=="function"&&(this[X]=function(q){return function(){return d[q].apply(d,arguments)}}(X));for(var Z=0;Z<g.length;Z++)d.on(g[Z],this.emit.bind(this,g[Z]));return this._read=function(te){u("wrapped _read",te),H&&(H=!1,d.resume())},this},typeof Symbol=="function"&&(F.prototype[Symbol.asyncIterator]=function(){return _===void 0&&(_=ya()),_(this)}),Object.defineProperty(F.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(F.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(F.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(p){this._readableState&&(this._readableState.flowing=p)}}),F._fromList=O,Object.defineProperty(F.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function O(d,p){if(p.length===0)return null;var x;return p.objectMode?x=p.buffer.shift():!d||d>=p.length?(p.decoder?x=p.buffer.join(""):p.buffer.length===1?x=p.buffer.first():x=p.buffer.concat(p.length),p.buffer.clear()):x=p.buffer.consume(d,p.decoder),x}function D(d){var p=d._readableState;u("endReadable",p.endEmitted),p.endEmitted||(p.ended=!0,n.nextTick(z,p,d))}function z(d,p){if(u("endReadableNT",d.endEmitted,d.length),!d.endEmitted&&d.length===0&&(d.endEmitted=!0,p.readable=!1,p.emit("end"),d.autoDestroy)){var x=p._writableState;(!x||x.autoDestroy&&x.finished)&&p.destroy()}}typeof Symbol=="function"&&(F.from=function(d,p){return R===void 0&&(R=ma()),R(F,d,p)});function V(d,p){for(var x=0,H=d.length;x<H;x++)if(d[x]===p)return x;return-1}return $r}var Ur,Ki;function Xi(){if(Ki)return Ur;Ki=1,Ur=a;var n=Ue().codes,e=n.ERR_METHOD_NOT_IMPLEMENTED,t=n.ERR_MULTIPLE_CALLBACK,o=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,l=n.ERR_TRANSFORM_WITH_LENGTH_0,c=qe();$e()(a,c);function E(w,A){var C=this._transformState;C.transforming=!1;var j=C.writecb;if(j===null)return this.emit("error",new t);C.writechunk=null,C.writecb=null,A!=null&&this.push(A),j(w);var y=this._readableState;y.reading=!1,(y.needReadable||y.length<y.highWaterMark)&&this._read(y.highWaterMark)}function a(w){if(!(this instanceof a))return new a(w);c.call(this,w),this._transformState={afterTransform:E.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,w&&(typeof w.transform=="function"&&(this._transform=w.transform),typeof w.flush=="function"&&(this._flush=w.flush)),this.on("prefinish",f)}function f(){var w=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(A,C){u(w,A,C)}):u(this,null,null)}a.prototype.push=function(w,A){return this._transformState.needTransform=!1,c.prototype.push.call(this,w,A)},a.prototype._transform=function(w,A,C){C(new e("_transform()"))},a.prototype._write=function(w,A,C){var j=this._transformState;if(j.writecb=C,j.writechunk=w,j.writeencoding=A,!j.transforming){var y=this._readableState;(j.needTransform||y.needReadable||y.length<y.highWaterMark)&&this._read(y.highWaterMark)}},a.prototype._read=function(w){var A=this._transformState;A.writechunk!==null&&!A.transforming?(A.transforming=!0,this._transform(A.writechunk,A.writeencoding,A.afterTransform)):A.needTransform=!0},a.prototype._destroy=function(w,A){c.prototype._destroy.call(this,w,function(C){A(C)})};function u(w,A,C){if(A)return w.emit("error",A);if(C!=null&&w.push(C),w._writableState.length)throw new l;if(w._transformState.transforming)throw new o;return w.push(null)}return Ur}var qr,Zi;function va(){if(Zi)return qr;Zi=1,qr=e;var n=Xi();$e()(e,n);function e(t){if(!(this instanceof e))return new e(t);n.call(this,t)}return e.prototype._transform=function(t,o,l){l(null,t)},qr}var xr,Qi;function ba(){if(Qi)return xr;Qi=1;var n;function e(C){var j=!1;return function(){j||(j=!0,C.apply(void 0,arguments))}}var t=Ue().codes,o=t.ERR_MISSING_ARGS,l=t.ERR_STREAM_DESTROYED;function c(C){if(C)throw C}function E(C){return C.setHeader&&typeof C.abort=="function"}function a(C,j,y,I){I=e(I);var S=!1;C.on("close",function(){S=!0}),n===void 0&&(n=Dr()),n(C,{readable:j,writable:y},function(b){if(b)return I(b);S=!0,I()});var h=!1;return function(b){if(!S&&!h){if(h=!0,E(C))return C.abort();if(typeof C.destroy=="function")return C.destroy();I(b||new l("pipe"))}}}function f(C){C()}function u(C,j){return C.pipe(j)}function w(C){return!C.length||typeof C[C.length-1]!="function"?c:C.pop()}function A(){for(var C=arguments.length,j=new Array(C),y=0;y<C;y++)j[y]=arguments[y];var I=w(j);if(Array.isArray(j[0])&&(j=j[0]),j.length<2)throw new o("streams");var S,h=j.map(function(b,P){var _=P<j.length-1,R=P>0;return a(b,_,R,function(v){S||(S=v),v&&h.forEach(f),!_&&(h.forEach(f),I(S))})});return j.reduce(u)}return xr=A,xr}var eo;function wa(){return eo||(eo=1,function(n,e){e=n.exports=Yi(),e.Stream=e,e.Readable=e,e.Writable=qi(),e.Duplex=qe(),e.Transform=Xi(),e.PassThrough=va(),e.finished=Dr(),e.pipeline=ba()}(ot,ot.exports)),ot.exports}/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Wr,to;function _a(){if(to)return Wr;to=1;let n;return Wr=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window!="undefined"?window:globalThis):e=>(n||(n=Promise.resolve())).then(e).catch(t=>setTimeout(()=>{throw t},0)),Wr}var zr,ro;function Sa(){if(ro)return zr;ro=1;function n(t,o){for(const l in o)Object.defineProperty(t,l,{value:o[l],enumerable:!0,configurable:!0});return t}function e(t,o,l){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");l||(l={}),typeof o=="object"&&(l=o,o=""),o&&(l.code=o);try{return n(t,l)}catch(c){l.message=t.message,l.stack=t.stack;const E=function(){};return E.prototype=Object.create(Object.getPrototypeOf(t)),n(new E,l)}}return zr=e,zr}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Gr,no;function Ca(){if(no)return Gr;no=1;const n=ko()("simple-peer"),e=Mo(),t=Bo(),o=wa(),l=_a(),c=Sa(),{Buffer:E}=He(),a=64*1024,f=5*1e3,u=5*1e3;function w(j){return j.replace(/a=ice-options:trickle\s\n/g,"")}function A(j){console.warn(j)}class C extends o.Duplex{constructor(y){if(y=Object.assign({allowHalfOpen:!1},y),super(y),this._id=t(4).toString("hex").slice(0,7),this._debug("new peer %o",y),this.channelName=y.initiator?y.channelName||t(20).toString("hex"):null,this.initiator=y.initiator||!1,this.channelConfig=y.channelConfig||C.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},C.config,y.config),this.offerOptions=y.offerOptions||{},this.answerOptions=y.answerOptions||{},this.sdpTransform=y.sdpTransform||(I=>I),this.streams=y.streams||(y.stream?[y.stream]:[]),this.trickle=y.trickle!==void 0?y.trickle:!0,this.allowHalfTrickle=y.allowHalfTrickle!==void 0?y.allowHalfTrickle:!1,this.iceCompleteTimeout=y.iceCompleteTimeout||f,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=y.wrtc&&typeof y.wrtc=="object"?y.wrtc:e(),!this._wrtc)throw c(typeof window=="undefined"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(I){this.destroy(c(I,"ERR_PC_CONSTRUCTOR"));return}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=I=>{this._onIceCandidate(I)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(I=>{this.destroy(c(I,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=I=>{this._setupData(I)},this.streams&&this.streams.forEach(I=>{this.addStream(I)}),this._pc.ontrack=I=>{this._onTrack(I)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof y=="string")try{y=JSON.parse(y)}catch(I){y={}}this._debug("signal()"),y.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),y.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(y.transceiverRequest.kind,y.transceiverRequest.init)),y.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(y.candidate):this._pendingCandidates.push(y.candidate)),y.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(y)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(I=>{this._addIceCandidate(I)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(I=>{this.destroy(c(I,"ERR_SET_REMOTE_DESCRIPTION"))}),!y.sdp&&!y.candidate&&!y.renegotiate&&!y.transceiverRequest&&this.destroy(c(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(y){const I=new this._wrtc.RTCIceCandidate(y);this._pc.addIceCandidate(I).catch(S=>{!I.address||I.address.endsWith(".local")?A("Ignoring unsupported ICE candidate."):this.destroy(c(S,"ERR_ADD_ICE_CANDIDATE"))})}send(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(y)}}addTransceiver(y,I){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(y,I),this._needsNegotiation()}catch(S){this.destroy(c(S,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:y,init:I}})}}addStream(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),y.getTracks().forEach(I=>{this.addTrack(I,y)})}}addTrack(y,I){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const S=this._senderMap.get(y)||new Map;let h=S.get(I);if(!h)h=this._pc.addTrack(y,I),S.set(I,h),this._senderMap.set(y,S),this._needsNegotiation();else throw h.removed?c(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):c(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(y,I,S){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const h=this._senderMap.get(y),b=h?h.get(S):null;if(!b)throw c(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");I&&this._senderMap.set(I,h),b.replaceTrack!=null?b.replaceTrack(I):this.destroy(c(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(y,I){if(this.destroying)return;if(this.destroyed)throw c(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const S=this._senderMap.get(y),h=S?S.get(I):null;if(!h)throw c(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{h.removed=!0,this._pc.removeTrack(h)}catch(b){b.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(h):this.destroy(c(b,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(y){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),y.getTracks().forEach(I=>{this.removeTrack(I,y)})}}_needsNegotiation(){this._debug("_needsNegotiation"),!this._batchedNegotiation&&(this._batchedNegotiation=!0,l(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw c(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(y){this._destroy(y,()=>{})}_destroy(y,I){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",y&&(y.message||y)),l(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",y&&(y.message||y)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(S){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(S){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,y&&this.emit("error",y),this.emit("close"),I()}))}_setupData(y){if(!y.channel)return this.destroy(c(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=y.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=a),this.channelName=this._channel.label,this._channel.onmessage=S=>{this._onChannelMessage(S)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=S=>{const h=S.error instanceof Error?S.error:new Error(`Datachannel error: ${S.message} ${S.filename}:${S.lineno}:${S.colno}`);this.destroy(c(h,"ERR_DATA_CHANNEL"))};let I=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(I&&this._onChannelClose(),I=!0):I=!1},u)}_read(){}_write(y,I,S){if(this.destroyed)return S(c(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(y)}catch(h){return this.destroy(c(h,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>a?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=S):S(null)}else this._debug("write before connect"),this._chunk=y,this._cb=S}_onFinish(){if(this.destroyed)return;const y=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?y():this.once("connect",y)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(y=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(y.sdp=w(y.sdp)),y.sdp=this.sdpTransform(y.sdp);const I=()=>{if(this.destroyed)return;const b=this._pc.localDescription||y;this._debug("signal"),this.emit("signal",{type:b.type,sdp:b.sdp})},S=()=>{this._debug("createOffer success"),!this.destroyed&&(this.trickle||this._iceComplete?I():this.once("_iceComplete",I))},h=b=>{this.destroy(c(b,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(y).then(S).catch(h)}).catch(y=>{this.destroy(c(y,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(y=>{!y.mid&&y.sender.track&&!y.requested&&(y.requested=!0,this.addTransceiver(y.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(y=>{if(this.destroyed)return;!this.trickle&&!this.allowHalfTrickle&&(y.sdp=w(y.sdp)),y.sdp=this.sdpTransform(y.sdp);const I=()=>{if(this.destroyed)return;const b=this._pc.localDescription||y;this._debug("signal"),this.emit("signal",{type:b.type,sdp:b.sdp}),this.initiator||this._requestMissingTransceivers()},S=()=>{this.destroyed||(this.trickle||this._iceComplete?I():this.once("_iceComplete",I))},h=b=>{this.destroy(c(b,"ERR_SET_LOCAL_DESCRIPTION"))};this._pc.setLocalDescription(y).then(S).catch(h)}).catch(y=>{this.destroy(c(y,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(c(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const y=this._pc.iceConnectionState,I=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",y,I),this.emit("iceStateChange",y,I),(y==="connected"||y==="completed")&&(this._pcReady=!0,this._maybeReady()),y==="failed"&&this.destroy(c(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),y==="closed"&&this.destroy(c(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(y){const I=S=>(Object.prototype.toString.call(S.values)==="[object Array]"&&S.values.forEach(h=>{Object.assign(S,h)}),S);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(S=>{const h=[];S.forEach(b=>{h.push(I(b))}),y(null,h)},S=>y(S)):this._pc.getStats.length>0?this._pc.getStats(S=>{if(this.destroyed)return;const h=[];S.result().forEach(b=>{const P={};b.names().forEach(_=>{P[_]=b.stat(_)}),P.id=b.id,P.type=b.type,P.timestamp=b.timestamp,h.push(I(P))}),y(null,h)},S=>y(S)):y(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const y=()=>{this.destroyed||this.getStats((I,S)=>{if(this.destroyed)return;I&&(S=[]);const h={},b={},P={};let _=!1;S.forEach(v=>{(v.type==="remotecandidate"||v.type==="remote-candidate")&&(h[v.id]=v),(v.type==="localcandidate"||v.type==="local-candidate")&&(b[v.id]=v),(v.type==="candidatepair"||v.type==="candidate-pair")&&(P[v.id]=v)});const R=v=>{_=!0;let g=b[v.localCandidateId];g&&(g.ip||g.address)?(this.localAddress=g.ip||g.address,this.localPort=Number(g.port)):g&&g.ipAddress?(this.localAddress=g.ipAddress,this.localPort=Number(g.portNumber)):typeof v.googLocalAddress=="string"&&(g=v.googLocalAddress.split(":"),this.localAddress=g[0],this.localPort=Number(g[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let B=h[v.remoteCandidateId];B&&(B.ip||B.address)?(this.remoteAddress=B.ip||B.address,this.remotePort=Number(B.port)):B&&B.ipAddress?(this.remoteAddress=B.ipAddress,this.remotePort=Number(B.portNumber)):typeof v.googRemoteAddress=="string"&&(B=v.googRemoteAddress.split(":"),this.remoteAddress=B[0],this.remotePort=Number(B[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(S.forEach(v=>{v.type==="transport"&&v.selectedCandidatePairId&&R(P[v.selectedCandidatePairId]),(v.type==="googCandidatePair"&&v.googActiveConnection==="true"||(v.type==="candidatepair"||v.type==="candidate-pair")&&v.selected)&&R(v)}),!_&&(!Object.keys(P).length||Object.keys(b).length)){setTimeout(y,100);return}else this._connecting=!1,this._connected=!0;if(this._chunk){try{this.send(this._chunk)}catch(g){return this.destroy(c(g,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const v=this._cb;this._cb=null,v(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};y()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>a||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(y=>{this._pc.removeTrack(y),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(y){this.destroyed||(y.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:y.candidate.candidate,sdpMLineIndex:y.candidate.sdpMLineIndex,sdpMid:y.candidate.sdpMid}}):!y.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),y.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(y){if(this.destroyed)return;let I=y.data;I instanceof ArrayBuffer&&(I=E.from(I)),this.push(I)}_onChannelBufferedAmountLow(){if(this.destroyed||!this._cb)return;this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const y=this._cb;this._cb=null,y(null)}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(y){this.destroyed||y.streams.forEach(I=>{this._debug("on track"),this.emit("track",y.track,I),this._remoteTracks.push({track:y.track,stream:I}),!this._remoteStreams.some(S=>S.id===I.id)&&(this._remoteStreams.push(I),l(()=>{this._debug("on stream"),this.emit("stream",I)}))})}_debug(){const y=[].slice.call(arguments);y[0]="["+this._id+"] "+y[0],n.apply(null,y)}}return C.WEBRTC_SUPPORT=!!e(),C.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},C.channelConfig={},Gr=C,Gr}var Ea=Ca();const Ra=yt(Ea);var Pa=Object.defineProperty,Aa=(n,e,t)=>e in n?Pa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,De=(n,e,t)=>Aa(n,typeof e!="symbol"?e+"":e,t),Vr=(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 io{constructor(e,t,o={}){De(this,"peer",null),De(this,"config"),De(this,"events"),De(this,"connectionState","new"),De(this,"isInitiator"),De(this,"remoteUserId"),De(this,"localStream",null),this.remoteUserId=e,this.config=t,this.events=o,this.isInitiator=t.initiator||!1}createConnection(e){return Vr(this,null,function*(){try{console.log(`[CallPeerConnection] Creating connection to ${this.remoteUserId}, initiator: ${this.isInitiator}`),this.localStream=e||null;const t={initiator:this.isInitiator,trickle:!0,stream:this.localStream||void 0,config:{iceServers:this.config.iceServers}};this.peer=new Ra(t),this.setupPeerEventListeners(),console.log(`[CallPeerConnection] Peer connection created for ${this.remoteUserId}`)}catch(t){throw console.error(`[CallPeerConnection] Failed to create connection to ${this.remoteUserId}:`,t),t}})}signal(e){var t,o;if(!this.peer){console.error(`[CallPeerConnection] Cannot signal to ${this.remoteUserId}: peer not initialized`);return}try{console.log(`[CallPeerConnection] Signaling to ${this.remoteUserId}:`,e.type),this.peer.signal(e)}catch(l){console.error(`[CallPeerConnection] Failed to signal to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}addStream(e){var t,o;if(!this.peer){console.error(`[CallPeerConnection] Cannot add stream to ${this.remoteUserId}: peer not initialized`);return}try{this.localStream&&this.removeStream(this.localStream),this.localStream=e,this.peer.addStream(e),console.log(`[CallPeerConnection] Stream added to ${this.remoteUserId}`)}catch(l){console.error(`[CallPeerConnection] Failed to add stream to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}removeStream(e){var t,o;if(!this.peer){console.error(`[CallPeerConnection] Cannot remove stream from ${this.remoteUserId}: peer not initialized`);return}try{this.peer.removeStream(e),this.localStream===e&&(this.localStream=null),console.log(`[CallPeerConnection] Stream removed from ${this.remoteUserId}`)}catch(l){console.error(`[CallPeerConnection] Failed to remove stream from ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}replaceTrack(e,t){var o,l;if(!this.peer){console.error(`[CallPeerConnection] Cannot replace track for ${this.remoteUserId}: peer not initialized`);return}try{this.peer.replaceTrack(e,t,this.localStream),console.log(`[CallPeerConnection] Track replaced for ${this.remoteUserId}`)}catch(c){console.error(`[CallPeerConnection] Failed to replace track for ${this.remoteUserId}:`,c),(l=(o=this.events).onError)==null||l.call(o,c)}}sendData(e){var t,o;if(!this.peer){console.error(`[CallPeerConnection] Cannot send data to ${this.remoteUserId}: peer not initialized`);return}if(!this.peer.connected){console.warn(`[CallPeerConnection] Cannot send data to ${this.remoteUserId}: not connected`);return}try{this.peer.send(JSON.stringify(e))}catch(l){console.error(`[CallPeerConnection] Failed to send data to ${this.remoteUserId}:`,l),(o=(t=this.events).onError)==null||o.call(t,l)}}setBandwidthLimit(e){return Vr(this,null,function*(){if(!this.peer){console.warn(`[CallPeerConnection] Cannot set bandwidth for ${this.remoteUserId}: peer connection not available`);return}try{const t=this.peer._pc;if(!t)return;const o=t.getSenders();for(const l of o)if(l.track){const c=l.getParameters();c.encodings||(c.encodings=[{}]),c.encodings[0].maxBitrate=e*1e3,yield l.setParameters(c)}console.log(`[CallPeerConnection] Bandwidth limit set to ${e}kbps for ${this.remoteUserId}`)}catch(t){console.error(`[CallPeerConnection] Failed to set bandwidth limit for ${this.remoteUserId}:`,t)}})}getConnectionState(){return this.connectionState}isConnected(){var e;return((e=this.peer)==null?void 0:e.connected)===!0}getStats(){return Vr(this,null,function*(){if(!this.peer)return null;try{const e=this.peer._pc;return e?yield e.getStats():null}catch(e){return console.error(`[CallPeerConnection] Failed to get stats for ${this.remoteUserId}:`,e),null}})}getRemoteUserId(){return this.remoteUserId}destroy(){if(console.log(`[CallPeerConnection] Destroying connection to ${this.remoteUserId}`),this.peer){try{this.peer.destroy()}catch(e){console.error(`[CallPeerConnection] Error destroying peer for ${this.remoteUserId}:`,e)}this.peer=null}this.localStream=null,this.connectionState="closed"}setupPeerEventListeners(){if(!this.peer)return;this.peer.on("signal",t=>{var o,l;console.log(`[CallPeerConnection] Signal from ${this.remoteUserId}:`,t.type),(l=(o=this.events).onSignal)==null||l.call(o,t)}),this.peer.on("connect",()=>{var t,o;console.log(`[CallPeerConnection] Connected to ${this.remoteUserId}`),this.connectionState="connected",(o=(t=this.events).onConnect)==null||o.call(t)}),this.peer.on("data",t=>{var o,l;try{const c=JSON.parse(t.toString());(l=(o=this.events).onData)==null||l.call(o,c)}catch(c){console.error(`[CallPeerConnection] Failed to parse data from ${this.remoteUserId}:`,c)}}),this.peer.on("stream",t=>{var o,l;console.log(`[CallPeerConnection] Stream received from ${this.remoteUserId}`),(l=(o=this.events).onStream)==null||l.call(o,t)}),this.peer.on("track",(t,o)=>{var l,c;console.log(`[CallPeerConnection] Track received from ${this.remoteUserId}:`,t.kind),(c=(l=this.events).onTrack)==null||c.call(l,t,o)}),this.peer.on("close",()=>{var t,o;console.log(`[CallPeerConnection] Connection closed with ${this.remoteUserId}`),this.connectionState="closed",(o=(t=this.events).onClose)==null||o.call(t)}),this.peer.on("error",t=>{var o,l;console.error(`[CallPeerConnection] Error with ${this.remoteUserId}:`,t),this.connectionState="failed",(l=(o=this.events).onError)==null||l.call(o,t)});const e=this.peer._pc;e&&e.addEventListener("connectionstatechange",()=>{if(this.peer){const t=this.peer._pc;t&&(this.connectionState=t.connectionState,console.log(`[CallPeerConnection] Connection state changed for ${this.remoteUserId}:`,this.connectionState))}})}getConnectionInfo(){return{remoteUserId:this.remoteUserId,isInitiator:this.isInitiator,connectionState:this.connectionState,connected:this.isConnected(),hasLocalStream:!!this.localStream,localStreamTracks:this.localStream?{video:this.localStream.getVideoTracks().length,audio:this.localStream.getAudioTracks().length}:null}}}const oo={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Xe=new Map,ut=n=>{const e=Xe.get(n);return e?Object.fromEntries(Object.entries(e.stores).map(([t,o])=>[t,o.getState()])):{}},Ta=(n,e,t)=>{if(n===void 0)return{type:"untracked",connection:e.connect(t)};const o=Xe.get(t.name);if(o)return Qe({type:"tracked",store:n},o);const l={connection:e.connect(t),stores:{}};return Xe.set(t.name,l),Qe({type:"tracked",store:n},l)},Ia=(n,e)=>{if(e===void 0)return;const t=Xe.get(n);t&&(delete t.stores[e],Object.keys(t.stores).length===0&&Xe.delete(n))},Oa=n=>{var e,t;if(!n)return;const o=n.split(`
17
17
  `),l=o.findIndex(E=>E.includes("api.setState"));if(l<0)return;const c=((e=o[l+1])==null?void 0:e.trim())||"";return(t=/.+ (.+) .+/.exec(c))==null?void 0:t[1]},ka=(n,e={})=>(t,o,l)=>{const I=e,{enabled:c,anonymousActionType:E,store:a}=I,f=ln(I,["enabled","anonymousActionType","store"]);let u;try{u=(c!=null?c:(oo?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch(h){}if(!u)return n(t,o,l);const S=Ta(a,u,f),{connection:w}=S,A=ln(S,["connection"]);let C=!0;l.setState=(h,b,P)=>{const _=t(h,b);if(!C)return _;const R=P===void 0?{type:E||Oa(new Error().stack)||"anonymous"}:typeof P=="string"?{type:P}:P;return a===void 0?(w==null||w.send(R,o()),_):(w==null||w.send(sn(Qe({},R),{type:`${a}/${R.type}`}),sn(Qe({},ut(f.name)),{[a]:l.getState()})),_)},l.devtools={cleanup:()=>{w&&typeof w.unsubscribe=="function"&&w.unsubscribe(),Ia(f.name,a)}};const j=(...h)=>{const b=C;C=!1,t(...h),C=b},y=n(l.setState,o,l);if(A.type==="untracked"?w==null||w.init(y):(A.stores[A.store]=l,w==null||w.init(Object.fromEntries(Object.entries(A.stores).map(([h,b])=>[h,h===A.store?y:b.getState()])))),l.dispatchFromDevtools&&typeof l.dispatch=="function"){let h=!1;const b=l.dispatch;l.dispatch=(...P)=>{(oo?"production":void 0)!=="production"&&P[0].type==="__setState"&&!h&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),h=!0),b(...P)}}return w.subscribe(h=>{var b;switch(h.type){case"ACTION":if(typeof h.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Hr(h.payload,P=>{if(P.type==="__setState"){if(a===void 0){j(P.state);return}Object.keys(P.state).length!==1&&console.error(`
18
18
  [zustand devtools middleware] Unsupported __setState action format.
19
19
  When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
20
20
  and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
21
- `);const _=P.state[a];if(_==null)return;JSON.stringify(l.getState())!==JSON.stringify(_)&&j(_);return}l.dispatchFromDevtools&&typeof l.dispatch=="function"&&l.dispatch(P)});case"DISPATCH":switch(h.payload.type){case"RESET":return j(y),a===void 0?w==null?void 0:w.init(l.getState()):w==null?void 0:w.init(ut(f.name));case"COMMIT":if(a===void 0){w==null||w.init(l.getState());return}return w==null?void 0:w.init(ut(f.name));case"ROLLBACK":return Hr(h.state,P=>{if(a===void 0){j(P),w==null||w.init(l.getState());return}j(P[a]),w==null||w.init(ut(f.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return Hr(h.state,P=>{if(a===void 0){j(P);return}JSON.stringify(l.getState())!==JSON.stringify(P[a])&&j(P[a])});case"IMPORT_STATE":{const{nextLiftedState:P}=h.payload,_=(b=P.computedStates.slice(-1)[0])==null?void 0:b.state;if(!_)return;j(a===void 0?_:_[a]),w==null||w.send(null,P);return}case"PAUSE_RECORDING":return C=!C}return}}),y},Hr=(n,e)=>{let t;try{t=JSON.parse(n)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}t!==void 0&&e(t)};var Ma={env:{}},Ba=Object.defineProperty,La=Object.defineProperties,Na=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,so=Object.prototype.propertyIsEnumerable,lo=(n,e,t)=>e in n?Ba(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Fe=(n,e)=>{for(var t in e||(e={}))ao.call(e,t)&&lo(n,t,e[t]);if(ft)for(var t of ft(e))so.call(e,t)&&lo(n,t,e[t]);return n},Jr=(n,e)=>La(n,Na(e)),Da=n=>typeof n=="symbol"?n:n+"",Fa=(n,e)=>{var t={};for(var o in n)ao.call(n,o)&&e.indexOf(o)<0&&(t[o]=n[o]);if(n!=null&&ft)for(var o of ft(n))e.indexOf(o)<0&&so.call(n,o)&&(t[o]=n[o]);return t};const co={roomId:"",participants:{},localParticipant:null,isCalling:!1,isRecording:!1,recordLoading:!1,callStatus:"idle",error:null,callStatusInfo:null,callStatusLoading:!1,callStatusError:null},we=ye.create()(ka(n=>Jr(Fe({},co),{setRoomId:e=>n({roomId:e},!1,"setRoomId"),setLocalParticipant:e=>n({localParticipant:e},!1,"setLocalParticipant"),addParticipant:e=>n(t=>({participants:Jr(Fe({},t.participants),{[e.userId]:e})}),!1,"addParticipant"),removeParticipant:e=>n(t=>{const o=t.participants,{[e]:l}=o;return{participants:Fa(o,[Da(e)])}},!1,"removeParticipant"),updateParticipant:(e,t)=>n(o=>({participants:Jr(Fe({},o.participants),{[e]:o.participants[e]?Fe(Fe({},o.participants[e]),t):Fe({userId:e,videoOn:!0,audioOn:!0,screenSharing:!1},t)})}),!1,"updateParticipant"),clearParticipants:()=>n({participants:{}},!1,"clearParticipants"),setCallStatus:e=>n({callStatus:e},!1,"setCallStatus"),setIsCalling:e=>n({isCalling:e},!1,"setIsCalling"),setIsRecording:e=>n({isRecording:e},!1,"setIsRecording"),setRecordLoading:e=>n({recordLoading:e},!1,"setRecordLoading"),setError:(e,t)=>n({error:t||e},!1,"setError"),clearError:()=>n({error:null},!1,"clearError"),setCallStatusInfo:e=>n({callStatusInfo:e},!1,"setCallStatusInfo"),setCallStatusLoading:e=>n({callStatusLoading:e},!1,"setCallStatusLoading"),setCallStatusError:e=>n({callStatusError:e},!1,"setCallStatusError"),resetCall:()=>n(Fe({},co),!1,"resetCall")}),{name:"peers-caller-store",enabled:Ma.env.NODE_ENV==="development"})),ja=n=>n.participants,uo=n=>Object.keys(n.participants).length,$a=n=>n.localParticipant,Ua=n=>n.callStatus,qa=n=>n.callStatus==="connected",xa=n=>n.error,Wa=n=>n.callStatusInfo,za=n=>n.callStatusLoading,Ga=n=>n.callStatusError,Va=n=>{var e;return((e=n.callStatusInfo)==null?void 0:e.canJoin)||!1},Ha=n=>{var e;return((e=n.callStatusInfo)==null?void 0:e.hasActiveCall)||!1},fo=n=>we.getState().participants[n],Ja=n=>{const e=fo(n);return!!(e!=null&&e.stream)},Ya=()=>{const n=we.getState();return Object.values(n.participants)},Ka=(n=4)=>uo(we.getState())<n;var Xa=Object.defineProperty,Za=(n,e,t)=>e in n?Xa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Qa=(n,e,t)=>Za(n,e+"",t);class ho{constructor(e){if(Qa(this,"store"),e&&typeof e.getState=="function")this.store=e;else{const t=e;this.store={getState:()=>t}}}get state(){return this.store.getState()}}var es=Object.defineProperty,ts=Object.defineProperties,rs=Object.getOwnPropertyDescriptors,po=Object.getOwnPropertySymbols,ns=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,Yr=(n,e,t)=>e in n?es(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Kr=(n,e)=>{for(var t in e||(e={}))ns.call(e,t)&&Yr(n,t,e[t]);if(po)for(var t of po(e))is.call(e,t)&&Yr(n,t,e[t]);return n},os=(n,e)=>ts(n,rs(e)),xe=(n,e,t)=>Yr(n,typeof e!="symbol"?e+"":e,t),dt=(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 Xr extends ho{constructor(e,t={},o=!1){super(we),xe(this,"userId"),xe(this,"mediaStream",null),xe(this,"peerConnections",new Map),xe(this,"remoteStreams",new Map),xe(this,"isLocalParticipant",!1),xe(this,"callbacks"),this.userId=e,this.callbacks=t,this.isLocalParticipant=o;const l={userId:e,videoOn:!0,audioOn:!0,screenSharing:!1};this.isLocalParticipant&&this.state.setLocalParticipant(l),this.state.addParticipant(l)}initialize(e){return dt(this,null,function*(){var t,o;try{console.log(`[CallParticipant] Initializing participant ${this.userId}`),this.mediaStream=new un(e);const c={stream:yield this.mediaStream.initialize(),videoElement:this.mediaStream.createVideoElement()};this.updateState(c),console.log(`[CallParticipant] Participant ${this.userId} initialized successfully`)}catch(l){throw console.error(`[CallParticipant] Failed to initialize participant ${this.userId}:`,l),(o=(t=this.callbacks).onError)==null||o.call(t,l),l}})}createPeerConnection(e,t,o){return dt(this,null,function*(){var l,c;try{if(console.log(`[CallParticipant] Creating peer connection from ${this.userId} to ${e}`),this.peerConnections.has(e)){console.warn(`[CallParticipant] Peer connection to ${e} already exists`);return}const E={onSignal:f=>{var u,w;console.log(`[CallParticipant] Signal from ${this.userId} to ${e}:`,f.type),(w=(u=this.callbacks).onSignal)==null||w.call(u,this.userId,e,f)},onConnect:()=>{var f,u;console.log(`[CallParticipant] ${this.userId} connected to ${e}`),(u=(f=this.callbacks).onPeerConnected)==null||u.call(f,e)},onStream:f=>{var u,w;console.log(`[CallParticipant] Stream received from ${e} by ${this.userId}`),this.remoteStreams.set(e,f),this.state.updateParticipant(e,{stream:f}),(w=(u=this.callbacks).onStreamReceived)==null||w.call(u,e,f)},onClose:()=>{var f,u;console.log(`[CallParticipant] Connection closed between ${this.userId} and ${e}`),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),(u=(f=this.callbacks).onPeerDisconnected)==null||u.call(f,e)},onError:f=>{var u,w;console.error(`[CallParticipant] Peer connection error between ${this.userId} and ${e}:`,f),(w=(u=this.callbacks).onError)==null||w.call(u,f)}},a=new io(e,os(Kr({},t),{initiator:o}),E);yield a.createConnection(this.getCurrentStream()),this.peerConnections.set(e,a)}catch(E){throw console.error(`[CallParticipant] Failed to create peer connection from ${this.userId} to ${e}:`,E),(c=(l=this.callbacks).onError)==null||c.call(l,E),E}})}getPeerConnection(e){return this.peerConnections.get(e)}signalToPeer(e,t){const o=this.peerConnections.get(e);o?o.signal(t):console.warn(`[CallParticipant] No peer connection found for ${e}`)}toggleAudio(e){this.mediaStream&&(this.mediaStream.toggleAudio(e),this.updateState({audioOn:e}))}toggleVideo(e){this.mediaStream&&(this.mediaStream.toggleVideo(e),this.updateState({videoOn:e}))}startScreenShare(){return dt(this,null,function*(){var e,t;try{if(!this.mediaStream)throw new Error("Media stream not initialized");console.log(`[CallParticipant] Starting screen share for ${this.userId}`);const o=yield this.mediaStream.startScreenShare();for(const[l,c]of this.peerConnections)c.addStream(o),console.log(`[CallParticipant] Screen share stream added to connection with ${l}`);this.updateState({screenSharing:!0,stream:o}),console.log(`[CallParticipant] Screen sharing started for ${this.userId}`)}catch(o){throw console.error(`[CallParticipant] Failed to start screen share for ${this.userId}:`,o),(t=(e=this.callbacks).onError)==null||t.call(e,o),o}})}stopScreenShare(){return dt(this,null,function*(){var e,t;try{if(!this.mediaStream)throw new Error("Media stream not initialized");console.log(`[CallParticipant] Stopping screen share for ${this.userId}`);const o=yield this.mediaStream.stopScreenShare();for(const[l,c]of this.peerConnections)c.addStream(o),console.log(`[CallParticipant] Camera stream restored for connection with ${l}`);this.updateState({screenSharing:!1,stream:o}),console.log(`[CallParticipant] Screen sharing stopped for ${this.userId}`)}catch(o){throw console.error(`[CallParticipant] Failed to stop screen share for ${this.userId}:`,o),(t=(e=this.callbacks).onError)==null||t.call(e,o),o}})}getState(){const e=this.state;return this.isLocalParticipant?e.localParticipant||{userId:this.userId,videoOn:!0,audioOn:!0,screenSharing:!1}:e.participants[this.userId]||{userId:this.userId,videoOn:!0,audioOn:!0,screenSharing:!1}}getUserId(){return this.userId}getMediaStream(){return this.mediaStream}getCurrentStream(){return this.getState().stream}getVideoElement(){return this.getState().videoElement}getRemoteStream(e){return this.remoteStreams.get(e)}getAllRemoteStreams(){return new Map(this.remoteStreams)}getAllPeerConnections(){return new Map(this.peerConnections)}getConnectionStatus(){const e={};for(const[t,o]of this.peerConnections)e[t]=o.isConnected();return e}removePeerConnection(e){const t=this.peerConnections.get(e);t&&(t.destroy(),this.peerConnections.delete(e),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),console.log(`[CallParticipant] Removed peer connection from ${this.userId} to ${e}`))}updateState(e){var t,o;const l=this.getState();if(Object.keys(e).some(E=>l[E]!==e[E])){const E=Kr(Kr({},l),e);this.isLocalParticipant&&this.state.setLocalParticipant(E),this.state.updateParticipant(this.userId,e),(o=(t=this.callbacks).onStateChanged)==null||o.call(t,this.userId,e)}}getDebugInfo(){var e;return{userId:this.userId,state:this.getState(),peerConnections:Array.from(this.peerConnections.keys()),remoteStreams:Array.from(this.remoteStreams.keys()),connectionStatus:this.getConnectionStatus(),mediaStreamInfo:(e=this.mediaStream)==null?void 0:e.getStreamInfo()}}cleanup(){console.log(`[CallParticipant] Cleaning up participant ${this.userId}`),this.state.removeParticipant(this.userId);for(const e of this.peerConnections.values())e.destroy();this.peerConnections.clear(),this.remoteStreams.clear(),this.mediaStream&&(this.mediaStream.cleanup(),this.mediaStream=null),console.log(`[CallParticipant] Participant ${this.userId} cleanup completed`)}}var Zr={exports:{}},go;function as(){return go||(go=1,function(n){function e(t,o){var l="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";(function(v){typeof RecordRTC=="undefined"&&v&&typeof window=="undefined"&&typeof globalThis!="undefined"&&(globalThis.navigator={userAgent:l,getUserMedia:function(){}},globalThis.console||(globalThis.console={}),(typeof globalThis.console.log=="undefined"||typeof globalThis.console.error=="undefined")&&(globalThis.console.error=globalThis.console.log=globalThis.console.log||function(){console.log(arguments)}),typeof document=="undefined"&&(v.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var g={getContext:function(){return g},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return g},v.HTMLVideoElement=function(){}),typeof location=="undefined"&&(v.location={protocol:"file:",href:"",hash:""}),typeof screen=="undefined"&&(v.screen={width:0,height:0}),typeof A=="undefined"&&(v.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),v.window=globalThis)})(typeof globalThis!="undefined"?globalThis:null),o=o||"multi-streams-mixer";var c=[],E=!1,a=document.createElement("canvas"),f=a.getContext("2d");a.style.opacity=0,a.style.position="absolute",a.style.zIndex=-1,a.style.top="-1000em",a.style.left="-1000em",a.className=o,(document.body||document.documentElement).appendChild(a),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var u=this,w=window.AudioContext;typeof w=="undefined"&&(typeof webkitAudioContext!="undefined"&&(w=webkitAudioContext),typeof mozAudioContext!="undefined"&&(w=mozAudioContext));var A=window.URL;typeof A=="undefined"&&typeof webkitURL!="undefined"&&(A=webkitURL),typeof navigator!="undefined"&&typeof navigator.getUserMedia=="undefined"&&(typeof navigator.webkitGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.webkitGetUserMedia),typeof navigator.mozGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.mozGetUserMedia));var C=window.MediaStream;typeof C=="undefined"&&typeof webkitMediaStream!="undefined"&&(C=webkitMediaStream),typeof C!="undefined"&&typeof C.prototype.stop=="undefined"&&(C.prototype.stop=function(){this.getTracks().forEach(function(v){v.stop()})});var j={};typeof w!="undefined"?j.AudioContext=w:typeof webkitAudioContext!="undefined"&&(j.AudioContext=webkitAudioContext);function y(v,g){"srcObject"in g?g.srcObject=v:"mozSrcObject"in g?g.mozSrcObject=v:g.srcObject=v}this.startDrawingFrames=function(){I()};function I(){if(!E){var v=c.length,g=!1,B=[];if(c.forEach(function(F){F.stream||(F.stream={}),F.stream.fullcanvas?g=F:B.push(F)}),g)a.width=g.stream.width,a.height=g.stream.height;else if(B.length){a.width=v>1?B[0].width*2:B[0].width;var U=1;(v===3||v===4)&&(U=2),(v===5||v===6)&&(U=3),(v===7||v===8)&&(U=4),(v===9||v===10)&&(U=5),a.height=B[0].height*U}else a.width=u.width||360,a.height=u.height||240;g&&g instanceof HTMLVideoElement&&S(g),B.forEach(function(F,J){S(F,J)}),setTimeout(I,u.frameInterval)}}function S(v,g){if(!E){var B=0,U=0,F=v.width,J=v.height;g===1&&(B=v.width),g===2&&(U=v.height),g===3&&(B=v.width,U=v.height),g===4&&(U=v.height*2),g===5&&(B=v.width,U=v.height*2),g===6&&(U=v.height*3),g===7&&(B=v.width,U=v.height*3),typeof v.stream.left!="undefined"&&(B=v.stream.left),typeof v.stream.top!="undefined"&&(U=v.stream.top),typeof v.stream.width!="undefined"&&(F=v.stream.width),typeof v.stream.height!="undefined"&&(J=v.stream.height),f.drawImage(v,B,U,F,J),typeof v.stream.onRender=="function"&&v.stream.onRender(f,B,U,F,J,g)}}function h(){E=!1;var v=b(),g=P();return g&&g.getTracks().filter(function(B){return B.kind==="audio"}).forEach(function(B){v.addTrack(B)}),t.forEach(function(B){B.fullcanvas}),v}function b(){R();var v;"captureStream"in a?v=a.captureStream():"mozCaptureStream"in a?v=a.mozCaptureStream():u.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var g=new C;return v.getTracks().filter(function(B){return B.kind==="video"}).forEach(function(B){g.addTrack(B)}),a.stream=g,g}function P(){j.AudioContextConstructor||(j.AudioContextConstructor=new j.AudioContext),u.audioContext=j.AudioContextConstructor,u.audioSources=[],u.useGainNode===!0&&(u.gainNode=u.audioContext.createGain(),u.gainNode.connect(u.audioContext.destination),u.gainNode.gain.value=0);var v=0;if(t.forEach(function(g){if(g.getTracks().filter(function(U){return U.kind==="audio"}).length){v++;var B=u.audioContext.createMediaStreamSource(g);u.useGainNode===!0&&B.connect(u.gainNode),u.audioSources.push(B)}}),!!v)return u.audioDestination=u.audioContext.createMediaStreamDestination(),u.audioSources.forEach(function(g){g.connect(u.audioDestination)}),u.audioDestination.stream}function _(v){var g=document.createElement("video");return y(v,g),g.className=o,g.muted=!0,g.volume=0,g.width=v.width||u.width||360,g.height=v.height||u.height||240,g.play(),g}this.appendStreams=function(v){if(!v)throw"First parameter is required.";v instanceof Array||(v=[v]),v.forEach(function(g){var B=new C;if(g.getTracks().filter(function(J){return J.kind==="video"}).length){var U=_(g);U.stream=g,c.push(U),B.addTrack(g.getTracks().filter(function(J){return J.kind==="video"})[0])}if(g.getTracks().filter(function(J){return J.kind==="audio"}).length){var F=u.audioContext.createMediaStreamSource(g);u.audioDestination=u.audioContext.createMediaStreamDestination(),F.connect(u.audioDestination),B.addTrack(u.audioDestination.stream.getTracks().filter(function(J){return J.kind==="audio"})[0])}t.push(B)})},this.releaseStreams=function(){c=[],E=!0,u.gainNode&&(u.gainNode.disconnect(),u.gainNode=null),u.audioSources.length&&(u.audioSources.forEach(function(v){v.disconnect()}),u.audioSources=[]),u.audioDestination&&(u.audioDestination.disconnect(),u.audioDestination=null),u.audioContext&&u.audioContext.close(),u.audioContext=null,f.clearRect(0,0,a.width,a.height),a.stream&&(a.stream.stop(),a.stream=null)},this.resetVideoStreams=function(v){v&&!(v instanceof Array)&&(v=[v]),R(v)};function R(v){c=[],v=v||t,v.forEach(function(g){if(g.getTracks().filter(function(U){return U.kind==="video"}).length){var B=_(g);B.stream=g,c.push(B)}})}this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=h}typeof RecordRTC=="undefined"&&(n.exports=e)}(Zr)),Zr.exports}var ss=as();const ls=yt(ss);var cs=_t();const us=yt(cs);class fs extends us{constructor(t,o=navigator.language){super();Te(this,"track",null);Te(this,"trackId",null);Te(this,"recognition",null);Te(this,"recognizing",!1);Te(this,"transcripts",[]);Te(this,"startTime",0);Te(this,"endTime",0);Te(this,"currentStamp",0);Te(this,"start",()=>(this.recognition.start(),this.recognition.stream=this.track,this.recognizing=!0,this.startTime=performance.now(),this));Te(this,"stop",()=>(this.recognition.stop(),this.recognizing=!1,this.endTime=performance.now(),this));("webkitSpeechRecognition"in window||"SpeechRecognition"in window)&&(this.recognition=new(window.SpeechRecognition||window.webkitSpeechRecognition),this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.lang=o,this.track=t,this.recognition.onstart=this.emit("start"),this.recognition.onend=()=>this.emit("end"),this.recognition.onresult=l=>{const{results:c,resultIndex:E}=l;let a="";if(c[E].isFinal&&c[E][0].transcript){const f={sentence:c[E][0].transcript,confidence:c[E][0].confidence,timeStamp:this.currentStamp,endTimeStamp:new Date().getTime()};this.transcripts.push(f),this.emit("sentence",f)}else this.currentStamp=new Date().getTime(),a+=c[E][0].transcript,this.emit("interim",{sentence:a,timeStamp:this.currentStamp});this.emit("result",l)})}}var ds=Object.defineProperty,yo=Object.getOwnPropertySymbols,hs=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable,Qr=(n,e,t)=>e in n?ds(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,gs=(n,e)=>{for(var t in e||(e={}))hs.call(e,t)&&Qr(n,t,e[t]);if(yo)for(var t of yo(e))ps.call(e,t)&&Qr(n,t,e[t]);return n},We=(n,e,t)=>Qr(n,typeof e!="symbol"?e+"":e,t),en=(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 mo{constructor(e={},t={}){We(this,"mixer",null),We(this,"recorder",null),We(this,"localTranscriber",null),We(this,"isRecording",!1),We(this,"config"),We(this,"callbacks"),this.config=gs({mimeType:"video/webm;codecs=vp8,opus",videoBitsPerSecond:1e6,audioBitsPerSecond:128e3,interval:1e3},e),this.callbacks=t}startRecording(e,t){return en(this,null,function*(){var o,l,c,E;try{if(console.log("[CallRecorder] Starting recording with",e.length,"streams"),this.isRecording)throw new Error("Recording already in progress");if(!t)throw new Error("Recording data is required");this.mixer=new ls(e),this.mixer.frameInterval=1,this.mixer.startDrawingFrames();const a=e[0];a&&a.getAudioTracks().length>0&&(this.localTranscriber=new fs(a)),MediaRecorder.isTypeSupported(this.config.mimeType)||(console.warn("[CallRecorder] Preferred mime type not supported, falling back to default"),this.config.mimeType="video/webm");const f=this.mixer.getMixedStream();this.recorder=new MediaRecorder(f,{mimeType:this.config.mimeType,videoBitsPerSecond:this.config.videoBitsPerSecond,audioBitsPerSecond:this.config.audioBitsPerSecond}),this.setupRecorderEventHandlers(t),this.recorder.start(this.config.interval),this.isRecording=!0,this.localTranscriber&&this.localTranscriber.start(),(l=(o=this.callbacks).onRecordingStarted)==null||l.call(o,t),console.log("[CallRecorder] Recording started successfully")}catch(a){throw console.error("[CallRecorder] Failed to start recording:",a),(E=(c=this.callbacks).onError)==null||E.call(c,a),a}})}stopRecording(){return en(this,null,function*(){var e,t;try{if(console.log("[CallRecorder] Stopping recording"),!this.isRecording||!this.recorder)return console.warn("[CallRecorder] No active recording to stop"),[];this.recorder.stop(),this.isRecording=!1;let o=[];return this.localTranscriber&&(this.localTranscriber.stop(),o=this.localTranscriber.transcripts||[]),this.mixer&&this.mixer.releaseStreams(),console.log("[CallRecorder] Recording stopped successfully"),o}catch(o){return console.error("[CallRecorder] Failed to stop recording:",o),(t=(e=this.callbacks).onError)==null||t.call(e,o),[]}})}resetVideoStreams(e){this.mixer&&(this.mixer.resetVideoStreams(e),console.log("[CallRecorder] Video streams reset"))}setupRecorderEventHandlers(e){this.recorder&&(this.recorder.ondataavailable=t=>{var o,l;t.data&&t.data.size>0&&((l=(o=this.callbacks).onRecordingChunk)==null||l.call(o,t.data,e))},this.recorder.onstart=()=>{console.log("[CallRecorder] MediaRecorder started")},this.recorder.onstop=()=>{var t,o;console.log("[CallRecorder] MediaRecorder stopped"),(o=(t=this.callbacks).onRecordingStopped)==null||o.call(t,e)},this.recorder.onerror=t=>{var o,l;console.error("[CallRecorder] MediaRecorder error:",t),(l=(o=this.callbacks).onError)==null||l.call(o,new Error(`Recording error: ${t}`))})}getRecordingState(){var e,t;return{isRecording:this.isRecording,isTranscribing:this.localTranscriber!==null,transcriptCount:((t=(e=this.localTranscriber)==null?void 0:e.transcripts)==null?void 0:t.length)||0}}getTranscripts(){var e;return((e=this.localTranscriber)==null?void 0:e.transcripts)||[]}static isRecordingSupported(){return typeof MediaRecorder!="undefined"&&typeof MediaRecorder.isTypeSupported=="function"}static isTranscriptionSupported(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}static getSupportedMimeTypes(){return["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=h264,opus","video/webm","video/mp4;codecs=h264,aac","video/mp4"].filter(t=>MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported(t))}cleanup(){return en(this,null,function*(){console.log("[CallRecorder] Cleaning up recorder"),this.isRecording&&(yield this.stopRecording()),this.localTranscriber&&(this.localTranscriber.stop(),this.localTranscriber=null),this.mixer&&(this.mixer.releaseStreams(),this.mixer=null),this.recorder=null})}}var ys=Object.defineProperty,ms=Object.defineProperties,vs=Object.getOwnPropertyDescriptors,vo=Object.getOwnPropertySymbols,bs=Object.prototype.hasOwnProperty,ws=Object.prototype.propertyIsEnumerable,tn=(n,e,t)=>e in n?ys(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_s=(n,e)=>{for(var t in e||(e={}))bs.call(e,t)&&tn(n,t,e[t]);if(vo)for(var t of vo(e))ws.call(e,t)&&tn(n,t,e[t]);return n},Ss=(n,e)=>ms(n,vs(e)),Pe=(n,e,t)=>tn(n,typeof e!="symbol"?e+"":e,t),me=(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 bo extends ho{constructor(e,t={}){if(super(we),Pe(this,"config"),Pe(this,"callbacks"),Pe(this,"socket"),Pe(this,"localParticipant",null),Pe(this,"participants",new Map),Pe(this,"recorder",null),Pe(this,"iceServers",[]),Pe(this,"isInitialized",!1),Pe(this,"listenersSetup",!1),Pe(this,"roomId"),Pe(this,"eventListeners",new Map),this.roomId=e.roomId,!this.roomId)throw new Error("roomId must be provided in config");this.config=Ss(_s({maxParticipants:4,debug:!1,socketPath:"/apis/video-call",mediaConfig:{video:!0,audio:!0}},e),{roomId:this.roomId}),this.callbacks=t,this.socket=new cn(this.config.socketUrl,this.config.token,this.config.socketPath),this.iceServers=this.config.iceServers||[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}],this.state.setRoomId(this.roomId),console.log("[PeersCaller] Initialized with config:",{roomId:this.roomId,tokenLength:this.config.token.length,maxParticipants:this.config.maxParticipants})}initialize(){return me(this,null,function*(){try{if(console.log("[PeersCaller] Initializing..."),this.isInitialized){console.warn("[PeersCaller] Already initialized");return}yield this.socket.connect(),yield this.fetchIceServers(),this.setupSocketListeners(),yield this.initializeLocalParticipant(),this.isInitialized=!0,this.state.setCallStatus("idle"),console.log("[PeersCaller] Initialization completed successfully (ready to start/join call)")}catch(e){throw console.error("[PeersCaller] Initialization failed:",e),this.handleError("NETWORK_ERROR",`Failed to initialize: ${e}`),e}})}startCall(){return me(this,arguments,function*(e=this.config.mediaConfig){var t,o;try{if(console.log("[PeersCaller] Starting call..."),this.isInitialized||(yield this.initialize()),this.localParticipant&&!this.localParticipant.getCurrentStream()){const c={video:e!=null&&e.video&&typeof e.video=="boolean"?e.video:!0,audio:e!=null&&e.audio&&typeof e.audio=="boolean"?e.audio:!0};yield this.localParticipant.initialize(c)}this.state.setIsCalling(!0),this.state.setCallStatus("connecting"),console.log("[PeersCaller] Starting call for room:",this.config.roomId);const l=yield this.socket.startCall(this.config.roomId);if(console.log("[PeersCaller] Received call.start response:",l),l.success)this.state.setCallStatus("connected"),l.participants.forEach(c=>{c!==this.config.userId&&this.handleParticipantJoined(c)}),console.log("[PeersCaller] Call started successfully"),(o=(t=this.callbacks).onCallStarted)==null||o.call(t,l);else{this.state.setIsCalling(!1),this.state.setCallStatus("idle");const c="Failed to start call on server";throw this.handleError("SIGNALING_ERROR",c),console.error("[PeersCaller] Call start failed:",c),new Error(c)}}catch(l){throw console.error("[PeersCaller] Failed to start call:",l),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start call: ${l}`),l}})}joinCall(){return me(this,arguments,function*(e=this.config.mediaConfig){try{console.log("[PeersCaller] Joining call..."),this.isInitialized||(yield this.initialize());const t=yield this.checkCallStatus();if(!t.hasActiveCall)throw new Error("No active call found");if(!t.canJoin)throw new Error(`Cannot join call: ${t.status==="full"?"Call is full":"Unable to join"}`);if(this.state.setCallStatus("connecting"),this.localParticipant&&!this.localParticipant.getCurrentStream()){const l={video:typeof(e==null?void 0:e.video)=="boolean"?e.video:!0,audio:typeof(e==null?void 0:e.audio)=="boolean"?e.audio:!0};console.log("[PeersCaller] Initializing local media with config:",l),yield this.localParticipant.initialize(l)}console.log("[PeersCaller] Joining call for room:",this.config.roomId);const o=yield this.socket.joinRoom(this.config.roomId);console.log("[PeersCaller] Received call.join response:",o),this.state.setCallStatus("connected"),this.state.setIsCalling(!0),o.participants.forEach(l=>{l!==this.config.userId&&this.handleParticipantJoined(l)}),console.log("[PeersCaller] Joined call successfully")}catch(t){throw console.error("[PeersCaller] Failed to join call:",t),this.state.setCallStatus("idle"),this.handleError("INVALID_ROOM_ID",`Failed to join call: ${t}`),t}})}endCall(){return me(this,null,function*(){try{console.log("[PeersCaller] Ending call..."),this.recorder&&this.state.isRecording&&(yield this.stopRecording());try{yield this.socket.endCallForAll(this.config.roomId),console.log("[PeersCaller] End call request sent to server")}catch(e){console.warn("[PeersCaller] Failed to notify server of call end:",e)}this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),console.log("[PeersCaller] Call ended successfully")}catch(e){console.error("[PeersCaller] Error ending call:",e)}})}leaveCall(){return me(this,null,function*(){try{console.log("[PeersCaller] Leaving call..."),console.log("[PeersCaller] Leaving call for room:",this.config.roomId);const e=yield this.socket.leaveCall(this.config.roomId);if(console.log("[PeersCaller] Received call.leave response:",e),e.success)this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),console.log("[PeersCaller] Left call successfully");else{const t="Failed to leave call on server";throw this.handleError("SIGNALING_ERROR",t),console.error("[PeersCaller] Call leave failed:",t),new Error(t)}}catch(e){throw console.error("[PeersCaller] Failed to leave call:",e),this.handleError("SIGNALING_ERROR",`Failed to leave call: ${e}`),e}})}toggleAudio(e){this.localParticipant&&(this.localParticipant.toggleAudio(e),this.broadcastStateUpdate({audioOn:e}),console.log(`[PeersCaller] Audio ${e?"enabled":"disabled"}`))}toggleVideo(e){this.localParticipant&&(this.localParticipant.toggleVideo(e),this.broadcastStateUpdate({videoOn:e}),console.log(`[PeersCaller] Video ${e?"enabled":"disabled"}`))}startScreenShare(){return me(this,null,function*(){try{if(!this.localParticipant)throw new Error("Local participant not initialized");yield this.localParticipant.startScreenShare(),this.broadcastStateUpdate({screenSharing:!0}),console.log("[PeersCaller] Screen sharing started")}catch(e){throw console.error("[PeersCaller] Failed to start screen share:",e),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start screen share: ${e}`),e}})}stopScreenShare(){return me(this,null,function*(){try{if(!this.localParticipant)throw new Error("Local participant not initialized");yield this.localParticipant.stopScreenShare(),this.broadcastStateUpdate({screenSharing:!1}),console.log("[PeersCaller] Screen sharing stopped")}catch(e){throw console.error("[PeersCaller] Failed to stop screen share:",e),e}})}startRecording(e,t){return me(this,null,function*(){var o;try{if(console.log("[PeersCaller] Starting recording..."),this.state.isRecording){console.warn("[PeersCaller] Recording already in progress");return}const l=[],c=(o=this.localParticipant)==null?void 0:o.getCurrentStream();c&&l.push(c);for(const E of this.participants.values()){const a=E.getAllRemoteStreams();l.push(...a.values())}if(l.length===0)throw new Error("No streams available for recording");this.recorder=new mo(t,{onRecordingStarted:E=>{this.socket.startRecording(this.config.roomId,E.id)},onRecordingChunk:(E,a)=>{this.socket.sendRecordingChunk(this.config.roomId,a.id,E)},onRecordingStopped:E=>{this.socket.endRecording(this.config.roomId,E.id)},onTranscriptReceived:E=>{this.socket.sendTranscript(this.config.roomId,E.text)},onError:E=>{this.handleError("RECORDING_FAILED",E.message)}}),yield this.recorder.startRecording(l,e),this.state.setIsRecording(!0),console.log("[PeersCaller] Recording started successfully")}catch(l){throw console.error("[PeersCaller] Failed to start recording:",l),this.handleError("RECORDING_FAILED",`Failed to start recording: ${l}`),l}})}stopRecording(){return me(this,null,function*(){try{if(console.log("[PeersCaller] Stopping recording..."),!this.recorder||!this.state.isRecording){console.warn("[PeersCaller] No active recording to stop");return}yield this.recorder.stopRecording(),this.state.setIsRecording(!1),console.log("[PeersCaller] Recording stopped successfully")}catch(e){throw console.error("[PeersCaller] Failed to stop recording:",e),e}})}getCallState(){return this.state}getLocalParticipant(){return this.localParticipant}getParticipants(){return new Map(this.participants)}getParticipant(e){return this.participants.get(e)}getDebugInfo(){return{isInitialized:this.isInitialized,localParticipant:this.localParticipant?{userId:this.localParticipant.getUserId(),hasStream:!!this.localParticipant.getCurrentStream(),streamTracks:this.localParticipant.getCurrentStream()?{video:this.localParticipant.getCurrentStream().getVideoTracks().length,audio:this.localParticipant.getCurrentStream().getAudioTracks().length}:null,peerConnections:Array.from(this.localParticipant.getAllPeerConnections().keys()),connectionStatus:this.localParticipant.getConnectionStatus()}:null,remoteParticipants:Array.from(this.participants.keys()),storeState:this.state,socketConnected:this.socket.isConnected()}}cleanup(){console.log("[PeersCaller] Cleaning up..."),this.state.isCalling&&this.endCall(),this.cleanupSocketListeners(),this.cleanupAllParticipants(),this.recorder&&(this.recorder.cleanup(),this.recorder=null),this.socket.disconnect(),this.state.resetCall(),this.isInitialized=!1,console.log("[PeersCaller] Cleanup completed")}initializeLocalParticipant(){return me(this,null,function*(){this.localParticipant=new Xr(this.config.userId,{onStateChanged:()=>{},onSignal:(e,t,o)=>{this.forwardSignalToServer(e,t,o)},onError:e=>{this.handleError("UNKNOWN_ERROR",e.message)}},!0),console.log("[PeersCaller] Local participant created (media not initialized yet)")})}setupSocketListeners(){if(this.listenersSetup){console.log("[PeersCaller] Socket listeners already set up, skipping...");return}this.cleanupSocketListeners(),console.log("[PeersCaller] Setting up socket listeners...");const e=S=>{this.handleParticipantJoined(S.userId)};this.socket.on("call.participant.joined",e),this.eventListeners.set("call.participant.joined",e);const t=S=>{this.handleParticipantLeft(S.userId)};this.socket.on("call.participant.left",t),this.eventListeners.set("call.participant.left",t);const o=S=>{S.participants.forEach(h=>{h!==this.config.userId&&this.handleParticipantJoined(h)})};this.socket.on("call.participants",o),this.eventListeners.set("call.participants",o);const l=()=>{this.state.setIsCalling(!1)};this.socket.on("call.left",l),this.eventListeners.set("call.left",l);const c=S=>{var h,b;console.error("[PeersCaller] Server error:",S),(b=(h=this.callbacks).onError)==null||b.call(h,S.error,S.message)};this.socket.on("call.error",c),this.eventListeners.set("call.error",c);const E=S=>{this.handleOffer(S.from,S.offer)};this.socket.on("call.offer",E),this.eventListeners.set("call.offer",E);const a=S=>{this.handleAnswer(S.from,S.answer)};this.socket.on("call.answer",a),this.eventListeners.set("call.answer",a);const f=S=>{this.handleCandidate(S.from,S.candidate)};this.socket.on("call.candidate",f),this.eventListeners.set("call.candidate",f);const u=S=>{this.handleParticipantStateUpdate(S.from,S.state)};this.socket.on("call.state",u),this.eventListeners.set("call.state",u);const w=S=>{this.handleCallEnded(S)};this.socket.on("call.ended",w),this.eventListeners.set("call.ended",w);const A=S=>{this.handleCallStatusChanged(S)};this.socket.on("call.status.changed",A),this.eventListeners.set("call.status.changed",A);const C=S=>{console.log("[PeersCaller] Recording started:",S.recordingId),this.state.setIsRecording(!0)};this.socket.on("call.recording.start",C),this.eventListeners.set("call.recording.start",C);const j=S=>{console.log("[PeersCaller] Recording chunk received:",S)};this.socket.on("call.recording.chunk.received",j),this.eventListeners.set("call.recording.chunk.received",j);const y=S=>{console.log("[PeersCaller] Recording ended:",S.recordingId),this.state.setIsRecording(!1)};this.socket.on("call.recording.end",y),this.eventListeners.set("call.recording.end",y);const I=S=>{console.log("[PeersCaller] Transcript received:",S)};this.socket.on("call.transcript",I),this.eventListeners.set("call.transcript",I),this.listenersSetup=!0,console.log("[PeersCaller] Socket listeners set up successfully")}cleanupSocketListeners(){if(!(!this.listenersSetup&&this.eventListeners.size===0)){console.log("[PeersCaller] Cleaning up socket listeners...");for(const[e,t]of this.eventListeners)this.socket.off(e,t);this.eventListeners.clear(),this.listenersSetup=!1,console.log("[PeersCaller] Socket listeners cleaned up successfully")}}handleParticipantJoined(e){return me(this,null,function*(){var t,o;try{if(e===this.config.userId||this.participants.has(e))return;if(this.participants.size>=this.config.maxParticipants-1){console.warn("[PeersCaller] Maximum participants reached");return}console.log(`[PeersCaller] Participant ${e} joined`);const l=new Xr(e,{onStreamReceived:(a,f)=>{var u,w;(w=(u=this.callbacks).onStreamReceived)==null||w.call(u,a,f)},onPeerConnected:a=>{console.log(`[PeersCaller] Peer connection established with ${a}`)},onPeerDisconnected:a=>{this.handleParticipantLeft(a)},onSignal:(a,f,u)=>{this.forwardSignalToServer(a,f,u)},onError:a=>{this.handleError("PEER_CONNECTION_FAILED",a.message)}},!1);if(this.participants.set(e,l),!this.localParticipant){console.error("[PeersCaller] Cannot create peer connection - local participant not initialized");return}const c=this.config.userId<e,E={iceServers:this.iceServers,initiator:c};yield this.localParticipant.createPeerConnection(e,E,c),(o=(t=this.callbacks).onParticipantJoined)==null||o.call(t,{userId:e,videoOn:!0,audioOn:!0,screenSharing:!1})}catch(l){console.error(`[PeersCaller] Failed to handle participant ${e} joining:`,l)}})}checkCallStatus(){return me(this,null,function*(){try{if(console.log("[PeersCaller] Checking call status..."),!this.socket.isConnected())throw new Error("Socket not connected");this.state.setCallStatusLoading(!0),this.state.setCallStatusError(null);const e=yield this.socket.checkCallStatus(this.config.roomId);return this.state.setCallStatusInfo(e),this.state.setCallStatusLoading(!1),console.log("[PeersCaller] Call status received:",e),e}catch(e){console.error("[PeersCaller] Failed to check call status:",e);const t=e instanceof Error?e.message:String(e);throw this.state.setCallStatusLoading(!1),this.state.setCallStatusError(t),this.handleError("NETWORK_ERROR",`Failed to check call status: ${t}`),e}})}handleOffer(e,t){return me(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received offer from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing offer from ${e}`),o.signal({type:"offer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for offer from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle offer from ${e}:`,o)}})}handleAnswer(e,t){return me(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received answer from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing answer from ${e}`),o.signal({type:"answer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for answer from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle answer from ${e}:`,o)}})}handleCandidate(e,t){return me(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received candidate from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing candidate from ${e}`),o.signal({type:"candidate",candidate:t})):console.warn(`[PeersCaller] No peer connection found for candidate from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle candidate from ${e}:`,o)}})}handleParticipantStateUpdate(e,t){var o,l;this.state.updateParticipant(e,t),(l=(o=this.callbacks).onParticipantStateChanged)==null||l.call(o,e,t)}handleParticipantLeft(e){var t,o;console.log(`[PeersCaller] Participant ${e} left`);const l=this.participants.get(e);l&&(l.cleanup(),this.participants.delete(e)),this.state.removeParticipant(e),(o=(t=this.callbacks).onParticipantLeft)==null||o.call(t,e)}handleCallEnded(e){return me(this,null,function*(){var t,o;console.log(`[PeersCaller] Call ended by ${e.endedBy}, reason: ${e.reason}`);try{this.recorder&&this.state.isRecording&&(yield this.stopRecording()),this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),(o=(t=this.callbacks).onCallEnded)==null||o.call(t,e),console.log("[PeersCaller] Call ended cleanup completed")}catch(l){console.error("[PeersCaller] Error handling call ended:",l)}})}broadcastStateUpdate(e){for(const t of this.participants.keys())this.socket.sendStateUpdate(t,e,this.config.roomId)}handleCallStatusChanged(e){var t,o;console.log("[PeersCaller] Call status changed:",e),this.state.setCallStatusInfo(e),(o=(t=this.callbacks).onCallStatusChanged)==null||o.call(t,e)}cleanupAllParticipants(){for(const e of this.participants.values())e.cleanup();this.participants.clear(),this.localParticipant&&(this.localParticipant.cleanup(),this.localParticipant=null)}handleError(e,t){var o,l;console.error(`[PeersCaller] ${e}: ${t}`),this.state.setError(e,t),(l=(o=this.callbacks).onError)==null||l.call(o,e,t)}fetchIceServers(){return me(this,null,function*(){try{console.log("[PeersCaller] Fetching ICE servers from backend...");const e=yield this.socket.getIceServers(this.roomId);if(e.error){console.warn("[PeersCaller] Failed to fetch ICE servers from backend:",e.error),console.log("[PeersCaller] Using default ICE servers");return}e.iceServers&&e.iceServers.length>0?(this.iceServers=e.iceServers,console.log(`[PeersCaller] Successfully fetched ${e.iceServers.length} ICE servers from backend for room ${this.roomId}`)):console.log("[PeersCaller] No ICE servers received from backend, using defaults")}catch(e){console.warn("[PeersCaller] Error fetching ICE servers:",e),console.log("[PeersCaller] Using default ICE servers")}})}forwardSignalToServer(e,t,o){try{switch(console.log(`[PeersCaller] Forwarding signal from ${e} to ${t}:`,o.type),o.type){case"offer":this.socket.sendOffer(t,o,this.config.roomId);break;case"answer":this.socket.sendAnswer(t,o,this.config.roomId);break;case"candidate":this.socket.sendCandidate(t,o.candidate,this.config.roomId);break;default:console.warn(`[PeersCaller] Unknown signal type: ${o.type}`)}}catch(l){console.error(`[PeersCaller] Failed to forward signal from ${e} to ${t}:`,l),this.handleError("SIGNALING_ERROR",`Failed to forward signal: ${l}`)}}}var Oe=(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())});function Cs(n){const[e,t]=Q.useState(null),[o,l]=Q.useState(!1),c=Q.useRef(!1),E=we.getState(),a=Object.values(we(g=>g.participants)),f=we(g=>g.localParticipant),u=we(g=>g.callStatus==="connected"),w=we(g=>g.isRecording),A=we(g=>g.error),C=Q.useCallback(()=>Oe(null,null,function*(){if(!(c.current||e))try{c.current=!0;const g=new bo(n,n.callbacks);yield g.initialize(),t(g),l(!0)}catch(g){throw console.error("[useVideoCall] Failed to initialize:",g),c.current=!1,g}}),[n,e]),j=Q.useCallback(g=>Oe(null,null,function*(){if(!e){yield C();return}return e.startCall(g)}),[e,C]),y=Q.useCallback(g=>Oe(null,null,function*(){if(!e){yield C();return}return e.joinCall(g)}),[e,C]),I=Q.useCallback(()=>{e==null||e.endCall()},[e]),S=Q.useCallback(g=>{e==null||e.toggleAudio(g)},[e]),h=Q.useCallback(g=>{e==null||e.toggleVideo(g)},[e]),b=Q.useCallback(()=>Oe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startScreenShare()}),[e]),P=Q.useCallback(()=>Oe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopScreenShare()}),[e]),_=Q.useCallback(g=>Oe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startRecording(g)}),[e]),R=Q.useCallback(()=>Oe(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopRecording()}),[e]),v=Q.useCallback(()=>{e&&(e.cleanup(),t(null),l(!1),c.current=!1)},[e]);return Q.useEffect(()=>{n.autoInitialize&&!o&&!c.current&&C().catch(console.error)},[n.autoInitialize,o,C]),Q.useEffect(()=>()=>{v()},[v]),{initialize:C,startCall:j,joinCall:y,endCall:I,toggleAudio:S,toggleVideo:h,startScreenShare:b,stopScreenShare:P,startRecording:_,stopRecording:R,callState:E,participants:a,localParticipant:f,isConnected:u,isRecording:w,error:A,cleanup:v,peersCaller:e}}function Es(n){const[e,t]=Q.useState(null),[o,l]=Q.useState(null),c=we(E=>E.participants[n]);return Q.useEffect(()=>{var E;if(c!=null&&c.stream){if(l(c.stream),!e){const a=document.createElement("video");a.autoplay=!0,a.playsInline=!0,a.muted=n===((E=we.getState().localParticipant)==null?void 0:E.userId),t(a)}e&&(e.srcObject=c.stream)}},[c==null?void 0:c.stream,n,e]),Q.useEffect(()=>()=>{e&&(e.srcObject=null)},[e]),{videoElement:e,stream:o,participant:c}}function Rs(){const n=we();return{roomId:n.roomId,participants:n.participants,localParticipant:n.localParticipant,isCalling:n.isCalling,isRecording:n.isRecording,recordLoading:n.recordLoading,callStatus:n.callStatus,error:n.error,participantCount:Object.keys(n.participants).length,isConnected:n.callStatus==="connected",hasError:!!n.error}}function Ps(){const[n,e]=Q.useState({videoDevices:[],audioDevices:[]}),[t,o]=Q.useState({camera:null,microphone:null}),l=Q.useCallback(()=>Oe(null,null,function*(){try{const a=yield navigator.mediaDevices.enumerateDevices();e({videoDevices:a.filter(f=>f.kind==="videoinput"),audioDevices:a.filter(f=>f.kind==="audioinput")})}catch(a){console.error("[useMediaDevices] Failed to get devices:",a)}}),[]),c=Q.useCallback(()=>Oe(null,null,function*(){try{if("permissions"in navigator){const a=yield navigator.permissions.query({name:"camera"}),f=yield navigator.permissions.query({name:"microphone"});o({camera:a.state,microphone:f.state})}}catch(a){console.error("[useMediaDevices] Failed to check permissions:",a)}}),[]),E=Q.useCallback(()=>Oe(null,null,function*(){try{return(yield navigator.mediaDevices.getUserMedia({video:!0,audio:!0})).getTracks().forEach(f=>f.stop()),yield c(),yield l(),!0}catch(a){return console.error("[useMediaDevices] Failed to request permissions:",a),!1}}),[c,l]);return Q.useEffect(()=>{var a;l(),c();const f=()=>{l()};return(a=navigator.mediaDevices)==null||a.addEventListener("devicechange",f),()=>{var u;(u=navigator.mediaDevices)==null||u.removeEventListener("devicechange",f)}},[l,c]),{devices:n,permissions:t,getDevices:l,checkPermissions:c,requestPermissions:E}}function As(){const[n,e]=Q.useState({webRTC:!1,getUserMedia:!1,getDisplayMedia:!1,mediaRecorder:!1,speechRecognition:!1});return Q.useEffect(()=>{e({webRTC:!!window.RTCPeerConnection,getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),mediaRecorder:typeof MediaRecorder!="undefined",speechRecognition:!!(window.SpeechRecognition||window.webkitSpeechRecognition)})},[]),{support:n,isSupported:Object.values(n).every(Boolean),unsupportedFeatures:Object.entries(n).filter(([,t])=>!t).map(([t])=>t)}}function Ts(n=""){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return n?`${n}_${e}_${t}`:`${e}_${t}`}const Is=()=>`peer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,Os=n=>!n||typeof n!="string"?!1:/^peer_\d+_[a-z0-9]{1,9}$/.test(n),ks=n=>{var e,t;return{video:(e=n.video)!=null?e:!0,audio:(t=n.audio)!=null?t:!0}};function Ms(n,e,t){const o=`[${n}] ${e}`,l=new Error(o);return t&&(l.details=t),l}function Bs(){const n={getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),RTCPeerConnection:!!window.RTCPeerConnection,MediaRecorder:typeof MediaRecorder!="undefined",WebSocket:typeof WebSocket!="undefined"},e=Object.entries(n).filter(([,t])=>!t).map(([t])=>t);return{supported:e.length===0,features:n,missingFeatures:e}}const Ls=()=>{try{return typeof window!="undefined"&&typeof window.RTCPeerConnection!="undefined"&&typeof navigator!="undefined"&&typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getUserMedia!="undefined"}catch(n){return!1}};function Ns(){return[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun3.l.google.com:19302"}]}Y.CallMediaStream=un,Y.CallParticipant=Xr,Y.CallPeerConnection=io,Y.CallRecorder=mo,Y.CallSocket=cn,Y.PeersCaller=bo,Y.canAcceptMoreParticipants=Ka,Y.checkWebRTCSupport=Bs,Y.formatError=Ms,Y.formatMediaConstraints=ks,Y.generateId=Ts,Y.generatePeerId=Is,Y.getDefaultIceServers=Ns,Y.getParticipant=fo,Y.getParticipantList=Ya,Y.isParticipantConnected=Ja,Y.isValidPeerId=Os,Y.isWebRTCSupported=Ls,Y.selectCallStatus=Ua,Y.selectCallStatusError=Ga,Y.selectCallStatusInfo=Wa,Y.selectCallStatusLoading=za,Y.selectCanJoinCall=Va,Y.selectError=xa,Y.selectIsCallActive=Ha,Y.selectIsConnected=qa,Y.selectLocalParticipant=$a,Y.selectParticipantCount=uo,Y.selectParticipants=ja,Y.useBrowserSupport=As,Y.useCallState=Rs,Y.useCallStore=we,Y.useMediaDevices=Ps,Y.useParticipantVideo=Es,Y.useVideoCall=Cs,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
21
+ `);const _=P.state[a];if(_==null)return;JSON.stringify(l.getState())!==JSON.stringify(_)&&j(_);return}l.dispatchFromDevtools&&typeof l.dispatch=="function"&&l.dispatch(P)});case"DISPATCH":switch(h.payload.type){case"RESET":return j(y),a===void 0?w==null?void 0:w.init(l.getState()):w==null?void 0:w.init(ut(f.name));case"COMMIT":if(a===void 0){w==null||w.init(l.getState());return}return w==null?void 0:w.init(ut(f.name));case"ROLLBACK":return Hr(h.state,P=>{if(a===void 0){j(P),w==null||w.init(l.getState());return}j(P[a]),w==null||w.init(ut(f.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return Hr(h.state,P=>{if(a===void 0){j(P);return}JSON.stringify(l.getState())!==JSON.stringify(P[a])&&j(P[a])});case"IMPORT_STATE":{const{nextLiftedState:P}=h.payload,_=(b=P.computedStates.slice(-1)[0])==null?void 0:b.state;if(!_)return;j(a===void 0?_:_[a]),w==null||w.send(null,P);return}case"PAUSE_RECORDING":return C=!C}return}}),y},Hr=(n,e)=>{let t;try{t=JSON.parse(n)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}t!==void 0&&e(t)};var Ma={env:{}},Ba=Object.defineProperty,La=Object.defineProperties,Na=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,so=Object.prototype.propertyIsEnumerable,lo=(n,e,t)=>e in n?Ba(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Fe=(n,e)=>{for(var t in e||(e={}))ao.call(e,t)&&lo(n,t,e[t]);if(ft)for(var t of ft(e))so.call(e,t)&&lo(n,t,e[t]);return n},Jr=(n,e)=>La(n,Na(e)),Da=n=>typeof n=="symbol"?n:n+"",Fa=(n,e)=>{var t={};for(var o in n)ao.call(n,o)&&e.indexOf(o)<0&&(t[o]=n[o]);if(n!=null&&ft)for(var o of ft(n))e.indexOf(o)<0&&so.call(n,o)&&(t[o]=n[o]);return t};const co={roomId:"",participants:{},localParticipant:null,isCalling:!1,isRecording:!1,recordLoading:!1,callStatus:"idle",error:null,callStatusInfo:null,callStatusLoading:!1,callStatusError:null},we=ye.create()(ka(n=>Jr(Fe({},co),{setRoomId:e=>n({roomId:e},!1,"setRoomId"),setLocalParticipant:e=>n({localParticipant:e},!1,"setLocalParticipant"),addParticipant:e=>n(t=>({participants:Jr(Fe({},t.participants),{[e.userId]:e})}),!1,"addParticipant"),removeParticipant:e=>n(t=>{const o=t.participants,{[e]:l}=o;return{participants:Fa(o,[Da(e)])}},!1,"removeParticipant"),updateParticipant:(e,t)=>n(o=>({participants:Jr(Fe({},o.participants),{[e]:o.participants[e]?Fe(Fe({},o.participants[e]),t):Fe({userId:e,videoOn:!0,audioOn:!0,screenSharing:!1},t)})}),!1,"updateParticipant"),clearParticipants:()=>n({participants:{}},!1,"clearParticipants"),setCallStatus:e=>n({callStatus:e},!1,"setCallStatus"),setIsCalling:e=>n({isCalling:e},!1,"setIsCalling"),setIsRecording:e=>n({isRecording:e},!1,"setIsRecording"),setRecordLoading:e=>n({recordLoading:e},!1,"setRecordLoading"),setError:(e,t)=>n({error:t||e},!1,"setError"),clearError:()=>n({error:null},!1,"clearError"),setCallStatusInfo:e=>n({callStatusInfo:e},!1,"setCallStatusInfo"),setCallStatusLoading:e=>n({callStatusLoading:e},!1,"setCallStatusLoading"),setCallStatusError:e=>n({callStatusError:e},!1,"setCallStatusError"),resetCall:()=>n(Fe({},co),!1,"resetCall")}),{name:"peers-caller-store",enabled:Ma.env.NODE_ENV==="development"})),ja=n=>n.participants,uo=n=>Object.keys(n.participants).length,$a=n=>n.localParticipant,Ua=n=>n.callStatus,qa=n=>n.callStatus==="connected",xa=n=>n.error,Wa=n=>n.callStatusInfo,za=n=>n.callStatusLoading,Ga=n=>n.callStatusError,Va=n=>{var e;return((e=n.callStatusInfo)==null?void 0:e.canJoin)||!1},Ha=n=>{var e;return((e=n.callStatusInfo)==null?void 0:e.hasActiveCall)||!1},fo=n=>we.getState().participants[n],Ja=n=>{const e=fo(n);return!!(e!=null&&e.stream)},Ya=()=>{const n=we.getState();return Object.values(n.participants)},Ka=(n=4)=>uo(we.getState())<n;var Xa=Object.defineProperty,Za=(n,e,t)=>e in n?Xa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Qa=(n,e,t)=>Za(n,e+"",t);class ho{constructor(e){if(Qa(this,"store"),e&&typeof e.getState=="function")this.store=e;else{const t=e;this.store={getState:()=>t}}}get state(){return this.store.getState()}}var es=Object.defineProperty,ts=Object.defineProperties,rs=Object.getOwnPropertyDescriptors,po=Object.getOwnPropertySymbols,ns=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,Yr=(n,e,t)=>e in n?es(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Kr=(n,e)=>{for(var t in e||(e={}))ns.call(e,t)&&Yr(n,t,e[t]);if(po)for(var t of po(e))is.call(e,t)&&Yr(n,t,e[t]);return n},os=(n,e)=>ts(n,rs(e)),xe=(n,e,t)=>Yr(n,typeof e!="symbol"?e+"":e,t),dt=(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 Xr extends ho{constructor(e,t={},o=!1){super(we),xe(this,"userId"),xe(this,"mediaStream",null),xe(this,"peerConnections",new Map),xe(this,"remoteStreams",new Map),xe(this,"isLocalParticipant",!1),xe(this,"callbacks"),this.userId=e,this.callbacks=t,this.isLocalParticipant=o;const l={userId:e,videoOn:!0,audioOn:!0,screenSharing:!1};this.isLocalParticipant&&this.state.setLocalParticipant(l),this.state.addParticipant(l)}initialize(e){return dt(this,null,function*(){var t,o;try{console.log(`[CallParticipant] Initializing participant ${this.userId}`),this.mediaStream=new un(e);const c={stream:yield this.mediaStream.initialize(),videoElement:this.mediaStream.createVideoElement()};this.updateState(c),console.log(`[CallParticipant] Participant ${this.userId} initialized successfully`)}catch(l){throw console.error(`[CallParticipant] Failed to initialize participant ${this.userId}:`,l),(o=(t=this.callbacks).onError)==null||o.call(t,l),l}})}createPeerConnection(e,t,o){return dt(this,null,function*(){var l,c;try{if(console.log(`[CallParticipant] Creating peer connection from ${this.userId} to ${e}`),this.peerConnections.has(e)){console.warn(`[CallParticipant] Peer connection to ${e} already exists`);return}const E={onSignal:f=>{var u,w;console.log(`[CallParticipant] Signal from ${this.userId} to ${e}:`,f.type),(w=(u=this.callbacks).onSignal)==null||w.call(u,this.userId,e,f)},onConnect:()=>{var f,u;console.log(`[CallParticipant] ${this.userId} connected to ${e}`),(u=(f=this.callbacks).onPeerConnected)==null||u.call(f,e)},onStream:f=>{var u,w;console.log(`[CallParticipant] Stream received from ${e} by ${this.userId}`),this.remoteStreams.set(e,f),this.state.updateParticipant(e,{stream:f}),(w=(u=this.callbacks).onStreamReceived)==null||w.call(u,e,f)},onClose:()=>{var f,u;console.log(`[CallParticipant] Connection closed between ${this.userId} and ${e}`),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),(u=(f=this.callbacks).onPeerDisconnected)==null||u.call(f,e)},onError:f=>{var u,w;console.error(`[CallParticipant] Peer connection error between ${this.userId} and ${e}:`,f),(w=(u=this.callbacks).onError)==null||w.call(u,f)}},a=new io(e,os(Kr({},t),{initiator:o}),E);yield a.createConnection(this.getCurrentStream()),this.peerConnections.set(e,a)}catch(E){throw console.error(`[CallParticipant] Failed to create peer connection from ${this.userId} to ${e}:`,E),(c=(l=this.callbacks).onError)==null||c.call(l,E),E}})}getPeerConnection(e){return this.peerConnections.get(e)}signalToPeer(e,t){const o=this.peerConnections.get(e);o?o.signal(t):console.warn(`[CallParticipant] No peer connection found for ${e}`)}toggleAudio(e){this.mediaStream&&(this.mediaStream.toggleAudio(e),this.updateState({audioOn:e}))}toggleVideo(e){this.mediaStream&&(this.mediaStream.toggleVideo(e),this.updateState({videoOn:e}))}startScreenShare(){return dt(this,null,function*(){var e,t;try{if(!this.mediaStream)throw new Error("Media stream not initialized");console.log(`[CallParticipant] Starting screen share for ${this.userId}`);const o=yield this.mediaStream.startScreenShare();for(const[l,c]of this.peerConnections)c.addStream(o),console.log(`[CallParticipant] Screen share stream added to connection with ${l}`);this.updateState({screenSharing:!0,stream:o}),console.log(`[CallParticipant] Screen sharing started for ${this.userId}`)}catch(o){throw console.error(`[CallParticipant] Failed to start screen share for ${this.userId}:`,o),(t=(e=this.callbacks).onError)==null||t.call(e,o),o}})}stopScreenShare(){return dt(this,null,function*(){var e,t;try{if(!this.mediaStream)throw new Error("Media stream not initialized");console.log(`[CallParticipant] Stopping screen share for ${this.userId}`);const o=yield this.mediaStream.stopScreenShare();for(const[l,c]of this.peerConnections)c.addStream(o),console.log(`[CallParticipant] Camera stream restored for connection with ${l}`);this.updateState({screenSharing:!1,stream:o}),console.log(`[CallParticipant] Screen sharing stopped for ${this.userId}`)}catch(o){throw console.error(`[CallParticipant] Failed to stop screen share for ${this.userId}:`,o),(t=(e=this.callbacks).onError)==null||t.call(e,o),o}})}getState(){const e=this.state;return this.isLocalParticipant?e.localParticipant||{userId:this.userId,videoOn:!0,audioOn:!0,screenSharing:!1}:e.participants[this.userId]||{userId:this.userId,videoOn:!0,audioOn:!0,screenSharing:!1}}getUserId(){return this.userId}getMediaStream(){return this.mediaStream}getCurrentStream(){return this.getState().stream}getVideoElement(){return this.getState().videoElement}getRemoteStream(e){return this.remoteStreams.get(e)}getAllRemoteStreams(){return new Map(this.remoteStreams)}getAllPeerConnections(){return new Map(this.peerConnections)}getConnectionStatus(){const e={};for(const[t,o]of this.peerConnections)e[t]=o.isConnected();return e}removePeerConnection(e){const t=this.peerConnections.get(e);t&&(t.destroy(),this.peerConnections.delete(e),this.remoteStreams.delete(e),this.state.updateParticipant(e,{stream:void 0}),console.log(`[CallParticipant] Removed peer connection from ${this.userId} to ${e}`))}updateState(e){var t,o;const l=this.getState();if(Object.keys(e).some(E=>l[E]!==e[E])){const E=Kr(Kr({},l),e);this.isLocalParticipant&&this.state.setLocalParticipant(E),this.state.updateParticipant(this.userId,e),(o=(t=this.callbacks).onStateChanged)==null||o.call(t,this.userId,e)}}getDebugInfo(){var e;return{userId:this.userId,state:this.getState(),peerConnections:Array.from(this.peerConnections.keys()),remoteStreams:Array.from(this.remoteStreams.keys()),connectionStatus:this.getConnectionStatus(),mediaStreamInfo:(e=this.mediaStream)==null?void 0:e.getStreamInfo()}}cleanup(){console.log(`[CallParticipant] Cleaning up participant ${this.userId}`),this.state.removeParticipant(this.userId);for(const e of this.peerConnections.values())e.destroy();this.peerConnections.clear(),this.remoteStreams.clear(),this.mediaStream&&(this.mediaStream.cleanup(),this.mediaStream=null),console.log(`[CallParticipant] Participant ${this.userId} cleanup completed`)}}var Zr={exports:{}},go;function as(){return go||(go=1,function(n){function e(t,o){var l="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";(function(v){typeof RecordRTC=="undefined"&&v&&typeof window=="undefined"&&typeof globalThis!="undefined"&&(globalThis.navigator={userAgent:l,getUserMedia:function(){}},globalThis.console||(globalThis.console={}),(typeof globalThis.console.log=="undefined"||typeof globalThis.console.error=="undefined")&&(globalThis.console.error=globalThis.console.log=globalThis.console.log||function(){console.log(arguments)}),typeof document=="undefined"&&(v.document={documentElement:{appendChild:function(){return""}}},document.createElement=document.captureStream=document.mozCaptureStream=function(){var g={getContext:function(){return g},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""},style:{}};return g},v.HTMLVideoElement=function(){}),typeof location=="undefined"&&(v.location={protocol:"file:",href:"",hash:""}),typeof screen=="undefined"&&(v.screen={width:0,height:0}),typeof A=="undefined"&&(v.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),v.window=globalThis)})(typeof globalThis!="undefined"?globalThis:null),o=o||"multi-streams-mixer";var c=[],E=!1,a=document.createElement("canvas"),f=a.getContext("2d");a.style.opacity=0,a.style.position="absolute",a.style.zIndex=-1,a.style.top="-1000em",a.style.left="-1000em",a.className=o,(document.body||document.documentElement).appendChild(a),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var u=this,w=window.AudioContext;typeof w=="undefined"&&(typeof webkitAudioContext!="undefined"&&(w=webkitAudioContext),typeof mozAudioContext!="undefined"&&(w=mozAudioContext));var A=window.URL;typeof A=="undefined"&&typeof webkitURL!="undefined"&&(A=webkitURL),typeof navigator!="undefined"&&typeof navigator.getUserMedia=="undefined"&&(typeof navigator.webkitGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.webkitGetUserMedia),typeof navigator.mozGetUserMedia!="undefined"&&(navigator.getUserMedia=navigator.mozGetUserMedia));var C=window.MediaStream;typeof C=="undefined"&&typeof webkitMediaStream!="undefined"&&(C=webkitMediaStream),typeof C!="undefined"&&typeof C.prototype.stop=="undefined"&&(C.prototype.stop=function(){this.getTracks().forEach(function(v){v.stop()})});var j={};typeof w!="undefined"?j.AudioContext=w:typeof webkitAudioContext!="undefined"&&(j.AudioContext=webkitAudioContext);function y(v,g){"srcObject"in g?g.srcObject=v:"mozSrcObject"in g?g.mozSrcObject=v:g.srcObject=v}this.startDrawingFrames=function(){I()};function I(){if(!E){var v=c.length,g=!1,B=[];if(c.forEach(function(F){F.stream||(F.stream={}),F.stream.fullcanvas?g=F:B.push(F)}),g)a.width=g.stream.width,a.height=g.stream.height;else if(B.length){a.width=v>1?B[0].width*2:B[0].width;var U=1;(v===3||v===4)&&(U=2),(v===5||v===6)&&(U=3),(v===7||v===8)&&(U=4),(v===9||v===10)&&(U=5),a.height=B[0].height*U}else a.width=u.width||360,a.height=u.height||240;g&&g instanceof HTMLVideoElement&&S(g),B.forEach(function(F,J){S(F,J)}),setTimeout(I,u.frameInterval)}}function S(v,g){if(!E){var B=0,U=0,F=v.width,J=v.height;g===1&&(B=v.width),g===2&&(U=v.height),g===3&&(B=v.width,U=v.height),g===4&&(U=v.height*2),g===5&&(B=v.width,U=v.height*2),g===6&&(U=v.height*3),g===7&&(B=v.width,U=v.height*3),typeof v.stream.left!="undefined"&&(B=v.stream.left),typeof v.stream.top!="undefined"&&(U=v.stream.top),typeof v.stream.width!="undefined"&&(F=v.stream.width),typeof v.stream.height!="undefined"&&(J=v.stream.height),f.drawImage(v,B,U,F,J),typeof v.stream.onRender=="function"&&v.stream.onRender(f,B,U,F,J,g)}}function h(){E=!1;var v=b(),g=P();return g&&g.getTracks().filter(function(B){return B.kind==="audio"}).forEach(function(B){v.addTrack(B)}),t.forEach(function(B){B.fullcanvas}),v}function b(){R();var v;"captureStream"in a?v=a.captureStream():"mozCaptureStream"in a?v=a.mozCaptureStream():u.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var g=new C;return v.getTracks().filter(function(B){return B.kind==="video"}).forEach(function(B){g.addTrack(B)}),a.stream=g,g}function P(){j.AudioContextConstructor||(j.AudioContextConstructor=new j.AudioContext),u.audioContext=j.AudioContextConstructor,u.audioSources=[],u.useGainNode===!0&&(u.gainNode=u.audioContext.createGain(),u.gainNode.connect(u.audioContext.destination),u.gainNode.gain.value=0);var v=0;if(t.forEach(function(g){if(g.getTracks().filter(function(U){return U.kind==="audio"}).length){v++;var B=u.audioContext.createMediaStreamSource(g);u.useGainNode===!0&&B.connect(u.gainNode),u.audioSources.push(B)}}),!!v)return u.audioDestination=u.audioContext.createMediaStreamDestination(),u.audioSources.forEach(function(g){g.connect(u.audioDestination)}),u.audioDestination.stream}function _(v){var g=document.createElement("video");return y(v,g),g.className=o,g.muted=!0,g.volume=0,g.width=v.width||u.width||360,g.height=v.height||u.height||240,g.play(),g}this.appendStreams=function(v){if(!v)throw"First parameter is required.";v instanceof Array||(v=[v]),v.forEach(function(g){var B=new C;if(g.getTracks().filter(function(J){return J.kind==="video"}).length){var U=_(g);U.stream=g,c.push(U),B.addTrack(g.getTracks().filter(function(J){return J.kind==="video"})[0])}if(g.getTracks().filter(function(J){return J.kind==="audio"}).length){var F=u.audioContext.createMediaStreamSource(g);u.audioDestination=u.audioContext.createMediaStreamDestination(),F.connect(u.audioDestination),B.addTrack(u.audioDestination.stream.getTracks().filter(function(J){return J.kind==="audio"})[0])}t.push(B)})},this.releaseStreams=function(){c=[],E=!0,u.gainNode&&(u.gainNode.disconnect(),u.gainNode=null),u.audioSources.length&&(u.audioSources.forEach(function(v){v.disconnect()}),u.audioSources=[]),u.audioDestination&&(u.audioDestination.disconnect(),u.audioDestination=null),u.audioContext&&u.audioContext.close(),u.audioContext=null,f.clearRect(0,0,a.width,a.height),a.stream&&(a.stream.stop(),a.stream=null)},this.resetVideoStreams=function(v){v&&!(v instanceof Array)&&(v=[v]),R(v)};function R(v){c=[],v=v||t,v.forEach(function(g){if(g.getTracks().filter(function(U){return U.kind==="video"}).length){var B=_(g);B.stream=g,c.push(B)}})}this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=h}typeof RecordRTC=="undefined"&&(n.exports=e)}(Zr)),Zr.exports}var ss=as();const ls=yt(ss);var cs=_t();const us=yt(cs);class fs extends us{constructor(t,o=navigator.language){super();Te(this,"track",null);Te(this,"trackId",null);Te(this,"recognition",null);Te(this,"recognizing",!1);Te(this,"transcripts",[]);Te(this,"startTime",0);Te(this,"endTime",0);Te(this,"currentStamp",0);Te(this,"start",()=>(this.recognition.start(),this.recognition.stream=this.track,this.recognizing=!0,this.startTime=performance.now(),this));Te(this,"stop",()=>(this.recognition.stop(),this.recognizing=!1,this.endTime=performance.now(),this));("webkitSpeechRecognition"in window||"SpeechRecognition"in window)&&(this.recognition=new(window.SpeechRecognition||window.webkitSpeechRecognition),this.recognition.continuous=!0,this.recognition.interimResults=!0,this.recognition.lang=o,this.track=t,this.recognition.onstart=this.emit("start"),this.recognition.onend=()=>this.emit("end"),this.recognition.onresult=l=>{const{results:c,resultIndex:E}=l;let a="";if(c[E].isFinal&&c[E][0].transcript){const f={sentence:c[E][0].transcript,confidence:c[E][0].confidence,timeStamp:this.currentStamp,endTimeStamp:new Date().getTime()};this.transcripts.push(f),this.emit("sentence",f)}else this.currentStamp=new Date().getTime(),a+=c[E][0].transcript,this.emit("interim",{sentence:a,timeStamp:this.currentStamp});this.emit("result",l)})}}var ds=Object.defineProperty,yo=Object.getOwnPropertySymbols,hs=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable,Qr=(n,e,t)=>e in n?ds(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,gs=(n,e)=>{for(var t in e||(e={}))hs.call(e,t)&&Qr(n,t,e[t]);if(yo)for(var t of yo(e))ps.call(e,t)&&Qr(n,t,e[t]);return n},We=(n,e,t)=>Qr(n,typeof e!="symbol"?e+"":e,t),en=(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 mo{constructor(e={},t={}){We(this,"mixer",null),We(this,"recorder",null),We(this,"localTranscriber",null),We(this,"isRecording",!1),We(this,"config"),We(this,"callbacks"),this.config=gs({mimeType:"video/webm;codecs=vp8,opus",videoBitsPerSecond:1e6,audioBitsPerSecond:128e3,interval:1e3},e),this.callbacks=t}startRecording(e,t){return en(this,null,function*(){var o,l,c,E;try{if(console.log("[CallRecorder] Starting recording with",e.length,"streams"),this.isRecording)throw new Error("Recording already in progress");if(!t)throw new Error("Recording data is required");this.mixer=new ls(e),this.mixer.frameInterval=1,this.mixer.startDrawingFrames();const a=e[0];a&&a.getAudioTracks().length>0&&(this.localTranscriber=new fs(a)),MediaRecorder.isTypeSupported(this.config.mimeType)||(console.warn("[CallRecorder] Preferred mime type not supported, falling back to default"),this.config.mimeType="video/webm");const f=this.mixer.getMixedStream();this.recorder=new MediaRecorder(f,{mimeType:this.config.mimeType,videoBitsPerSecond:this.config.videoBitsPerSecond,audioBitsPerSecond:this.config.audioBitsPerSecond}),this.setupRecorderEventHandlers(t),this.recorder.start(this.config.interval),this.isRecording=!0,this.localTranscriber&&this.localTranscriber.start(),(l=(o=this.callbacks).onRecordingStarted)==null||l.call(o,t),console.log("[CallRecorder] Recording started successfully")}catch(a){throw console.error("[CallRecorder] Failed to start recording:",a),(E=(c=this.callbacks).onError)==null||E.call(c,a),a}})}stopRecording(){return en(this,null,function*(){var e,t;try{if(console.log("[CallRecorder] Stopping recording"),!this.isRecording||!this.recorder)return console.warn("[CallRecorder] No active recording to stop"),[];this.recorder.stop(),this.isRecording=!1;let o=[];return this.localTranscriber&&(this.localTranscriber.stop(),o=this.localTranscriber.transcripts||[]),this.mixer&&this.mixer.releaseStreams(),console.log("[CallRecorder] Recording stopped successfully"),o}catch(o){return console.error("[CallRecorder] Failed to stop recording:",o),(t=(e=this.callbacks).onError)==null||t.call(e,o),[]}})}resetVideoStreams(e){this.mixer&&(this.mixer.resetVideoStreams(e),console.log("[CallRecorder] Video streams reset"))}setupRecorderEventHandlers(e){this.recorder&&(this.recorder.ondataavailable=t=>{var o,l;t.data&&t.data.size>0&&((l=(o=this.callbacks).onRecordingChunk)==null||l.call(o,t.data,e))},this.recorder.onstart=()=>{console.log("[CallRecorder] MediaRecorder started")},this.recorder.onstop=()=>{var t,o;console.log("[CallRecorder] MediaRecorder stopped"),(o=(t=this.callbacks).onRecordingStopped)==null||o.call(t,e)},this.recorder.onerror=t=>{var o,l;console.error("[CallRecorder] MediaRecorder error:",t),(l=(o=this.callbacks).onError)==null||l.call(o,new Error(`Recording error: ${t}`))})}getRecordingState(){var e,t;return{isRecording:this.isRecording,isTranscribing:this.localTranscriber!==null,transcriptCount:((t=(e=this.localTranscriber)==null?void 0:e.transcripts)==null?void 0:t.length)||0}}getTranscripts(){var e;return((e=this.localTranscriber)==null?void 0:e.transcripts)||[]}static isRecordingSupported(){return typeof MediaRecorder!="undefined"&&typeof MediaRecorder.isTypeSupported=="function"}static isTranscriptionSupported(){return!!(window.SpeechRecognition||window.webkitSpeechRecognition)}static getSupportedMimeTypes(){return["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=h264,opus","video/webm","video/mp4;codecs=h264,aac","video/mp4"].filter(t=>MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported(t))}cleanup(){return en(this,null,function*(){console.log("[CallRecorder] Cleaning up recorder"),this.isRecording&&(yield this.stopRecording()),this.localTranscriber&&(this.localTranscriber.stop(),this.localTranscriber=null),this.mixer&&(this.mixer.releaseStreams(),this.mixer=null),this.recorder=null})}}var ys=Object.defineProperty,ms=Object.defineProperties,vs=Object.getOwnPropertyDescriptors,vo=Object.getOwnPropertySymbols,bs=Object.prototype.hasOwnProperty,ws=Object.prototype.propertyIsEnumerable,tn=(n,e,t)=>e in n?ys(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_s=(n,e)=>{for(var t in e||(e={}))bs.call(e,t)&&tn(n,t,e[t]);if(vo)for(var t of vo(e))ws.call(e,t)&&tn(n,t,e[t]);return n},Ss=(n,e)=>ms(n,vs(e)),Pe=(n,e,t)=>tn(n,typeof e!="symbol"?e+"":e,t),ve=(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 bo extends ho{constructor(e,t={}){if(super(we),Pe(this,"config"),Pe(this,"callbacks"),Pe(this,"socket"),Pe(this,"localParticipant",null),Pe(this,"participants",new Map),Pe(this,"recorder",null),Pe(this,"iceServers",[]),Pe(this,"isInitialized",!1),Pe(this,"listenersSetup",!1),Pe(this,"roomId"),Pe(this,"eventListeners",new Map),this.roomId=e.roomId,!this.roomId)throw new Error("roomId must be provided in config");this.config=Ss(_s({maxParticipants:4,debug:!1,socketPath:"/apis/video-call",mediaConfig:{video:!0,audio:!0}},e),{roomId:this.roomId}),this.callbacks=t,this.socket=new cn(this.config.socketUrl,this.config.token,this.config.socketPath),this.iceServers=this.config.iceServers||[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}],this.state.setRoomId(this.roomId),console.log("[PeersCaller] Initialized with config:",{roomId:this.roomId,tokenLength:this.config.token.length,maxParticipants:this.config.maxParticipants})}initialize(){return ve(this,null,function*(){try{if(console.log("[PeersCaller] Initializing..."),this.isInitialized){console.warn("[PeersCaller] Already initialized");return}yield this.socket.connect(),this.setupSocketListeners(),yield this.initializeLocalParticipant(),this.isInitialized=!0,this.state.setCallStatus("idle"),console.log("[PeersCaller] Initialization completed successfully (ready to start/join call)")}catch(e){throw console.error("[PeersCaller] Initialization failed:",e),this.handleError("NETWORK_ERROR",`Failed to initialize: ${e}`),e}})}startCall(){return ve(this,arguments,function*(e=this.config.mediaConfig){var t,o;try{if(console.log("[PeersCaller] Starting call..."),this.isInitialized||(yield this.initialize()),this.localParticipant&&!this.localParticipant.getCurrentStream()){const c={video:e!=null&&e.video&&typeof e.video=="boolean"?e.video:!0,audio:e!=null&&e.audio&&typeof e.audio=="boolean"?e.audio:!0};yield this.localParticipant.initialize(c)}this.state.setIsCalling(!0),this.state.setCallStatus("connecting"),console.log("[PeersCaller] Starting call for room:",this.config.roomId);const l=yield this.socket.startCall(this.config.roomId);if(console.log("[PeersCaller] Received call.start response:",l),l.success)this.state.setCallStatus("connected"),l.participants.forEach(c=>{c!==this.config.userId&&this.handleParticipantJoined(c)}),console.log("[PeersCaller] Call started successfully"),(o=(t=this.callbacks).onCallStarted)==null||o.call(t,l);else{this.state.setIsCalling(!1),this.state.setCallStatus("idle");const c="Failed to start call on server";throw this.handleError("SIGNALING_ERROR",c),console.error("[PeersCaller] Call start failed:",c),new Error(c)}}catch(l){throw console.error("[PeersCaller] Failed to start call:",l),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start call: ${l}`),l}})}joinCall(){return ve(this,arguments,function*(e=this.config.mediaConfig){try{console.log("[PeersCaller] Joining call..."),this.isInitialized||(yield this.initialize());const t=yield this.checkCallStatus();if(!t.hasActiveCall)throw new Error("No active call found");if(!t.canJoin)throw new Error(`Cannot join call: ${t.status==="full"?"Call is full":"Unable to join"}`);if(this.state.setCallStatus("connecting"),this.localParticipant&&!this.localParticipant.getCurrentStream()){const l={video:typeof(e==null?void 0:e.video)=="boolean"?e.video:!0,audio:typeof(e==null?void 0:e.audio)=="boolean"?e.audio:!0};console.log("[PeersCaller] Initializing local media with config:",l),yield this.localParticipant.initialize(l)}console.log("[PeersCaller] Joining call for room:",this.config.roomId);const o=yield this.socket.joinRoom(this.config.roomId);console.log("[PeersCaller] Received call.join response:",o),this.state.setCallStatus("connected"),this.state.setIsCalling(!0),o.participants.forEach(l=>{l!==this.config.userId&&this.handleParticipantJoined(l)}),console.log("[PeersCaller] Joined call successfully")}catch(t){throw console.error("[PeersCaller] Failed to join call:",t),this.state.setCallStatus("idle"),this.handleError("INVALID_ROOM_ID",`Failed to join call: ${t}`),t}})}endCall(){return ve(this,null,function*(){try{console.log("[PeersCaller] Ending call..."),this.recorder&&this.state.isRecording&&(yield this.stopRecording());try{yield this.socket.endCallForAll(this.config.roomId),console.log("[PeersCaller] End call request sent to server")}catch(e){console.warn("[PeersCaller] Failed to notify server of call end:",e)}this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),console.log("[PeersCaller] Call ended successfully")}catch(e){console.error("[PeersCaller] Error ending call:",e)}})}leaveCall(){return ve(this,null,function*(){try{console.log("[PeersCaller] Leaving call..."),console.log("[PeersCaller] Leaving call for room:",this.config.roomId);const e=yield this.socket.leaveCall(this.config.roomId);if(console.log("[PeersCaller] Received call.leave response:",e),e.success)this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),console.log("[PeersCaller] Left call successfully");else{const t="Failed to leave call on server";throw this.handleError("SIGNALING_ERROR",t),console.error("[PeersCaller] Call leave failed:",t),new Error(t)}}catch(e){throw console.error("[PeersCaller] Failed to leave call:",e),this.handleError("SIGNALING_ERROR",`Failed to leave call: ${e}`),e}})}toggleAudio(e){this.localParticipant&&(this.localParticipant.toggleAudio(e),this.broadcastStateUpdate({audioOn:e}),console.log(`[PeersCaller] Audio ${e?"enabled":"disabled"}`))}toggleVideo(e){this.localParticipant&&(this.localParticipant.toggleVideo(e),this.broadcastStateUpdate({videoOn:e}),console.log(`[PeersCaller] Video ${e?"enabled":"disabled"}`))}startScreenShare(){return ve(this,null,function*(){try{if(!this.localParticipant)throw new Error("Local participant not initialized");yield this.localParticipant.startScreenShare(),this.broadcastStateUpdate({screenSharing:!0}),console.log("[PeersCaller] Screen sharing started")}catch(e){throw console.error("[PeersCaller] Failed to start screen share:",e),this.handleError("MEDIA_ACCESS_DENIED",`Failed to start screen share: ${e}`),e}})}stopScreenShare(){return ve(this,null,function*(){try{if(!this.localParticipant)throw new Error("Local participant not initialized");yield this.localParticipant.stopScreenShare(),this.broadcastStateUpdate({screenSharing:!1}),console.log("[PeersCaller] Screen sharing stopped")}catch(e){throw console.error("[PeersCaller] Failed to stop screen share:",e),e}})}startRecording(e,t){return ve(this,null,function*(){var o;try{if(console.log("[PeersCaller] Starting recording..."),this.state.isRecording){console.warn("[PeersCaller] Recording already in progress");return}const l=[],c=(o=this.localParticipant)==null?void 0:o.getCurrentStream();c&&l.push(c);for(const E of this.participants.values()){const a=E.getAllRemoteStreams();l.push(...a.values())}if(l.length===0)throw new Error("No streams available for recording");this.recorder=new mo(t,{onRecordingStarted:E=>{this.socket.startRecording(this.config.roomId,E.id)},onRecordingChunk:(E,a)=>{this.socket.sendRecordingChunk(this.config.roomId,a.id,E)},onRecordingStopped:E=>{this.socket.endRecording(this.config.roomId,E.id)},onTranscriptReceived:E=>{this.socket.sendTranscript(this.config.roomId,E.text)},onError:E=>{this.handleError("RECORDING_FAILED",E.message)}}),yield this.recorder.startRecording(l,e),this.state.setIsRecording(!0),console.log("[PeersCaller] Recording started successfully")}catch(l){throw console.error("[PeersCaller] Failed to start recording:",l),this.handleError("RECORDING_FAILED",`Failed to start recording: ${l}`),l}})}stopRecording(){return ve(this,null,function*(){try{if(console.log("[PeersCaller] Stopping recording..."),!this.recorder||!this.state.isRecording){console.warn("[PeersCaller] No active recording to stop");return}yield this.recorder.stopRecording(),this.state.setIsRecording(!1),console.log("[PeersCaller] Recording stopped successfully")}catch(e){throw console.error("[PeersCaller] Failed to stop recording:",e),e}})}getCallState(){return this.state}getLocalParticipant(){return this.localParticipant}getParticipants(){return new Map(this.participants)}getParticipant(e){return this.participants.get(e)}getDebugInfo(){return{isInitialized:this.isInitialized,localParticipant:this.localParticipant?{userId:this.localParticipant.getUserId(),hasStream:!!this.localParticipant.getCurrentStream(),streamTracks:this.localParticipant.getCurrentStream()?{video:this.localParticipant.getCurrentStream().getVideoTracks().length,audio:this.localParticipant.getCurrentStream().getAudioTracks().length}:null,peerConnections:Array.from(this.localParticipant.getAllPeerConnections().keys()),connectionStatus:this.localParticipant.getConnectionStatus()}:null,remoteParticipants:Array.from(this.participants.keys()),storeState:this.state,socketConnected:this.socket.isConnected()}}cleanup(){console.log("[PeersCaller] Cleaning up..."),this.state.isCalling&&this.endCall(),this.cleanupSocketListeners(),this.cleanupAllParticipants(),this.recorder&&(this.recorder.cleanup(),this.recorder=null),this.socket.disconnect(),this.state.resetCall(),this.isInitialized=!1,console.log("[PeersCaller] Cleanup completed")}initializeLocalParticipant(){return ve(this,null,function*(){this.localParticipant=new Xr(this.config.userId,{onStateChanged:()=>{},onSignal:(e,t,o)=>{this.forwardSignalToServer(e,t,o)},onError:e=>{this.handleError("UNKNOWN_ERROR",e.message)}},!0),console.log("[PeersCaller] Local participant created (media not initialized yet)")})}setupSocketListeners(){if(this.listenersSetup){console.log("[PeersCaller] Socket listeners already set up, skipping...");return}this.cleanupSocketListeners(),console.log("[PeersCaller] Setting up socket listeners...");const e=S=>{this.handleParticipantJoined(S.userId)};this.socket.on("call.participant.joined",e),this.eventListeners.set("call.participant.joined",e);const t=S=>{this.handleParticipantLeft(S.userId)};this.socket.on("call.participant.left",t),this.eventListeners.set("call.participant.left",t);const o=S=>{S.participants.forEach(h=>{h!==this.config.userId&&this.handleParticipantJoined(h)})};this.socket.on("call.participants",o),this.eventListeners.set("call.participants",o);const l=()=>{this.state.setIsCalling(!1)};this.socket.on("call.left",l),this.eventListeners.set("call.left",l);const c=S=>{var h,b;console.error("[PeersCaller] Server error:",S),(b=(h=this.callbacks).onError)==null||b.call(h,S.error,S.message)};this.socket.on("call.error",c),this.eventListeners.set("call.error",c);const E=S=>{this.handleOffer(S.from,S.offer)};this.socket.on("call.offer",E),this.eventListeners.set("call.offer",E);const a=S=>{this.handleAnswer(S.from,S.answer)};this.socket.on("call.answer",a),this.eventListeners.set("call.answer",a);const f=S=>{this.handleCandidate(S.from,S.candidate)};this.socket.on("call.candidate",f),this.eventListeners.set("call.candidate",f);const u=S=>{this.handleParticipantStateUpdate(S.from,S.state)};this.socket.on("call.state",u),this.eventListeners.set("call.state",u);const w=S=>{this.handleCallEnded(S)};this.socket.on("call.ended",w),this.eventListeners.set("call.ended",w);const A=S=>{this.handleCallStatusChanged(S)};this.socket.on("call.status.changed",A),this.eventListeners.set("call.status.changed",A);const C=S=>{console.log("[PeersCaller] Recording started:",S.recordingId),this.state.setIsRecording(!0)};this.socket.on("call.recording.start",C),this.eventListeners.set("call.recording.start",C);const j=S=>{console.log("[PeersCaller] Recording chunk received:",S)};this.socket.on("call.recording.chunk.received",j),this.eventListeners.set("call.recording.chunk.received",j);const y=S=>{console.log("[PeersCaller] Recording ended:",S.recordingId),this.state.setIsRecording(!1)};this.socket.on("call.recording.end",y),this.eventListeners.set("call.recording.end",y);const I=S=>{console.log("[PeersCaller] Transcript received:",S)};this.socket.on("call.transcript",I),this.eventListeners.set("call.transcript",I),this.listenersSetup=!0,console.log("[PeersCaller] Socket listeners set up successfully")}cleanupSocketListeners(){if(!(!this.listenersSetup&&this.eventListeners.size===0)){console.log("[PeersCaller] Cleaning up socket listeners...");for(const[e,t]of this.eventListeners)this.socket.off(e,t);this.eventListeners.clear(),this.listenersSetup=!1,console.log("[PeersCaller] Socket listeners cleaned up successfully")}}handleParticipantJoined(e){return ve(this,null,function*(){var t,o;try{if(e===this.config.userId||this.participants.has(e))return;if(this.participants.size>=this.config.maxParticipants-1){console.warn("[PeersCaller] Maximum participants reached");return}console.log(`[PeersCaller] Participant ${e} joined`);const l=new Xr(e,{onStreamReceived:(a,f)=>{var u,w;(w=(u=this.callbacks).onStreamReceived)==null||w.call(u,a,f)},onPeerConnected:a=>{console.log(`[PeersCaller] Peer connection established with ${a}`)},onPeerDisconnected:a=>{this.handleParticipantLeft(a)},onSignal:(a,f,u)=>{this.forwardSignalToServer(a,f,u)},onError:a=>{this.handleError("PEER_CONNECTION_FAILED",a.message)}},!1);if(this.participants.set(e,l),!this.localParticipant){console.error("[PeersCaller] Cannot create peer connection - local participant not initialized");return}const c=this.config.userId<e,E={iceServers:this.iceServers,initiator:c};yield this.localParticipant.createPeerConnection(e,E,c),(o=(t=this.callbacks).onParticipantJoined)==null||o.call(t,{userId:e,videoOn:!0,audioOn:!0,screenSharing:!1})}catch(l){console.error(`[PeersCaller] Failed to handle participant ${e} joining:`,l)}})}checkCallStatus(){return ve(this,null,function*(){try{if(console.log("[PeersCaller] Checking call status..."),!this.socket.isConnected())throw new Error("Socket not connected");this.state.setCallStatusLoading(!0),this.state.setCallStatusError(null);const e=yield this.socket.checkCallStatus(this.config.roomId);return this.state.setCallStatusInfo(e),this.state.setCallStatusLoading(!1),console.log("[PeersCaller] Call status received:",e),e}catch(e){console.error("[PeersCaller] Failed to check call status:",e);const t=e instanceof Error?e.message:String(e);throw this.state.setCallStatusLoading(!1),this.state.setCallStatusError(t),this.handleError("NETWORK_ERROR",`Failed to check call status: ${t}`),e}})}handleOffer(e,t){return ve(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received offer from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing offer from ${e}`),o.signal({type:"offer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for offer from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle offer from ${e}:`,o)}})}handleAnswer(e,t){return ve(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received answer from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing answer from ${e}`),o.signal({type:"answer",sdp:t.sdp})):console.warn(`[PeersCaller] No peer connection found for answer from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle answer from ${e}:`,o)}})}handleCandidate(e,t){return ve(this,null,function*(){try{if(!this.localParticipant){console.warn(`[PeersCaller] Received candidate from ${e} but local participant not initialized`);return}const o=this.localParticipant.getPeerConnection(e);o?(console.log(`[PeersCaller] Processing candidate from ${e}`),o.signal({type:"candidate",candidate:t})):console.warn(`[PeersCaller] No peer connection found for candidate from ${e}`)}catch(o){console.error(`[PeersCaller] Failed to handle candidate from ${e}:`,o)}})}handleParticipantStateUpdate(e,t){var o,l;this.state.updateParticipant(e,t),(l=(o=this.callbacks).onParticipantStateChanged)==null||l.call(o,e,t)}handleParticipantLeft(e){var t,o;console.log(`[PeersCaller] Participant ${e} left`);const l=this.participants.get(e);l&&(l.cleanup(),this.participants.delete(e)),this.state.removeParticipant(e),(o=(t=this.callbacks).onParticipantLeft)==null||o.call(t,e)}handleCallEnded(e){return ve(this,null,function*(){var t,o;console.log(`[PeersCaller] Call ended by ${e.endedBy}, reason: ${e.reason}`);try{this.recorder&&this.state.isRecording&&(yield this.stopRecording()),this.cleanupAllParticipants(),this.state.setIsCalling(!1),this.state.setCallStatus("idle"),this.state.clearParticipants(),(o=(t=this.callbacks).onCallEnded)==null||o.call(t,e),console.log("[PeersCaller] Call ended cleanup completed")}catch(l){console.error("[PeersCaller] Error handling call ended:",l)}})}broadcastStateUpdate(e){for(const t of this.participants.keys())this.socket.sendStateUpdate(t,e,this.config.roomId)}handleCallStatusChanged(e){var t,o;console.log("[PeersCaller] Call status changed:",e),this.state.setCallStatusInfo(e),(o=(t=this.callbacks).onCallStatusChanged)==null||o.call(t,e)}cleanupAllParticipants(){for(const e of this.participants.values())e.cleanup();this.participants.clear(),this.localParticipant&&(this.localParticipant.cleanup(),this.localParticipant=null)}handleError(e,t){var o,l;console.error(`[PeersCaller] ${e}: ${t}`),this.state.setError(e,t),(l=(o=this.callbacks).onError)==null||l.call(o,e,t)}forwardSignalToServer(e,t,o){try{switch(console.log(`[PeersCaller] Forwarding signal from ${e} to ${t}:`,o.type),o.type){case"offer":this.socket.sendOffer(t,o,this.config.roomId);break;case"answer":this.socket.sendAnswer(t,o,this.config.roomId);break;case"candidate":this.socket.sendCandidate(t,o.candidate,this.config.roomId);break;default:console.warn(`[PeersCaller] Unknown signal type: ${o.type}`)}}catch(l){console.error(`[PeersCaller] Failed to forward signal from ${e} to ${t}:`,l),this.handleError("SIGNALING_ERROR",`Failed to forward signal: ${l}`)}}}var Ie=(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())});function Cs(n){const[e,t]=Q.useState(null),[o,l]=Q.useState(!1),c=Q.useRef(!1),E=we.getState(),a=Object.values(we(g=>g.participants)),f=we(g=>g.localParticipant),u=we(g=>g.callStatus==="connected"),w=we(g=>g.isRecording),A=we(g=>g.error),C=Q.useCallback(()=>Ie(null,null,function*(){if(!(c.current||e))try{c.current=!0;const g=new bo(n,n.callbacks);yield g.initialize(),t(g),l(!0)}catch(g){throw console.error("[useVideoCall] Failed to initialize:",g),c.current=!1,g}}),[n,e]),j=Q.useCallback(g=>Ie(null,null,function*(){if(!e){yield C();return}return e.startCall(g)}),[e,C]),y=Q.useCallback(g=>Ie(null,null,function*(){if(!e){yield C();return}return e.joinCall(g)}),[e,C]),I=Q.useCallback(()=>{e==null||e.endCall()},[e]),S=Q.useCallback(g=>{e==null||e.toggleAudio(g)},[e]),h=Q.useCallback(g=>{e==null||e.toggleVideo(g)},[e]),b=Q.useCallback(()=>Ie(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startScreenShare()}),[e]),P=Q.useCallback(()=>Ie(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopScreenShare()}),[e]),_=Q.useCallback(g=>Ie(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.startRecording(g)}),[e]),R=Q.useCallback(()=>Ie(null,null,function*(){if(!e)throw new Error("PeersCaller not initialized");return e.stopRecording()}),[e]),v=Q.useCallback(()=>{e&&(e.cleanup(),t(null),l(!1),c.current=!1)},[e]);return Q.useEffect(()=>{n.autoInitialize&&!o&&!c.current&&C().catch(console.error)},[n.autoInitialize,o,C]),Q.useEffect(()=>()=>{v()},[v]),{initialize:C,startCall:j,joinCall:y,endCall:I,toggleAudio:S,toggleVideo:h,startScreenShare:b,stopScreenShare:P,startRecording:_,stopRecording:R,callState:E,participants:a,localParticipant:f,isConnected:u,isRecording:w,error:A,cleanup:v,peersCaller:e}}function Es(n){const[e,t]=Q.useState(null),[o,l]=Q.useState(null),c=we(E=>E.participants[n]);return Q.useEffect(()=>{var E;if(c!=null&&c.stream){if(l(c.stream),!e){const a=document.createElement("video");a.autoplay=!0,a.playsInline=!0,a.muted=n===((E=we.getState().localParticipant)==null?void 0:E.userId),t(a)}e&&(e.srcObject=c.stream)}},[c==null?void 0:c.stream,n,e]),Q.useEffect(()=>()=>{e&&(e.srcObject=null)},[e]),{videoElement:e,stream:o,participant:c}}function Rs(){const n=we();return{roomId:n.roomId,participants:n.participants,localParticipant:n.localParticipant,isCalling:n.isCalling,isRecording:n.isRecording,recordLoading:n.recordLoading,callStatus:n.callStatus,error:n.error,participantCount:Object.keys(n.participants).length,isConnected:n.callStatus==="connected",hasError:!!n.error}}function Ps(){const[n,e]=Q.useState({videoDevices:[],audioDevices:[]}),[t,o]=Q.useState({camera:null,microphone:null}),l=Q.useCallback(()=>Ie(null,null,function*(){try{const a=yield navigator.mediaDevices.enumerateDevices();e({videoDevices:a.filter(f=>f.kind==="videoinput"),audioDevices:a.filter(f=>f.kind==="audioinput")})}catch(a){console.error("[useMediaDevices] Failed to get devices:",a)}}),[]),c=Q.useCallback(()=>Ie(null,null,function*(){try{if("permissions"in navigator){const a=yield navigator.permissions.query({name:"camera"}),f=yield navigator.permissions.query({name:"microphone"});o({camera:a.state,microphone:f.state})}}catch(a){console.error("[useMediaDevices] Failed to check permissions:",a)}}),[]),E=Q.useCallback(()=>Ie(null,null,function*(){try{return(yield navigator.mediaDevices.getUserMedia({video:!0,audio:!0})).getTracks().forEach(f=>f.stop()),yield c(),yield l(),!0}catch(a){return console.error("[useMediaDevices] Failed to request permissions:",a),!1}}),[c,l]);return Q.useEffect(()=>{var a;l(),c();const f=()=>{l()};return(a=navigator.mediaDevices)==null||a.addEventListener("devicechange",f),()=>{var u;(u=navigator.mediaDevices)==null||u.removeEventListener("devicechange",f)}},[l,c]),{devices:n,permissions:t,getDevices:l,checkPermissions:c,requestPermissions:E}}function As(){const[n,e]=Q.useState({webRTC:!1,getUserMedia:!1,getDisplayMedia:!1,mediaRecorder:!1,speechRecognition:!1});return Q.useEffect(()=>{e({webRTC:!!window.RTCPeerConnection,getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),mediaRecorder:typeof MediaRecorder!="undefined",speechRecognition:!!(window.SpeechRecognition||window.webkitSpeechRecognition)})},[]),{support:n,isSupported:Object.values(n).every(Boolean),unsupportedFeatures:Object.entries(n).filter(([,t])=>!t).map(([t])=>t)}}function Ts(n=""){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return n?`${n}_${e}_${t}`:`${e}_${t}`}const Is=()=>`peer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,Os=n=>!n||typeof n!="string"?!1:/^peer_\d+_[a-z0-9]{1,9}$/.test(n),ks=n=>{var e,t;return{video:(e=n.video)!=null?e:!0,audio:(t=n.audio)!=null?t:!0}};function Ms(n,e,t){const o=`[${n}] ${e}`,l=new Error(o);return t&&(l.details=t),l}function Bs(){const n={getUserMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),getDisplayMedia:!!(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia),RTCPeerConnection:!!window.RTCPeerConnection,MediaRecorder:typeof MediaRecorder!="undefined",WebSocket:typeof WebSocket!="undefined"},e=Object.entries(n).filter(([,t])=>!t).map(([t])=>t);return{supported:e.length===0,features:n,missingFeatures:e}}const Ls=()=>{try{return typeof window!="undefined"&&typeof window.RTCPeerConnection!="undefined"&&typeof navigator!="undefined"&&typeof navigator.mediaDevices!="undefined"&&typeof navigator.mediaDevices.getUserMedia!="undefined"}catch(n){return!1}};function Ns(){return[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun3.l.google.com:19302"}]}Y.CallMediaStream=un,Y.CallParticipant=Xr,Y.CallPeerConnection=io,Y.CallRecorder=mo,Y.CallSocket=cn,Y.PeersCaller=bo,Y.canAcceptMoreParticipants=Ka,Y.checkWebRTCSupport=Bs,Y.formatError=Ms,Y.formatMediaConstraints=ks,Y.generateId=Ts,Y.generatePeerId=Is,Y.getDefaultIceServers=Ns,Y.getParticipant=fo,Y.getParticipantList=Ya,Y.isParticipantConnected=Ja,Y.isValidPeerId=Os,Y.isWebRTCSupported=Ls,Y.selectCallStatus=Ua,Y.selectCallStatusError=Ga,Y.selectCallStatusInfo=Wa,Y.selectCallStatusLoading=za,Y.selectCanJoinCall=Va,Y.selectError=xa,Y.selectIsCallActive=Ha,Y.selectIsConnected=qa,Y.selectLocalParticipant=$a,Y.selectParticipantCount=uo,Y.selectParticipants=ja,Y.useBrowserSupport=As,Y.useCallState=Rs,Y.useCallStore=we,Y.useMediaDevices=Ps,Y.useParticipantVideo=Es,Y.useVideoCall=Cs,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
22
22
  //# sourceMappingURL=peers-caller.umd.js.map