quickvo-player 0.0.4 → 0.0.5

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.js CHANGED
@@ -3,7 +3,7 @@ var D = (f) => {
3
3
  throw TypeError(f);
4
4
  };
5
5
  var W = (f, o, u) => o in f ? U(f, o, { enumerable: !0, configurable: !0, writable: !0, value: u }) : f[o] = u;
6
- var v = (f, o, u) => W(f, typeof o != "symbol" ? o + "" : o, u), B = (f, o, u) => o.has(f) || D("Cannot " + u);
6
+ var b = (f, o, u) => W(f, typeof o != "symbol" ? o + "" : o, u), B = (f, o, u) => o.has(f) || D("Cannot " + u);
7
7
  var x = (f, o, u) => (B(f, o, "read from private field"), u ? u.call(f) : o.get(f)), P = (f, o, u) => o.has(f) ? D("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(f) : o.set(f, u), C = (f, o, u, c) => (B(f, o, "write to private field"), c ? c.call(f, u) : o.set(f, u), u);
8
8
  const L = '(function(){"use strict";const U=new TextDecoder("utf-8"),H=(e,s)=>{const a=e.getUint8(s),t=a>>7&1,n=a>>5&3,r=a&31;return{forbidden_zero_bit:t,nal_ref_idc:n,nal_unit_type:r}},b=(e,s)=>e.getUint8(s),P=(e,s,a)=>{const t=new Uint8Array(e.buffer.slice(s,s+a));return U?.decode(t)||""},T=(e,s,a)=>{let t=s,n,r=0;switch(a){case 0:n=e.getFloat64(t,!1),r=8;break;case 1:n=!!e.getUint8(t),r=1;break;case 2:{n="";const o=e.getUint16(t,!1);t=t+2;const c=new Int8Array(e.buffer,t,o).filter(d=>d!==0);n=(U?.decode(c)||"").trim(),r=2+o}break;case 3:for(n={};t<e.byteLength;){const o=e.getUint16(t,!1);if(o===0)break;t=t+2;const c=P(e,t,o);t=t+o;const g=b(e,t);if(g===6)break;t=t+1;const d=T(e,t,g);t=t+d.length,n[c]=d.value,r=2+o+1+d.length}break;case 8:{n={};const o=e.getUint32(t,!1);t=t+4;for(let c=0;c<o;c++){const g=e.getUint16(t,!1);t=t+2;const d=P(e,t,g);t=t+g;const h=b(e,t);t=t+1;const l=T(e,t,h);t=t+l.length,n[d]=l.value,r=2+g+1+l.length}}break;case 10:{n=[];const o=e.getUint32(t,!1);t=t+4;for(let c=0;c<o;c++){const g=b(e,t);t=t+1;const d=T(e,t,g);t=t+d.length,n.push(d.value),r=1+d.length}}break}return{amfType:a,length:r,value:n}},m=(e,s)=>e.getUint8(s)<<16|e.getUint8(s+1)<<8|e.getUint8(s+2);var u={header:{getSignature:e=>{const s=new Int8Array(e.buffer.slice(0,3));return U?.decode(s)||""},getVersion:e=>e.getUint8(3),getFlags:e=>{const a=e.getUint8(0).toString(2).padStart(5,"0").split(""),[,,t,,n]=a;return{audio:n==="1",video:t==="1"}},getDataOffset:e=>e.getUint32(5)},getPreviousTagSize:(e,s)=>e.getUint32(s),isSurplusTag:(e,s)=>{let a=!0;const t=e.byteLength;if(s+4>t)a=!1;else if(s+4+11>t)a=!1;else{const n=m(e,s+4+1);s+4+11+n>t&&(a=!1)}return a},tag:{tagHeader:{getTagType:(e,s)=>{const a=e.getUint8(s);let t;switch(a){case 18:t="script";break;case 8:t="audio";break;case 9:t="video";break}return t},getDataSize:(e,s)=>m(e,s+1),getTimestamp:(e,s)=>m(e,s+4),getTimestampExtended:(e,s)=>e.getUint8(s+7),getStreamID:(e,s)=>m(e,s+8)},tagBody:{parseAudio:(e,s,a)=>{let t=s;const n=e.getUint8(t),r=n>>4&15,i=n>>2&3,o=n>>1&1,c=n&1;t=t+1;const g=e.getUint8(t);t=t+1;const d=a-2,h=new Uint8Array(e.buffer.slice(t,t+d));if(r===10&&g===0){const l=e.getUint8(t),p=e.getUint8(t+1),f=(l&248)>>3,y=(l&7)<<1|p>>7,S=(p&120)>>3,A=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],D=`mp4a.40.${f}`,z=A[y];return{soundFormat:r,soundRate:i,soundSize:o,soundType:c,accPacketType:g,data:h,audioObjectType:f,samplingFrequencyIndex:y,channelConfiguration:S,codec:D,sampleRate:z}}return{soundFormat:r,soundRate:i,soundSize:o,soundType:c,accPacketType:g,data:h}},parseVideo:(e,s,a)=>{let t=s;const n=e.getUint8(t),r=n>>4&15,i=n&15;t=t+1;const o=e.getUint8(t);t=t+1;const c=m(e,t);t=t+3;const g=a-5,d=new Uint8Array(e.buffer.slice(t,t+g));switch(i){case 7:if(o===0){const h=e.getUint8(t);if(t=t+1,h!==1)throw new Error("Invalid AVC version");const l=e.getUint8(t)&255;t=t+1;const p=e.getUint8(t)&255;t=t+1;const f=e.getUint8(t)&255;t=t+1;const A=`avc1.${Array.from([l,p,f],E=>E.toString(16).padStart(2,"0")).join("")}`,D=(e.getUint8(t)&3)-1;t=t+1;const z=e.getUint8(t)&31;t=t+1;const _=e.getUint16(t,!1);t=t+2;const O=new Uint8Array(e.buffer.slice(t,t+_));t=t+_;const I=e.getUint8(t)&31;t=t+1;const x=e.getUint16(t,!1);t=t+2;const M=new Uint8Array(e.buffer.slice(t,t+x));return t=t+x,{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d,version:h,codec:A,profile:l,compatibility:p,level:f,lengthSizeMinusOne:D,numOfSequenceParameterSets:z,sequenceParameterSetLength:_,sps:O,numOfPictureParameterSets:I,pictureParameterSetLength:x,pps:M}}else if(o===1){const h=[],l=t+a-5;for(;t+4<l;){const p=e.getUint32(t,!1);t=t+4;const f=H(e,t);t=t+1;const y=p-1,S=new Uint8Array(e.buffer.slice(t,t+y));t=t+y,h.push({size:p,header:f,payload:S})}return{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d,nalus:h}}break;default:throw new Error("Unsupported codecID")}return{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d}},parseMetaData:(e,s)=>{let a=s;{if(e.getUint8(a)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");a=a+1}const t=e.getUint16(a,!1);a=a+2;{const i=new Int8Array(e.buffer.slice(a,a+t));if((U?.decode(i)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");a=a+t}const n=b(e,a);return a=a+1,T(e,a,n).value}}}};class L{parseSpeed=8;pendingPayloads=[];payload=new Uint8Array(0);offset=0;is_parsing=!1;header;tag;on={};constructor(){}init=()=>{this.destroy()};push=s=>{this.pendingPayloads.push(s),this.is_parsing||this.parse()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.offset=0,this.is_parsing=!1,this.header=void 0,this.tag=void 0};parse=async()=>{for(this.is_parsing=!0;;){const s=this.pendingPayloads.shift();if(!s)break;const a=new Uint8Array(this.payload.byteLength+s.byteLength);a.set(this.payload,0),a.set(s,this.payload.byteLength),this.payload=a;const t=new DataView(this.payload.buffer);this.header||this.parseHeader(t),await this.parseTag(t)}this.is_parsing=!1};parseHeader=s=>(this.header={signature:u.header.getSignature(s),version:u.header.getVersion(s),flags:u.header.getFlags(s),dataOffset:u.header.getDataOffset(s)},this.offset=this.header?.dataOffset,this.on.header&&this.on.header(this.header),this.header);parseTag=async s=>{const a=(n,r)=>({tagType:u.tag.tagHeader.getTagType(n,r),dataSize:u.tag.tagHeader.getDataSize(n,r),timestamp:u.tag.tagHeader.getTimestamp(n,r),timestampExtended:u.tag.tagHeader.getTimestampExtended(n,r),streamID:u.tag.tagHeader.getStreamID(n,r)}),t=(n,r,i,o)=>{let c;switch(n){case"script":c=u.tag.tagBody.parseMetaData(r,i);break;case"audio":c=u.tag.tagBody.parseAudio(r,i,o);break;case"video":c=u.tag.tagBody.parseVideo(r,i,o);break}return c};for(;this.offset<s.byteLength;){if(u.isSurplusTag(s,this.offset)===!1){this.payload=this.payload.slice(this.offset),this.offset=0;break}const r=a(s,this.offset+4),{tagType:i,dataSize:o}=r;if(!i)break;const c=t(i,s,this.offset+4+11,o);this.tag={header:r,body:c},this.on.tag&&this.on.tag(this.tag),this.offset=this.offset+4+11+o,await new Promise(g=>setTimeout(()=>g(!0),this.parseSpeed))}}}const k=new L;k.on.header=e=>postMessage({action:"onHeader",data:e}),k.on.tag=e=>postMessage({action:"onTag",data:e}),onmessage=e=>{const{action:s,data:a}=e.data,t=k[s];t&&t(a)}})();\n', A = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", L], { type: "text/javascript;charset=utf-8" });
9
9
  function E(f) {
@@ -27,11 +27,11 @@ function E(f) {
27
27
  }
28
28
  class _ {
29
29
  constructor() {
30
- v(this, "worker", new E());
31
- v(this, "on", {});
32
- v(this, "init", () => this.worker.postMessage({ action: "init" }));
33
- v(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
34
- v(this, "destroy", () => {
30
+ b(this, "worker", new E());
31
+ b(this, "on", {});
32
+ b(this, "init", () => this.worker.postMessage({ action: "init" }));
33
+ b(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
34
+ b(this, "destroy", () => {
35
35
  this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
36
36
  });
37
37
  this.worker.onmessage = (o) => {
@@ -63,9 +63,9 @@ function V(f) {
63
63
  }
64
64
  class j {
65
65
  constructor() {
66
- v(this, "worker", new V());
67
- v(this, "on", { audio: {}, video: {} });
68
- v(this, "audio", {
66
+ b(this, "worker", new V());
67
+ b(this, "on", { audio: {}, video: {} });
68
+ b(this, "audio", {
69
69
  init: (o) => this.worker.postMessage({ type: "audio", action: "init", data: o }),
70
70
  decode: (o) => this.worker.postMessage({ type: "audio", action: "decode", data: o }),
71
71
  flush: () => this.worker.postMessage({ type: "audio", action: "flush" }),
@@ -73,7 +73,7 @@ class j {
73
73
  this.worker.postMessage({ type: "audio", action: "destroy" });
74
74
  }
75
75
  });
76
- v(this, "video", {
76
+ b(this, "video", {
77
77
  init: (o) => this.worker.postMessage({ type: "video", action: "init", data: o }),
78
78
  decode: (o) => this.worker.postMessage({ type: "video", action: "decode", data: o }),
79
79
  flush: () => this.worker.postMessage({ type: "video", action: "flush" }),
@@ -81,7 +81,7 @@ class j {
81
81
  this.worker.postMessage({ type: "video", action: "destroy", data: {} });
82
82
  }
83
83
  });
84
- v(this, "destroy", () => {
84
+ b(this, "destroy", () => {
85
85
  this.worker.postMessage({ type: "audio", action: "destroy" }), this.worker.postMessage({ type: "video", action: "destroy", data: {} }), this.worker.terminate();
86
86
  });
87
87
  this.worker.onmessage = (o) => {
@@ -120,14 +120,14 @@ function H(f) {
120
120
  }
121
121
  class $ {
122
122
  constructor() {
123
- v(this, "worker", new H());
124
- v(this, "init", ({ offscreenCanvas: o, baseTime: u = 0, writable: c }) => this.worker.postMessage({ action: "init", data: { offscreenCanvas: o, baseTime: u, writable: c } }, [o, c]));
125
- v(this, "setShader", (o) => this.worker.postMessage({ action: "setShader", data: o }));
126
- v(this, "setSize", ({ width: o, height: u }) => this.worker.postMessage({ action: "setSize", data: { width: o, height: u } }));
127
- v(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
128
- v(this, "setCut", async (o) => this.worker.postMessage({ action: "setCut", data: o }));
129
- v(this, "setPause", (o) => this.worker.postMessage({ action: "setPause", data: o }));
130
- v(this, "destroy", () => {
123
+ b(this, "worker", new H());
124
+ b(this, "init", ({ offscreenCanvas: o, baseTime: u = 0, writable: c }) => this.worker.postMessage({ action: "init", data: { offscreenCanvas: o, baseTime: u, writable: c } }, [o, c]));
125
+ b(this, "setShader", (o) => this.worker.postMessage({ action: "setShader", data: o }));
126
+ b(this, "setSize", ({ width: o, height: u }) => this.worker.postMessage({ action: "setSize", data: { width: o, height: u } }));
127
+ b(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
128
+ b(this, "setCut", async (o) => this.worker.postMessage({ action: "setCut", data: o }));
129
+ b(this, "setPause", (o) => this.worker.postMessage({ action: "setPause", data: o }));
130
+ b(this, "destroy", () => {
131
131
  this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
132
132
  });
133
133
  }
@@ -225,16 +225,16 @@ const J = async (f, o) => {
225
225
  };
226
226
  class X {
227
227
  constructor() {
228
- v(this, "prAudioStream");
229
- v(this, "audioContext");
230
- v(this, "destination");
231
- v(this, "stream", new MediaStream());
232
- v(this, "nextStartTime", 0);
233
- v(this, "pendingSources", []);
234
- v(this, "init", (o) => {
228
+ b(this, "prAudioStream");
229
+ b(this, "audioContext");
230
+ b(this, "destination");
231
+ b(this, "stream", new MediaStream());
232
+ b(this, "nextStartTime", 0);
233
+ b(this, "pendingSources", []);
234
+ b(this, "init", (o) => {
235
235
  o || (o = new (window.AudioContext || window.webkitAudioContext)()), this.audioContext = o, this.destination = this.audioContext.createMediaStreamDestination(), this.stream = new MediaStream(), this.stream.addTrack(this.destination.stream.getAudioTracks()[0]), this.prAudioStream = new Q(this.stream, this.audioContext), this.nextStartTime = 0, this.pendingSources = [];
236
236
  });
237
- v(this, "getStream", () => {
237
+ b(this, "getStream", () => {
238
238
  var o;
239
239
  return (o = this.prAudioStream) == null ? void 0 : o.getStream();
240
240
  });
@@ -271,7 +271,7 @@ class Y {
271
271
  * @param input string | URL | Request
272
272
  * @param init RequestInit
273
273
  */
274
- v(this, "check", (o, u) => new Promise(async (c, r) => {
274
+ b(this, "check", (o, u) => new Promise(async (c, r) => {
275
275
  var i;
276
276
  this.stop(), C(this, T, new AbortController());
277
277
  const n = window.setTimeout(() => {
@@ -291,7 +291,7 @@ class Y {
291
291
  * @param input string | URL | Request
292
292
  * @param init RequestInit
293
293
  */
294
- v(this, "request", async (o, u) => new Promise(async (c, r) => {
294
+ b(this, "request", async (o, u) => new Promise(async (c, r) => {
295
295
  var n;
296
296
  try {
297
297
  await this.check(o, u), C(this, T, new AbortController());
@@ -304,7 +304,7 @@ class Y {
304
304
  /**
305
305
  * stop
306
306
  */
307
- v(this, "stop", () => {
307
+ b(this, "stop", () => {
308
308
  var o;
309
309
  ((o = x(this, T)) == null ? void 0 : o.signal.aborted) === !1 && x(this, T).abort("Actively stop.");
310
310
  });
@@ -324,29 +324,29 @@ const O = (f) => {
324
324
  };
325
325
  class be {
326
326
  constructor() {
327
- v(this, "prFetch", new Y());
328
- v(this, "demuxerWorker");
329
- v(this, "decoderWorker");
330
- v(this, "audioPlayer");
331
- v(this, "renderWorker");
332
- v(this, "renderBaseTime", 0);
333
- v(this, "stream");
334
- v(this, "canvas");
335
- v(this, "on", { demuxer: {}, decoder: {} });
336
- v(this, "cutRenders", /* @__PURE__ */ new Map());
327
+ b(this, "prFetch", new Y());
328
+ b(this, "demuxerWorker");
329
+ b(this, "decoderWorker");
330
+ b(this, "audioPlayer");
331
+ b(this, "renderWorker");
332
+ b(this, "renderBaseTime", 0);
333
+ b(this, "stream");
334
+ b(this, "canvas");
335
+ b(this, "on", { demuxer: {}, decoder: {} });
336
+ b(this, "cutRenders", /* @__PURE__ */ new Map());
337
337
  // @ts-ignore
338
- v(this, "trackGenerator");
338
+ b(this, "trackGenerator");
339
339
  /**
340
340
  * 初始化
341
341
  */
342
- v(this, "init", () => {
342
+ b(this, "init", () => {
343
343
  this.initDemuxer(), this.initDecoder(), this.audioPlayer = new X(), this.audioPlayer.init(), this.initRender();
344
344
  });
345
345
  /**
346
346
  * 开始播放
347
347
  * @param url : string
348
348
  */
349
- v(this, "start", async (o) => (this.stop(), this.renderBaseTime = (/* @__PURE__ */ new Date()).getTime(), this.init(), this.prFetch.request(o).then(async (u) => {
349
+ b(this, "start", async (o) => (this.stop(), this.renderBaseTime = (/* @__PURE__ */ new Date()).getTime(), this.init(), this.prFetch.request(o).then(async (u) => {
350
350
  var n;
351
351
  const c = (n = u.body) == null ? void 0 : n.getReader();
352
352
  if (!c) throw new Error("Reader is error.");
@@ -365,7 +365,7 @@ class be {
365
365
  /**
366
366
  * 停止
367
367
  */
368
- v(this, "stop", async () => {
368
+ b(this, "stop", async () => {
369
369
  var u, c, r, n;
370
370
  try {
371
371
  this.prFetch.stop();
@@ -381,7 +381,7 @@ class be {
381
381
  /**
382
382
  * 监听媒体 tag
383
383
  */
384
- v(this, "onTag", (o) => {
384
+ b(this, "onTag", (o) => {
385
385
  var i;
386
386
  if (!this.decoderWorker) return;
387
387
  const { header: u, body: c } = o, { tagType: r, timestamp: n } = u;
@@ -424,13 +424,13 @@ class be {
424
424
  /**
425
425
  * 初始化分离器
426
426
  */
427
- v(this, "initDemuxer", () => {
427
+ b(this, "initDemuxer", () => {
428
428
  this.demuxerWorker = new _(), this.demuxerWorker.init(), this.demuxerWorker.on.tag = this.onTag;
429
429
  });
430
430
  /**
431
431
  * 初始化解码器
432
432
  */
433
- v(this, "initDecoder", () => {
433
+ b(this, "initDecoder", () => {
434
434
  this.decoderWorker = new j(), this.decoderWorker.on.audio.decode = (o) => {
435
435
  var u;
436
436
  (u = this.audioPlayer) == null || u.push(o), this.on.decoder.audio && this.on.decoder.audio(o);
@@ -450,28 +450,20 @@ class be {
450
450
  /**
451
451
  * 初始化渲染器
452
452
  */
453
- v(this, "initRender", () => {
453
+ b(this, "initRender", () => {
454
454
  const { worker: o, canvas: u, stream: c } = G(this.renderBaseTime);
455
455
  this.renderWorker = o, this.canvas = u, this.stream = c, this.renderWorker.setPause(!1);
456
456
  });
457
- v(this, "getCanvas", () => this.canvas);
458
- v(this, "getStream", () => this.stream);
459
- v(this, "getCutCanvas", (o) => {
460
- var u;
461
- return (u = this.cutRenders.get(o)) == null ? void 0 : u.canvas;
462
- });
463
- v(this, "getCutStream", (o) => {
464
- var u;
465
- return (u = this.cutRenders.get(o)) == null ? void 0 : u.stream;
466
- });
467
- v(this, "setPause", (o) => {
457
+ b(this, "getCanvas", () => this.canvas);
458
+ b(this, "getStream", () => this.stream);
459
+ b(this, "setPause", (o) => {
468
460
  var u;
469
461
  (u = this.renderWorker) == null || u.setPause(o);
470
462
  });
471
463
  /**
472
464
  * 设置渲染模式
473
465
  */
474
- v(this, "setShader", (o) => {
466
+ b(this, "setShader", (o) => {
475
467
  var u;
476
468
  (u = this.renderWorker) == null || u.setShader(o);
477
469
  });
@@ -479,11 +471,11 @@ class be {
479
471
  * 是否静音 默认为true
480
472
  * @param state?: boolean
481
473
  */
482
- v(this, "setMute", (o) => {
474
+ b(this, "setMute", (o) => {
483
475
  var u, c;
484
476
  return (c = (u = this.audioPlayer) == null ? void 0 : u.prAudioStream) == null ? void 0 : c.setMute(o);
485
477
  });
486
- v(this, "cut", {
478
+ b(this, "cut", {
487
479
  /**
488
480
  * 创建剪切
489
481
  */
@@ -491,6 +483,14 @@ class be {
491
483
  let c = this.cutRenders.get(o);
492
484
  return c ? (c.worker.setCut(u), c.worker.setPause(!1), c) : (c = G(this.renderBaseTime), c.worker.setCut(u), this.cutRenders.set(o, c), c);
493
485
  },
486
+ getCanvas: (o) => {
487
+ var u;
488
+ return (u = this.cutRenders.get(o)) == null ? void 0 : u.canvas;
489
+ },
490
+ getStream: (o) => {
491
+ var u;
492
+ return (u = this.cutRenders.get(o)) == null ? void 0 : u.stream;
493
+ },
494
494
  setPause: (o, u) => {
495
495
  var c;
496
496
  (c = this.cutRenders.get(o)) == null || c.worker.setPause(u);
@@ -720,15 +720,15 @@ function requireFloat() {
720
720
  if (a < 22250738585072014e-324)
721
721
  w = a / 5e-324, t(w >>> 0, d, y + s), t((p << 31 | w / 4294967296) >>> 0, d, y + l);
722
722
  else {
723
- var b = Math.floor(Math.log(a) / Math.LN2);
724
- b === 1024 && (b = 1023), w = a * Math.pow(2, -b), t(w * 4503599627370496 >>> 0, d, y + s), t((p << 31 | b + 1023 << 20 | w * 1048576 & 1048575) >>> 0, d, y + l);
723
+ var v = Math.floor(Math.log(a) / Math.LN2);
724
+ v === 1024 && (v = 1023), w = a * Math.pow(2, -v), t(w * 4503599627370496 >>> 0, d, y + s), t((p << 31 | v + 1023 << 20 | w * 1048576 & 1048575) >>> 0, d, y + l);
725
725
  }
726
726
  }
727
727
  }
728
728
  n.writeDoubleLE = i.bind(null, o, 0, 4), n.writeDoubleBE = i.bind(null, u, 4, 0);
729
729
  function e(t, s, l, a, d) {
730
- var y = t(a, d + s), p = t(a, d + l), w = (p >> 31) * 2 + 1, b = p >>> 20 & 2047, m = 4294967296 * (p & 1048575) + y;
731
- return b === 2047 ? m ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * m : w * Math.pow(2, b - 1075) * (m + 4503599627370496);
730
+ var y = t(a, d + s), p = t(a, d + l), w = (p >> 31) * 2 + 1, v = p >>> 20 & 2047, m = 4294967296 * (p & 1048575) + y;
731
+ return v === 2047 ? m ? NaN : w * (1 / 0) : v === 0 ? w * 5e-324 * m : w * Math.pow(2, v - 1075) * (m + 4503599627370496);
732
732
  }
733
733
  n.readDoubleLE = e.bind(null, c, 0, 4), n.readDoubleBE = e.bind(null, r, 4, 0);
734
734
  }(), n;
@@ -1001,13 +1001,13 @@ function requireWriter() {
1001
1001
  if (hasRequiredWriter) return writer;
1002
1002
  hasRequiredWriter = 1, writer = t;
1003
1003
  var f = requireMinimal$1(), o, u = f.LongBits, c = f.base64, r = f.utf8;
1004
- function n(b, m, g) {
1005
- this.fn = b, this.len = m, this.next = void 0, this.val = g;
1004
+ function n(v, m, g) {
1005
+ this.fn = v, this.len = m, this.next = void 0, this.val = g;
1006
1006
  }
1007
1007
  function i() {
1008
1008
  }
1009
- function e(b) {
1010
- this.head = b.head, this.tail = b.tail, this.len = b.len, this.next = b.states;
1009
+ function e(v) {
1010
+ this.head = v.head, this.tail = v.tail, this.len = v.len, this.next = v.states;
1011
1011
  }
1012
1012
  function t() {
1013
1013
  this.len = 0, this.head = new n(i, 0, 0), this.tail = this.head, this.states = null;
@@ -1026,16 +1026,16 @@ function requireWriter() {
1026
1026
  }, f.Array !== Array && (t.alloc = f.pool(t.alloc, f.Array.prototype.subarray)), t.prototype._push = function(m, g, k) {
1027
1027
  return this.tail = this.tail.next = new n(m, g, k), this.len += g, this;
1028
1028
  };
1029
- function l(b, m, g) {
1030
- m[g] = b & 255;
1029
+ function l(v, m, g) {
1030
+ m[g] = v & 255;
1031
1031
  }
1032
- function a(b, m, g) {
1033
- for (; b > 127; )
1034
- m[g++] = b & 127 | 128, b >>>= 7;
1035
- m[g] = b;
1032
+ function a(v, m, g) {
1033
+ for (; v > 127; )
1034
+ m[g++] = v & 127 | 128, v >>>= 7;
1035
+ m[g] = v;
1036
1036
  }
1037
- function d(b, m) {
1038
- this.len = b, this.next = void 0, this.val = m;
1037
+ function d(v, m) {
1038
+ this.len = v, this.next = void 0, this.val = m;
1039
1039
  }
1040
1040
  d.prototype = Object.create(n.prototype), d.prototype.fn = a, t.prototype.uint32 = function(m) {
1041
1041
  return this.len += (this.tail = this.tail.next = new d(
@@ -1047,12 +1047,12 @@ function requireWriter() {
1047
1047
  }, t.prototype.sint32 = function(m) {
1048
1048
  return this.uint32((m << 1 ^ m >> 31) >>> 0);
1049
1049
  };
1050
- function y(b, m, g) {
1051
- for (; b.hi; )
1052
- m[g++] = b.lo & 127 | 128, b.lo = (b.lo >>> 7 | b.hi << 25) >>> 0, b.hi >>>= 7;
1053
- for (; b.lo > 127; )
1054
- m[g++] = b.lo & 127 | 128, b.lo = b.lo >>> 7;
1055
- m[g++] = b.lo;
1050
+ function y(v, m, g) {
1051
+ for (; v.hi; )
1052
+ m[g++] = v.lo & 127 | 128, v.lo = (v.lo >>> 7 | v.hi << 25) >>> 0, v.hi >>>= 7;
1053
+ for (; v.lo > 127; )
1054
+ m[g++] = v.lo & 127 | 128, v.lo = v.lo >>> 7;
1055
+ m[g++] = v.lo;
1056
1056
  }
1057
1057
  t.prototype.uint64 = function(m) {
1058
1058
  var g = u.from(m);
@@ -1063,8 +1063,8 @@ function requireWriter() {
1063
1063
  }, t.prototype.bool = function(m) {
1064
1064
  return this._push(l, 1, m ? 1 : 0);
1065
1065
  };
1066
- function p(b, m, g) {
1067
- m[g] = b & 255, m[g + 1] = b >>> 8 & 255, m[g + 2] = b >>> 16 & 255, m[g + 3] = b >>> 24;
1066
+ function p(v, m, g) {
1067
+ m[g] = v & 255, m[g + 1] = v >>> 8 & 255, m[g + 2] = v >>> 16 & 255, m[g + 3] = v >>> 24;
1068
1068
  }
1069
1069
  t.prototype.fixed32 = function(m) {
1070
1070
  return this._push(p, 4, m >>> 0);
@@ -1105,8 +1105,8 @@ function requireWriter() {
1105
1105
  for (var m = this.head.next, g = this.constructor.alloc(this.len), k = 0; m; )
1106
1106
  m.fn(m.val, g, k), k += m.len, m = m.next;
1107
1107
  return g;
1108
- }, t._configure = function(b) {
1109
- o = b, t.create = s(), o._configure();
1108
+ }, t._configure = function(v) {
1109
+ o = v, t.create = s(), o._configure();
1110
1110
  }, writer;
1111
1111
  }
1112
1112
  var writer_buffer, hasRequiredWriter_buffer;
@@ -1575,8 +1575,8 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1575
1575
  a.userMap === $util.emptyObject && (a.userMap = {});
1576
1576
  let w = e.uint32() + e.pos;
1577
1577
  for (d = "", y = null; e.pos < w; ) {
1578
- let b = e.uint32();
1579
- switch (b >>> 3) {
1578
+ let v = e.uint32();
1579
+ switch (v >>> 3) {
1580
1580
  case 1:
1581
1581
  d = e.string();
1582
1582
  break;
@@ -1584,7 +1584,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1584
1584
  y = $root.com.quick.voice.proto.UserInfo.decode(e, e.uint32());
1585
1585
  break;
1586
1586
  default:
1587
- e.skipType(b & 7);
1587
+ e.skipType(v & 7);
1588
1588
  break;
1589
1589
  }
1590
1590
  }
@@ -2079,8 +2079,8 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2079
2079
  a.customKeyMap === $util.emptyObject && (a.customKeyMap = {});
2080
2080
  let w = e.uint32() + e.pos;
2081
2081
  for (d = "", y = ""; e.pos < w; ) {
2082
- let b = e.uint32();
2083
- switch (b >>> 3) {
2082
+ let v = e.uint32();
2083
+ switch (v >>> 3) {
2084
2084
  case 1:
2085
2085
  d = e.string();
2086
2086
  break;
@@ -2088,7 +2088,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2088
2088
  y = e.string();
2089
2089
  break;
2090
2090
  default:
2091
- e.skipType(b & 7);
2091
+ e.skipType(v & 7);
2092
2092
  break;
2093
2093
  }
2094
2094
  }
@@ -2171,56 +2171,56 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2171
2171
  });
2172
2172
  class RoomUser {
2173
2173
  constructor() {
2174
- v(this, "userId", "");
2175
- v(this, "mc_audio");
2174
+ b(this, "userId", "");
2175
+ b(this, "mc_audio");
2176
2176
  // 麦克风
2177
- v(this, "mc_video");
2177
+ b(this, "mc_video");
2178
2178
  // 摄像头
2179
- v(this, "ss_audio");
2179
+ b(this, "ss_audio");
2180
2180
  // 屏幕共享视频
2181
- v(this, "ss_video");
2181
+ b(this, "ss_video");
2182
2182
  // 屏幕共享音频
2183
- v(this, "updateTime", 0);
2184
- v(this, "getUpdateTimeKey", () => {
2183
+ b(this, "updateTime", 0);
2184
+ b(this, "getUpdateTimeKey", () => {
2185
2185
  const o = [];
2186
2186
  return this.mc_audio && o.push(this.mc_audio.updateTime), this.mc_video && o.push(this.mc_video.updateTime), this.ss_audio && o.push(this.ss_audio.updateTime), this.ss_video && o.push(this.ss_video.updateTime), o.join("_");
2187
2187
  });
2188
- v(this, "init", (o) => {
2188
+ b(this, "init", (o) => {
2189
2189
  var e, t, s, l;
2190
2190
  const { id: u, audios: c = [], videos: r = [] } = o;
2191
2191
  this.userId = u;
2192
2192
  const n = this.getUpdateTimeKey();
2193
2193
  this.mc_audio && (this.mc_audio.remove = !0), this.mc_video && (this.mc_video.remove = !0), this.ss_audio && (this.ss_audio.remove = !0), this.ss_video && (this.ss_video.remove = !0);
2194
2194
  for (const a of c) {
2195
- const { type: d = 0, isEnable: y = !1, isMute: p = !1, updateTime: w, volume: b = 0 } = a;
2195
+ const { type: d = 0, isEnable: y = !1, isMute: p = !1, updateTime: w, volume: v = 0 } = a;
2196
2196
  switch (d) {
2197
2197
  case 0:
2198
2198
  {
2199
2199
  if (this.mc_audio || (this.mc_audio = createAudioInfo()), this.mc_audio.remove = !1, this.mc_audio.updateTime === w) break;
2200
- this.mc_audio.isEnable = !!y, this.mc_audio.isMute = !!p, this.mc_audio.updateTime = Number(w), this.mc_audio.volume = Number(b);
2200
+ this.mc_audio.isEnable = !!y, this.mc_audio.isMute = !!p, this.mc_audio.updateTime = Number(w), this.mc_audio.volume = Number(v);
2201
2201
  }
2202
2202
  break;
2203
2203
  case 1:
2204
2204
  {
2205
2205
  if (this.ss_audio || (this.ss_audio = createAudioInfo()), this.ss_audio.remove = !1, this.ss_audio.updateTime === w) break;
2206
- this.ss_audio.isEnable = !!y, this.ss_audio.isMute = !!p, this.ss_audio.updateTime = Number(w), this.ss_audio.volume = Number(b);
2206
+ this.ss_audio.isEnable = !!y, this.ss_audio.isMute = !!p, this.ss_audio.updateTime = Number(w), this.ss_audio.volume = Number(v);
2207
2207
  }
2208
2208
  break;
2209
2209
  }
2210
2210
  }
2211
2211
  for (const a of r) {
2212
- const { type: d = 0, isEnable: y, isMute: p, updateTime: w, width: b, height: m, x: g, y: k } = a;
2212
+ const { type: d = 0, isEnable: y, isMute: p, updateTime: w, width: v, height: m, x: g, y: k } = a;
2213
2213
  switch (d) {
2214
2214
  case 0:
2215
2215
  {
2216
2216
  if (this.mc_video || (this.mc_video = createVideoInfo()), this.mc_video.remove = !1, this.mc_video.updateTime === w) break;
2217
- this.mc_video.isEnable = !!y, this.mc_video.isMute = !!p, this.mc_video.updateTime = Number(w) || 0, this.mc_video.sx = g || 0, this.mc_video.sy = k || 0, this.mc_video.sw = b || 0, this.mc_video.sh = m || 0;
2217
+ this.mc_video.isEnable = !!y, this.mc_video.isMute = !!p, this.mc_video.updateTime = Number(w) || 0, this.mc_video.sx = g || 0, this.mc_video.sy = k || 0, this.mc_video.sw = v || 0, this.mc_video.sh = m || 0;
2218
2218
  }
2219
2219
  break;
2220
2220
  case 1:
2221
2221
  {
2222
2222
  if (this.ss_video || (this.ss_video = createVideoInfo()), this.ss_video.remove = !1, this.ss_video.updateTime === w) break;
2223
- this.ss_video.isEnable = !!y, this.ss_video.isMute = !!p, this.ss_video.updateTime = Number(w) || 0, this.ss_video.sx = g || 0, this.ss_video.sy = k || 0, this.ss_video.sw = b || 0, this.ss_video.sh = m || 0;
2223
+ this.ss_video.isEnable = !!y, this.ss_video.isMute = !!p, this.ss_video.updateTime = Number(w) || 0, this.ss_video.sx = g || 0, this.ss_video.sy = k || 0, this.ss_video.sw = v || 0, this.ss_video.sh = m || 0;
2224
2224
  }
2225
2225
  break;
2226
2226
  }
@@ -2229,7 +2229,7 @@ class RoomUser {
2229
2229
  const i = this.getUpdateTimeKey();
2230
2230
  n !== i && (this.updateTime = (/* @__PURE__ */ new Date()).getTime());
2231
2231
  });
2232
- v(this, "destroy", () => {
2232
+ b(this, "destroy", () => {
2233
2233
  var o, u;
2234
2234
  (o = this.mc_video) != null && o.destroy && this.mc_video.destroy(), (u = this.ss_video) != null && u.destroy && this.ss_video.destroy(), this.mc_audio = void 0, this.mc_video = void 0, this.ss_audio = void 0, this.ss_video = void 0;
2235
2235
  });
@@ -2264,36 +2264,36 @@ const parseSEI = (f) => {
2264
2264
  };
2265
2265
  class QuickVoPlayer {
2266
2266
  constructor() {
2267
- v(this, "displayMode", "original");
2268
- v(this, "prPlayer", new be());
2269
- v(this, "dom");
2270
- v(this, "room", {
2267
+ b(this, "displayMode", "original");
2268
+ b(this, "prPlayer", new be());
2269
+ b(this, "dom");
2270
+ b(this, "room", {
2271
2271
  roomId: "",
2272
2272
  updateTime: "",
2273
2273
  author: "",
2274
2274
  version: ""
2275
2275
  });
2276
- v(this, "usersMap", /* @__PURE__ */ new Map());
2277
- v(this, "on", {
2276
+ b(this, "usersMap", /* @__PURE__ */ new Map());
2277
+ b(this, "on", {
2278
2278
  users: (o) => {
2279
2279
  }
2280
2280
  });
2281
- v(this, "init", () => {
2281
+ b(this, "init", () => {
2282
2282
  this.prPlayer.init();
2283
2283
  });
2284
- v(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
2285
- v(this, "stop", () => {
2284
+ b(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
2285
+ b(this, "stop", () => {
2286
2286
  this.prPlayer.stop(), this.usersMap = /* @__PURE__ */ new Map(), this.room.roomId = "", this.room.author = "", this.room.updateTime = "", this.room.version = "";
2287
2287
  });
2288
- v(this, "setMute", (o) => {
2288
+ b(this, "setMute", (o) => {
2289
2289
  this.prPlayer.setMute(o);
2290
2290
  });
2291
- v(this, "getStream", () => this.prPlayer.getStream());
2292
- v(this, "getAllUseUpdateKey", () => {
2291
+ b(this, "getStream", () => this.prPlayer.getStream());
2292
+ b(this, "getAllUseUpdateKey", () => {
2293
2293
  const o = [...this.usersMap.values()];
2294
2294
  return Array.from(o, (c) => c.updateTime).join("_");
2295
2295
  });
2296
- v(this, "checkAndCreateUser", (o, u) => {
2296
+ b(this, "checkAndCreateUser", (o, u) => {
2297
2297
  var c, r;
2298
2298
  if (this.usersMap.has(o)) {
2299
2299
  const n = this.usersMap.get(o);
@@ -2326,7 +2326,7 @@ class QuickVoPlayer {
2326
2326
  /**
2327
2327
  * 监听SEI信息
2328
2328
  */
2329
- v(this, "onSEI", (o) => {
2329
+ b(this, "onSEI", (o) => {
2330
2330
  try {
2331
2331
  const u = parseSEI(o);
2332
2332
  if (!u) return;
@@ -2348,7 +2348,7 @@ class QuickVoPlayer {
2348
2348
  }
2349
2349
  const s = this.getAllUseUpdateKey();
2350
2350
  if (e !== s && this.on.users) {
2351
- const l = [...this.usersMap.values()], a = Array.from(l, ({ userId: d, mc_audio: y, mc_video: p, ss_audio: w, ss_video: b, updateTime: m }) => ({ userId: d, mc_audio: y, mc_video: p, ss_audio: w, ss_video: b, updateTime: m }));
2351
+ const l = [...this.usersMap.values()], a = Array.from(l, ({ userId: d, mc_audio: y, mc_video: p, ss_audio: w, ss_video: v, updateTime: m }) => ({ userId: d, mc_audio: y, mc_video: p, ss_audio: w, ss_video: v, updateTime: m }));
2352
2352
  this.on.users(a);
2353
2353
  }
2354
2354
  }
@@ -2364,7 +2364,7 @@ class QuickVoPlayer {
2364
2364
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", u);
2365
2365
  }
2366
2366
  });
2367
- v(this, "setDisplayMode", (o) => {
2367
+ b(this, "setDisplayMode", (o) => {
2368
2368
  var u, c, r, n, i, e, t, s;
2369
2369
  switch (this.displayMode = o, o) {
2370
2370
  case "original":
@@ -1,3 +1,3 @@
1
- (function(T,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(T=typeof globalThis<"u"?globalThis:T||self,k(T["quickvo-player"]={}))})(this,function(exports){"use strict";var U=Object.defineProperty;var D=T=>{throw TypeError(T)};var W=(T,k,f)=>k in T?U(T,k,{enumerable:!0,configurable:!0,writable:!0,value:f}):T[k]=f;var v=(T,k,f)=>W(T,typeof k!="symbol"?k+"":k,f),B=(T,k,f)=>k.has(T)||D("Cannot "+f);var S=(T,k,f)=>(B(T,k,"read from private field"),f?f.call(T):k.get(T)),P=(T,k,f)=>k.has(T)?D("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(T):k.set(T,f),C=(T,k,f,n)=>(B(T,k,"write to private field"),n?n.call(T,f):k.set(T,f),f);var T,k;const L='(function(){"use strict";const U=new TextDecoder("utf-8"),H=(e,s)=>{const a=e.getUint8(s),t=a>>7&1,n=a>>5&3,r=a&31;return{forbidden_zero_bit:t,nal_ref_idc:n,nal_unit_type:r}},b=(e,s)=>e.getUint8(s),P=(e,s,a)=>{const t=new Uint8Array(e.buffer.slice(s,s+a));return U?.decode(t)||""},T=(e,s,a)=>{let t=s,n,r=0;switch(a){case 0:n=e.getFloat64(t,!1),r=8;break;case 1:n=!!e.getUint8(t),r=1;break;case 2:{n="";const o=e.getUint16(t,!1);t=t+2;const c=new Int8Array(e.buffer,t,o).filter(d=>d!==0);n=(U?.decode(c)||"").trim(),r=2+o}break;case 3:for(n={};t<e.byteLength;){const o=e.getUint16(t,!1);if(o===0)break;t=t+2;const c=P(e,t,o);t=t+o;const g=b(e,t);if(g===6)break;t=t+1;const d=T(e,t,g);t=t+d.length,n[c]=d.value,r=2+o+1+d.length}break;case 8:{n={};const o=e.getUint32(t,!1);t=t+4;for(let c=0;c<o;c++){const g=e.getUint16(t,!1);t=t+2;const d=P(e,t,g);t=t+g;const h=b(e,t);t=t+1;const l=T(e,t,h);t=t+l.length,n[d]=l.value,r=2+g+1+l.length}}break;case 10:{n=[];const o=e.getUint32(t,!1);t=t+4;for(let c=0;c<o;c++){const g=b(e,t);t=t+1;const d=T(e,t,g);t=t+d.length,n.push(d.value),r=1+d.length}}break}return{amfType:a,length:r,value:n}},m=(e,s)=>e.getUint8(s)<<16|e.getUint8(s+1)<<8|e.getUint8(s+2);var u={header:{getSignature:e=>{const s=new Int8Array(e.buffer.slice(0,3));return U?.decode(s)||""},getVersion:e=>e.getUint8(3),getFlags:e=>{const a=e.getUint8(0).toString(2).padStart(5,"0").split(""),[,,t,,n]=a;return{audio:n==="1",video:t==="1"}},getDataOffset:e=>e.getUint32(5)},getPreviousTagSize:(e,s)=>e.getUint32(s),isSurplusTag:(e,s)=>{let a=!0;const t=e.byteLength;if(s+4>t)a=!1;else if(s+4+11>t)a=!1;else{const n=m(e,s+4+1);s+4+11+n>t&&(a=!1)}return a},tag:{tagHeader:{getTagType:(e,s)=>{const a=e.getUint8(s);let t;switch(a){case 18:t="script";break;case 8:t="audio";break;case 9:t="video";break}return t},getDataSize:(e,s)=>m(e,s+1),getTimestamp:(e,s)=>m(e,s+4),getTimestampExtended:(e,s)=>e.getUint8(s+7),getStreamID:(e,s)=>m(e,s+8)},tagBody:{parseAudio:(e,s,a)=>{let t=s;const n=e.getUint8(t),r=n>>4&15,i=n>>2&3,o=n>>1&1,c=n&1;t=t+1;const g=e.getUint8(t);t=t+1;const d=a-2,h=new Uint8Array(e.buffer.slice(t,t+d));if(r===10&&g===0){const l=e.getUint8(t),p=e.getUint8(t+1),f=(l&248)>>3,y=(l&7)<<1|p>>7,S=(p&120)>>3,A=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],D=`mp4a.40.${f}`,z=A[y];return{soundFormat:r,soundRate:i,soundSize:o,soundType:c,accPacketType:g,data:h,audioObjectType:f,samplingFrequencyIndex:y,channelConfiguration:S,codec:D,sampleRate:z}}return{soundFormat:r,soundRate:i,soundSize:o,soundType:c,accPacketType:g,data:h}},parseVideo:(e,s,a)=>{let t=s;const n=e.getUint8(t),r=n>>4&15,i=n&15;t=t+1;const o=e.getUint8(t);t=t+1;const c=m(e,t);t=t+3;const g=a-5,d=new Uint8Array(e.buffer.slice(t,t+g));switch(i){case 7:if(o===0){const h=e.getUint8(t);if(t=t+1,h!==1)throw new Error("Invalid AVC version");const l=e.getUint8(t)&255;t=t+1;const p=e.getUint8(t)&255;t=t+1;const f=e.getUint8(t)&255;t=t+1;const A=`avc1.${Array.from([l,p,f],E=>E.toString(16).padStart(2,"0")).join("")}`,D=(e.getUint8(t)&3)-1;t=t+1;const z=e.getUint8(t)&31;t=t+1;const _=e.getUint16(t,!1);t=t+2;const O=new Uint8Array(e.buffer.slice(t,t+_));t=t+_;const I=e.getUint8(t)&31;t=t+1;const x=e.getUint16(t,!1);t=t+2;const M=new Uint8Array(e.buffer.slice(t,t+x));return t=t+x,{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d,version:h,codec:A,profile:l,compatibility:p,level:f,lengthSizeMinusOne:D,numOfSequenceParameterSets:z,sequenceParameterSetLength:_,sps:O,numOfPictureParameterSets:I,pictureParameterSetLength:x,pps:M}}else if(o===1){const h=[],l=t+a-5;for(;t+4<l;){const p=e.getUint32(t,!1);t=t+4;const f=H(e,t);t=t+1;const y=p-1,S=new Uint8Array(e.buffer.slice(t,t+y));t=t+y,h.push({size:p,header:f,payload:S})}return{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d,nalus:h}}break;default:throw new Error("Unsupported codecID")}return{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d}},parseMetaData:(e,s)=>{let a=s;{if(e.getUint8(a)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");a=a+1}const t=e.getUint16(a,!1);a=a+2;{const i=new Int8Array(e.buffer.slice(a,a+t));if((U?.decode(i)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");a=a+t}const n=b(e,a);return a=a+1,T(e,a,n).value}}}};class L{parseSpeed=8;pendingPayloads=[];payload=new Uint8Array(0);offset=0;is_parsing=!1;header;tag;on={};constructor(){}init=()=>{this.destroy()};push=s=>{this.pendingPayloads.push(s),this.is_parsing||this.parse()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.offset=0,this.is_parsing=!1,this.header=void 0,this.tag=void 0};parse=async()=>{for(this.is_parsing=!0;;){const s=this.pendingPayloads.shift();if(!s)break;const a=new Uint8Array(this.payload.byteLength+s.byteLength);a.set(this.payload,0),a.set(s,this.payload.byteLength),this.payload=a;const t=new DataView(this.payload.buffer);this.header||this.parseHeader(t),await this.parseTag(t)}this.is_parsing=!1};parseHeader=s=>(this.header={signature:u.header.getSignature(s),version:u.header.getVersion(s),flags:u.header.getFlags(s),dataOffset:u.header.getDataOffset(s)},this.offset=this.header?.dataOffset,this.on.header&&this.on.header(this.header),this.header);parseTag=async s=>{const a=(n,r)=>({tagType:u.tag.tagHeader.getTagType(n,r),dataSize:u.tag.tagHeader.getDataSize(n,r),timestamp:u.tag.tagHeader.getTimestamp(n,r),timestampExtended:u.tag.tagHeader.getTimestampExtended(n,r),streamID:u.tag.tagHeader.getStreamID(n,r)}),t=(n,r,i,o)=>{let c;switch(n){case"script":c=u.tag.tagBody.parseMetaData(r,i);break;case"audio":c=u.tag.tagBody.parseAudio(r,i,o);break;case"video":c=u.tag.tagBody.parseVideo(r,i,o);break}return c};for(;this.offset<s.byteLength;){if(u.isSurplusTag(s,this.offset)===!1){this.payload=this.payload.slice(this.offset),this.offset=0;break}const r=a(s,this.offset+4),{tagType:i,dataSize:o}=r;if(!i)break;const c=t(i,s,this.offset+4+11,o);this.tag={header:r,body:c},this.on.tag&&this.on.tag(this.tag),this.offset=this.offset+4+11+o,await new Promise(g=>setTimeout(()=>g(!0),this.parseSpeed))}}}const k=new L;k.on.header=e=>postMessage({action:"onHeader",data:e}),k.on.tag=e=>postMessage({action:"onTag",data:e}),onmessage=e=>{const{action:s,data:a}=e.data,t=k[s];t&&t(a)}})();\n',A=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",L],{type:"text/javascript;charset=utf-8"});function E(f){let n;try{if(n=A&&(self.URL||self.webkitURL).createObjectURL(A),!n)throw"";const u=new Worker(n,{name:f==null?void 0:f.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(L),{name:f==null?void 0:f.name})}}class _{constructor(){v(this,"worker",new E);v(this,"on",{});v(this,"init",()=>this.worker.postMessage({action:"init"}));v(this,"push",n=>this.worker.postMessage({action:"push",data:n}));v(this,"destroy",()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()});this.worker.onmessage=n=>{const{action:u,data:c}=n.data;u==="onHeader"&&this.on.header&&this.on.header(c),u==="onTag"&&this.on.tag&&this.on.tag(c)}}}const N=`(function(){"use strict";class r{audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;on={audio:{},video:{}};constructor(){}audio={init:i=>{this.audio.destroy(),this.audioDecoderConfig={...i},this.audioDecoder=new AudioDecoder({output:e=>{this.on.audio.decode&&this.on.audio.decode(e)},error:e=>{this.on.audio.error&&this.on.audio.error(e)}}),this.audioDecoder.configure(this.audioDecoderConfig)},decode:i=>{if(!this.audioDecoder)return;const e=new EncodedAudioChunk(i);this.audioDecoder.decode(e)},flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={init:i=>{this.video.destroy(),this.videoDecoderConfig={...i},this.videoDecoder=new VideoDecoder({output:async e=>{const d=await createImageBitmap(e),s=e.timestamp;e.close(),d.width>0&&d.height>0?this.on.video.decode&&this.on.video.decode({timestamp:s,bitmap:d}):d.close()},error:e=>{this.on.video.error&&this.on.video.error(e)}}),this.videoDecoder.configure(this.videoDecoderConfig)},decode:i=>{if(this.videoDecoder&&(i.type==="key"&&(this.hasKeyFrame=!0),this.hasKeyFrame&&this.videoDecoder.decodeQueueSize<2)){const e=new EncodedVideoChunk(i);this.videoDecoder.decode(e)}},flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const t=new r;t.on.audio.decode=o=>postMessage({type:"audio",action:"onDecode",data:o}),t.on.audio.error=o=>postMessage({type:"audio",action:"onError",data:o}),t.on.video.decode=o=>postMessage({type:"video",action:"onDecode",data:o}),t.on.video.error=o=>postMessage({type:"video",action:"onError",data:o}),onmessage=o=>{const{type:i,action:e,data:d}=o.data,s=t[i][e];s&&s(d)}})();
2
- `,R=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",N],{type:"text/javascript;charset=utf-8"});function V(f){let n;try{if(n=R&&(self.URL||self.webkitURL).createObjectURL(R),!n)throw"";const u=new Worker(n,{name:f==null?void 0:f.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(N),{name:f==null?void 0:f.name})}}class j{constructor(){v(this,"worker",new V);v(this,"on",{audio:{},video:{}});v(this,"audio",{init:n=>this.worker.postMessage({type:"audio",action:"init",data:n}),decode:n=>this.worker.postMessage({type:"audio",action:"decode",data:n}),flush:()=>this.worker.postMessage({type:"audio",action:"flush"}),destroy:()=>{this.worker.postMessage({type:"audio",action:"destroy"})}});v(this,"video",{init:n=>this.worker.postMessage({type:"video",action:"init",data:n}),decode:n=>this.worker.postMessage({type:"video",action:"decode",data:n}),flush:()=>this.worker.postMessage({type:"video",action:"flush"}),destroy:()=>{this.worker.postMessage({type:"video",action:"destroy",data:{}})}});v(this,"destroy",()=>{this.worker.postMessage({type:"audio",action:"destroy"}),this.worker.postMessage({type:"video",action:"destroy",data:{}}),this.worker.terminate()});this.worker.onmessage=n=>{const{type:u,action:c,data:o}=n.data;switch(u){case"audio":c==="onDecode"&&this.on.audio.decode&&this.on.audio.decode(o),c==="onError"&&this.on.audio.error&&this.on.audio.error(o);break;case"video":c==="onDecode"&&this.on.video.decode&&this.on.video.decode(o),c==="onError"&&this.on.video.error&&this.on.video.error(o);break}}}}const F=`(function(){"use strict";class r{isRendering=!1;pendingFrames=[];offscreenCanvas;writable;writer;ctx;cutOption;baseTime=0;pause=!1;shader=["stream"];constructor(){}init=({offscreenCanvas:e,baseTime:t=performance.timeOrigin,writable:i})=>{this.destroy(),this.offscreenCanvas=e,this.writable=i,this.writer=this.writable.getWriter(),this.ctx=this.offscreenCanvas.getContext("2d"),this.baseTime=t};setShader=e=>{this.shader=e};setSize=({width:e,height:t})=>{this.offscreenCanvas&&(this.offscreenCanvas.width=e,this.offscreenCanvas.height=t)};destroy=()=>{this.isRendering=!1,this.pendingFrames=[],this.offscreenCanvas=void 0,this.ctx=void 0,this.baseTime=0};push=e=>{this.pendingFrames.push(e),this.isRendering===!1&&setTimeout(this.renderFrame,0)};setCut=e=>{this.cutOption=e};setPause=e=>{this.pause=e,this.isRendering===!1&&setTimeout(this.renderFrame,0)};calculateTimeUntilNextFrame=e=>{const t=performance.timeOrigin+performance.now(),s=this.baseTime+e/1e3-t;return Math.max(0,s)};renderFrame=async()=>{for(this.isRendering=!0;;){const e=this.pendingFrames.shift();if(!e)break;let{timestamp:t,bitmap:i}=e;if(this.cutOption){const{sx:a=0,sy:c=0,sw:m=i.width,sh:o=i.height}=this.cutOption;i=await createImageBitmap(i,a,c,m,o)}const s=this.calculateTimeUntilNextFrame(t);await new Promise(a=>setTimeout(()=>a(!0),s)),this.drawImage({timestamp:t,bitmap:i}),this.cutOption&&i.close()}this.isRendering=!1};drawImage=e=>{if(this.pause!==!0){if(this.shader.includes("stream")){const t=new VideoFrame(e.bitmap,{timestamp:e.timestamp});this.writer.write(t),t.close()}this.shader.includes("canvas")&&this.ctx&&this.offscreenCanvas&&this.ctx.drawImage(e.bitmap,0,0,this.offscreenCanvas.width,this.offscreenCanvas.height)}}}const h=new r;onmessage=n=>{const{action:e,data:t}=n.data,i=h[e];i&&i(t)}})();
3
- `,M=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",F],{type:"text/javascript;charset=utf-8"});function H(f){let n;try{if(n=M&&(self.URL||self.webkitURL).createObjectURL(M),!n)throw"";const u=new Worker(n,{name:f==null?void 0:f.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(F),{name:f==null?void 0:f.name})}}class ${constructor(){v(this,"worker",new H);v(this,"init",({offscreenCanvas:n,baseTime:u=0,writable:c})=>this.worker.postMessage({action:"init",data:{offscreenCanvas:n,baseTime:u,writable:c}},[n,c]));v(this,"setShader",n=>this.worker.postMessage({action:"setShader",data:n}));v(this,"setSize",({width:n,height:u})=>this.worker.postMessage({action:"setSize",data:{width:n,height:u}}));v(this,"push",n=>this.worker.postMessage({action:"push",data:n}));v(this,"setCut",async n=>this.worker.postMessage({action:"setCut",data:n}));v(this,"setPause",n=>this.worker.postMessage({action:"setPause",data:n}));v(this,"destroy",()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()})}}var q=Object.defineProperty,K=(f,n,u)=>n in f?q(f,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):f[n]=u,h=(f,n,u)=>K(f,typeof n!="symbol"?n+"":n,u);class Q{constructor(n,u){h(this,"inputStream",new MediaStream),h(this,"outputStream",new MediaStream),h(this,"inputGain",1),h(this,"enhanceGain",1),h(this,"bgsGain",1),h(this,"bgmGain",1),h(this,"outputGain",1),h(this,"mixAudioMap",new Map),h(this,"audioContext",new AudioContext),h(this,"sourceNode"),h(this,"inputGainNode"),h(this,"enhanceGainNode"),h(this,"bgsGainNode"),h(this,"bgmGainNode"),h(this,"analyserNode"),h(this,"analyserArrayData"),h(this,"outputGainNode"),h(this,"destinationNode"),h(this,"filterStream",c=>c),h(this,"stop",()=>{{const c=this.inputStream.getTracks();for(const o of c)o.stop(),this.inputStream.removeTrack(o)}}),h(this,"getStream",()=>this.filterStream(this.outputStream)),h(this,"setMute",(c=!0)=>{c?this.analyserNode.disconnect(this.outputGainNode):this.analyserNode.connect(this.outputGainNode)}),h(this,"setInputGain",c=>{this.inputGain=c,this.inputGainNode.gain.setValueAtTime(c,this.audioContext.currentTime)}),h(this,"setEnhanceGain",async c=>{this.enhanceGain=c+1,this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime)}),h(this,"setBgsGain",c=>{this.bgsGain=c,this.bgsGainNode.gain.setValueAtTime(c,this.audioContext.currentTime)}),h(this,"setBgmGain",c=>{this.bgmGain=c,this.bgmGainNode.gain.setValueAtTime(c,this.audioContext.currentTime)}),h(this,"setOutputGain",c=>{this.outputGain=c,this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime)}),h(this,"getVolume",()=>{const{analyserNode:c,analyserArrayData:o}=this;c.getByteFrequencyData(o);let r=0;for(let i=0;i<o.length;i++)r+=o[i];return Math.ceil(r/o.length)}),h(this,"mixAudio",(c,o="bgm")=>new Promise(async(r,i)=>{try{{const s=this.mixAudioMap.get(o);s&&s.stop()}const e=o==="bgs"?this.bgsGainNode:this.bgmGainNode,t=this.audioContext.createBufferSource();this.mixAudioMap.set(o,t),t.buffer=c,t.connect(e),t.onended=()=>{t.disconnect(e),this.mixAudioMap.delete(o),r(!0)},t.start(0)}catch(e){i(e)}})),h(this,"mixAudioStop",c=>{const o=this.mixAudioMap.get(c);o==null||o.stop()}),h(this,"changeMix",(c,o)=>{const r=c==="bgs"?this.bgsGainNode:this.bgmGainNode;o?r.connect(this.destinationNode):r.disconnect(this.destinationNode)}),u&&(this.audioContext=u),this.inputStream=n,this.sourceNode=this.audioContext.createMediaStreamSource(this.inputStream),this.inputGainNode=this.audioContext.createGain(),this.inputGainNode.gain.setValueAtTime(this.inputGain,this.audioContext.currentTime),this.enhanceGainNode=this.audioContext.createGain(),this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime),this.bgsGainNode=this.audioContext.createGain(),this.bgsGainNode.gain.setValueAtTime(this.bgsGain,this.audioContext.currentTime),this.bgmGainNode=this.audioContext.createGain(),this.bgmGainNode.gain.setValueAtTime(this.bgmGain,this.audioContext.currentTime),this.analyserNode=this.audioContext.createAnalyser(),this.analyserNode.fftSize=512,this.analyserArrayData=new Uint8Array(this.analyserNode.frequencyBinCount),this.outputGainNode=this.audioContext.createGain(),this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime),this.destinationNode=this.audioContext.createMediaStreamDestination(),this.outputStream=this.destinationNode.stream;{const{sourceNode:c,inputGainNode:o,enhanceGainNode:r,bgsGainNode:i,bgmGainNode:e,analyserNode:t,outputGainNode:s,destinationNode:l}=this;c.connect(o),o.connect(r),r.connect(t),i.connect(t),e.connect(t),r.connect(l),i.connect(l),e.connect(l),t.connect(s),s.connect(this.audioContext.destination)}this.setMute(!0),this.audioContext.resume()}}const J=async(f,n)=>{try{const{format:u,numberOfChannels:c,numberOfFrames:o,sampleRate:r}=n,i=f.createBuffer(c,o,r);for(let e=0;e<c;e++){const t=n.allocationSize({planeIndex:e}),s=new Uint8Array(t);n.copyTo(s,{planeIndex:e});const l=new DataView(s.buffer),a=i.getChannelData(e);for(let d=0;d<o;d++){let y;switch(u){case"s16":case"s16-planar":y=l.getInt16(d*2,!0)/32768;break;case"f32":case"f32-planar":y=l.getFloat32(d*4,!0);break;case"u8":case"u8-planar":y=(l.getUint8(d)-128)/128;break;default:throw new Error(`Unsupported audio format: ${u}`)}a[d]=Math.max(-1,Math.min(1,y))}}return i}catch(u){throw console.error("Failed to convert AudioData to AudioBuffer:",u),u}};class X{constructor(){v(this,"prAudioStream");v(this,"audioContext");v(this,"destination");v(this,"stream",new MediaStream);v(this,"nextStartTime",0);v(this,"pendingSources",[]);v(this,"init",n=>{n||(n=new(window.AudioContext||window.webkitAudioContext)),this.audioContext=n,this.destination=this.audioContext.createMediaStreamDestination(),this.stream=new MediaStream,this.stream.addTrack(this.destination.stream.getAudioTracks()[0]),this.prAudioStream=new Q(this.stream,this.audioContext),this.nextStartTime=0,this.pendingSources=[]});v(this,"getStream",()=>{var n;return(n=this.prAudioStream)==null?void 0:n.getStream()})}async push(n){try{if(!this.audioContext||!this.destination)return;const u=await J(this.audioContext,n);if(!u)return;const c=this.audioContext.createBufferSource();c.buffer=u,c.connect(this.destination);const o=Math.max(this.nextStartTime,this.audioContext.currentTime);this.nextStartTime=o+u.duration,c.start(o),this.pendingSources.push(c),c.onended=()=>{this.pendingSources=this.pendingSources.filter(r=>r!==c)},this.audioContext.state==="suspended"&&await this.audioContext.resume()}finally{n.close()}}destroy(){var n,u;(n=this.audioContext)==null||n.close(),this.audioContext=void 0,this.destination=void 0,this.nextStartTime=0,(u=this.prAudioStream)==null||u.stop(),this.pendingSources.forEach(c=>c.stop()),this.pendingSources=[]}}class Y{constructor(n={}){P(this,T,{timeout:5*1e3});P(this,k);v(this,"check",(n,u)=>new Promise(async(c,o)=>{var i;this.stop(),C(this,k,new AbortController);const r=window.setTimeout(()=>{var e;(e=S(this,k))==null||e.abort("Timeout."),o({status:"timeout",reason:""})},S(this,T).timeout);try{const e=await fetch(n,{...u,method:"HEAD",signal:(i=S(this,k))==null?void 0:i.signal});e.status===200?c({status:"successed",reason:""}):o({status:"failed",reason:`${e.status}`})}catch(e){o({status:"error",reason:e.message})}clearTimeout(r)}));v(this,"request",async(n,u)=>new Promise(async(c,o)=>{var r;try{await this.check(n,u),C(this,k,new AbortController);const i=await fetch(n,{...u,signal:(r=S(this,k))==null?void 0:r.signal});c(i)}catch(i){this.stop(),o(i)}}));v(this,"stop",()=>{var n;((n=S(this,k))==null?void 0:n.signal.aborted)===!1&&S(this,k).abort("Actively stop.")});C(this,T,{...S(this,T),...n})}}T=new WeakMap,k=new WeakMap;const O=f=>{const n=(f==null?void 0:f.getTracks())||[];for(const u of n)u.stop()},G=f=>{const n=new $,u=document.createElement("canvas"),c=u.transferControlToOffscreen(),o=new MediaStreamTrackGenerator({kind:"video"}),r=new MediaStream([o]),i=()=>{n.destroy(),O(r)};return n.init({offscreenCanvas:c,baseTime:f,writable:o.writable}),{worker:n,canvas:u,stream:r,destroy:i}};class be{constructor(){v(this,"prFetch",new Y);v(this,"demuxerWorker");v(this,"decoderWorker");v(this,"audioPlayer");v(this,"renderWorker");v(this,"renderBaseTime",0);v(this,"stream");v(this,"canvas");v(this,"on",{demuxer:{},decoder:{}});v(this,"cutRenders",new Map);v(this,"trackGenerator");v(this,"init",()=>{this.initDemuxer(),this.initDecoder(),this.audioPlayer=new X,this.audioPlayer.init(),this.initRender()});v(this,"start",async n=>(this.stop(),this.renderBaseTime=new Date().getTime(),this.init(),this.prFetch.request(n).then(async u=>{var r;const c=(r=u.body)==null?void 0:r.getReader();if(!c)throw new Error("Reader is error.");const o=()=>{c.read().then(({done:i,value:e})=>{var t;e&&((t=this.demuxerWorker)==null||t.push(e)),!i&&o()}).catch(i=>{if(i.name!=="AbortError")throw i})};o()}).catch(u=>{console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->Breathe: err",u)})));v(this,"stop",async()=>{var u,c,o,r;try{this.prFetch.stop()}catch(i){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->Breathe: error",i)}(u=this.demuxerWorker)==null||u.destroy(),(c=this.decoderWorker)==null||c.destroy(),(o=this.renderWorker)==null||o.destroy(),O(this.stream);const n=[...this.cutRenders.keys()];for(const i of n)this.cut.remove(i);(r=this.audioPlayer)==null||r.destroy(),this.renderBaseTime=0,this.canvas=void 0});v(this,"onTag",n=>{var i;if(!this.decoderWorker)return;const{header:u,body:c}=n,{tagType:o,timestamp:r}=u;switch(o){case"script":{const{width:e,height:t}=c;(i=this.renderWorker)==null||i.setSize({width:e,height:t}),this.on.demuxer.script&&this.on.demuxer.script(n)}break;case"audio":{const{accPacketType:e,data:t}=c;if(e===0){const{codec:s,sampleRate:l,channelConfiguration:a}=c,d={codec:s,sampleRate:l,numberOfChannels:a,description:new Uint8Array([])};this.decoderWorker.audio.init(d)}else e===1&&this.decoderWorker.audio.decode({type:"key",timestamp:r*1,data:t});this.on.demuxer.audio&&this.on.demuxer.audio(n)}break;case"video":{const{avcPacketType:e,frameType:t,data:s,nalus:l=[]}=c;if(e===0){const{codec:a,data:d}=c;this.decoderWorker.video.init({codec:a,description:d})}else if(e===1){const a=t===1?"key":"delta";this.decoderWorker.video.decode({type:a,timestamp:r*1e3,data:s});for(const d of l){const{header:y,payload:p}=d,{nal_unit_type:w}=y;w===6&&this.on.demuxer.sei&&this.on.demuxer.sei(p)}}this.on.demuxer.video&&this.on.demuxer.video(n)}break}});v(this,"initDemuxer",()=>{this.demuxerWorker=new _,this.demuxerWorker.init(),this.demuxerWorker.on.tag=this.onTag});v(this,"initDecoder",()=>{this.decoderWorker=new j,this.decoderWorker.on.audio.decode=n=>{var u;(u=this.audioPlayer)==null||u.push(n),this.on.decoder.audio&&this.on.decoder.audio(n)},this.decoderWorker.on.audio.error=n=>{this.stop(),this.on.error&&this.on.error(n)},this.decoderWorker.on.video.decode=async n=>{var c,o;(c=this.renderWorker)==null||c.push(n);const u=[...this.cutRenders.keys()];for(const r of u)(o=this.cutRenders.get(r))==null||o.worker.push(n);this.on.decoder.video&&this.on.decoder.video(n),n.bitmap.close()},this.decoderWorker.on.video.error=n=>{this.stop(),this.on.error&&this.on.error(n)}});v(this,"initRender",()=>{const{worker:n,canvas:u,stream:c}=G(this.renderBaseTime);this.renderWorker=n,this.canvas=u,this.stream=c,this.renderWorker.setPause(!1)});v(this,"getCanvas",()=>this.canvas);v(this,"getStream",()=>this.stream);v(this,"getCutCanvas",n=>{var u;return(u=this.cutRenders.get(n))==null?void 0:u.canvas});v(this,"getCutStream",n=>{var u;return(u=this.cutRenders.get(n))==null?void 0:u.stream});v(this,"setPause",n=>{var u;(u=this.renderWorker)==null||u.setPause(n)});v(this,"setShader",n=>{var u;(u=this.renderWorker)==null||u.setShader(n)});v(this,"setMute",n=>{var u,c;return(c=(u=this.audioPlayer)==null?void 0:u.prAudioStream)==null?void 0:c.setMute(n)});v(this,"cut",{create:(n,u)=>{let c=this.cutRenders.get(n);return c?(c.worker.setCut(u),c.worker.setPause(!1),c):(c=G(this.renderBaseTime),c.worker.setCut(u),this.cutRenders.set(n,c),c)},setPause:(n,u)=>{var c;(c=this.cutRenders.get(n))==null||c.worker.setPause(u)},setShader:(n,u)=>{var c;(c=this.cutRenders.get(n))==null||c.worker.setShader(u)},remove:n=>{var u;(u=this.cutRenders.get(n))==null||u.destroy(),this.cutRenders.delete(n)}})}}new TextDecoder("utf-8");var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},indexMinimal={},minimal$1={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;hasRequiredAspromise=1,aspromise=f;function f(n,u){for(var c=new Array(arguments.length-1),o=0,r=2,i=!0;r<arguments.length;)c[o++]=arguments[r++];return new Promise(function(t,s){c[o]=function(a){if(i)if(i=!1,a)s(a);else{for(var d=new Array(arguments.length-1),y=0;y<d.length;)d[y++]=arguments[y];t.apply(null,d)}};try{n.apply(u||null,c)}catch(l){i&&(i=!1,s(l))}})}return aspromise}var base64={},hasRequiredBase64;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,function(f){var n=f;n.length=function(e){var t=e.length;if(!t)return 0;for(var s=0;--t%4>1&&e.charAt(t)==="=";)++s;return Math.ceil(e.length*3)/4-s};for(var u=new Array(64),c=new Array(123),o=0;o<64;)c[u[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;n.encode=function(e,t,s){for(var l=null,a=[],d=0,y=0,p;t<s;){var w=e[t++];switch(y){case 0:a[d++]=u[w>>2],p=(w&3)<<4,y=1;break;case 1:a[d++]=u[p|w>>4],p=(w&15)<<2,y=2;break;case 2:a[d++]=u[p|w>>6],a[d++]=u[w&63],y=0;break}d>8191&&((l||(l=[])).push(String.fromCharCode.apply(String,a)),d=0)}return y&&(a[d++]=u[p],a[d++]=61,y===1&&(a[d++]=61)),l?(d&&l.push(String.fromCharCode.apply(String,a.slice(0,d))),l.join("")):String.fromCharCode.apply(String,a.slice(0,d))};var r="invalid encoding";n.decode=function(e,t,s){for(var l=s,a=0,d,y=0;y<e.length;){var p=e.charCodeAt(y++);if(p===61&&a>1)break;if((p=c[p])===void 0)throw Error(r);switch(a){case 0:d=p,a=1;break;case 1:t[s++]=d<<2|(p&48)>>4,d=p,a=2;break;case 2:t[s++]=(d&15)<<4|(p&60)>>2,d=p,a=3;break;case 3:t[s++]=(d&3)<<6|p,a=0;break}}if(a===1)throw Error(r);return s-l},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}}(base64)),base64}var eventemitter,hasRequiredEventemitter;function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;hasRequiredEventemitter=1,eventemitter=f;function f(){this._listeners={}}return f.prototype.on=function(u,c,o){return(this._listeners[u]||(this._listeners[u]=[])).push({fn:c,ctx:o||this}),this},f.prototype.off=function(u,c){if(u===void 0)this._listeners={};else if(c===void 0)this._listeners[u]=[];else for(var o=this._listeners[u],r=0;r<o.length;)o[r].fn===c?o.splice(r,1):++r;return this},f.prototype.emit=function(u){var c=this._listeners[u];if(c){for(var o=[],r=1;r<arguments.length;)o.push(arguments[r++]);for(r=0;r<c.length;)c[r].fn.apply(c[r++].ctx,o)}return this},eventemitter}var float,hasRequiredFloat;function requireFloat(){if(hasRequiredFloat)return float;hasRequiredFloat=1,float=f(f);function f(r){return typeof Float32Array<"u"?function(){var i=new Float32Array([-0]),e=new Uint8Array(i.buffer),t=e[3]===128;function s(y,p,w){i[0]=y,p[w]=e[0],p[w+1]=e[1],p[w+2]=e[2],p[w+3]=e[3]}function l(y,p,w){i[0]=y,p[w]=e[3],p[w+1]=e[2],p[w+2]=e[1],p[w+3]=e[0]}r.writeFloatLE=t?s:l,r.writeFloatBE=t?l:s;function a(y,p){return e[0]=y[p],e[1]=y[p+1],e[2]=y[p+2],e[3]=y[p+3],i[0]}function d(y,p){return e[3]=y[p],e[2]=y[p+1],e[1]=y[p+2],e[0]=y[p+3],i[0]}r.readFloatLE=t?a:d,r.readFloatBE=t?d:a}():function(){function i(t,s,l,a){var d=s<0?1:0;if(d&&(s=-s),s===0)t(1/s>0?0:2147483648,l,a);else if(isNaN(s))t(2143289344,l,a);else if(s>34028234663852886e22)t((d<<31|2139095040)>>>0,l,a);else if(s<11754943508222875e-54)t((d<<31|Math.round(s/1401298464324817e-60))>>>0,l,a);else{var y=Math.floor(Math.log(s)/Math.LN2),p=Math.round(s*Math.pow(2,-y)*8388608)&8388607;t((d<<31|y+127<<23|p)>>>0,l,a)}}r.writeFloatLE=i.bind(null,n),r.writeFloatBE=i.bind(null,u);function e(t,s,l){var a=t(s,l),d=(a>>31)*2+1,y=a>>>23&255,p=a&8388607;return y===255?p?NaN:d*(1/0):y===0?d*1401298464324817e-60*p:d*Math.pow(2,y-150)*(p+8388608)}r.readFloatLE=e.bind(null,c),r.readFloatBE=e.bind(null,o)}(),typeof Float64Array<"u"?function(){var i=new Float64Array([-0]),e=new Uint8Array(i.buffer),t=e[7]===128;function s(y,p,w){i[0]=y,p[w]=e[0],p[w+1]=e[1],p[w+2]=e[2],p[w+3]=e[3],p[w+4]=e[4],p[w+5]=e[5],p[w+6]=e[6],p[w+7]=e[7]}function l(y,p,w){i[0]=y,p[w]=e[7],p[w+1]=e[6],p[w+2]=e[5],p[w+3]=e[4],p[w+4]=e[3],p[w+5]=e[2],p[w+6]=e[1],p[w+7]=e[0]}r.writeDoubleLE=t?s:l,r.writeDoubleBE=t?l:s;function a(y,p){return e[0]=y[p],e[1]=y[p+1],e[2]=y[p+2],e[3]=y[p+3],e[4]=y[p+4],e[5]=y[p+5],e[6]=y[p+6],e[7]=y[p+7],i[0]}function d(y,p){return e[7]=y[p],e[6]=y[p+1],e[5]=y[p+2],e[4]=y[p+3],e[3]=y[p+4],e[2]=y[p+5],e[1]=y[p+6],e[0]=y[p+7],i[0]}r.readDoubleLE=t?a:d,r.readDoubleBE=t?d:a}():function(){function i(t,s,l,a,d,y){var p=a<0?1:0;if(p&&(a=-a),a===0)t(0,d,y+s),t(1/a>0?0:2147483648,d,y+l);else if(isNaN(a))t(0,d,y+s),t(2146959360,d,y+l);else if(a>17976931348623157e292)t(0,d,y+s),t((p<<31|2146435072)>>>0,d,y+l);else{var w;if(a<22250738585072014e-324)w=a/5e-324,t(w>>>0,d,y+s),t((p<<31|w/4294967296)>>>0,d,y+l);else{var b=Math.floor(Math.log(a)/Math.LN2);b===1024&&(b=1023),w=a*Math.pow(2,-b),t(w*4503599627370496>>>0,d,y+s),t((p<<31|b+1023<<20|w*1048576&1048575)>>>0,d,y+l)}}}r.writeDoubleLE=i.bind(null,n,0,4),r.writeDoubleBE=i.bind(null,u,4,0);function e(t,s,l,a,d){var y=t(a,d+s),p=t(a,d+l),w=(p>>31)*2+1,b=p>>>20&2047,m=4294967296*(p&1048575)+y;return b===2047?m?NaN:w*(1/0):b===0?w*5e-324*m:w*Math.pow(2,b-1075)*(m+4503599627370496)}r.readDoubleLE=e.bind(null,c,0,4),r.readDoubleBE=e.bind(null,o,4,0)}(),r}function n(r,i,e){i[e]=r&255,i[e+1]=r>>>8&255,i[e+2]=r>>>16&255,i[e+3]=r>>>24}function u(r,i,e){i[e]=r>>>24,i[e+1]=r>>>16&255,i[e+2]=r>>>8&255,i[e+3]=r&255}function c(r,i){return(r[i]|r[i+1]<<8|r[i+2]<<16|r[i+3]<<24)>>>0}function o(r,i){return(r[i]<<24|r[i+1]<<16|r[i+2]<<8|r[i+3])>>>0}return float}var inquire_1,hasRequiredInquire;function requireInquire(){if(hasRequiredInquire)return inquire_1;hasRequiredInquire=1,inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(f){}return null}return inquire_1}var utf8={},hasRequiredUtf8;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,function(f){var n=f;n.length=function(c){for(var o=0,r=0,i=0;i<c.length;++i)r=c.charCodeAt(i),r<128?o+=1:r<2048?o+=2:(r&64512)===55296&&(c.charCodeAt(i+1)&64512)===56320?(++i,o+=4):o+=3;return o},n.read=function(c,o,r){var i=r-o;if(i<1)return"";for(var e=null,t=[],s=0,l;o<r;)l=c[o++],l<128?t[s++]=l:l>191&&l<224?t[s++]=(l&31)<<6|c[o++]&63:l>239&&l<365?(l=((l&7)<<18|(c[o++]&63)<<12|(c[o++]&63)<<6|c[o++]&63)-65536,t[s++]=55296+(l>>10),t[s++]=56320+(l&1023)):t[s++]=(l&15)<<12|(c[o++]&63)<<6|c[o++]&63,s>8191&&((e||(e=[])).push(String.fromCharCode.apply(String,t)),s=0);return e?(s&&e.push(String.fromCharCode.apply(String,t.slice(0,s))),e.join("")):String.fromCharCode.apply(String,t.slice(0,s))},n.write=function(c,o,r){for(var i=r,e,t,s=0;s<c.length;++s)e=c.charCodeAt(s),e<128?o[r++]=e:e<2048?(o[r++]=e>>6|192,o[r++]=e&63|128):(e&64512)===55296&&((t=c.charCodeAt(s+1))&64512)===56320?(e=65536+((e&1023)<<10)+(t&1023),++s,o[r++]=e>>18|240,o[r++]=e>>12&63|128,o[r++]=e>>6&63|128,o[r++]=e&63|128):(o[r++]=e>>12|224,o[r++]=e>>6&63|128,o[r++]=e&63|128);return r-i}}(utf8)),utf8}var pool_1,hasRequiredPool;function requirePool(){if(hasRequiredPool)return pool_1;hasRequiredPool=1,pool_1=f;function f(n,u,c){var o=c||8192,r=o>>>1,i=null,e=o;return function(s){if(s<1||s>r)return n(s);e+s>o&&(i=n(o),e=0);var l=u.call(i,e,e+=s);return e&7&&(e=(e|7)+1),l}}return pool_1}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=n;var f=requireMinimal$1();function n(r,i){this.lo=r>>>0,this.hi=i>>>0}var u=n.zero=new n(0,0);u.toNumber=function(){return 0},u.zzEncode=u.zzDecode=function(){return this},u.length=function(){return 1};var c=n.zeroHash="\0\0\0\0\0\0\0\0";n.fromNumber=function(i){if(i===0)return u;var e=i<0;e&&(i=-i);var t=i>>>0,s=(i-t)/4294967296>>>0;return e&&(s=~s>>>0,t=~t>>>0,++t>4294967295&&(t=0,++s>4294967295&&(s=0))),new n(t,s)},n.from=function(i){if(typeof i=="number")return n.fromNumber(i);if(f.isString(i))if(f.Long)i=f.Long.fromString(i);else return n.fromNumber(parseInt(i,10));return i.low||i.high?new n(i.low>>>0,i.high>>>0):u},n.prototype.toNumber=function(i){if(!i&&this.hi>>>31){var e=~this.lo+1>>>0,t=~this.hi>>>0;return e||(t=t+1>>>0),-(e+t*4294967296)}return this.lo+this.hi*4294967296},n.prototype.toLong=function(i){return f.Long?new f.Long(this.lo|0,this.hi|0,!!i):{low:this.lo|0,high:this.hi|0,unsigned:!!i}};var o=String.prototype.charCodeAt;return n.fromHash=function(i){return i===c?u:new n((o.call(i,0)|o.call(i,1)<<8|o.call(i,2)<<16|o.call(i,3)<<24)>>>0,(o.call(i,4)|o.call(i,5)<<8|o.call(i,6)<<16|o.call(i,7)<<24)>>>0)},n.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},n.prototype.zzEncode=function(){var i=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^i)>>>0,this.lo=(this.lo<<1^i)>>>0,this},n.prototype.zzDecode=function(){var i=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^i)>>>0,this.hi=(this.hi>>>1^i)>>>0,this},n.prototype.length=function(){var i=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,t=this.hi>>>24;return t===0?e===0?i<16384?i<128?1:2:i<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:t<128?9:10},longbits}var hasRequiredMinimal$1;function requireMinimal$1(){return hasRequiredMinimal$1||(hasRequiredMinimal$1=1,function(f){var n=f;n.asPromise=requireAspromise(),n.base64=requireBase64(),n.EventEmitter=requireEventemitter(),n.float=requireFloat(),n.inquire=requireInquire(),n.utf8=requireUtf8(),n.pool=requirePool(),n.LongBits=requireLongbits(),n.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),n.global=n.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||minimal$1,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r},n.isString=function(r){return typeof r=="string"||r instanceof String},n.isObject=function(r){return r&&typeof r=="object"},n.isset=n.isSet=function(r,i){var e=r[i];return e!=null&&r.hasOwnProperty(i)?typeof e!="object"||(Array.isArray(e)?e.length:Object.keys(e).length)>0:!1},n.Buffer=function(){try{var o=n.inquire("buffer").Buffer;return o.prototype.utf8Write?o:null}catch{return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(r){return typeof r=="number"?n.Buffer?n._Buffer_allocUnsafe(r):new n.Array(r):n.Buffer?n._Buffer_from(r):typeof Uint8Array>"u"?r:new Uint8Array(r)},n.Array=typeof Uint8Array<"u"?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(r){return r?n.LongBits.from(r).toHash():n.LongBits.zeroHash},n.longFromHash=function(r,i){var e=n.LongBits.fromHash(r);return n.Long?n.Long.fromBits(e.lo,e.hi,i):e.toNumber(!!i)};function u(o,r,i){for(var e=Object.keys(r),t=0;t<e.length;++t)(o[e[t]]===void 0||!i)&&(o[e[t]]=r[e[t]]);return o}n.merge=u,n.lcFirst=function(r){return r.charAt(0).toLowerCase()+r.substring(1)};function c(o){function r(i,e){if(!(this instanceof r))return new r(i,e);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,r):Object.defineProperty(this,"stack",{value:new Error().stack||""}),e&&u(this,e)}return r.prototype=Object.create(Error.prototype,{constructor:{value:r,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return o},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),r}n.newError=c,n.ProtocolError=c("ProtocolError"),n.oneOfGetter=function(r){for(var i={},e=0;e<r.length;++e)i[r[e]]=1;return function(){for(var t=Object.keys(this),s=t.length-1;s>-1;--s)if(i[t[s]]===1&&this[t[s]]!==void 0&&this[t[s]]!==null)return t[s]}},n.oneOfSetter=function(r){return function(i){for(var e=0;e<r.length;++e)r[e]!==i&&delete this[r[e]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var o=n.Buffer;if(!o){n._Buffer_from=n._Buffer_allocUnsafe=null;return}n._Buffer_from=o.from!==Uint8Array.from&&o.from||function(i,e){return new o(i,e)},n._Buffer_allocUnsafe=o.allocUnsafe||function(i){return new o(i)}}}(minimal$1)),minimal$1}var writer,hasRequiredWriter;function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=t;var f=requireMinimal$1(),n,u=f.LongBits,c=f.base64,o=f.utf8;function r(b,m,g){this.fn=b,this.len=m,this.next=void 0,this.val=g}function i(){}function e(b){this.head=b.head,this.tail=b.tail,this.len=b.len,this.next=b.states}function t(){this.len=0,this.head=new r(i,0,0),this.tail=this.head,this.states=null}var s=function(){return f.Buffer?function(){return(t.create=function(){return new n})()}:function(){return new t}};t.create=s(),t.alloc=function(m){return new f.Array(m)},f.Array!==Array&&(t.alloc=f.pool(t.alloc,f.Array.prototype.subarray)),t.prototype._push=function(m,g,x){return this.tail=this.tail.next=new r(m,g,x),this.len+=g,this};function l(b,m,g){m[g]=b&255}function a(b,m,g){for(;b>127;)m[g++]=b&127|128,b>>>=7;m[g]=b}function d(b,m){this.len=b,this.next=void 0,this.val=m}d.prototype=Object.create(r.prototype),d.prototype.fn=a,t.prototype.uint32=function(m){return this.len+=(this.tail=this.tail.next=new d((m=m>>>0)<128?1:m<16384?2:m<2097152?3:m<268435456?4:5,m)).len,this},t.prototype.int32=function(m){return m<0?this._push(y,10,u.fromNumber(m)):this.uint32(m)},t.prototype.sint32=function(m){return this.uint32((m<<1^m>>31)>>>0)};function y(b,m,g){for(;b.hi;)m[g++]=b.lo&127|128,b.lo=(b.lo>>>7|b.hi<<25)>>>0,b.hi>>>=7;for(;b.lo>127;)m[g++]=b.lo&127|128,b.lo=b.lo>>>7;m[g++]=b.lo}t.prototype.uint64=function(m){var g=u.from(m);return this._push(y,g.length(),g)},t.prototype.int64=t.prototype.uint64,t.prototype.sint64=function(m){var g=u.from(m).zzEncode();return this._push(y,g.length(),g)},t.prototype.bool=function(m){return this._push(l,1,m?1:0)};function p(b,m,g){m[g]=b&255,m[g+1]=b>>>8&255,m[g+2]=b>>>16&255,m[g+3]=b>>>24}t.prototype.fixed32=function(m){return this._push(p,4,m>>>0)},t.prototype.sfixed32=t.prototype.fixed32,t.prototype.fixed64=function(m){var g=u.from(m);return this._push(p,4,g.lo)._push(p,4,g.hi)},t.prototype.sfixed64=t.prototype.fixed64,t.prototype.float=function(m){return this._push(f.float.writeFloatLE,4,m)},t.prototype.double=function(m){return this._push(f.float.writeDoubleLE,8,m)};var w=f.Array.prototype.set?function(m,g,x){g.set(m,x)}:function(m,g,x){for(var I=0;I<m.length;++I)g[x+I]=m[I]};return t.prototype.bytes=function(m){var g=m.length>>>0;if(!g)return this._push(l,1,0);if(f.isString(m)){var x=t.alloc(g=c.length(m));c.decode(m,x,0),m=x}return this.uint32(g)._push(w,g,m)},t.prototype.string=function(m){var g=o.length(m);return g?this.uint32(g)._push(o.write,g,m):this._push(l,1,0)},t.prototype.fork=function(){return this.states=new e(this),this.head=this.tail=new r(i,0,0),this.len=0,this},t.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new r(i,0,0),this.len=0),this},t.prototype.ldelim=function(){var m=this.head,g=this.tail,x=this.len;return this.reset().uint32(x),x&&(this.tail.next=m.next,this.tail=g,this.len+=x),this},t.prototype.finish=function(){for(var m=this.head.next,g=this.constructor.alloc(this.len),x=0;m;)m.fn(m.val,g,x),x+=m.len,m=m.next;return g},t._configure=function(b){n=b,t.create=s(),n._configure()},writer}var writer_buffer,hasRequiredWriter_buffer;function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=u;var f=requireWriter();(u.prototype=Object.create(f.prototype)).constructor=u;var n=requireMinimal$1();function u(){f.call(this)}u._configure=function(){u.alloc=n._Buffer_allocUnsafe,u.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&n.Buffer.prototype.set.name==="set"?function(r,i,e){i.set(r,e)}:function(r,i,e){if(r.copy)r.copy(i,e,0,r.length);else for(var t=0;t<r.length;)i[e++]=r[t++]}},u.prototype.bytes=function(r){n.isString(r)&&(r=n._Buffer_from(r,"base64"));var i=r.length>>>0;return this.uint32(i),i&&this._push(u.writeBytesBuffer,i,r),this};function c(o,r,i){o.length<40?n.utf8.write(o,r,i):r.utf8Write?r.utf8Write(o,i):r.write(o,i)}return u.prototype.string=function(r){var i=n.Buffer.byteLength(r);return this.uint32(i),i&&this._push(c,i,r),this},u._configure(),writer_buffer}var reader,hasRequiredReader;function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=r;var f=requireMinimal$1(),n,u=f.LongBits,c=f.utf8;function o(a,d){return RangeError("index out of range: "+a.pos+" + "+(d||1)+" > "+a.len)}function r(a){this.buf=a,this.pos=0,this.len=a.length}var i=typeof Uint8Array<"u"?function(d){if(d instanceof Uint8Array||Array.isArray(d))return new r(d);throw Error("illegal buffer")}:function(d){if(Array.isArray(d))return new r(d);throw Error("illegal buffer")},e=function(){return f.Buffer?function(y){return(r.create=function(w){return f.Buffer.isBuffer(w)?new n(w):i(w)})(y)}:i};r.create=e(),r.prototype._slice=f.Array.prototype.subarray||f.Array.prototype.slice,r.prototype.uint32=function(){var d=4294967295;return function(){if(d=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(d=(d|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return d;if((this.pos+=5)>this.len)throw this.pos=this.len,o(this,10);return d}}(),r.prototype.int32=function(){return this.uint32()|0},r.prototype.sint32=function(){var d=this.uint32();return d>>>1^-(d&1)|0};function t(){var a=new u(0,0),d=0;if(this.len-this.pos>4){for(;d<4;++d)if(a.lo=(a.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return a;if(a.lo=(a.lo|(this.buf[this.pos]&127)<<28)>>>0,a.hi=(a.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return a;d=0}else{for(;d<3;++d){if(this.pos>=this.len)throw o(this);if(a.lo=(a.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return a}return a.lo=(a.lo|(this.buf[this.pos++]&127)<<d*7)>>>0,a}if(this.len-this.pos>4){for(;d<5;++d)if(a.hi=(a.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return a}else for(;d<5;++d){if(this.pos>=this.len)throw o(this);if(a.hi=(a.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return a}throw Error("invalid varint encoding")}r.prototype.bool=function(){return this.uint32()!==0};function s(a,d){return(a[d-4]|a[d-3]<<8|a[d-2]<<16|a[d-1]<<24)>>>0}r.prototype.fixed32=function(){if(this.pos+4>this.len)throw o(this,4);return s(this.buf,this.pos+=4)},r.prototype.sfixed32=function(){if(this.pos+4>this.len)throw o(this,4);return s(this.buf,this.pos+=4)|0};function l(){if(this.pos+8>this.len)throw o(this,8);return new u(s(this.buf,this.pos+=4),s(this.buf,this.pos+=4))}return r.prototype.float=function(){if(this.pos+4>this.len)throw o(this,4);var d=f.float.readFloatLE(this.buf,this.pos);return this.pos+=4,d},r.prototype.double=function(){if(this.pos+8>this.len)throw o(this,4);var d=f.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,d},r.prototype.bytes=function(){var d=this.uint32(),y=this.pos,p=this.pos+d;if(p>this.len)throw o(this,d);if(this.pos+=d,Array.isArray(this.buf))return this.buf.slice(y,p);if(y===p){var w=f.Buffer;return w?w.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,y,p)},r.prototype.string=function(){var d=this.bytes();return c.read(d,0,d.length)},r.prototype.skip=function(d){if(typeof d=="number"){if(this.pos+d>this.len)throw o(this,d);this.pos+=d}else do if(this.pos>=this.len)throw o(this);while(this.buf[this.pos++]&128);return this},r.prototype.skipType=function(a){switch(a){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(a=this.uint32()&7)!==4;)this.skipType(a);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+a+" at offset "+this.pos)}return this},r._configure=function(a){n=a,r.create=e(),n._configure();var d=f.Long?"toLong":"toNumber";f.merge(r.prototype,{int64:function(){return t.call(this)[d](!1)},uint64:function(){return t.call(this)[d](!0)},sint64:function(){return t.call(this).zzDecode()[d](!1)},fixed64:function(){return l.call(this)[d](!0)},sfixed64:function(){return l.call(this)[d](!1)}})},reader}var reader_buffer,hasRequiredReader_buffer;function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=u;var f=requireReader();(u.prototype=Object.create(f.prototype)).constructor=u;var n=requireMinimal$1();function u(c){f.call(this,c)}return u._configure=function(){n.Buffer&&(u.prototype._slice=n.Buffer.prototype.slice)},u.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))},u._configure(),reader_buffer}var rpc={},service,hasRequiredService;function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=n;var f=requireMinimal$1();(n.prototype=Object.create(f.EventEmitter.prototype)).constructor=n;function n(u,c,o){if(typeof u!="function")throw TypeError("rpcImpl must be a function");f.EventEmitter.call(this),this.rpcImpl=u,this.requestDelimited=!!c,this.responseDelimited=!!o}return n.prototype.rpcCall=function u(c,o,r,i,e){if(!i)throw TypeError("request must be specified");var t=this;if(!e)return f.asPromise(u,t,c,o,r,i);if(!t.rpcImpl){setTimeout(function(){e(Error("already ended"))},0);return}try{return t.rpcImpl(c,o[t.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(l,a){if(l)return t.emit("error",l,c),e(l);if(a===null){t.end(!0);return}if(!(a instanceof r))try{a=r[t.responseDelimited?"decodeDelimited":"decode"](a)}catch(d){return t.emit("error",d,c),e(d)}return t.emit("data",a,c),e(null,a)})}catch(s){t.emit("error",s,c),setTimeout(function(){e(s)},0);return}},n.prototype.end=function(c){return this.rpcImpl&&(c||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service}var hasRequiredRpc;function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,function(f){var n=f;n.Service=requireService()}(rpc)),rpc}var roots,hasRequiredRoots;function requireRoots(){return hasRequiredRoots||(hasRequiredRoots=1,roots={}),roots}var hasRequiredIndexMinimal;function requireIndexMinimal(){return hasRequiredIndexMinimal||(hasRequiredIndexMinimal=1,function(f){var n=f;n.build="minimal",n.Writer=requireWriter(),n.BufferWriter=requireWriter_buffer(),n.Reader=requireReader(),n.BufferReader=requireReader_buffer(),n.util=requireMinimal$1(),n.rpc=requireRpc(),n.roots=requireRoots(),n.configure=u;function u(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}u()}(indexMinimal)),indexMinimal}var minimal,hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,minimal=requireIndexMinimal()),minimal}var minimalExports=requireMinimal();const $Reader=minimalExports.Reader,$Writer=minimalExports.Writer,$util=minimalExports.util,$root=minimalExports.roots.default||(minimalExports.roots.default={}),com=$root.com=(()=>{const f={};return f.quick=function(){const n={};return n.voice=function(){const u={};return u.proto=function(){const c={};return c.SeiData=function(){function o(r){if(r)for(let i=Object.keys(r),e=0;e<i.length;++e)r[i[e]]!=null&&(this[i[e]]=r[i[e]])}return o.prototype.event=0,o.prototype.data=$util.newBuffer([]),o.prototype.compress=!1,o.prototype.version=0,o.create=function(i){return new o(i)},o.encode=function(i,e){return e||(e=$Writer.create()),i.event!=null&&Object.hasOwnProperty.call(i,"event")&&e.uint32(8).int32(i.event),i.data!=null&&Object.hasOwnProperty.call(i,"data")&&e.uint32(18).bytes(i.data),i.compress!=null&&Object.hasOwnProperty.call(i,"compress")&&e.uint32(24).bool(i.compress),i.version!=null&&Object.hasOwnProperty.call(i,"version")&&e.uint32(32).int32(i.version),e},o.encodeDelimited=function(i,e){return this.encode(i,e).ldelim()},o.decode=function(i,e,t){i instanceof $Reader||(i=$Reader.create(i));let s=e===void 0?i.len:i.pos+e,l=new $root.com.quick.voice.proto.SeiData;for(;i.pos<s;){let a=i.uint32();if(a===t)break;switch(a>>>3){case 1:{l.event=i.int32();break}case 2:{l.data=i.bytes();break}case 3:{l.compress=i.bool();break}case 4:{l.version=i.int32();break}default:i.skipType(a&7);break}}return l},o.decodeDelimited=function(i){return i instanceof $Reader||(i=new $Reader(i)),this.decode(i,i.uint32())},o.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.event!=null&&i.hasOwnProperty("event"))switch(i.event){default:return"event: enum value expected";case 0:case 1:break}return i.data!=null&&i.hasOwnProperty("data")&&!(i.data&&typeof i.data.length=="number"||$util.isString(i.data))?"data: buffer expected":i.compress!=null&&i.hasOwnProperty("compress")&&typeof i.compress!="boolean"?"compress: boolean expected":i.version!=null&&i.hasOwnProperty("version")&&!$util.isInteger(i.version)?"version: integer expected":null},o.fromObject=function(i){if(i instanceof $root.com.quick.voice.proto.SeiData)return i;let e=new $root.com.quick.voice.proto.SeiData;switch(i.event){default:if(typeof i.event=="number"){e.event=i.event;break}break;case"Layout":case 0:e.event=0;break;case"Custom":case 1:e.event=1;break}return i.data!=null&&(typeof i.data=="string"?$util.base64.decode(i.data,e.data=$util.newBuffer($util.base64.length(i.data)),0):i.data.length>=0&&(e.data=i.data)),i.compress!=null&&(e.compress=!!i.compress),i.version!=null&&(e.version=i.version|0),e},o.toObject=function(i,e){e||(e={});let t={};return e.defaults&&(t.event=e.enums===String?"Layout":0,e.bytes===String?t.data="":(t.data=[],e.bytes!==Array&&(t.data=$util.newBuffer(t.data))),t.compress=!1,t.version=0),i.event!=null&&i.hasOwnProperty("event")&&(t.event=e.enums===String?$root.com.quick.voice.proto.EventType[i.event]===void 0?i.event:$root.com.quick.voice.proto.EventType[i.event]:i.event),i.data!=null&&i.hasOwnProperty("data")&&(t.data=e.bytes===String?$util.base64.encode(i.data,0,i.data.length):e.bytes===Array?Array.prototype.slice.call(i.data):i.data),i.compress!=null&&i.hasOwnProperty("compress")&&(t.compress=i.compress),i.version!=null&&i.hasOwnProperty("version")&&(t.version=i.version),t},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/com.quick.voice.proto.SeiData"},o}(),c.EventType=function(){const o={},r=Object.create(o);return r[o[0]="Layout"]=0,r[o[1]="Custom"]=1,r}(),c.LayoutData=function(){function o(i){if(this.userMap={},i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.roomId="",o.prototype.type=0,o.prototype.userMap=$util.emptyObject,o.prototype.globalCustom=null;let r;return Object.defineProperty(o.prototype,"_globalCustom",{get:$util.oneOfGetter(r=["globalCustom"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){if(t||(t=$Writer.create()),e.roomId!=null&&Object.hasOwnProperty.call(e,"roomId")&&t.uint32(10).string(e.roomId),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(16).int32(e.type),e.userMap!=null&&Object.hasOwnProperty.call(e,"userMap"))for(let s=Object.keys(e.userMap),l=0;l<s.length;++l)t.uint32(26).fork().uint32(10).string(s[l]),$root.com.quick.voice.proto.UserInfo.encode(e.userMap[s[l]],t.uint32(18).fork()).ldelim().ldelim();return e.globalCustom!=null&&Object.hasOwnProperty.call(e,"globalCustom")&&$root.com.quick.voice.proto.CustomInfo.encode(e.globalCustom,t.uint32(34).fork()).ldelim(),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.LayoutData,d,y;for(;e.pos<l;){let p=e.uint32();if(p===s)break;switch(p>>>3){case 1:{a.roomId=e.string();break}case 2:{a.type=e.int32();break}case 3:{a.userMap===$util.emptyObject&&(a.userMap={});let w=e.uint32()+e.pos;for(d="",y=null;e.pos<w;){let b=e.uint32();switch(b>>>3){case 1:d=e.string();break;case 2:y=$root.com.quick.voice.proto.UserInfo.decode(e,e.uint32());break;default:e.skipType(b&7);break}}a.userMap[d]=y;break}case 4:{a.globalCustom=$root.com.quick.voice.proto.CustomInfo.decode(e,e.uint32());break}default:e.skipType(p&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.roomId!=null&&e.hasOwnProperty("roomId")&&!$util.isString(e.roomId))return"roomId: string expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:case 2:break}if(e.userMap!=null&&e.hasOwnProperty("userMap")){if(!$util.isObject(e.userMap))return"userMap: object expected";let t=Object.keys(e.userMap);for(let s=0;s<t.length;++s){let l=$root.com.quick.voice.proto.UserInfo.verify(e.userMap[t[s]]);if(l)return"userMap."+l}}if(e.globalCustom!=null&&e.hasOwnProperty("globalCustom")){let t=$root.com.quick.voice.proto.CustomInfo.verify(e.globalCustom);if(t)return"globalCustom."+t}return null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.LayoutData)return e;let t=new $root.com.quick.voice.proto.LayoutData;switch(e.roomId!=null&&(t.roomId=String(e.roomId)),e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"AudioAndVideo":case 0:t.type=0;break;case"OnlyAudio":case 1:t.type=1;break;case"OnlyVideo":case 2:t.type=2;break}if(e.userMap){if(typeof e.userMap!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");t.userMap={};for(let s=Object.keys(e.userMap),l=0;l<s.length;++l){if(typeof e.userMap[s[l]]!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");t.userMap[s[l]]=$root.com.quick.voice.proto.UserInfo.fromObject(e.userMap[s[l]])}}if(e.globalCustom!=null){if(typeof e.globalCustom!="object")throw TypeError(".com.quick.voice.proto.LayoutData.globalCustom: object expected");t.globalCustom=$root.com.quick.voice.proto.CustomInfo.fromObject(e.globalCustom)}return t},o.toObject=function(e,t){t||(t={});let s={};(t.objects||t.defaults)&&(s.userMap={}),t.defaults&&(s.roomId="",s.type=t.enums===String?"AudioAndVideo":0),e.roomId!=null&&e.hasOwnProperty("roomId")&&(s.roomId=e.roomId),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.LayoutType[e.type]===void 0?e.type:$root.com.quick.voice.proto.LayoutType[e.type]:e.type);let l;if(e.userMap&&(l=Object.keys(e.userMap)).length){s.userMap={};for(let a=0;a<l.length;++a)s.userMap[l[a]]=$root.com.quick.voice.proto.UserInfo.toObject(e.userMap[l[a]],t)}return e.globalCustom!=null&&e.hasOwnProperty("globalCustom")&&(s.globalCustom=$root.com.quick.voice.proto.CustomInfo.toObject(e.globalCustom,t),t.oneofs&&(s._globalCustom="globalCustom")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.LayoutData"},o}(),c.UserInfo=function(){function o(i){if(this.audios=[],this.videos=[],i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.id="",o.prototype.audios=$util.emptyArray,o.prototype.videos=$util.emptyArray,o.prototype.custom=null;let r;return Object.defineProperty(o.prototype,"_custom",{get:$util.oneOfGetter(r=["custom"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){if(t||(t=$Writer.create()),e.id!=null&&Object.hasOwnProperty.call(e,"id")&&t.uint32(10).string(e.id),e.audios!=null&&e.audios.length)for(let s=0;s<e.audios.length;++s)$root.com.quick.voice.proto.AudioInfo.encode(e.audios[s],t.uint32(18).fork()).ldelim();if(e.videos!=null&&e.videos.length)for(let s=0;s<e.videos.length;++s)$root.com.quick.voice.proto.VideoInfo.encode(e.videos[s],t.uint32(26).fork()).ldelim();return e.custom!=null&&Object.hasOwnProperty.call(e,"custom")&&$root.com.quick.voice.proto.CustomInfo.encode(e.custom,t.uint32(34).fork()).ldelim(),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.UserInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{a.id=e.string();break}case 2:{a.audios&&a.audios.length||(a.audios=[]),a.audios.push($root.com.quick.voice.proto.AudioInfo.decode(e,e.uint32()));break}case 3:{a.videos&&a.videos.length||(a.videos=[]),a.videos.push($root.com.quick.voice.proto.VideoInfo.decode(e,e.uint32()));break}case 4:{a.custom=$root.com.quick.voice.proto.CustomInfo.decode(e,e.uint32());break}default:e.skipType(d&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.id!=null&&e.hasOwnProperty("id")&&!$util.isString(e.id))return"id: string expected";if(e.audios!=null&&e.hasOwnProperty("audios")){if(!Array.isArray(e.audios))return"audios: array expected";for(let t=0;t<e.audios.length;++t){let s=$root.com.quick.voice.proto.AudioInfo.verify(e.audios[t]);if(s)return"audios."+s}}if(e.videos!=null&&e.hasOwnProperty("videos")){if(!Array.isArray(e.videos))return"videos: array expected";for(let t=0;t<e.videos.length;++t){let s=$root.com.quick.voice.proto.VideoInfo.verify(e.videos[t]);if(s)return"videos."+s}}if(e.custom!=null&&e.hasOwnProperty("custom")){let t=$root.com.quick.voice.proto.CustomInfo.verify(e.custom);if(t)return"custom."+t}return null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.UserInfo)return e;let t=new $root.com.quick.voice.proto.UserInfo;if(e.id!=null&&(t.id=String(e.id)),e.audios){if(!Array.isArray(e.audios))throw TypeError(".com.quick.voice.proto.UserInfo.audios: array expected");t.audios=[];for(let s=0;s<e.audios.length;++s){if(typeof e.audios[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.audios: object expected");t.audios[s]=$root.com.quick.voice.proto.AudioInfo.fromObject(e.audios[s])}}if(e.videos){if(!Array.isArray(e.videos))throw TypeError(".com.quick.voice.proto.UserInfo.videos: array expected");t.videos=[];for(let s=0;s<e.videos.length;++s){if(typeof e.videos[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.videos: object expected");t.videos[s]=$root.com.quick.voice.proto.VideoInfo.fromObject(e.videos[s])}}if(e.custom!=null){if(typeof e.custom!="object")throw TypeError(".com.quick.voice.proto.UserInfo.custom: object expected");t.custom=$root.com.quick.voice.proto.CustomInfo.fromObject(e.custom)}return t},o.toObject=function(e,t){t||(t={});let s={};if((t.arrays||t.defaults)&&(s.audios=[],s.videos=[]),t.defaults&&(s.id=""),e.id!=null&&e.hasOwnProperty("id")&&(s.id=e.id),e.audios&&e.audios.length){s.audios=[];for(let l=0;l<e.audios.length;++l)s.audios[l]=$root.com.quick.voice.proto.AudioInfo.toObject(e.audios[l],t)}if(e.videos&&e.videos.length){s.videos=[];for(let l=0;l<e.videos.length;++l)s.videos[l]=$root.com.quick.voice.proto.VideoInfo.toObject(e.videos[l],t)}return e.custom!=null&&e.hasOwnProperty("custom")&&(s.custom=$root.com.quick.voice.proto.CustomInfo.toObject(e.custom,t),t.oneofs&&(s._custom="custom")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.UserInfo"},o}(),c.AudioInfo=function(){function o(i){if(i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.type=0,o.prototype.isEnable=!1,o.prototype.isMute=!1,o.prototype.volume=0,o.prototype.updateTime=null;let r;return Object.defineProperty(o.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=$Writer.create()),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),e.isEnable!=null&&Object.hasOwnProperty.call(e,"isEnable")&&t.uint32(16).bool(e.isEnable),e.isMute!=null&&Object.hasOwnProperty.call(e,"isMute")&&t.uint32(24).bool(e.isMute),e.volume!=null&&Object.hasOwnProperty.call(e,"volume")&&t.uint32(33).double(e.volume),e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(40).int64(e.updateTime),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.AudioInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{a.type=e.int32();break}case 2:{a.isEnable=e.bool();break}case 3:{a.isMute=e.bool();break}case 4:{a.volume=e.double();break}case 5:{a.updateTime=e.int64();break}default:e.skipType(d&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:break}return e.isEnable!=null&&e.hasOwnProperty("isEnable")&&typeof e.isEnable!="boolean"?"isEnable: boolean expected":e.isMute!=null&&e.hasOwnProperty("isMute")&&typeof e.isMute!="boolean"?"isMute: boolean expected":e.volume!=null&&e.hasOwnProperty("volume")&&typeof e.volume!="number"?"volume: number expected":e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.AudioInfo)return e;let t=new $root.com.quick.voice.proto.AudioInfo;switch(e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"Microphone":case 0:t.type=0;break;case"SystemVoice":case 1:t.type=1;break}return e.isEnable!=null&&(t.isEnable=!!e.isEnable),e.isMute!=null&&(t.isMute=!!e.isMute),e.volume!=null&&(t.volume=Number(e.volume)),e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},o.toObject=function(e,t){t||(t={});let s={};return t.defaults&&(s.type=t.enums===String?"Microphone":0,s.isEnable=!1,s.isMute=!1,s.volume=0),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.AudioType[e.type]===void 0?e.type:$root.com.quick.voice.proto.AudioType[e.type]:e.type),e.isEnable!=null&&e.hasOwnProperty("isEnable")&&(s.isEnable=e.isEnable),e.isMute!=null&&e.hasOwnProperty("isMute")&&(s.isMute=e.isMute),e.volume!=null&&e.hasOwnProperty("volume")&&(s.volume=t.json&&!isFinite(e.volume)?String(e.volume):e.volume),e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.AudioInfo"},o}(),c.VideoInfo=function(){function o(i){if(i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.type=0,o.prototype.isEnable=!1,o.prototype.isMute=!1,o.prototype.width=0,o.prototype.height=0,o.prototype.x=0,o.prototype.y=0,o.prototype.updateTime=null;let r;return Object.defineProperty(o.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=$Writer.create()),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),e.isEnable!=null&&Object.hasOwnProperty.call(e,"isEnable")&&t.uint32(16).bool(e.isEnable),e.isMute!=null&&Object.hasOwnProperty.call(e,"isMute")&&t.uint32(24).bool(e.isMute),e.width!=null&&Object.hasOwnProperty.call(e,"width")&&t.uint32(32).int32(e.width),e.height!=null&&Object.hasOwnProperty.call(e,"height")&&t.uint32(40).int32(e.height),e.x!=null&&Object.hasOwnProperty.call(e,"x")&&t.uint32(48).int32(e.x),e.y!=null&&Object.hasOwnProperty.call(e,"y")&&t.uint32(56).int32(e.y),e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(64).int64(e.updateTime),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.VideoInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{a.type=e.int32();break}case 2:{a.isEnable=e.bool();break}case 3:{a.isMute=e.bool();break}case 4:{a.width=e.int32();break}case 5:{a.height=e.int32();break}case 6:{a.x=e.int32();break}case 7:{a.y=e.int32();break}case 8:{a.updateTime=e.int64();break}default:e.skipType(d&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:break}return e.isEnable!=null&&e.hasOwnProperty("isEnable")&&typeof e.isEnable!="boolean"?"isEnable: boolean expected":e.isMute!=null&&e.hasOwnProperty("isMute")&&typeof e.isMute!="boolean"?"isMute: boolean expected":e.width!=null&&e.hasOwnProperty("width")&&!$util.isInteger(e.width)?"width: integer expected":e.height!=null&&e.hasOwnProperty("height")&&!$util.isInteger(e.height)?"height: integer expected":e.x!=null&&e.hasOwnProperty("x")&&!$util.isInteger(e.x)?"x: integer expected":e.y!=null&&e.hasOwnProperty("y")&&!$util.isInteger(e.y)?"y: integer expected":e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.VideoInfo)return e;let t=new $root.com.quick.voice.proto.VideoInfo;switch(e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"Camera":case 0:t.type=0;break;case"Screen":case 1:t.type=1;break}return e.isEnable!=null&&(t.isEnable=!!e.isEnable),e.isMute!=null&&(t.isMute=!!e.isMute),e.width!=null&&(t.width=e.width|0),e.height!=null&&(t.height=e.height|0),e.x!=null&&(t.x=e.x|0),e.y!=null&&(t.y=e.y|0),e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},o.toObject=function(e,t){t||(t={});let s={};return t.defaults&&(s.type=t.enums===String?"Camera":0,s.isEnable=!1,s.isMute=!1,s.width=0,s.height=0,s.x=0,s.y=0),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.VideoType[e.type]===void 0?e.type:$root.com.quick.voice.proto.VideoType[e.type]:e.type),e.isEnable!=null&&e.hasOwnProperty("isEnable")&&(s.isEnable=e.isEnable),e.isMute!=null&&e.hasOwnProperty("isMute")&&(s.isMute=e.isMute),e.width!=null&&e.hasOwnProperty("width")&&(s.width=e.width),e.height!=null&&e.hasOwnProperty("height")&&(s.height=e.height),e.x!=null&&e.hasOwnProperty("x")&&(s.x=e.x),e.y!=null&&e.hasOwnProperty("y")&&(s.y=e.y),e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.VideoInfo"},o}(),c.CustomInfo=function(){function o(i){if(this.customKeyMap={},i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.roomId="",o.prototype.customKeyMap=$util.emptyObject,o.prototype.updateTime=null;let r;return Object.defineProperty(o.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){if(t||(t=$Writer.create()),e.roomId!=null&&Object.hasOwnProperty.call(e,"roomId")&&t.uint32(10).string(e.roomId),e.customKeyMap!=null&&Object.hasOwnProperty.call(e,"customKeyMap"))for(let s=Object.keys(e.customKeyMap),l=0;l<s.length;++l)t.uint32(18).fork().uint32(10).string(s[l]).uint32(18).string(e.customKeyMap[s[l]]).ldelim();return e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(24).int64(e.updateTime),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.CustomInfo,d,y;for(;e.pos<l;){let p=e.uint32();if(p===s)break;switch(p>>>3){case 1:{a.roomId=e.string();break}case 2:{a.customKeyMap===$util.emptyObject&&(a.customKeyMap={});let w=e.uint32()+e.pos;for(d="",y="";e.pos<w;){let b=e.uint32();switch(b>>>3){case 1:d=e.string();break;case 2:y=e.string();break;default:e.skipType(b&7);break}}a.customKeyMap[d]=y;break}case 3:{a.updateTime=e.int64();break}default:e.skipType(p&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.roomId!=null&&e.hasOwnProperty("roomId")&&!$util.isString(e.roomId))return"roomId: string expected";if(e.customKeyMap!=null&&e.hasOwnProperty("customKeyMap")){if(!$util.isObject(e.customKeyMap))return"customKeyMap: object expected";let t=Object.keys(e.customKeyMap);for(let s=0;s<t.length;++s)if(!$util.isString(e.customKeyMap[t[s]]))return"customKeyMap: string{k:string} expected"}return e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.CustomInfo)return e;let t=new $root.com.quick.voice.proto.CustomInfo;if(e.roomId!=null&&(t.roomId=String(e.roomId)),e.customKeyMap){if(typeof e.customKeyMap!="object")throw TypeError(".com.quick.voice.proto.CustomInfo.customKeyMap: object expected");t.customKeyMap={};for(let s=Object.keys(e.customKeyMap),l=0;l<s.length;++l)t.customKeyMap[s[l]]=String(e.customKeyMap[s[l]])}return e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},o.toObject=function(e,t){t||(t={});let s={};(t.objects||t.defaults)&&(s.customKeyMap={}),t.defaults&&(s.roomId=""),e.roomId!=null&&e.hasOwnProperty("roomId")&&(s.roomId=e.roomId);let l;if(e.customKeyMap&&(l=Object.keys(e.customKeyMap)).length){s.customKeyMap={};for(let a=0;a<l.length;++a)s.customKeyMap[l[a]]=e.customKeyMap[l[a]]}return e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.CustomInfo"},o}(),c.LayoutType=function(){const o={},r=Object.create(o);return r[o[0]="AudioAndVideo"]=0,r[o[1]="OnlyAudio"]=1,r[o[2]="OnlyVideo"]=2,r}(),c.AudioType=function(){const o={},r=Object.create(o);return r[o[0]="Microphone"]=0,r[o[1]="SystemVoice"]=1,r}(),c.VideoType=function(){const o={},r=Object.create(o);return r[o[0]="Camera"]=0,r[o[1]="Screen"]=1,r}(),c}(),u}(),n}(),f})(),createAudioInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,volume:0}),createVideoInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,sx:0,sy:0,sw:0,sh:0});class RoomUser{constructor(){v(this,"userId","");v(this,"mc_audio");v(this,"mc_video");v(this,"ss_audio");v(this,"ss_video");v(this,"updateTime",0);v(this,"getUpdateTimeKey",()=>{const n=[];return this.mc_audio&&n.push(this.mc_audio.updateTime),this.mc_video&&n.push(this.mc_video.updateTime),this.ss_audio&&n.push(this.ss_audio.updateTime),this.ss_video&&n.push(this.ss_video.updateTime),n.join("_")});v(this,"init",n=>{var e,t,s,l;const{id:u,audios:c=[],videos:o=[]}=n;this.userId=u;const r=this.getUpdateTimeKey();this.mc_audio&&(this.mc_audio.remove=!0),this.mc_video&&(this.mc_video.remove=!0),this.ss_audio&&(this.ss_audio.remove=!0),this.ss_video&&(this.ss_video.remove=!0);for(const a of c){const{type:d=0,isEnable:y=!1,isMute:p=!1,updateTime:w,volume:b=0}=a;switch(d){case 0:{if(this.mc_audio||(this.mc_audio=createAudioInfo()),this.mc_audio.remove=!1,this.mc_audio.updateTime===w)break;this.mc_audio.isEnable=!!y,this.mc_audio.isMute=!!p,this.mc_audio.updateTime=Number(w),this.mc_audio.volume=Number(b)}break;case 1:{if(this.ss_audio||(this.ss_audio=createAudioInfo()),this.ss_audio.remove=!1,this.ss_audio.updateTime===w)break;this.ss_audio.isEnable=!!y,this.ss_audio.isMute=!!p,this.ss_audio.updateTime=Number(w),this.ss_audio.volume=Number(b)}break}}for(const a of o){const{type:d=0,isEnable:y,isMute:p,updateTime:w,width:b,height:m,x:g,y:x}=a;switch(d){case 0:{if(this.mc_video||(this.mc_video=createVideoInfo()),this.mc_video.remove=!1,this.mc_video.updateTime===w)break;this.mc_video.isEnable=!!y,this.mc_video.isMute=!!p,this.mc_video.updateTime=Number(w)||0,this.mc_video.sx=g||0,this.mc_video.sy=x||0,this.mc_video.sw=b||0,this.mc_video.sh=m||0}break;case 1:{if(this.ss_video||(this.ss_video=createVideoInfo()),this.ss_video.remove=!1,this.ss_video.updateTime===w)break;this.ss_video.isEnable=!!y,this.ss_video.isMute=!!p,this.ss_video.updateTime=Number(w)||0,this.ss_video.sx=g||0,this.ss_video.sy=x||0,this.ss_video.sw=b||0,this.ss_video.sh=m||0}break}}(e=this.mc_audio)!=null&&e.remove&&(this.mc_audio=void 0),(t=this.mc_video)!=null&&t.remove&&(this.mc_video=void 0),(s=this.ss_audio)!=null&&s.remove&&(this.ss_audio=void 0),(l=this.ss_video)!=null&&l.remove&&(this.ss_video=void 0);const i=this.getUpdateTimeKey();r!==i&&(this.updateTime=new Date().getTime())});v(this,"destroy",()=>{var n,u;(n=this.mc_video)!=null&&n.destroy&&this.mc_video.destroy(),(u=this.ss_video)!=null&&u.destroy&&this.ss_video.destroy(),this.mc_audio=void 0,this.mc_video=void 0,this.ss_audio=void 0,this.ss_video=void 0})}}const parseSEI=f=>{let n=0,u=0;for(;;){const o=f[n];if(u=u+o,n=n+1,o!==255)break}let c=0;for(;;){const o=f[n];if(c=c+o,n=n+1,o!==255)break}if(u===5){const o=f.slice(n,n+16),i=Array.from(o,p=>p.toString(16).padStart(2,"0")).join("");n=n+16;const e=c-16,t=f.slice(n,n+e),s=com.quick.voice.proto.SeiData.decode(t),{event:l=0}=s,a=s.data;let d;switch(l){case 0:d=com.quick.voice.proto.LayoutData.decode(s.data);break;case 1:d=com.quick.voice.proto.CustomInfo.decode(s.data);break}return{uuid:i,...s,event:l,data_remote:a,data:d}}};class QuickVoPlayer{constructor(){v(this,"displayMode","original");v(this,"prPlayer",new be);v(this,"dom");v(this,"room",{roomId:"",updateTime:"",author:"",version:""});v(this,"usersMap",new Map);v(this,"on",{users:n=>{}});v(this,"init",()=>{this.prPlayer.init()});v(this,"start",async n=>(this.stop(),this.prPlayer.start(n)));v(this,"stop",()=>{this.prPlayer.stop(),this.usersMap=new Map,this.room.roomId="",this.room.author="",this.room.updateTime="",this.room.version=""});v(this,"setMute",n=>{this.prPlayer.setMute(n)});v(this,"getStream",()=>this.prPlayer.getStream());v(this,"getAllUseUpdateKey",()=>{const n=[...this.usersMap.values()];return Array.from(n,c=>c.updateTime).join("_")});v(this,"checkAndCreateUser",(n,u)=>{var c,o;if(this.usersMap.has(n)){const r=this.usersMap.get(n);if(r==null||r.init(u),r!=null&&r.mc_video){const{sx:i,sy:e,sw:t,sh:s}=r.mc_video;(c=r==null?void 0:r.mc_video.worker)==null||c.setCut({sx:i,sy:e,sw:t,sh:s})}if(r!=null&&r.ss_video){const{sx:i,sy:e,sw:t,sh:s}=r.ss_video;(o=r==null?void 0:r.ss_video.worker)==null||o.setCut({sx:i,sy:e,sw:t,sh:s})}}else{const r=new RoomUser;if(this.usersMap.set(n,r),r.init(u),r){if(r.mc_video){const{sx:i,sy:e,sw:t,sh:s}=r.mc_video,l=`${r.userId}_mc_video`,{worker:a,stream:d,destroy:y}=this.prPlayer.cut.create(l,{sx:i,sy:e,sw:t,sh:s});r.mc_video.worker=a,this.displayMode==="original"&&a.setPause(!0),r.mc_video.stream=d,r.mc_video.destroy=()=>{y(),this.prPlayer.cut.remove(l),this.usersMap.delete(r.userId)}}if(r.ss_video){const{sx:i,sy:e,sw:t,sh:s}=r.ss_video,l=`${r.userId}_ss_video`,{worker:a,stream:d,destroy:y}=this.prPlayer.cut.create(l,{sx:i,sy:e,sw:t,sh:s});r.ss_video.worker=a,this.displayMode==="original"&&a.setPause(!0),r.ss_video.stream=d,r.ss_video.destroy=()=>{y(),this.prPlayer.cut.remove(l),this.usersMap.delete(r.userId)}}}}});v(this,"onSEI",n=>{try{const u=parseSEI(n);if(!u)return;const{event:c,data:o}=u;switch(c){case 0:{const{roomId:r,userMap:i}=o;if(r!==this.room.roomId)return;const e=this.getAllUseUpdateKey(),t=Object.keys(i);{const l=[...this.usersMap.values()];for(const a of l)t.includes(a.userId)||a==null||a.destroy()}for(const l of t){const a=i[l];this.checkAndCreateUser(l,a)}const s=this.getAllUseUpdateKey();if(e!==s&&this.on.users){const l=[...this.usersMap.values()],a=Array.from(l,({userId:d,mc_audio:y,mc_video:p,ss_audio:w,ss_video:b,updateTime:m})=>({userId:d,mc_audio:y,mc_video:p,ss_audio:w,ss_video:b,updateTime:m}));this.on.users(a)}}break;case 1:{const{roomId:r,updateTime:i}=o,{author:e,version:t}=o.customKeyMap;this.room.roomId=r,this.room.updateTime=i,this.room.author=e,this.room.version=t}break}}catch(u){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->onSEI: error",u)}});v(this,"setDisplayMode",n=>{var u,c,o,r,i,e,t,s;switch(this.displayMode=n,n){case"original":{this.prPlayer.setPause(!1);const l=[...this.usersMap.values()];for(const a of l)(c=(u=a.mc_video)==null?void 0:u.worker)==null||c.setPause(!0),(r=(o=a.ss_video)==null?void 0:o.worker)==null||r.setPause(!0)}break;case"cut":{this.prPlayer.setPause(!0);const l=[...this.usersMap.values()];for(const a of l)(e=(i=a.mc_video)==null?void 0:i.worker)==null||e.setPause(!1),(s=(t=a.ss_video)==null?void 0:t.worker)==null||s.setPause(!1)}break}});this.prPlayer.on.demuxer.sei=this.onSEI}}exports.QuickVoPlayer=QuickVoPlayer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
1
+ (function(T,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(T=typeof globalThis<"u"?globalThis:T||self,k(T["quickvo-player"]={}))})(this,function(exports){"use strict";var U=Object.defineProperty;var D=T=>{throw TypeError(T)};var W=(T,k,f)=>k in T?U(T,k,{enumerable:!0,configurable:!0,writable:!0,value:f}):T[k]=f;var b=(T,k,f)=>W(T,typeof k!="symbol"?k+"":k,f),B=(T,k,f)=>k.has(T)||D("Cannot "+f);var S=(T,k,f)=>(B(T,k,"read from private field"),f?f.call(T):k.get(T)),P=(T,k,f)=>k.has(T)?D("Cannot add the same private member more than once"):k instanceof WeakSet?k.add(T):k.set(T,f),C=(T,k,f,n)=>(B(T,k,"write to private field"),n?n.call(T,f):k.set(T,f),f);var T,k;const L='(function(){"use strict";const U=new TextDecoder("utf-8"),H=(e,s)=>{const a=e.getUint8(s),t=a>>7&1,n=a>>5&3,r=a&31;return{forbidden_zero_bit:t,nal_ref_idc:n,nal_unit_type:r}},b=(e,s)=>e.getUint8(s),P=(e,s,a)=>{const t=new Uint8Array(e.buffer.slice(s,s+a));return U?.decode(t)||""},T=(e,s,a)=>{let t=s,n,r=0;switch(a){case 0:n=e.getFloat64(t,!1),r=8;break;case 1:n=!!e.getUint8(t),r=1;break;case 2:{n="";const o=e.getUint16(t,!1);t=t+2;const c=new Int8Array(e.buffer,t,o).filter(d=>d!==0);n=(U?.decode(c)||"").trim(),r=2+o}break;case 3:for(n={};t<e.byteLength;){const o=e.getUint16(t,!1);if(o===0)break;t=t+2;const c=P(e,t,o);t=t+o;const g=b(e,t);if(g===6)break;t=t+1;const d=T(e,t,g);t=t+d.length,n[c]=d.value,r=2+o+1+d.length}break;case 8:{n={};const o=e.getUint32(t,!1);t=t+4;for(let c=0;c<o;c++){const g=e.getUint16(t,!1);t=t+2;const d=P(e,t,g);t=t+g;const h=b(e,t);t=t+1;const l=T(e,t,h);t=t+l.length,n[d]=l.value,r=2+g+1+l.length}}break;case 10:{n=[];const o=e.getUint32(t,!1);t=t+4;for(let c=0;c<o;c++){const g=b(e,t);t=t+1;const d=T(e,t,g);t=t+d.length,n.push(d.value),r=1+d.length}}break}return{amfType:a,length:r,value:n}},m=(e,s)=>e.getUint8(s)<<16|e.getUint8(s+1)<<8|e.getUint8(s+2);var u={header:{getSignature:e=>{const s=new Int8Array(e.buffer.slice(0,3));return U?.decode(s)||""},getVersion:e=>e.getUint8(3),getFlags:e=>{const a=e.getUint8(0).toString(2).padStart(5,"0").split(""),[,,t,,n]=a;return{audio:n==="1",video:t==="1"}},getDataOffset:e=>e.getUint32(5)},getPreviousTagSize:(e,s)=>e.getUint32(s),isSurplusTag:(e,s)=>{let a=!0;const t=e.byteLength;if(s+4>t)a=!1;else if(s+4+11>t)a=!1;else{const n=m(e,s+4+1);s+4+11+n>t&&(a=!1)}return a},tag:{tagHeader:{getTagType:(e,s)=>{const a=e.getUint8(s);let t;switch(a){case 18:t="script";break;case 8:t="audio";break;case 9:t="video";break}return t},getDataSize:(e,s)=>m(e,s+1),getTimestamp:(e,s)=>m(e,s+4),getTimestampExtended:(e,s)=>e.getUint8(s+7),getStreamID:(e,s)=>m(e,s+8)},tagBody:{parseAudio:(e,s,a)=>{let t=s;const n=e.getUint8(t),r=n>>4&15,i=n>>2&3,o=n>>1&1,c=n&1;t=t+1;const g=e.getUint8(t);t=t+1;const d=a-2,h=new Uint8Array(e.buffer.slice(t,t+d));if(r===10&&g===0){const l=e.getUint8(t),p=e.getUint8(t+1),f=(l&248)>>3,y=(l&7)<<1|p>>7,S=(p&120)>>3,A=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],D=`mp4a.40.${f}`,z=A[y];return{soundFormat:r,soundRate:i,soundSize:o,soundType:c,accPacketType:g,data:h,audioObjectType:f,samplingFrequencyIndex:y,channelConfiguration:S,codec:D,sampleRate:z}}return{soundFormat:r,soundRate:i,soundSize:o,soundType:c,accPacketType:g,data:h}},parseVideo:(e,s,a)=>{let t=s;const n=e.getUint8(t),r=n>>4&15,i=n&15;t=t+1;const o=e.getUint8(t);t=t+1;const c=m(e,t);t=t+3;const g=a-5,d=new Uint8Array(e.buffer.slice(t,t+g));switch(i){case 7:if(o===0){const h=e.getUint8(t);if(t=t+1,h!==1)throw new Error("Invalid AVC version");const l=e.getUint8(t)&255;t=t+1;const p=e.getUint8(t)&255;t=t+1;const f=e.getUint8(t)&255;t=t+1;const A=`avc1.${Array.from([l,p,f],E=>E.toString(16).padStart(2,"0")).join("")}`,D=(e.getUint8(t)&3)-1;t=t+1;const z=e.getUint8(t)&31;t=t+1;const _=e.getUint16(t,!1);t=t+2;const O=new Uint8Array(e.buffer.slice(t,t+_));t=t+_;const I=e.getUint8(t)&31;t=t+1;const x=e.getUint16(t,!1);t=t+2;const M=new Uint8Array(e.buffer.slice(t,t+x));return t=t+x,{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d,version:h,codec:A,profile:l,compatibility:p,level:f,lengthSizeMinusOne:D,numOfSequenceParameterSets:z,sequenceParameterSetLength:_,sps:O,numOfPictureParameterSets:I,pictureParameterSetLength:x,pps:M}}else if(o===1){const h=[],l=t+a-5;for(;t+4<l;){const p=e.getUint32(t,!1);t=t+4;const f=H(e,t);t=t+1;const y=p-1,S=new Uint8Array(e.buffer.slice(t,t+y));t=t+y,h.push({size:p,header:f,payload:S})}return{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d,nalus:h}}break;default:throw new Error("Unsupported codecID")}return{frameType:r,codecID:i,avcPacketType:o,cts:c,data:d}},parseMetaData:(e,s)=>{let a=s;{if(e.getUint8(a)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");a=a+1}const t=e.getUint16(a,!1);a=a+2;{const i=new Int8Array(e.buffer.slice(a,a+t));if((U?.decode(i)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");a=a+t}const n=b(e,a);return a=a+1,T(e,a,n).value}}}};class L{parseSpeed=8;pendingPayloads=[];payload=new Uint8Array(0);offset=0;is_parsing=!1;header;tag;on={};constructor(){}init=()=>{this.destroy()};push=s=>{this.pendingPayloads.push(s),this.is_parsing||this.parse()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.offset=0,this.is_parsing=!1,this.header=void 0,this.tag=void 0};parse=async()=>{for(this.is_parsing=!0;;){const s=this.pendingPayloads.shift();if(!s)break;const a=new Uint8Array(this.payload.byteLength+s.byteLength);a.set(this.payload,0),a.set(s,this.payload.byteLength),this.payload=a;const t=new DataView(this.payload.buffer);this.header||this.parseHeader(t),await this.parseTag(t)}this.is_parsing=!1};parseHeader=s=>(this.header={signature:u.header.getSignature(s),version:u.header.getVersion(s),flags:u.header.getFlags(s),dataOffset:u.header.getDataOffset(s)},this.offset=this.header?.dataOffset,this.on.header&&this.on.header(this.header),this.header);parseTag=async s=>{const a=(n,r)=>({tagType:u.tag.tagHeader.getTagType(n,r),dataSize:u.tag.tagHeader.getDataSize(n,r),timestamp:u.tag.tagHeader.getTimestamp(n,r),timestampExtended:u.tag.tagHeader.getTimestampExtended(n,r),streamID:u.tag.tagHeader.getStreamID(n,r)}),t=(n,r,i,o)=>{let c;switch(n){case"script":c=u.tag.tagBody.parseMetaData(r,i);break;case"audio":c=u.tag.tagBody.parseAudio(r,i,o);break;case"video":c=u.tag.tagBody.parseVideo(r,i,o);break}return c};for(;this.offset<s.byteLength;){if(u.isSurplusTag(s,this.offset)===!1){this.payload=this.payload.slice(this.offset),this.offset=0;break}const r=a(s,this.offset+4),{tagType:i,dataSize:o}=r;if(!i)break;const c=t(i,s,this.offset+4+11,o);this.tag={header:r,body:c},this.on.tag&&this.on.tag(this.tag),this.offset=this.offset+4+11+o,await new Promise(g=>setTimeout(()=>g(!0),this.parseSpeed))}}}const k=new L;k.on.header=e=>postMessage({action:"onHeader",data:e}),k.on.tag=e=>postMessage({action:"onTag",data:e}),onmessage=e=>{const{action:s,data:a}=e.data,t=k[s];t&&t(a)}})();\n',A=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",L],{type:"text/javascript;charset=utf-8"});function E(f){let n;try{if(n=A&&(self.URL||self.webkitURL).createObjectURL(A),!n)throw"";const u=new Worker(n,{name:f==null?void 0:f.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(L),{name:f==null?void 0:f.name})}}class _{constructor(){b(this,"worker",new E);b(this,"on",{});b(this,"init",()=>this.worker.postMessage({action:"init"}));b(this,"push",n=>this.worker.postMessage({action:"push",data:n}));b(this,"destroy",()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()});this.worker.onmessage=n=>{const{action:u,data:c}=n.data;u==="onHeader"&&this.on.header&&this.on.header(c),u==="onTag"&&this.on.tag&&this.on.tag(c)}}}const N=`(function(){"use strict";class r{audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;on={audio:{},video:{}};constructor(){}audio={init:i=>{this.audio.destroy(),this.audioDecoderConfig={...i},this.audioDecoder=new AudioDecoder({output:e=>{this.on.audio.decode&&this.on.audio.decode(e)},error:e=>{this.on.audio.error&&this.on.audio.error(e)}}),this.audioDecoder.configure(this.audioDecoderConfig)},decode:i=>{if(!this.audioDecoder)return;const e=new EncodedAudioChunk(i);this.audioDecoder.decode(e)},flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={init:i=>{this.video.destroy(),this.videoDecoderConfig={...i},this.videoDecoder=new VideoDecoder({output:async e=>{const d=await createImageBitmap(e),s=e.timestamp;e.close(),d.width>0&&d.height>0?this.on.video.decode&&this.on.video.decode({timestamp:s,bitmap:d}):d.close()},error:e=>{this.on.video.error&&this.on.video.error(e)}}),this.videoDecoder.configure(this.videoDecoderConfig)},decode:i=>{if(this.videoDecoder&&(i.type==="key"&&(this.hasKeyFrame=!0),this.hasKeyFrame&&this.videoDecoder.decodeQueueSize<2)){const e=new EncodedVideoChunk(i);this.videoDecoder.decode(e)}},flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const t=new r;t.on.audio.decode=o=>postMessage({type:"audio",action:"onDecode",data:o}),t.on.audio.error=o=>postMessage({type:"audio",action:"onError",data:o}),t.on.video.decode=o=>postMessage({type:"video",action:"onDecode",data:o}),t.on.video.error=o=>postMessage({type:"video",action:"onError",data:o}),onmessage=o=>{const{type:i,action:e,data:d}=o.data,s=t[i][e];s&&s(d)}})();
2
+ `,R=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",N],{type:"text/javascript;charset=utf-8"});function V(f){let n;try{if(n=R&&(self.URL||self.webkitURL).createObjectURL(R),!n)throw"";const u=new Worker(n,{name:f==null?void 0:f.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(N),{name:f==null?void 0:f.name})}}class j{constructor(){b(this,"worker",new V);b(this,"on",{audio:{},video:{}});b(this,"audio",{init:n=>this.worker.postMessage({type:"audio",action:"init",data:n}),decode:n=>this.worker.postMessage({type:"audio",action:"decode",data:n}),flush:()=>this.worker.postMessage({type:"audio",action:"flush"}),destroy:()=>{this.worker.postMessage({type:"audio",action:"destroy"})}});b(this,"video",{init:n=>this.worker.postMessage({type:"video",action:"init",data:n}),decode:n=>this.worker.postMessage({type:"video",action:"decode",data:n}),flush:()=>this.worker.postMessage({type:"video",action:"flush"}),destroy:()=>{this.worker.postMessage({type:"video",action:"destroy",data:{}})}});b(this,"destroy",()=>{this.worker.postMessage({type:"audio",action:"destroy"}),this.worker.postMessage({type:"video",action:"destroy",data:{}}),this.worker.terminate()});this.worker.onmessage=n=>{const{type:u,action:c,data:o}=n.data;switch(u){case"audio":c==="onDecode"&&this.on.audio.decode&&this.on.audio.decode(o),c==="onError"&&this.on.audio.error&&this.on.audio.error(o);break;case"video":c==="onDecode"&&this.on.video.decode&&this.on.video.decode(o),c==="onError"&&this.on.video.error&&this.on.video.error(o);break}}}}const F=`(function(){"use strict";class r{isRendering=!1;pendingFrames=[];offscreenCanvas;writable;writer;ctx;cutOption;baseTime=0;pause=!1;shader=["stream"];constructor(){}init=({offscreenCanvas:e,baseTime:t=performance.timeOrigin,writable:i})=>{this.destroy(),this.offscreenCanvas=e,this.writable=i,this.writer=this.writable.getWriter(),this.ctx=this.offscreenCanvas.getContext("2d"),this.baseTime=t};setShader=e=>{this.shader=e};setSize=({width:e,height:t})=>{this.offscreenCanvas&&(this.offscreenCanvas.width=e,this.offscreenCanvas.height=t)};destroy=()=>{this.isRendering=!1,this.pendingFrames=[],this.offscreenCanvas=void 0,this.ctx=void 0,this.baseTime=0};push=e=>{this.pendingFrames.push(e),this.isRendering===!1&&setTimeout(this.renderFrame,0)};setCut=e=>{this.cutOption=e};setPause=e=>{this.pause=e,this.isRendering===!1&&setTimeout(this.renderFrame,0)};calculateTimeUntilNextFrame=e=>{const t=performance.timeOrigin+performance.now(),s=this.baseTime+e/1e3-t;return Math.max(0,s)};renderFrame=async()=>{for(this.isRendering=!0;;){const e=this.pendingFrames.shift();if(!e)break;let{timestamp:t,bitmap:i}=e;if(this.cutOption){const{sx:a=0,sy:c=0,sw:m=i.width,sh:o=i.height}=this.cutOption;i=await createImageBitmap(i,a,c,m,o)}const s=this.calculateTimeUntilNextFrame(t);await new Promise(a=>setTimeout(()=>a(!0),s)),this.drawImage({timestamp:t,bitmap:i}),this.cutOption&&i.close()}this.isRendering=!1};drawImage=e=>{if(this.pause!==!0){if(this.shader.includes("stream")){const t=new VideoFrame(e.bitmap,{timestamp:e.timestamp});this.writer.write(t),t.close()}this.shader.includes("canvas")&&this.ctx&&this.offscreenCanvas&&this.ctx.drawImage(e.bitmap,0,0,this.offscreenCanvas.width,this.offscreenCanvas.height)}}}const h=new r;onmessage=n=>{const{action:e,data:t}=n.data,i=h[e];i&&i(t)}})();
3
+ `,M=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",F],{type:"text/javascript;charset=utf-8"});function H(f){let n;try{if(n=M&&(self.URL||self.webkitURL).createObjectURL(M),!n)throw"";const u=new Worker(n,{name:f==null?void 0:f.name});return u.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(n)}),u}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(F),{name:f==null?void 0:f.name})}}class ${constructor(){b(this,"worker",new H);b(this,"init",({offscreenCanvas:n,baseTime:u=0,writable:c})=>this.worker.postMessage({action:"init",data:{offscreenCanvas:n,baseTime:u,writable:c}},[n,c]));b(this,"setShader",n=>this.worker.postMessage({action:"setShader",data:n}));b(this,"setSize",({width:n,height:u})=>this.worker.postMessage({action:"setSize",data:{width:n,height:u}}));b(this,"push",n=>this.worker.postMessage({action:"push",data:n}));b(this,"setCut",async n=>this.worker.postMessage({action:"setCut",data:n}));b(this,"setPause",n=>this.worker.postMessage({action:"setPause",data:n}));b(this,"destroy",()=>{this.worker.postMessage({action:"destroy",data:{}}),this.worker.terminate()})}}var q=Object.defineProperty,K=(f,n,u)=>n in f?q(f,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):f[n]=u,h=(f,n,u)=>K(f,typeof n!="symbol"?n+"":n,u);class Q{constructor(n,u){h(this,"inputStream",new MediaStream),h(this,"outputStream",new MediaStream),h(this,"inputGain",1),h(this,"enhanceGain",1),h(this,"bgsGain",1),h(this,"bgmGain",1),h(this,"outputGain",1),h(this,"mixAudioMap",new Map),h(this,"audioContext",new AudioContext),h(this,"sourceNode"),h(this,"inputGainNode"),h(this,"enhanceGainNode"),h(this,"bgsGainNode"),h(this,"bgmGainNode"),h(this,"analyserNode"),h(this,"analyserArrayData"),h(this,"outputGainNode"),h(this,"destinationNode"),h(this,"filterStream",c=>c),h(this,"stop",()=>{{const c=this.inputStream.getTracks();for(const o of c)o.stop(),this.inputStream.removeTrack(o)}}),h(this,"getStream",()=>this.filterStream(this.outputStream)),h(this,"setMute",(c=!0)=>{c?this.analyserNode.disconnect(this.outputGainNode):this.analyserNode.connect(this.outputGainNode)}),h(this,"setInputGain",c=>{this.inputGain=c,this.inputGainNode.gain.setValueAtTime(c,this.audioContext.currentTime)}),h(this,"setEnhanceGain",async c=>{this.enhanceGain=c+1,this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime)}),h(this,"setBgsGain",c=>{this.bgsGain=c,this.bgsGainNode.gain.setValueAtTime(c,this.audioContext.currentTime)}),h(this,"setBgmGain",c=>{this.bgmGain=c,this.bgmGainNode.gain.setValueAtTime(c,this.audioContext.currentTime)}),h(this,"setOutputGain",c=>{this.outputGain=c,this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime)}),h(this,"getVolume",()=>{const{analyserNode:c,analyserArrayData:o}=this;c.getByteFrequencyData(o);let r=0;for(let i=0;i<o.length;i++)r+=o[i];return Math.ceil(r/o.length)}),h(this,"mixAudio",(c,o="bgm")=>new Promise(async(r,i)=>{try{{const s=this.mixAudioMap.get(o);s&&s.stop()}const e=o==="bgs"?this.bgsGainNode:this.bgmGainNode,t=this.audioContext.createBufferSource();this.mixAudioMap.set(o,t),t.buffer=c,t.connect(e),t.onended=()=>{t.disconnect(e),this.mixAudioMap.delete(o),r(!0)},t.start(0)}catch(e){i(e)}})),h(this,"mixAudioStop",c=>{const o=this.mixAudioMap.get(c);o==null||o.stop()}),h(this,"changeMix",(c,o)=>{const r=c==="bgs"?this.bgsGainNode:this.bgmGainNode;o?r.connect(this.destinationNode):r.disconnect(this.destinationNode)}),u&&(this.audioContext=u),this.inputStream=n,this.sourceNode=this.audioContext.createMediaStreamSource(this.inputStream),this.inputGainNode=this.audioContext.createGain(),this.inputGainNode.gain.setValueAtTime(this.inputGain,this.audioContext.currentTime),this.enhanceGainNode=this.audioContext.createGain(),this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain,this.audioContext.currentTime),this.bgsGainNode=this.audioContext.createGain(),this.bgsGainNode.gain.setValueAtTime(this.bgsGain,this.audioContext.currentTime),this.bgmGainNode=this.audioContext.createGain(),this.bgmGainNode.gain.setValueAtTime(this.bgmGain,this.audioContext.currentTime),this.analyserNode=this.audioContext.createAnalyser(),this.analyserNode.fftSize=512,this.analyserArrayData=new Uint8Array(this.analyserNode.frequencyBinCount),this.outputGainNode=this.audioContext.createGain(),this.outputGainNode.gain.setValueAtTime(this.outputGain,this.audioContext.currentTime),this.destinationNode=this.audioContext.createMediaStreamDestination(),this.outputStream=this.destinationNode.stream;{const{sourceNode:c,inputGainNode:o,enhanceGainNode:r,bgsGainNode:i,bgmGainNode:e,analyserNode:t,outputGainNode:s,destinationNode:l}=this;c.connect(o),o.connect(r),r.connect(t),i.connect(t),e.connect(t),r.connect(l),i.connect(l),e.connect(l),t.connect(s),s.connect(this.audioContext.destination)}this.setMute(!0),this.audioContext.resume()}}const J=async(f,n)=>{try{const{format:u,numberOfChannels:c,numberOfFrames:o,sampleRate:r}=n,i=f.createBuffer(c,o,r);for(let e=0;e<c;e++){const t=n.allocationSize({planeIndex:e}),s=new Uint8Array(t);n.copyTo(s,{planeIndex:e});const l=new DataView(s.buffer),a=i.getChannelData(e);for(let d=0;d<o;d++){let y;switch(u){case"s16":case"s16-planar":y=l.getInt16(d*2,!0)/32768;break;case"f32":case"f32-planar":y=l.getFloat32(d*4,!0);break;case"u8":case"u8-planar":y=(l.getUint8(d)-128)/128;break;default:throw new Error(`Unsupported audio format: ${u}`)}a[d]=Math.max(-1,Math.min(1,y))}}return i}catch(u){throw console.error("Failed to convert AudioData to AudioBuffer:",u),u}};class X{constructor(){b(this,"prAudioStream");b(this,"audioContext");b(this,"destination");b(this,"stream",new MediaStream);b(this,"nextStartTime",0);b(this,"pendingSources",[]);b(this,"init",n=>{n||(n=new(window.AudioContext||window.webkitAudioContext)),this.audioContext=n,this.destination=this.audioContext.createMediaStreamDestination(),this.stream=new MediaStream,this.stream.addTrack(this.destination.stream.getAudioTracks()[0]),this.prAudioStream=new Q(this.stream,this.audioContext),this.nextStartTime=0,this.pendingSources=[]});b(this,"getStream",()=>{var n;return(n=this.prAudioStream)==null?void 0:n.getStream()})}async push(n){try{if(!this.audioContext||!this.destination)return;const u=await J(this.audioContext,n);if(!u)return;const c=this.audioContext.createBufferSource();c.buffer=u,c.connect(this.destination);const o=Math.max(this.nextStartTime,this.audioContext.currentTime);this.nextStartTime=o+u.duration,c.start(o),this.pendingSources.push(c),c.onended=()=>{this.pendingSources=this.pendingSources.filter(r=>r!==c)},this.audioContext.state==="suspended"&&await this.audioContext.resume()}finally{n.close()}}destroy(){var n,u;(n=this.audioContext)==null||n.close(),this.audioContext=void 0,this.destination=void 0,this.nextStartTime=0,(u=this.prAudioStream)==null||u.stop(),this.pendingSources.forEach(c=>c.stop()),this.pendingSources=[]}}class Y{constructor(n={}){P(this,T,{timeout:5*1e3});P(this,k);b(this,"check",(n,u)=>new Promise(async(c,o)=>{var i;this.stop(),C(this,k,new AbortController);const r=window.setTimeout(()=>{var e;(e=S(this,k))==null||e.abort("Timeout."),o({status:"timeout",reason:""})},S(this,T).timeout);try{const e=await fetch(n,{...u,method:"HEAD",signal:(i=S(this,k))==null?void 0:i.signal});e.status===200?c({status:"successed",reason:""}):o({status:"failed",reason:`${e.status}`})}catch(e){o({status:"error",reason:e.message})}clearTimeout(r)}));b(this,"request",async(n,u)=>new Promise(async(c,o)=>{var r;try{await this.check(n,u),C(this,k,new AbortController);const i=await fetch(n,{...u,signal:(r=S(this,k))==null?void 0:r.signal});c(i)}catch(i){this.stop(),o(i)}}));b(this,"stop",()=>{var n;((n=S(this,k))==null?void 0:n.signal.aborted)===!1&&S(this,k).abort("Actively stop.")});C(this,T,{...S(this,T),...n})}}T=new WeakMap,k=new WeakMap;const O=f=>{const n=(f==null?void 0:f.getTracks())||[];for(const u of n)u.stop()},G=f=>{const n=new $,u=document.createElement("canvas"),c=u.transferControlToOffscreen(),o=new MediaStreamTrackGenerator({kind:"video"}),r=new MediaStream([o]),i=()=>{n.destroy(),O(r)};return n.init({offscreenCanvas:c,baseTime:f,writable:o.writable}),{worker:n,canvas:u,stream:r,destroy:i}};class be{constructor(){b(this,"prFetch",new Y);b(this,"demuxerWorker");b(this,"decoderWorker");b(this,"audioPlayer");b(this,"renderWorker");b(this,"renderBaseTime",0);b(this,"stream");b(this,"canvas");b(this,"on",{demuxer:{},decoder:{}});b(this,"cutRenders",new Map);b(this,"trackGenerator");b(this,"init",()=>{this.initDemuxer(),this.initDecoder(),this.audioPlayer=new X,this.audioPlayer.init(),this.initRender()});b(this,"start",async n=>(this.stop(),this.renderBaseTime=new Date().getTime(),this.init(),this.prFetch.request(n).then(async u=>{var r;const c=(r=u.body)==null?void 0:r.getReader();if(!c)throw new Error("Reader is error.");const o=()=>{c.read().then(({done:i,value:e})=>{var t;e&&((t=this.demuxerWorker)==null||t.push(e)),!i&&o()}).catch(i=>{if(i.name!=="AbortError")throw i})};o()}).catch(u=>{console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->Breathe: err",u)})));b(this,"stop",async()=>{var u,c,o,r;try{this.prFetch.stop()}catch(i){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->Breathe: error",i)}(u=this.demuxerWorker)==null||u.destroy(),(c=this.decoderWorker)==null||c.destroy(),(o=this.renderWorker)==null||o.destroy(),O(this.stream);const n=[...this.cutRenders.keys()];for(const i of n)this.cut.remove(i);(r=this.audioPlayer)==null||r.destroy(),this.renderBaseTime=0,this.canvas=void 0});b(this,"onTag",n=>{var i;if(!this.decoderWorker)return;const{header:u,body:c}=n,{tagType:o,timestamp:r}=u;switch(o){case"script":{const{width:e,height:t}=c;(i=this.renderWorker)==null||i.setSize({width:e,height:t}),this.on.demuxer.script&&this.on.demuxer.script(n)}break;case"audio":{const{accPacketType:e,data:t}=c;if(e===0){const{codec:s,sampleRate:l,channelConfiguration:a}=c,d={codec:s,sampleRate:l,numberOfChannels:a,description:new Uint8Array([])};this.decoderWorker.audio.init(d)}else e===1&&this.decoderWorker.audio.decode({type:"key",timestamp:r*1,data:t});this.on.demuxer.audio&&this.on.demuxer.audio(n)}break;case"video":{const{avcPacketType:e,frameType:t,data:s,nalus:l=[]}=c;if(e===0){const{codec:a,data:d}=c;this.decoderWorker.video.init({codec:a,description:d})}else if(e===1){const a=t===1?"key":"delta";this.decoderWorker.video.decode({type:a,timestamp:r*1e3,data:s});for(const d of l){const{header:y,payload:p}=d,{nal_unit_type:w}=y;w===6&&this.on.demuxer.sei&&this.on.demuxer.sei(p)}}this.on.demuxer.video&&this.on.demuxer.video(n)}break}});b(this,"initDemuxer",()=>{this.demuxerWorker=new _,this.demuxerWorker.init(),this.demuxerWorker.on.tag=this.onTag});b(this,"initDecoder",()=>{this.decoderWorker=new j,this.decoderWorker.on.audio.decode=n=>{var u;(u=this.audioPlayer)==null||u.push(n),this.on.decoder.audio&&this.on.decoder.audio(n)},this.decoderWorker.on.audio.error=n=>{this.stop(),this.on.error&&this.on.error(n)},this.decoderWorker.on.video.decode=async n=>{var c,o;(c=this.renderWorker)==null||c.push(n);const u=[...this.cutRenders.keys()];for(const r of u)(o=this.cutRenders.get(r))==null||o.worker.push(n);this.on.decoder.video&&this.on.decoder.video(n),n.bitmap.close()},this.decoderWorker.on.video.error=n=>{this.stop(),this.on.error&&this.on.error(n)}});b(this,"initRender",()=>{const{worker:n,canvas:u,stream:c}=G(this.renderBaseTime);this.renderWorker=n,this.canvas=u,this.stream=c,this.renderWorker.setPause(!1)});b(this,"getCanvas",()=>this.canvas);b(this,"getStream",()=>this.stream);b(this,"setPause",n=>{var u;(u=this.renderWorker)==null||u.setPause(n)});b(this,"setShader",n=>{var u;(u=this.renderWorker)==null||u.setShader(n)});b(this,"setMute",n=>{var u,c;return(c=(u=this.audioPlayer)==null?void 0:u.prAudioStream)==null?void 0:c.setMute(n)});b(this,"cut",{create:(n,u)=>{let c=this.cutRenders.get(n);return c?(c.worker.setCut(u),c.worker.setPause(!1),c):(c=G(this.renderBaseTime),c.worker.setCut(u),this.cutRenders.set(n,c),c)},getCanvas:n=>{var u;return(u=this.cutRenders.get(n))==null?void 0:u.canvas},getStream:n=>{var u;return(u=this.cutRenders.get(n))==null?void 0:u.stream},setPause:(n,u)=>{var c;(c=this.cutRenders.get(n))==null||c.worker.setPause(u)},setShader:(n,u)=>{var c;(c=this.cutRenders.get(n))==null||c.worker.setShader(u)},remove:n=>{var u;(u=this.cutRenders.get(n))==null||u.destroy(),this.cutRenders.delete(n)}})}}new TextDecoder("utf-8");var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},indexMinimal={},minimal$1={},aspromise,hasRequiredAspromise;function requireAspromise(){if(hasRequiredAspromise)return aspromise;hasRequiredAspromise=1,aspromise=f;function f(n,u){for(var c=new Array(arguments.length-1),o=0,r=2,i=!0;r<arguments.length;)c[o++]=arguments[r++];return new Promise(function(t,s){c[o]=function(a){if(i)if(i=!1,a)s(a);else{for(var d=new Array(arguments.length-1),y=0;y<d.length;)d[y++]=arguments[y];t.apply(null,d)}};try{n.apply(u||null,c)}catch(l){i&&(i=!1,s(l))}})}return aspromise}var base64={},hasRequiredBase64;function requireBase64(){return hasRequiredBase64||(hasRequiredBase64=1,function(f){var n=f;n.length=function(e){var t=e.length;if(!t)return 0;for(var s=0;--t%4>1&&e.charAt(t)==="=";)++s;return Math.ceil(e.length*3)/4-s};for(var u=new Array(64),c=new Array(123),o=0;o<64;)c[u[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;n.encode=function(e,t,s){for(var l=null,a=[],d=0,y=0,p;t<s;){var w=e[t++];switch(y){case 0:a[d++]=u[w>>2],p=(w&3)<<4,y=1;break;case 1:a[d++]=u[p|w>>4],p=(w&15)<<2,y=2;break;case 2:a[d++]=u[p|w>>6],a[d++]=u[w&63],y=0;break}d>8191&&((l||(l=[])).push(String.fromCharCode.apply(String,a)),d=0)}return y&&(a[d++]=u[p],a[d++]=61,y===1&&(a[d++]=61)),l?(d&&l.push(String.fromCharCode.apply(String,a.slice(0,d))),l.join("")):String.fromCharCode.apply(String,a.slice(0,d))};var r="invalid encoding";n.decode=function(e,t,s){for(var l=s,a=0,d,y=0;y<e.length;){var p=e.charCodeAt(y++);if(p===61&&a>1)break;if((p=c[p])===void 0)throw Error(r);switch(a){case 0:d=p,a=1;break;case 1:t[s++]=d<<2|(p&48)>>4,d=p,a=2;break;case 2:t[s++]=(d&15)<<4|(p&60)>>2,d=p,a=3;break;case 3:t[s++]=(d&3)<<6|p,a=0;break}}if(a===1)throw Error(r);return s-l},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}}(base64)),base64}var eventemitter,hasRequiredEventemitter;function requireEventemitter(){if(hasRequiredEventemitter)return eventemitter;hasRequiredEventemitter=1,eventemitter=f;function f(){this._listeners={}}return f.prototype.on=function(u,c,o){return(this._listeners[u]||(this._listeners[u]=[])).push({fn:c,ctx:o||this}),this},f.prototype.off=function(u,c){if(u===void 0)this._listeners={};else if(c===void 0)this._listeners[u]=[];else for(var o=this._listeners[u],r=0;r<o.length;)o[r].fn===c?o.splice(r,1):++r;return this},f.prototype.emit=function(u){var c=this._listeners[u];if(c){for(var o=[],r=1;r<arguments.length;)o.push(arguments[r++]);for(r=0;r<c.length;)c[r].fn.apply(c[r++].ctx,o)}return this},eventemitter}var float,hasRequiredFloat;function requireFloat(){if(hasRequiredFloat)return float;hasRequiredFloat=1,float=f(f);function f(r){return typeof Float32Array<"u"?function(){var i=new Float32Array([-0]),e=new Uint8Array(i.buffer),t=e[3]===128;function s(y,p,w){i[0]=y,p[w]=e[0],p[w+1]=e[1],p[w+2]=e[2],p[w+3]=e[3]}function l(y,p,w){i[0]=y,p[w]=e[3],p[w+1]=e[2],p[w+2]=e[1],p[w+3]=e[0]}r.writeFloatLE=t?s:l,r.writeFloatBE=t?l:s;function a(y,p){return e[0]=y[p],e[1]=y[p+1],e[2]=y[p+2],e[3]=y[p+3],i[0]}function d(y,p){return e[3]=y[p],e[2]=y[p+1],e[1]=y[p+2],e[0]=y[p+3],i[0]}r.readFloatLE=t?a:d,r.readFloatBE=t?d:a}():function(){function i(t,s,l,a){var d=s<0?1:0;if(d&&(s=-s),s===0)t(1/s>0?0:2147483648,l,a);else if(isNaN(s))t(2143289344,l,a);else if(s>34028234663852886e22)t((d<<31|2139095040)>>>0,l,a);else if(s<11754943508222875e-54)t((d<<31|Math.round(s/1401298464324817e-60))>>>0,l,a);else{var y=Math.floor(Math.log(s)/Math.LN2),p=Math.round(s*Math.pow(2,-y)*8388608)&8388607;t((d<<31|y+127<<23|p)>>>0,l,a)}}r.writeFloatLE=i.bind(null,n),r.writeFloatBE=i.bind(null,u);function e(t,s,l){var a=t(s,l),d=(a>>31)*2+1,y=a>>>23&255,p=a&8388607;return y===255?p?NaN:d*(1/0):y===0?d*1401298464324817e-60*p:d*Math.pow(2,y-150)*(p+8388608)}r.readFloatLE=e.bind(null,c),r.readFloatBE=e.bind(null,o)}(),typeof Float64Array<"u"?function(){var i=new Float64Array([-0]),e=new Uint8Array(i.buffer),t=e[7]===128;function s(y,p,w){i[0]=y,p[w]=e[0],p[w+1]=e[1],p[w+2]=e[2],p[w+3]=e[3],p[w+4]=e[4],p[w+5]=e[5],p[w+6]=e[6],p[w+7]=e[7]}function l(y,p,w){i[0]=y,p[w]=e[7],p[w+1]=e[6],p[w+2]=e[5],p[w+3]=e[4],p[w+4]=e[3],p[w+5]=e[2],p[w+6]=e[1],p[w+7]=e[0]}r.writeDoubleLE=t?s:l,r.writeDoubleBE=t?l:s;function a(y,p){return e[0]=y[p],e[1]=y[p+1],e[2]=y[p+2],e[3]=y[p+3],e[4]=y[p+4],e[5]=y[p+5],e[6]=y[p+6],e[7]=y[p+7],i[0]}function d(y,p){return e[7]=y[p],e[6]=y[p+1],e[5]=y[p+2],e[4]=y[p+3],e[3]=y[p+4],e[2]=y[p+5],e[1]=y[p+6],e[0]=y[p+7],i[0]}r.readDoubleLE=t?a:d,r.readDoubleBE=t?d:a}():function(){function i(t,s,l,a,d,y){var p=a<0?1:0;if(p&&(a=-a),a===0)t(0,d,y+s),t(1/a>0?0:2147483648,d,y+l);else if(isNaN(a))t(0,d,y+s),t(2146959360,d,y+l);else if(a>17976931348623157e292)t(0,d,y+s),t((p<<31|2146435072)>>>0,d,y+l);else{var w;if(a<22250738585072014e-324)w=a/5e-324,t(w>>>0,d,y+s),t((p<<31|w/4294967296)>>>0,d,y+l);else{var v=Math.floor(Math.log(a)/Math.LN2);v===1024&&(v=1023),w=a*Math.pow(2,-v),t(w*4503599627370496>>>0,d,y+s),t((p<<31|v+1023<<20|w*1048576&1048575)>>>0,d,y+l)}}}r.writeDoubleLE=i.bind(null,n,0,4),r.writeDoubleBE=i.bind(null,u,4,0);function e(t,s,l,a,d){var y=t(a,d+s),p=t(a,d+l),w=(p>>31)*2+1,v=p>>>20&2047,m=4294967296*(p&1048575)+y;return v===2047?m?NaN:w*(1/0):v===0?w*5e-324*m:w*Math.pow(2,v-1075)*(m+4503599627370496)}r.readDoubleLE=e.bind(null,c,0,4),r.readDoubleBE=e.bind(null,o,4,0)}(),r}function n(r,i,e){i[e]=r&255,i[e+1]=r>>>8&255,i[e+2]=r>>>16&255,i[e+3]=r>>>24}function u(r,i,e){i[e]=r>>>24,i[e+1]=r>>>16&255,i[e+2]=r>>>8&255,i[e+3]=r&255}function c(r,i){return(r[i]|r[i+1]<<8|r[i+2]<<16|r[i+3]<<24)>>>0}function o(r,i){return(r[i]<<24|r[i+1]<<16|r[i+2]<<8|r[i+3])>>>0}return float}var inquire_1,hasRequiredInquire;function requireInquire(){if(hasRequiredInquire)return inquire_1;hasRequiredInquire=1,inquire_1=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(f){}return null}return inquire_1}var utf8={},hasRequiredUtf8;function requireUtf8(){return hasRequiredUtf8||(hasRequiredUtf8=1,function(f){var n=f;n.length=function(c){for(var o=0,r=0,i=0;i<c.length;++i)r=c.charCodeAt(i),r<128?o+=1:r<2048?o+=2:(r&64512)===55296&&(c.charCodeAt(i+1)&64512)===56320?(++i,o+=4):o+=3;return o},n.read=function(c,o,r){var i=r-o;if(i<1)return"";for(var e=null,t=[],s=0,l;o<r;)l=c[o++],l<128?t[s++]=l:l>191&&l<224?t[s++]=(l&31)<<6|c[o++]&63:l>239&&l<365?(l=((l&7)<<18|(c[o++]&63)<<12|(c[o++]&63)<<6|c[o++]&63)-65536,t[s++]=55296+(l>>10),t[s++]=56320+(l&1023)):t[s++]=(l&15)<<12|(c[o++]&63)<<6|c[o++]&63,s>8191&&((e||(e=[])).push(String.fromCharCode.apply(String,t)),s=0);return e?(s&&e.push(String.fromCharCode.apply(String,t.slice(0,s))),e.join("")):String.fromCharCode.apply(String,t.slice(0,s))},n.write=function(c,o,r){for(var i=r,e,t,s=0;s<c.length;++s)e=c.charCodeAt(s),e<128?o[r++]=e:e<2048?(o[r++]=e>>6|192,o[r++]=e&63|128):(e&64512)===55296&&((t=c.charCodeAt(s+1))&64512)===56320?(e=65536+((e&1023)<<10)+(t&1023),++s,o[r++]=e>>18|240,o[r++]=e>>12&63|128,o[r++]=e>>6&63|128,o[r++]=e&63|128):(o[r++]=e>>12|224,o[r++]=e>>6&63|128,o[r++]=e&63|128);return r-i}}(utf8)),utf8}var pool_1,hasRequiredPool;function requirePool(){if(hasRequiredPool)return pool_1;hasRequiredPool=1,pool_1=f;function f(n,u,c){var o=c||8192,r=o>>>1,i=null,e=o;return function(s){if(s<1||s>r)return n(s);e+s>o&&(i=n(o),e=0);var l=u.call(i,e,e+=s);return e&7&&(e=(e|7)+1),l}}return pool_1}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=n;var f=requireMinimal$1();function n(r,i){this.lo=r>>>0,this.hi=i>>>0}var u=n.zero=new n(0,0);u.toNumber=function(){return 0},u.zzEncode=u.zzDecode=function(){return this},u.length=function(){return 1};var c=n.zeroHash="\0\0\0\0\0\0\0\0";n.fromNumber=function(i){if(i===0)return u;var e=i<0;e&&(i=-i);var t=i>>>0,s=(i-t)/4294967296>>>0;return e&&(s=~s>>>0,t=~t>>>0,++t>4294967295&&(t=0,++s>4294967295&&(s=0))),new n(t,s)},n.from=function(i){if(typeof i=="number")return n.fromNumber(i);if(f.isString(i))if(f.Long)i=f.Long.fromString(i);else return n.fromNumber(parseInt(i,10));return i.low||i.high?new n(i.low>>>0,i.high>>>0):u},n.prototype.toNumber=function(i){if(!i&&this.hi>>>31){var e=~this.lo+1>>>0,t=~this.hi>>>0;return e||(t=t+1>>>0),-(e+t*4294967296)}return this.lo+this.hi*4294967296},n.prototype.toLong=function(i){return f.Long?new f.Long(this.lo|0,this.hi|0,!!i):{low:this.lo|0,high:this.hi|0,unsigned:!!i}};var o=String.prototype.charCodeAt;return n.fromHash=function(i){return i===c?u:new n((o.call(i,0)|o.call(i,1)<<8|o.call(i,2)<<16|o.call(i,3)<<24)>>>0,(o.call(i,4)|o.call(i,5)<<8|o.call(i,6)<<16|o.call(i,7)<<24)>>>0)},n.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},n.prototype.zzEncode=function(){var i=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^i)>>>0,this.lo=(this.lo<<1^i)>>>0,this},n.prototype.zzDecode=function(){var i=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^i)>>>0,this.hi=(this.hi>>>1^i)>>>0,this},n.prototype.length=function(){var i=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,t=this.hi>>>24;return t===0?e===0?i<16384?i<128?1:2:i<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:t<128?9:10},longbits}var hasRequiredMinimal$1;function requireMinimal$1(){return hasRequiredMinimal$1||(hasRequiredMinimal$1=1,function(f){var n=f;n.asPromise=requireAspromise(),n.base64=requireBase64(),n.EventEmitter=requireEventemitter(),n.float=requireFloat(),n.inquire=requireInquire(),n.utf8=requireUtf8(),n.pool=requirePool(),n.LongBits=requireLongbits(),n.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),n.global=n.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||minimal$1,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r},n.isString=function(r){return typeof r=="string"||r instanceof String},n.isObject=function(r){return r&&typeof r=="object"},n.isset=n.isSet=function(r,i){var e=r[i];return e!=null&&r.hasOwnProperty(i)?typeof e!="object"||(Array.isArray(e)?e.length:Object.keys(e).length)>0:!1},n.Buffer=function(){try{var o=n.inquire("buffer").Buffer;return o.prototype.utf8Write?o:null}catch{return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(r){return typeof r=="number"?n.Buffer?n._Buffer_allocUnsafe(r):new n.Array(r):n.Buffer?n._Buffer_from(r):typeof Uint8Array>"u"?r:new Uint8Array(r)},n.Array=typeof Uint8Array<"u"?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(r){return r?n.LongBits.from(r).toHash():n.LongBits.zeroHash},n.longFromHash=function(r,i){var e=n.LongBits.fromHash(r);return n.Long?n.Long.fromBits(e.lo,e.hi,i):e.toNumber(!!i)};function u(o,r,i){for(var e=Object.keys(r),t=0;t<e.length;++t)(o[e[t]]===void 0||!i)&&(o[e[t]]=r[e[t]]);return o}n.merge=u,n.lcFirst=function(r){return r.charAt(0).toLowerCase()+r.substring(1)};function c(o){function r(i,e){if(!(this instanceof r))return new r(i,e);Object.defineProperty(this,"message",{get:function(){return i}}),Error.captureStackTrace?Error.captureStackTrace(this,r):Object.defineProperty(this,"stack",{value:new Error().stack||""}),e&&u(this,e)}return r.prototype=Object.create(Error.prototype,{constructor:{value:r,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return o},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),r}n.newError=c,n.ProtocolError=c("ProtocolError"),n.oneOfGetter=function(r){for(var i={},e=0;e<r.length;++e)i[r[e]]=1;return function(){for(var t=Object.keys(this),s=t.length-1;s>-1;--s)if(i[t[s]]===1&&this[t[s]]!==void 0&&this[t[s]]!==null)return t[s]}},n.oneOfSetter=function(r){return function(i){for(var e=0;e<r.length;++e)r[e]!==i&&delete this[r[e]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var o=n.Buffer;if(!o){n._Buffer_from=n._Buffer_allocUnsafe=null;return}n._Buffer_from=o.from!==Uint8Array.from&&o.from||function(i,e){return new o(i,e)},n._Buffer_allocUnsafe=o.allocUnsafe||function(i){return new o(i)}}}(minimal$1)),minimal$1}var writer,hasRequiredWriter;function requireWriter(){if(hasRequiredWriter)return writer;hasRequiredWriter=1,writer=t;var f=requireMinimal$1(),n,u=f.LongBits,c=f.base64,o=f.utf8;function r(v,m,g){this.fn=v,this.len=m,this.next=void 0,this.val=g}function i(){}function e(v){this.head=v.head,this.tail=v.tail,this.len=v.len,this.next=v.states}function t(){this.len=0,this.head=new r(i,0,0),this.tail=this.head,this.states=null}var s=function(){return f.Buffer?function(){return(t.create=function(){return new n})()}:function(){return new t}};t.create=s(),t.alloc=function(m){return new f.Array(m)},f.Array!==Array&&(t.alloc=f.pool(t.alloc,f.Array.prototype.subarray)),t.prototype._push=function(m,g,x){return this.tail=this.tail.next=new r(m,g,x),this.len+=g,this};function l(v,m,g){m[g]=v&255}function a(v,m,g){for(;v>127;)m[g++]=v&127|128,v>>>=7;m[g]=v}function d(v,m){this.len=v,this.next=void 0,this.val=m}d.prototype=Object.create(r.prototype),d.prototype.fn=a,t.prototype.uint32=function(m){return this.len+=(this.tail=this.tail.next=new d((m=m>>>0)<128?1:m<16384?2:m<2097152?3:m<268435456?4:5,m)).len,this},t.prototype.int32=function(m){return m<0?this._push(y,10,u.fromNumber(m)):this.uint32(m)},t.prototype.sint32=function(m){return this.uint32((m<<1^m>>31)>>>0)};function y(v,m,g){for(;v.hi;)m[g++]=v.lo&127|128,v.lo=(v.lo>>>7|v.hi<<25)>>>0,v.hi>>>=7;for(;v.lo>127;)m[g++]=v.lo&127|128,v.lo=v.lo>>>7;m[g++]=v.lo}t.prototype.uint64=function(m){var g=u.from(m);return this._push(y,g.length(),g)},t.prototype.int64=t.prototype.uint64,t.prototype.sint64=function(m){var g=u.from(m).zzEncode();return this._push(y,g.length(),g)},t.prototype.bool=function(m){return this._push(l,1,m?1:0)};function p(v,m,g){m[g]=v&255,m[g+1]=v>>>8&255,m[g+2]=v>>>16&255,m[g+3]=v>>>24}t.prototype.fixed32=function(m){return this._push(p,4,m>>>0)},t.prototype.sfixed32=t.prototype.fixed32,t.prototype.fixed64=function(m){var g=u.from(m);return this._push(p,4,g.lo)._push(p,4,g.hi)},t.prototype.sfixed64=t.prototype.fixed64,t.prototype.float=function(m){return this._push(f.float.writeFloatLE,4,m)},t.prototype.double=function(m){return this._push(f.float.writeDoubleLE,8,m)};var w=f.Array.prototype.set?function(m,g,x){g.set(m,x)}:function(m,g,x){for(var I=0;I<m.length;++I)g[x+I]=m[I]};return t.prototype.bytes=function(m){var g=m.length>>>0;if(!g)return this._push(l,1,0);if(f.isString(m)){var x=t.alloc(g=c.length(m));c.decode(m,x,0),m=x}return this.uint32(g)._push(w,g,m)},t.prototype.string=function(m){var g=o.length(m);return g?this.uint32(g)._push(o.write,g,m):this._push(l,1,0)},t.prototype.fork=function(){return this.states=new e(this),this.head=this.tail=new r(i,0,0),this.len=0,this},t.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new r(i,0,0),this.len=0),this},t.prototype.ldelim=function(){var m=this.head,g=this.tail,x=this.len;return this.reset().uint32(x),x&&(this.tail.next=m.next,this.tail=g,this.len+=x),this},t.prototype.finish=function(){for(var m=this.head.next,g=this.constructor.alloc(this.len),x=0;m;)m.fn(m.val,g,x),x+=m.len,m=m.next;return g},t._configure=function(v){n=v,t.create=s(),n._configure()},writer}var writer_buffer,hasRequiredWriter_buffer;function requireWriter_buffer(){if(hasRequiredWriter_buffer)return writer_buffer;hasRequiredWriter_buffer=1,writer_buffer=u;var f=requireWriter();(u.prototype=Object.create(f.prototype)).constructor=u;var n=requireMinimal$1();function u(){f.call(this)}u._configure=function(){u.alloc=n._Buffer_allocUnsafe,u.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&n.Buffer.prototype.set.name==="set"?function(r,i,e){i.set(r,e)}:function(r,i,e){if(r.copy)r.copy(i,e,0,r.length);else for(var t=0;t<r.length;)i[e++]=r[t++]}},u.prototype.bytes=function(r){n.isString(r)&&(r=n._Buffer_from(r,"base64"));var i=r.length>>>0;return this.uint32(i),i&&this._push(u.writeBytesBuffer,i,r),this};function c(o,r,i){o.length<40?n.utf8.write(o,r,i):r.utf8Write?r.utf8Write(o,i):r.write(o,i)}return u.prototype.string=function(r){var i=n.Buffer.byteLength(r);return this.uint32(i),i&&this._push(c,i,r),this},u._configure(),writer_buffer}var reader,hasRequiredReader;function requireReader(){if(hasRequiredReader)return reader;hasRequiredReader=1,reader=r;var f=requireMinimal$1(),n,u=f.LongBits,c=f.utf8;function o(a,d){return RangeError("index out of range: "+a.pos+" + "+(d||1)+" > "+a.len)}function r(a){this.buf=a,this.pos=0,this.len=a.length}var i=typeof Uint8Array<"u"?function(d){if(d instanceof Uint8Array||Array.isArray(d))return new r(d);throw Error("illegal buffer")}:function(d){if(Array.isArray(d))return new r(d);throw Error("illegal buffer")},e=function(){return f.Buffer?function(y){return(r.create=function(w){return f.Buffer.isBuffer(w)?new n(w):i(w)})(y)}:i};r.create=e(),r.prototype._slice=f.Array.prototype.subarray||f.Array.prototype.slice,r.prototype.uint32=function(){var d=4294967295;return function(){if(d=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(d=(d|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(d=(d|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return d;if((this.pos+=5)>this.len)throw this.pos=this.len,o(this,10);return d}}(),r.prototype.int32=function(){return this.uint32()|0},r.prototype.sint32=function(){var d=this.uint32();return d>>>1^-(d&1)|0};function t(){var a=new u(0,0),d=0;if(this.len-this.pos>4){for(;d<4;++d)if(a.lo=(a.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return a;if(a.lo=(a.lo|(this.buf[this.pos]&127)<<28)>>>0,a.hi=(a.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return a;d=0}else{for(;d<3;++d){if(this.pos>=this.len)throw o(this);if(a.lo=(a.lo|(this.buf[this.pos]&127)<<d*7)>>>0,this.buf[this.pos++]<128)return a}return a.lo=(a.lo|(this.buf[this.pos++]&127)<<d*7)>>>0,a}if(this.len-this.pos>4){for(;d<5;++d)if(a.hi=(a.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return a}else for(;d<5;++d){if(this.pos>=this.len)throw o(this);if(a.hi=(a.hi|(this.buf[this.pos]&127)<<d*7+3)>>>0,this.buf[this.pos++]<128)return a}throw Error("invalid varint encoding")}r.prototype.bool=function(){return this.uint32()!==0};function s(a,d){return(a[d-4]|a[d-3]<<8|a[d-2]<<16|a[d-1]<<24)>>>0}r.prototype.fixed32=function(){if(this.pos+4>this.len)throw o(this,4);return s(this.buf,this.pos+=4)},r.prototype.sfixed32=function(){if(this.pos+4>this.len)throw o(this,4);return s(this.buf,this.pos+=4)|0};function l(){if(this.pos+8>this.len)throw o(this,8);return new u(s(this.buf,this.pos+=4),s(this.buf,this.pos+=4))}return r.prototype.float=function(){if(this.pos+4>this.len)throw o(this,4);var d=f.float.readFloatLE(this.buf,this.pos);return this.pos+=4,d},r.prototype.double=function(){if(this.pos+8>this.len)throw o(this,4);var d=f.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,d},r.prototype.bytes=function(){var d=this.uint32(),y=this.pos,p=this.pos+d;if(p>this.len)throw o(this,d);if(this.pos+=d,Array.isArray(this.buf))return this.buf.slice(y,p);if(y===p){var w=f.Buffer;return w?w.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,y,p)},r.prototype.string=function(){var d=this.bytes();return c.read(d,0,d.length)},r.prototype.skip=function(d){if(typeof d=="number"){if(this.pos+d>this.len)throw o(this,d);this.pos+=d}else do if(this.pos>=this.len)throw o(this);while(this.buf[this.pos++]&128);return this},r.prototype.skipType=function(a){switch(a){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(a=this.uint32()&7)!==4;)this.skipType(a);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+a+" at offset "+this.pos)}return this},r._configure=function(a){n=a,r.create=e(),n._configure();var d=f.Long?"toLong":"toNumber";f.merge(r.prototype,{int64:function(){return t.call(this)[d](!1)},uint64:function(){return t.call(this)[d](!0)},sint64:function(){return t.call(this).zzDecode()[d](!1)},fixed64:function(){return l.call(this)[d](!0)},sfixed64:function(){return l.call(this)[d](!1)}})},reader}var reader_buffer,hasRequiredReader_buffer;function requireReader_buffer(){if(hasRequiredReader_buffer)return reader_buffer;hasRequiredReader_buffer=1,reader_buffer=u;var f=requireReader();(u.prototype=Object.create(f.prototype)).constructor=u;var n=requireMinimal$1();function u(c){f.call(this,c)}return u._configure=function(){n.Buffer&&(u.prototype._slice=n.Buffer.prototype.slice)},u.prototype.string=function(){var o=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+o,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+o,this.len))},u._configure(),reader_buffer}var rpc={},service,hasRequiredService;function requireService(){if(hasRequiredService)return service;hasRequiredService=1,service=n;var f=requireMinimal$1();(n.prototype=Object.create(f.EventEmitter.prototype)).constructor=n;function n(u,c,o){if(typeof u!="function")throw TypeError("rpcImpl must be a function");f.EventEmitter.call(this),this.rpcImpl=u,this.requestDelimited=!!c,this.responseDelimited=!!o}return n.prototype.rpcCall=function u(c,o,r,i,e){if(!i)throw TypeError("request must be specified");var t=this;if(!e)return f.asPromise(u,t,c,o,r,i);if(!t.rpcImpl){setTimeout(function(){e(Error("already ended"))},0);return}try{return t.rpcImpl(c,o[t.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(l,a){if(l)return t.emit("error",l,c),e(l);if(a===null){t.end(!0);return}if(!(a instanceof r))try{a=r[t.responseDelimited?"decodeDelimited":"decode"](a)}catch(d){return t.emit("error",d,c),e(d)}return t.emit("data",a,c),e(null,a)})}catch(s){t.emit("error",s,c),setTimeout(function(){e(s)},0);return}},n.prototype.end=function(c){return this.rpcImpl&&(c||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},service}var hasRequiredRpc;function requireRpc(){return hasRequiredRpc||(hasRequiredRpc=1,function(f){var n=f;n.Service=requireService()}(rpc)),rpc}var roots,hasRequiredRoots;function requireRoots(){return hasRequiredRoots||(hasRequiredRoots=1,roots={}),roots}var hasRequiredIndexMinimal;function requireIndexMinimal(){return hasRequiredIndexMinimal||(hasRequiredIndexMinimal=1,function(f){var n=f;n.build="minimal",n.Writer=requireWriter(),n.BufferWriter=requireWriter_buffer(),n.Reader=requireReader(),n.BufferReader=requireReader_buffer(),n.util=requireMinimal$1(),n.rpc=requireRpc(),n.roots=requireRoots(),n.configure=u;function u(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}u()}(indexMinimal)),indexMinimal}var minimal,hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,minimal=requireIndexMinimal()),minimal}var minimalExports=requireMinimal();const $Reader=minimalExports.Reader,$Writer=minimalExports.Writer,$util=minimalExports.util,$root=minimalExports.roots.default||(minimalExports.roots.default={}),com=$root.com=(()=>{const f={};return f.quick=function(){const n={};return n.voice=function(){const u={};return u.proto=function(){const c={};return c.SeiData=function(){function o(r){if(r)for(let i=Object.keys(r),e=0;e<i.length;++e)r[i[e]]!=null&&(this[i[e]]=r[i[e]])}return o.prototype.event=0,o.prototype.data=$util.newBuffer([]),o.prototype.compress=!1,o.prototype.version=0,o.create=function(i){return new o(i)},o.encode=function(i,e){return e||(e=$Writer.create()),i.event!=null&&Object.hasOwnProperty.call(i,"event")&&e.uint32(8).int32(i.event),i.data!=null&&Object.hasOwnProperty.call(i,"data")&&e.uint32(18).bytes(i.data),i.compress!=null&&Object.hasOwnProperty.call(i,"compress")&&e.uint32(24).bool(i.compress),i.version!=null&&Object.hasOwnProperty.call(i,"version")&&e.uint32(32).int32(i.version),e},o.encodeDelimited=function(i,e){return this.encode(i,e).ldelim()},o.decode=function(i,e,t){i instanceof $Reader||(i=$Reader.create(i));let s=e===void 0?i.len:i.pos+e,l=new $root.com.quick.voice.proto.SeiData;for(;i.pos<s;){let a=i.uint32();if(a===t)break;switch(a>>>3){case 1:{l.event=i.int32();break}case 2:{l.data=i.bytes();break}case 3:{l.compress=i.bool();break}case 4:{l.version=i.int32();break}default:i.skipType(a&7);break}}return l},o.decodeDelimited=function(i){return i instanceof $Reader||(i=new $Reader(i)),this.decode(i,i.uint32())},o.verify=function(i){if(typeof i!="object"||i===null)return"object expected";if(i.event!=null&&i.hasOwnProperty("event"))switch(i.event){default:return"event: enum value expected";case 0:case 1:break}return i.data!=null&&i.hasOwnProperty("data")&&!(i.data&&typeof i.data.length=="number"||$util.isString(i.data))?"data: buffer expected":i.compress!=null&&i.hasOwnProperty("compress")&&typeof i.compress!="boolean"?"compress: boolean expected":i.version!=null&&i.hasOwnProperty("version")&&!$util.isInteger(i.version)?"version: integer expected":null},o.fromObject=function(i){if(i instanceof $root.com.quick.voice.proto.SeiData)return i;let e=new $root.com.quick.voice.proto.SeiData;switch(i.event){default:if(typeof i.event=="number"){e.event=i.event;break}break;case"Layout":case 0:e.event=0;break;case"Custom":case 1:e.event=1;break}return i.data!=null&&(typeof i.data=="string"?$util.base64.decode(i.data,e.data=$util.newBuffer($util.base64.length(i.data)),0):i.data.length>=0&&(e.data=i.data)),i.compress!=null&&(e.compress=!!i.compress),i.version!=null&&(e.version=i.version|0),e},o.toObject=function(i,e){e||(e={});let t={};return e.defaults&&(t.event=e.enums===String?"Layout":0,e.bytes===String?t.data="":(t.data=[],e.bytes!==Array&&(t.data=$util.newBuffer(t.data))),t.compress=!1,t.version=0),i.event!=null&&i.hasOwnProperty("event")&&(t.event=e.enums===String?$root.com.quick.voice.proto.EventType[i.event]===void 0?i.event:$root.com.quick.voice.proto.EventType[i.event]:i.event),i.data!=null&&i.hasOwnProperty("data")&&(t.data=e.bytes===String?$util.base64.encode(i.data,0,i.data.length):e.bytes===Array?Array.prototype.slice.call(i.data):i.data),i.compress!=null&&i.hasOwnProperty("compress")&&(t.compress=i.compress),i.version!=null&&i.hasOwnProperty("version")&&(t.version=i.version),t},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(i){return i===void 0&&(i="type.googleapis.com"),i+"/com.quick.voice.proto.SeiData"},o}(),c.EventType=function(){const o={},r=Object.create(o);return r[o[0]="Layout"]=0,r[o[1]="Custom"]=1,r}(),c.LayoutData=function(){function o(i){if(this.userMap={},i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.roomId="",o.prototype.type=0,o.prototype.userMap=$util.emptyObject,o.prototype.globalCustom=null;let r;return Object.defineProperty(o.prototype,"_globalCustom",{get:$util.oneOfGetter(r=["globalCustom"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){if(t||(t=$Writer.create()),e.roomId!=null&&Object.hasOwnProperty.call(e,"roomId")&&t.uint32(10).string(e.roomId),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(16).int32(e.type),e.userMap!=null&&Object.hasOwnProperty.call(e,"userMap"))for(let s=Object.keys(e.userMap),l=0;l<s.length;++l)t.uint32(26).fork().uint32(10).string(s[l]),$root.com.quick.voice.proto.UserInfo.encode(e.userMap[s[l]],t.uint32(18).fork()).ldelim().ldelim();return e.globalCustom!=null&&Object.hasOwnProperty.call(e,"globalCustom")&&$root.com.quick.voice.proto.CustomInfo.encode(e.globalCustom,t.uint32(34).fork()).ldelim(),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.LayoutData,d,y;for(;e.pos<l;){let p=e.uint32();if(p===s)break;switch(p>>>3){case 1:{a.roomId=e.string();break}case 2:{a.type=e.int32();break}case 3:{a.userMap===$util.emptyObject&&(a.userMap={});let w=e.uint32()+e.pos;for(d="",y=null;e.pos<w;){let v=e.uint32();switch(v>>>3){case 1:d=e.string();break;case 2:y=$root.com.quick.voice.proto.UserInfo.decode(e,e.uint32());break;default:e.skipType(v&7);break}}a.userMap[d]=y;break}case 4:{a.globalCustom=$root.com.quick.voice.proto.CustomInfo.decode(e,e.uint32());break}default:e.skipType(p&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.roomId!=null&&e.hasOwnProperty("roomId")&&!$util.isString(e.roomId))return"roomId: string expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:case 2:break}if(e.userMap!=null&&e.hasOwnProperty("userMap")){if(!$util.isObject(e.userMap))return"userMap: object expected";let t=Object.keys(e.userMap);for(let s=0;s<t.length;++s){let l=$root.com.quick.voice.proto.UserInfo.verify(e.userMap[t[s]]);if(l)return"userMap."+l}}if(e.globalCustom!=null&&e.hasOwnProperty("globalCustom")){let t=$root.com.quick.voice.proto.CustomInfo.verify(e.globalCustom);if(t)return"globalCustom."+t}return null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.LayoutData)return e;let t=new $root.com.quick.voice.proto.LayoutData;switch(e.roomId!=null&&(t.roomId=String(e.roomId)),e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"AudioAndVideo":case 0:t.type=0;break;case"OnlyAudio":case 1:t.type=1;break;case"OnlyVideo":case 2:t.type=2;break}if(e.userMap){if(typeof e.userMap!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");t.userMap={};for(let s=Object.keys(e.userMap),l=0;l<s.length;++l){if(typeof e.userMap[s[l]]!="object")throw TypeError(".com.quick.voice.proto.LayoutData.userMap: object expected");t.userMap[s[l]]=$root.com.quick.voice.proto.UserInfo.fromObject(e.userMap[s[l]])}}if(e.globalCustom!=null){if(typeof e.globalCustom!="object")throw TypeError(".com.quick.voice.proto.LayoutData.globalCustom: object expected");t.globalCustom=$root.com.quick.voice.proto.CustomInfo.fromObject(e.globalCustom)}return t},o.toObject=function(e,t){t||(t={});let s={};(t.objects||t.defaults)&&(s.userMap={}),t.defaults&&(s.roomId="",s.type=t.enums===String?"AudioAndVideo":0),e.roomId!=null&&e.hasOwnProperty("roomId")&&(s.roomId=e.roomId),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.LayoutType[e.type]===void 0?e.type:$root.com.quick.voice.proto.LayoutType[e.type]:e.type);let l;if(e.userMap&&(l=Object.keys(e.userMap)).length){s.userMap={};for(let a=0;a<l.length;++a)s.userMap[l[a]]=$root.com.quick.voice.proto.UserInfo.toObject(e.userMap[l[a]],t)}return e.globalCustom!=null&&e.hasOwnProperty("globalCustom")&&(s.globalCustom=$root.com.quick.voice.proto.CustomInfo.toObject(e.globalCustom,t),t.oneofs&&(s._globalCustom="globalCustom")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.LayoutData"},o}(),c.UserInfo=function(){function o(i){if(this.audios=[],this.videos=[],i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.id="",o.prototype.audios=$util.emptyArray,o.prototype.videos=$util.emptyArray,o.prototype.custom=null;let r;return Object.defineProperty(o.prototype,"_custom",{get:$util.oneOfGetter(r=["custom"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){if(t||(t=$Writer.create()),e.id!=null&&Object.hasOwnProperty.call(e,"id")&&t.uint32(10).string(e.id),e.audios!=null&&e.audios.length)for(let s=0;s<e.audios.length;++s)$root.com.quick.voice.proto.AudioInfo.encode(e.audios[s],t.uint32(18).fork()).ldelim();if(e.videos!=null&&e.videos.length)for(let s=0;s<e.videos.length;++s)$root.com.quick.voice.proto.VideoInfo.encode(e.videos[s],t.uint32(26).fork()).ldelim();return e.custom!=null&&Object.hasOwnProperty.call(e,"custom")&&$root.com.quick.voice.proto.CustomInfo.encode(e.custom,t.uint32(34).fork()).ldelim(),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.UserInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{a.id=e.string();break}case 2:{a.audios&&a.audios.length||(a.audios=[]),a.audios.push($root.com.quick.voice.proto.AudioInfo.decode(e,e.uint32()));break}case 3:{a.videos&&a.videos.length||(a.videos=[]),a.videos.push($root.com.quick.voice.proto.VideoInfo.decode(e,e.uint32()));break}case 4:{a.custom=$root.com.quick.voice.proto.CustomInfo.decode(e,e.uint32());break}default:e.skipType(d&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.id!=null&&e.hasOwnProperty("id")&&!$util.isString(e.id))return"id: string expected";if(e.audios!=null&&e.hasOwnProperty("audios")){if(!Array.isArray(e.audios))return"audios: array expected";for(let t=0;t<e.audios.length;++t){let s=$root.com.quick.voice.proto.AudioInfo.verify(e.audios[t]);if(s)return"audios."+s}}if(e.videos!=null&&e.hasOwnProperty("videos")){if(!Array.isArray(e.videos))return"videos: array expected";for(let t=0;t<e.videos.length;++t){let s=$root.com.quick.voice.proto.VideoInfo.verify(e.videos[t]);if(s)return"videos."+s}}if(e.custom!=null&&e.hasOwnProperty("custom")){let t=$root.com.quick.voice.proto.CustomInfo.verify(e.custom);if(t)return"custom."+t}return null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.UserInfo)return e;let t=new $root.com.quick.voice.proto.UserInfo;if(e.id!=null&&(t.id=String(e.id)),e.audios){if(!Array.isArray(e.audios))throw TypeError(".com.quick.voice.proto.UserInfo.audios: array expected");t.audios=[];for(let s=0;s<e.audios.length;++s){if(typeof e.audios[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.audios: object expected");t.audios[s]=$root.com.quick.voice.proto.AudioInfo.fromObject(e.audios[s])}}if(e.videos){if(!Array.isArray(e.videos))throw TypeError(".com.quick.voice.proto.UserInfo.videos: array expected");t.videos=[];for(let s=0;s<e.videos.length;++s){if(typeof e.videos[s]!="object")throw TypeError(".com.quick.voice.proto.UserInfo.videos: object expected");t.videos[s]=$root.com.quick.voice.proto.VideoInfo.fromObject(e.videos[s])}}if(e.custom!=null){if(typeof e.custom!="object")throw TypeError(".com.quick.voice.proto.UserInfo.custom: object expected");t.custom=$root.com.quick.voice.proto.CustomInfo.fromObject(e.custom)}return t},o.toObject=function(e,t){t||(t={});let s={};if((t.arrays||t.defaults)&&(s.audios=[],s.videos=[]),t.defaults&&(s.id=""),e.id!=null&&e.hasOwnProperty("id")&&(s.id=e.id),e.audios&&e.audios.length){s.audios=[];for(let l=0;l<e.audios.length;++l)s.audios[l]=$root.com.quick.voice.proto.AudioInfo.toObject(e.audios[l],t)}if(e.videos&&e.videos.length){s.videos=[];for(let l=0;l<e.videos.length;++l)s.videos[l]=$root.com.quick.voice.proto.VideoInfo.toObject(e.videos[l],t)}return e.custom!=null&&e.hasOwnProperty("custom")&&(s.custom=$root.com.quick.voice.proto.CustomInfo.toObject(e.custom,t),t.oneofs&&(s._custom="custom")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.UserInfo"},o}(),c.AudioInfo=function(){function o(i){if(i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.type=0,o.prototype.isEnable=!1,o.prototype.isMute=!1,o.prototype.volume=0,o.prototype.updateTime=null;let r;return Object.defineProperty(o.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=$Writer.create()),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),e.isEnable!=null&&Object.hasOwnProperty.call(e,"isEnable")&&t.uint32(16).bool(e.isEnable),e.isMute!=null&&Object.hasOwnProperty.call(e,"isMute")&&t.uint32(24).bool(e.isMute),e.volume!=null&&Object.hasOwnProperty.call(e,"volume")&&t.uint32(33).double(e.volume),e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(40).int64(e.updateTime),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.AudioInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{a.type=e.int32();break}case 2:{a.isEnable=e.bool();break}case 3:{a.isMute=e.bool();break}case 4:{a.volume=e.double();break}case 5:{a.updateTime=e.int64();break}default:e.skipType(d&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:break}return e.isEnable!=null&&e.hasOwnProperty("isEnable")&&typeof e.isEnable!="boolean"?"isEnable: boolean expected":e.isMute!=null&&e.hasOwnProperty("isMute")&&typeof e.isMute!="boolean"?"isMute: boolean expected":e.volume!=null&&e.hasOwnProperty("volume")&&typeof e.volume!="number"?"volume: number expected":e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.AudioInfo)return e;let t=new $root.com.quick.voice.proto.AudioInfo;switch(e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"Microphone":case 0:t.type=0;break;case"SystemVoice":case 1:t.type=1;break}return e.isEnable!=null&&(t.isEnable=!!e.isEnable),e.isMute!=null&&(t.isMute=!!e.isMute),e.volume!=null&&(t.volume=Number(e.volume)),e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},o.toObject=function(e,t){t||(t={});let s={};return t.defaults&&(s.type=t.enums===String?"Microphone":0,s.isEnable=!1,s.isMute=!1,s.volume=0),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.AudioType[e.type]===void 0?e.type:$root.com.quick.voice.proto.AudioType[e.type]:e.type),e.isEnable!=null&&e.hasOwnProperty("isEnable")&&(s.isEnable=e.isEnable),e.isMute!=null&&e.hasOwnProperty("isMute")&&(s.isMute=e.isMute),e.volume!=null&&e.hasOwnProperty("volume")&&(s.volume=t.json&&!isFinite(e.volume)?String(e.volume):e.volume),e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.AudioInfo"},o}(),c.VideoInfo=function(){function o(i){if(i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.type=0,o.prototype.isEnable=!1,o.prototype.isMute=!1,o.prototype.width=0,o.prototype.height=0,o.prototype.x=0,o.prototype.y=0,o.prototype.updateTime=null;let r;return Object.defineProperty(o.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=$Writer.create()),e.type!=null&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),e.isEnable!=null&&Object.hasOwnProperty.call(e,"isEnable")&&t.uint32(16).bool(e.isEnable),e.isMute!=null&&Object.hasOwnProperty.call(e,"isMute")&&t.uint32(24).bool(e.isMute),e.width!=null&&Object.hasOwnProperty.call(e,"width")&&t.uint32(32).int32(e.width),e.height!=null&&Object.hasOwnProperty.call(e,"height")&&t.uint32(40).int32(e.height),e.x!=null&&Object.hasOwnProperty.call(e,"x")&&t.uint32(48).int32(e.x),e.y!=null&&Object.hasOwnProperty.call(e,"y")&&t.uint32(56).int32(e.y),e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(64).int64(e.updateTime),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.VideoInfo;for(;e.pos<l;){let d=e.uint32();if(d===s)break;switch(d>>>3){case 1:{a.type=e.int32();break}case 2:{a.isEnable=e.bool();break}case 3:{a.isMute=e.bool();break}case 4:{a.width=e.int32();break}case 5:{a.height=e.int32();break}case 6:{a.x=e.int32();break}case 7:{a.y=e.int32();break}case 8:{a.updateTime=e.int64();break}default:e.skipType(d&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.type!=null&&e.hasOwnProperty("type"))switch(e.type){default:return"type: enum value expected";case 0:case 1:break}return e.isEnable!=null&&e.hasOwnProperty("isEnable")&&typeof e.isEnable!="boolean"?"isEnable: boolean expected":e.isMute!=null&&e.hasOwnProperty("isMute")&&typeof e.isMute!="boolean"?"isMute: boolean expected":e.width!=null&&e.hasOwnProperty("width")&&!$util.isInteger(e.width)?"width: integer expected":e.height!=null&&e.hasOwnProperty("height")&&!$util.isInteger(e.height)?"height: integer expected":e.x!=null&&e.hasOwnProperty("x")&&!$util.isInteger(e.x)?"x: integer expected":e.y!=null&&e.hasOwnProperty("y")&&!$util.isInteger(e.y)?"y: integer expected":e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.VideoInfo)return e;let t=new $root.com.quick.voice.proto.VideoInfo;switch(e.type){default:if(typeof e.type=="number"){t.type=e.type;break}break;case"Camera":case 0:t.type=0;break;case"Screen":case 1:t.type=1;break}return e.isEnable!=null&&(t.isEnable=!!e.isEnable),e.isMute!=null&&(t.isMute=!!e.isMute),e.width!=null&&(t.width=e.width|0),e.height!=null&&(t.height=e.height|0),e.x!=null&&(t.x=e.x|0),e.y!=null&&(t.y=e.y|0),e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},o.toObject=function(e,t){t||(t={});let s={};return t.defaults&&(s.type=t.enums===String?"Camera":0,s.isEnable=!1,s.isMute=!1,s.width=0,s.height=0,s.x=0,s.y=0),e.type!=null&&e.hasOwnProperty("type")&&(s.type=t.enums===String?$root.com.quick.voice.proto.VideoType[e.type]===void 0?e.type:$root.com.quick.voice.proto.VideoType[e.type]:e.type),e.isEnable!=null&&e.hasOwnProperty("isEnable")&&(s.isEnable=e.isEnable),e.isMute!=null&&e.hasOwnProperty("isMute")&&(s.isMute=e.isMute),e.width!=null&&e.hasOwnProperty("width")&&(s.width=e.width),e.height!=null&&e.hasOwnProperty("height")&&(s.height=e.height),e.x!=null&&e.hasOwnProperty("x")&&(s.x=e.x),e.y!=null&&e.hasOwnProperty("y")&&(s.y=e.y),e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.VideoInfo"},o}(),c.CustomInfo=function(){function o(i){if(this.customKeyMap={},i)for(let e=Object.keys(i),t=0;t<e.length;++t)i[e[t]]!=null&&(this[e[t]]=i[e[t]])}o.prototype.roomId="",o.prototype.customKeyMap=$util.emptyObject,o.prototype.updateTime=null;let r;return Object.defineProperty(o.prototype,"_updateTime",{get:$util.oneOfGetter(r=["updateTime"]),set:$util.oneOfSetter(r)}),o.create=function(e){return new o(e)},o.encode=function(e,t){if(t||(t=$Writer.create()),e.roomId!=null&&Object.hasOwnProperty.call(e,"roomId")&&t.uint32(10).string(e.roomId),e.customKeyMap!=null&&Object.hasOwnProperty.call(e,"customKeyMap"))for(let s=Object.keys(e.customKeyMap),l=0;l<s.length;++l)t.uint32(18).fork().uint32(10).string(s[l]).uint32(18).string(e.customKeyMap[s[l]]).ldelim();return e.updateTime!=null&&Object.hasOwnProperty.call(e,"updateTime")&&t.uint32(24).int64(e.updateTime),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,t,s){e instanceof $Reader||(e=$Reader.create(e));let l=t===void 0?e.len:e.pos+t,a=new $root.com.quick.voice.proto.CustomInfo,d,y;for(;e.pos<l;){let p=e.uint32();if(p===s)break;switch(p>>>3){case 1:{a.roomId=e.string();break}case 2:{a.customKeyMap===$util.emptyObject&&(a.customKeyMap={});let w=e.uint32()+e.pos;for(d="",y="";e.pos<w;){let v=e.uint32();switch(v>>>3){case 1:d=e.string();break;case 2:y=e.string();break;default:e.skipType(v&7);break}}a.customKeyMap[d]=y;break}case 3:{a.updateTime=e.int64();break}default:e.skipType(p&7);break}}return a},o.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},o.verify=function(e){if(typeof e!="object"||e===null)return"object expected";if(e.roomId!=null&&e.hasOwnProperty("roomId")&&!$util.isString(e.roomId))return"roomId: string expected";if(e.customKeyMap!=null&&e.hasOwnProperty("customKeyMap")){if(!$util.isObject(e.customKeyMap))return"customKeyMap: object expected";let t=Object.keys(e.customKeyMap);for(let s=0;s<t.length;++s)if(!$util.isString(e.customKeyMap[t[s]]))return"customKeyMap: string{k:string} expected"}return e.updateTime!=null&&e.hasOwnProperty("updateTime")&&!$util.isInteger(e.updateTime)&&!(e.updateTime&&$util.isInteger(e.updateTime.low)&&$util.isInteger(e.updateTime.high))?"updateTime: integer|Long expected":null},o.fromObject=function(e){if(e instanceof $root.com.quick.voice.proto.CustomInfo)return e;let t=new $root.com.quick.voice.proto.CustomInfo;if(e.roomId!=null&&(t.roomId=String(e.roomId)),e.customKeyMap){if(typeof e.customKeyMap!="object")throw TypeError(".com.quick.voice.proto.CustomInfo.customKeyMap: object expected");t.customKeyMap={};for(let s=Object.keys(e.customKeyMap),l=0;l<s.length;++l)t.customKeyMap[s[l]]=String(e.customKeyMap[s[l]])}return e.updateTime!=null&&($util.Long?(t.updateTime=$util.Long.fromValue(e.updateTime)).unsigned=!1:typeof e.updateTime=="string"?t.updateTime=parseInt(e.updateTime,10):typeof e.updateTime=="number"?t.updateTime=e.updateTime:typeof e.updateTime=="object"&&(t.updateTime=new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber())),t},o.toObject=function(e,t){t||(t={});let s={};(t.objects||t.defaults)&&(s.customKeyMap={}),t.defaults&&(s.roomId=""),e.roomId!=null&&e.hasOwnProperty("roomId")&&(s.roomId=e.roomId);let l;if(e.customKeyMap&&(l=Object.keys(e.customKeyMap)).length){s.customKeyMap={};for(let a=0;a<l.length;++a)s.customKeyMap[l[a]]=e.customKeyMap[l[a]]}return e.updateTime!=null&&e.hasOwnProperty("updateTime")&&(typeof e.updateTime=="number"?s.updateTime=t.longs===String?String(e.updateTime):e.updateTime:s.updateTime=t.longs===String?$util.Long.prototype.toString.call(e.updateTime):t.longs===Number?new $util.LongBits(e.updateTime.low>>>0,e.updateTime.high>>>0).toNumber():e.updateTime,t.oneofs&&(s._updateTime="updateTime")),s},o.prototype.toJSON=function(){return this.constructor.toObject(this,minimalExports.util.toJSONOptions)},o.getTypeUrl=function(e){return e===void 0&&(e="type.googleapis.com"),e+"/com.quick.voice.proto.CustomInfo"},o}(),c.LayoutType=function(){const o={},r=Object.create(o);return r[o[0]="AudioAndVideo"]=0,r[o[1]="OnlyAudio"]=1,r[o[2]="OnlyVideo"]=2,r}(),c.AudioType=function(){const o={},r=Object.create(o);return r[o[0]="Microphone"]=0,r[o[1]="SystemVoice"]=1,r}(),c.VideoType=function(){const o={},r=Object.create(o);return r[o[0]="Camera"]=0,r[o[1]="Screen"]=1,r}(),c}(),u}(),n}(),f})(),createAudioInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,volume:0}),createVideoInfo=()=>({remove:!1,isEnable:!1,updateTime:0,isMute:!1,sx:0,sy:0,sw:0,sh:0});class RoomUser{constructor(){b(this,"userId","");b(this,"mc_audio");b(this,"mc_video");b(this,"ss_audio");b(this,"ss_video");b(this,"updateTime",0);b(this,"getUpdateTimeKey",()=>{const n=[];return this.mc_audio&&n.push(this.mc_audio.updateTime),this.mc_video&&n.push(this.mc_video.updateTime),this.ss_audio&&n.push(this.ss_audio.updateTime),this.ss_video&&n.push(this.ss_video.updateTime),n.join("_")});b(this,"init",n=>{var e,t,s,l;const{id:u,audios:c=[],videos:o=[]}=n;this.userId=u;const r=this.getUpdateTimeKey();this.mc_audio&&(this.mc_audio.remove=!0),this.mc_video&&(this.mc_video.remove=!0),this.ss_audio&&(this.ss_audio.remove=!0),this.ss_video&&(this.ss_video.remove=!0);for(const a of c){const{type:d=0,isEnable:y=!1,isMute:p=!1,updateTime:w,volume:v=0}=a;switch(d){case 0:{if(this.mc_audio||(this.mc_audio=createAudioInfo()),this.mc_audio.remove=!1,this.mc_audio.updateTime===w)break;this.mc_audio.isEnable=!!y,this.mc_audio.isMute=!!p,this.mc_audio.updateTime=Number(w),this.mc_audio.volume=Number(v)}break;case 1:{if(this.ss_audio||(this.ss_audio=createAudioInfo()),this.ss_audio.remove=!1,this.ss_audio.updateTime===w)break;this.ss_audio.isEnable=!!y,this.ss_audio.isMute=!!p,this.ss_audio.updateTime=Number(w),this.ss_audio.volume=Number(v)}break}}for(const a of o){const{type:d=0,isEnable:y,isMute:p,updateTime:w,width:v,height:m,x:g,y:x}=a;switch(d){case 0:{if(this.mc_video||(this.mc_video=createVideoInfo()),this.mc_video.remove=!1,this.mc_video.updateTime===w)break;this.mc_video.isEnable=!!y,this.mc_video.isMute=!!p,this.mc_video.updateTime=Number(w)||0,this.mc_video.sx=g||0,this.mc_video.sy=x||0,this.mc_video.sw=v||0,this.mc_video.sh=m||0}break;case 1:{if(this.ss_video||(this.ss_video=createVideoInfo()),this.ss_video.remove=!1,this.ss_video.updateTime===w)break;this.ss_video.isEnable=!!y,this.ss_video.isMute=!!p,this.ss_video.updateTime=Number(w)||0,this.ss_video.sx=g||0,this.ss_video.sy=x||0,this.ss_video.sw=v||0,this.ss_video.sh=m||0}break}}(e=this.mc_audio)!=null&&e.remove&&(this.mc_audio=void 0),(t=this.mc_video)!=null&&t.remove&&(this.mc_video=void 0),(s=this.ss_audio)!=null&&s.remove&&(this.ss_audio=void 0),(l=this.ss_video)!=null&&l.remove&&(this.ss_video=void 0);const i=this.getUpdateTimeKey();r!==i&&(this.updateTime=new Date().getTime())});b(this,"destroy",()=>{var n,u;(n=this.mc_video)!=null&&n.destroy&&this.mc_video.destroy(),(u=this.ss_video)!=null&&u.destroy&&this.ss_video.destroy(),this.mc_audio=void 0,this.mc_video=void 0,this.ss_audio=void 0,this.ss_video=void 0})}}const parseSEI=f=>{let n=0,u=0;for(;;){const o=f[n];if(u=u+o,n=n+1,o!==255)break}let c=0;for(;;){const o=f[n];if(c=c+o,n=n+1,o!==255)break}if(u===5){const o=f.slice(n,n+16),i=Array.from(o,p=>p.toString(16).padStart(2,"0")).join("");n=n+16;const e=c-16,t=f.slice(n,n+e),s=com.quick.voice.proto.SeiData.decode(t),{event:l=0}=s,a=s.data;let d;switch(l){case 0:d=com.quick.voice.proto.LayoutData.decode(s.data);break;case 1:d=com.quick.voice.proto.CustomInfo.decode(s.data);break}return{uuid:i,...s,event:l,data_remote:a,data:d}}};class QuickVoPlayer{constructor(){b(this,"displayMode","original");b(this,"prPlayer",new be);b(this,"dom");b(this,"room",{roomId:"",updateTime:"",author:"",version:""});b(this,"usersMap",new Map);b(this,"on",{users:n=>{}});b(this,"init",()=>{this.prPlayer.init()});b(this,"start",async n=>(this.stop(),this.prPlayer.start(n)));b(this,"stop",()=>{this.prPlayer.stop(),this.usersMap=new Map,this.room.roomId="",this.room.author="",this.room.updateTime="",this.room.version=""});b(this,"setMute",n=>{this.prPlayer.setMute(n)});b(this,"getStream",()=>this.prPlayer.getStream());b(this,"getAllUseUpdateKey",()=>{const n=[...this.usersMap.values()];return Array.from(n,c=>c.updateTime).join("_")});b(this,"checkAndCreateUser",(n,u)=>{var c,o;if(this.usersMap.has(n)){const r=this.usersMap.get(n);if(r==null||r.init(u),r!=null&&r.mc_video){const{sx:i,sy:e,sw:t,sh:s}=r.mc_video;(c=r==null?void 0:r.mc_video.worker)==null||c.setCut({sx:i,sy:e,sw:t,sh:s})}if(r!=null&&r.ss_video){const{sx:i,sy:e,sw:t,sh:s}=r.ss_video;(o=r==null?void 0:r.ss_video.worker)==null||o.setCut({sx:i,sy:e,sw:t,sh:s})}}else{const r=new RoomUser;if(this.usersMap.set(n,r),r.init(u),r){if(r.mc_video){const{sx:i,sy:e,sw:t,sh:s}=r.mc_video,l=`${r.userId}_mc_video`,{worker:a,stream:d,destroy:y}=this.prPlayer.cut.create(l,{sx:i,sy:e,sw:t,sh:s});r.mc_video.worker=a,this.displayMode==="original"&&a.setPause(!0),r.mc_video.stream=d,r.mc_video.destroy=()=>{y(),this.prPlayer.cut.remove(l),this.usersMap.delete(r.userId)}}if(r.ss_video){const{sx:i,sy:e,sw:t,sh:s}=r.ss_video,l=`${r.userId}_ss_video`,{worker:a,stream:d,destroy:y}=this.prPlayer.cut.create(l,{sx:i,sy:e,sw:t,sh:s});r.ss_video.worker=a,this.displayMode==="original"&&a.setPause(!0),r.ss_video.stream=d,r.ss_video.destroy=()=>{y(),this.prPlayer.cut.remove(l),this.usersMap.delete(r.userId)}}}}});b(this,"onSEI",n=>{try{const u=parseSEI(n);if(!u)return;const{event:c,data:o}=u;switch(c){case 0:{const{roomId:r,userMap:i}=o;if(r!==this.room.roomId)return;const e=this.getAllUseUpdateKey(),t=Object.keys(i);{const l=[...this.usersMap.values()];for(const a of l)t.includes(a.userId)||a==null||a.destroy()}for(const l of t){const a=i[l];this.checkAndCreateUser(l,a)}const s=this.getAllUseUpdateKey();if(e!==s&&this.on.users){const l=[...this.usersMap.values()],a=Array.from(l,({userId:d,mc_audio:y,mc_video:p,ss_audio:w,ss_video:v,updateTime:m})=>({userId:d,mc_audio:y,mc_video:p,ss_audio:w,ss_video:v,updateTime:m}));this.on.users(a)}}break;case 1:{const{roomId:r,updateTime:i}=o,{author:e,version:t}=o.customKeyMap;this.room.roomId=r,this.room.updateTime=i,this.room.author=e,this.room.version=t}break}}catch(u){console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m","color:#0097ff;","------->onSEI: error",u)}});b(this,"setDisplayMode",n=>{var u,c,o,r,i,e,t,s;switch(this.displayMode=n,n){case"original":{this.prPlayer.setPause(!1);const l=[...this.usersMap.values()];for(const a of l)(c=(u=a.mc_video)==null?void 0:u.worker)==null||c.setPause(!0),(r=(o=a.ss_video)==null?void 0:o.worker)==null||r.setPause(!0)}break;case"cut":{this.prPlayer.setPause(!0);const l=[...this.usersMap.values()];for(const a of l)(e=(i=a.mc_video)==null?void 0:i.worker)==null||e.setPause(!1),(s=(t=a.ss_video)==null?void 0:t.worker)==null||s.setPause(!1)}break}});this.prPlayer.on.demuxer.sei=this.onSEI}}exports.QuickVoPlayer=QuickVoPlayer,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quickvo-player",
3
3
  "description": "基于web-codecs解码flv视频流并输出帧数据。",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -19,7 +19,7 @@
19
19
  "build": "tsc && vite build"
20
20
  },
21
21
  "dependencies": {
22
- "pr-player": "^0.0.8",
22
+ "pr-player": "^0.1.0",
23
23
  "protobufjs": "^7.5.4"
24
24
  },
25
25
  "devDependencies": {