quickvo-player 0.2.8 → 0.2.9

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
@@ -2,20 +2,20 @@ var Q = Object.defineProperty;
2
2
  var X = (h) => {
3
3
  throw TypeError(h);
4
4
  };
5
- var tt = (h, o, a) => o in h ? Q(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a;
6
- var m = (h, o, a) => tt(h, typeof o != "symbol" ? o + "" : o, a), Z = (h, o, a) => o.has(h) || X("Cannot " + a);
7
- var I = (h, o, a) => (Z(h, o, "read from private field"), a ? a.call(h) : o.get(h)), J = (h, o, a) => o.has(h) ? X("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, a), H = (h, o, a, u) => (Z(h, o, "write to private field"), u ? u.call(h, a) : o.set(h, a), a);
5
+ var tt = (h, o, u) => o in h ? Q(h, o, { enumerable: !0, configurable: !0, writable: !0, value: u }) : h[o] = u;
6
+ var m = (h, o, u) => tt(h, typeof o != "symbol" ? o + "" : o, u), Z = (h, o, u) => o.has(h) || X("Cannot " + u);
7
+ var I = (h, o, u) => (Z(h, o, "read from private field"), u ? u.call(h) : o.get(h)), J = (h, o, u) => o.has(h) ? X("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, u), H = (h, o, u, a) => (Z(h, o, "write to private field"), a ? a.call(h, u) : o.set(h, u), u);
8
8
  const D = '(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const h=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:h,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:l,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:h=[]}=this.pat||{};if(h.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(h=>h.elementary_pid===o);if(p){if(l===1){const h=this.payloadMap.get(o);if(h){switch(p.kind){case"audio":{const d=await this.parseAudio(h);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(h);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),0))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const h=this.payloadMap.get(o),d=new Uint8Array(h.byteLength+r.byteLength);d.set(h,0),d.set(r,h.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),l=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(l&192)>>6,h=l>>4&3,d=l&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:h,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d}}const a=[];{const l=n.section_length-5-4,i=e+l;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const l=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const h=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:l,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:h,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const l=n.section_length-9-4,i=e+l;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,l;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),h=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),h&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,l=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:h,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:l}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig&&s.getUint8(e)===255){const g=s.getUint8(e+2),p=s.getUint8(e+3);let h,d;d=g>>2&15,h=(g&1)<<2|p>>6;const u=`mp4a.40.${h}`,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][d];this.audioConfig={kind:"audio",codec:u,sampleRate:U,numberOfChannels:h},this.on.config&&this.on.config(this.audioConfig)}const{dts:o=0,pts:l=0}=n,i=l-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:l,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const l=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,h;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,h=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:l,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:h,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let h,d;if(h=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),h&&d){const u=I(h,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:h,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const l=[];let i="delta";for(const h of o){const{type:d,nalu:u}=h;switch(d){case 6:case 9:l.push(u);break;case 1:i="delta",l.push(u);break;case 5:i="key",l.push(u);break}}const c=C(l),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:l}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),l=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(l)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const l=t.slice(n,n+o),i=M(l);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:l}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",h=r===void 0?void 0:r+l;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:l,pts:h,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:h}=i;this.videoConfig={kind:"video",codec:r,description:h,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:h}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+l;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:l,pts:u,cts:g,data:p,nalus:h})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,l;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),l=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:l}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const l=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(l)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const h=t.getUint8(n),d=t.getUint8(n+1),u=h>>3&31,f=(h&7)<<1|d>>7,U=d>>3&15,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:l,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,l=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(l){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],h=n+e-5;for(;!(n+4>h);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:l,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const h=this.getAMFValue(t,n,p);n=n+h.length,a[g]=h.value,o=2+r+1+h.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class O{pattern;cacher=new P;isParseing=!1;offset=0;parser;on={};constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new O;A.on.info=y=>postMessage({action:"on.info",data:y}),A.on.config=y=>postMessage({action:"on.config",data:y}),A.on.chunk=y=>postMessage({action:"on.chunk",data:y}),A.on.debug=y=>postMessage({action:"on.debug",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n', _ = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
9
9
  function L(h) {
10
10
  let o;
11
11
  try {
12
12
  if (o = _ && (self.URL || self.webkitURL).createObjectURL(_), !o) throw "";
13
- const a = new Worker(o, {
13
+ const u = new Worker(o, {
14
14
  name: h == null ? void 0 : h.name
15
15
  });
16
- return a.addEventListener("error", () => {
16
+ return u.addEventListener("error", () => {
17
17
  (self.URL || self.webkitURL).revokeObjectURL(o);
18
- }), a;
18
+ }), u;
19
19
  } catch {
20
20
  return new Worker(
21
21
  "data:text/javascript;charset=utf-8," + encodeURIComponent(D),
@@ -35,19 +35,19 @@ class V {
35
35
  this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
36
36
  });
37
37
  this.worker.onmessage = (o) => {
38
- const { action: a, data: u } = o.data;
39
- switch (a) {
38
+ const { action: u, data: a } = o.data;
39
+ switch (u) {
40
40
  case "on.info":
41
- this.on.info && this.on.info(u);
41
+ this.on.info && this.on.info(a);
42
42
  break;
43
43
  case "on.config":
44
- this.on.config && this.on.config(u);
44
+ this.on.config && this.on.config(a);
45
45
  break;
46
46
  case "on.chunk":
47
- this.on.chunk && this.on.chunk(u);
47
+ this.on.chunk && this.on.chunk(a);
48
48
  break;
49
49
  case "on.debug":
50
- this.on.debug && this.on.debug(u);
50
+ this.on.debug && this.on.debug(a);
51
51
  break;
52
52
  }
53
53
  };
@@ -59,12 +59,12 @@ function F(h) {
59
59
  let o;
60
60
  try {
61
61
  if (o = C && (self.URL || self.webkitURL).createObjectURL(C), !o) throw "";
62
- const a = new Worker(o, {
62
+ const u = new Worker(o, {
63
63
  name: h == null ? void 0 : h.name
64
64
  });
65
- return a.addEventListener("error", () => {
65
+ return u.addEventListener("error", () => {
66
66
  (self.URL || self.webkitURL).revokeObjectURL(o);
67
- }), a;
67
+ }), u;
68
68
  } catch {
69
69
  return new Worker(
70
70
  "data:text/javascript;charset=utf-8," + encodeURIComponent(S),
@@ -87,95 +87,95 @@ class N {
87
87
  this.worker.postMessage({ action: "destroy" }), this.worker.terminate();
88
88
  });
89
89
  this.worker.onmessage = (o) => {
90
- const { action: a, data: u } = o.data;
91
- switch (a) {
90
+ const { action: u, data: a } = o.data;
91
+ switch (u) {
92
92
  case "on.audio.decode":
93
- this.on.audio.decode && this.on.audio.decode(u);
93
+ this.on.audio.decode && this.on.audio.decode(a);
94
94
  break;
95
95
  case "on.audio.error":
96
- this.on.audio.error && this.on.audio.error(u);
96
+ this.on.audio.error && this.on.audio.error(a);
97
97
  break;
98
98
  case "on.video.decode":
99
- this.on.video.decode && this.on.video.decode(u);
99
+ this.on.video.decode && this.on.video.decode(a);
100
100
  break;
101
101
  case "on.video.error":
102
- this.on.video.error && this.on.video.error(u);
102
+ this.on.video.error && this.on.video.error(a);
103
103
  break;
104
104
  case "on.nalus":
105
- this.on.nalus && this.on.nalus(u);
105
+ this.on.nalus && this.on.nalus(a);
106
106
  break;
107
107
  case "on.analysis":
108
- this.on.analysis && this.on.analysis(u);
108
+ this.on.analysis && this.on.analysis(a);
109
109
  break;
110
110
  }
111
111
  };
112
112
  }
113
113
  }
114
- var B = Object.defineProperty, G = (h, o, a) => o in h ? B(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a, y = (h, o, a) => G(h, typeof o != "symbol" ? o + "" : o, a);
114
+ var B = Object.defineProperty, G = (h, o, u) => o in h ? B(h, o, { enumerable: !0, configurable: !0, writable: !0, value: u }) : h[o] = u, y = (h, o, u) => G(h, typeof o != "symbol" ? o + "" : o, u);
115
115
  class O {
116
- constructor(o, a) {
117
- y(this, "inputStream", new MediaStream()), y(this, "outputStream", new MediaStream()), y(this, "inputGain", 1), y(this, "enhanceGain", 1), y(this, "bgsGain", 1), y(this, "bgmGain", 1), y(this, "outputGain", 1), y(this, "mixAudioMap", /* @__PURE__ */ new Map()), y(this, "audioContext", new AudioContext()), y(this, "sourceNode"), y(this, "inputGainNode"), y(this, "enhanceGainNode"), y(this, "bgsGainNode"), y(this, "bgmGainNode"), y(this, "analyserNode"), y(this, "analyserArrayData"), y(this, "outputGainNode"), y(this, "destinationNode"), y(this, "filterStream", (u) => u), y(this, "stop", () => {
116
+ constructor(o, u) {
117
+ y(this, "inputStream", new MediaStream()), y(this, "outputStream", new MediaStream()), y(this, "inputGain", 1), y(this, "enhanceGain", 1), y(this, "bgsGain", 1), y(this, "bgmGain", 1), y(this, "outputGain", 1), y(this, "mixAudioMap", /* @__PURE__ */ new Map()), y(this, "audioContext", new AudioContext()), y(this, "sourceNode"), y(this, "inputGainNode"), y(this, "enhanceGainNode"), y(this, "bgsGainNode"), y(this, "bgmGainNode"), y(this, "analyserNode"), y(this, "analyserArrayData"), y(this, "outputGainNode"), y(this, "destinationNode"), y(this, "filterStream", (a) => a), y(this, "stop", () => {
118
118
  {
119
- const u = this.inputStream.getTracks();
120
- for (const n of u)
119
+ const a = this.inputStream.getTracks();
120
+ for (const n of a)
121
121
  n.stop(), this.inputStream.removeTrack(n);
122
122
  }
123
- }), y(this, "getStream", () => this.filterStream(this.outputStream)), y(this, "setMute", (u = !0) => {
124
- u ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
125
- }), y(this, "setInputGain", (u) => {
126
- this.inputGain = u, this.inputGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
127
- }), y(this, "setEnhanceGain", async (u) => {
128
- this.enhanceGain = u + 1, this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime);
129
- }), y(this, "setBgsGain", (u) => {
130
- this.bgsGain = u, this.bgsGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
131
- }), y(this, "setBgmGain", (u) => {
132
- this.bgmGain = u, this.bgmGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
133
- }), y(this, "setOutputGain", (u) => {
134
- this.outputGain = u, this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
123
+ }), y(this, "getStream", () => this.filterStream(this.outputStream)), y(this, "setMute", (a = !0) => {
124
+ a ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
125
+ }), y(this, "setInputGain", (a) => {
126
+ this.inputGain = a, this.inputGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
127
+ }), y(this, "setEnhanceGain", async (a) => {
128
+ this.enhanceGain = a + 1, this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime);
129
+ }), y(this, "setBgsGain", (a) => {
130
+ this.bgsGain = a, this.bgsGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
131
+ }), y(this, "setBgmGain", (a) => {
132
+ this.bgmGain = a, this.bgmGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
133
+ }), y(this, "setOutputGain", (a) => {
134
+ this.outputGain = a, this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
135
135
  }), y(this, "getVolume", () => {
136
- const { analyserNode: u, analyserArrayData: n } = this;
137
- u.getByteFrequencyData(n);
136
+ const { analyserNode: a, analyserArrayData: n } = this;
137
+ a.getByteFrequencyData(n);
138
138
  let r = 0;
139
139
  for (let i = 0; i < n.length; i++)
140
140
  r += n[i];
141
141
  return Math.ceil(r / n.length);
142
- }), y(this, "mixAudio", (u, n = "bgm") => new Promise(async (r, i) => {
142
+ }), y(this, "mixAudio", (a, n = "bgm") => new Promise(async (r, i) => {
143
143
  try {
144
144
  {
145
145
  const s = this.mixAudioMap.get(n);
146
146
  s && s.stop();
147
147
  }
148
148
  const t = n === "bgs" ? this.bgsGainNode : this.bgmGainNode, e = this.audioContext.createBufferSource();
149
- this.mixAudioMap.set(n, e), e.buffer = u, e.connect(t), e.onended = () => {
149
+ this.mixAudioMap.set(n, e), e.buffer = a, e.connect(t), e.onended = () => {
150
150
  e.disconnect(t), this.mixAudioMap.delete(n), r(!0);
151
151
  }, e.start(0);
152
152
  } catch (t) {
153
153
  i(t);
154
154
  }
155
- })), y(this, "mixAudioStop", (u) => {
156
- const n = this.mixAudioMap.get(u);
155
+ })), y(this, "mixAudioStop", (a) => {
156
+ const n = this.mixAudioMap.get(a);
157
157
  n == null || n.stop();
158
- }), y(this, "changeMix", (u, n) => {
159
- const r = u === "bgs" ? this.bgsGainNode : this.bgmGainNode;
158
+ }), y(this, "changeMix", (a, n) => {
159
+ const r = a === "bgs" ? this.bgsGainNode : this.bgmGainNode;
160
160
  n ? r.connect(this.destinationNode) : r.disconnect(this.destinationNode);
161
- }), a && (this.audioContext = a), this.inputStream = o, 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;
161
+ }), u && (this.audioContext = u), this.inputStream = o, 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;
162
162
  {
163
- const { sourceNode: u, inputGainNode: n, enhanceGainNode: r, bgsGainNode: i, bgmGainNode: t, analyserNode: e, outputGainNode: s, destinationNode: l } = this;
164
- u.connect(n), n.connect(r), r.connect(e), i.connect(e), t.connect(e), r.connect(l), i.connect(l), t.connect(l), e.connect(s), s.connect(this.audioContext.destination);
163
+ const { sourceNode: a, inputGainNode: n, enhanceGainNode: r, bgsGainNode: i, bgmGainNode: t, analyserNode: e, outputGainNode: s, destinationNode: l } = this;
164
+ a.connect(n), n.connect(r), r.connect(e), i.connect(e), t.connect(e), r.connect(l), i.connect(l), t.connect(l), e.connect(s), s.connect(this.audioContext.destination);
165
165
  }
166
166
  this.setMute(!0), this.audioContext.resume();
167
167
  }
168
168
  }
169
169
  const E = async (h, o) => {
170
170
  try {
171
- const { format: a, numberOfChannels: u, numberOfFrames: n, sampleRate: r } = o, i = h.createBuffer(u, n, r);
172
- for (let t = 0; t < u; t++) {
171
+ const { format: u, numberOfChannels: a, numberOfFrames: n, sampleRate: r } = o, i = h.createBuffer(a, n, r);
172
+ for (let t = 0; t < a; t++) {
173
173
  const e = o.allocationSize({ planeIndex: t }), s = new Uint8Array(e);
174
174
  o.copyTo(s, { planeIndex: t });
175
175
  const l = new DataView(s.buffer), c = i.getChannelData(t);
176
176
  for (let d = 0; d < n; d++) {
177
177
  let p;
178
- switch (a) {
178
+ switch (u) {
179
179
  case "s16":
180
180
  // 16-bit signed PCM (范围: -32768 ~ 32767)
181
181
  case "s16-planar":
@@ -192,14 +192,14 @@ const E = async (h, o) => {
192
192
  p = (l.getUint8(d) - 128) / 128;
193
193
  break;
194
194
  default:
195
- throw new Error(`Unsupported audio format: ${a}`);
195
+ throw new Error(`Unsupported audio format: ${u}`);
196
196
  }
197
197
  c[d] = Math.max(-1, Math.min(1, p));
198
198
  }
199
199
  }
200
200
  return i;
201
- } catch (a) {
202
- throw console.error("Failed to convert AudioData to AudioBuffer:", a), a;
201
+ } catch (u) {
202
+ throw console.error("Failed to convert AudioData to AudioBuffer:", u), u;
203
203
  }
204
204
  };
205
205
  class W {
@@ -219,22 +219,22 @@ class W {
219
219
  });
220
220
  }
221
221
  async push(o) {
222
- const { audioData: a, playbackRate: u = 1 } = o;
222
+ const { audioData: u, playbackRate: a = 1 } = o;
223
223
  if (!this.audioContext || !this.destination) return;
224
- let n = await E(this.audioContext, a);
225
- if (a.close(), !n) return;
224
+ let n = await E(this.audioContext, u);
225
+ if (u.close(), !n) return;
226
226
  const r = this.audioContext.createBufferSource();
227
- r.buffer = n, r.playbackRate.value = u;
228
- const i = -1200 * Math.log2(u);
227
+ r.buffer = n, r.playbackRate.value = a;
228
+ const i = -1200 * Math.log2(a);
229
229
  r.detune.value = i, r.connect(this.destination);
230
- const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = n.duration / u;
230
+ const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = n.duration / a;
231
231
  this.nextStartTime = t + e, r.start(t), this.pendingSources.push(r), r.onended = () => {
232
232
  this.pendingSources = this.pendingSources.filter((s) => s !== r);
233
233
  }, this.audioContext.state === "suspended" && await this.audioContext.resume();
234
234
  }
235
235
  destroy() {
236
- var o, a;
237
- (o = this.audioContext) == null || o.close(), this.audioContext = void 0, this.destination = void 0, this.nextStartTime = 0, (a = this.prAudioStream) == null || a.stop(), this.pendingSources.forEach((u) => u.stop()), this.pendingSources = [];
236
+ var o, u;
237
+ (o = this.audioContext) == null || o.close(), this.audioContext = void 0, this.destination = void 0, this.nextStartTime = 0, (u = this.prAudioStream) == null || u.stop(), this.pendingSources.forEach((a) => a.stop()), this.pendingSources = [];
238
238
  }
239
239
  }
240
240
  const R = `(function(){"use strict";class o{writable;writer;cutOption;pause=!1;constructor(){}init=({writable:t})=>{this.destroy(),this.writable=t,this.writer=this.writable.getWriter()};push=async t=>{if(this.pause)return;const{timestamp:s}=t;let{bitmap:i}=t;if(this.cutOption){const{sx:n=0,sy:c=0,sw:h=i.width,sh:u=i.height}=this.cutOption;i=await createImageBitmap(i,n,c,h,u)}const r=new VideoFrame(i,{timestamp:s});this.cutOption&&i.close(),this.writer.write(r),r.close()};setCut=t=>{this.cutOption=t};setPause=t=>{this.pause=t};destroy=()=>{this.writable=void 0,this.writer=void 0,this.cutOption=void 0}}const a=new o;onmessage=e=>{const{action:t,data:s}=e.data,i=a[t];i&&i(s)}})();
@@ -243,12 +243,12 @@ function j(h) {
243
243
  let o;
244
244
  try {
245
245
  if (o = v && (self.URL || self.webkitURL).createObjectURL(v), !o) throw "";
246
- const a = new Worker(o, {
246
+ const u = new Worker(o, {
247
247
  name: h == null ? void 0 : h.name
248
248
  });
249
- return a.addEventListener("error", () => {
249
+ return u.addEventListener("error", () => {
250
250
  (self.URL || self.webkitURL).revokeObjectURL(o);
251
- }), a;
251
+ }), u;
252
252
  } catch {
253
253
  return new Worker(
254
254
  "data:text/javascript;charset=utf-8," + encodeURIComponent(R),
@@ -275,12 +275,12 @@ const q = (h) => {
275
275
  return o.includes(".m3u8") || o.includes("hls") || o.includes("master.m3u8") || o.match(/index\d*\.m3u8/) ? "hls" : o.includes(".mpd") || o.includes("dash") ? "dash" : o.startsWith("rtmp://") || o.startsWith("rtmps://") ? "rtmp" : o.includes(".flv") || o.includes("flv") && !o.includes("flash") ? "flv" : "unknown";
276
276
  }, M = (h) => {
277
277
  const o = (h == null ? void 0 : h.getTracks()) || [];
278
- for (const a of o)
279
- a.stop();
278
+ for (const u of o)
279
+ u.stop();
280
280
  }, A = () => {
281
- const h = new MediaStreamTrackGenerator({ kind: "video" }), o = new MediaStream([h]), a = new z();
282
- return a.init({ writable: h.writable }), { worker: a, stream: o, destroy: () => {
283
- a.destroy(), M(o);
281
+ const h = new MediaStreamTrackGenerator({ kind: "video" }), o = new MediaStream([h]), u = new z();
282
+ return u.init({ writable: h.writable }), { worker: u, stream: o, destroy: () => {
283
+ u.destroy(), M(o);
284
284
  } };
285
285
  };
286
286
  class $ {
@@ -294,44 +294,44 @@ class $ {
294
294
  * @param timeout 超时时间 ms
295
295
  * @returns
296
296
  */
297
- m(this, "add", (o, a = () => !1, u = 0) => new Promise((n) => {
297
+ m(this, "add", (o, u = () => !1, a = 0) => new Promise((n) => {
298
298
  var t, e;
299
- if (a()) return n(!0);
299
+ if (u()) return n(!0);
300
300
  this.resolvesMap.has(o) || this.resolvesMap.set(o, /* @__PURE__ */ new Map()), this.index++;
301
301
  const r = `${this.index}`;
302
- if (u = Math.max(0, u), u === 0) {
302
+ if (a = Math.max(0, a), a === 0) {
303
303
  (t = this.resolvesMap.get(o)) == null || t.set(r, { resolve: n, timer: 0 });
304
304
  return;
305
305
  }
306
306
  const i = window.setTimeout(() => {
307
307
  this.emit(o);
308
- }, u);
308
+ }, a);
309
309
  (e = this.resolvesMap.get(o)) == null || e.set(r, { resolve: n, timer: i });
310
310
  }));
311
311
  m(this, "emit", async (o) => {
312
- const a = this.resolvesMap.get(o);
313
- if (!a) return;
314
- const u = [...a.keys()];
315
- for (const n of u) {
316
- const r = a.get(n);
317
- r && (clearTimeout(r.timer), r.resolve(), a.delete(n));
312
+ const u = this.resolvesMap.get(o);
313
+ if (!u) return;
314
+ const a = [...u.keys()];
315
+ for (const n of a) {
316
+ const r = u.get(n);
317
+ r && (clearTimeout(r.timer), r.resolve(), u.delete(n));
318
318
  }
319
319
  });
320
320
  }
321
321
  }
322
322
  const Y = (h) => {
323
323
  const o = new DataView(h.buffer);
324
- let a = 0, u, n, r;
325
- u = o.getUint32(a, !1), a += 4;
324
+ let u = 0, a, n, r;
325
+ a = o.getUint32(u, !1), u += 4;
326
326
  {
327
- const i = o.getUint8(a), t = i >> 7 & 1, e = i >> 5 & 3, s = i & 31;
328
- n = { forbidden_zero_bit: t, nal_ref_idc: e, nal_unit_type: s }, a += 1;
327
+ const i = o.getUint8(u), t = i >> 7 & 1, e = i >> 5 & 3, s = i & 31;
328
+ n = { forbidden_zero_bit: t, nal_ref_idc: e, nal_unit_type: s }, u += 1;
329
329
  }
330
330
  {
331
- const i = u - 1;
332
- r = new Uint8Array(o.buffer.slice(a, a + i));
331
+ const i = a - 1;
332
+ r = new Uint8Array(o.buffer.slice(u, u + i));
333
333
  }
334
- return { size: u, header: n, data: r };
334
+ return { size: a, header: n, data: r };
335
335
  };
336
336
  var P, U;
337
337
  class x {
@@ -345,7 +345,7 @@ class x {
345
345
  * @param input string | URL | Request
346
346
  * @param init RequestInit
347
347
  */
348
- m(this, "check", (o, a) => new Promise(async (u, n) => {
348
+ m(this, "check", (o, u) => new Promise(async (a, n) => {
349
349
  var i;
350
350
  this.stop(), H(this, U, new AbortController());
351
351
  const r = window.setTimeout(() => {
@@ -353,8 +353,8 @@ class x {
353
353
  (t = I(this, U)) == null || t.abort("Timeout."), n({ status: "timeout", reason: "" });
354
354
  }, I(this, P).timeout);
355
355
  try {
356
- const t = await fetch(o, { ...a, method: "HEAD", signal: (i = I(this, U)) == null ? void 0 : i.signal });
357
- t.status === 200 ? u({ status: "successed", reason: "" }) : n({ status: "failed", reason: `${t.status}` });
356
+ const t = await fetch(o, { ...u, method: "HEAD", signal: (i = I(this, U)) == null ? void 0 : i.signal });
357
+ t.status === 200 ? a({ status: "successed", reason: "" }) : n({ status: "failed", reason: `${t.status}` });
358
358
  } catch (t) {
359
359
  n({ status: "error", reason: t.message });
360
360
  }
@@ -365,12 +365,12 @@ class x {
365
365
  * @param input string | URL | Request
366
366
  * @param init RequestInit
367
367
  */
368
- m(this, "request", async (o, a) => new Promise(async (u, n) => {
368
+ m(this, "request", async (o, u) => new Promise(async (a, n) => {
369
369
  var r;
370
370
  try {
371
- await this.check(o, a), H(this, U, new AbortController());
372
- const i = await fetch(o, { ...a, signal: (r = I(this, U)) == null ? void 0 : r.signal });
373
- u(i);
371
+ await this.check(o, u), H(this, U, new AbortController());
372
+ const i = await fetch(o, { ...u, signal: (r = I(this, U)) == null ? void 0 : r.signal });
373
+ a(i);
374
374
  } catch (i) {
375
375
  this.stop(), n(i);
376
376
  }
@@ -411,9 +411,9 @@ class et {
411
411
  */
412
412
  m(this, "start", async (o) => {
413
413
  await this.stop(), this.url = o;
414
- const a = q(o);
415
- if (a === "unknown") throw new Error("This address cannot be parsed.");
416
- switch (this.init(a), a) {
414
+ const u = q(o);
415
+ if (u === "unknown") throw new Error("This address cannot be parsed.");
416
+ switch (this.init(u), u) {
417
417
  case "flv":
418
418
  this.flv.start();
419
419
  break;
@@ -426,13 +426,13 @@ class et {
426
426
  * 停止
427
427
  */
428
428
  m(this, "stop", async () => {
429
- var a, u, n, r, i;
429
+ var u, a, n, r, i;
430
430
  try {
431
431
  this.url = "", clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop(), this.getSegmentsFetch.stop();
432
432
  } catch (t) {
433
433
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: error", t);
434
434
  }
435
- (a = this.demuxerWorker) == null || a.destroy(), (u = this.decoderWorker) == null || u.destroy(), (n = this.renderWorker) == null || n.destroy();
435
+ (u = this.demuxerWorker) == null || u.destroy(), (a = this.decoderWorker) == null || a.destroy(), (n = this.renderWorker) == null || n.destroy();
436
436
  const o = [...this.cutRenders.keys()];
437
437
  for (const t of o)
438
438
  (r = this.cutRenders.get(t)) == null || r.worker.destroy(), this.cutRenders.delete(t);
@@ -447,32 +447,32 @@ class et {
447
447
  * @param pause: boolean
448
448
  */
449
449
  m(this, "setPause", (o) => {
450
- var a;
451
- (a = this.renderWorker) == null || a.setPause(o);
450
+ var u;
451
+ (u = this.renderWorker) == null || u.setPause(o);
452
452
  });
453
453
  /**
454
454
  * 是否静音 默认为true
455
455
  * @param state?: boolean
456
456
  */
457
457
  m(this, "setMute", (o) => {
458
- var a, u;
459
- return (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null ? void 0 : u.setMute(o);
458
+ var u, a;
459
+ return (a = (u = this.audioPlayer) == null ? void 0 : u.prAudioStream) == null ? void 0 : a.setMute(o);
460
460
  });
461
461
  /**
462
462
  * 是否开启追帧
463
463
  * @param frameTrack?: boolean
464
464
  */
465
465
  m(this, "setFrameTrack", (o) => {
466
- var a;
467
- this.option.frameTrack = o, (a = this.decoderWorker) == null || a.setFrameTrack(o);
466
+ var u;
467
+ this.option.frameTrack = o, (u = this.decoderWorker) == null || u.setFrameTrack(o);
468
468
  });
469
469
  /**
470
470
  * 是否已准备好
471
471
  */
472
472
  m(this, "isReady", () => {
473
473
  const o = () => {
474
- var a;
475
- return ((a = this.stream) == null ? void 0 : a.active) === !0;
474
+ var u;
475
+ return ((u = this.stream) == null ? void 0 : u.active) === !0;
476
476
  };
477
477
  return this.prResolves.add("isReady", o);
478
478
  });
@@ -480,31 +480,31 @@ class et {
480
480
  /**
481
481
  * 创建剪切
482
482
  */
483
- create: (o, a) => {
484
- let u = this.cutRenders.get(o);
485
- return u ? (u.worker.setCut(a), u.worker.setPause(!1), u) : (u = A(), u.worker.setCut(a), this.cutRenders.set(o, u), u);
483
+ create: (o, u) => {
484
+ let a = this.cutRenders.get(o);
485
+ return a ? (a.worker.setCut(u), a.worker.setPause(!1), a) : (a = A(), a.worker.setCut(u), this.cutRenders.set(o, a), a);
486
486
  },
487
487
  /**
488
488
  * 获取媒体流
489
489
  */
490
490
  getStream: (o) => {
491
- var a;
492
- return (a = this.cutRenders.get(o)) == null ? void 0 : a.stream;
491
+ var u;
492
+ return (u = this.cutRenders.get(o)) == null ? void 0 : u.stream;
493
493
  },
494
494
  /**
495
495
  * 设置暂停
496
496
  * @param pause: boolean
497
497
  */
498
- setPause: (o, a) => {
499
- var u;
500
- (u = this.cutRenders.get(o)) == null || u.worker.setPause(a);
498
+ setPause: (o, u) => {
499
+ var a;
500
+ (a = this.cutRenders.get(o)) == null || a.worker.setPause(u);
501
501
  },
502
502
  /**
503
503
  * 移除剪切
504
504
  */
505
505
  remove: (o) => {
506
- var a;
507
- (a = this.cutRenders.get(o)) == null || a.destroy(), this.cutRenders.delete(o);
506
+ var u;
507
+ (u = this.cutRenders.get(o)) == null || u.destroy(), this.cutRenders.delete(o);
508
508
  }
509
509
  });
510
510
  /**
@@ -517,42 +517,42 @@ class et {
517
517
  * 初始化解复器
518
518
  */
519
519
  m(this, "initDemuxer", (o) => {
520
- this.demuxerWorker = new V(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (a) => {
521
- this.option.debug && this.on.debug && this.on.debug(a);
522
- }, this.demuxerWorker.on.info = (a) => {
523
- this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: info", a), this.on.demuxer.info && this.on.demuxer.info(a);
524
- }, this.demuxerWorker.on.config = (a) => {
520
+ this.demuxerWorker = new V(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (u) => {
521
+ this.option.debug && this.on.debug && this.on.debug(u);
522
+ }, this.demuxerWorker.on.info = (u) => {
523
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: info", u), this.on.demuxer.info && this.on.demuxer.info(u);
524
+ }, this.demuxerWorker.on.config = (u) => {
525
525
  var n, r;
526
- this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: config", a), this.on.demuxer.config && this.on.demuxer.config(a);
527
- const { kind: u } = a;
528
- switch (u) {
526
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: config", u), this.on.demuxer.config && this.on.demuxer.config(u);
527
+ const { kind: a } = u;
528
+ switch (a) {
529
529
  case "audio":
530
530
  {
531
- const { codec: i, sampleRate: t, numberOfChannels: e } = a;
531
+ const { codec: i, sampleRate: t, numberOfChannels: e } = u;
532
532
  (n = this.decoderWorker) == null || n.initAudio({ codec: i, sampleRate: t, numberOfChannels: e });
533
533
  }
534
534
  break;
535
535
  case "video":
536
536
  {
537
- const { codec: i, description: t } = a;
537
+ const { codec: i, description: t } = u;
538
538
  (r = this.decoderWorker) == null || r.initVideo({ codec: i, description: t });
539
539
  }
540
540
  break;
541
541
  }
542
- }, this.demuxerWorker.on.chunk = (a) => {
543
- if (this.on.demuxer.chunk && this.on.demuxer.chunk(a), !this.decoderWorker) return;
544
- const { kind: u } = a;
545
- switch (u) {
542
+ }, this.demuxerWorker.on.chunk = (u) => {
543
+ if (this.on.demuxer.chunk && this.on.demuxer.chunk(u), !this.decoderWorker) return;
544
+ const { kind: a } = u;
545
+ switch (a) {
546
546
  case "audio":
547
547
  {
548
- const { type: n, dts: r, data: i } = a, t = r * 1e3;
549
- this.decoderWorker.push({ kind: u, init: { type: n, timestamp: t, data: i } });
548
+ const { type: n, dts: r, data: i } = u, t = r * 1e3;
549
+ this.decoderWorker.push({ kind: a, init: { type: n, timestamp: t, data: i } });
550
550
  }
551
551
  break;
552
552
  case "video":
553
553
  {
554
- const { type: n, dts: r, data: i, nalus: t = [] } = a, e = r * 1e3;
555
- this.decoderWorker.push({ kind: u, init: { type: n, timestamp: e, data: i }, nalus: t });
554
+ const { type: n, dts: r, data: i, nalus: t = [] } = u, e = r * 1e3;
555
+ this.decoderWorker.push({ kind: a, init: { type: n, timestamp: e, data: i }, nalus: t });
556
556
  }
557
557
  break;
558
558
  }
@@ -563,53 +563,53 @@ class et {
563
563
  */
564
564
  m(this, "initDecoder", (o) => {
565
565
  this.decoderWorker = new N(), this.decoderWorker.init(o);
566
- const { frameTrack: a = !1 } = this.option;
567
- this.decoderWorker.setFrameTrack(a), this.decoderWorker.on.audio.decode = (u) => {
566
+ const { frameTrack: u = !1 } = this.option;
567
+ this.decoderWorker.setFrameTrack(u), this.decoderWorker.on.audio.decode = (a) => {
568
568
  var n;
569
- (n = this.audioPlayer) == null || n.push(u), this.on.decoder.audio && this.on.decoder.audio(u);
570
- }, this.decoderWorker.on.audio.error = (u) => {
571
- this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: audio.error ", u), this.on.error && this.on.error(u);
572
- }, this.decoderWorker.on.video.decode = async (u) => {
569
+ (n = this.audioPlayer) == null || n.push(a), this.on.decoder.audio && this.on.decoder.audio(a);
570
+ }, this.decoderWorker.on.audio.error = (a) => {
571
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: audio.error ", a), this.on.error && this.on.error(a);
572
+ }, this.decoderWorker.on.video.decode = async (a) => {
573
573
  var r, i;
574
- (r = this.renderWorker) == null || r.push(u);
574
+ (r = this.renderWorker) == null || r.push(a);
575
575
  const n = [...this.cutRenders.keys()];
576
576
  for (const t of n)
577
- (i = this.cutRenders.get(t)) == null || i.worker.push(u);
578
- this.on.decoder.video && this.on.decoder.video(u), u.bitmap.close();
579
- }, this.decoderWorker.on.video.error = (u) => {
580
- this.on.error && this.on.error(u);
581
- }, this.decoderWorker.on.nalus = async (u) => {
582
- for (const n of u) {
577
+ (i = this.cutRenders.get(t)) == null || i.worker.push(a);
578
+ this.on.decoder.video && this.on.decoder.video(a), a.bitmap.close();
579
+ }, this.decoderWorker.on.video.error = (a) => {
580
+ this.on.error && this.on.error(a);
581
+ }, this.decoderWorker.on.nalus = async (a) => {
582
+ for (const n of a) {
583
583
  if (n.byteLength <= 4) continue;
584
584
  const { header: r, data: i } = Y(n), { nal_unit_type: t } = r;
585
585
  t === 6 && this.on.decoder.sei && this.on.decoder.sei(i);
586
586
  }
587
- }, this.decoderWorker.on.analysis = (u) => {
588
- this.on.decoder.analysis && this.on.decoder.analysis(u);
587
+ }, this.decoderWorker.on.analysis = (a) => {
588
+ this.on.decoder.analysis && this.on.decoder.analysis(a);
589
589
  };
590
590
  });
591
591
  /**
592
592
  * 初始化渲染器
593
593
  */
594
594
  m(this, "initRender", () => {
595
- const { worker: o, stream: a } = A();
596
- this.renderWorker = o, this.stream = a, this.renderWorker.setPause(!1);
595
+ const { worker: o, stream: u } = A();
596
+ this.renderWorker = o, this.stream = u, this.renderWorker.setPause(!1);
597
597
  });
598
598
  m(this, "flv", {
599
599
  start: async () => {
600
- var o, a;
600
+ var o, u;
601
601
  try {
602
- let u = await this.prFetch.request(this.url);
603
- if (u.status !== 200 && (await new Promise((r) => setTimeout(() => r(!0), 500)), u = await this.prFetch.request(this.url)), u.status !== 200 && (await new Promise((r) => setTimeout(() => r(!0), 500)), u = await this.prFetch.request(this.url)), u.status !== 200) throw new Error("request is error.");
604
- const n = (o = u.body) == null ? void 0 : o.getReader();
602
+ let a = await this.prFetch.request(this.url);
603
+ if (a.status !== 200 && (await new Promise((r) => setTimeout(() => r(!0), 500)), a = await this.prFetch.request(this.url)), a.status !== 200 && (await new Promise((r) => setTimeout(() => r(!0), 500)), a = await this.prFetch.request(this.url)), a.status !== 200) throw new Error("request is error.");
604
+ const n = (o = a.body) == null ? void 0 : o.getReader();
605
605
  if (!n) throw new Error("reader is error.");
606
606
  for (; ; ) {
607
607
  const { done: r, value: i } = await n.read();
608
- if (i && ((a = this.demuxerWorker) == null || a.push(i)), r || this.url === "") break;
608
+ if (i && ((u = this.demuxerWorker) == null || u.push(i)), r || this.url === "") break;
609
609
  }
610
- } catch (u) {
611
- if ((u == null ? void 0 : u.name) !== "AbortError") throw Error(u);
612
- this.on.error && this.on.error(u);
610
+ } catch (a) {
611
+ if ((a == null ? void 0 : a.name) !== "AbortError") throw Error(a);
612
+ this.on.error && this.on.error(a);
613
613
  }
614
614
  }
615
615
  });
@@ -619,27 +619,27 @@ class et {
619
619
  url: "",
620
620
  getSegmentsTimer: 0,
621
621
  parse: async (o) => {
622
- const a = new TextDecoder("utf-8").decode(o).split(`
623
- `).map((e) => e.replace("\r", "")), u = this.url.substring(0, this.url.lastIndexOf("/") + 1);
622
+ const u = new TextDecoder("utf-8").decode(o).split(`
623
+ `).map((e) => e.replace("\r", "")), a = this.url.substring(0, this.url.lastIndexOf("/") + 1);
624
624
  let n = 4, r = 0, i = !1;
625
625
  const t = [];
626
- for (const e of a)
626
+ for (const e of u)
627
627
  e.startsWith("#EXTINF:") ? n = parseFloat(e.split(":")[1].split(",")[0]) : e.startsWith("#EXT-X-TARGETDURATION:") ? r = parseInt(e.split(":")[1]) : e.startsWith("#EXT-X-ENDLIST") ? i = !1 : e.startsWith("#EXT-X-MEDIA-SEQUENCE:") ? i = !0 : e.includes(".ts") && !e.startsWith("#") && t.push({
628
- url: e.startsWith("http") ? e : u + e,
628
+ url: e.startsWith("http") ? e : a + e,
629
629
  duration: n,
630
630
  isLive: i
631
631
  });
632
- return { baseUrl: u, targetDuration: r, isLive: i, segments: t };
632
+ return { baseUrl: a, targetDuration: r, isLive: i, segments: t };
633
633
  },
634
634
  getSegments: async () => {
635
635
  var o;
636
636
  try {
637
- let a = await this.getSegmentsFetch.request(this.url);
638
- if (a.status !== 200 && (await new Promise((n) => setTimeout(() => n(!0), 500)), a = await this.getSegmentsFetch.request(this.url)), a.status !== 200 && (await new Promise((n) => setTimeout(() => n(!0), 500)), a = await this.getSegmentsFetch.request(this.url)), a.status !== 200) throw new Error("request is error.");
639
- const u = (o = a.body) == null ? void 0 : o.getReader();
640
- if (!u) throw new Error("reader is error.");
637
+ let u = await this.getSegmentsFetch.request(this.url);
638
+ if (u.status !== 200 && (await new Promise((n) => setTimeout(() => n(!0), 500)), u = await this.getSegmentsFetch.request(this.url)), u.status !== 200 && (await new Promise((n) => setTimeout(() => n(!0), 500)), u = await this.getSegmentsFetch.request(this.url)), u.status !== 200) throw new Error("request is error.");
639
+ const a = (o = u.body) == null ? void 0 : o.getReader();
640
+ if (!a) throw new Error("reader is error.");
641
641
  for (; ; ) {
642
- const { done: n, value: r } = await u.read();
642
+ const { done: n, value: r } = await a.read();
643
643
  if (r) {
644
644
  const i = await this.hls.parse(r), { segments: t = [], isLive: e = !1 } = i;
645
645
  this.hls.isLive = e, e === !1 && (this.option.frameTrack = !1);
@@ -649,22 +649,22 @@ class et {
649
649
  }
650
650
  if (n || this.url === "") break;
651
651
  }
652
- } catch (a) {
653
- this.on.error && this.on.error(a);
652
+ } catch (u) {
653
+ this.on.error && this.on.error(u);
654
654
  }
655
655
  },
656
656
  start: async () => {
657
- var o, a, u;
657
+ var o, u, a;
658
658
  try {
659
659
  for (await this.hls.getSegments(), this.hls.getSegmentsTimer = window.setInterval(this.hls.getSegments, 500), this.hls.isLive === !1 && (clearInterval(this.hls.getSegmentsTimer), (o = this.decoderWorker) == null ? void 0 : o.setFrameTrack(!1)); ; ) {
660
660
  const n = this.hls.urls.shift();
661
661
  if (n) {
662
662
  this.hls.url = n;
663
- const r = (a = (await this.prFetch.request(n)).body) == null ? void 0 : a.getReader();
663
+ const r = (u = (await this.prFetch.request(n)).body) == null ? void 0 : u.getReader();
664
664
  if (!r) throw new Error("segment reader is error.");
665
665
  for (; ; ) {
666
666
  const { done: i, value: t } = await r.read();
667
- if (t && ((u = this.demuxerWorker) == null || u.push(t)), i || this.url === "") break;
667
+ if (t && ((a = this.demuxerWorker) == null || a.push(t)), i || this.url === "") break;
668
668
  }
669
669
  } else
670
670
  await new Promise((r) => setTimeout(() => r(!0), 300));
@@ -674,19 +674,19 @@ class et {
674
674
  }
675
675
  }
676
676
  });
677
- const { debug: a = !1 } = o;
678
- this.option.debug = a;
677
+ const { debug: u = !1 } = o;
678
+ this.option.debug = u;
679
679
  }
680
680
  }
681
681
  var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, indexMinimal = {}, minimal$1 = {}, aspromise, hasRequiredAspromise;
682
682
  function requireAspromise() {
683
683
  if (hasRequiredAspromise) return aspromise;
684
684
  hasRequiredAspromise = 1, aspromise = h;
685
- function h(o, a) {
686
- for (var u = new Array(arguments.length - 1), n = 0, r = 2, i = !0; r < arguments.length; )
687
- u[n++] = arguments[r++];
685
+ function h(o, u) {
686
+ for (var a = new Array(arguments.length - 1), n = 0, r = 2, i = !0; r < arguments.length; )
687
+ a[n++] = arguments[r++];
688
688
  return new Promise(function(e, s) {
689
- u[n] = function(c) {
689
+ a[n] = function(c) {
690
690
  if (i)
691
691
  if (i = !1, c)
692
692
  s(c);
@@ -697,7 +697,7 @@ function requireAspromise() {
697
697
  }
698
698
  };
699
699
  try {
700
- o.apply(a || null, u);
700
+ o.apply(u || null, a);
701
701
  } catch (l) {
702
702
  i && (i = !1, s(l));
703
703
  }
@@ -717,25 +717,25 @@ function requireBase64() {
717
717
  ++s;
718
718
  return Math.ceil(t.length * 3) / 4 - s;
719
719
  };
720
- for (var a = new Array(64), u = new Array(123), n = 0; n < 64; )
721
- u[a[n] = n < 26 ? n + 65 : n < 52 ? n + 71 : n < 62 ? n - 4 : n - 59 | 43] = n++;
720
+ for (var u = new Array(64), a = new Array(123), n = 0; n < 64; )
721
+ a[u[n] = n < 26 ? n + 65 : n < 52 ? n + 71 : n < 62 ? n - 4 : n - 59 | 43] = n++;
722
722
  o.encode = function(t, e, s) {
723
723
  for (var l = null, c = [], d = 0, p = 0, f; e < s; ) {
724
724
  var w = t[e++];
725
725
  switch (p) {
726
726
  case 0:
727
- c[d++] = a[w >> 2], f = (w & 3) << 4, p = 1;
727
+ c[d++] = u[w >> 2], f = (w & 3) << 4, p = 1;
728
728
  break;
729
729
  case 1:
730
- c[d++] = a[f | w >> 4], f = (w & 15) << 2, p = 2;
730
+ c[d++] = u[f | w >> 4], f = (w & 15) << 2, p = 2;
731
731
  break;
732
732
  case 2:
733
- c[d++] = a[f | w >> 6], c[d++] = a[w & 63], p = 0;
733
+ c[d++] = u[f | w >> 6], c[d++] = u[w & 63], p = 0;
734
734
  break;
735
735
  }
736
736
  d > 8191 && ((l || (l = [])).push(String.fromCharCode.apply(String, c)), d = 0);
737
737
  }
738
- return p && (c[d++] = a[f], c[d++] = 61, p === 1 && (c[d++] = 61)), l ? (d && l.push(String.fromCharCode.apply(String, c.slice(0, d))), l.join("")) : String.fromCharCode.apply(String, c.slice(0, d));
738
+ return p && (c[d++] = u[f], c[d++] = 61, p === 1 && (c[d++] = 61)), l ? (d && l.push(String.fromCharCode.apply(String, c.slice(0, d))), l.join("")) : String.fromCharCode.apply(String, c.slice(0, d));
739
739
  };
740
740
  var r = "invalid encoding";
741
741
  o.decode = function(t, e, s) {
@@ -743,7 +743,7 @@ function requireBase64() {
743
743
  var f = t.charCodeAt(p++);
744
744
  if (f === 61 && c > 1)
745
745
  break;
746
- if ((f = u[f]) === void 0)
746
+ if ((f = a[f]) === void 0)
747
747
  throw Error(r);
748
748
  switch (c) {
749
749
  case 0:
@@ -775,27 +775,27 @@ function requireEventemitter() {
775
775
  function h() {
776
776
  this._listeners = {};
777
777
  }
778
- return h.prototype.on = function(a, u, n) {
779
- return (this._listeners[a] || (this._listeners[a] = [])).push({
780
- fn: u,
778
+ return h.prototype.on = function(u, a, n) {
779
+ return (this._listeners[u] || (this._listeners[u] = [])).push({
780
+ fn: a,
781
781
  ctx: n || this
782
782
  }), this;
783
- }, h.prototype.off = function(a, u) {
784
- if (a === void 0)
783
+ }, h.prototype.off = function(u, a) {
784
+ if (u === void 0)
785
785
  this._listeners = {};
786
- else if (u === void 0)
787
- this._listeners[a] = [];
786
+ else if (a === void 0)
787
+ this._listeners[u] = [];
788
788
  else
789
- for (var n = this._listeners[a], r = 0; r < n.length; )
790
- n[r].fn === u ? n.splice(r, 1) : ++r;
789
+ for (var n = this._listeners[u], r = 0; r < n.length; )
790
+ n[r].fn === a ? n.splice(r, 1) : ++r;
791
791
  return this;
792
- }, h.prototype.emit = function(a) {
793
- var u = this._listeners[a];
794
- if (u) {
792
+ }, h.prototype.emit = function(u) {
793
+ var a = this._listeners[u];
794
+ if (a) {
795
795
  for (var n = [], r = 1; r < arguments.length; )
796
796
  n.push(arguments[r++]);
797
- for (r = 0; r < u.length; )
798
- u[r].fn.apply(u[r++].ctx, n);
797
+ for (r = 0; r < a.length; )
798
+ a[r].fn.apply(a[r++].ctx, n);
799
799
  }
800
800
  return this;
801
801
  }, eventemitter;
@@ -843,12 +843,12 @@ function requireFloat() {
843
843
  e((d << 31 | p + 127 << 23 | f) >>> 0, l, c);
844
844
  }
845
845
  }
846
- r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null, a);
846
+ r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null, u);
847
847
  function t(e, s, l) {
848
848
  var c = e(s, l), d = (c >> 31) * 2 + 1, p = c >>> 23 & 255, f = c & 8388607;
849
849
  return p === 255 ? f ? NaN : d * (1 / 0) : p === 0 ? d * 1401298464324817e-60 * f : d * Math.pow(2, p - 150) * (f + 8388608);
850
850
  }
851
- r.readFloatLE = t.bind(null, u), r.readFloatBE = t.bind(null, n);
851
+ r.readFloatLE = t.bind(null, a), r.readFloatBE = t.bind(null, n);
852
852
  }(), typeof Float64Array < "u" ? function() {
853
853
  var i = new Float64Array([-0]), t = new Uint8Array(i.buffer), e = t[7] === 128;
854
854
  function s(p, f, w) {
@@ -890,21 +890,21 @@ function requireFloat() {
890
890
  }
891
891
  }
892
892
  }
893
- r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null, a, 4, 0);
893
+ r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null, u, 4, 0);
894
894
  function t(e, s, l, c, d) {
895
895
  var p = e(c, d + s), f = e(c, d + l), w = (f >> 31) * 2 + 1, b = f >>> 20 & 2047, g = 4294967296 * (f & 1048575) + p;
896
896
  return b === 2047 ? g ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * g : w * Math.pow(2, b - 1075) * (g + 4503599627370496);
897
897
  }
898
- r.readDoubleLE = t.bind(null, u, 0, 4), r.readDoubleBE = t.bind(null, n, 4, 0);
898
+ r.readDoubleLE = t.bind(null, a, 0, 4), r.readDoubleBE = t.bind(null, n, 4, 0);
899
899
  }(), r;
900
900
  }
901
901
  function o(r, i, t) {
902
902
  i[t] = r & 255, i[t + 1] = r >>> 8 & 255, i[t + 2] = r >>> 16 & 255, i[t + 3] = r >>> 24;
903
903
  }
904
- function a(r, i, t) {
904
+ function u(r, i, t) {
905
905
  i[t] = r >>> 24, i[t + 1] = r >>> 16 & 255, i[t + 2] = r >>> 8 & 255, i[t + 3] = r & 255;
906
906
  }
907
- function u(r, i) {
907
+ function a(r, i) {
908
908
  return (r[i] | r[i + 1] << 8 | r[i + 2] << 16 | r[i + 3] << 24) >>> 0;
909
909
  }
910
910
  function n(r, i) {
@@ -931,20 +931,20 @@ var utf8 = {}, hasRequiredUtf8;
931
931
  function requireUtf8() {
932
932
  return hasRequiredUtf8 || (hasRequiredUtf8 = 1, function(h) {
933
933
  var o = h;
934
- o.length = function(u) {
935
- for (var n = 0, r = 0, i = 0; i < u.length; ++i)
936
- r = u.charCodeAt(i), r < 128 ? n += 1 : r < 2048 ? n += 2 : (r & 64512) === 55296 && (u.charCodeAt(i + 1) & 64512) === 56320 ? (++i, n += 4) : n += 3;
934
+ o.length = function(a) {
935
+ for (var n = 0, r = 0, i = 0; i < a.length; ++i)
936
+ r = a.charCodeAt(i), r < 128 ? n += 1 : r < 2048 ? n += 2 : (r & 64512) === 55296 && (a.charCodeAt(i + 1) & 64512) === 56320 ? (++i, n += 4) : n += 3;
937
937
  return n;
938
- }, o.read = function(u, n, r) {
938
+ }, o.read = function(a, n, r) {
939
939
  var i = r - n;
940
940
  if (i < 1)
941
941
  return "";
942
942
  for (var t = null, e = [], s = 0, l; n < r; )
943
- l = u[n++], l < 128 ? e[s++] = l : l > 191 && l < 224 ? e[s++] = (l & 31) << 6 | u[n++] & 63 : l > 239 && l < 365 ? (l = ((l & 7) << 18 | (u[n++] & 63) << 12 | (u[n++] & 63) << 6 | u[n++] & 63) - 65536, e[s++] = 55296 + (l >> 10), e[s++] = 56320 + (l & 1023)) : e[s++] = (l & 15) << 12 | (u[n++] & 63) << 6 | u[n++] & 63, s > 8191 && ((t || (t = [])).push(String.fromCharCode.apply(String, e)), s = 0);
943
+ l = a[n++], l < 128 ? e[s++] = l : l > 191 && l < 224 ? e[s++] = (l & 31) << 6 | a[n++] & 63 : l > 239 && l < 365 ? (l = ((l & 7) << 18 | (a[n++] & 63) << 12 | (a[n++] & 63) << 6 | a[n++] & 63) - 65536, e[s++] = 55296 + (l >> 10), e[s++] = 56320 + (l & 1023)) : e[s++] = (l & 15) << 12 | (a[n++] & 63) << 6 | a[n++] & 63, s > 8191 && ((t || (t = [])).push(String.fromCharCode.apply(String, e)), s = 0);
944
944
  return t ? (s && t.push(String.fromCharCode.apply(String, e.slice(0, s))), t.join("")) : String.fromCharCode.apply(String, e.slice(0, s));
945
- }, o.write = function(u, n, r) {
946
- for (var i = r, t, e, s = 0; s < u.length; ++s)
947
- t = u.charCodeAt(s), t < 128 ? n[r++] = t : t < 2048 ? (n[r++] = t >> 6 | 192, n[r++] = t & 63 | 128) : (t & 64512) === 55296 && ((e = u.charCodeAt(s + 1)) & 64512) === 56320 ? (t = 65536 + ((t & 1023) << 10) + (e & 1023), ++s, n[r++] = t >> 18 | 240, n[r++] = t >> 12 & 63 | 128, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128) : (n[r++] = t >> 12 | 224, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128);
945
+ }, o.write = function(a, n, r) {
946
+ for (var i = r, t, e, s = 0; s < a.length; ++s)
947
+ t = a.charCodeAt(s), t < 128 ? n[r++] = t : t < 2048 ? (n[r++] = t >> 6 | 192, n[r++] = t & 63 | 128) : (t & 64512) === 55296 && ((e = a.charCodeAt(s + 1)) & 64512) === 56320 ? (t = 65536 + ((t & 1023) << 10) + (e & 1023), ++s, n[r++] = t >> 18 | 240, n[r++] = t >> 12 & 63 | 128, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128) : (n[r++] = t >> 12 | 224, n[r++] = t >> 6 & 63 | 128, n[r++] = t & 63 | 128);
948
948
  return r - i;
949
949
  };
950
950
  }(utf8)), utf8;
@@ -953,13 +953,13 @@ var pool_1, hasRequiredPool;
953
953
  function requirePool() {
954
954
  if (hasRequiredPool) return pool_1;
955
955
  hasRequiredPool = 1, pool_1 = h;
956
- function h(o, a, u) {
957
- var n = u || 8192, r = n >>> 1, i = null, t = n;
956
+ function h(o, u, a) {
957
+ var n = a || 8192, r = n >>> 1, i = null, t = n;
958
958
  return function(s) {
959
959
  if (s < 1 || s > r)
960
960
  return o(s);
961
961
  t + s > n && (i = o(n), t = 0);
962
- var l = a.call(i, t, t += s);
962
+ var l = u.call(i, t, t += s);
963
963
  return t & 7 && (t = (t | 7) + 1), l;
964
964
  };
965
965
  }
@@ -973,18 +973,18 @@ function requireLongbits() {
973
973
  function o(r, i) {
974
974
  this.lo = r >>> 0, this.hi = i >>> 0;
975
975
  }
976
- var a = o.zero = new o(0, 0);
977
- a.toNumber = function() {
976
+ var u = o.zero = new o(0, 0);
977
+ u.toNumber = function() {
978
978
  return 0;
979
- }, a.zzEncode = a.zzDecode = function() {
979
+ }, u.zzEncode = u.zzDecode = function() {
980
980
  return this;
981
- }, a.length = function() {
981
+ }, u.length = function() {
982
982
  return 1;
983
983
  };
984
- var u = o.zeroHash = "\0\0\0\0\0\0\0\0";
984
+ var a = o.zeroHash = "\0\0\0\0\0\0\0\0";
985
985
  o.fromNumber = function(i) {
986
986
  if (i === 0)
987
- return a;
987
+ return u;
988
988
  var t = i < 0;
989
989
  t && (i = -i);
990
990
  var e = i >>> 0, s = (i - e) / 4294967296 >>> 0;
@@ -997,7 +997,7 @@ function requireLongbits() {
997
997
  i = h.Long.fromString(i);
998
998
  else
999
999
  return o.fromNumber(parseInt(i, 10));
1000
- return i.low || i.high ? new o(i.low >>> 0, i.high >>> 0) : a;
1000
+ return i.low || i.high ? new o(i.low >>> 0, i.high >>> 0) : u;
1001
1001
  }, o.prototype.toNumber = function(i) {
1002
1002
  if (!i && this.hi >>> 31) {
1003
1003
  var t = ~this.lo + 1 >>> 0, e = ~this.hi >>> 0;
@@ -1009,7 +1009,7 @@ function requireLongbits() {
1009
1009
  };
1010
1010
  var n = String.prototype.charCodeAt;
1011
1011
  return o.fromHash = function(i) {
1012
- return i === u ? a : new o(
1012
+ return i === a ? u : new o(
1013
1013
  (n.call(i, 0) | n.call(i, 1) << 8 | n.call(i, 2) << 16 | n.call(i, 3) << 24) >>> 0,
1014
1014
  (n.call(i, 4) | n.call(i, 5) << 8 | n.call(i, 6) << 16 | n.call(i, 7) << 24) >>> 0
1015
1015
  );
@@ -1082,21 +1082,21 @@ function requireMinimal$1() {
1082
1082
  var t = o.LongBits.fromHash(r);
1083
1083
  return o.Long ? o.Long.fromBits(t.lo, t.hi, i) : t.toNumber(!!i);
1084
1084
  };
1085
- function a(n, r, i) {
1085
+ function u(n, r, i) {
1086
1086
  for (var t = Object.keys(r), e = 0; e < t.length; ++e)
1087
1087
  (n[t[e]] === void 0 || !i) && (n[t[e]] = r[t[e]]);
1088
1088
  return n;
1089
1089
  }
1090
- o.merge = a, o.lcFirst = function(r) {
1090
+ o.merge = u, o.lcFirst = function(r) {
1091
1091
  return r.charAt(0).toLowerCase() + r.substring(1);
1092
1092
  };
1093
- function u(n) {
1093
+ function a(n) {
1094
1094
  function r(i, t) {
1095
1095
  if (!(this instanceof r))
1096
1096
  return new r(i, t);
1097
1097
  Object.defineProperty(this, "message", { get: function() {
1098
1098
  return i;
1099
- } }), Error.captureStackTrace ? Error.captureStackTrace(this, r) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t && a(this, t);
1099
+ } }), Error.captureStackTrace ? Error.captureStackTrace(this, r) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t && u(this, t);
1100
1100
  }
1101
1101
  return r.prototype = Object.create(Error.prototype, {
1102
1102
  constructor: {
@@ -1127,7 +1127,7 @@ function requireMinimal$1() {
1127
1127
  }
1128
1128
  }), r;
1129
1129
  }
1130
- o.newError = u, o.ProtocolError = u("ProtocolError"), o.oneOfGetter = function(r) {
1130
+ o.newError = a, o.ProtocolError = a("ProtocolError"), o.oneOfGetter = function(r) {
1131
1131
  for (var i = {}, t = 0; t < r.length; ++t)
1132
1132
  i[r[t]] = 1;
1133
1133
  return function() {
@@ -1165,7 +1165,7 @@ var writer, hasRequiredWriter;
1165
1165
  function requireWriter() {
1166
1166
  if (hasRequiredWriter) return writer;
1167
1167
  hasRequiredWriter = 1, writer = e;
1168
- var h = requireMinimal$1(), o, a = h.LongBits, u = h.base64, n = h.utf8;
1168
+ var h = requireMinimal$1(), o, u = h.LongBits, a = h.base64, n = h.utf8;
1169
1169
  function r(b, g, k) {
1170
1170
  this.fn = b, this.len = g, this.next = void 0, this.val = k;
1171
1171
  }
@@ -1208,7 +1208,7 @@ function requireWriter() {
1208
1208
  g
1209
1209
  )).len, this;
1210
1210
  }, e.prototype.int32 = function(g) {
1211
- return g < 0 ? this._push(p, 10, a.fromNumber(g)) : this.uint32(g);
1211
+ return g < 0 ? this._push(p, 10, u.fromNumber(g)) : this.uint32(g);
1212
1212
  }, e.prototype.sint32 = function(g) {
1213
1213
  return this.uint32((g << 1 ^ g >> 31) >>> 0);
1214
1214
  };
@@ -1220,10 +1220,10 @@ function requireWriter() {
1220
1220
  g[k++] = b.lo;
1221
1221
  }
1222
1222
  e.prototype.uint64 = function(g) {
1223
- var k = a.from(g);
1223
+ var k = u.from(g);
1224
1224
  return this._push(p, k.length(), k);
1225
1225
  }, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(g) {
1226
- var k = a.from(g).zzEncode();
1226
+ var k = u.from(g).zzEncode();
1227
1227
  return this._push(p, k.length(), k);
1228
1228
  }, e.prototype.bool = function(g) {
1229
1229
  return this._push(l, 1, g ? 1 : 0);
@@ -1234,7 +1234,7 @@ function requireWriter() {
1234
1234
  e.prototype.fixed32 = function(g) {
1235
1235
  return this._push(f, 4, g >>> 0);
1236
1236
  }, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(g) {
1237
- var k = a.from(g);
1237
+ var k = u.from(g);
1238
1238
  return this._push(f, 4, k.lo)._push(f, 4, k.hi);
1239
1239
  }, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(g) {
1240
1240
  return this._push(h.float.writeFloatLE, 4, g);
@@ -1252,8 +1252,8 @@ function requireWriter() {
1252
1252
  if (!k)
1253
1253
  return this._push(l, 1, 0);
1254
1254
  if (h.isString(g)) {
1255
- var T = e.alloc(k = u.length(g));
1256
- u.decode(g, T, 0), g = T;
1255
+ var T = e.alloc(k = a.length(g));
1256
+ a.decode(g, T, 0), g = T;
1257
1257
  }
1258
1258
  return this.uint32(k)._push(w, k, g);
1259
1259
  }, e.prototype.string = function(g) {
@@ -1277,15 +1277,15 @@ function requireWriter() {
1277
1277
  var writer_buffer, hasRequiredWriter_buffer;
1278
1278
  function requireWriter_buffer() {
1279
1279
  if (hasRequiredWriter_buffer) return writer_buffer;
1280
- hasRequiredWriter_buffer = 1, writer_buffer = a;
1280
+ hasRequiredWriter_buffer = 1, writer_buffer = u;
1281
1281
  var h = requireWriter();
1282
- (a.prototype = Object.create(h.prototype)).constructor = a;
1282
+ (u.prototype = Object.create(h.prototype)).constructor = u;
1283
1283
  var o = requireMinimal$1();
1284
- function a() {
1284
+ function u() {
1285
1285
  h.call(this);
1286
1286
  }
1287
- a._configure = function() {
1288
- a.alloc = o._Buffer_allocUnsafe, a.writeBytesBuffer = o.Buffer && o.Buffer.prototype instanceof Uint8Array && o.Buffer.prototype.set.name === "set" ? function(r, i, t) {
1287
+ u._configure = function() {
1288
+ u.alloc = o._Buffer_allocUnsafe, u.writeBytesBuffer = o.Buffer && o.Buffer.prototype instanceof Uint8Array && o.Buffer.prototype.set.name === "set" ? function(r, i, t) {
1289
1289
  i.set(r, t);
1290
1290
  } : function(r, i, t) {
1291
1291
  if (r.copy)
@@ -1293,24 +1293,24 @@ function requireWriter_buffer() {
1293
1293
  else for (var e = 0; e < r.length; )
1294
1294
  i[t++] = r[e++];
1295
1295
  };
1296
- }, a.prototype.bytes = function(r) {
1296
+ }, u.prototype.bytes = function(r) {
1297
1297
  o.isString(r) && (r = o._Buffer_from(r, "base64"));
1298
1298
  var i = r.length >>> 0;
1299
- return this.uint32(i), i && this._push(a.writeBytesBuffer, i, r), this;
1299
+ return this.uint32(i), i && this._push(u.writeBytesBuffer, i, r), this;
1300
1300
  };
1301
- function u(n, r, i) {
1301
+ function a(n, r, i) {
1302
1302
  n.length < 40 ? o.utf8.write(n, r, i) : r.utf8Write ? r.utf8Write(n, i) : r.write(n, i);
1303
1303
  }
1304
- return a.prototype.string = function(r) {
1304
+ return u.prototype.string = function(r) {
1305
1305
  var i = o.Buffer.byteLength(r);
1306
- return this.uint32(i), i && this._push(u, i, r), this;
1307
- }, a._configure(), writer_buffer;
1306
+ return this.uint32(i), i && this._push(a, i, r), this;
1307
+ }, u._configure(), writer_buffer;
1308
1308
  }
1309
1309
  var reader, hasRequiredReader;
1310
1310
  function requireReader() {
1311
1311
  if (hasRequiredReader) return reader;
1312
1312
  hasRequiredReader = 1, reader = r;
1313
- var h = requireMinimal$1(), o, a = h.LongBits, u = h.utf8;
1313
+ var h = requireMinimal$1(), o, u = h.LongBits, a = h.utf8;
1314
1314
  function n(c, d) {
1315
1315
  return RangeError("index out of range: " + c.pos + " + " + (d || 1) + " > " + c.len);
1316
1316
  }
@@ -1348,7 +1348,7 @@ function requireReader() {
1348
1348
  return d >>> 1 ^ -(d & 1) | 0;
1349
1349
  };
1350
1350
  function e() {
1351
- var c = new a(0, 0), d = 0;
1351
+ var c = new u(0, 0), d = 0;
1352
1352
  if (this.len - this.pos > 4) {
1353
1353
  for (; d < 4; ++d)
1354
1354
  if (c.lo = (c.lo | (this.buf[this.pos] & 127) << d * 7) >>> 0, this.buf[this.pos++] < 128)
@@ -1396,7 +1396,7 @@ function requireReader() {
1396
1396
  function l() {
1397
1397
  if (this.pos + 8 > this.len)
1398
1398
  throw n(this, 8);
1399
- return new a(s(this.buf, this.pos += 4), s(this.buf, this.pos += 4));
1399
+ return new u(s(this.buf, this.pos += 4), s(this.buf, this.pos += 4));
1400
1400
  }
1401
1401
  return r.prototype.float = function() {
1402
1402
  if (this.pos + 4 > this.len)
@@ -1421,7 +1421,7 @@ function requireReader() {
1421
1421
  return this._slice.call(this.buf, p, f);
1422
1422
  }, r.prototype.string = function() {
1423
1423
  var d = this.bytes();
1424
- return u.read(d, 0, d.length);
1424
+ return a.read(d, 0, d.length);
1425
1425
  }, r.prototype.skip = function(d) {
1426
1426
  if (typeof d == "number") {
1427
1427
  if (this.pos + d > this.len)
@@ -1484,19 +1484,19 @@ function requireReader() {
1484
1484
  var reader_buffer, hasRequiredReader_buffer;
1485
1485
  function requireReader_buffer() {
1486
1486
  if (hasRequiredReader_buffer) return reader_buffer;
1487
- hasRequiredReader_buffer = 1, reader_buffer = a;
1487
+ hasRequiredReader_buffer = 1, reader_buffer = u;
1488
1488
  var h = requireReader();
1489
- (a.prototype = Object.create(h.prototype)).constructor = a;
1489
+ (u.prototype = Object.create(h.prototype)).constructor = u;
1490
1490
  var o = requireMinimal$1();
1491
- function a(u) {
1492
- h.call(this, u);
1491
+ function u(a) {
1492
+ h.call(this, a);
1493
1493
  }
1494
- return a._configure = function() {
1495
- o.Buffer && (a.prototype._slice = o.Buffer.prototype.slice);
1496
- }, a.prototype.string = function() {
1494
+ return u._configure = function() {
1495
+ o.Buffer && (u.prototype._slice = o.Buffer.prototype.slice);
1496
+ }, u.prototype.string = function() {
1497
1497
  var n = this.uint32();
1498
1498
  return this.buf.utf8Slice ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + n, this.len)) : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + n, this.len));
1499
- }, a._configure(), reader_buffer;
1499
+ }, u._configure(), reader_buffer;
1500
1500
  }
1501
1501
  var rpc = {}, service, hasRequiredService;
1502
1502
  function requireService() {
@@ -1504,17 +1504,17 @@ function requireService() {
1504
1504
  hasRequiredService = 1, service = o;
1505
1505
  var h = requireMinimal$1();
1506
1506
  (o.prototype = Object.create(h.EventEmitter.prototype)).constructor = o;
1507
- function o(a, u, n) {
1508
- if (typeof a != "function")
1507
+ function o(u, a, n) {
1508
+ if (typeof u != "function")
1509
1509
  throw TypeError("rpcImpl must be a function");
1510
- h.EventEmitter.call(this), this.rpcImpl = a, this.requestDelimited = !!u, this.responseDelimited = !!n;
1510
+ h.EventEmitter.call(this), this.rpcImpl = u, this.requestDelimited = !!a, this.responseDelimited = !!n;
1511
1511
  }
1512
- return o.prototype.rpcCall = function a(u, n, r, i, t) {
1512
+ return o.prototype.rpcCall = function u(a, n, r, i, t) {
1513
1513
  if (!i)
1514
1514
  throw TypeError("request must be specified");
1515
1515
  var e = this;
1516
1516
  if (!t)
1517
- return h.asPromise(a, e, u, n, r, i);
1517
+ return h.asPromise(u, e, a, n, r, i);
1518
1518
  if (!e.rpcImpl) {
1519
1519
  setTimeout(function() {
1520
1520
  t(Error("already ended"));
@@ -1523,11 +1523,11 @@ function requireService() {
1523
1523
  }
1524
1524
  try {
1525
1525
  return e.rpcImpl(
1526
- u,
1526
+ a,
1527
1527
  n[e.requestDelimited ? "encodeDelimited" : "encode"](i).finish(),
1528
1528
  function(l, c) {
1529
1529
  if (l)
1530
- return e.emit("error", l, u), t(l);
1530
+ return e.emit("error", l, a), t(l);
1531
1531
  if (c === null) {
1532
1532
  e.end(
1533
1533
  /* endedByRPC */
@@ -1539,19 +1539,19 @@ function requireService() {
1539
1539
  try {
1540
1540
  c = r[e.responseDelimited ? "decodeDelimited" : "decode"](c);
1541
1541
  } catch (d) {
1542
- return e.emit("error", d, u), t(d);
1542
+ return e.emit("error", d, a), t(d);
1543
1543
  }
1544
- return e.emit("data", c, u), t(null, c);
1544
+ return e.emit("data", c, a), t(null, c);
1545
1545
  }
1546
1546
  );
1547
1547
  } catch (s) {
1548
- e.emit("error", s, u), setTimeout(function() {
1548
+ e.emit("error", s, a), setTimeout(function() {
1549
1549
  t(s);
1550
1550
  }, 0);
1551
1551
  return;
1552
1552
  }
1553
- }, o.prototype.end = function(u) {
1554
- return this.rpcImpl && (u || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this;
1553
+ }, o.prototype.end = function(a) {
1554
+ return this.rpcImpl && (a || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this;
1555
1555
  }, service;
1556
1556
  }
1557
1557
  var hasRequiredRpc;
@@ -1569,11 +1569,11 @@ var hasRequiredIndexMinimal;
1569
1569
  function requireIndexMinimal() {
1570
1570
  return hasRequiredIndexMinimal || (hasRequiredIndexMinimal = 1, function(h) {
1571
1571
  var o = h;
1572
- o.build = "minimal", o.Writer = requireWriter(), o.BufferWriter = requireWriter_buffer(), o.Reader = requireReader(), o.BufferReader = requireReader_buffer(), o.util = requireMinimal$1(), o.rpc = requireRpc(), o.roots = requireRoots(), o.configure = a;
1573
- function a() {
1572
+ o.build = "minimal", o.Writer = requireWriter(), o.BufferWriter = requireWriter_buffer(), o.Reader = requireReader(), o.BufferReader = requireReader_buffer(), o.util = requireMinimal$1(), o.rpc = requireRpc(), o.roots = requireRoots(), o.configure = u;
1573
+ function u() {
1574
1574
  o.util._configure(), o.Writer._configure(o.BufferWriter), o.Reader._configure(o.BufferReader);
1575
1575
  }
1576
- a();
1576
+ u();
1577
1577
  }(indexMinimal)), indexMinimal;
1578
1578
  }
1579
1579
  var minimal, hasRequiredMinimal;
@@ -1586,10 +1586,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1586
1586
  return h.quick = function() {
1587
1587
  const o = {};
1588
1588
  return o.voice = function() {
1589
- const a = {};
1590
- return a.proto = function() {
1591
- const u = {};
1592
- return u.SeiData = function() {
1589
+ const u = {};
1590
+ return u.proto = function() {
1591
+ const a = {};
1592
+ return a.SeiData = function() {
1593
1593
  function n(r) {
1594
1594
  if (r) for (let i = Object.keys(r), t = 0; t < i.length; ++t) r[i[t]] != null && (this[i[t]] = r[i[t]]);
1595
1595
  }
@@ -1682,10 +1682,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1682
1682
  }, n.getTypeUrl = function(i) {
1683
1683
  return i === void 0 && (i = "type.googleapis.com"), i + "/com.quick.voice.proto.SeiData";
1684
1684
  }, n;
1685
- }(), u.EventType = function() {
1685
+ }(), a.EventType = function() {
1686
1686
  const n = {}, r = Object.create(n);
1687
1687
  return r[n[0] = "Layout"] = 0, r[n[1] = "Custom"] = 1, r;
1688
- }(), u.LayoutData = function() {
1688
+ }(), a.LayoutData = function() {
1689
1689
  function n(i) {
1690
1690
  if (this.userMap = {}, i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
1691
1691
  }
@@ -1844,7 +1844,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1844
1844
  }, n.getTypeUrl = function(t) {
1845
1845
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.LayoutData";
1846
1846
  }, n;
1847
- }(), u.UserInfo = function() {
1847
+ }(), a.UserInfo = function() {
1848
1848
  function n(i) {
1849
1849
  if (this.audios = [], this.videos = [], i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
1850
1850
  }
@@ -1967,7 +1967,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1967
1967
  }, n.getTypeUrl = function(t) {
1968
1968
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.UserInfo";
1969
1969
  }, n;
1970
- }(), u.AudioInfo = function() {
1970
+ }(), a.AudioInfo = function() {
1971
1971
  function n(i) {
1972
1972
  if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
1973
1973
  }
@@ -2072,7 +2072,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2072
2072
  }, n.getTypeUrl = function(t) {
2073
2073
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.AudioInfo";
2074
2074
  }, n;
2075
- }(), u.VideoInfo = function() {
2075
+ }(), a.VideoInfo = function() {
2076
2076
  function n(i) {
2077
2077
  if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
2078
2078
  }
@@ -2198,7 +2198,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2198
2198
  }, n.getTypeUrl = function(t) {
2199
2199
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.VideoInfo";
2200
2200
  }, n;
2201
- }(), u.CustomInfo = function() {
2201
+ }(), a.CustomInfo = function() {
2202
2202
  function n(i) {
2203
2203
  if (this.customKeyMap = {}, i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
2204
2204
  }
@@ -2305,17 +2305,17 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2305
2305
  }, n.getTypeUrl = function(t) {
2306
2306
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.CustomInfo";
2307
2307
  }, n;
2308
- }(), u.LayoutType = function() {
2308
+ }(), a.LayoutType = function() {
2309
2309
  const n = {}, r = Object.create(n);
2310
2310
  return r[n[0] = "AudioAndVideo"] = 0, r[n[1] = "OnlyAudio"] = 1, r[n[2] = "OnlyVideo"] = 2, r;
2311
- }(), u.AudioType = function() {
2311
+ }(), a.AudioType = function() {
2312
2312
  const n = {}, r = Object.create(n);
2313
2313
  return r[n[0] = "Microphone"] = 0, r[n[1] = "SystemVoice"] = 1, r;
2314
- }(), u.VideoType = function() {
2314
+ }(), a.VideoType = function() {
2315
2315
  const n = {}, r = Object.create(n);
2316
2316
  return r[n[0] = "Camera"] = 0, r[n[1] = "Screen"] = 1, r;
2317
- }(), u;
2318
- }(), a;
2317
+ }(), a;
2318
+ }(), u;
2319
2319
  }(), o;
2320
2320
  }(), h;
2321
2321
  })(), createAudioInfo = () => ({
@@ -2352,11 +2352,11 @@ class RoomUser {
2352
2352
  });
2353
2353
  m(this, "init", (o) => {
2354
2354
  var t, e, s, l;
2355
- const { id: a, audios: u = [], videos: n = [] } = o;
2356
- this.userId = a;
2355
+ const { id: u, audios: a = [], videos: n = [] } = o;
2356
+ this.userId = u;
2357
2357
  const r = this.getUpdateTimeKey();
2358
2358
  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);
2359
- for (const c of u) {
2359
+ for (const c of a) {
2360
2360
  const { type: d = 0, isEnable: p = !1, isMute: f = !1, updateTime: w, volume: b = 0 } = c;
2361
2361
  switch (d) {
2362
2362
  case 0:
@@ -2395,26 +2395,26 @@ class RoomUser {
2395
2395
  r !== i && (this.updateTime = (/* @__PURE__ */ new Date()).getTime());
2396
2396
  });
2397
2397
  m(this, "destroy", () => {
2398
- var o, a;
2399
- (o = this.mc_video) != null && o.destroy && this.mc_video.destroy(), (a = this.ss_video) != null && a.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;
2398
+ var o, u;
2399
+ (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;
2400
2400
  });
2401
2401
  }
2402
2402
  }
2403
2403
  const parseSEI = (h) => {
2404
- let o = 0, a = 0;
2404
+ let o = 0, u = 0;
2405
2405
  for (; ; ) {
2406
2406
  const n = h[o];
2407
- if (a = a + n, o = o + 1, n !== 255) break;
2407
+ if (u = u + n, o = o + 1, n !== 255) break;
2408
2408
  }
2409
- let u = 0;
2409
+ let a = 0;
2410
2410
  for (; ; ) {
2411
2411
  const n = h[o];
2412
- if (u = u + n, o = o + 1, n !== 255) break;
2412
+ if (a = a + n, o = o + 1, n !== 255) break;
2413
2413
  }
2414
- if (a === 5) {
2414
+ if (u === 5) {
2415
2415
  const n = h.slice(o, o + 16), i = Array.from(n, (f) => f.toString(16).padStart(2, "0")).join("");
2416
2416
  o = o + 16;
2417
- const t = u - 16, e = h.slice(o, o + t), s = com.quick.voice.proto.SeiData.decode(e), { event: l = 0 } = s, c = s.data;
2417
+ const t = a - 16, e = h.slice(o, o + t), s = com.quick.voice.proto.SeiData.decode(e), { event: l = 0 } = s, c = s.data;
2418
2418
  let d;
2419
2419
  switch (l) {
2420
2420
  case 0:
@@ -2459,47 +2459,44 @@ class QuickVoPlayer {
2459
2459
  m(this, "getStream", () => this.prPlayer.getStream());
2460
2460
  m(this, "getAllUseUpdateKey", () => {
2461
2461
  const o = [...this.usersMap.values()];
2462
- return Array.from(o, (u) => u.updateTime).join("_");
2462
+ return Array.from(o, (a) => a.updateTime).join("_");
2463
2463
  });
2464
- m(this, "checkAndCreateUser", (o, a) => {
2465
- var u, n;
2466
- if (this.usersMap.has(o)) {
2467
- const r = this.usersMap.get(o);
2468
- if (r == null || r.init(a), r != null && r.mc_video) {
2469
- const { sx: i, sy: t, sw: e, sh: s } = r.mc_video;
2470
- (u = r == null ? void 0 : r.mc_video.worker) == null || u.setCut({ sx: i, sy: t, sw: e, sh: s });
2464
+ m(this, "checkAndCreateUser", (o, u) => {
2465
+ var n, r;
2466
+ !this.usersMap.has(o) && this.usersMap.set(o, new RoomUser());
2467
+ const a = this.usersMap.get(o);
2468
+ if (a) {
2469
+ if (a.init(u), a.mc_video && a.mc_video.worker === void 0) {
2470
+ const { sx: i, sy: t, sw: e, sh: s } = a.mc_video, l = `${a.userId}_mc_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2471
+ a.mc_video.worker = c, this.displayMode === "original" && c.setPause(!0), a.mc_video.stream = d, a.mc_video.destroy = () => {
2472
+ p(), this.prPlayer.cut.remove(l), a.mc_video = void 0;
2473
+ };
2471
2474
  }
2472
- if (r != null && r.ss_video) {
2473
- const { sx: i, sy: t, sw: e, sh: s } = r.ss_video;
2474
- (n = r == null ? void 0 : r.ss_video.worker) == null || n.setCut({ sx: i, sy: t, sw: e, sh: s });
2475
+ if (a.ss_video && a.ss_video.worker === void 0) {
2476
+ const { sx: i, sy: t, sw: e, sh: s } = a.ss_video, l = `${a.userId}_ss_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2477
+ a.ss_video.worker = c, this.displayMode === "original" && c.setPause(!0), a.ss_video.stream = d, a.ss_video.destroy = () => {
2478
+ p(), this.prPlayer.cut.remove(l), a.ss_video = void 0;
2479
+ };
2475
2480
  }
2476
- } else {
2477
- const r = new RoomUser();
2478
- if (this.usersMap.set(o, r), r.init(a), r) {
2479
- if (r.mc_video) {
2480
- const { sx: i, sy: t, sw: e, sh: s } = r.mc_video, l = `${r.userId}_mc_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2481
- r.mc_video.worker = c, this.displayMode === "original" && c.setPause(!0), r.mc_video.stream = d, r.mc_video.destroy = () => {
2482
- p(), this.prPlayer.cut.remove(l), this.usersMap.delete(r.userId);
2483
- };
2484
- }
2485
- if (r.ss_video) {
2486
- const { sx: i, sy: t, sw: e, sh: s } = r.ss_video, l = `${r.userId}_ss_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2487
- r.ss_video.worker = c, this.displayMode === "original" && c.setPause(!0), r.ss_video.stream = d, r.ss_video.destroy = () => {
2488
- p(), this.prPlayer.cut.remove(l), this.usersMap.delete(r.userId);
2489
- };
2490
- }
2481
+ if (a != null && a.mc_video) {
2482
+ const { sx: i, sy: t, sw: e, sh: s } = a.mc_video;
2483
+ (n = a == null ? void 0 : a.mc_video.worker) == null || n.setCut({ sx: i, sy: t, sw: e, sh: s });
2484
+ }
2485
+ if (a != null && a.ss_video) {
2486
+ const { sx: i, sy: t, sw: e, sh: s } = a.ss_video;
2487
+ (r = a == null ? void 0 : a.ss_video.worker) == null || r.setCut({ sx: i, sy: t, sw: e, sh: s });
2491
2488
  }
2492
2489
  }
2493
2490
  });
2494
2491
  m(this, "setDisplayMode", (o) => {
2495
- var a, u, n, r, i, t, e, s;
2492
+ var u, a, n, r, i, t, e, s;
2496
2493
  switch (this.displayMode = o, o) {
2497
2494
  case "original":
2498
2495
  {
2499
2496
  this.prPlayer.setPause(!1);
2500
2497
  const l = [...this.usersMap.values()];
2501
2498
  for (const c of l)
2502
- (u = (a = c.mc_video) == null ? void 0 : a.worker) == null || u.setPause(!0), (r = (n = c.ss_video) == null ? void 0 : n.worker) == null || r.setPause(!0);
2499
+ (a = (u = c.mc_video) == null ? void 0 : u.worker) == null || a.setPause(!0), (r = (n = c.ss_video) == null ? void 0 : n.worker) == null || r.setPause(!0);
2503
2500
  }
2504
2501
  break;
2505
2502
  case "cut":
@@ -2517,10 +2514,10 @@ class QuickVoPlayer {
2517
2514
  */
2518
2515
  m(this, "onSEI", (o) => {
2519
2516
  try {
2520
- const a = parseSEI(o);
2521
- if (!a) return;
2522
- const { event: u, data: n } = a;
2523
- switch (u) {
2517
+ const u = parseSEI(o);
2518
+ if (!u) return;
2519
+ const { event: a, data: n } = u;
2520
+ switch (a) {
2524
2521
  case 0:
2525
2522
  {
2526
2523
  const { roomId: r, userMap: i } = n;
@@ -2529,7 +2526,7 @@ class QuickVoPlayer {
2529
2526
  {
2530
2527
  const l = [...this.usersMap.values()];
2531
2528
  for (const c of l)
2532
- e.includes(c.userId) || c == null || c.destroy();
2529
+ e.includes(c.userId) || (c == null || c.destroy(), this.usersMap.delete(c.userId));
2533
2530
  }
2534
2531
  for (const l of e) {
2535
2532
  const c = i[l];
@@ -2549,15 +2546,15 @@ class QuickVoPlayer {
2549
2546
  }
2550
2547
  break;
2551
2548
  }
2552
- } catch (a) {
2553
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", a);
2549
+ } catch (u) {
2550
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", u);
2554
2551
  }
2555
2552
  });
2556
2553
  m(this, "onAnalysis", (o) => {
2557
2554
  this.on.analysis && this.on.analysis(o);
2558
2555
  });
2559
- const { debug: a = !1 } = o;
2560
- this.option.debug = a, this.prPlayer = new et({ debug: a }), this.prPlayer.on.demuxer.chunk = (u) => {
2556
+ const { debug: u = !1 } = o;
2557
+ this.option.debug = u, this.prPlayer = new et({ debug: u }), this.prPlayer.on.demuxer.chunk = (a) => {
2561
2558
  }, this.prPlayer.on.decoder.sei = this.onSEI, this.prPlayer.on.decoder.analysis = this.onAnalysis;
2562
2559
  }
2563
2560
  }