@cloudflare/realtimekit-recording-sdk 0.0.2-staging.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.iife.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";var Ht=Object.defineProperty;var en=(n,e,t)=>e in n?Ht(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var it=(n,e,t)=>(en(n,typeof e!="symbol"?e+"":e,t),t),We=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var l=(n,e,t)=>(We(n,e,"read from private field"),t?t.call(n):e.get(n)),D=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},C=(n,e,t,i)=>(We(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t);var rt=(n,e,t)=>(We(n,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var et={exports:{}},re=typeof Reflect=="object"?Reflect:null,st=re&&typeof re.apply=="function"?re.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Ie;re&&typeof re.ownKeys=="function"?Ie=re.ownKeys:Object.getOwnPropertySymbols?Ie=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ie=function(e){return Object.getOwnPropertyNames(e)};function tn(n){console&&console.warn&&console.warn(n)}var vt=Number.isNaN||function(e){return e!==e};function v(){v.init.call(this)}et.exports=v;et.exports.once=on;v.EventEmitter=v;v.prototype._events=void 0;v.prototype._eventsCount=0;v.prototype._maxListeners=void 0;var ot=10;function Ke(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return ot},set:function(n){if(typeof n!="number"||n<0||vt(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");ot=n}});v.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};v.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||vt(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function kt(n){return n._maxListeners===void 0?v.defaultMaxListeners:n._maxListeners}v.prototype.getMaxListeners=function(){return kt(this)};v.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",s=this._events;if(s!==void 0)r=r&&s.error===void 0;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")st(f,this,t);else for(var h=f.length,d=Rt(f,h),i=0;i<h;++i)st(d[i],this,t);return!0};function It(n,e,t,i){var r,s,o;if(Ke(t),s=n._events,s===void 0?(s=n._events=Object.create(null),n._eventsCount=0):(s.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),s=n._events),o=s[e]),o===void 0)o=s[e]=t,++n._eventsCount;else if(typeof o=="function"?o=s[e]=i?[t,o]:[o,t]:i?o.unshift(t):o.push(t),r=kt(n),r>0&&o.length>r&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=o.length,tn(a)}return n}v.prototype.addListener=function(e,t){return It(this,e,t,!1)};v.prototype.on=v.prototype.addListener;v.prototype.prependListener=function(e,t){return It(this,e,t,!0)};function nn(){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 Nt(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=nn.bind(i);return r.listener=t,i.wrapFn=r,r}v.prototype.once=function(e,t){return Ke(t),this.on(e,Nt(this,e,t)),this};v.prototype.prependOnceListener=function(e,t){return Ke(t),this.prependListener(e,Nt(this,e,t)),this};v.prototype.removeListener=function(e,t){var i,r,s,o,a;if(Ke(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():rn(i,s),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};v.prototype.off=v.prototype.removeListener;v.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(r=0;r<s.length;++r)o=s[r],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function Et(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?sn(r):Rt(r,r.length)}v.prototype.listeners=function(e){return Et(this,e,!0)};v.prototype.rawListeners=function(e){return Et(this,e,!1)};v.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):Tt.call(n,e)};v.prototype.listenerCount=Tt;function Tt(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}v.prototype.eventNames=function(){return this._eventsCount>0?Ie(this._events):[]};function Rt(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function rn(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function sn(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function on(n,e){return new Promise(function(t,i){function r(o){n.removeListener(e,s),i(o)}function s(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}Ot(n,e,s,{once:!0}),e!=="error"&&an(n,r,{once:!0})})}function an(n,e,t){typeof n.on=="function"&&Ot(n,"error",e,t)}function Ot(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(s){i.once&&n.removeEventListener(e,r),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var cn=et.exports;class un{constructor(){it(this,"client")}logToConsole(){return window.devMode===!0&&!this.isInitialized()}init(e){this.client=e}isInitialized(){return this.client!==void 0}generateMessage(e){return`RealtimeKitRecordingLogger::${e}`}info(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.info(this.generateMessage(e),t,i)),this.logToConsole()&&console.log(e)}error(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.error(this.generateMessage(e),t,i)),this.logToConsole()&&console.error(e)}debug(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.debug(this.generateMessage(e),t,i)),this.logToConsole()&&console.debug(e)}log(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.log(this.generateMessage(e),t,i)),this.logToConsole()&&console.log(e)}warn(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.warn(this.generateMessage(e),t,i)),this.logToConsole()&&console.warn(e)}}const N=new un,Lt=1e3,fn=60*Lt,hn=1*Lt;var H,G,we,ce,_e,St;class ln extends cn.EventEmitter{constructor(t,i){super();D(this,_e);D(this,H,null);D(this,G,!1);D(this,we,!1);D(this,ce,null);this.meeting=t,this.options=i,rt(this,_e,St).call(this)}cleanup(){N.info("Cleaning up recording controller"),delete window.dyteRecording,delete window.realtimeKitRecording,this.meeting.removeAllListeners(),this.removeAllListeners(),l(this,ce)!==null&&clearInterval(l(this,ce))}getParticipantCount(){return this.meeting.getParticipantCount()}getWaitlistedCount(){return this.meeting.getWaitlistedCount()}scanMeetingState(){if(!this.options.autoStop)return;if(this.getParticipantCount()>0||this.getWaitlistedCount()>0){C(this,H,null),C(this,G,!1),window.triggerDyteRecording=!0,window.triggerRealtimeKitRecording=!0;return}if(l(this,H)===null){C(this,H,new Date);return}if(new Date().getTime()-l(this,H).getTime()>this.options.waitTimeMs){N.info("Setting triggerDyteRecording & triggerRealtimeKitRecording to false"),C(this,G,!0),window.triggerDyteRecording=!1,window.triggerRealtimeKitRecording=!1;return}C(this,G,!1),window.triggerDyteRecording=!0,window.triggerRealtimeKitRecording=!0}stopRecording(){if(this.options.autoStop)throw new Error("Cannot stop recording when autoStop is true");N.info("Stopping recording"),window.triggerDyteRecording&&(window.triggerDyteRecording=!1),window.triggerRealtimeKitRecording&&(window.triggerRealtimeKitRecording=!1)}get meetingJoined(){return l(this,we)}}H=new WeakMap,G=new WeakMap,we=new WeakMap,ce=new WeakMap,_e=new WeakSet,St=function(){window.dyteRecording!==void 0&&(window.dyteRecording=void 0,window.realtimeKitRecording=void 0,window.triggerDyteRecording=!1,window.triggerRealtimeKitRecording=!1),window.realtimeKitRecording!==void 0&&(window.dyteRecording=void 0,window.realtimeKitRecording=void 0,window.triggerDyteRecording=!1,window.triggerRealtimeKitRecording=!1),window.triggerDyteRecording=!0,window.triggerRealtimeKitRecording=!0,window.dyteRecording={getParticipantCount:()=>this.getParticipantCount(),isMeetingEnded:()=>l(this,G),isMeetingJoined:()=>this.meetingJoined,getMeeting:()=>this.meeting.getMeeting()},window.realtimeKitRecording={getParticipantCount:()=>this.getParticipantCount(),isMeetingEnded:()=>l(this,G),isMeetingJoined:()=>this.meetingJoined,getMeeting:()=>this.meeting.getMeeting()},this.meeting.handleParticipantJoin(()=>{N.info(`Participant joined. Total participants: ${this.getParticipantCount()}. Scanning meeting state`),this.scanMeetingState(),this.emit("participantCount",this.getParticipantCount())}),this.meeting.handleParticipantLeave(()=>{N.info(`Participant left. Remaining participants: ${this.getParticipantCount()}. Scanning meeting state`),this.scanMeetingState(),this.emit("participantCount",this.getParticipantCount())}),this.meeting.handleMeetingJoined(()=>{N.info("Meeting joined"),C(this,we,!0),this.emit("participantCount",this.getParticipantCount())}),this.meeting.handleMeetingLeft(({state:t})=>{t!=="ended"&&t!=="kicked"||(N.info("Meeting ended"),this.emit("meetingEnded"),this.cleanup(),window.triggerDyteRecording=!1,window.triggerRealtimeKitRecording=!1)}),this.options.autoStop&&C(this,ce,setInterval(()=>{this.scanMeetingState()},this.options.scanInterval))};class dn{constructor(e){this.meeting=e}getParticipantCount(){return this.meeting.participants.active.size}getMeeting(){return this.meeting}getWaitlistedCount(){return this.meeting.participants.waitlisted.toArray().length}handleMeetingJoined(e){this.meeting.self.on("roomJoined",e)}handleMeetingLeft(e){this.meeting.self.on("roomLeft",e)}handleParticipantJoin(e){this.meeting.participants.active.on("participantJoined",e)}handleParticipantLeave(e){this.meeting.participants.active.on("participantLeft",e)}removeAllListeners(){this.meeting.self.removeAllListeners()}}function Ft(n){let e=typeof n;if(e=="object"){if(Array.isArray(n))return"array";if(n===null)return"null"}return e}function gn(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}let W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Ve=[];for(let n=0;n<W.length;n++)Ve[W[n].charCodeAt(0)]=n;Ve["-".charCodeAt(0)]=W.indexOf("+");Ve["_".charCodeAt(0)]=W.indexOf("/");function mn(n){let e=n.length*3/4;n[n.length-2]=="="?e-=2:n[n.length-1]=="="&&(e-=1);let t=new Uint8Array(e),i=0,r=0,s,o=0;for(let a=0;a<n.length;a++){if(s=Ve[n.charCodeAt(a)],s===void 0)switch(n[a]){case"=":r=0;case`
|
|
2
2
|
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:o=s,r=1;break;case 1:t[i++]=o<<2|(s&48)>>4,o=s,r=2;break;case 2:t[i++]=(o&15)<<4|(s&60)>>2,o=s,r=3;break;case 3:t[i++]=(o&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,i)}function pn(n){let e="",t=0,i,r=0;for(let s=0;s<n.length;s++)switch(i=n[s],t){case 0:e+=W[i>>2],r=(i&3)<<4,t=1;break;case 1:e+=W[r|i>>4],r=(i&15)<<2,t=2;break;case 2:e+=W[r|i>>6],e+=W[i&63],t=0;break}return t&&(e+=W[r],e+="=",t==1&&(e+="=")),e}var Se;(function(n){n.symbol=Symbol.for("protobuf-ts/unknown"),n.onRead=(t,i,r,s,o)=>{(e(i)?i[n.symbol]:i[n.symbol]=[]).push({no:r,wireType:s,data:o})},n.onWrite=(t,i,r)=>{for(let{no:s,wireType:o,data:a}of n.list(i))r.tag(s,o).raw(a)},n.list=(t,i)=>{if(e(t)){let r=t[n.symbol];return i?r.filter(s=>s.no==i):r}return[]},n.last=(t,i)=>n.list(t,i).slice(-1)[0];const e=t=>t&&Array.isArray(t[n.symbol])})(Se||(Se={}));var L;(function(n){n[n.Varint=0]="Varint",n[n.Bit64=1]="Bit64",n[n.LengthDelimited=2]="LengthDelimited",n[n.StartGroup=3]="StartGroup",n[n.EndGroup=4]="EndGroup",n[n.Bit32=5]="Bit32"})(L||(L={}));function wn(){let n=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(n|=(r&127)<<i,!(r&128))return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[n,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,!(r&128))return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function $e(n,e,t){for(let s=0;s<28;s=s+7){const o=n>>>s,a=!(!(o>>>7)&&e==0),f=(a?o|128:o)&255;if(t.push(f),!a)return}const i=n>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),f=(a?o|128:o)&255;if(t.push(f),!a)return}t.push(e>>>31&1)}}const Ne=65536*65536;function Ct(n){let e=n[0]=="-";e&&(n=n.slice(1));const t=1e6;let i=0,r=0;function s(o,a){const f=Number(n.slice(o,a));r*=t,i=i*t+f,i>=Ne&&(r=r+(i/Ne|0),i=i%Ne)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,i,r]}function Xe(n,e){if(e>>>0<=2097151)return""+(Ne*e+(n>>>0));let t=n&16777215,i=(n>>>24|e<<8)>>>0&16777215,r=e>>16&65535,s=t+i*6777216+r*6710656,o=i+r*8147497,a=r*2,f=1e7;s>=f&&(o+=Math.floor(s/f),s%=f),o>=f&&(a+=Math.floor(o/f),o%=f);function h(d,E){let g=d?String(d):"";return E?"0000000".slice(g.length)+g:g}return h(a,0)+h(o,a)+h(s,1)}function at(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function bn(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}let I;function yn(){const n=new DataView(new ArrayBuffer(8));I=globalThis.BigInt!==void 0&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:n}:void 0}yn();function Mt(n){if(!n)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const At=/^-?[0-9]+$/,Fe=4294967296,ve=2147483648;class Dt{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Fe+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class M extends Dt{static from(e){if(I)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=I.C(e);case"number":if(e===0)return this.ZERO;e=I.C(e);case"bigint":if(!e)return this.ZERO;if(e<I.UMIN)throw new Error("signed value for ulong");if(e>I.UMAX)throw new Error("ulong too large");return I.V.setBigUint64(0,e,!0),new M(I.V.getInt32(0,!0),I.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!At.test(e))throw new Error("string is no integer");let[t,i,r]=Ct(e);if(t)throw new Error("signed value for ulong");return new M(i,r);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new M(e,e/Fe)}throw new Error("unknown value "+typeof e)}toString(){return I?this.toBigInt().toString():Xe(this.lo,this.hi)}toBigInt(){return Mt(I),I.V.setInt32(0,this.lo,!0),I.V.setInt32(4,this.hi,!0),I.V.getBigUint64(0,!0)}}M.ZERO=new M(0,0);class S extends Dt{static from(e){if(I)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=I.C(e);case"number":if(e===0)return this.ZERO;e=I.C(e);case"bigint":if(!e)return this.ZERO;if(e<I.MIN)throw new Error("signed long too small");if(e>I.MAX)throw new Error("signed long too large");return I.V.setBigInt64(0,e,!0),new S(I.V.getInt32(0,!0),I.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!At.test(e))throw new Error("string is no integer");let[t,i,r]=Ct(e);if(t){if(r>ve||r==ve&&i!=0)throw new Error("signed long too small")}else if(r>=ve)throw new Error("signed long too large");let s=new S(i,r);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new S(e,e/Fe):new S(-e,-e/Fe).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&ve)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new S(t,e)}toString(){if(I)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+Xe(e.lo,e.hi)}return Xe(this.lo,this.hi)}toBigInt(){return Mt(I),I.V.setInt32(0,this.lo,!0),I.V.setInt32(4,this.hi,!0),I.V.getBigInt64(0,!0)}}S.ZERO=new S(0,0);const ct={readUnknownField:!0,readerFactory:n=>new kn(n)};function vn(n){return n?Object.assign(Object.assign({},ct),n):ct}class kn{constructor(e,t){this.varint64=wn,this.uint32=bn,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,i=e&7;if(t<=0||i<0||i>5)throw new Error("illegal tag: field no "+t+" wire type "+i);return[t,i]}skip(e){let t=this.pos;switch(e){case L.Varint:for(;this.buf[this.pos++]&128;);break;case L.Bit64:this.pos+=4;case L.Bit32:this.pos+=4;break;case L.LengthDelimited:let i=this.uint32();this.pos+=i;break;case L.StartGroup:let r;for(;(r=this.tag()[1])!==L.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new S(...this.varint64())}uint64(){return new M(...this.varint64())}sint64(){let[e,t]=this.varint64(),i=-(e&1);return e=(e>>>1|(t&1)<<31)^i,t=t>>>1^i,new S(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new M(this.sfixed32(),this.sfixed32())}sfixed64(){return new S(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function m(n,e){if(!n)throw new Error(e)}const In=34028234663852886e22,Nn=-34028234663852886e22,En=4294967295,Tn=2147483647,Rn=-2147483648;function he(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>Tn||n<Rn)throw new Error("invalid int 32: "+n)}function Ce(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>En||n<0)throw new Error("invalid uint 32: "+n)}function tt(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>In||n<Nn))throw new Error("invalid float 32: "+n)}const ut={writeUnknownFields:!0,writerFactory:()=>new Ln};function On(n){return n?Object.assign(Object.assign({},ut),n):ut}class Ln{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Ce(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return he(e),at(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){tt(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Ce(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){he(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return he(e),e=(e<<1^e>>31)>>>0,at(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=S.from(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=M.from(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=S.from(e);return $e(t.lo,t.hi,this.buf),this}sint64(e){let t=S.from(e),i=t.hi>>31,r=t.lo<<1^i,s=(t.hi<<1|t.lo>>>31)^i;return $e(r,s,this.buf),this}uint64(e){let t=M.from(e);return $e(t.lo,t.hi,this.buf),this}}const ft={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},ht={ignoreUnknownFields:!1};function Sn(n){return n?Object.assign(Object.assign({},ht),n):ht}function Fn(n){return n?Object.assign(Object.assign({},ft),n):ft}const xt=Symbol.for("protobuf-ts/message-type");function lt(n){let e=!1;const t=[];for(let i=0;i<n.length;i++){let r=n.charAt(i);r=="_"?e=!0:/\d/.test(r)?(t.push(r),e=!0):e?(t.push(r.toUpperCase()),e=!1):i==0?t.push(r.toLowerCase()):t.push(r)}return t.join("")}var u;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(u||(u={}));var V;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING",n[n.NUMBER=2]="NUMBER"})(V||(V={}));var Me;(function(n){n[n.NO=0]="NO",n[n.PACKED=1]="PACKED",n[n.UNPACKED=2]="UNPACKED"})(Me||(Me={}));function Cn(n){var e,t,i,r;return n.localName=(e=n.localName)!==null&&e!==void 0?e:lt(n.name),n.jsonName=(t=n.jsonName)!==null&&t!==void 0?t:lt(n.name),n.repeat=(i=n.repeat)!==null&&i!==void 0?i:Me.NO,n.opt=(r=n.opt)!==null&&r!==void 0?r:n.repeat||n.oneof?!1:n.kind=="message",n}function Mn(n){if(typeof n!="object"||n===null||!n.hasOwnProperty("oneofKind"))return!1;switch(typeof n.oneofKind){case"string":return n[n.oneofKind]===void 0?!1:Object.keys(n).length==2;case"undefined":return Object.keys(n).length==1;default:return!1}}class An{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;const e=[],t=[],i=[];for(let r of this.fields)if(r.oneof)i.includes(r.oneof)||(i.push(r.oneof),e.push(r.oneof),t.push(r.oneof));else switch(t.push(r.localName),r.kind){case"scalar":case"enum":(!r.opt||r.repeat)&&e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName);break}this.data={req:e,known:t,oneofs:Object.values(i)}}is(e,t,i=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let r=Object.keys(e),s=this.data;if(r.length<s.req.length||s.req.some(o=>!r.includes(o))||!i&&r.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(const o of s.oneofs){const a=e[o];if(!Mn(a))return!1;if(a.oneofKind===void 0)continue;const f=this.fields.find(h=>h.localName===a.oneofKind);if(!f||!this.field(a[a.oneofKind],f,i,t))return!1}for(const o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,i,t))return!1;return!0}field(e,t,i,r){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,r,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,r):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),i,r):this.message(e,t.T(),i,r);case"map":if(typeof e!="object"||e===null)return!1;if(r<2)return!0;if(!this.mapKeys(e,t.K,r))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,r,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,r);case"message":return this.messages(Object.values(e),t.V.T(),i,r)}break}return!0}message(e,t,i,r){return i?t.isAssignable(e,r):t.is(e,r)}messages(e,t,i,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(i){for(let s=0;s<e.length&&s<r;s++)if(!t.isAssignable(e[s],r-1))return!1}else for(let s=0;s<e.length&&s<r;s++)if(!t.is(e[s],r-1))return!1;return!0}scalar(e,t,i){let r=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(i){case V.BIGINT:return r=="bigint";case V.NUMBER:return r=="number"&&!isNaN(e);default:return r=="string"}case u.BOOL:return r=="boolean";case u.STRING:return r=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return r=="number"&&!isNaN(e);default:return r=="number"&&Number.isInteger(e)}}scalars(e,t,i,r){if(!Array.isArray(e))return!1;if(i<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<i;s++)if(!this.scalar(e[s],t,r))return!1}return!0}mapKeys(e,t,i){let r=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(r.slice(0,i).map(s=>parseInt(s)),t,i);case u.BOOL:return this.scalars(r.slice(0,i).map(s=>s=="true"?!0:s=="false"?!1:s),t,i);default:return this.scalars(r,t,i,V.STRING)}}}function _(n,e){switch(e){case V.BIGINT:return n.toBigInt();case V.NUMBER:return n.toNumber();default:return n.toString()}}class Dn{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};const t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(const i of t)this.fMap[i.name]=i,this.fMap[i.jsonName]=i,this.fMap[i.localName]=i}}assert(e,t,i){if(!e){let r=Ft(i);throw(r=="number"||r=="boolean")&&(r=i.toString()),new Error(`Cannot parse JSON ${r} for ${this.info.typeName}#${t}`)}}read(e,t,i){this.prepare();const r=[];for(const[s,o]of Object.entries(e)){const a=this.fMap[s];if(!a){if(!i.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}const f=a.localName;let h;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(r.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(a.oneof),h=t[a.oneof]={oneofKind:f}}else h=t;if(a.kind=="map"){if(o===null)continue;this.assert(gn(o),a.name,o);const d=h[f];for(const[E,g]of Object.entries(o)){this.assert(g!==null,a.name+" map value",null);let A;switch(a.V.kind){case"message":A=a.V.T().internalJsonRead(g,i);break;case"enum":if(A=this.enum(a.V.T(),g,a.name,i.ignoreUnknownFields),A===!1)continue;break;case"scalar":A=this.scalar(g,a.V.T,a.V.L,a.name);break}this.assert(A!==void 0,a.name+" map value",g);let U=E;a.K==u.BOOL&&(U=U=="true"?!0:U=="false"?!1:U),U=this.scalar(U,a.K,V.STRING,a.name).toString(),d[U]=A}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);const d=h[f];for(const E of o){this.assert(E!==null,a.name,null);let g;switch(a.kind){case"message":g=a.T().internalJsonRead(E,i);break;case"enum":if(g=this.enum(a.T(),E,a.name,i.ignoreUnknownFields),g===!1)continue;break;case"scalar":g=this.scalar(E,a.T,a.L,a.name);break}this.assert(g!==void 0,a.name,o),d.push(g)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}h[f]=a.T().internalJsonRead(o,i,h[f]);break;case"enum":if(o===null)continue;let d=this.enum(a.T(),o,a.name,i.ignoreUnknownFields);if(d===!1)continue;h[f]=d;break;case"scalar":if(o===null)continue;h[f]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,i,r){if(e[0]=="google.protobuf.NullValue"&&m(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${i}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return m(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${i}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o>"u"&&r?!1:(m(typeof o=="number",`Unable to parse field ${this.info.typeName}#${i}, enum ${e[0]} has no value for "${t}".`),o)}m(!1,`Unable to parse field ${this.info.typeName}#${i}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,i,r){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&tt(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?Ce(a):he(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return _(S.ZERO,i);if(typeof e!="number"&&typeof e!="string")break;return _(S.from(e),i);case u.FIXED64:case u.UINT64:if(e===null)return _(M.ZERO,i);if(typeof e!="number"&&typeof e!="string")break;return _(M.from(e),i);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(f){f="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return mn(e)}}catch(o){s=o.message}this.assert(!1,r+(s?" - "+s:""),e)}}class xn{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){const i={},r=e;for(const s of this.fields){if(!s.oneof){let h=this.field(s,r[s.localName],t);h!==void 0&&(i[t.useProtoFieldName?s.name:s.jsonName]=h);continue}const o=r[s.oneof];if(o.oneofKind!==s.localName)continue;const a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let f=this.field(s,o[s.localName],a);m(f!==void 0),i[t.useProtoFieldName?s.name:s.jsonName]=f}return i}field(e,t,i){let r;if(e.kind=="map"){m(typeof t=="object"&&t!==null);const s={};switch(e.V.kind){case"scalar":for(const[f,h]of Object.entries(t)){const d=this.scalar(e.V.T,h,e.name,!1,!0);m(d!==void 0),s[f.toString()]=d}break;case"message":const o=e.V.T();for(const[f,h]of Object.entries(t)){const d=this.message(o,h,e.name,i);m(d!==void 0),s[f.toString()]=d}break;case"enum":const a=e.V.T();for(const[f,h]of Object.entries(t)){m(h===void 0||typeof h=="number");const d=this.enum(a,h,e.name,!1,!0,i.enumAsInteger);m(d!==void 0),s[f.toString()]=d}break}(i.emitDefaultValues||Object.keys(s).length>0)&&(r=s)}else if(e.repeat){m(Array.isArray(t));const s=[];switch(e.kind){case"scalar":for(let f=0;f<t.length;f++){const h=this.scalar(e.T,t[f],e.name,e.opt,!0);m(h!==void 0),s.push(h)}break;case"enum":const o=e.T();for(let f=0;f<t.length;f++){m(t[f]===void 0||typeof t[f]=="number");const h=this.enum(o,t[f],e.name,e.opt,!0,i.enumAsInteger);m(h!==void 0),s.push(h)}break;case"message":const a=e.T();for(let f=0;f<t.length;f++){const h=this.message(a,t[f],e.name,i);m(h!==void 0),s.push(h)}break}(i.emitDefaultValues||s.length>0||i.emitDefaultValues)&&(r=s)}else switch(e.kind){case"scalar":r=this.scalar(e.T,t,e.name,e.opt,i.emitDefaultValues);break;case"enum":r=this.enum(e.T(),t,e.name,e.opt,i.emitDefaultValues,i.enumAsInteger);break;case"message":r=this.message(e.T(),t,e.name,i);break}return r}enum(e,t,i,r,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!r?void 0:null;if(t===void 0){m(r);return}if(!(t===0&&!s&&!r))return m(typeof t=="number"),m(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,i,r){return t===void 0?r.emitDefaultValues?null:void 0:e.internalJsonWrite(t,r)}scalar(e,t,i,r,s){if(t===void 0){m(r);return}const o=s||r;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(he(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(Ce(t),t);case u.FLOAT:tt(t);case u.DOUBLE:return t===0?o?0:void 0:(m(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?o?"":void 0:(m(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(m(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:m(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=M.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:m(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let f=S.from(t);return f.isZero()&&!o?void 0:f.toString();case u.BYTES:return m(t instanceof Uint8Array),t.byteLength?pn(t):o?"":void 0}}}function Ge(n,e=V.STRING){switch(n){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return _(M.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return _(S.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}class Bn{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(i=>[i.no,i]))}}read(e,t,i,r){this.prepare();const s=r===void 0?e.len:e.pos+r;for(;e.pos<s;){const[o,a]=e.tag(),f=this.fieldNoToField.get(o);if(!f){let g=i.readUnknownField;if(g=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let A=e.skip(a);g!==!1&&(g===!0?Se.onRead:g)(this.info.typeName,t,o,a,A);continue}let h=t,d=f.repeat,E=f.localName;switch(f.oneof&&(h=h[f.oneof],h.oneofKind!==E&&(h=t[f.oneof]={oneofKind:E})),f.kind){case"scalar":case"enum":let g=f.kind=="enum"?u.INT32:f.T,A=f.kind=="scalar"?f.L:void 0;if(d){let ye=h[E];if(a==L.LengthDelimited&&g!=u.STRING&&g!=u.BYTES){let Pe=e.uint32()+e.pos;for(;e.pos<Pe;)ye.push(this.scalar(e,g,A))}else ye.push(this.scalar(e,g,A))}else h[E]=this.scalar(e,g,A);break;case"message":if(d){let ye=h[E],Pe=f.T().internalBinaryRead(e,e.uint32(),i);ye.push(Pe)}else h[E]=f.T().internalBinaryRead(e,e.uint32(),i,h[E]);break;case"map":let[U,Qt]=this.mapEntry(f,e,i);h[E][U]=Qt;break}}}mapEntry(e,t,i){let r=t.uint32(),s=t.pos+r,o,a;for(;t.pos<s;){let[f,h]=t.tag();switch(f){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,V.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=e.V.T().internalBinaryRead(t,t.uint32(),i);break}break;default:throw new Error(`Unknown field ${f} (wire type ${h}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let f=Ge(e.K);o=e.K==u.BOOL?f.toString():f}if(a===void 0)switch(e.V.kind){case"scalar":a=Ge(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}scalar(e,t,i){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return _(e.int64(),i);case u.UINT64:return _(e.uint64(),i);case u.FIXED64:return _(e.fixed64(),i);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return _(e.sfixed64(),i);case u.SINT32:return e.sint32();case u.SINT64:return _(e.sint64(),i)}}}class _n{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,i)=>t.no-i.no)}}write(e,t,i){this.prepare();for(const s of this.fields){let o,a,f=s.repeat,h=s.localName;if(s.oneof){const d=e[s.oneof];if(d.oneofKind!==h)continue;o=d[h],a=!0}else o=e[h],a=!1;switch(s.kind){case"scalar":case"enum":let d=s.kind=="enum"?u.INT32:s.T;if(f)if(m(Array.isArray(o)),f==Me.PACKED)this.packed(t,d,s.no,o);else for(const E of o)this.scalar(t,d,s.no,E,!0);else o===void 0?m(s.opt):this.scalar(t,d,s.no,o,a||s.opt);break;case"message":if(f){m(Array.isArray(o));for(const E of o)this.message(t,i,s.T(),s.no,E)}else this.message(t,i,s.T(),s.no,o);break;case"map":m(typeof o=="object"&&o!==null);for(const[E,g]of Object.entries(o))this.mapEntry(t,i,s,E,g);break}}let r=i.writeUnknownFields;r!==!1&&(r===!0?Se.onWrite:r)(this.info.typeName,e,t)}mapEntry(e,t,i,r,s){e.tag(i.no,L.LengthDelimited),e.fork();let o=r;switch(i.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(r);break;case u.BOOL:m(r=="true"||r=="false"),o=r=="true";break}switch(this.scalar(e,i.K,1,o,!0),i.V.kind){case"scalar":this.scalar(e,i.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,i.V.T(),2,s);break}e.join()}message(e,t,i,r,s){s!==void 0&&(i.internalBinaryWrite(s,e.tag(r,L.LengthDelimited).fork(),t),e.join())}scalar(e,t,i,r,s){let[o,a,f]=this.scalarInfo(t,r);(!f||s)&&(e.tag(i,o),e[a](r))}packed(e,t,i,r){if(!r.length)return;m(t!==u.BYTES&&t!==u.STRING),e.tag(i,L.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<r.length;o++)e[s](r[o]);e.join()}scalarInfo(e,t){let i=L.Varint,r,s=t===void 0,o=t===0;switch(e){case u.INT32:r="int32";break;case u.STRING:o=s||!t.length,i=L.LengthDelimited,r="string";break;case u.BOOL:o=t===!1,r="bool";break;case u.UINT32:r="uint32";break;case u.DOUBLE:i=L.Bit64,r="double";break;case u.FLOAT:i=L.Bit32,r="float";break;case u.INT64:o=s||S.from(t).isZero(),r="int64";break;case u.UINT64:o=s||M.from(t).isZero(),r="uint64";break;case u.FIXED64:o=s||M.from(t).isZero(),i=L.Bit64,r="fixed64";break;case u.BYTES:o=s||!t.byteLength,i=L.LengthDelimited,r="bytes";break;case u.FIXED32:i=L.Bit32,r="fixed32";break;case u.SFIXED32:i=L.Bit32,r="sfixed32";break;case u.SFIXED64:o=s||S.from(t).isZero(),i=L.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:o=s||S.from(t).isZero(),r="sint64";break}return[i,r,s||o]}}function Kn(n){const e=n.messagePrototype?Object.create(n.messagePrototype):Object.defineProperty({},xt,{value:n});for(let t of n.fields){let i=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[i]=[];else switch(t.kind){case"scalar":e[i]=Ge(t.T,t.L);break;case"enum":e[i]=0;break;case"map":e[i]={};break}}return e}function je(n,e,t){let i,r=t,s;for(let o of n.fields){let a=o.localName;if(o.oneof){const f=r[o.oneof];if((f==null?void 0:f.oneofKind)==null)continue;if(i=f[a],s=e[o.oneof],s.oneofKind=f.oneofKind,i==null){delete s[a];continue}}else if(i=r[a],s=e,i==null)continue;switch(o.repeat&&(s[a].length=i.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let h=0;h<i.length;h++)s[a][h]=i[h];else s[a]=i;break;case"message":let f=o.T();if(o.repeat)for(let h=0;h<i.length;h++)s[a][h]=f.create(i[h]);else s[a]===void 0?s[a]=f.create(i):f.mergePartial(s[a],i);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],i);break;case"message":let h=o.V.T();for(let d of Object.keys(i))s[a][d]=h.create(i[d]);break}break}}}function Vn(n,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let i of n.fields){let r=i.localName,s=i.oneof?e[i.oneof][r]:e[r],o=i.oneof?t[i.oneof][r]:t[r];switch(i.kind){case"enum":case"scalar":let a=i.kind=="enum"?u.INT32:i.T;if(!(i.repeat?dt(a,s,o):Bt(a,s,o)))return!1;break;case"map":if(!(i.V.kind=="message"?gt(i.V.T(),ke(s),ke(o)):dt(i.V.kind=="enum"?u.INT32:i.V.T,ke(s),ke(o))))return!1;break;case"message":let f=i.T();if(!(i.repeat?gt(f,s,o):f.equals(s,o)))return!1;break}}return!0}const ke=Object.values;function Bt(n,e,t){if(e===t)return!0;if(n!==u.BYTES)return!1;let i=e,r=t;if(i.length!==r.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!=r[s])return!1;return!0}function dt(n,e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Bt(n,e[i],t[i]))return!1;return!0}function gt(n,e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n.equals(e[i],t[i]))return!1;return!0}const _t=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),Un=_t[xt]={};class Pn{constructor(e,t,i){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Cn),this.options=i??{},Un.value=this,this.messagePrototype=Object.create(null,_t),this.refTypeCheck=new An(this),this.refJsonReader=new Dn(this),this.refJsonWriter=new xn(this),this.refBinReader=new Bn(this),this.refBinWriter=new _n(this)}create(e){let t=Kn(this);return e!==void 0&&je(this,t,e),t}clone(e){let t=this.create();return je(this,t,e),t}equals(e,t){return Vn(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){je(this,e,t)}fromBinary(e,t){let i=vn(t);return this.internalBinaryRead(i.readerFactory(e),e.byteLength,i)}fromJson(e,t){return this.internalJsonRead(e,Sn(t))}fromJsonString(e,t){let i=JSON.parse(e);return this.fromJson(i,t)}toJson(e,t){return this.internalJsonWrite(e,Fn(t))}toJsonString(e,t){var i;let r=this.toJson(e,t);return JSON.stringify(r,null,(i=t==null?void 0:t.prettySpaces)!==null&&i!==void 0?i:0)}toBinary(e,t){let i=On(t);return this.internalBinaryWrite(e,i.writerFactory(),i).finish()}internalJsonRead(e,t,i){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=i??this.create();return this.refJsonReader.read(e,r,t),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${Ft(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,i){return this.refBinWriter.write(e,t,i),t}internalBinaryRead(e,t,i,r){let s=r??this.create();return this.refBinReader.read(e,s,i,t),s}}var Wn=Object.defineProperty,$n=(n,e,t)=>e in n?Wn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,jn=(n,e,t)=>($n(n,typeof e!="symbol"?e+"":e,t),t),nt=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},c=(n,e,t)=>(nt(n,e,"read from private field"),t?t.call(n):e.get(n)),b=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},p=(n,e,t,i)=>(nt(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),w=(n,e,t)=>(nt(n,e,"access private method"),t),Ae={},Jn={get exports(){return Ae},set exports(n){Ae=n}},se=typeof Reflect=="object"?Reflect:null,mt=se&&typeof se.apply=="function"?se.apply:function(n,e,t){return Function.prototype.apply.call(n,e,t)},Ee;se&&typeof se.ownKeys=="function"?Ee=se.ownKeys:Object.getOwnPropertySymbols?Ee=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Ee=function(n){return Object.getOwnPropertyNames(n)};function Xn(n){console&&console.warn&&console.warn(n)}var Kt=Number.isNaN||function(n){return n!==n};function k(){k.init.call(this)}Jn.exports=k;Ae.once=qn;k.EventEmitter=k;k.prototype._events=void 0;k.prototype._eventsCount=0;k.prototype._maxListeners=void 0;var pt=10;function Ue(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(k,"defaultMaxListeners",{enumerable:!0,get:function(){return pt},set:function(n){if(typeof n!="number"||n<0||Kt(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");pt=n}});k.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};k.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||Kt(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function Vt(n){return n._maxListeners===void 0?k.defaultMaxListeners:n._maxListeners}k.prototype.getMaxListeners=function(){return Vt(this)};k.prototype.emit=function(n){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);var i=n==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=r[n];if(a===void 0)return!1;if(typeof a=="function")mt(a,this,e);else for(var f=a.length,h=jt(a,f),t=0;t<f;++t)mt(h[t],this,e);return!0};function Ut(n,e,t,i){var r,s,o;if(Ue(t),s=n._events,s===void 0?(s=n._events=Object.create(null),n._eventsCount=0):(s.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),s=n._events),o=s[e]),o===void 0)o=s[e]=t,++n._eventsCount;else if(typeof o=="function"?o=s[e]=i?[t,o]:[o,t]:i?o.unshift(t):o.push(t),r=Vt(n),r>0&&o.length>r&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=o.length,Xn(a)}return n}k.prototype.addListener=function(n,e){return Ut(this,n,e,!1)};k.prototype.on=k.prototype.addListener;k.prototype.prependListener=function(n,e){return Ut(this,n,e,!0)};function Gn(){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 Pt(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=Gn.bind(i);return r.listener=t,i.wrapFn=r,r}k.prototype.once=function(n,e){return Ue(e),this.on(n,Pt(this,n,e)),this};k.prototype.prependOnceListener=function(n,e){return Ue(e),this.prependListener(n,Pt(this,n,e)),this};k.prototype.removeListener=function(n,e){var t,i,r,s,o;if(Ue(e),i=this._events,i===void 0)return this;if(t=i[n],t===void 0)return this;if(t===e||t.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[n],i.removeListener&&this.emit("removeListener",n,t.listener||e));else if(typeof t!="function"){for(r=-1,s=t.length-1;s>=0;s--)if(t[s]===e||t[s].listener===e){o=t[s].listener,r=s;break}if(r<0)return this;r===0?t.shift():Zn(t,r),t.length===1&&(i[n]=t[0]),i.removeListener!==void 0&&this.emit("removeListener",n,o||e)}return this};k.prototype.off=k.prototype.removeListener;k.prototype.removeAllListeners=function(n){var e,t,i;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[n]),this;if(arguments.length===0){var r=Object.keys(t),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=t[n],typeof e=="function")this.removeListener(n,e);else if(e!==void 0)for(i=e.length-1;i>=0;i--)this.removeListener(n,e[i]);return this};function Wt(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Yn(r):jt(r,r.length)}k.prototype.listeners=function(n){return Wt(this,n,!0)};k.prototype.rawListeners=function(n){return Wt(this,n,!1)};k.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):$t.call(n,e)};k.prototype.listenerCount=$t;function $t(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}k.prototype.eventNames=function(){return this._eventsCount>0?Ee(this._events):[]};function jt(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Zn(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Yn(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function qn(n,e){return new Promise(function(t,i){function r(o){n.removeListener(e,s),i(o)}function s(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}Jt(n,e,s,{once:!0}),e!=="error"&&zn(n,r,{once:!0})})}function zn(n,e,t){typeof n.on=="function"&&Jt(n,"error",e,t)}function Jt(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(s){i.once&&n.removeEventListener(e,r),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}class Qn extends Pn{constructor(){super("message.v1.SocketMessage",[{no:1,name:"event",kind:"scalar",T:13},{no:2,name:"id",kind:"scalar",opt:!0,T:9},{no:3,name:"payload",kind:"scalar",opt:!0,T:12},{no:4,name:"metadata",kind:"scalar",opt:!0,T:12}])}}const wt=new Qn;class Xt{static encode(e){return wt.toBinary(e)}static decode(e){return wt.fromBinary(new Uint8Array(e))}}function Hn(n,e){return Math.floor(Math.random()*(e-n+1)+n)}var J;class ei{constructor(e={}){jn(this,"opts"),b(this,J,void 0),this.opts={initialTimeout:e.initialTimeout||1e3,maxTimeout:e.maxTimeout||1e4,factor:e.factor||2},p(this,J,0)}async wait(){p(this,J,c(this,J)+1);const e=Hn(0,Math.min(this.opts.maxTimeout,this.opts.initialTimeout*2**c(this,J)));await new Promise(t=>{setTimeout(t,e)})}getAttempts(){return c(this,J)}reset(){p(this,J,0)}}J=new WeakMap;const j={debug:0,info:1,warn:2,error:3};var z,Q;class ti{constructor(e){b(this,z,void 0),b(this,Q,void 0),p(this,z,console),p(this,Q,e)}debug(...e){j[c(this,Q)]>j.debug||c(this,z).debug("[Sockrates]:",...e)}info(...e){j[c(this,Q)]>j.info||c(this,z).info("[Sockrates]:",...e)}warn(...e){j[c(this,Q)]>j.warn||c(this,z).warn("[Sockrates]:",...e)}error(...e){j[c(this,Q)]>j.error||c(this,z).error("[Sockrates]:",...e)}}z=new WeakMap,Q=new WeakMap;var Gt=(n=>(n[n.CONNECTING=0]="CONNECTING",n[n.OPEN=1]="OPEN",n[n.CLOSING=2]="CLOSING",n[n.CLOSED=3]="CLOSED",n))(Gt||{});const bt="2",yt="3";var O,te,y,T,X,F,$,q,B,ne,ie,P,Ze,Zt,fe,Te,Ye,Yt,Re,Je,De,qe,ze,qt,le,Oe,oe,de,xe,Qe,ae,ge,He,zt,me,Le,pe,Be;class ni{constructor(e,t){b(this,Ze),b(this,fe),b(this,Ye),b(this,Re),b(this,De),b(this,ze),b(this,le),b(this,oe),b(this,xe),b(this,ae),b(this,He),b(this,me),b(this,pe),b(this,O,void 0),b(this,te,void 0),b(this,y,void 0),b(this,T,void 0),b(this,X,void 0),b(this,F,void 0),b(this,$,void 0),b(this,q,void 0),b(this,B,void 0),b(this,ne,void 0),b(this,ie,void 0),b(this,P,void 0);var i,r,s,o,a,f,h,d,E,g,A;p(this,te,e),p(this,X,[]),p(this,F,new Ae),p(this,$,!0),p(this,B,!1),p(this,y,t??{}),(i=c(this,y)).autoReconnect??(i.autoReconnect=!0),(r=c(this,y)).retryConnectionInterval??(r.retryConnectionInterval=1e3),(s=c(this,y)).pingTimeout??(s.pingTimeout=3e4),(o=c(this,y)).connectionTimeout??(o.connectionTimeout=5e3),(a=c(this,y)).debug??(a.debug=!0),(f=c(this,y)).maxReconnectionAttempts??(f.maxReconnectionAttempts=10),(h=c(this,y)).disconnectOnPingTimeout??(h.disconnectOnPingTimeout=!0),(d=c(this,y)).queueOnDisconnect??(d.queueOnDisconnect=!1),(E=c(this,y)).flushOnReconnect??(E.flushOnReconnect=!1),(g=c(this,y)).clientInitiatedPings??(g.clientInitiatedPings=!1),(A=c(this,y)).clientInitiatedPingInterval??(A.clientInitiatedPingInterval=3e4),p(this,q,{code:void 0,reason:void 0}),p(this,T,c(this,y).logger??new ti(c(this,y).debug?"debug":"info")),p(this,P,new ei)}get readyState(){var e;return(e=c(this,O))==null?void 0:e.readyState}get url(){return c(this,te)}updateURL(e){p(this,te,e),w(this,ze,qt).call(this)}get config(){return c(this,y)}get sendQueue(){return c(this,X)}flush(){if(!c(this,y).queueOnDisconnect)return!1;const e=[];return c(this,X).forEach(t=>{this.send(t.event,t.id,t.payload,t.metadata)||e.push(t)}),p(this,X,e),c(this,X)}async connect(e=!1){if(!e&&[0,1].includes(this.readyState)){c(this,T).debug("Websocket was already connecting or connected.");return}if(c(this,$)!==!1)return new Promise((t,i)=>{w(this,ae,ge).call(this),w(this,pe,Be).call(this);try{p(this,O,new WebSocket(w(this,Ze,Zt).call(this,c(this,te)))),c(this,O).binaryType="arraybuffer",c(this,T).debug("Connecting");const r=setTimeout(()=>{c(this,T).debug("Connection timeout. Closing socket"),p(this,$,!0),w(this,pe,Be).call(this),c(this,O).close(3001,"Connection Timeout"),c(this,y).autoReconnect&&!c(this,B)&&(c(this,F).emit("reconnecting"),w(this,le,Oe).call(this)),i(new Error("Connection timed out!"))},c(this,y).connectionTimeout);c(this,O).onopen=()=>{c(this,T).debug(`Ready State: ${Gt[c(this,O).readyState]}`),r&&clearTimeout(r),w(this,xe,Qe).call(this),w(this,He,zt).call(this),p(this,q,{code:void 0,reason:void 0}),c(this,F).emit("connected"),c(this,y).flushOnReconnect&&this.flush(),t()},c(this,O).onclose=s=>{try{r&&clearTimeout(r);const{code:o,reason:a}=s;i(a),c(this,T).debug("Socket closed. Close event:",{event:s}),c(this,T).debug(`Connection closed code: ${o}`),c(this,T).debug(`Connection closed reason: ${a}`),c(this,B)||w(this,De,qe).call(this,o,a)}catch(o){w(this,fe,Te).call(this,o)}},c(this,O).onerror=s=>{w(this,fe,Te).call(this,s)},c(this,O).onmessage=s=>w(this,Ye,Yt).call(this,s)}catch(r){w(this,fe,Te).call(this,r,i)}})}send(e,t,i,r){const s={event:e,id:t,payload:i,metadata:r};if(c(this,y).queueOnDisconnect&&(!c(this,O)||c(this,O).readyState!==1))return c(this,T).debug("Queuing message since socket is not connected!",s),c(this,X).push(s),!1;const o=Xt.encode(s);return w(this,oe,de).call(this,o)}emit(e,t,i,r){return this.send(e,t,i,r)}sendRaw(e){return w(this,oe,de).call(this,e)}receive(e,t){return c(this,F).on(e.toString(),t)}on(e,t){if(typeof e=="string"&&(e==="connected"||e==="disconnected"||e==="errored"||e==="reconnected"||e==="reconnecting"||e==="reconnectAttempt"||e==="reconnectFailure"||e==="failed")){c(this,F).on(e,t);return}this.receive(e,t)}removeAllListeners(){c(this,F).removeAllListeners()}removeReceiver(e,t){this.removeListener(e,t)}removeListener(e,t){c(this,F).removeListener(e.toString(),t)}removeReceivers(e){this.removeListeners(e)}removeListeners(e){c(this,F).listeners(e.toString()).map(t=>this.removeListener(e,t))}disconnect(){p(this,$,!1),w(this,ae,ge).call(this),w(this,me,Le).call(this),this.removeAllListeners(),p(this,q,{code:1e3,reason:"Sockrates disconnect method called"}),c(this,O).close(1e3,"Sockrates disconnect method called.")}}O=new WeakMap,te=new WeakMap,y=new WeakMap,T=new WeakMap,X=new WeakMap,F=new WeakMap,$=new WeakMap,q=new WeakMap,B=new WeakMap,ne=new WeakMap,ie=new WeakMap,P=new WeakMap,Ze=new WeakSet,Zt=function(n){if(n.startsWith("ws://")||n.startsWith("wss://"))return n;if(n.startsWith("https://"))return`wss://${n.substring(8)}`;if(n.startsWith("http://"))return`ws://${n.substring(7)}`;throw new Error("Invalid URL. URL must start with http(s):// or ws(s)://.")},fe=new WeakSet,Te=function(n,e){c(this,T).error("Error:",{error:n}),c(this,F).emit("errored",{error:n}),e==null||e(n)},Ye=new WeakSet,Yt=function(n){if(w(this,xe,Qe).call(this),n.data===bt){c(this,T).debug("Received ping from server"),w(this,oe,de).call(this,yt);return}if(n.data===yt){c(this,T).debug("Received pong from server");return}const e=Xt.decode(n.data),{id:t,payload:i}=e;c(this,T).debug("Received message",{event:e.event,messageID:t}),c(this,F).emit(e.event.toString(),{id:t,payload:i})},Re=new WeakSet,Je=function(){return c(this,O).readyState===1},De=new WeakSet,qe=function(n,e){p(this,q,{reason:e,code:n}),c(this,F).emit("disconnected",{code:n,reason:e})},ze=new WeakSet,qt=function(){const{reason:n,code:e}=c(this,q);e&&e!==1e3&&c(this,$)&&c(this,y).autoReconnect&&!c(this,B)&&(c(this,T).debug(`Triggering reconnection due to ${n}.`),c(this,F).emit("reconnecting"),w(this,le,Oe).call(this))},le=new WeakSet,Oe=async function(n=!0){if(n&&c(this,B)){c(this,T).debug("Reconnect called when already in a reconnect loop. Ignoring.");return}if(c(this,B)||c(this,P).reset(),c(this,y).maxReconnectionAttempts!==null&&c(this,P).getAttempts()>=c(this,y).maxReconnectionAttempts){c(this,F).emit("failed"),p(this,B,!1);return}p(this,B,!0),w(this,pe,Be).call(this),w(this,ae,ge).call(this);try{if(await c(this,P).wait(),c(this,$)===!1)return;if(c(this,T).debug(`Reconnection attempt ${c(this,P).getAttempts()}`),c(this,F).emit("reconnectAttempt",{attempt:c(this,P).getAttempts()}),await this.connect(),!w(this,Re,Je).call(this))throw Error("Reconnect Failed");p(this,B,!1),p(this,q,{code:void 0,reason:void 0}),c(this,F).emit("reconnected")}catch{c(this,T).debug("Failed to reconnect."),c(this,F).emit("reconnectFailure",{attempt:c(this,P).getAttempts()}),w(this,le,Oe).call(this,!1)}},oe=new WeakSet,de=function(n){try{return c(this,O).send(n),!0}catch(e){return c(this,T).error(e.message),!1}},xe=new WeakSet,Qe=function(){this.config.disconnectOnPingTimeout&&(c(this,T).debug("Resetting ping timeout"),w(this,ae,ge).call(this),p(this,ne,setTimeout(()=>{var n;c(this,T).debug("Disconnecting the socket due to ping timeout"),p(this,$,!0);const e=3002,t="Ping timeout";(n=c(this,O))==null||n.close(e,t),w(this,De,qe).call(this,e,t)},c(this,y).pingTimeout)))},ae=new WeakSet,ge=function(){c(this,ne)&&(clearTimeout(c(this,ne)),p(this,ne,void 0))},He=new WeakSet,zt=function(){w(this,me,Le).call(this),c(this,y).clientInitiatedPings&&p(this,ie,setInterval(()=>{w(this,Re,Je).call(this)&&(c(this,T).debug("Sending client-initiated ping"),w(this,oe,de).call(this,bt))},c(this,y).clientInitiatedPingInterval))},me=new WeakSet,Le=function(){c(this,ie)&&(clearInterval(c(this,ie)),p(this,ie,void 0))},pe=new WeakSet,Be=function(){w(this,me,Le).call(this),c(this,O)&&(c(this,O).onopen=void 0,c(this,O).onerror=void 0,c(this,O).onmessage=void 0,c(this,O).onclose=void 0)};class ii{constructor(e,t){this.url=e,console.info(`Creating websocket with url: ${e} and config: ${t}`)}sendRaw(e){return console.info(`Sending raw message to websocket: ${e}`),!0}connect(e){return console.info(`Connecting to websocket: ${this.url} with force: ${e}`),Promise.resolve()}disconnect(){console.info(`Disconnecting from websocket: ${this.url}`)}on(e,t){console.info(`Adding listener to websocket: ${e} with listener: ${t}`)}}var Z,ee,be;class ri{constructor(e,t=!1){D(this,Z,null);D(this,ee,!1);D(this,be,!1);this.wsUrl=e,this.devMode=t}get connected(){return l(this,ee)}async connect(e){let t;this.devMode?t=new ii(this.wsUrl,{queueOnDisconnect:!0,flushOnReconnect:!0}):t=new ni(this.wsUrl,{queueOnDisconnect:!0,flushOnReconnect:!0}),e.participants.addListener("broadcastedMessage",i=>t.sendRaw(JSON.stringify(i))),N.info("Connecting to websocket"),t.on("connected",()=>{N.info("Connected to websocket")}),await t.connect(!0),C(this,Z,t),C(this,ee,!0)}disconnect(){l(this,Z)&&(l(this,Z).disconnect(),C(this,ee,!1))}startRecordingMessage(){if(l(this,be))throw new Error("Start recording message already sent");if(l(this,Z)&&l(this,ee))C(this,be,!0),l(this,Z).sendRaw(JSON.stringify({type:"StartRecording"}));else throw new Error("Not connected to websocket, make sure you have called init.")}}Z=new WeakMap,ee=new WeakMap,be=new WeakMap;class si{constructor(){}checkIfSDKEnabled(){return N.info("Check if SDK enabled"),window.dyteRecordingSdk===!0||window.realtimeKitRecordingSdk===!0}checkIfRecordingTriggerAdded(){return N.info("Check if recording trigger added"),window.triggerDyteRecording===!0||window.triggerRealtimeKitRecording===!0}checkMeetingJoined(){var e;return N.info("Check if meeting joined getter available"),((e=window.realtimeKitRecording)==null?void 0:e.isMeetingJoined())!==!0}checkParticipantCount(){var e;return N.info("Check if participant count getter available"),((e=window.realtimeKitRecording)==null?void 0:e.getParticipantCount())!==void 0}pageLoadTests(){N.info("Running on page load tests");const e=[];if(this.checkIfSDKEnabled()||e.push("SDK not enabled"),e.length>0)throw new Error(e.join(", "))}sdkInitTests(){N.info("Running SDK init tests");const e=[];if(this.checkIfRecordingTriggerAdded()||e.push("Recording trigger not added"),this.checkParticipantCount()||e.push("Participant count getter not working"),e.length>0)throw new Error(e.join(`
|
|
3
|
-
`))}showAlert(e){N.error(e),e+="You can contact Dyte support for help",window.alert(e)}}var Y,R,x,K,ue;class oi{constructor(e){D(this,Y,void 0);D(this,R,void 0);D(this,x,void 0);D(this,K,void 0);D(this,ue,void 0);e.waitTimeMs&&!e.autoStop&&N.warn("You have passed both waitTimeMs and autoStop. waitTimeMs will be ignored"),C(this,R,{waitTimeMs:e.waitTimeMs??1*fn,websocketUrl:e.websocketUrl??"ws://localhost:8080/ws",autoStart:e.autoStart??!0,autoStop:e.autoStop??!0,devMode:window.navigator.webdriver==!1,scanInterval:e.scanInterval??hn}),window.dyteRecordingSdk=!0,window.realtimeKitRecordingSdk=!0,window.devMode=l(this,R).devMode,C(this,K,new si),this.performOnPageLoadChecks()}async init(e){N.info("Initializing RealtimeKit Recording SDK");const t=new ln(new dn(e),{autoStop:l(this,R).autoStop,waitTimeMs:l(this,R).waitTimeMs,scanInterval:l(this,R).scanInterval}),i=new ri(l(this,R).websocketUrl,l(this,R).devMode);await i.connect(e),C(this,x,i),C(this,Y,t),this.sdkInitTests(),N.init(e),C(this,ue,e),l(this,R).autoStart&&await this.startRecording()}async startRecording(){var e,t;if((e=l(this,ue))!=null&&e.self.roomJoined){const i="Meeting already joined. Cannot start recording. SDK will call
|
|
3
|
+
`))}showAlert(e){N.error(e),e+="You can contact Dyte support for help",window.alert(e)}}var Y,R,x,K,ue;class oi{constructor(e){D(this,Y,void 0);D(this,R,void 0);D(this,x,void 0);D(this,K,void 0);D(this,ue,void 0);e.waitTimeMs&&!e.autoStop&&N.warn("You have passed both waitTimeMs and autoStop. waitTimeMs will be ignored"),C(this,R,{waitTimeMs:e.waitTimeMs??1*fn,websocketUrl:e.websocketUrl??"ws://localhost:8080/ws",autoStart:e.autoStart??!0,autoStop:e.autoStop??!0,devMode:window.navigator.webdriver==!1,scanInterval:e.scanInterval??hn}),window.dyteRecordingSdk=!0,window.realtimeKitRecordingSdk=!0,window.devMode=l(this,R).devMode,C(this,K,new si),this.performOnPageLoadChecks()}async init(e){N.info("Initializing RealtimeKit Recording SDK");const t=new ln(new dn(e),{autoStop:l(this,R).autoStop,waitTimeMs:l(this,R).waitTimeMs,scanInterval:l(this,R).scanInterval}),i=new ri(l(this,R).websocketUrl,l(this,R).devMode);await i.connect(e),C(this,x,i),C(this,Y,t),this.sdkInitTests(),N.init(e),C(this,ue,e),l(this,R).autoStart&&await this.startRecording()}async startRecording(){var e,t;if((e=l(this,ue))!=null&&e.self.roomJoined){const i="Meeting already joined. Cannot start recording. SDK will call meeting.join() automatically.";if(N.warn(i),l(this,R).devMode)throw new Error(i)}if(await((t=l(this,ue))==null?void 0:t.join()),N.info("Sending start recording request"),l(this,x))try{l(this,x).startRecordingMessage()}catch(i){const r=`Failed to start recording with error: ${i}`;if(N.error(r),l(this,R).devMode)throw new Error(r)}}stopRecording(){if(N.info("Stopping RealtimeKit Recording SDK"),l(this,Y))l(this,Y).stopRecording(),l(this,x)&&l(this,x).connected&&l(this,x).disconnect();else{const e="recording controller not initialized";if(N.error(e),l(this,R).devMode)throw new Error(e)}}async cleanup(){if(N.info("Cleaning up RealtimeKit Recording SDK"),delete window.devMode,delete window.realtimeKitRecordingSdk,delete window.dyteRecordingSdk,l(this,Y))try{l(this,Y).cleanup(),l(this,x)&&l(this,x).connected&&l(this,x).disconnect()}catch(e){const t=`Failed to cleanup with error: ${e}`;if(N.error(t),l(this,R).devMode)throw new Error(t)}else{const e="recording controller not initialized";if(N.error("recording controller not initialized"),l(this,R).devMode)throw new Error(e)}}performOnPageLoadChecks(){if(l(this,K))try{l(this,K).pageLoadTests()}catch(e){const t=`Failed to perform page load checks with error: ${e}`;if(typeof e=="string"&&l(this,R).devMode&&l(this,K).showAlert(e),l(this,R).devMode)throw new Error(t)}else{const e="SDK Checks controller not initialized";if(l(this,R).devMode)throw new Error(e)}}sdkInitTests(){if(l(this,K))try{l(this,K).sdkInitTests()}catch(e){const t=`Failed to perform sdk init checks with error: ${e}`;if(typeof e=="string"&&l(this,R).devMode&&l(this,K).showAlert(e),l(this,R).devMode)throw new Error(t)}else{const e="SDK Checks controller not initialized";if(l(this,R).devMode)throw new Error(e)}}}Y=new WeakMap,R=new WeakMap,x=new WeakMap,K=new WeakMap,ue=new WeakMap;exports.RealtimeKitRecording=oi;
|
package/dist/index.es.js
CHANGED
|
@@ -3042,7 +3042,7 @@ class ai {
|
|
|
3042
3042
|
async startRecording() {
|
|
3043
3043
|
var e, t;
|
|
3044
3044
|
if ((e = l(this, ue)) != null && e.self.roomJoined) {
|
|
3045
|
-
const i = "Meeting already joined. Cannot start recording. SDK will call
|
|
3045
|
+
const i = "Meeting already joined. Cannot start recording. SDK will call meeting.join() automatically.";
|
|
3046
3046
|
if (N.warn(i), l(this, R).devMode)
|
|
3047
3047
|
throw new Error(i);
|
|
3048
3048
|
}
|
package/dist/index.iife.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
var gi=Object.defineProperty;var mi=(R,E,O)=>E in R?gi(R,E,{enumerable:!0,configurable:!0,writable:!0,value:O}):R[E]=O;var on=(R,E,O)=>(mi(R,typeof E!="symbol"?E+"":E,O),O),st=(R,E,O)=>{if(!E.has(R))throw TypeError("Cannot "+O)};var l=(R,E,O)=>(st(R,E,"read from private field"),O?O.call(R):E.get(R)),x=(R,E,O)=>{if(E.has(R))throw TypeError("Cannot add the same private member more than once");E instanceof WeakSet?E.add(R):E.set(R,O)},D=(R,E,O,ge)=>(st(R,E,"write to private field"),ge?ge.call(R,O):E.set(R,O),O);var an=(R,E,O)=>(st(R,E,"access private method"),O);var RecordingSDK=function(R){var ne,z,Ie,he,je,cn,Q,ie,Ne,H,F,K,$,le;"use strict";var E={exports:{}},O=typeof Reflect=="object"?Reflect:null,ge=O&&typeof O.apply=="function"?O.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Ee;O&&typeof O.ownKeys=="function"?Ee=O.ownKeys:Object.getOwnPropertySymbols?Ee=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ee=function(e){return Object.getOwnPropertyNames(e)};function un(n){console&&console.warn&&console.warn(n)}var ot=Number.isNaN||function(e){return e!==e};function b(){b.init.call(this)}E.exports=b,E.exports.once=dn,b.EventEmitter=b,b.prototype._events=void 0,b.prototype._eventsCount=0,b.prototype._maxListeners=void 0;var at=10;function Te(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(b,"defaultMaxListeners",{enumerable:!0,get:function(){return at},set:function(n){if(typeof n!="number"||n<0||ot(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");at=n}}),b.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},b.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ot(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ct(n){return n._maxListeners===void 0?b.defaultMaxListeners:n._maxListeners}b.prototype.getMaxListeners=function(){return ct(this)},b.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",s=this._events;if(s!==void 0)r=r&&s.error===void 0;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")ge(f,this,t);else for(var h=f.length,d=dt(f,h),i=0;i<h;++i)ge(d[i],this,t);return!0};function ut(n,e,t,i){var r,s,o;if(Te(t),s=n._events,s===void 0?(s=n._events=Object.create(null),n._eventsCount=0):(s.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),s=n._events),o=s[e]),o===void 0)o=s[e]=t,++n._eventsCount;else if(typeof o=="function"?o=s[e]=i?[t,o]:[o,t]:i?o.unshift(t):o.push(t),r=ct(n),r>0&&o.length>r&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=o.length,un(a)}return n}b.prototype.addListener=function(e,t){return ut(this,e,t,!1)},b.prototype.on=b.prototype.addListener,b.prototype.prependListener=function(e,t){return ut(this,e,t,!0)};function fn(){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 ft(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=fn.bind(i);return r.listener=t,i.wrapFn=r,r}b.prototype.once=function(e,t){return Te(t),this.on(e,ft(this,e,t)),this},b.prototype.prependOnceListener=function(e,t){return Te(t),this.prependListener(e,ft(this,e,t)),this},b.prototype.removeListener=function(e,t){var i,r,s,o,a;if(Te(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():hn(i,s),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this},b.prototype.off=b.prototype.removeListener,b.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(r=0;r<s.length;++r)o=s[r],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function ht(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?ln(r):dt(r,r.length)}b.prototype.listeners=function(e){return ht(this,e,!0)},b.prototype.rawListeners=function(e){return ht(this,e,!1)},b.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):lt.call(n,e)},b.prototype.listenerCount=lt;function lt(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}b.prototype.eventNames=function(){return this._eventsCount>0?Ee(this._events):[]};function dt(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function hn(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function ln(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function dn(n,e){return new Promise(function(t,i){function r(o){n.removeListener(e,s),i(o)}function s(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}gt(n,e,s,{once:!0}),e!=="error"&&gn(n,r,{once:!0})})}function gn(n,e,t){typeof n.on=="function"&>(n,"error",e,t)}function gt(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(s){i.once&&n.removeEventListener(e,r),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var mn=E.exports;class pn{constructor(){on(this,"client")}logToConsole(){return window.devMode===!0&&!this.isInitialized()}init(e){this.client=e}isInitialized(){return this.client!==void 0}generateMessage(e){return`RealtimeKitRecordingLogger::${e}`}info(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.info(this.generateMessage(e),t,i)),this.logToConsole()&&console.log(e)}error(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.error(this.generateMessage(e),t,i)),this.logToConsole()&&console.error(e)}debug(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.debug(this.generateMessage(e),t,i)),this.logToConsole()&&console.debug(e)}log(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.log(this.generateMessage(e),t,i)),this.logToConsole()&&console.log(e)}warn(e,t,i){var r;this.isInitialized()&&((r=this.client)==null||r.__internals__.logger.warn(this.generateMessage(e),t,i)),this.logToConsole()&&console.warn(e)}}const I=new pn,mt=1e3,wn=60*mt,bn=1*mt;class yn extends mn.EventEmitter{constructor(t,i){super();x(this,je);x(this,ne,null);x(this,z,!1);x(this,Ie,!1);x(this,he,null);this.meeting=t,this.options=i,an(this,je,cn).call(this)}cleanup(){I.info("Cleaning up recording controller"),delete window.dyteRecording,delete window.realtimeKitRecording,this.meeting.removeAllListeners(),this.removeAllListeners(),l(this,he)!==null&&clearInterval(l(this,he))}getParticipantCount(){return this.meeting.getParticipantCount()}getWaitlistedCount(){return this.meeting.getWaitlistedCount()}scanMeetingState(){if(!this.options.autoStop)return;if(this.getParticipantCount()>0||this.getWaitlistedCount()>0){D(this,ne,null),D(this,z,!1),window.triggerDyteRecording=!0,window.triggerRealtimeKitRecording=!0;return}if(l(this,ne)===null){D(this,ne,new Date);return}if(new Date().getTime()-l(this,ne).getTime()>this.options.waitTimeMs){I.info("Setting triggerDyteRecording & triggerRealtimeKitRecording to false"),D(this,z,!0),window.triggerDyteRecording=!1,window.triggerRealtimeKitRecording=!1;return}D(this,z,!1),window.triggerDyteRecording=!0,window.triggerRealtimeKitRecording=!0}stopRecording(){if(this.options.autoStop)throw new Error("Cannot stop recording when autoStop is true");I.info("Stopping recording"),window.triggerDyteRecording&&(window.triggerDyteRecording=!1),window.triggerRealtimeKitRecording&&(window.triggerRealtimeKitRecording=!1)}get meetingJoined(){return l(this,Ie)}}ne=new WeakMap,z=new WeakMap,Ie=new WeakMap,he=new WeakMap,je=new WeakSet,cn=function(){window.dyteRecording!==void 0&&(window.dyteRecording=void 0,window.realtimeKitRecording=void 0,window.triggerDyteRecording=!1,window.triggerRealtimeKitRecording=!1),window.realtimeKitRecording!==void 0&&(window.dyteRecording=void 0,window.realtimeKitRecording=void 0,window.triggerDyteRecording=!1,window.triggerRealtimeKitRecording=!1),window.triggerDyteRecording=!0,window.triggerRealtimeKitRecording=!0,window.dyteRecording={getParticipantCount:()=>this.getParticipantCount(),isMeetingEnded:()=>l(this,z),isMeetingJoined:()=>this.meetingJoined,getMeeting:()=>this.meeting.getMeeting()},window.realtimeKitRecording={getParticipantCount:()=>this.getParticipantCount(),isMeetingEnded:()=>l(this,z),isMeetingJoined:()=>this.meetingJoined,getMeeting:()=>this.meeting.getMeeting()},this.meeting.handleParticipantJoin(()=>{I.info(`Participant joined. Total participants: ${this.getParticipantCount()}. Scanning meeting state`),this.scanMeetingState(),this.emit("participantCount",this.getParticipantCount())}),this.meeting.handleParticipantLeave(()=>{I.info(`Participant left. Remaining participants: ${this.getParticipantCount()}. Scanning meeting state`),this.scanMeetingState(),this.emit("participantCount",this.getParticipantCount())}),this.meeting.handleMeetingJoined(()=>{I.info("Meeting joined"),D(this,Ie,!0),this.emit("participantCount",this.getParticipantCount())}),this.meeting.handleMeetingLeft(({state:t})=>{t!=="ended"&&t!=="kicked"||(I.info("Meeting ended"),this.emit("meetingEnded"),this.cleanup(),window.triggerDyteRecording=!1,window.triggerRealtimeKitRecording=!1)}),this.options.autoStop&&D(this,he,setInterval(()=>{this.scanMeetingState()},this.options.scanInterval))};class vn{constructor(e){this.meeting=e}getParticipantCount(){return this.meeting.participants.active.size}getMeeting(){return this.meeting}getWaitlistedCount(){return this.meeting.participants.waitlisted.toArray().length}handleMeetingJoined(e){this.meeting.self.on("roomJoined",e)}handleMeetingLeft(e){this.meeting.self.on("roomLeft",e)}handleParticipantJoin(e){this.meeting.participants.active.on("participantJoined",e)}handleParticipantLeave(e){this.meeting.participants.active.on("participantLeft",e)}removeAllListeners(){this.meeting.self.removeAllListeners()}}function pt(n){let e=typeof n;if(e=="object"){if(Array.isArray(n))return"array";if(n===null)return"null"}return e}function kn(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}let j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Re=[];for(let n=0;n<j.length;n++)Re[j[n].charCodeAt(0)]=n;Re["-".charCodeAt(0)]=j.indexOf("+"),Re["_".charCodeAt(0)]=j.indexOf("/");function In(n){let e=n.length*3/4;n[n.length-2]=="="?e-=2:n[n.length-1]=="="&&(e-=1);let t=new Uint8Array(e),i=0,r=0,s,o=0;for(let a=0;a<n.length;a++){if(s=Re[n.charCodeAt(a)],s===void 0)switch(n[a]){case"=":r=0;case`
|
|
2
2
|
`:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(r){case 0:o=s,r=1;break;case 1:t[i++]=o<<2|(s&48)>>4,o=s,r=2;break;case 2:t[i++]=(o&15)<<4|(s&60)>>2,o=s,r=3;break;case 3:t[i++]=(o&3)<<6|s,r=0;break}}if(r==1)throw Error("invalid base64 string.");return t.subarray(0,i)}function Nn(n){let e="",t=0,i,r=0;for(let s=0;s<n.length;s++)switch(i=n[s],t){case 0:e+=j[i>>2],r=(i&3)<<4,t=1;break;case 1:e+=j[r|i>>4],r=(i&15)<<2,t=2;break;case 2:e+=j[r|i>>6],e+=j[i&63],t=0;break}return t&&(e+=j[r],e+="=",t==1&&(e+="=")),e}var Oe;(function(n){n.symbol=Symbol.for("protobuf-ts/unknown"),n.onRead=(t,i,r,s,o)=>{(e(i)?i[n.symbol]:i[n.symbol]=[]).push({no:r,wireType:s,data:o})},n.onWrite=(t,i,r)=>{for(let{no:s,wireType:o,data:a}of n.list(i))r.tag(s,o).raw(a)},n.list=(t,i)=>{if(e(t)){let r=t[n.symbol];return i?r.filter(s=>s.no==i):r}return[]},n.last=(t,i)=>n.list(t,i).slice(-1)[0];const e=t=>t&&Array.isArray(t[n.symbol])})(Oe||(Oe={}));var C;(function(n){n[n.Varint=0]="Varint",n[n.Bit64=1]="Bit64",n[n.LengthDelimited=2]="LengthDelimited",n[n.StartGroup=3]="StartGroup",n[n.EndGroup=4]="EndGroup",n[n.Bit32=5]="Bit32"})(C||(C={}));function En(){let n=0,e=0;for(let i=0;i<28;i+=7){let r=this.buf[this.pos++];if(n|=(r&127)<<i,!(r&128))return this.assertBounds(),[n,e]}let t=this.buf[this.pos++];if(n|=(t&15)<<28,e=(t&112)>>4,!(t&128))return this.assertBounds(),[n,e];for(let i=3;i<=31;i+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<i,!(r&128))return this.assertBounds(),[n,e]}throw new Error("invalid varint")}function Xe(n,e,t){for(let s=0;s<28;s=s+7){const o=n>>>s,a=!(!(o>>>7)&&e==0),f=(a?o|128:o)&255;if(t.push(f),!a)return}const i=n>>>28&15|(e&7)<<4,r=!!(e>>3);if(t.push((r?i|128:i)&255),!!r){for(let s=3;s<31;s=s+7){const o=e>>>s,a=!!(o>>>7),f=(a?o|128:o)&255;if(t.push(f),!a)return}t.push(e>>>31&1)}}const Le=65536*65536;function wt(n){let e=n[0]=="-";e&&(n=n.slice(1));const t=1e6;let i=0,r=0;function s(o,a){const f=Number(n.slice(o,a));r*=t,i=i*t+f,i>=Le&&(r=r+(i/Le|0),i=i%Le)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,i,r]}function Ge(n,e){if(e>>>0<=2097151)return""+(Le*e+(n>>>0));let t=n&16777215,i=(n>>>24|e<<8)>>>0&16777215,r=e>>16&65535,s=t+i*6777216+r*6710656,o=i+r*8147497,a=r*2,f=1e7;s>=f&&(o+=Math.floor(s/f),s%=f),o>=f&&(a+=Math.floor(o/f),o%=f);function h(d,T){let g=d?String(d):"";return T?"0000000".slice(g.length)+g:g}return h(a,0)+h(o,a)+h(s,1)}function bt(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function Tn(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}let N;function Rn(){const n=new DataView(new ArrayBuffer(8));N=globalThis.BigInt!==void 0&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:n}:void 0}Rn();function yt(n){if(!n)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}const vt=/^-?[0-9]+$/,Se=4294967296,Fe=2147483648;class kt{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*Se+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}}class B extends kt{static from(e){if(N)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=N.C(e);case"number":if(e===0)return this.ZERO;e=N.C(e);case"bigint":if(!e)return this.ZERO;if(e<N.UMIN)throw new Error("signed value for ulong");if(e>N.UMAX)throw new Error("ulong too large");return N.V.setBigUint64(0,e,!0),new B(N.V.getInt32(0,!0),N.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!vt.test(e))throw new Error("string is no integer");let[t,i,r]=wt(e);if(t)throw new Error("signed value for ulong");return new B(i,r);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new B(e,e/Se)}throw new Error("unknown value "+typeof e)}toString(){return N?this.toBigInt().toString():Ge(this.lo,this.hi)}toBigInt(){return yt(N),N.V.setInt32(0,this.lo,!0),N.V.setInt32(4,this.hi,!0),N.V.getBigUint64(0,!0)}}B.ZERO=new B(0,0);class M extends kt{static from(e){if(N)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=N.C(e);case"number":if(e===0)return this.ZERO;e=N.C(e);case"bigint":if(!e)return this.ZERO;if(e<N.MIN)throw new Error("signed long too small");if(e>N.MAX)throw new Error("signed long too large");return N.V.setBigInt64(0,e,!0),new M(N.V.getInt32(0,!0),N.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!vt.test(e))throw new Error("string is no integer");let[t,i,r]=wt(e);if(t){if(r>Fe||r==Fe&&i!=0)throw new Error("signed long too small")}else if(r>=Fe)throw new Error("signed long too large");let s=new M(i,r);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new M(e,e/Se):new M(-e,-e/Se).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&Fe)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new M(t,e)}toString(){if(N)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+Ge(e.lo,e.hi)}return Ge(this.lo,this.hi)}toBigInt(){return yt(N),N.V.setInt32(0,this.lo,!0),N.V.setInt32(4,this.hi,!0),N.V.getBigInt64(0,!0)}}M.ZERO=new M(0,0);const It={readUnknownField:!0,readerFactory:n=>new Ln(n)};function On(n){return n?Object.assign(Object.assign({},It),n):It}class Ln{constructor(e,t){this.varint64=En,this.uint32=Tn,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t!=null?t:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,i=e&7;if(t<=0||i<0||i>5)throw new Error("illegal tag: field no "+t+" wire type "+i);return[t,i]}skip(e){let t=this.pos;switch(e){case C.Varint:for(;this.buf[this.pos++]&128;);break;case C.Bit64:this.pos+=4;case C.Bit32:this.pos+=4;break;case C.LengthDelimited:let i=this.uint32();this.pos+=i;break;case C.StartGroup:let r;for(;(r=this.tag()[1])!==C.EndGroup;)this.skip(r);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new M(...this.varint64())}uint64(){return new B(...this.varint64())}sint64(){let[e,t]=this.varint64(),i=-(e&1);return e=(e>>>1|(t&1)<<31)^i,t=t>>>1^i,new M(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new B(this.sfixed32(),this.sfixed32())}sfixed64(){return new M(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function m(n,e){if(!n)throw new Error(e)}const Sn=34028234663852886e22,Fn=-34028234663852886e22,Cn=4294967295,Mn=2147483647,An=-2147483648;function me(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>Mn||n<An)throw new Error("invalid int 32: "+n)}function Ce(n){if(typeof n!="number")throw new Error("invalid uint 32: "+typeof n);if(!Number.isInteger(n)||n>Cn||n<0)throw new Error("invalid uint 32: "+n)}function Ze(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>Sn||n<Fn))throw new Error("invalid float 32: "+n)}const Nt={writeUnknownFields:!0,writerFactory:()=>new Bn};function Dn(n){return n?Object.assign(Object.assign({},Nt),n):Nt}class Bn{constructor(e){this.stack=[],this.textEncoder=e!=null?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),i=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],i),i+=this.chunks[r].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Ce(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return me(e),bt(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Ze(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Ce(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){me(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return me(e),e=(e<<1^e>>31)>>>0,bt(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=M.from(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),i=new DataView(t.buffer),r=B.from(e);return i.setInt32(0,r.lo,!0),i.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=M.from(e);return Xe(t.lo,t.hi,this.buf),this}sint64(e){let t=M.from(e),i=t.hi>>31,r=t.lo<<1^i,s=(t.hi<<1|t.lo>>>31)^i;return Xe(r,s,this.buf),this}uint64(e){let t=B.from(e);return Xe(t.lo,t.hi,this.buf),this}}const Et={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Tt={ignoreUnknownFields:!1};function _n(n){return n?Object.assign(Object.assign({},Tt),n):Tt}function xn(n){return n?Object.assign(Object.assign({},Et),n):Et}const Rt=Symbol.for("protobuf-ts/message-type");function Ot(n){let e=!1;const t=[];for(let i=0;i<n.length;i++){let r=n.charAt(i);r=="_"?e=!0:/\d/.test(r)?(t.push(r),e=!0):e?(t.push(r.toUpperCase()),e=!1):i==0?t.push(r.toLowerCase()):t.push(r)}return t.join("")}var u;(function(n){n[n.DOUBLE=1]="DOUBLE",n[n.FLOAT=2]="FLOAT",n[n.INT64=3]="INT64",n[n.UINT64=4]="UINT64",n[n.INT32=5]="INT32",n[n.FIXED64=6]="FIXED64",n[n.FIXED32=7]="FIXED32",n[n.BOOL=8]="BOOL",n[n.STRING=9]="STRING",n[n.BYTES=12]="BYTES",n[n.UINT32=13]="UINT32",n[n.SFIXED32=15]="SFIXED32",n[n.SFIXED64=16]="SFIXED64",n[n.SINT32=17]="SINT32",n[n.SINT64=18]="SINT64"})(u||(u={}));var W;(function(n){n[n.BIGINT=0]="BIGINT",n[n.STRING=1]="STRING",n[n.NUMBER=2]="NUMBER"})(W||(W={}));var Me;(function(n){n[n.NO=0]="NO",n[n.PACKED=1]="PACKED",n[n.UNPACKED=2]="UNPACKED"})(Me||(Me={}));function Kn(n){var e,t,i,r;return n.localName=(e=n.localName)!==null&&e!==void 0?e:Ot(n.name),n.jsonName=(t=n.jsonName)!==null&&t!==void 0?t:Ot(n.name),n.repeat=(i=n.repeat)!==null&&i!==void 0?i:Me.NO,n.opt=(r=n.opt)!==null&&r!==void 0?r:n.repeat||n.oneof?!1:n.kind=="message",n}function Vn(n){if(typeof n!="object"||n===null||!n.hasOwnProperty("oneofKind"))return!1;switch(typeof n.oneofKind){case"string":return n[n.oneofKind]===void 0?!1:Object.keys(n).length==2;case"undefined":return Object.keys(n).length==1;default:return!1}}class Un{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}prepare(){if(this.data)return;const e=[],t=[],i=[];for(let r of this.fields)if(r.oneof)i.includes(r.oneof)||(i.push(r.oneof),e.push(r.oneof),t.push(r.oneof));else switch(t.push(r.localName),r.kind){case"scalar":case"enum":(!r.opt||r.repeat)&&e.push(r.localName);break;case"message":r.repeat&&e.push(r.localName);break;case"map":e.push(r.localName);break}this.data={req:e,known:t,oneofs:Object.values(i)}}is(e,t,i=!1){if(t<0)return!0;if(e==null||typeof e!="object")return!1;this.prepare();let r=Object.keys(e),s=this.data;if(r.length<s.req.length||s.req.some(o=>!r.includes(o))||!i&&r.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(const o of s.oneofs){const a=e[o];if(!Vn(a))return!1;if(a.oneofKind===void 0)continue;const f=this.fields.find(h=>h.localName===a.oneofKind);if(!f||!this.field(a[a.oneofKind],f,i,t))return!1}for(const o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,i,t))return!1;return!0}field(e,t,i,r){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,r,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,u.INT32,r):this.scalar(e,u.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),i,r):this.message(e,t.T(),i,r);case"map":if(typeof e!="object"||e===null)return!1;if(r<2)return!0;if(!this.mapKeys(e,t.K,r))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,r,t.V.L);case"enum":return this.scalars(Object.values(e),u.INT32,r);case"message":return this.messages(Object.values(e),t.V.T(),i,r)}break}return!0}message(e,t,i,r){return i?t.isAssignable(e,r):t.is(e,r)}messages(e,t,i,r){if(!Array.isArray(e))return!1;if(r<2)return!0;if(i){for(let s=0;s<e.length&&s<r;s++)if(!t.isAssignable(e[s],r-1))return!1}else for(let s=0;s<e.length&&s<r;s++)if(!t.is(e[s],r-1))return!1;return!0}scalar(e,t,i){let r=typeof e;switch(t){case u.UINT64:case u.FIXED64:case u.INT64:case u.SFIXED64:case u.SINT64:switch(i){case W.BIGINT:return r=="bigint";case W.NUMBER:return r=="number"&&!isNaN(e);default:return r=="string"}case u.BOOL:return r=="boolean";case u.STRING:return r=="string";case u.BYTES:return e instanceof Uint8Array;case u.DOUBLE:case u.FLOAT:return r=="number"&&!isNaN(e);default:return r=="number"&&Number.isInteger(e)}}scalars(e,t,i,r){if(!Array.isArray(e))return!1;if(i<2)return!0;if(Array.isArray(e)){for(let s=0;s<e.length&&s<i;s++)if(!this.scalar(e[s],t,r))return!1}return!0}mapKeys(e,t,i){let r=Object.keys(e);switch(t){case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:return this.scalars(r.slice(0,i).map(s=>parseInt(s)),t,i);case u.BOOL:return this.scalars(r.slice(0,i).map(s=>s=="true"?!0:s=="false"?!1:s),t,i);default:return this.scalars(r,t,i,W.STRING)}}}function U(n,e){switch(e){case W.BIGINT:return n.toBigInt();case W.NUMBER:return n.toNumber();default:return n.toString()}}class Pn{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};const t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(const i of t)this.fMap[i.name]=i,this.fMap[i.jsonName]=i,this.fMap[i.localName]=i}}assert(e,t,i){if(!e){let r=pt(i);throw(r=="number"||r=="boolean")&&(r=i.toString()),new Error(`Cannot parse JSON ${r} for ${this.info.typeName}#${t}`)}}read(e,t,i){this.prepare();const r=[];for(const[s,o]of Object.entries(e)){const a=this.fMap[s];if(!a){if(!i.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}const f=a.localName;let h;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(r.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);r.push(a.oneof),h=t[a.oneof]={oneofKind:f}}else h=t;if(a.kind=="map"){if(o===null)continue;this.assert(kn(o),a.name,o);const d=h[f];for(const[T,g]of Object.entries(o)){this.assert(g!==null,a.name+" map value",null);let _;switch(a.V.kind){case"message":_=a.V.T().internalJsonRead(g,i);break;case"enum":if(_=this.enum(a.V.T(),g,a.name,i.ignoreUnknownFields),_===!1)continue;break;case"scalar":_=this.scalar(g,a.V.T,a.V.L,a.name);break}this.assert(_!==void 0,a.name+" map value",g);let V=T;a.K==u.BOOL&&(V=V=="true"?!0:V=="false"?!1:V),V=this.scalar(V,a.K,W.STRING,a.name).toString(),d[V]=_}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);const d=h[f];for(const T of o){this.assert(T!==null,a.name,null);let g;switch(a.kind){case"message":g=a.T().internalJsonRead(T,i);break;case"enum":if(g=this.enum(a.T(),T,a.name,i.ignoreUnknownFields),g===!1)continue;break;case"scalar":g=this.scalar(T,a.T,a.L,a.name);break}this.assert(g!==void 0,a.name,o),d.push(g)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}h[f]=a.T().internalJsonRead(o,i,h[f]);break;case"enum":if(o===null)continue;let d=this.enum(a.T(),o,a.name,i.ignoreUnknownFields);if(d===!1)continue;h[f]=d;break;case"scalar":if(o===null)continue;h[f]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,i,r){if(e[0]=="google.protobuf.NullValue"&&m(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${i}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return m(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${i}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o=="undefined"&&r?!1:(m(typeof o=="number",`Unable to parse field ${this.info.typeName}#${i}, enum ${e[0]} has no value for "${t}".`),o)}m(!1,`Unable to parse field ${this.info.typeName}#${i}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,i,r){let s;try{switch(t){case u.DOUBLE:case u.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==u.FLOAT&&Ze(o),o;case u.INT32:case u.FIXED32:case u.SFIXED32:case u.SINT32:case u.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==u.UINT32?Ce(a):me(a),a;case u.INT64:case u.SFIXED64:case u.SINT64:if(e===null)return U(M.ZERO,i);if(typeof e!="number"&&typeof e!="string")break;return U(M.from(e),i);case u.FIXED64:case u.UINT64:if(e===null)return U(B.ZERO,i);if(typeof e!="number"&&typeof e!="string")break;return U(B.from(e),i);case u.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case u.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(f){f="invalid UTF8";break}return e;case u.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return In(e)}}catch(o){s=o.message}this.assert(!1,r+(s?" - "+s:""),e)}}class Wn{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){const i={},r=e;for(const s of this.fields){if(!s.oneof){let h=this.field(s,r[s.localName],t);h!==void 0&&(i[t.useProtoFieldName?s.name:s.jsonName]=h);continue}const o=r[s.oneof];if(o.oneofKind!==s.localName)continue;const a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t;let f=this.field(s,o[s.localName],a);m(f!==void 0),i[t.useProtoFieldName?s.name:s.jsonName]=f}return i}field(e,t,i){let r;if(e.kind=="map"){m(typeof t=="object"&&t!==null);const s={};switch(e.V.kind){case"scalar":for(const[f,h]of Object.entries(t)){const d=this.scalar(e.V.T,h,e.name,!1,!0);m(d!==void 0),s[f.toString()]=d}break;case"message":const o=e.V.T();for(const[f,h]of Object.entries(t)){const d=this.message(o,h,e.name,i);m(d!==void 0),s[f.toString()]=d}break;case"enum":const a=e.V.T();for(const[f,h]of Object.entries(t)){m(h===void 0||typeof h=="number");const d=this.enum(a,h,e.name,!1,!0,i.enumAsInteger);m(d!==void 0),s[f.toString()]=d}break}(i.emitDefaultValues||Object.keys(s).length>0)&&(r=s)}else if(e.repeat){m(Array.isArray(t));const s=[];switch(e.kind){case"scalar":for(let f=0;f<t.length;f++){const h=this.scalar(e.T,t[f],e.name,e.opt,!0);m(h!==void 0),s.push(h)}break;case"enum":const o=e.T();for(let f=0;f<t.length;f++){m(t[f]===void 0||typeof t[f]=="number");const h=this.enum(o,t[f],e.name,e.opt,!0,i.enumAsInteger);m(h!==void 0),s.push(h)}break;case"message":const a=e.T();for(let f=0;f<t.length;f++){const h=this.message(a,t[f],e.name,i);m(h!==void 0),s.push(h)}break}(i.emitDefaultValues||s.length>0||i.emitDefaultValues)&&(r=s)}else switch(e.kind){case"scalar":r=this.scalar(e.T,t,e.name,e.opt,i.emitDefaultValues);break;case"enum":r=this.enum(e.T(),t,e.name,e.opt,i.emitDefaultValues,i.enumAsInteger);break;case"message":r=this.message(e.T(),t,e.name,i);break}return r}enum(e,t,i,r,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!r?void 0:null;if(t===void 0){m(r);return}if(!(t===0&&!s&&!r))return m(typeof t=="number"),m(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,i,r){return t===void 0?r.emitDefaultValues?null:void 0:e.internalJsonWrite(t,r)}scalar(e,t,i,r,s){if(t===void 0){m(r);return}const o=s||r;switch(e){case u.INT32:case u.SFIXED32:case u.SINT32:return t===0?o?0:void 0:(me(t),t);case u.FIXED32:case u.UINT32:return t===0?o?0:void 0:(Ce(t),t);case u.FLOAT:Ze(t);case u.DOUBLE:return t===0?o?0:void 0:(m(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case u.STRING:return t===""?o?"":void 0:(m(typeof t=="string"),t);case u.BOOL:return t===!1?o?!1:void 0:(m(typeof t=="boolean"),t);case u.UINT64:case u.FIXED64:m(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=B.from(t);return a.isZero()&&!o?void 0:a.toString();case u.INT64:case u.SFIXED64:case u.SINT64:m(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let f=M.from(t);return f.isZero()&&!o?void 0:f.toString();case u.BYTES:return m(t instanceof Uint8Array),t.byteLength?Nn(t):o?"":void 0}}}function Ye(n,e=W.STRING){switch(n){case u.BOOL:return!1;case u.UINT64:case u.FIXED64:return U(B.ZERO,e);case u.INT64:case u.SFIXED64:case u.SINT64:return U(M.ZERO,e);case u.DOUBLE:case u.FLOAT:return 0;case u.BYTES:return new Uint8Array(0);case u.STRING:return"";default:return 0}}class $n{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){const t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(i=>[i.no,i]))}}read(e,t,i,r){this.prepare();const s=r===void 0?e.len:e.pos+r;for(;e.pos<s;){const[o,a]=e.tag(),f=this.fieldNoToField.get(o);if(!f){let g=i.readUnknownField;if(g=="throw")throw new Error(`Unknown field ${o} (wire type ${a}) for ${this.info.typeName}`);let _=e.skip(a);g!==!1&&(g===!0?Oe.onRead:g)(this.info.typeName,t,o,a,_);continue}let h=t,d=f.repeat,T=f.localName;switch(f.oneof&&(h=h[f.oneof],h.oneofKind!==T&&(h=t[f.oneof]={oneofKind:T})),f.kind){case"scalar":case"enum":let g=f.kind=="enum"?u.INT32:f.T,_=f.kind=="scalar"?f.L:void 0;if(d){let re=h[T];if(a==C.LengthDelimited&&g!=u.STRING&&g!=u.BYTES){let de=e.uint32()+e.pos;for(;e.pos<de;)re.push(this.scalar(e,g,_))}else re.push(this.scalar(e,g,_))}else h[T]=this.scalar(e,g,_);break;case"message":if(d){let re=h[T],de=f.T().internalBinaryRead(e,e.uint32(),i);re.push(de)}else h[T]=f.T().internalBinaryRead(e,e.uint32(),i,h[T]);break;case"map":let[V,Je]=this.mapEntry(f,e,i);h[T][V]=Je;break}}}mapEntry(e,t,i){let r=t.uint32(),s=t.pos+r,o,a;for(;t.pos<s;){let[f,h]=t.tag();switch(f){case 1:e.K==u.BOOL?o=t.bool().toString():o=this.scalar(t,e.K,W.STRING);break;case 2:switch(e.V.kind){case"scalar":a=this.scalar(t,e.V.T,e.V.L);break;case"enum":a=t.int32();break;case"message":a=e.V.T().internalBinaryRead(t,t.uint32(),i);break}break;default:throw new Error(`Unknown field ${f} (wire type ${h}) in map entry for ${this.info.typeName}#${e.name}`)}}if(o===void 0){let f=Ye(e.K);o=e.K==u.BOOL?f.toString():f}if(a===void 0)switch(e.V.kind){case"scalar":a=Ye(e.V.T,e.V.L);break;case"enum":a=0;break;case"message":a=e.V.T().create();break}return[o,a]}scalar(e,t,i){switch(t){case u.INT32:return e.int32();case u.STRING:return e.string();case u.BOOL:return e.bool();case u.DOUBLE:return e.double();case u.FLOAT:return e.float();case u.INT64:return U(e.int64(),i);case u.UINT64:return U(e.uint64(),i);case u.FIXED64:return U(e.fixed64(),i);case u.FIXED32:return e.fixed32();case u.BYTES:return e.bytes();case u.UINT32:return e.uint32();case u.SFIXED32:return e.sfixed32();case u.SFIXED64:return U(e.sfixed64(),i);case u.SINT32:return e.sint32();case u.SINT64:return U(e.sint64(),i)}}}class jn{constructor(e){this.info=e}prepare(){if(!this.fields){const e=this.info.fields?this.info.fields.concat():[];this.fields=e.sort((t,i)=>t.no-i.no)}}write(e,t,i){this.prepare();for(const s of this.fields){let o,a,f=s.repeat,h=s.localName;if(s.oneof){const d=e[s.oneof];if(d.oneofKind!==h)continue;o=d[h],a=!0}else o=e[h],a=!1;switch(s.kind){case"scalar":case"enum":let d=s.kind=="enum"?u.INT32:s.T;if(f)if(m(Array.isArray(o)),f==Me.PACKED)this.packed(t,d,s.no,o);else for(const T of o)this.scalar(t,d,s.no,T,!0);else o===void 0?m(s.opt):this.scalar(t,d,s.no,o,a||s.opt);break;case"message":if(f){m(Array.isArray(o));for(const T of o)this.message(t,i,s.T(),s.no,T)}else this.message(t,i,s.T(),s.no,o);break;case"map":m(typeof o=="object"&&o!==null);for(const[T,g]of Object.entries(o))this.mapEntry(t,i,s,T,g);break}}let r=i.writeUnknownFields;r!==!1&&(r===!0?Oe.onWrite:r)(this.info.typeName,e,t)}mapEntry(e,t,i,r,s){e.tag(i.no,C.LengthDelimited),e.fork();let o=r;switch(i.K){case u.INT32:case u.FIXED32:case u.UINT32:case u.SFIXED32:case u.SINT32:o=Number.parseInt(r);break;case u.BOOL:m(r=="true"||r=="false"),o=r=="true";break}switch(this.scalar(e,i.K,1,o,!0),i.V.kind){case"scalar":this.scalar(e,i.V.T,2,s,!0);break;case"enum":this.scalar(e,u.INT32,2,s,!0);break;case"message":this.message(e,t,i.V.T(),2,s);break}e.join()}message(e,t,i,r,s){s!==void 0&&(i.internalBinaryWrite(s,e.tag(r,C.LengthDelimited).fork(),t),e.join())}scalar(e,t,i,r,s){let[o,a,f]=this.scalarInfo(t,r);(!f||s)&&(e.tag(i,o),e[a](r))}packed(e,t,i,r){if(!r.length)return;m(t!==u.BYTES&&t!==u.STRING),e.tag(i,C.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;o<r.length;o++)e[s](r[o]);e.join()}scalarInfo(e,t){let i=C.Varint,r,s=t===void 0,o=t===0;switch(e){case u.INT32:r="int32";break;case u.STRING:o=s||!t.length,i=C.LengthDelimited,r="string";break;case u.BOOL:o=t===!1,r="bool";break;case u.UINT32:r="uint32";break;case u.DOUBLE:i=C.Bit64,r="double";break;case u.FLOAT:i=C.Bit32,r="float";break;case u.INT64:o=s||M.from(t).isZero(),r="int64";break;case u.UINT64:o=s||B.from(t).isZero(),r="uint64";break;case u.FIXED64:o=s||B.from(t).isZero(),i=C.Bit64,r="fixed64";break;case u.BYTES:o=s||!t.byteLength,i=C.LengthDelimited,r="bytes";break;case u.FIXED32:i=C.Bit32,r="fixed32";break;case u.SFIXED32:i=C.Bit32,r="sfixed32";break;case u.SFIXED64:o=s||M.from(t).isZero(),i=C.Bit64,r="sfixed64";break;case u.SINT32:r="sint32";break;case u.SINT64:o=s||M.from(t).isZero(),r="sint64";break}return[i,r,s||o]}}function Jn(n){const e=n.messagePrototype?Object.create(n.messagePrototype):Object.defineProperty({},Rt,{value:n});for(let t of n.fields){let i=t.localName;if(!t.opt)if(t.oneof)e[t.oneof]={oneofKind:void 0};else if(t.repeat)e[i]=[];else switch(t.kind){case"scalar":e[i]=Ye(t.T,t.L);break;case"enum":e[i]=0;break;case"map":e[i]={};break}}return e}function qe(n,e,t){let i,r=t,s;for(let o of n.fields){let a=o.localName;if(o.oneof){const f=r[o.oneof];if((f==null?void 0:f.oneofKind)==null)continue;if(i=f[a],s=e[o.oneof],s.oneofKind=f.oneofKind,i==null){delete s[a];continue}}else if(i=r[a],s=e,i==null)continue;switch(o.repeat&&(s[a].length=i.length),o.kind){case"scalar":case"enum":if(o.repeat)for(let h=0;h<i.length;h++)s[a][h]=i[h];else s[a]=i;break;case"message":let f=o.T();if(o.repeat)for(let h=0;h<i.length;h++)s[a][h]=f.create(i[h]);else s[a]===void 0?s[a]=f.create(i):f.mergePartial(s[a],i);break;case"map":switch(o.V.kind){case"scalar":case"enum":Object.assign(s[a],i);break;case"message":let h=o.V.T();for(let d of Object.keys(i))s[a][d]=h.create(i[d]);break}break}}}function Xn(n,e,t){if(e===t)return!0;if(!e||!t)return!1;for(let i of n.fields){let r=i.localName,s=i.oneof?e[i.oneof][r]:e[r],o=i.oneof?t[i.oneof][r]:t[r];switch(i.kind){case"enum":case"scalar":let a=i.kind=="enum"?u.INT32:i.T;if(!(i.repeat?St(a,s,o):Lt(a,s,o)))return!1;break;case"map":if(!(i.V.kind=="message"?Ft(i.V.T(),Ae(s),Ae(o)):St(i.V.kind=="enum"?u.INT32:i.V.T,Ae(s),Ae(o))))return!1;break;case"message":let f=i.T();if(!(i.repeat?Ft(f,s,o):f.equals(s,o)))return!1;break}}return!0}const Ae=Object.values;function Lt(n,e,t){if(e===t)return!0;if(n!==u.BYTES)return!1;let i=e,r=t;if(i.length!==r.length)return!1;for(let s=0;s<i.length;s++)if(i[s]!=r[s])return!1;return!0}function St(n,e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Lt(n,e[i],t[i]))return!1;return!0}function Ft(n,e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!n.equals(e[i],t[i]))return!1;return!0}const Ct=Object.getOwnPropertyDescriptors(Object.getPrototypeOf({})),Gn=Ct[Rt]={};class Zn{constructor(e,t,i){this.defaultCheckDepth=16,this.typeName=e,this.fields=t.map(Kn),this.options=i!=null?i:{},Gn.value=this,this.messagePrototype=Object.create(null,Ct),this.refTypeCheck=new Un(this),this.refJsonReader=new Pn(this),this.refJsonWriter=new Wn(this),this.refBinReader=new $n(this),this.refBinWriter=new jn(this)}create(e){let t=Jn(this);return e!==void 0&&qe(this,t,e),t}clone(e){let t=this.create();return qe(this,t,e),t}equals(e,t){return Xn(this,e,t)}is(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!1)}isAssignable(e,t=this.defaultCheckDepth){return this.refTypeCheck.is(e,t,!0)}mergePartial(e,t){qe(this,e,t)}fromBinary(e,t){let i=On(t);return this.internalBinaryRead(i.readerFactory(e),e.byteLength,i)}fromJson(e,t){return this.internalJsonRead(e,_n(t))}fromJsonString(e,t){let i=JSON.parse(e);return this.fromJson(i,t)}toJson(e,t){return this.internalJsonWrite(e,xn(t))}toJsonString(e,t){var i;let r=this.toJson(e,t);return JSON.stringify(r,null,(i=t==null?void 0:t.prettySpaces)!==null&&i!==void 0?i:0)}toBinary(e,t){let i=Dn(t);return this.internalBinaryWrite(e,i.writerFactory(),i).finish()}internalJsonRead(e,t,i){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){let r=i!=null?i:this.create();return this.refJsonReader.read(e,r,t),r}throw new Error(`Unable to parse message ${this.typeName} from JSON ${pt(e)}.`)}internalJsonWrite(e,t){return this.refJsonWriter.write(e,t)}internalBinaryWrite(e,t,i){return this.refBinWriter.write(e,t,i),t}internalBinaryRead(e,t,i,r){let s=r!=null?r:this.create();return this.refBinReader.read(e,s,i,t),s}}var Yn=Object.defineProperty,qn=(n,e,t)=>e in n?Yn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,zn=(n,e,t)=>(qn(n,typeof e!="symbol"?e+"":e,t),t),ze=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},c=(n,e,t)=>(ze(n,e,"read from private field"),t?t.call(n):e.get(n)),y=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},p=(n,e,t,i)=>(ze(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),w=(n,e,t)=>(ze(n,e,"access private method"),t),De={},Qn={get exports(){return De},set exports(n){De=n}},se=typeof Reflect=="object"?Reflect:null,Mt=se&&typeof se.apply=="function"?se.apply:function(n,e,t){return Function.prototype.apply.call(n,e,t)},Be;se&&typeof se.ownKeys=="function"?Be=se.ownKeys:Object.getOwnPropertySymbols?Be=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Be=function(n){return Object.getOwnPropertyNames(n)};function Hn(n){console&&console.warn&&console.warn(n)}var At=Number.isNaN||function(n){return n!==n};function v(){v.init.call(this)}Qn.exports=v,De.once=ii,v.EventEmitter=v,v.prototype._events=void 0,v.prototype._eventsCount=0,v.prototype._maxListeners=void 0;var Dt=10;function _e(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return Dt},set:function(n){if(typeof n!="number"||n<0||At(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");Dt=n}}),v.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},v.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||At(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function Bt(n){return n._maxListeners===void 0?v.defaultMaxListeners:n._maxListeners}v.prototype.getMaxListeners=function(){return Bt(this)},v.prototype.emit=function(n){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);var i=n==="error",r=this._events;if(r!==void 0)i=i&&r.error===void 0;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=r[n];if(a===void 0)return!1;if(typeof a=="function")Mt(a,this,e);else for(var f=a.length,h=Ut(a,f),t=0;t<f;++t)Mt(h[t],this,e);return!0};function _t(n,e,t,i){var r,s,o;if(_e(t),s=n._events,s===void 0?(s=n._events=Object.create(null),n._eventsCount=0):(s.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),s=n._events),o=s[e]),o===void 0)o=s[e]=t,++n._eventsCount;else if(typeof o=="function"?o=s[e]=i?[t,o]:[o,t]:i?o.unshift(t):o.push(t),r=Bt(n),r>0&&o.length>r&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=o.length,Hn(a)}return n}v.prototype.addListener=function(n,e){return _t(this,n,e,!1)},v.prototype.on=v.prototype.addListener,v.prototype.prependListener=function(n,e){return _t(this,n,e,!0)};function ei(){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 xt(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=ei.bind(i);return r.listener=t,i.wrapFn=r,r}v.prototype.once=function(n,e){return _e(e),this.on(n,xt(this,n,e)),this},v.prototype.prependOnceListener=function(n,e){return _e(e),this.prependListener(n,xt(this,n,e)),this},v.prototype.removeListener=function(n,e){var t,i,r,s,o;if(_e(e),i=this._events,i===void 0)return this;if(t=i[n],t===void 0)return this;if(t===e||t.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete i[n],i.removeListener&&this.emit("removeListener",n,t.listener||e));else if(typeof t!="function"){for(r=-1,s=t.length-1;s>=0;s--)if(t[s]===e||t[s].listener===e){o=t[s].listener,r=s;break}if(r<0)return this;r===0?t.shift():ti(t,r),t.length===1&&(i[n]=t[0]),i.removeListener!==void 0&&this.emit("removeListener",n,o||e)}return this},v.prototype.off=v.prototype.removeListener,v.prototype.removeAllListeners=function(n){var e,t,i;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[n]),this;if(arguments.length===0){var r=Object.keys(t),s;for(i=0;i<r.length;++i)s=r[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=t[n],typeof e=="function")this.removeListener(n,e);else if(e!==void 0)for(i=e.length-1;i>=0;i--)this.removeListener(n,e[i]);return this};function Kt(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?ni(r):Ut(r,r.length)}v.prototype.listeners=function(n){return Kt(this,n,!0)},v.prototype.rawListeners=function(n){return Kt(this,n,!1)},v.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):Vt.call(n,e)},v.prototype.listenerCount=Vt;function Vt(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}v.prototype.eventNames=function(){return this._eventsCount>0?Be(this._events):[]};function Ut(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function ti(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function ni(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function ii(n,e){return new Promise(function(t,i){function r(o){n.removeListener(e,s),i(o)}function s(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}Pt(n,e,s,{once:!0}),e!=="error"&&ri(n,r,{once:!0})})}function ri(n,e,t){typeof n.on=="function"&&Pt(n,"error",e,t)}function Pt(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(s){i.once&&n.removeEventListener(e,r),t(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}class si extends Zn{constructor(){super("message.v1.SocketMessage",[{no:1,name:"event",kind:"scalar",T:13},{no:2,name:"id",kind:"scalar",opt:!0,T:9},{no:3,name:"payload",kind:"scalar",opt:!0,T:12},{no:4,name:"metadata",kind:"scalar",opt:!0,T:12}])}}const Wt=new si;class $t{static encode(e){return Wt.toBinary(e)}static decode(e){return Wt.fromBinary(new Uint8Array(e))}}function oi(n,e){return Math.floor(Math.random()*(e-n+1)+n)}var G;class ai{constructor(e={}){zn(this,"opts"),y(this,G,void 0),this.opts={initialTimeout:e.initialTimeout||1e3,maxTimeout:e.maxTimeout||1e4,factor:e.factor||2},p(this,G,0)}async wait(){p(this,G,c(this,G)+1);const e=oi(0,Math.min(this.opts.maxTimeout,this.opts.initialTimeout*2**c(this,G)));await new Promise(t=>{setTimeout(t,e)})}getAttempts(){return c(this,G)}reset(){p(this,G,0)}}G=new WeakMap;const Z={debug:0,info:1,warn:2,error:3};var ee,te;class ci{constructor(e){y(this,ee,void 0),y(this,te,void 0),p(this,ee,console),p(this,te,e)}debug(...e){Z[c(this,te)]>Z.debug||c(this,ee).debug("[Sockrates]:",...e)}info(...e){Z[c(this,te)]>Z.info||c(this,ee).info("[Sockrates]:",...e)}warn(...e){Z[c(this,te)]>Z.warn||c(this,ee).warn("[Sockrates]:",...e)}error(...e){Z[c(this,te)]>Z.error||c(this,ee).error("[Sockrates]:",...e)}}ee=new WeakMap,te=new WeakMap;var jt=(n=>(n[n.CONNECTING=0]="CONNECTING",n[n.OPEN=1]="OPEN",n[n.CLOSING=2]="CLOSING",n[n.CLOSED=3]="CLOSED",n))(jt||{});const Jt="2",Xt="3";var S,oe,k,L,Y,A,J,q,P,ae,ce,X,Qe,Gt,pe,xe,He,Zt,Ke,et,Ve,tt,nt,Yt,we,Ue,ue,be,Pe,it,fe,ye,rt,qt,ve,We,ke,$e;class ui{constructor(e,t){var V,Je,re,de,zt,Qt,Ht,en,tn,nn,rn,sn;y(this,Qe),y(this,pe),y(this,He),y(this,Ke),y(this,Ve),y(this,nt),y(this,we),y(this,ue),y(this,Pe),y(this,fe),y(this,rt),y(this,ve),y(this,ke),y(this,S,void 0),y(this,oe,void 0),y(this,k,void 0),y(this,L,void 0),y(this,Y,void 0),y(this,A,void 0),y(this,J,void 0),y(this,q,void 0),y(this,P,void 0),y(this,ae,void 0),y(this,ce,void 0),y(this,X,void 0);var i,r,s,o,a,f,h,d,T,g,_;p(this,oe,e),p(this,Y,[]),p(this,A,new De),p(this,J,!0),p(this,P,!1),p(this,k,t!=null?t:{}),(V=(i=c(this,k)).autoReconnect)!=null||(i.autoReconnect=!0),(Je=(r=c(this,k)).retryConnectionInterval)!=null||(r.retryConnectionInterval=1e3),(re=(s=c(this,k)).pingTimeout)!=null||(s.pingTimeout=3e4),(de=(o=c(this,k)).connectionTimeout)!=null||(o.connectionTimeout=5e3),(zt=(a=c(this,k)).debug)!=null||(a.debug=!0),(Qt=(f=c(this,k)).maxReconnectionAttempts)!=null||(f.maxReconnectionAttempts=10),(Ht=(h=c(this,k)).disconnectOnPingTimeout)!=null||(h.disconnectOnPingTimeout=!0),(en=(d=c(this,k)).queueOnDisconnect)!=null||(d.queueOnDisconnect=!1),(tn=(T=c(this,k)).flushOnReconnect)!=null||(T.flushOnReconnect=!1),(nn=(g=c(this,k)).clientInitiatedPings)!=null||(g.clientInitiatedPings=!1),(rn=(_=c(this,k)).clientInitiatedPingInterval)!=null||(_.clientInitiatedPingInterval=3e4),p(this,q,{code:void 0,reason:void 0}),p(this,L,(sn=c(this,k).logger)!=null?sn:new ci(c(this,k).debug?"debug":"info")),p(this,X,new ai)}get readyState(){var e;return(e=c(this,S))==null?void 0:e.readyState}get url(){return c(this,oe)}updateURL(e){p(this,oe,e),w(this,nt,Yt).call(this)}get config(){return c(this,k)}get sendQueue(){return c(this,Y)}flush(){if(!c(this,k).queueOnDisconnect)return!1;const e=[];return c(this,Y).forEach(t=>{this.send(t.event,t.id,t.payload,t.metadata)||e.push(t)}),p(this,Y,e),c(this,Y)}async connect(e=!1){if(!e&&[0,1].includes(this.readyState)){c(this,L).debug("Websocket was already connecting or connected.");return}if(c(this,J)!==!1)return new Promise((t,i)=>{w(this,fe,ye).call(this),w(this,ke,$e).call(this);try{p(this,S,new WebSocket(w(this,Qe,Gt).call(this,c(this,oe)))),c(this,S).binaryType="arraybuffer",c(this,L).debug("Connecting");const r=setTimeout(()=>{c(this,L).debug("Connection timeout. Closing socket"),p(this,J,!0),w(this,ke,$e).call(this),c(this,S).close(3001,"Connection Timeout"),c(this,k).autoReconnect&&!c(this,P)&&(c(this,A).emit("reconnecting"),w(this,we,Ue).call(this)),i(new Error("Connection timed out!"))},c(this,k).connectionTimeout);c(this,S).onopen=()=>{c(this,L).debug(`Ready State: ${jt[c(this,S).readyState]}`),r&&clearTimeout(r),w(this,Pe,it).call(this),w(this,rt,qt).call(this),p(this,q,{code:void 0,reason:void 0}),c(this,A).emit("connected"),c(this,k).flushOnReconnect&&this.flush(),t()},c(this,S).onclose=s=>{try{r&&clearTimeout(r);const{code:o,reason:a}=s;i(a),c(this,L).debug("Socket closed. Close event:",{event:s}),c(this,L).debug(`Connection closed code: ${o}`),c(this,L).debug(`Connection closed reason: ${a}`),c(this,P)||w(this,Ve,tt).call(this,o,a)}catch(o){w(this,pe,xe).call(this,o)}},c(this,S).onerror=s=>{w(this,pe,xe).call(this,s)},c(this,S).onmessage=s=>w(this,He,Zt).call(this,s)}catch(r){w(this,pe,xe).call(this,r,i)}})}send(e,t,i,r){const s={event:e,id:t,payload:i,metadata:r};if(c(this,k).queueOnDisconnect&&(!c(this,S)||c(this,S).readyState!==1))return c(this,L).debug("Queuing message since socket is not connected!",s),c(this,Y).push(s),!1;const o=$t.encode(s);return w(this,ue,be).call(this,o)}emit(e,t,i,r){return this.send(e,t,i,r)}sendRaw(e){return w(this,ue,be).call(this,e)}receive(e,t){return c(this,A).on(e.toString(),t)}on(e,t){if(typeof e=="string"&&(e==="connected"||e==="disconnected"||e==="errored"||e==="reconnected"||e==="reconnecting"||e==="reconnectAttempt"||e==="reconnectFailure"||e==="failed")){c(this,A).on(e,t);return}this.receive(e,t)}removeAllListeners(){c(this,A).removeAllListeners()}removeReceiver(e,t){this.removeListener(e,t)}removeListener(e,t){c(this,A).removeListener(e.toString(),t)}removeReceivers(e){this.removeListeners(e)}removeListeners(e){c(this,A).listeners(e.toString()).map(t=>this.removeListener(e,t))}disconnect(){p(this,J,!1),w(this,fe,ye).call(this),w(this,ve,We).call(this),this.removeAllListeners(),p(this,q,{code:1e3,reason:"Sockrates disconnect method called"}),c(this,S).close(1e3,"Sockrates disconnect method called.")}}S=new WeakMap,oe=new WeakMap,k=new WeakMap,L=new WeakMap,Y=new WeakMap,A=new WeakMap,J=new WeakMap,q=new WeakMap,P=new WeakMap,ae=new WeakMap,ce=new WeakMap,X=new WeakMap,Qe=new WeakSet,Gt=function(n){if(n.startsWith("ws://")||n.startsWith("wss://"))return n;if(n.startsWith("https://"))return`wss://${n.substring(8)}`;if(n.startsWith("http://"))return`ws://${n.substring(7)}`;throw new Error("Invalid URL. URL must start with http(s):// or ws(s)://.")},pe=new WeakSet,xe=function(n,e){c(this,L).error("Error:",{error:n}),c(this,A).emit("errored",{error:n}),e==null||e(n)},He=new WeakSet,Zt=function(n){if(w(this,Pe,it).call(this),n.data===Jt){c(this,L).debug("Received ping from server"),w(this,ue,be).call(this,Xt);return}if(n.data===Xt){c(this,L).debug("Received pong from server");return}const e=$t.decode(n.data),{id:t,payload:i}=e;c(this,L).debug("Received message",{event:e.event,messageID:t}),c(this,A).emit(e.event.toString(),{id:t,payload:i})},Ke=new WeakSet,et=function(){return c(this,S).readyState===1},Ve=new WeakSet,tt=function(n,e){p(this,q,{reason:e,code:n}),c(this,A).emit("disconnected",{code:n,reason:e})},nt=new WeakSet,Yt=function(){const{reason:n,code:e}=c(this,q);e&&e!==1e3&&c(this,J)&&c(this,k).autoReconnect&&!c(this,P)&&(c(this,L).debug(`Triggering reconnection due to ${n}.`),c(this,A).emit("reconnecting"),w(this,we,Ue).call(this))},we=new WeakSet,Ue=async function(n=!0){if(n&&c(this,P)){c(this,L).debug("Reconnect called when already in a reconnect loop. Ignoring.");return}if(c(this,P)||c(this,X).reset(),c(this,k).maxReconnectionAttempts!==null&&c(this,X).getAttempts()>=c(this,k).maxReconnectionAttempts){c(this,A).emit("failed"),p(this,P,!1);return}p(this,P,!0),w(this,ke,$e).call(this),w(this,fe,ye).call(this);try{if(await c(this,X).wait(),c(this,J)===!1)return;if(c(this,L).debug(`Reconnection attempt ${c(this,X).getAttempts()}`),c(this,A).emit("reconnectAttempt",{attempt:c(this,X).getAttempts()}),await this.connect(),!w(this,Ke,et).call(this))throw Error("Reconnect Failed");p(this,P,!1),p(this,q,{code:void 0,reason:void 0}),c(this,A).emit("reconnected")}catch(e){c(this,L).debug("Failed to reconnect."),c(this,A).emit("reconnectFailure",{attempt:c(this,X).getAttempts()}),w(this,we,Ue).call(this,!1)}},ue=new WeakSet,be=function(n){try{return c(this,S).send(n),!0}catch(e){return c(this,L).error(e.message),!1}},Pe=new WeakSet,it=function(){this.config.disconnectOnPingTimeout&&(c(this,L).debug("Resetting ping timeout"),w(this,fe,ye).call(this),p(this,ae,setTimeout(()=>{var n;c(this,L).debug("Disconnecting the socket due to ping timeout"),p(this,J,!0);const e=3002,t="Ping timeout";(n=c(this,S))==null||n.close(e,t),w(this,Ve,tt).call(this,e,t)},c(this,k).pingTimeout)))},fe=new WeakSet,ye=function(){c(this,ae)&&(clearTimeout(c(this,ae)),p(this,ae,void 0))},rt=new WeakSet,qt=function(){w(this,ve,We).call(this),c(this,k).clientInitiatedPings&&p(this,ce,setInterval(()=>{w(this,Ke,et).call(this)&&(c(this,L).debug("Sending client-initiated ping"),w(this,ue,be).call(this,Jt))},c(this,k).clientInitiatedPingInterval))},ve=new WeakSet,We=function(){c(this,ce)&&(clearInterval(c(this,ce)),p(this,ce,void 0))},ke=new WeakSet,$e=function(){w(this,ve,We).call(this),c(this,S)&&(c(this,S).onopen=void 0,c(this,S).onerror=void 0,c(this,S).onmessage=void 0,c(this,S).onclose=void 0)};class fi{constructor(e,t){this.url=e,console.info(`Creating websocket with url: ${e} and config: ${t}`)}sendRaw(e){return console.info(`Sending raw message to websocket: ${e}`),!0}connect(e){return console.info(`Connecting to websocket: ${this.url} with force: ${e}`),Promise.resolve()}disconnect(){console.info(`Disconnecting from websocket: ${this.url}`)}on(e,t){console.info(`Adding listener to websocket: ${e} with listener: ${t}`)}}class hi{constructor(e,t=!1){x(this,Q,null);x(this,ie,!1);x(this,Ne,!1);this.wsUrl=e,this.devMode=t}get connected(){return l(this,ie)}async connect(e){let t;this.devMode?t=new fi(this.wsUrl,{queueOnDisconnect:!0,flushOnReconnect:!0}):t=new ui(this.wsUrl,{queueOnDisconnect:!0,flushOnReconnect:!0}),e.participants.addListener("broadcastedMessage",i=>t.sendRaw(JSON.stringify(i))),I.info("Connecting to websocket"),t.on("connected",()=>{I.info("Connected to websocket")}),await t.connect(!0),D(this,Q,t),D(this,ie,!0)}disconnect(){l(this,Q)&&(l(this,Q).disconnect(),D(this,ie,!1))}startRecordingMessage(){if(l(this,Ne))throw new Error("Start recording message already sent");if(l(this,Q)&&l(this,ie))D(this,Ne,!0),l(this,Q).sendRaw(JSON.stringify({type:"StartRecording"}));else throw new Error("Not connected to websocket, make sure you have called init.")}}Q=new WeakMap,ie=new WeakMap,Ne=new WeakMap;class li{constructor(){}checkIfSDKEnabled(){return I.info("Check if SDK enabled"),window.dyteRecordingSdk===!0||window.realtimeKitRecordingSdk===!0}checkIfRecordingTriggerAdded(){return I.info("Check if recording trigger added"),window.triggerDyteRecording===!0||window.triggerRealtimeKitRecording===!0}checkMeetingJoined(){var e;return I.info("Check if meeting joined getter available"),((e=window.realtimeKitRecording)==null?void 0:e.isMeetingJoined())!==!0}checkParticipantCount(){var e;return I.info("Check if participant count getter available"),((e=window.realtimeKitRecording)==null?void 0:e.getParticipantCount())!==void 0}pageLoadTests(){I.info("Running on page load tests");const e=[];if(this.checkIfSDKEnabled()||e.push("SDK not enabled"),e.length>0)throw new Error(e.join(", "))}sdkInitTests(){I.info("Running SDK init tests");const e=[];if(this.checkIfRecordingTriggerAdded()||e.push("Recording trigger not added"),this.checkParticipantCount()||e.push("Participant count getter not working"),e.length>0)throw new Error(e.join(`
|
|
3
|
-
`))}showAlert(e){I.error(e),e+="You can contact Dyte support for help",window.alert(e)}}class di{constructor(e){x(this,H,void 0);x(this,F,void 0);x(this,K,void 0);x(this,$,void 0);x(this,le,void 0);var t,i,r,s,o;e.waitTimeMs&&!e.autoStop&&I.warn("You have passed both waitTimeMs and autoStop. waitTimeMs will be ignored"),D(this,F,{waitTimeMs:(t=e.waitTimeMs)!=null?t:1*wn,websocketUrl:(i=e.websocketUrl)!=null?i:"ws://localhost:8080/ws",autoStart:(r=e.autoStart)!=null?r:!0,autoStop:(s=e.autoStop)!=null?s:!0,devMode:window.navigator.webdriver==!1,scanInterval:(o=e.scanInterval)!=null?o:bn}),window.dyteRecordingSdk=!0,window.realtimeKitRecordingSdk=!0,window.devMode=l(this,F).devMode,D(this,$,new li),this.performOnPageLoadChecks()}async init(e){I.info("Initializing RealtimeKit Recording SDK");const t=new yn(new vn(e),{autoStop:l(this,F).autoStop,waitTimeMs:l(this,F).waitTimeMs,scanInterval:l(this,F).scanInterval}),i=new hi(l(this,F).websocketUrl,l(this,F).devMode);await i.connect(e),D(this,K,i),D(this,H,t),this.sdkInitTests(),I.init(e),D(this,le,e),l(this,F).autoStart&&await this.startRecording()}async startRecording(){var e,t;if((e=l(this,le))!=null&&e.self.roomJoined){const i="Meeting already joined. Cannot start recording. SDK will call
|
|
3
|
+
`))}showAlert(e){I.error(e),e+="You can contact Dyte support for help",window.alert(e)}}class di{constructor(e){x(this,H,void 0);x(this,F,void 0);x(this,K,void 0);x(this,$,void 0);x(this,le,void 0);var t,i,r,s,o;e.waitTimeMs&&!e.autoStop&&I.warn("You have passed both waitTimeMs and autoStop. waitTimeMs will be ignored"),D(this,F,{waitTimeMs:(t=e.waitTimeMs)!=null?t:1*wn,websocketUrl:(i=e.websocketUrl)!=null?i:"ws://localhost:8080/ws",autoStart:(r=e.autoStart)!=null?r:!0,autoStop:(s=e.autoStop)!=null?s:!0,devMode:window.navigator.webdriver==!1,scanInterval:(o=e.scanInterval)!=null?o:bn}),window.dyteRecordingSdk=!0,window.realtimeKitRecordingSdk=!0,window.devMode=l(this,F).devMode,D(this,$,new li),this.performOnPageLoadChecks()}async init(e){I.info("Initializing RealtimeKit Recording SDK");const t=new yn(new vn(e),{autoStop:l(this,F).autoStop,waitTimeMs:l(this,F).waitTimeMs,scanInterval:l(this,F).scanInterval}),i=new hi(l(this,F).websocketUrl,l(this,F).devMode);await i.connect(e),D(this,K,i),D(this,H,t),this.sdkInitTests(),I.init(e),D(this,le,e),l(this,F).autoStart&&await this.startRecording()}async startRecording(){var e,t;if((e=l(this,le))!=null&&e.self.roomJoined){const i="Meeting already joined. Cannot start recording. SDK will call meeting.join() automatically.";if(I.warn(i),l(this,F).devMode)throw new Error(i)}if(await((t=l(this,le))==null?void 0:t.join()),I.info("Sending start recording request"),l(this,K))try{l(this,K).startRecordingMessage()}catch(i){const r=`Failed to start recording with error: ${i}`;if(I.error(r),l(this,F).devMode)throw new Error(r)}}stopRecording(){if(I.info("Stopping RealtimeKit Recording SDK"),l(this,H))l(this,H).stopRecording(),l(this,K)&&l(this,K).connected&&l(this,K).disconnect();else{const e="recording controller not initialized";if(I.error(e),l(this,F).devMode)throw new Error(e)}}async cleanup(){if(I.info("Cleaning up RealtimeKit Recording SDK"),delete window.devMode,delete window.realtimeKitRecordingSdk,delete window.dyteRecordingSdk,l(this,H))try{l(this,H).cleanup(),l(this,K)&&l(this,K).connected&&l(this,K).disconnect()}catch(e){const t=`Failed to cleanup with error: ${e}`;if(I.error(t),l(this,F).devMode)throw new Error(t)}else{const e="recording controller not initialized";if(I.error("recording controller not initialized"),l(this,F).devMode)throw new Error(e)}}performOnPageLoadChecks(){if(l(this,$))try{l(this,$).pageLoadTests()}catch(e){const t=`Failed to perform page load checks with error: ${e}`;if(typeof e=="string"&&l(this,F).devMode&&l(this,$).showAlert(e),l(this,F).devMode)throw new Error(t)}else{const e="SDK Checks controller not initialized";if(l(this,F).devMode)throw new Error(e)}}sdkInitTests(){if(l(this,$))try{l(this,$).sdkInitTests()}catch(e){const t=`Failed to perform sdk init checks with error: ${e}`;if(typeof e=="string"&&l(this,F).devMode&&l(this,$).showAlert(e),l(this,F).devMode)throw new Error(t)}else{const e="SDK Checks controller not initialized";if(l(this,F).devMode)throw new Error(e)}}}return H=new WeakMap,F=new WeakMap,K=new WeakMap,$=new WeakMap,le=new WeakMap,R.RealtimeKitRecording=di,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),R}({});
|