quickvo-player 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
- var Y = Object.defineProperty;
2
- var Z = (h) => {
1
+ var Q = Object.defineProperty;
2
+ var J = (h) => {
3
3
  throw TypeError(h);
4
4
  };
5
- var et = (h, o, u) => o in h ? Y(h, o, { enumerable: !0, configurable: !0, writable: !0, value: u }) : h[o] = u;
6
- var y = (h, o, u) => et(h, typeof o != "symbol" ? o + "" : o, u), Q = (h, o, u) => o.has(h) || Z("Cannot " + u);
7
- var S = (h, o, u) => (Q(h, o, "read from private field"), u ? u.call(h) : o.get(h)), K = (h, o, u) => o.has(h) ? Z("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, u), H = (h, o, u, a) => (Q(h, o, "write to private field"), a ? a.call(h, u) : o.set(h, u), u);
8
- const x = '(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>100&&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);", x], { type: "text/javascript;charset=utf-8" });
9
- function R(h) {
5
+ var Y = (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) => Y(h, typeof o != "symbol" ? o + "" : o, a), Z = (h, o, a) => o.has(h) || J("Cannot " + a);
7
+ var R = (h, o, a) => (Z(h, o, "read from private field"), a ? a.call(h) : o.get(h)), H = (h, o, a) => o.has(h) ? J("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, a), K = (h, o, a, u) => (Z(h, o, "write to private field"), u ? u.call(h, a) : o.set(h, a), a);
8
+ const A = '(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>100&&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);", A], { type: "text/javascript;charset=utf-8" });
9
+ function P(h) {
10
10
  let o;
11
11
  try {
12
12
  if (o = _ && (self.URL || self.webkitURL).createObjectURL(_), !o) throw "";
13
- const u = new Worker(o, {
13
+ const a = new Worker(o, {
14
14
  name: h == null ? void 0 : h.name
15
15
  });
16
- return u.addEventListener("error", () => {
16
+ return a.addEventListener("error", () => {
17
17
  (self.URL || self.webkitURL).revokeObjectURL(o);
18
- }), u;
18
+ }), a;
19
19
  } catch {
20
20
  return new Worker(
21
- "data:text/javascript;charset=utf-8," + encodeURIComponent(x),
21
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(A),
22
22
  {
23
23
  name: h == null ? void 0 : h.name
24
24
  }
@@ -27,44 +27,44 @@ function R(h) {
27
27
  }
28
28
  class I {
29
29
  constructor() {
30
- y(this, "worker", new R());
31
- y(this, "on", {});
32
- y(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
33
- y(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
34
- y(this, "destroy", () => {
30
+ m(this, "worker", new P());
31
+ m(this, "on", {});
32
+ m(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
33
+ m(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
34
+ m(this, "destroy", () => {
35
35
  this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
36
36
  });
37
37
  this.worker.onmessage = (o) => {
38
- const { action: u, data: a } = o.data;
39
- switch (u) {
38
+ const { action: a, data: u } = o.data;
39
+ switch (a) {
40
40
  case "on.info":
41
- this.on.info && this.on.info(a);
41
+ this.on.info && this.on.info(u);
42
42
  break;
43
43
  case "on.config":
44
- this.on.config && this.on.config(a);
44
+ this.on.config && this.on.config(u);
45
45
  break;
46
46
  case "on.chunk":
47
- this.on.chunk && this.on.chunk(a);
47
+ this.on.chunk && this.on.chunk(u);
48
48
  break;
49
49
  case "on.debug":
50
- this.on.debug && this.on.debug(a);
50
+ this.on.debug && this.on.debug(u);
51
51
  break;
52
52
  }
53
53
  };
54
54
  }
55
55
  }
56
- const M = `(function(){"use strict";class r{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];currentChunk;isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[30,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeedRatio=1;maxDecodingSpeedRatio=2;decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;frameStartTime;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};initAudio=e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const t=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:t})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)};initVideo=e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{this.frameStartTime||(this.frameStartTime=i.timestamp);const t=i.timestamp-this.frameStartTime+this.baseTime*1e3,s=await createImageBitmap(i);i.close(),s.width>0&&s.height>0?(this.on.video.decode&&this.on.video.decode({timestamp:t,bitmap:s}),this.currentChunk&&this.currentChunk.kind==="video"&&this.currentChunk.nalus&&this.on.nalus&&this.on.nalus(this.currentChunk.nalus)):s.close()},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};push=e=>{this.pendingChunks.push(e)};destroy=()=>{this.audio.destroy(),this.video.destroy(),this.pendingChunks=[],this.firstVideoChunkTimestamp=void 0,this.secondVideoChunkTimestamp=void 0,this.frameStartTime=void 0,this.lastRenderTime=void 0,this.nextRenderTime=void 0,clearInterval(this.decodeTimer)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const t=this.lastRenderTime-this.nextRenderTime;e-=t}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;this.currentChunk=this.pendingChunks.shift(),!!this.currentChunk;){const e=this.pendingChunks.length;if(this.frameTrack){const[s,n]=this.fameTrackOption[this.pattern];if(e<=s&&(this.isFrameTrack=!1),e>=n&&(this.isFrameTrack=!0),this.isFrameTrack){const a=Math.min(1+(e-s)/100,this.maxDecodingSpeedRatio);this.decodingSpeedRatio=Number(a.toFixed(1))}else this.decodingSpeedRatio=1}if(this.on.analysis){const{decodingSpeed:s,decodingSpeedRatio:n,fps:a}=this;this.on.analysis({decodingSpeed:s,decodingSpeedRatio:n,fps:a,cacheLength:e})}const{kind:i,init:t}=this.currentChunk;switch(i){case"audio":this.decodeAudio(t);break;case"video":this.decodeVideo(t);break}if(i==="video")break}this.isProcessing=!1}};decodeAudio=e=>{if(!this.audioDecoder)return;const i=new EncodedAudioChunk(e);this.audioDecoder.decode(i)};decodeVideo=e=>{if(this.videoDecoder&&(e.type==="key"&&(this.hasKeyFrame=!0),this.firstVideoChunkTimestamp?this.secondVideoChunkTimestamp||(this.secondVideoChunkTimestamp=e.timestamp,this.decodingSpeed=(this.secondVideoChunkTimestamp-this.firstVideoChunkTimestamp)/1e3):this.firstVideoChunkTimestamp=e.timestamp,this.hasKeyFrame)){const i=new EncodedVideoChunk(e);this.videoDecoder.decode(i)}};audio={flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new r;d.on.audio.decode=o=>postMessage({action:"on.audio.decode",data:o},[o.audioData]),d.on.audio.error=o=>postMessage({action:"on.audio.error",data:o}),d.on.video.decode=o=>postMessage({action:"on.video.decode",data:o},[o.bitmap]),d.on.video.error=o=>postMessage({action:"on.video.error",data:o}),d.on.nalus=o=>postMessage({action:"on.nalus",data:o}),d.on.analysis=o=>postMessage({action:"on.analysis",data:o}),onmessage=o=>{const{action:e,data:i}=o.data,t=d[e];t&&t(i)}})();
56
+ const M = `(function(){"use strict";class a{pattern="flv";audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;baseTime=0;pendingChunks=[];currentChunk;isProcessing=!1;decodeTimer=0;frameTrack=!1;isFrameTrack=!1;fameTrackOption={flv:[30,50],hls:[200,300],dash:[50,100],rtmp:[50,100]};decodingSpeedRatio=1;maxDecodingSpeedRatio=2;decodingSpeed=16;fps=0;firstVideoChunkTimestamp;secondVideoChunkTimestamp;frameStartTime;lastRenderTime;nextRenderTime;on={audio:{},video:{}};constructor(){}init=e=>{this.destroy(),this.pattern=e,this.baseTime=new Date().getTime()-performance.now(),this.initDecodeInterval()};initAudio=e=>{this.audio.destroy(),this.audioDecoderConfig={...e},this.audioDecoder=new AudioDecoder({output:i=>{const o=this.decodingSpeedRatio;this.on.audio.decode&&this.on.audio.decode({audioData:i,playbackRate:o})},error:i=>{this.on.audio.error&&this.on.audio.error(i)}}),this.audioDecoder.configure(this.audioDecoderConfig)};initVideo=e=>{this.video.destroy(),this.videoDecoderConfig={...e},this.videoDecoder=new VideoDecoder({output:async i=>{this.frameStartTime||(this.frameStartTime=i.timestamp);try{const o=i.timestamp-this.frameStartTime+this.baseTime*1e3,s=await createImageBitmap(i);if(i.close(),!s.width||!s.height)return s.close();this.on.video.decode&&this.on.video.decode({timestamp:o,bitmap:s}),this.currentChunk&&this.currentChunk.kind==="video"&&this.currentChunk.nalus&&this.on.nalus&&this.on.nalus(this.currentChunk.nalus)}catch{i.close()}},error:i=>{this.on.video.error&&this.on.video.error(i)}}),this.videoDecoder.configure(this.videoDecoderConfig)};setFrameTrack=e=>{this.frameTrack=e,this.frameTrack===!1&&(this.decodingSpeedRatio=1)};push=e=>{this.pendingChunks.push(e)};destroy=()=>{this.audio.destroy(),this.video.destroy(),this.pendingChunks=[],this.firstVideoChunkTimestamp=void 0,this.secondVideoChunkTimestamp=void 0,this.frameStartTime=void 0,this.lastRenderTime=void 0,this.nextRenderTime=void 0,clearInterval(this.decodeTimer)};initDecodeInterval=()=>{let e=this.decodingSpeed/this.decodingSpeedRatio;const i=this.baseTime+performance.now();if(this.lastRenderTime||(this.lastRenderTime=i),this.fps=Math.round(1e3/(i-this.lastRenderTime)),this.lastRenderTime=i,this.nextRenderTime){const o=this.lastRenderTime-this.nextRenderTime;e-=o}this.nextRenderTime=this.lastRenderTime+e,this.decodeTimer=setTimeout(()=>{this.decode(),this.initDecodeInterval()},e)};decode=()=>{if(this.isProcessing!==!0){for(this.isProcessing=!0;this.currentChunk=this.pendingChunks.shift(),!!this.currentChunk;){const e=this.pendingChunks.length;if(this.frameTrack){const[s,n]=this.fameTrackOption[this.pattern];if(e<=s&&(this.isFrameTrack=!1),e>=n&&(this.isFrameTrack=!0),this.isFrameTrack){const r=Math.min(1+(e-s)/100,this.maxDecodingSpeedRatio);this.decodingSpeedRatio=Number(r.toFixed(1))}else this.decodingSpeedRatio=1}if(this.on.analysis){const{decodingSpeed:s,decodingSpeedRatio:n,fps:r}=this;this.on.analysis({decodingSpeed:s,decodingSpeedRatio:n,fps:r,cacheLength:e})}const{kind:i,init:o}=this.currentChunk;switch(i){case"audio":this.decodeAudio(o);break;case"video":this.decodeVideo(o);break}if(i==="video")break}this.isProcessing=!1}};decodeAudio=e=>{if(!this.audioDecoder)return;const i=new EncodedAudioChunk(e);this.audioDecoder.decode(i)};decodeVideo=e=>{if(this.videoDecoder&&(e.type==="key"&&(this.hasKeyFrame=!0),this.firstVideoChunkTimestamp?this.secondVideoChunkTimestamp||(this.secondVideoChunkTimestamp=e.timestamp,this.decodingSpeed=(this.secondVideoChunkTimestamp-this.firstVideoChunkTimestamp)/1e3):this.firstVideoChunkTimestamp=e.timestamp,this.hasKeyFrame)){const i=new EncodedVideoChunk(e);this.videoDecoder.decode(i)}};audio={flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const d=new a;d.on.audio.decode=t=>postMessage({action:"on.audio.decode",data:t},[t.audioData]),d.on.audio.error=t=>postMessage({action:"on.audio.error",data:t}),d.on.video.decode=t=>postMessage({action:"on.video.decode",data:t},[t.bitmap]),d.on.video.error=t=>postMessage({action:"on.video.error",data:t}),d.on.nalus=t=>postMessage({action:"on.nalus",data:t}),d.on.analysis=t=>postMessage({action:"on.analysis",data:t}),onmessage=t=>{const{action:e,data:i}=t.data,o=d[e];o&&o(i)}})();
57
57
  `, C = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", M], { type: "text/javascript;charset=utf-8" });
58
- function V(h) {
58
+ function L(h) {
59
59
  let o;
60
60
  try {
61
61
  if (o = C && (self.URL || self.webkitURL).createObjectURL(C), !o) throw "";
62
- const u = new Worker(o, {
62
+ const a = new Worker(o, {
63
63
  name: h == null ? void 0 : h.name
64
64
  });
65
- return u.addEventListener("error", () => {
65
+ return a.addEventListener("error", () => {
66
66
  (self.URL || self.webkitURL).revokeObjectURL(o);
67
- }), u;
67
+ }), a;
68
68
  } catch {
69
69
  return new Worker(
70
70
  "data:text/javascript;charset=utf-8," + encodeURIComponent(M),
@@ -74,146 +74,145 @@ function V(h) {
74
74
  );
75
75
  }
76
76
  }
77
- class L {
77
+ class V {
78
78
  constructor() {
79
- y(this, "worker", new V());
80
- y(this, "on", { audio: {}, video: {} });
81
- y(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
82
- y(this, "initAudio", (o) => this.worker.postMessage({ action: "initAudio", data: o }));
83
- y(this, "initVideo", (o) => this.worker.postMessage({ action: "initVideo", data: o }));
84
- y(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
85
- y(this, "setFrameTrack", (o) => this.worker.postMessage({ action: "setFrameTrack", data: o }));
86
- y(this, "destroy", () => {
79
+ m(this, "worker", new L());
80
+ m(this, "on", { audio: {}, video: {} });
81
+ m(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
82
+ m(this, "initAudio", (o) => this.worker.postMessage({ action: "initAudio", data: o }));
83
+ m(this, "initVideo", (o) => this.worker.postMessage({ action: "initVideo", data: o }));
84
+ m(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
85
+ m(this, "setFrameTrack", (o) => this.worker.postMessage({ action: "setFrameTrack", data: o }));
86
+ m(this, "destroy", () => {
87
87
  this.worker.postMessage({ action: "destroy" }), this.worker.terminate();
88
88
  });
89
89
  this.worker.onmessage = (o) => {
90
- const { action: u, data: a } = o.data;
91
- switch (u) {
90
+ const { action: a, data: u } = o.data;
91
+ switch (a) {
92
92
  case "on.audio.decode":
93
- this.on.audio.decode && this.on.audio.decode(a);
93
+ this.on.audio.decode && this.on.audio.decode(u);
94
94
  break;
95
95
  case "on.audio.error":
96
- this.on.audio.error && this.on.audio.error(a);
96
+ this.on.audio.error && this.on.audio.error(u);
97
97
  break;
98
98
  case "on.video.decode":
99
- this.on.video.decode && this.on.video.decode(a);
99
+ this.on.video.decode && this.on.video.decode(u);
100
100
  break;
101
101
  case "on.video.error":
102
- this.on.video.error && this.on.video.error(a);
102
+ this.on.video.error && this.on.video.error(u);
103
103
  break;
104
104
  case "on.nalus":
105
- this.on.nalus && this.on.nalus(a);
105
+ this.on.nalus && this.on.nalus(u);
106
106
  break;
107
107
  case "on.analysis":
108
- this.on.analysis && this.on.analysis(a);
108
+ this.on.analysis && this.on.analysis(u);
109
109
  break;
110
110
  }
111
111
  };
112
112
  }
113
113
  }
114
- const D = `(function(){"use strict";class h{renderMap=new Map;constructor(){}push=async t=>{const{timestamp:s}=t,{bitmap:e}=t;if(e.height===0||e.width===0)return e.close();const n=[...this.renderMap.keys()];for(const i of n){const a=this.renderMap.get(i);if(!a)continue;const{pause:f=!1,writer:c,option:d}=a;if(f!==!0)if(i==="default"||!d){const o=new VideoFrame(e,{timestamp:s});c.write(o),o.close()}else{const{sx:o=0,sy:w=0,sw:y=e.width,sh:M=e.height}=d,u=await createImageBitmap(e,o,w,y,M),p=new VideoFrame(u,{timestamp:s});u.close(),c.write(p),p.close()}}e.close()};addCut=t=>{const{key:s,writable:e,option:n}={key:"default",...t},i=e.getWriter();this.renderMap.set(s,{writable:e,writer:i,option:n,pause:!1})};delCut=t=>{this.renderMap.delete(t)};setCut=t=>{const{key:s,cutOption:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,option:e})};setPause=t=>{const{key:s,pause:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,pause:e})};destroy=()=>{this.renderMap=new Map}}const l=new h;onmessage=r=>{const{action:t,data:s}=r.data,e=l[t];e&&e(s)}})();
115
- `, v = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
116
- function N(h) {
114
+ const S = `(function(){"use strict";class l{renderMap=new Map;constructor(){}push=async t=>{const{timestamp:s}=t,{bitmap:e}=t;if(e.height===0||e.width===0)return e.close();try{const n=[...this.renderMap.keys()];for(const i of n){const a=this.renderMap.get(i);if(!a)continue;const{pause:y=!1,writer:h,offscreen:c,option:u}=a;if(y===!0)continue;const f=r=>{if(h){const o=new VideoFrame(r,{timestamp:s});try{o&&h.write(o)}catch{}o.close()}else c&&(c.width=r.width,c.height=r.height,c?.getContext("2d")?.drawImage(r,0,0))};if(i==="default")f(e);else if(u){const{sx:r=0,sy:o=0,sw:p=e.width,sh:g=e.height}=u,M=await createImageBitmap(e,r,o,p,g);f(M)}}}catch{}e.close()};addCut=t=>{const{key:s,writable:e,offscreen:n,option:i}={key:"default",...t};if(e){const a=e.getWriter();this.renderMap.set(s,{writer:a,option:i,pause:!1})}else this.renderMap.set(s,{offscreen:n,option:i,pause:!1})};delCut=t=>{this.renderMap.delete(t)};setCut=t=>{const{key:s,cutOption:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,option:e})};setPause=t=>{const{key:s,pause:e}={key:"default",...t},n=this.renderMap.get(s);n&&this.renderMap.set(s,{...n,pause:e})};destroy=()=>{this.renderMap=new Map}}const w=new l;onmessage=d=>{const{action:t,data:s}=d.data,e=w[t];e&&e(s)}})();
115
+ `, v = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", S], { type: "text/javascript;charset=utf-8" });
116
+ function F(h) {
117
117
  let o;
118
118
  try {
119
119
  if (o = v && (self.URL || self.webkitURL).createObjectURL(v), !o) throw "";
120
- const u = new Worker(o, {
120
+ const a = new Worker(o, {
121
121
  name: h == null ? void 0 : h.name
122
122
  });
123
- return u.addEventListener("error", () => {
123
+ return a.addEventListener("error", () => {
124
124
  (self.URL || self.webkitURL).revokeObjectURL(o);
125
- }), u;
125
+ }), a;
126
126
  } catch {
127
127
  return new Worker(
128
- "data:text/javascript;charset=utf-8," + encodeURIComponent(D),
128
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(S),
129
129
  {
130
130
  name: h == null ? void 0 : h.name
131
131
  }
132
132
  );
133
133
  }
134
134
  }
135
- class F {
135
+ class B {
136
136
  constructor() {
137
- y(this, "worker", new N());
138
- y(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }, [o.bitmap]));
139
- y(this, "addCut", (o) => this.worker.postMessage({ action: "addCut", data: o }, [o.writable]));
140
- y(this, "delCut", (o) => this.worker.postMessage({ action: "delCut", data: o }));
141
- y(this, "setCut", (o) => this.worker.postMessage({ action: "setCut", data: o }));
142
- y(this, "setPause", (o) => this.worker.postMessage({ action: "setPause", data: o }));
143
- y(this, "destroy", () => {
137
+ m(this, "worker", new F());
138
+ m(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }, [o.bitmap]));
139
+ m(this, "addCut", (o) => {
140
+ const a = [];
141
+ o.writable && a.push(o.writable), o.offscreen && a.push(o.offscreen), this.worker.postMessage({ action: "addCut", data: o }, a);
142
+ });
143
+ m(this, "delCut", (o) => this.worker.postMessage({ action: "delCut", data: o }));
144
+ m(this, "setCut", (o) => this.worker.postMessage({ action: "setCut", data: o }));
145
+ m(this, "setPause", (o) => this.worker.postMessage({ action: "setPause", data: o }));
146
+ m(this, "destroy", () => {
144
147
  this.worker.postMessage({ action: "destroy", data: {} }), this.worker.terminate();
145
148
  });
146
149
  }
147
150
  }
148
- 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, m = (h, o, u) => G(h, typeof o != "symbol" ? o + "" : o, u);
151
+ var N = Object.defineProperty, G = (h, o, a) => o in h ? N(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);
149
152
  class W {
150
- constructor(o, u) {
151
- m(this, "inputStream", new MediaStream()), m(this, "outputStream", new MediaStream()), m(this, "inputGain", 1), m(this, "enhanceGain", 1), m(this, "bgsGain", 1), m(this, "bgmGain", 1), m(this, "outputGain", 1), m(this, "mixAudioMap", /* @__PURE__ */ new Map()), m(this, "audioContext", new AudioContext()), m(this, "sourceNode"), m(this, "highPassNode"), m(this, "lowPassNode"), m(this, "inputGainNode"), m(this, "enhanceGainNode"), m(this, "bgsGainNode"), m(this, "bgmGainNode"), m(this, "analyserNode"), m(this, "analyserArrayData"), m(this, "outputGainNode"), m(this, "destinationNode"), m(this, "filterStream", (a) => a), m(this, "stop", () => {
153
+ constructor(o, a) {
154
+ 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", () => {
152
155
  {
153
- const a = this.inputStream.getTracks();
154
- for (const n of a)
156
+ const u = this.inputStream.getTracks();
157
+ for (const n of u)
155
158
  n.stop(), this.inputStream.removeTrack(n);
156
159
  }
157
- }), m(this, "pause", async (a) => {
158
- const n = this.inputStream.getTracks();
159
- for (const r of n)
160
- r.enabled = !a;
161
- }), m(this, "getStream", () => this.filterStream(this.outputStream)), m(this, "setMute", (a = !0) => {
162
- a ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
163
- }), m(this, "setInputGain", (a) => {
164
- this.inputGain = a, this.inputGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
165
- }), m(this, "setEnhanceGain", async (a) => {
166
- this.enhanceGain = a + 1, this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime);
167
- }), m(this, "setBgsGain", (a) => {
168
- this.bgsGain = a, this.bgsGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
169
- }), m(this, "setBgmGain", (a) => {
170
- this.bgmGain = a, this.bgmGainNode.gain.setValueAtTime(a, this.audioContext.currentTime);
171
- }), m(this, "setOutputGain", (a) => {
172
- this.outputGain = a, this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
173
- }), m(this, "getVolume", () => {
174
- const { analyserNode: a, analyserArrayData: n } = this;
175
- a.getByteFrequencyData(n);
160
+ }), y(this, "getStream", () => this.filterStream(this.outputStream)), y(this, "setMute", (u = !0) => {
161
+ u ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
162
+ }), y(this, "setInputGain", (u) => {
163
+ this.inputGain = u, this.inputGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
164
+ }), y(this, "setEnhanceGain", async (u) => {
165
+ this.enhanceGain = u + 1, this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime);
166
+ }), y(this, "setBgsGain", (u) => {
167
+ this.bgsGain = u, this.bgsGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
168
+ }), y(this, "setBgmGain", (u) => {
169
+ this.bgmGain = u, this.bgmGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
170
+ }), y(this, "setOutputGain", (u) => {
171
+ this.outputGain = u, this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
172
+ }), y(this, "getVolume", () => {
173
+ const { analyserNode: u, analyserArrayData: n } = this;
174
+ u.getByteFrequencyData(n);
176
175
  let r = 0;
177
176
  for (let i = 0; i < n.length; i++)
178
177
  r += n[i];
179
178
  return Math.ceil(r / n.length);
180
- }), m(this, "mixAudio", (a, n = "bgm") => new Promise(async (r, i) => {
179
+ }), y(this, "mixAudio", (u, n = "bgm") => new Promise(async (r, i) => {
181
180
  try {
182
181
  {
183
182
  const s = this.mixAudioMap.get(n);
184
183
  s && s.stop();
185
184
  }
186
185
  const t = n === "bgs" ? this.bgsGainNode : this.bgmGainNode, e = this.audioContext.createBufferSource();
187
- this.mixAudioMap.set(n, e), e.buffer = a, e.connect(t), e.onended = () => {
186
+ this.mixAudioMap.set(n, e), e.buffer = u, e.connect(t), e.onended = () => {
188
187
  e.disconnect(t), this.mixAudioMap.delete(n), r(!0);
189
188
  }, e.start(0);
190
189
  } catch (t) {
191
190
  i(t);
192
191
  }
193
- })), m(this, "mixAudioStop", (a) => {
194
- const n = this.mixAudioMap.get(a);
192
+ })), y(this, "mixAudioStop", (u) => {
193
+ const n = this.mixAudioMap.get(u);
195
194
  n == null || n.stop();
196
- }), m(this, "changeMix", (a, n) => {
197
- const r = a === "bgs" ? this.bgsGainNode : this.bgmGainNode;
195
+ }), y(this, "changeMix", (u, n) => {
196
+ const r = u === "bgs" ? this.bgsGainNode : this.bgmGainNode;
198
197
  n ? r.connect(this.destinationNode) : r.disconnect(this.destinationNode);
199
- }), u && (this.audioContext = u), this.inputStream = o, this.sourceNode = this.audioContext.createMediaStreamSource(this.inputStream), this.highPassNode = this.audioContext.createBiquadFilter(), this.highPassNode.type = "highpass", this.highPassNode.frequency.value = 100, this.lowPassNode = this.audioContext.createBiquadFilter(), this.lowPassNode.type = "lowpass", this.lowPassNode.frequency.value = 8e3, 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;
198
+ }), 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;
200
199
  {
201
- const { sourceNode: a, highPassNode: n, lowPassNode: r, inputGainNode: i, enhanceGainNode: t, bgsGainNode: e, bgmGainNode: s, analyserNode: l, outputGainNode: c, destinationNode: d } = this;
202
- a.connect(n), n.connect(r), r.connect(i), i.connect(t), t.connect(l), e.connect(l), s.connect(l), t.connect(d), e.connect(d), s.connect(d), l.connect(c), c.connect(this.audioContext.destination);
200
+ const { sourceNode: u, inputGainNode: n, enhanceGainNode: r, bgsGainNode: i, bgmGainNode: t, analyserNode: e, outputGainNode: s, destinationNode: l } = this;
201
+ 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);
203
202
  }
204
203
  this.setMute(!0), this.audioContext.resume();
205
204
  }
206
205
  }
207
206
  const E = async (h, o) => {
208
207
  try {
209
- const { format: u, numberOfChannels: a, numberOfFrames: n, sampleRate: r } = o, i = h.createBuffer(a, n, r);
210
- for (let t = 0; t < a; t++) {
208
+ const { format: a, numberOfChannels: u, numberOfFrames: n, sampleRate: r } = o, i = h.createBuffer(u, n, r);
209
+ for (let t = 0; t < u; t++) {
211
210
  const e = o.allocationSize({ planeIndex: t }), s = new Uint8Array(e);
212
211
  o.copyTo(s, { planeIndex: t });
213
212
  const l = new DataView(s.buffer), c = i.getChannelData(t);
214
213
  for (let d = 0; d < n; d++) {
215
214
  let p;
216
- switch (u) {
215
+ switch (a) {
217
216
  case "s16":
218
217
  // 16-bit signed PCM (范围: -32768 ~ 32767)
219
218
  case "s16-planar":
@@ -230,49 +229,49 @@ const E = async (h, o) => {
230
229
  p = (l.getUint8(d) - 128) / 128;
231
230
  break;
232
231
  default:
233
- throw new Error(`Unsupported audio format: ${u}`);
232
+ throw new Error(`Unsupported audio format: ${a}`);
234
233
  }
235
234
  c[d] = Math.max(-1, Math.min(1, p));
236
235
  }
237
236
  }
238
237
  return i;
239
- } catch (u) {
240
- throw console.error("Failed to convert AudioData to AudioBuffer:", u), u;
238
+ } catch (a) {
239
+ throw console.error("Failed to convert AudioData to AudioBuffer:", a), a;
241
240
  }
242
241
  };
243
242
  class O {
244
243
  constructor() {
245
- y(this, "prAudioStream");
246
- y(this, "audioContext");
247
- y(this, "destination");
248
- y(this, "stream", new MediaStream());
249
- y(this, "nextStartTime", 0);
250
- y(this, "pendingSources", []);
251
- y(this, "init", (o) => {
244
+ m(this, "prAudioStream");
245
+ m(this, "audioContext");
246
+ m(this, "destination");
247
+ m(this, "stream", new MediaStream());
248
+ m(this, "nextStartTime", 0);
249
+ m(this, "pendingSources", []);
250
+ m(this, "init", (o) => {
252
251
  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 W(this.stream, this.audioContext), this.nextStartTime = 0, this.pendingSources = [];
253
252
  });
254
- y(this, "getStream", () => {
253
+ m(this, "getStream", () => {
255
254
  var o;
256
255
  return (o = this.prAudioStream) == null ? void 0 : o.getStream();
257
256
  });
258
257
  }
259
258
  async push(o) {
260
- const { audioData: u, playbackRate: a = 1 } = o;
259
+ const { audioData: a, playbackRate: u = 1 } = o;
261
260
  if (!this.audioContext || !this.destination) return;
262
- let n = await E(this.audioContext, u);
263
- if (u.close(), !n) return;
261
+ let n = await E(this.audioContext, a);
262
+ if (a.close(), !n) return;
264
263
  const r = this.audioContext.createBufferSource();
265
- r.buffer = n, r.playbackRate.value = a;
266
- const i = -1200 * Math.log2(a);
264
+ r.buffer = n, r.playbackRate.value = u;
265
+ const i = -1200 * Math.log2(u);
267
266
  r.detune.value = i, r.connect(this.destination);
268
- const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = n.duration / a;
267
+ const t = Math.max(this.nextStartTime, this.audioContext.currentTime), e = n.duration / u;
269
268
  this.nextStartTime = t + e, r.start(t), this.pendingSources.push(r), r.onended = () => {
270
269
  this.pendingSources = this.pendingSources.filter((s) => s !== r);
271
270
  }, this.audioContext.state === "suspended" && await this.audioContext.resume();
272
271
  }
273
272
  destroy() {
274
- var o, u;
275
- (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 = [];
273
+ var o, a;
274
+ (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 = [];
276
275
  }
277
276
  }
278
277
  const j = (h) => {
@@ -280,13 +279,13 @@ const j = (h) => {
280
279
  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";
281
280
  }, z = (h) => {
282
281
  const o = (h == null ? void 0 : h.getTracks()) || [];
283
- for (const u of o)
284
- u.stop();
282
+ for (const a of o)
283
+ a.stop();
285
284
  };
286
- class q {
285
+ class $ {
287
286
  constructor() {
288
- y(this, "resolvesMap", /* @__PURE__ */ new Map());
289
- y(this, "index", 0);
287
+ m(this, "resolvesMap", /* @__PURE__ */ new Map());
288
+ m(this, "index", 0);
290
289
  /**
291
290
  *
292
291
  * @param eventKey 唯一key
@@ -294,128 +293,130 @@ class q {
294
293
  * @param timeout 超时时间 ms
295
294
  * @returns
296
295
  */
297
- y(this, "add", (o, u = () => !1, a = 0) => new Promise((n) => {
296
+ m(this, "add", (o, a = () => !1, u = 0) => new Promise((n) => {
298
297
  var t, e;
299
- if (u()) return n(!0);
298
+ if (a()) return n(!0);
300
299
  this.resolvesMap.has(o) || this.resolvesMap.set(o, /* @__PURE__ */ new Map()), this.index++;
301
300
  const r = `${this.index}`;
302
- if (a = Math.max(0, a), a === 0) {
301
+ if (u = Math.max(0, u), u === 0) {
303
302
  (t = this.resolvesMap.get(o)) == null || t.set(r, { resolve: n, timer: 0 });
304
303
  return;
305
304
  }
306
305
  const i = window.setTimeout(() => {
307
306
  this.emit(o);
308
- }, a);
307
+ }, u);
309
308
  (e = this.resolvesMap.get(o)) == null || e.set(r, { resolve: n, timer: i });
310
309
  }));
311
- y(this, "emit", async (o) => {
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));
310
+ m(this, "emit", async (o) => {
311
+ const a = this.resolvesMap.get(o);
312
+ if (!a) return;
313
+ const u = [...a.keys()];
314
+ for (const n of u) {
315
+ const r = a.get(n);
316
+ r && (clearTimeout(r.timer), r.resolve(), a.delete(n));
318
317
  }
319
318
  });
320
319
  }
321
320
  }
322
321
  const X = (h) => {
323
322
  const o = new DataView(h.buffer);
324
- let u = 0, a, n, r;
325
- a = o.getUint32(u, !1), u += 4;
323
+ let a = 0, u, n, r;
324
+ u = o.getUint32(a, !1), a += 4;
326
325
  {
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;
326
+ const i = o.getUint8(a), t = i >> 7 & 1, e = i >> 5 & 3, s = i & 31;
327
+ n = { forbidden_zero_bit: t, nal_ref_idc: e, nal_unit_type: s }, a += 1;
329
328
  }
330
329
  {
331
- const i = a - 1;
332
- r = new Uint8Array(o.buffer.slice(u, u + i));
330
+ const i = u - 1;
331
+ r = new Uint8Array(o.buffer.slice(a, a + i));
333
332
  }
334
- return { size: a, header: n, data: r };
333
+ return { size: u, header: n, data: r };
335
334
  };
336
- var P, U, J;
337
- class A {
338
- // 实例变量:统一管理当前请求的中止
335
+ var q, U;
336
+ class x {
339
337
  constructor(o = {}) {
340
- K(this, P, {
338
+ H(this, q, {
341
339
  timeout: 5 * 1e3,
342
340
  check: !1
343
341
  });
344
- K(this, U, null);
342
+ H(this, U);
345
343
  /**
346
- * 检查资源可用性(HEAD 请求)—— 用实例变量控制器
344
+ *
345
+ * @param input string | URL | Request
346
+ * @param init RequestInit
347
347
  */
348
- K(this, J, (o, u) => new Promise(async (a) => {
349
- H(this, U, new AbortController());
350
- const { signal: n } = S(this, U), r = S(this, P).timeout, i = setTimeout(() => {
348
+ m(this, "check", (o, a) => new Promise(async (u, n) => {
349
+ var i;
350
+ this.stop(), K(this, U, new AbortController());
351
+ const r = window.setTimeout(() => {
351
352
  var t;
352
- (t = S(this, U)) == null || t.abort(`Timeout (${r}ms)`);
353
- }, r);
354
- await fetch(o, { cache: "no-store", ...u, method: "HEAD", signal: n }).then((t) => {
355
- clearTimeout(i), a({ status: t.status === 200 ? "successed" : "failed", reason: t.status === 200 ? "" : `HTTP ${t.status}` });
356
- }).catch((t) => {
357
- if (clearTimeout(i), t.name === "AbortError") {
358
- const e = n.reason || "Actively stopped";
359
- a({
360
- status: e.includes("Timeout") ? "timeout" : "stopped",
361
- reason: e
362
- });
363
- } else
364
- a({ status: "error", reason: t.message });
365
- });
353
+ (t = R(this, U)) == null || t.abort("Timeout."), n({ status: "timeout", reason: "" });
354
+ }, R(this, q).timeout);
355
+ try {
356
+ const t = await fetch(o, { ...a, method: "HEAD", signal: (i = R(this, U)) == null ? void 0 : i.signal });
357
+ t.status === 200 ? u({ status: "successed", reason: "" }) : n({ status: "failed", reason: `${t.status}` });
358
+ } catch (t) {
359
+ n({ status: "error", reason: t.message });
360
+ }
361
+ clearTimeout(r);
366
362
  }));
367
363
  /**
368
- * 发起数据请求(GET/POST 等)—— 用实例变量控制器
364
+ *
365
+ * @param input string | URL | Request
366
+ * @param init RequestInit
369
367
  */
370
- y(this, "request", (o, u) => new Promise(async (a, n) => {
368
+ m(this, "request", async (o, a) => new Promise(async (u, n) => {
369
+ var r;
371
370
  try {
372
- this.stop(), S(this, P).check && await S(this, J).call(this, o), H(this, U, new AbortController());
373
- const { signal: r } = S(this, U), i = await fetch(o, { cache: "no-store", ...u, signal: r });
374
- a(i);
375
- } catch (r) {
376
- n(r);
371
+ R(this, q).check && await this.check(o, a), K(this, U, new AbortController());
372
+ const i = await fetch(o, { ...a, signal: (r = R(this, U)) == null ? void 0 : r.signal });
373
+ u(i);
374
+ } catch (i) {
375
+ this.stop(), n(i);
377
376
  }
378
377
  }));
379
- y(this, "stop", () => {
378
+ /**
379
+ * stop
380
+ */
381
+ m(this, "stop", () => {
380
382
  var o;
381
- if (((o = S(this, U)) == null ? void 0 : o.signal.aborted) === !1) {
382
- const u = new Error("Actively stopped.");
383
- u.name = "AbortError", S(this, U).abort(u);
384
- }
383
+ ((o = R(this, U)) == null ? void 0 : o.signal.aborted) === !1 && R(this, U).abort("Actively stop.");
385
384
  });
386
- H(this, P, { ...S(this, P), ...o });
385
+ K(this, q, { ...R(this, q), ...o });
387
386
  }
388
387
  }
389
- P = new WeakMap(), U = new WeakMap(), J = new WeakMap();
388
+ q = new WeakMap(), U = new WeakMap();
390
389
  class tt {
391
390
  constructor(o = {}) {
392
- y(this, "option", {
391
+ m(this, "option", {
393
392
  debug: !1,
394
393
  frameTrack: !1
395
394
  });
396
- y(this, "prFetch", new A());
397
- y(this, "getSegmentsFetch", new A());
398
- y(this, "prResolves", new q());
399
- y(this, "url", "");
400
- y(this, "start_resolve");
401
- y(this, "demuxerWorker");
402
- y(this, "decoderWorker");
403
- y(this, "audioPlayer");
404
- y(this, "renderWorker");
405
- y(this, "stream");
406
- y(this, "on", { demuxer: {}, decoder: {} });
407
- y(this, "cutRenders", /* @__PURE__ */ new Map());
395
+ m(this, "converter", "MediaStreamTrackGenerator" in window ? "generator" : "canvas");
396
+ // 自动检测浏览器 使用哪一种模式转换生产视频流
397
+ m(this, "prFetch", new x());
398
+ m(this, "getSegmentsFetch", new x());
399
+ m(this, "prResolves", new $());
400
+ m(this, "url", "");
401
+ m(this, "start_resolve");
402
+ m(this, "demuxerWorker");
403
+ m(this, "decoderWorker");
404
+ m(this, "audioPlayer");
405
+ m(this, "renderWorker");
406
+ m(this, "stream");
407
+ m(this, "on", { demuxer: {}, decoder: {} });
408
+ m(this, "cutRenders", /* @__PURE__ */ new Map());
408
409
  // @ts-ignore
409
- y(this, "trackGenerator");
410
+ m(this, "trackGenerator");
410
411
  /**
411
412
  * 开始播放
412
413
  * @param url : string
413
414
  */
414
- y(this, "start", async (o) => {
415
+ m(this, "start", async (o) => {
415
416
  await this.stop(), this.url = o;
416
- const u = j(o);
417
- if (u === "unknown") throw new Error("This address cannot be parsed.");
418
- switch (this.init(u), u) {
417
+ const a = j(o);
418
+ if (a === "unknown") throw new Error("This address cannot be parsed.");
419
+ switch (this.init(a), a) {
419
420
  case "flv":
420
421
  this.flv.start();
421
422
  break;
@@ -427,146 +428,149 @@ class tt {
427
428
  /**
428
429
  * 停止
429
430
  */
430
- y(this, "stop", async () => {
431
- var o, u, a, n;
431
+ m(this, "stop", async () => {
432
+ var o, a, u, n;
432
433
  try {
433
- this.url = "", clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop(), this.getSegmentsFetch.stop();
434
+ this.url = "", clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop(), this.getSegmentsFetch.stop(), (o = this.demuxerWorker) == null || o.destroy(), (a = this.decoderWorker) == null || a.destroy(), (u = this.renderWorker) == null || u.destroy(), this.cutRenders = /* @__PURE__ */ new Map(), z(this.stream), (n = this.audioPlayer) == null || n.destroy();
434
435
  } catch (r) {
435
436
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: error", r);
436
437
  }
437
- (o = this.demuxerWorker) == null || o.destroy(), (u = this.decoderWorker) == null || u.destroy(), (a = this.renderWorker) == null || a.destroy(), this.cutRenders = /* @__PURE__ */ new Map(), z(this.stream), (n = this.audioPlayer) == null || n.destroy();
438
438
  });
439
439
  /**
440
440
  * 获取媒体流
441
441
  */
442
- y(this, "getStream", () => this.stream);
442
+ m(this, "getStream", () => this.stream);
443
443
  /**
444
444
  * 设置暂停
445
445
  * @param pause: boolean
446
446
  */
447
- y(this, "setPause", (o) => {
448
- var u;
449
- (u = this.renderWorker) == null || u.setPause({ pause: o });
447
+ m(this, "setPause", (o) => {
448
+ var a;
449
+ (a = this.renderWorker) == null || a.setPause({ pause: o });
450
450
  });
451
451
  /**
452
452
  * 是否静音 默认为true
453
453
  * @param state?: boolean
454
454
  */
455
- y(this, "setMute", (o) => {
456
- var u, a;
457
- return (a = (u = this.audioPlayer) == null ? void 0 : u.prAudioStream) == null ? void 0 : a.setMute(o);
455
+ m(this, "setMute", (o) => {
456
+ var a, u;
457
+ return (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null ? void 0 : u.setMute(o);
458
458
  });
459
459
  /**
460
460
  * 设置输出音量
461
461
  * @param gain
462
462
  */
463
- y(this, "setOutputGain", (o) => {
464
- var u, a;
465
- (a = (u = this.audioPlayer) == null ? void 0 : u.prAudioStream) == null || a.setOutputGain(o);
463
+ m(this, "setOutputGain", (o) => {
464
+ var a, u;
465
+ (u = (a = this.audioPlayer) == null ? void 0 : a.prAudioStream) == null || u.setOutputGain(o);
466
466
  });
467
467
  /**
468
468
  * 是否开启追帧
469
469
  * @param frameTrack?: boolean
470
470
  */
471
- y(this, "setFrameTrack", (o) => {
472
- var u;
473
- this.option.frameTrack = o, (u = this.decoderWorker) == null || u.setFrameTrack(o);
471
+ m(this, "setFrameTrack", (o) => {
472
+ var a;
473
+ this.option.frameTrack = o, (a = this.decoderWorker) == null || a.setFrameTrack(o);
474
474
  });
475
475
  /**
476
476
  * 是否已准备好
477
477
  */
478
- y(this, "isReady", () => {
478
+ m(this, "isReady", () => {
479
479
  const o = () => {
480
- var u;
481
- return ((u = this.stream) == null ? void 0 : u.active) === !0;
480
+ var a;
481
+ return ((a = this.stream) == null ? void 0 : a.active) === !0;
482
482
  };
483
483
  return this.prResolves.add("isReady", o);
484
484
  });
485
- y(this, "cut", {
485
+ m(this, "cut", {
486
486
  /**
487
487
  * 创建剪切
488
488
  */
489
- create: (o, u) => {
490
- var r;
491
- const a = new MediaStreamTrackGenerator({ kind: "video" }), n = new MediaStream([a]);
492
- return (r = this.renderWorker) == null || r.addCut({ key: o, writable: a.writable, option: u }), this.cutRenders.set(o, { stream: n }), n;
489
+ create: (o, a) => {
490
+ var i, t;
491
+ if (this.converter === "generator") {
492
+ const e = new MediaStreamTrackGenerator({ kind: "video" }), s = new MediaStream([e]);
493
+ return (i = this.renderWorker) == null || i.addCut({ key: o, writable: e.writable, option: a }), this.cutRenders.set(o, { stream: s }), s;
494
+ }
495
+ const u = document.createElement("canvas"), n = u.captureStream(), r = u.transferControlToOffscreen();
496
+ return (t = this.renderWorker) == null || t.addCut({ key: o, offscreen: r, option: a }), this.cutRenders.set(o, { stream: n }), n;
493
497
  },
494
498
  /**
495
499
  * 设置剪切
496
500
  */
497
- setCut: (o, u) => {
498
- var a;
499
- (a = this.renderWorker) == null || a.setCut({ key: o, cutOption: u });
501
+ setCut: (o, a) => {
502
+ var u;
503
+ (u = this.renderWorker) == null || u.setCut({ key: o, cutOption: a });
500
504
  },
501
505
  /**
502
506
  * 获取媒体流
503
507
  */
504
508
  getStream: (o) => {
505
- var u;
506
- return (u = this.cutRenders.get(o)) == null ? void 0 : u.stream;
509
+ var a;
510
+ return (a = this.cutRenders.get(o)) == null ? void 0 : a.stream;
507
511
  },
508
512
  /**
509
513
  * 移除剪切
510
514
  */
511
515
  remove: (o) => {
512
- var u;
513
- (u = this.renderWorker) == null || u.delCut(o), this.cutRenders.delete(o);
516
+ var a;
517
+ (a = this.renderWorker) == null || a.delCut(o), this.cutRenders.delete(o);
514
518
  },
515
519
  /**
516
520
  * 设置暂停
517
521
  * @param pause: boolean
518
522
  */
519
- setPause: (o, u) => {
520
- var a;
521
- (a = this.renderWorker) == null || a.setPause({ key: o, pause: u });
523
+ setPause: (o, a) => {
524
+ var u;
525
+ (u = this.renderWorker) == null || u.setPause({ key: o, pause: a });
522
526
  }
523
527
  });
524
528
  /**
525
529
  * 初始化
526
530
  */
527
- y(this, "init", (o) => {
531
+ m(this, "init", (o) => {
528
532
  this.initDecoder(o), this.initRender(), this.initDemuxer(o), this.audioPlayer = new O(), this.audioPlayer.init();
529
533
  });
530
534
  /**
531
535
  * 初始化解复器
532
536
  */
533
- y(this, "initDemuxer", (o) => {
534
- this.demuxerWorker = new I(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (u) => {
535
- this.option.debug && this.on.debug && this.on.debug(u);
536
- }, this.demuxerWorker.on.info = (u) => {
537
- 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);
538
- }, this.demuxerWorker.on.config = (u) => {
537
+ m(this, "initDemuxer", (o) => {
538
+ this.demuxerWorker = new I(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (a) => {
539
+ this.option.debug && this.on.debug && this.on.debug(a);
540
+ }, this.demuxerWorker.on.info = (a) => {
541
+ 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);
542
+ }, this.demuxerWorker.on.config = (a) => {
539
543
  var n, r;
540
- 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);
541
- const { kind: a } = u;
542
- switch (a) {
544
+ 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);
545
+ const { kind: u } = a;
546
+ switch (u) {
543
547
  case "audio":
544
548
  {
545
- const { codec: i, sampleRate: t, numberOfChannels: e } = u;
549
+ const { codec: i, sampleRate: t, numberOfChannels: e } = a;
546
550
  (n = this.decoderWorker) == null || n.initAudio({ codec: i, sampleRate: t, numberOfChannels: e });
547
551
  }
548
552
  break;
549
553
  case "video":
550
554
  {
551
- const { codec: i, description: t } = u;
555
+ const { codec: i, description: t } = a;
552
556
  (r = this.decoderWorker) == null || r.initVideo({ codec: i, description: t });
553
557
  }
554
558
  break;
555
559
  }
556
- }, this.demuxerWorker.on.chunk = (u) => {
557
- if (this.on.demuxer.chunk && this.on.demuxer.chunk(u), !this.decoderWorker) return;
558
- const { kind: a } = u;
559
- switch (a) {
560
+ }, this.demuxerWorker.on.chunk = (a) => {
561
+ if (this.on.demuxer.chunk && this.on.demuxer.chunk(a), !this.decoderWorker) return;
562
+ const { kind: u } = a;
563
+ switch (u) {
560
564
  case "audio":
561
565
  {
562
- const { type: n, dts: r, data: i } = u, t = r * 1e3;
563
- this.decoderWorker.push({ kind: a, init: { type: n, timestamp: t, data: i } });
566
+ const { type: n, dts: r, data: i } = a, t = r * 1e3;
567
+ this.decoderWorker.push({ kind: u, init: { type: n, timestamp: t, data: i } });
564
568
  }
565
569
  break;
566
570
  case "video":
567
571
  {
568
- const { type: n, dts: r, data: i, nalus: t = [] } = u, e = r * 1e3;
569
- this.decoderWorker.push({ kind: a, init: { type: n, timestamp: e, data: i }, nalus: t });
572
+ const { type: n, dts: r, data: i, nalus: t = [] } = a, e = r * 1e3;
573
+ this.decoderWorker.push({ kind: u, init: { type: n, timestamp: e, data: i }, nalus: t });
570
574
  }
571
575
  break;
572
576
  }
@@ -575,41 +579,46 @@ class tt {
575
579
  /**
576
580
  * 初始化解码器
577
581
  */
578
- y(this, "initDecoder", (o) => {
579
- this.decoderWorker = new L(), this.decoderWorker.init(o);
580
- const { frameTrack: u = !1 } = this.option;
581
- this.decoderWorker.setFrameTrack(u), this.decoderWorker.on.audio.decode = (a) => {
582
+ m(this, "initDecoder", (o) => {
583
+ this.decoderWorker = new V(), this.decoderWorker.init(o);
584
+ const { frameTrack: a = !1 } = this.option;
585
+ this.decoderWorker.setFrameTrack(a), this.decoderWorker.on.audio.decode = (u) => {
582
586
  var n;
583
- (n = this.audioPlayer) == null || n.push(a), this.on.decoder.audio && this.on.decoder.audio(a);
584
- }, this.decoderWorker.on.audio.error = (a) => {
585
- 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);
586
- }, this.decoderWorker.on.video.decode = async (a) => {
587
+ (n = this.audioPlayer) == null || n.push(u), this.on.decoder.audio && this.on.decoder.audio(u);
588
+ }, this.decoderWorker.on.audio.error = (u) => {
589
+ 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);
590
+ }, this.decoderWorker.on.video.decode = async (u) => {
587
591
  var n;
588
- this.start_resolve && (this.start_resolve(!0), this.start_resolve = void 0), (n = this.renderWorker) == null || n.push(a), this.on.decoder.video && this.on.decoder.video(a);
589
- }, this.decoderWorker.on.video.error = (a) => {
590
- this.on.error && this.on.error(a);
591
- }, this.decoderWorker.on.nalus = async (a) => {
592
- for (const n of a) {
592
+ this.start_resolve && (this.start_resolve(!0), this.start_resolve = void 0), (n = this.renderWorker) == null || n.push(u), this.on.decoder.video && this.on.decoder.video(u);
593
+ }, this.decoderWorker.on.video.error = (u) => {
594
+ this.on.error && this.on.error(u);
595
+ }, this.decoderWorker.on.nalus = async (u) => {
596
+ for (const n of u) {
593
597
  if (n.byteLength <= 4) continue;
594
598
  const { header: r, data: i } = X(n), { nal_unit_type: t } = r;
595
599
  t === 6 && this.on.decoder.sei && this.on.decoder.sei(i);
596
600
  }
597
- }, this.decoderWorker.on.analysis = (a) => {
598
- this.on.decoder.analysis && this.on.decoder.analysis(a);
601
+ }, this.decoderWorker.on.analysis = (u) => {
602
+ this.on.decoder.analysis && this.on.decoder.analysis(u);
599
603
  };
600
604
  });
601
605
  /**
602
606
  * 初始化渲染器
603
607
  */
604
- y(this, "initRender", () => {
605
- var a, n;
606
- this.renderWorker = new F();
607
- const o = new MediaStreamTrackGenerator({ kind: "video" }), u = new MediaStream([o]);
608
- (a = this.renderWorker) == null || a.addCut({ writable: o.writable }), this.stream = u, (n = this.renderWorker) == null || n.setPause({ pause: !1 });
608
+ m(this, "initRender", () => {
609
+ var o, a, u;
610
+ if (this.renderWorker = new B(), this.converter === "generator") {
611
+ const n = new MediaStreamTrackGenerator({ kind: "video" }), r = new MediaStream([n]);
612
+ (o = this.renderWorker) == null || o.addCut({ writable: n.writable }), this.stream = r;
613
+ } else {
614
+ const n = document.createElement("canvas"), r = n.captureStream(), i = n.transferControlToOffscreen();
615
+ (a = this.renderWorker) == null || a.addCut({ offscreen: i }), this.stream = r;
616
+ }
617
+ (u = this.renderWorker) == null || u.setPause({ pause: !1 });
609
618
  });
610
- y(this, "flv", {
611
- start: () => new Promise(async (o, u) => {
612
- var a, n;
619
+ m(this, "flv", {
620
+ start: () => new Promise(async (o, a) => {
621
+ var u, n;
613
622
  try {
614
623
  this.start_resolve = o;
615
624
  let r, i = 0;
@@ -623,52 +632,52 @@ class tt {
623
632
  if ((r == null ? void 0 : r.status) === 200 || i === 3) break;
624
633
  await new Promise((e) => setTimeout(() => e(!0), 500));
625
634
  }
626
- if (!r || r.status !== 200) return u("request is error.");
627
- const t = (a = r.body) == null ? void 0 : a.getReader();
628
- if (!t) return u("reader is error.");
635
+ if (!r || r.status !== 200) return a("request is error.");
636
+ const t = (u = r.body) == null ? void 0 : u.getReader();
637
+ if (!t) return a("reader is error.");
629
638
  for (; ; ) {
630
639
  const { done: e, value: s } = await t.read();
631
640
  if (s && ((n = this.demuxerWorker) == null || n.push(s)), e || this.url === "") break;
632
641
  }
633
642
  } catch (r) {
634
- r.name !== "AbortError" && u(r);
643
+ r.name !== "AbortError" && a(r);
635
644
  }
636
645
  })
637
646
  });
638
- y(this, "hls", {
647
+ m(this, "hls", {
639
648
  isLive: !1,
640
649
  urls: [],
641
650
  url: "",
642
651
  getSegmentsTimer: 0,
643
652
  parse: async (o) => {
644
- const u = new TextDecoder("utf-8").decode(o).split(`
645
- `).map((e) => e.replace("\r", "")), a = this.url.substring(0, this.url.lastIndexOf("/") + 1);
653
+ const a = new TextDecoder("utf-8").decode(o).split(`
654
+ `).map((e) => e.replace("\r", "")), u = this.url.substring(0, this.url.lastIndexOf("/") + 1);
646
655
  let n = 4, r = 0, i = !1;
647
656
  const t = [];
648
- for (const e of u)
657
+ for (const e of a)
649
658
  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({
650
- url: e.startsWith("http") ? e : a + e,
659
+ url: e.startsWith("http") ? e : u + e,
651
660
  duration: n,
652
661
  isLive: i
653
662
  });
654
- return { baseUrl: a, targetDuration: r, isLive: i, segments: t };
663
+ return { baseUrl: u, targetDuration: r, isLive: i, segments: t };
655
664
  },
656
665
  getSegments: async () => {
657
666
  var o;
658
667
  try {
659
- let u, a = 0;
668
+ let a, u = 0;
660
669
  for (; ; ) {
661
- a += 1;
670
+ u += 1;
662
671
  try {
663
- u = await this.getSegmentsFetch.request(this.url);
672
+ a = await this.getSegmentsFetch.request(this.url);
664
673
  } catch (r) {
665
674
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", r);
666
675
  }
667
- if ((u == null ? void 0 : u.status) === 200 || a === 3) break;
676
+ if ((a == null ? void 0 : a.status) === 200 || u === 3) break;
668
677
  await new Promise((r) => setTimeout(() => r(!0), 500));
669
678
  }
670
- if (!u || u.status !== 200) throw new Error("request is error.");
671
- const n = (o = u.body) == null ? void 0 : o.getReader();
679
+ if (!a || a.status !== 200) throw new Error("request is error.");
680
+ const n = (o = a.body) == null ? void 0 : o.getReader();
672
681
  if (!n) throw new Error("reader is error.");
673
682
  for (; ; ) {
674
683
  const { done: r, value: i } = await n.read();
@@ -681,14 +690,14 @@ class tt {
681
690
  }
682
691
  if (r || this.url === "") break;
683
692
  }
684
- } catch (u) {
685
- u.name !== "AbortError" && this.on.error && this.on.error(u);
693
+ } catch (a) {
694
+ a.name !== "AbortError" && this.on.error && this.on.error(a);
686
695
  }
687
696
  },
688
- start: () => new Promise(async (o, u) => {
689
- var a, n, r;
697
+ start: () => new Promise(async (o, a) => {
698
+ var u, n, r;
690
699
  try {
691
- for (this.start_resolve = o, this.hls.url = "", this.hls.urls = [], await this.hls.getSegments(), this.hls.getSegmentsTimer = window.setInterval(this.hls.getSegments, 500), this.hls.isLive === !1 && (clearInterval(this.hls.getSegmentsTimer), (a = this.decoderWorker) == null ? void 0 : a.setFrameTrack(!1)); ; ) {
700
+ for (this.start_resolve = o, this.hls.url = "", this.hls.urls = [], await this.hls.getSegments(), this.hls.getSegmentsTimer = window.setInterval(this.hls.getSegments, 500), this.hls.isLive === !1 && (clearInterval(this.hls.getSegmentsTimer), (u = this.decoderWorker) == null ? void 0 : u.setFrameTrack(!1)); ; ) {
692
701
  const i = this.hls.urls.shift();
693
702
  if (i) {
694
703
  this.hls.url = i;
@@ -702,23 +711,23 @@ class tt {
702
711
  await new Promise((t) => setTimeout(() => t(!0), 300));
703
712
  }
704
713
  } catch (i) {
705
- i.name !== "AbortError" && u(i);
714
+ i.name !== "AbortError" && a(i);
706
715
  }
707
716
  })
708
717
  });
709
- const { debug: u = !1 } = o;
710
- this.option.debug = u;
718
+ const { debug: a = !1 } = o;
719
+ this.option.debug = a;
711
720
  }
712
721
  }
713
722
  var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, indexMinimal = {}, minimal$1 = {}, aspromise, hasRequiredAspromise;
714
723
  function requireAspromise() {
715
724
  if (hasRequiredAspromise) return aspromise;
716
725
  hasRequiredAspromise = 1, aspromise = h;
717
- function h(o, u) {
718
- for (var a = new Array(arguments.length - 1), n = 0, r = 2, i = !0; r < arguments.length; )
719
- a[n++] = arguments[r++];
726
+ function h(o, a) {
727
+ for (var u = new Array(arguments.length - 1), n = 0, r = 2, i = !0; r < arguments.length; )
728
+ u[n++] = arguments[r++];
720
729
  return new Promise(function(e, s) {
721
- a[n] = function(c) {
730
+ u[n] = function(c) {
722
731
  if (i)
723
732
  if (i = !1, c)
724
733
  s(c);
@@ -729,7 +738,7 @@ function requireAspromise() {
729
738
  }
730
739
  };
731
740
  try {
732
- o.apply(u || null, a);
741
+ o.apply(a || null, u);
733
742
  } catch (l) {
734
743
  i && (i = !1, s(l));
735
744
  }
@@ -749,25 +758,25 @@ function requireBase64() {
749
758
  ++s;
750
759
  return Math.ceil(t.length * 3) / 4 - s;
751
760
  };
752
- for (var u = new Array(64), a = new Array(123), n = 0; n < 64; )
753
- a[u[n] = n < 26 ? n + 65 : n < 52 ? n + 71 : n < 62 ? n - 4 : n - 59 | 43] = n++;
761
+ for (var a = new Array(64), u = new Array(123), n = 0; n < 64; )
762
+ u[a[n] = n < 26 ? n + 65 : n < 52 ? n + 71 : n < 62 ? n - 4 : n - 59 | 43] = n++;
754
763
  o.encode = function(t, e, s) {
755
764
  for (var l = null, c = [], d = 0, p = 0, f; e < s; ) {
756
765
  var w = t[e++];
757
766
  switch (p) {
758
767
  case 0:
759
- c[d++] = u[w >> 2], f = (w & 3) << 4, p = 1;
768
+ c[d++] = a[w >> 2], f = (w & 3) << 4, p = 1;
760
769
  break;
761
770
  case 1:
762
- c[d++] = u[f | w >> 4], f = (w & 15) << 2, p = 2;
771
+ c[d++] = a[f | w >> 4], f = (w & 15) << 2, p = 2;
763
772
  break;
764
773
  case 2:
765
- c[d++] = u[f | w >> 6], c[d++] = u[w & 63], p = 0;
774
+ c[d++] = a[f | w >> 6], c[d++] = a[w & 63], p = 0;
766
775
  break;
767
776
  }
768
777
  d > 8191 && ((l || (l = [])).push(String.fromCharCode.apply(String, c)), d = 0);
769
778
  }
770
- 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));
779
+ 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));
771
780
  };
772
781
  var r = "invalid encoding";
773
782
  o.decode = function(t, e, s) {
@@ -775,7 +784,7 @@ function requireBase64() {
775
784
  var f = t.charCodeAt(p++);
776
785
  if (f === 61 && c > 1)
777
786
  break;
778
- if ((f = a[f]) === void 0)
787
+ if ((f = u[f]) === void 0)
779
788
  throw Error(r);
780
789
  switch (c) {
781
790
  case 0:
@@ -807,27 +816,27 @@ function requireEventemitter() {
807
816
  function h() {
808
817
  this._listeners = {};
809
818
  }
810
- return h.prototype.on = function(u, a, n) {
811
- return (this._listeners[u] || (this._listeners[u] = [])).push({
812
- fn: a,
819
+ return h.prototype.on = function(a, u, n) {
820
+ return (this._listeners[a] || (this._listeners[a] = [])).push({
821
+ fn: u,
813
822
  ctx: n || this
814
823
  }), this;
815
- }, h.prototype.off = function(u, a) {
816
- if (u === void 0)
824
+ }, h.prototype.off = function(a, u) {
825
+ if (a === void 0)
817
826
  this._listeners = {};
818
- else if (a === void 0)
819
- this._listeners[u] = [];
827
+ else if (u === void 0)
828
+ this._listeners[a] = [];
820
829
  else
821
- for (var n = this._listeners[u], r = 0; r < n.length; )
822
- n[r].fn === a ? n.splice(r, 1) : ++r;
830
+ for (var n = this._listeners[a], r = 0; r < n.length; )
831
+ n[r].fn === u ? n.splice(r, 1) : ++r;
823
832
  return this;
824
- }, h.prototype.emit = function(u) {
825
- var a = this._listeners[u];
826
- if (a) {
833
+ }, h.prototype.emit = function(a) {
834
+ var u = this._listeners[a];
835
+ if (u) {
827
836
  for (var n = [], r = 1; r < arguments.length; )
828
837
  n.push(arguments[r++]);
829
- for (r = 0; r < a.length; )
830
- a[r].fn.apply(a[r++].ctx, n);
838
+ for (r = 0; r < u.length; )
839
+ u[r].fn.apply(u[r++].ctx, n);
831
840
  }
832
841
  return this;
833
842
  }, eventemitter;
@@ -875,12 +884,12 @@ function requireFloat() {
875
884
  e((d << 31 | p + 127 << 23 | f) >>> 0, l, c);
876
885
  }
877
886
  }
878
- r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null, u);
887
+ r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null, a);
879
888
  function t(e, s, l) {
880
889
  var c = e(s, l), d = (c >> 31) * 2 + 1, p = c >>> 23 & 255, f = c & 8388607;
881
890
  return p === 255 ? f ? NaN : d * (1 / 0) : p === 0 ? d * 1401298464324817e-60 * f : d * Math.pow(2, p - 150) * (f + 8388608);
882
891
  }
883
- r.readFloatLE = t.bind(null, a), r.readFloatBE = t.bind(null, n);
892
+ r.readFloatLE = t.bind(null, u), r.readFloatBE = t.bind(null, n);
884
893
  }(), typeof Float64Array < "u" ? function() {
885
894
  var i = new Float64Array([-0]), t = new Uint8Array(i.buffer), e = t[7] === 128;
886
895
  function s(p, f, w) {
@@ -922,21 +931,21 @@ function requireFloat() {
922
931
  }
923
932
  }
924
933
  }
925
- r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null, u, 4, 0);
934
+ r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null, a, 4, 0);
926
935
  function t(e, s, l, c, d) {
927
936
  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;
928
937
  return b === 2047 ? g ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * g : w * Math.pow(2, b - 1075) * (g + 4503599627370496);
929
938
  }
930
- r.readDoubleLE = t.bind(null, a, 0, 4), r.readDoubleBE = t.bind(null, n, 4, 0);
939
+ r.readDoubleLE = t.bind(null, u, 0, 4), r.readDoubleBE = t.bind(null, n, 4, 0);
931
940
  }(), r;
932
941
  }
933
942
  function o(r, i, t) {
934
943
  i[t] = r & 255, i[t + 1] = r >>> 8 & 255, i[t + 2] = r >>> 16 & 255, i[t + 3] = r >>> 24;
935
944
  }
936
- function u(r, i, t) {
945
+ function a(r, i, t) {
937
946
  i[t] = r >>> 24, i[t + 1] = r >>> 16 & 255, i[t + 2] = r >>> 8 & 255, i[t + 3] = r & 255;
938
947
  }
939
- function a(r, i) {
948
+ function u(r, i) {
940
949
  return (r[i] | r[i + 1] << 8 | r[i + 2] << 16 | r[i + 3] << 24) >>> 0;
941
950
  }
942
951
  function n(r, i) {
@@ -963,20 +972,20 @@ var utf8 = {}, hasRequiredUtf8;
963
972
  function requireUtf8() {
964
973
  return hasRequiredUtf8 || (hasRequiredUtf8 = 1, function(h) {
965
974
  var o = h;
966
- o.length = function(a) {
967
- for (var n = 0, r = 0, i = 0; i < a.length; ++i)
968
- 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;
975
+ o.length = function(u) {
976
+ for (var n = 0, r = 0, i = 0; i < u.length; ++i)
977
+ 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;
969
978
  return n;
970
- }, o.read = function(a, n, r) {
979
+ }, o.read = function(u, n, r) {
971
980
  var i = r - n;
972
981
  if (i < 1)
973
982
  return "";
974
983
  for (var t = null, e = [], s = 0, l; n < r; )
975
- 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);
984
+ 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);
976
985
  return t ? (s && t.push(String.fromCharCode.apply(String, e.slice(0, s))), t.join("")) : String.fromCharCode.apply(String, e.slice(0, s));
977
- }, o.write = function(a, n, r) {
978
- for (var i = r, t, e, s = 0; s < a.length; ++s)
979
- 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);
986
+ }, o.write = function(u, n, r) {
987
+ for (var i = r, t, e, s = 0; s < u.length; ++s)
988
+ 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);
980
989
  return r - i;
981
990
  };
982
991
  }(utf8)), utf8;
@@ -985,13 +994,13 @@ var pool_1, hasRequiredPool;
985
994
  function requirePool() {
986
995
  if (hasRequiredPool) return pool_1;
987
996
  hasRequiredPool = 1, pool_1 = h;
988
- function h(o, u, a) {
989
- var n = a || 8192, r = n >>> 1, i = null, t = n;
997
+ function h(o, a, u) {
998
+ var n = u || 8192, r = n >>> 1, i = null, t = n;
990
999
  return function(s) {
991
1000
  if (s < 1 || s > r)
992
1001
  return o(s);
993
1002
  t + s > n && (i = o(n), t = 0);
994
- var l = u.call(i, t, t += s);
1003
+ var l = a.call(i, t, t += s);
995
1004
  return t & 7 && (t = (t | 7) + 1), l;
996
1005
  };
997
1006
  }
@@ -1005,18 +1014,18 @@ function requireLongbits() {
1005
1014
  function o(r, i) {
1006
1015
  this.lo = r >>> 0, this.hi = i >>> 0;
1007
1016
  }
1008
- var u = o.zero = new o(0, 0);
1009
- u.toNumber = function() {
1017
+ var a = o.zero = new o(0, 0);
1018
+ a.toNumber = function() {
1010
1019
  return 0;
1011
- }, u.zzEncode = u.zzDecode = function() {
1020
+ }, a.zzEncode = a.zzDecode = function() {
1012
1021
  return this;
1013
- }, u.length = function() {
1022
+ }, a.length = function() {
1014
1023
  return 1;
1015
1024
  };
1016
- var a = o.zeroHash = "\0\0\0\0\0\0\0\0";
1025
+ var u = o.zeroHash = "\0\0\0\0\0\0\0\0";
1017
1026
  o.fromNumber = function(i) {
1018
1027
  if (i === 0)
1019
- return u;
1028
+ return a;
1020
1029
  var t = i < 0;
1021
1030
  t && (i = -i);
1022
1031
  var e = i >>> 0, s = (i - e) / 4294967296 >>> 0;
@@ -1029,7 +1038,7 @@ function requireLongbits() {
1029
1038
  i = h.Long.fromString(i);
1030
1039
  else
1031
1040
  return o.fromNumber(parseInt(i, 10));
1032
- return i.low || i.high ? new o(i.low >>> 0, i.high >>> 0) : u;
1041
+ return i.low || i.high ? new o(i.low >>> 0, i.high >>> 0) : a;
1033
1042
  }, o.prototype.toNumber = function(i) {
1034
1043
  if (!i && this.hi >>> 31) {
1035
1044
  var t = ~this.lo + 1 >>> 0, e = ~this.hi >>> 0;
@@ -1041,7 +1050,7 @@ function requireLongbits() {
1041
1050
  };
1042
1051
  var n = String.prototype.charCodeAt;
1043
1052
  return o.fromHash = function(i) {
1044
- return i === a ? u : new o(
1053
+ return i === u ? a : new o(
1045
1054
  (n.call(i, 0) | n.call(i, 1) << 8 | n.call(i, 2) << 16 | n.call(i, 3) << 24) >>> 0,
1046
1055
  (n.call(i, 4) | n.call(i, 5) << 8 | n.call(i, 6) << 16 | n.call(i, 7) << 24) >>> 0
1047
1056
  );
@@ -1114,21 +1123,21 @@ function requireMinimal$1() {
1114
1123
  var t = o.LongBits.fromHash(r);
1115
1124
  return o.Long ? o.Long.fromBits(t.lo, t.hi, i) : t.toNumber(!!i);
1116
1125
  };
1117
- function u(n, r, i) {
1126
+ function a(n, r, i) {
1118
1127
  for (var t = Object.keys(r), e = 0; e < t.length; ++e)
1119
1128
  (n[t[e]] === void 0 || !i) && (n[t[e]] = r[t[e]]);
1120
1129
  return n;
1121
1130
  }
1122
- o.merge = u, o.lcFirst = function(r) {
1131
+ o.merge = a, o.lcFirst = function(r) {
1123
1132
  return r.charAt(0).toLowerCase() + r.substring(1);
1124
1133
  };
1125
- function a(n) {
1134
+ function u(n) {
1126
1135
  function r(i, t) {
1127
1136
  if (!(this instanceof r))
1128
1137
  return new r(i, t);
1129
1138
  Object.defineProperty(this, "message", { get: function() {
1130
1139
  return i;
1131
- } }), Error.captureStackTrace ? Error.captureStackTrace(this, r) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t && u(this, t);
1140
+ } }), Error.captureStackTrace ? Error.captureStackTrace(this, r) : Object.defineProperty(this, "stack", { value: new Error().stack || "" }), t && a(this, t);
1132
1141
  }
1133
1142
  return r.prototype = Object.create(Error.prototype, {
1134
1143
  constructor: {
@@ -1159,7 +1168,7 @@ function requireMinimal$1() {
1159
1168
  }
1160
1169
  }), r;
1161
1170
  }
1162
- o.newError = a, o.ProtocolError = a("ProtocolError"), o.oneOfGetter = function(r) {
1171
+ o.newError = u, o.ProtocolError = u("ProtocolError"), o.oneOfGetter = function(r) {
1163
1172
  for (var i = {}, t = 0; t < r.length; ++t)
1164
1173
  i[r[t]] = 1;
1165
1174
  return function() {
@@ -1197,7 +1206,7 @@ var writer, hasRequiredWriter;
1197
1206
  function requireWriter() {
1198
1207
  if (hasRequiredWriter) return writer;
1199
1208
  hasRequiredWriter = 1, writer = e;
1200
- var h = requireMinimal$1(), o, u = h.LongBits, a = h.base64, n = h.utf8;
1209
+ var h = requireMinimal$1(), o, a = h.LongBits, u = h.base64, n = h.utf8;
1201
1210
  function r(b, g, k) {
1202
1211
  this.fn = b, this.len = g, this.next = void 0, this.val = k;
1203
1212
  }
@@ -1240,7 +1249,7 @@ function requireWriter() {
1240
1249
  g
1241
1250
  )).len, this;
1242
1251
  }, e.prototype.int32 = function(g) {
1243
- return g < 0 ? this._push(p, 10, u.fromNumber(g)) : this.uint32(g);
1252
+ return g < 0 ? this._push(p, 10, a.fromNumber(g)) : this.uint32(g);
1244
1253
  }, e.prototype.sint32 = function(g) {
1245
1254
  return this.uint32((g << 1 ^ g >> 31) >>> 0);
1246
1255
  };
@@ -1252,10 +1261,10 @@ function requireWriter() {
1252
1261
  g[k++] = b.lo;
1253
1262
  }
1254
1263
  e.prototype.uint64 = function(g) {
1255
- var k = u.from(g);
1264
+ var k = a.from(g);
1256
1265
  return this._push(p, k.length(), k);
1257
1266
  }, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(g) {
1258
- var k = u.from(g).zzEncode();
1267
+ var k = a.from(g).zzEncode();
1259
1268
  return this._push(p, k.length(), k);
1260
1269
  }, e.prototype.bool = function(g) {
1261
1270
  return this._push(l, 1, g ? 1 : 0);
@@ -1266,7 +1275,7 @@ function requireWriter() {
1266
1275
  e.prototype.fixed32 = function(g) {
1267
1276
  return this._push(f, 4, g >>> 0);
1268
1277
  }, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(g) {
1269
- var k = u.from(g);
1278
+ var k = a.from(g);
1270
1279
  return this._push(f, 4, k.lo)._push(f, 4, k.hi);
1271
1280
  }, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(g) {
1272
1281
  return this._push(h.float.writeFloatLE, 4, g);
@@ -1276,16 +1285,16 @@ function requireWriter() {
1276
1285
  var w = h.Array.prototype.set ? function(g, k, T) {
1277
1286
  k.set(g, T);
1278
1287
  } : function(g, k, T) {
1279
- for (var $ = 0; $ < g.length; ++$)
1280
- k[T + $] = g[$];
1288
+ for (var D = 0; D < g.length; ++D)
1289
+ k[T + D] = g[D];
1281
1290
  };
1282
1291
  return e.prototype.bytes = function(g) {
1283
1292
  var k = g.length >>> 0;
1284
1293
  if (!k)
1285
1294
  return this._push(l, 1, 0);
1286
1295
  if (h.isString(g)) {
1287
- var T = e.alloc(k = a.length(g));
1288
- a.decode(g, T, 0), g = T;
1296
+ var T = e.alloc(k = u.length(g));
1297
+ u.decode(g, T, 0), g = T;
1289
1298
  }
1290
1299
  return this.uint32(k)._push(w, k, g);
1291
1300
  }, e.prototype.string = function(g) {
@@ -1309,15 +1318,15 @@ function requireWriter() {
1309
1318
  var writer_buffer, hasRequiredWriter_buffer;
1310
1319
  function requireWriter_buffer() {
1311
1320
  if (hasRequiredWriter_buffer) return writer_buffer;
1312
- hasRequiredWriter_buffer = 1, writer_buffer = u;
1321
+ hasRequiredWriter_buffer = 1, writer_buffer = a;
1313
1322
  var h = requireWriter();
1314
- (u.prototype = Object.create(h.prototype)).constructor = u;
1323
+ (a.prototype = Object.create(h.prototype)).constructor = a;
1315
1324
  var o = requireMinimal$1();
1316
- function u() {
1325
+ function a() {
1317
1326
  h.call(this);
1318
1327
  }
1319
- u._configure = function() {
1320
- u.alloc = o._Buffer_allocUnsafe, u.writeBytesBuffer = o.Buffer && o.Buffer.prototype instanceof Uint8Array && o.Buffer.prototype.set.name === "set" ? function(r, i, t) {
1328
+ a._configure = function() {
1329
+ a.alloc = o._Buffer_allocUnsafe, a.writeBytesBuffer = o.Buffer && o.Buffer.prototype instanceof Uint8Array && o.Buffer.prototype.set.name === "set" ? function(r, i, t) {
1321
1330
  i.set(r, t);
1322
1331
  } : function(r, i, t) {
1323
1332
  if (r.copy)
@@ -1325,24 +1334,24 @@ function requireWriter_buffer() {
1325
1334
  else for (var e = 0; e < r.length; )
1326
1335
  i[t++] = r[e++];
1327
1336
  };
1328
- }, u.prototype.bytes = function(r) {
1337
+ }, a.prototype.bytes = function(r) {
1329
1338
  o.isString(r) && (r = o._Buffer_from(r, "base64"));
1330
1339
  var i = r.length >>> 0;
1331
- return this.uint32(i), i && this._push(u.writeBytesBuffer, i, r), this;
1340
+ return this.uint32(i), i && this._push(a.writeBytesBuffer, i, r), this;
1332
1341
  };
1333
- function a(n, r, i) {
1342
+ function u(n, r, i) {
1334
1343
  n.length < 40 ? o.utf8.write(n, r, i) : r.utf8Write ? r.utf8Write(n, i) : r.write(n, i);
1335
1344
  }
1336
- return u.prototype.string = function(r) {
1345
+ return a.prototype.string = function(r) {
1337
1346
  var i = o.Buffer.byteLength(r);
1338
- return this.uint32(i), i && this._push(a, i, r), this;
1339
- }, u._configure(), writer_buffer;
1347
+ return this.uint32(i), i && this._push(u, i, r), this;
1348
+ }, a._configure(), writer_buffer;
1340
1349
  }
1341
1350
  var reader, hasRequiredReader;
1342
1351
  function requireReader() {
1343
1352
  if (hasRequiredReader) return reader;
1344
1353
  hasRequiredReader = 1, reader = r;
1345
- var h = requireMinimal$1(), o, u = h.LongBits, a = h.utf8;
1354
+ var h = requireMinimal$1(), o, a = h.LongBits, u = h.utf8;
1346
1355
  function n(c, d) {
1347
1356
  return RangeError("index out of range: " + c.pos + " + " + (d || 1) + " > " + c.len);
1348
1357
  }
@@ -1380,7 +1389,7 @@ function requireReader() {
1380
1389
  return d >>> 1 ^ -(d & 1) | 0;
1381
1390
  };
1382
1391
  function e() {
1383
- var c = new u(0, 0), d = 0;
1392
+ var c = new a(0, 0), d = 0;
1384
1393
  if (this.len - this.pos > 4) {
1385
1394
  for (; d < 4; ++d)
1386
1395
  if (c.lo = (c.lo | (this.buf[this.pos] & 127) << d * 7) >>> 0, this.buf[this.pos++] < 128)
@@ -1428,7 +1437,7 @@ function requireReader() {
1428
1437
  function l() {
1429
1438
  if (this.pos + 8 > this.len)
1430
1439
  throw n(this, 8);
1431
- return new u(s(this.buf, this.pos += 4), s(this.buf, this.pos += 4));
1440
+ return new a(s(this.buf, this.pos += 4), s(this.buf, this.pos += 4));
1432
1441
  }
1433
1442
  return r.prototype.float = function() {
1434
1443
  if (this.pos + 4 > this.len)
@@ -1453,7 +1462,7 @@ function requireReader() {
1453
1462
  return this._slice.call(this.buf, p, f);
1454
1463
  }, r.prototype.string = function() {
1455
1464
  var d = this.bytes();
1456
- return a.read(d, 0, d.length);
1465
+ return u.read(d, 0, d.length);
1457
1466
  }, r.prototype.skip = function(d) {
1458
1467
  if (typeof d == "number") {
1459
1468
  if (this.pos + d > this.len)
@@ -1516,19 +1525,19 @@ function requireReader() {
1516
1525
  var reader_buffer, hasRequiredReader_buffer;
1517
1526
  function requireReader_buffer() {
1518
1527
  if (hasRequiredReader_buffer) return reader_buffer;
1519
- hasRequiredReader_buffer = 1, reader_buffer = u;
1528
+ hasRequiredReader_buffer = 1, reader_buffer = a;
1520
1529
  var h = requireReader();
1521
- (u.prototype = Object.create(h.prototype)).constructor = u;
1530
+ (a.prototype = Object.create(h.prototype)).constructor = a;
1522
1531
  var o = requireMinimal$1();
1523
- function u(a) {
1524
- h.call(this, a);
1532
+ function a(u) {
1533
+ h.call(this, u);
1525
1534
  }
1526
- return u._configure = function() {
1527
- o.Buffer && (u.prototype._slice = o.Buffer.prototype.slice);
1528
- }, u.prototype.string = function() {
1535
+ return a._configure = function() {
1536
+ o.Buffer && (a.prototype._slice = o.Buffer.prototype.slice);
1537
+ }, a.prototype.string = function() {
1529
1538
  var n = this.uint32();
1530
1539
  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));
1531
- }, u._configure(), reader_buffer;
1540
+ }, a._configure(), reader_buffer;
1532
1541
  }
1533
1542
  var rpc = {}, service, hasRequiredService;
1534
1543
  function requireService() {
@@ -1536,17 +1545,17 @@ function requireService() {
1536
1545
  hasRequiredService = 1, service = o;
1537
1546
  var h = requireMinimal$1();
1538
1547
  (o.prototype = Object.create(h.EventEmitter.prototype)).constructor = o;
1539
- function o(u, a, n) {
1540
- if (typeof u != "function")
1548
+ function o(a, u, n) {
1549
+ if (typeof a != "function")
1541
1550
  throw TypeError("rpcImpl must be a function");
1542
- h.EventEmitter.call(this), this.rpcImpl = u, this.requestDelimited = !!a, this.responseDelimited = !!n;
1551
+ h.EventEmitter.call(this), this.rpcImpl = a, this.requestDelimited = !!u, this.responseDelimited = !!n;
1543
1552
  }
1544
- return o.prototype.rpcCall = function u(a, n, r, i, t) {
1553
+ return o.prototype.rpcCall = function a(u, n, r, i, t) {
1545
1554
  if (!i)
1546
1555
  throw TypeError("request must be specified");
1547
1556
  var e = this;
1548
1557
  if (!t)
1549
- return h.asPromise(u, e, a, n, r, i);
1558
+ return h.asPromise(a, e, u, n, r, i);
1550
1559
  if (!e.rpcImpl) {
1551
1560
  setTimeout(function() {
1552
1561
  t(Error("already ended"));
@@ -1555,11 +1564,11 @@ function requireService() {
1555
1564
  }
1556
1565
  try {
1557
1566
  return e.rpcImpl(
1558
- a,
1567
+ u,
1559
1568
  n[e.requestDelimited ? "encodeDelimited" : "encode"](i).finish(),
1560
1569
  function(l, c) {
1561
1570
  if (l)
1562
- return e.emit("error", l, a), t(l);
1571
+ return e.emit("error", l, u), t(l);
1563
1572
  if (c === null) {
1564
1573
  e.end(
1565
1574
  /* endedByRPC */
@@ -1571,19 +1580,19 @@ function requireService() {
1571
1580
  try {
1572
1581
  c = r[e.responseDelimited ? "decodeDelimited" : "decode"](c);
1573
1582
  } catch (d) {
1574
- return e.emit("error", d, a), t(d);
1583
+ return e.emit("error", d, u), t(d);
1575
1584
  }
1576
- return e.emit("data", c, a), t(null, c);
1585
+ return e.emit("data", c, u), t(null, c);
1577
1586
  }
1578
1587
  );
1579
1588
  } catch (s) {
1580
- e.emit("error", s, a), setTimeout(function() {
1589
+ e.emit("error", s, u), setTimeout(function() {
1581
1590
  t(s);
1582
1591
  }, 0);
1583
1592
  return;
1584
1593
  }
1585
- }, o.prototype.end = function(a) {
1586
- return this.rpcImpl && (a || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this;
1594
+ }, o.prototype.end = function(u) {
1595
+ return this.rpcImpl && (u || this.rpcImpl(null, null, null), this.rpcImpl = null, this.emit("end").off()), this;
1587
1596
  }, service;
1588
1597
  }
1589
1598
  var hasRequiredRpc;
@@ -1601,11 +1610,11 @@ var hasRequiredIndexMinimal;
1601
1610
  function requireIndexMinimal() {
1602
1611
  return hasRequiredIndexMinimal || (hasRequiredIndexMinimal = 1, function(h) {
1603
1612
  var o = h;
1604
- 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;
1605
- function u() {
1613
+ 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;
1614
+ function a() {
1606
1615
  o.util._configure(), o.Writer._configure(o.BufferWriter), o.Reader._configure(o.BufferReader);
1607
1616
  }
1608
- u();
1617
+ a();
1609
1618
  }(indexMinimal)), indexMinimal;
1610
1619
  }
1611
1620
  var minimal, hasRequiredMinimal;
@@ -1618,10 +1627,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1618
1627
  return h.quick = function() {
1619
1628
  const o = {};
1620
1629
  return o.voice = function() {
1621
- const u = {};
1622
- return u.proto = function() {
1623
- const a = {};
1624
- return a.SeiData = function() {
1630
+ const a = {};
1631
+ return a.proto = function() {
1632
+ const u = {};
1633
+ return u.SeiData = function() {
1625
1634
  function n(r) {
1626
1635
  if (r) for (let i = Object.keys(r), t = 0; t < i.length; ++t) r[i[t]] != null && (this[i[t]] = r[i[t]]);
1627
1636
  }
@@ -1714,10 +1723,10 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1714
1723
  }, n.getTypeUrl = function(i) {
1715
1724
  return i === void 0 && (i = "type.googleapis.com"), i + "/com.quick.voice.proto.SeiData";
1716
1725
  }, n;
1717
- }(), a.EventType = function() {
1726
+ }(), u.EventType = function() {
1718
1727
  const n = {}, r = Object.create(n);
1719
1728
  return r[n[0] = "Layout"] = 0, r[n[1] = "Custom"] = 1, r;
1720
- }(), a.LayoutData = function() {
1729
+ }(), u.LayoutData = function() {
1721
1730
  function n(i) {
1722
1731
  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]]);
1723
1732
  }
@@ -1876,7 +1885,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1876
1885
  }, n.getTypeUrl = function(t) {
1877
1886
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.LayoutData";
1878
1887
  }, n;
1879
- }(), a.UserInfo = function() {
1888
+ }(), u.UserInfo = function() {
1880
1889
  function n(i) {
1881
1890
  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]]);
1882
1891
  }
@@ -1999,7 +2008,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1999
2008
  }, n.getTypeUrl = function(t) {
2000
2009
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.UserInfo";
2001
2010
  }, n;
2002
- }(), a.AudioInfo = function() {
2011
+ }(), u.AudioInfo = function() {
2003
2012
  function n(i) {
2004
2013
  if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
2005
2014
  }
@@ -2104,7 +2113,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2104
2113
  }, n.getTypeUrl = function(t) {
2105
2114
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.AudioInfo";
2106
2115
  }, n;
2107
- }(), a.VideoInfo = function() {
2116
+ }(), u.VideoInfo = function() {
2108
2117
  function n(i) {
2109
2118
  if (i) for (let t = Object.keys(i), e = 0; e < t.length; ++e) i[t[e]] != null && (this[t[e]] = i[t[e]]);
2110
2119
  }
@@ -2230,7 +2239,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2230
2239
  }, n.getTypeUrl = function(t) {
2231
2240
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.VideoInfo";
2232
2241
  }, n;
2233
- }(), a.CustomInfo = function() {
2242
+ }(), u.CustomInfo = function() {
2234
2243
  function n(i) {
2235
2244
  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]]);
2236
2245
  }
@@ -2337,17 +2346,17 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2337
2346
  }, n.getTypeUrl = function(t) {
2338
2347
  return t === void 0 && (t = "type.googleapis.com"), t + "/com.quick.voice.proto.CustomInfo";
2339
2348
  }, n;
2340
- }(), a.LayoutType = function() {
2349
+ }(), u.LayoutType = function() {
2341
2350
  const n = {}, r = Object.create(n);
2342
2351
  return r[n[0] = "AudioAndVideo"] = 0, r[n[1] = "OnlyAudio"] = 1, r[n[2] = "OnlyVideo"] = 2, r;
2343
- }(), a.AudioType = function() {
2352
+ }(), u.AudioType = function() {
2344
2353
  const n = {}, r = Object.create(n);
2345
2354
  return r[n[0] = "Microphone"] = 0, r[n[1] = "SystemVoice"] = 1, r;
2346
- }(), a.VideoType = function() {
2355
+ }(), u.VideoType = function() {
2347
2356
  const n = {}, r = Object.create(n);
2348
2357
  return r[n[0] = "Camera"] = 0, r[n[1] = "Screen"] = 1, r;
2349
- }(), a;
2350
- }(), u;
2358
+ }(), u;
2359
+ }(), a;
2351
2360
  }(), o;
2352
2361
  }(), h;
2353
2362
  })(), createAudioInfo = () => ({
@@ -2368,27 +2377,27 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2368
2377
  });
2369
2378
  class RoomUser {
2370
2379
  constructor() {
2371
- y(this, "userId", "");
2372
- y(this, "mc_audio");
2380
+ m(this, "userId", "");
2381
+ m(this, "mc_audio");
2373
2382
  // 麦克风
2374
- y(this, "mc_video");
2383
+ m(this, "mc_video");
2375
2384
  // 摄像头
2376
- y(this, "ss_audio");
2385
+ m(this, "ss_audio");
2377
2386
  // 屏幕共享视频
2378
- y(this, "ss_video");
2387
+ m(this, "ss_video");
2379
2388
  // 屏幕共享音频
2380
- y(this, "updateTime", 0);
2381
- y(this, "getUpdateTimeKey", () => {
2389
+ m(this, "updateTime", 0);
2390
+ m(this, "getUpdateTimeKey", () => {
2382
2391
  const o = [];
2383
2392
  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("_");
2384
2393
  });
2385
- y(this, "init", (o) => {
2394
+ m(this, "init", (o) => {
2386
2395
  var t, e, s, l;
2387
- const { id: u, audios: a = [], videos: n = [] } = o;
2388
- this.userId = u;
2396
+ const { id: a, audios: u = [], videos: n = [] } = o;
2397
+ this.userId = a;
2389
2398
  const r = this.getUpdateTimeKey();
2390
2399
  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);
2391
- for (const c of a) {
2400
+ for (const c of u) {
2392
2401
  const { type: d = 0, isEnable: p = !1, isMute: f = !1, updateTime: w, volume: b = 0 } = c;
2393
2402
  switch (d) {
2394
2403
  case 0:
@@ -2426,26 +2435,26 @@ class RoomUser {
2426
2435
  const i = this.getUpdateTimeKey();
2427
2436
  r !== i && (this.updateTime = (/* @__PURE__ */ new Date()).getTime());
2428
2437
  });
2429
- y(this, "destroy", () => {
2438
+ m(this, "destroy", () => {
2430
2439
  this.mc_audio = void 0, this.mc_video = void 0, this.ss_audio = void 0, this.ss_video = void 0;
2431
2440
  });
2432
2441
  }
2433
2442
  }
2434
2443
  const parseSEI = (h) => {
2435
- let o = 0, u = 0;
2444
+ let o = 0, a = 0;
2436
2445
  for (; ; ) {
2437
2446
  const n = h[o];
2438
- if (u = u + n, o = o + 1, n !== 255) break;
2447
+ if (a = a + n, o = o + 1, n !== 255) break;
2439
2448
  }
2440
- let a = 0;
2449
+ let u = 0;
2441
2450
  for (; ; ) {
2442
2451
  const n = h[o];
2443
- if (a = a + n, o = o + 1, n !== 255) break;
2452
+ if (u = u + n, o = o + 1, n !== 255) break;
2444
2453
  }
2445
- if (u === 5) {
2454
+ if (a === 5) {
2446
2455
  const n = h.slice(o, o + 16), i = Array.from(n, (f) => f.toString(16).padStart(2, "0")).join("");
2447
2456
  o = o + 16;
2448
- 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;
2457
+ 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;
2449
2458
  let d;
2450
2459
  switch (l) {
2451
2460
  case 0:
@@ -2460,80 +2469,80 @@ const parseSEI = (h) => {
2460
2469
  };
2461
2470
  class QuickVoPlayer {
2462
2471
  constructor(o = {}) {
2463
- y(this, "option", {
2472
+ m(this, "option", {
2464
2473
  debug: !1,
2465
2474
  ws: "wss://livep2p.devplay.cc/websocket"
2466
2475
  });
2467
- y(this, "displayMode", "original");
2468
- y(this, "prPlayer");
2469
- y(this, "dom");
2470
- y(this, "room", {
2476
+ m(this, "displayMode", "original");
2477
+ m(this, "prPlayer");
2478
+ m(this, "dom");
2479
+ m(this, "room", {
2471
2480
  roomId: "",
2472
2481
  updateTime: "",
2473
2482
  author: "",
2474
2483
  version: ""
2475
2484
  });
2476
- y(this, "usersMap", /* @__PURE__ */ new Map());
2477
- y(this, "on", {
2485
+ m(this, "usersMap", /* @__PURE__ */ new Map());
2486
+ m(this, "on", {
2478
2487
  users: (o) => {
2479
2488
  },
2480
2489
  analysis: (o) => {
2481
2490
  }
2482
2491
  });
2483
- y(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
2484
- y(this, "stop", () => {
2492
+ m(this, "start", async (o) => (this.stop(), this.prPlayer.start(o)));
2493
+ m(this, "stop", () => {
2485
2494
  this.prPlayer.stop(), this.usersMap = /* @__PURE__ */ new Map(), this.room.roomId = "", this.room.author = "", this.room.updateTime = "", this.room.version = "";
2486
2495
  });
2487
- y(this, "setMute", (o) => {
2496
+ m(this, "setMute", (o) => {
2488
2497
  this.prPlayer.setMute(o);
2489
2498
  });
2490
- y(this, "setOutputGain", (o) => {
2491
- var u, a;
2492
- (a = (u = this.prPlayer.audioPlayer) == null ? void 0 : u.prAudioStream) == null || a.setOutputGain(o);
2499
+ m(this, "setOutputGain", (o) => {
2500
+ var a, u;
2501
+ (u = (a = this.prPlayer.audioPlayer) == null ? void 0 : a.prAudioStream) == null || u.setOutputGain(o);
2493
2502
  });
2494
- y(this, "getStream", () => this.prPlayer.getStream());
2495
- y(this, "getAllUseUpdateKey", () => {
2503
+ m(this, "getStream", () => this.prPlayer.getStream());
2504
+ m(this, "getAllUseUpdateKey", () => {
2496
2505
  const o = [...this.usersMap.values()];
2497
- return Array.from(o, (a) => a.updateTime).join("_");
2506
+ return Array.from(o, (u) => u.updateTime).join("_");
2498
2507
  });
2499
- y(this, "checkAndCreateUser", (o, u) => {
2508
+ m(this, "checkAndCreateUser", (o, a) => {
2500
2509
  !this.usersMap.has(o) && this.usersMap.set(o, new RoomUser());
2501
- const a = this.usersMap.get(o);
2502
- if (a) {
2503
- if (a.init(u), a.mc_video && a.mc_video.stream === void 0) {
2504
- const { sx: n, sy: r, sw: i, sh: t } = a.mc_video, e = `${a.userId}_mc_video`, s = this.prPlayer.cut.create(e, { sx: n, sy: r, sw: i, sh: t });
2505
- this.displayMode === "original" && this.prPlayer.cut.setPause(e, !0), a.mc_video.stream = s;
2510
+ const u = this.usersMap.get(o);
2511
+ if (u) {
2512
+ if (u.init(a), u.mc_video && u.mc_video.stream === void 0) {
2513
+ const { sx: n, sy: r, sw: i, sh: t } = u.mc_video, e = `${u.userId}_mc_video`, s = this.prPlayer.cut.create(e, { sx: n, sy: r, sw: i, sh: t });
2514
+ this.displayMode === "original" && this.prPlayer.cut.setPause(e, !0), u.mc_video.stream = s;
2506
2515
  }
2507
- if (a.ss_video && a.ss_video.stream === void 0) {
2508
- const { sx: n, sy: r, sw: i, sh: t } = a.ss_video, e = `${a.userId}_ss_video`, s = this.prPlayer.cut.create(e, { sx: n, sy: r, sw: i, sh: t });
2509
- this.displayMode === "original" && this.prPlayer.cut.setPause(e, !0), a.ss_video.stream = s;
2516
+ if (u.ss_video && u.ss_video.stream === void 0) {
2517
+ const { sx: n, sy: r, sw: i, sh: t } = u.ss_video, e = `${u.userId}_ss_video`, s = this.prPlayer.cut.create(e, { sx: n, sy: r, sw: i, sh: t });
2518
+ this.displayMode === "original" && this.prPlayer.cut.setPause(e, !0), u.ss_video.stream = s;
2510
2519
  }
2511
- if (a != null && a.mc_video) {
2512
- const n = `${a.userId}_mc_video`, { sx: r, sy: i, sw: t, sh: e } = a.mc_video;
2520
+ if (u != null && u.mc_video) {
2521
+ const n = `${u.userId}_mc_video`, { sx: r, sy: i, sw: t, sh: e } = u.mc_video;
2513
2522
  this.prPlayer.cut.setCut(n, { sx: r, sy: i, sw: t, sh: e });
2514
2523
  }
2515
- if (a != null && a.ss_video) {
2516
- const n = `${a.userId}_ss_video`, { sx: r, sy: i, sw: t, sh: e } = a.ss_video;
2524
+ if (u != null && u.ss_video) {
2525
+ const n = `${u.userId}_ss_video`, { sx: r, sy: i, sw: t, sh: e } = u.ss_video;
2517
2526
  this.prPlayer.cut.setCut(n, { sx: r, sy: i, sw: t, sh: e });
2518
2527
  }
2519
2528
  }
2520
2529
  });
2521
- y(this, "setDisplayMode", (o) => {
2530
+ m(this, "setDisplayMode", (o) => {
2522
2531
  switch (this.displayMode = o, o) {
2523
2532
  case "original":
2524
2533
  {
2525
2534
  this.prPlayer.setPause(!1);
2526
- const u = [...this.usersMap.keys()];
2527
- for (const a of u)
2528
- this.prPlayer.cut.setPause(`${a}_mc_video`, !0), this.prPlayer.cut.setPause(`${a}_ss_video`, !0);
2535
+ const a = [...this.usersMap.keys()];
2536
+ for (const u of a)
2537
+ this.prPlayer.cut.setPause(`${u}_mc_video`, !0), this.prPlayer.cut.setPause(`${u}_ss_video`, !0);
2529
2538
  }
2530
2539
  break;
2531
2540
  case "cut":
2532
2541
  {
2533
2542
  this.prPlayer.setPause(!0);
2534
- const u = [...this.usersMap.keys()];
2535
- for (const a of u)
2536
- this.prPlayer.cut.setPause(`${a}_mc_video`, !1), this.prPlayer.cut.setPause(`${a}_ss_video`, !1);
2543
+ const a = [...this.usersMap.keys()];
2544
+ for (const u of a)
2545
+ this.prPlayer.cut.setPause(`${u}_mc_video`, !1), this.prPlayer.cut.setPause(`${u}_ss_video`, !1);
2537
2546
  }
2538
2547
  break;
2539
2548
  }
@@ -2541,12 +2550,12 @@ class QuickVoPlayer {
2541
2550
  /**
2542
2551
  * 监听SEI信息
2543
2552
  */
2544
- y(this, "onSEI", (o) => {
2553
+ m(this, "onSEI", (o) => {
2545
2554
  try {
2546
- const u = parseSEI(o);
2547
- if (!u) return;
2548
- const { event: a, data: n } = u;
2549
- switch (a) {
2555
+ const a = parseSEI(o);
2556
+ if (!a) return;
2557
+ const { event: u, data: n } = a;
2558
+ switch (u) {
2550
2559
  case 0:
2551
2560
  {
2552
2561
  const { roomId: r, userMap: i } = n;
@@ -2575,21 +2584,21 @@ class QuickVoPlayer {
2575
2584
  }
2576
2585
  break;
2577
2586
  }
2578
- } catch (u) {
2579
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", u);
2587
+ } catch (a) {
2588
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->onSEI: error", a);
2580
2589
  }
2581
2590
  });
2582
- y(this, "onAnalysis", (o) => {
2591
+ m(this, "onAnalysis", (o) => {
2583
2592
  this.on.analysis && this.on.analysis(o);
2584
2593
  });
2585
- const a = btoa(encodeURI(JSON.stringify({
2594
+ const u = btoa(encodeURI(JSON.stringify({
2586
2595
  appId: "A6B499768801E248ACA11E5F842DB6DF",
2587
2596
  userId: "web_breathe",
2588
2597
  // "authId":"mobilePackageName" | "webRequestHostOrigin",
2589
2598
  platform: "web",
2590
2599
  version: "1.0.1"
2591
2600
  // 连接版本号
2592
- }))), n = `${this.option.ws}?s=${a}&t=${Date.now()}`;
2601
+ }))), n = `${this.option.ws}?s=${u}&t=${Date.now()}`;
2593
2602
  let r = new WebSocket(n);
2594
2603
  console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: ws", r);
2595
2604
  const { debug: i = !1 } = o;