@castlabs/prestoplay 6.9.0 → 6.10.0
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/CHANGELOG.md +39 -0
- package/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +6 -6
- package/cjs/cl.cast.js +105 -104
- package/cjs/cl.conviva.js +33 -33
- package/cjs/cl.core.js +420 -417
- package/cjs/cl.crypto.js +10 -9
- package/cjs/cl.dash.js +71 -71
- package/cjs/cl.externs.js +11 -12
- package/cjs/cl.freewheel.js +21 -21
- package/cjs/cl.hls.js +72 -71
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +29 -31
- package/cjs/cl.ima.js +22 -22
- package/cjs/cl.mse.js +273 -272
- package/cjs/cl.muxdata.js +14 -15
- package/cjs/cl.onboard.js +3 -3
- package/cjs/cl.persistent.js +13 -13
- package/cjs/cl.playlist.js +6 -6
- package/cjs/cl.smooth.js +71 -71
- package/cjs/cl.thumbnails.js +24 -24
- package/cjs/cl.tizen.js +68 -68
- package/cjs/cl.ttml.js +27 -27
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +13 -13
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.youbora.js +16 -16
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +5 -5
- package/cl.cast.js +87 -87
- package/cl.conviva.js +27 -27
- package/cl.core.js +363 -359
- package/cl.crypto.js +9 -9
- package/cl.dash.js +67 -67
- package/cl.externs.js +11 -12
- package/cl.freewheel.js +17 -17
- package/cl.hls.js +61 -61
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -25
- package/cl.ima.js +17 -17
- package/cl.mse.js +235 -236
- package/cl.muxdata.js +12 -12
- package/cl.onboard.js +4 -4
- package/cl.persistent.js +9 -9
- package/cl.playlist.js +5 -5
- package/cl.smooth.js +59 -58
- package/cl.thumbnails.js +17 -17
- package/cl.tizen.js +57 -57
- package/cl.ttml.js +22 -22
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +8 -8
- package/cl.vr.js +14 -14
- package/cl.vtt.js +12 -12
- package/cl.youbora.js +13 -13
- package/package.json +1 -1
- package/typings.d.ts +47 -2
package/cl.hls.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
|
|
3
|
-
4,4024,{missingTag:b});return a},
|
|
4
|
-
|
|
5
|
-
if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.G,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ua:d,ha:e}},
|
|
6
|
-
null}},
|
|
7
|
-
0,0,()=>[a.a],c.ua,c.ha,0,b)},
|
|
8
|
-
_.
|
|
9
|
-
|
|
10
|
-
f.push(h)):/^#(?!EXT)/m.test(h)||(h=
|
|
11
|
-
14|h[2]<<7|h[3]}function d(){throw new _.H(_.G,4,4030);}
|
|
12
|
-
f}while(e<a.byteLength);return d()},
|
|
13
|
-
Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.H(_.G,4,4030,
|
|
14
|
-
4,4030);}const d=new _.
|
|
15
|
-
|
|
16
|
-
b}return _.
|
|
17
|
-
|
|
18
|
-
"SAMPLE-AES"===e)&&!b.every(e=>e===
|
|
19
|
-
|
|
20
|
-
e.uris[0]);try{return yield a.g(f)}catch(h){throw a.f.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.H(_.G,4,4030,"Failed to fetch the media segment.");}}})},
|
|
21
|
-
|
|
22
|
-
b){a.ca.forEach(c=>{c.width=b})},
|
|
23
|
-
a.length)return a[0];const b=a[0],c=a.reduce((e,f)=>e+f.duration,0),d=new Map;a.forEach((e,f)=>{const g=
|
|
24
|
-
endTime:a[0].startTime+c})},
|
|
25
|
-
|
|
26
|
-
"\n");d=d.trim();return{text:d,response:c}})},
|
|
27
|
-
c={
|
|
28
|
-
a.a.debug("Offset NOT applied to",
|
|
29
|
-
1].S,f=f[f.length-1].xa):f=0;if(e&&0<f)try{{const k=
|
|
30
|
-
}g=0}}c=c.S||[];for(const k of c)
|
|
31
|
-
e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)
|
|
32
|
-
b=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.H(_.G,4,4015);var e=b,f=0,g=!0;for(h of e){var h=h.trim();if(!h.length||/^#(?!EXT)/m.test(h)||g)g=!1;else if(e=_.
|
|
33
|
-
h,f.concat(a.$),a.S);break a}f.push(e);e.name===
|
|
34
|
-
new _.
|
|
35
|
-
b,c){return _.y(function*(){if(0===b.length)return new Map;var d=[
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.f.clear()}},
|
|
58
|
-
|
|
59
|
-
c)}start(a,b){const c=this;return _.y(function*(){if(c.I)throw Error("start() may be called only once!");c.I=!0;c.D=b;const {response:d,text:e}=yield
|
|
60
|
-
b){var c=b.presentationTimeline;b=b.periods[0].startTime;var d=[];"LIVE"===a.j&&(a.w=null);var e=Array.from(a.A.values());e=a.f.hlsLowLatency&&0<e.length?e:Array.from(a.g.values());e=yield
|
|
61
|
-
7,7001);a=this.D.networkingEngine.fetch(a);_.
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var iA="CLOSED-CAPTIONS",jA="Could not parse MP4 segment start time.",kA="EXT-X-BYTERANGE",lA="EXT-X-DISCONTINUITY",mA="EXT-X-DISCONTINUITY-SEQUENCE",nA="EXT-X-ENDLIST",oA="EXT-X-KEY",pA="EXT-X-MAP",qA="EXT-X-MEDIA-SEQUENCE",rA="EXT-X-PART-INF",sA="EXT-X-PLAYLIST-TYPE",tA="EXT-X-PRELOAD-HINT",uA="EXT-X-PROGRAM-DATE-TIME",vA="EXT-X-SERVER-CONTROL",wA="EXT-X-STREAM-INF",xA="EXT-X-TARGETDURATION",yA="Failed to infer discontinuity number",zA="Guessing audio-only",AA="METHOD",BA="SAMPLE-AES-CTR",
|
|
2
|
+
CA="SUBTITLES",DA="Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one ",EA="application/vnd.apple.mpegurl",FA="sample",GA="whole-segment",HA=function(a,b){return _.J(a,b,void 0,{required:!0})},IA=function(a){if(1>a.a)throw _.Aj();--a.a},JA=function(a){if(null!==a&&void 0!==a)return Number(a)},KA=function(a,b){return a.filter(c=>c.name===b)},LA=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=HA(d,"TYPE");return c.includes(d)})},MA=function(a,b){return a.some(c=>c.name===
|
|
3
|
+
b)},NA=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.H(_.G,4,4024,{missingTag:b});return a},OA=function(a){var b=NA(a,"EXT-X-TILES");if(!b)return{Ge:1,hf:1,durationPerTile:null};a=_.J(b,"LAYOUT")||"1x1";b=(b=_.J(b,"DURATION"))?Number(b):null;const [c,d]=a.split("x").map(e=>parseInt(e,10));return{Ge:c,hf:d,durationPerTile:b}},PA=function(a,b){return _.xu([a],[b])[0]},QA=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&
|
|
4
|
+
b.add(c.video)});a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},RA=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of QA(c))b(d,c)})},SA=function(a){return a.type===_.p||a.type===_.w},TA=function(a){const b=NA(a,sA);if(NA(a,nA))return _.Xt;if(!b)return"LIVE";if(b.value===_.Xt)return _.Xt;if("EVENT"===b.value)return"EVENT";throw new _.H(_.G,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${b.value}`);},UA=function(a,b,c){c=void 0===c?!1:c;
|
|
5
|
+
var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.H(_.G,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.H(_.G,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.H(_.G,4,4044,"Invalid byte range, offset is required but missing.");if(null==b)throw new _.H(_.G,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{ua:d,ha:e}},VA=function(a,b){a=NA(a,kA);return UA(a?
|
|
6
|
+
a.value:null,b)},WA=function(a){a=NA(a,"EXTINF",{required:!0}).value.split(",");return{duration:Number(a[0]),title:a[1]||null}},XA=function(a,b){b=void 0===b?{}:b;const c={Wc:!1,vf:!1,wf:null,Tf:null,Ue:null};a=NA(a,vA,{required:b.Ze});if(!a)return c;const d=e=>null==e?null:Number(e);c.Wc="YES"===_.J(a,"CAN-BLOCK-RELOAD");c.vf="YES"===_.J(a,"CAN-SKIP-DATERANGES");c.wf=d(_.J(a,"CAN-SKIP-UNTIL"));c.Tf=d(_.J(a,"HOLD-BACK"));c.Ue=d(_.J(a,"PART-HOLD-BACK",void 0,{required:b.Ze}));return c},YA=function(a,
|
|
7
|
+
b,c){c=void 0===c?!1:c;a=_.J(a,"BYTERANGE");return UA(a,b,c)},$A=function(a,b){const c=VA(a.$,null);return new ZA(0,0,0,()=>[a.a],c.ua,c.ha,0,b)},aB=function(a,b){if(null==a)return null;a=Object.assign({},a);null==a.iv&&(a.iv=_.dh(new Uint8Array(12),new Uint8Array([b>>24&255,b>>16&255,b>>8&255,b&255])));return a},bB=function(a){let b=Infinity,c=Infinity;QA(a).filter(SA).forEach(d=>{{d=d.S;var e=d[0].startTime;const f=d[d.length-1].endTime;d=e;e=f-e}b=Math.min(b,d);c=Math.min(c,e)});return{wc:b,duration:c}},
|
|
8
|
+
cB=function(a){return a.map(b=>{({duration:b}=bB(b));return b}).reduce((b,c)=>b+c,0)},dB=function(a,b,c){if(b===_.Xt)return{delay:0,Sc:0};b=NA(a,rA);if(c&&b)return c=Number(HA(b,"PART-TARGET")),{Ue:a}=XA(a,{Ze:!0}),{delay:a,Sc:c};a=NA(a,xA,{required:!0});a=Number(a.value);return{delay:3*a,Sc:a}},eB=function(a){const b=[];RA(a,c=>{b.push(c.Zf)});return{delay:Math.max(...b.map(c=>c.delay)),Sc:Math.min(...b.map(c=>c.Sc))}},fB=function(a){const b=new Map;a.forEach(c=>{var d=c.ca[0].groupId;b.has(d)?(d=
|
|
9
|
+
b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},gB=function(a){const b=new Map;for(const c of a){a=_.J(c,_.Ga);a=_.vg(a||_.Ae);const d=HA(c,_.Ba),e=HA(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},iB=function(a){a=a.audio.concat(a.video);for(const b of a)a=b.ca[0].codecs.split(",").filter(c=>"mp4a.40.34"!==c),hB(b,a)},mB=function(a,b,c){const d=[],e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=_.ih(a.a++,h),jB.includes(h.name)?d.push(h):kB.includes(h.name)?
|
|
10
|
+
"EXT-X-PART"===h.name?g.push(h):h.name===tA&&"PART"===_.J(h,"TYPE")&&g.push(h):f.push(h)):/^#(?!EXT)/m.test(h)||(h=PA(b,h.trim()),e.push(new lB(h,f,g)),f=[],g=[])});0<g.length&&e.push(new lB(null,f,g));return{S:e,$:d}},nB=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},oB=function(a,b=0){return b+10<=a.length&&73===a[b]&&68===a[b+1]&&51===a[b+2]&&255>a[b+3]&&255>a[b+4]&&128>a[b+6]&&128>a[b+7]&&128>a[b+8]&&128>a[b+9]?!0:!1},pB=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+
|
|
11
|
+
h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.H(_.G,4,4030);}oB(a)||d();let e=10;a[5]&64&&(e=e+4+c(a.subarray(10,14)));do{var f=c(a.subarray(e+4,e+8));1>f&&d();var g=String.fromCharCode(a[e],a[e+1],a[e+2],a[e+3]);if("PRIV"===g){g=a.subarray(e+10,e+f+10);for(let h=0;h<g.byteLength;h++)if(0===g[h]){if("com.apple.streaming.transportStreamTimestamp"===unescape(b(g,0,h)))return a=g.subarray(h+1),f=(a[3]&1)<<30|a[4]<<22|a[5]<<14|a[6]<<
|
|
12
|
+
6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}oB(a,e)||d();e+=10;e+=f}while(e<a.byteLength);return d()},qB=function(a,b){let c=null,d=0;try{(new _.Qj).L(_.yd,_.Jj).L(_.ye,_.Jj).L(_.td,_.Jj).Z("mdhd",g=>{g.reader.skip(0==g.version?8:16);d=_.P(g.reader);g.parser.stop()}).parse(b,!0)}catch(g){c=g}if(c||!d)throw _.aq.error("Unable to find timescale in init segment!"),new _.H(_.G,4,4030,jA,c);let e=0,f=!1;try{(new _.Qj).L("moof",_.Jj).L("traf",_.Jj).Z("tfdt",g=>{var h=d;if(0===g.version)h=_.P(g.reader)/
|
|
13
|
+
h;else{{const k=_.P(g.reader),l=_.P(g.reader);if(!(2097151>=k||h>=Math.pow(2,12)))throw Error("Cannot accurately parse MP4 timestamp, base time is too high and timescale is \x3c\x3d 2^12");h=k/h*Math.pow(2,32)+l/h}}e=h;f=!0;g.parser.stop()}).parse(a,!0)}catch(g){c=g}if(c||!f)throw new _.H(_.G,4,4030,jA,c);return e},rB=function(a){for(;a.getPosition()<a.Ba()-1;){const b=a.getPosition();if(71===_.Bj(a))return IA(a),b}return-1},sB=function(a){function b(){d.seek(e+188);f=_.Bj(d);71!=f&&(d.seek(e+192),
|
|
14
|
+
f=_.Bj(d));71!=f&&(d.seek(e+204),f=_.Bj(d));71!=f&&c();IA(d)}function c(){throw new _.H(_.G,4,4030);}const d=new _.wk(new DataView(a),!1);let e=0,f=0;e=rB(d);0>e&&(_.aq.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Bj(d);71!=f&&c();a=_.Cj(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Bj(d)&48)>>4;0!=a&&2!=a||c();3==a&&(a=_.Bj(d),d.skip(a));if(1!=_.P(d)>>8){b();continue}d.skip(3);a=_.Bj(d)>>6;0!=a&&1!=a||c();0==_.Bj(d)&&c();a=_.Bj(d);
|
|
15
|
+
const g=_.Cj(d),h=_.Cj(d);return(1073741824*((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},vB=function(a){const b=tB(a),c=uB(a);a.forEach(d=>{const e=d.S,f=e.findIndex(h=>h.xa===b);let g=e.findIndex(h=>h.xa===c+1);-1===g&&(g=e.length);d.S=e.slice(f,g)})},uB=function(a){a=a.map(b=>b.S[b.S.length-1].xa);return Math.min(...a)},tB=function(a){a=a.map(b=>b.S[0].xa);return Math.max(...a)},yB=function(a){var b=HA(a,AA);if(!wB.includes(b))return xB.error("PlayReady in HLS is only supported with [",wB.join(", "),
|
|
16
|
+
"], not",b),null;a=HA(a,_.lb);b=_.ao(a);a=null;b=_.K(b.data);try{a=_.qu(_.$u(b))}catch(c){a=b}return _.yu(_.Kc,[{initDataType:_.uc,initData:a}],"")},AB=function(a){if(0===a.length)return zB();if(a.some(c=>c.type===GA)||a.every(c=>c.type===_.Cd))return a[0];a=a.filter(c=>c.type===FA);const b=_.bg(a.flatMap(c=>c.drmInfos));return{keyInfo:null,keyId:a[a.length-1].keyId,type:FA,drmInfos:b}},DB=function(a){a=BB(a);if(a.some(b=>CB(b))&&1<a.length)throw new _.H(_.G,4,4046,"Two EXT-X-KEY tags, one with METHOD\x3dAES-128 are applied to one playlist.");
|
|
17
|
+
},CB=function(a){return KA(a.$,oA).some(b=>"AES-128"===_.J(b,AA))},FB=function(a,b,c){return BB(a).map(d=>EB(d.$,b,c))},GB=function(a){return a.filter(b=>MA(b.$,oA)).length},BB=function(a){return a.filter(b=>MA(b.$,oA))},EB=function(a,b,c){a=KA(a,oA);if(0===a.length)return null;var d=HA(a[0],AA);if(1===a.length){if("NONE"===d)return zB();if("AES-128"===d)return a=a[0],d=_.J(a,"IV",""),{type:GA,keyInfo:{method:"AES-128",url:PA(b,HA(a,_.lb)),iv:d?_.ah((d||"0x").slice(2)):null},drmInfos:[],keyId:null}}b=
|
|
18
|
+
a.map(e=>HA(e,AA));if(!b.every(e=>"SAMPLE-AES"===e)&&!b.every(e=>e===BA))throw HB.warn(`EXT-X-KEY methods ${b.join(", ")} are incompatible.`),new _.H(_.G,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");b=a.map(e=>{const f=_.J(e,"KEYFORMAT","identity");{const g=IB[f]||null;e=g?g(e,c):null}e||HB.warn("Unsupported HLS KEYFORMAT",f);return e}).filter(Boolean);if(0===b.length)throw new _.H(_.G,4,4026);return{keyInfo:null,keyId:b.map(e=>e.keyIds).reduce((e,f)=>e.concat(f),[]).reverse()[0]||
|
|
19
|
+
null,type:FA,drmInfos:b}},zB=function(){return{type:_.Cd,keyInfo:null,drmInfos:[],keyId:null}},JB=function(a,b,c){return _.y(function*(){const d=b.f(),e=_.mv(b.Ia(),b.ua,b.ua+2048-1,a.a.attemptParameters);e.type=2;const f=_.mv(b.Ia(),b.ua,b.ha,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.g(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.f.warn("Unable to fetch a partial HLS segment! Falling back to a full segment request, which is expensive! Your server should support Range requests and CORS pre-flights.",
|
|
20
|
+
e.uris[0]);try{return yield a.g(f)}catch(h){throw a.f.error("Failed to fetch media segment to parse its start timestamp.",f.uris[0],h),new _.H(_.G,4,4030,"Failed to fetch the media segment.");}}})},KB=function(a,b,c,d,e,f){return _.y(function*(){a.f.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.cc||d===_.bc)return 0;if(d===_.ac){var g=yield JB(a,c,f);const h=_.K(g.data);return oB(h)?pB(h):sB(g.data)}if(d===_.Ke||d===_.dc)return g=[JB(a,c,f)],b&&g.push(JB(a,b,!0)),g=yield Promise.all(g),
|
|
21
|
+
qB(g[0].data,(g[1]||g[0]).data);if(d===_.Je)return g=yield JB(a,c,f),sB(g.data);if(!_.Hu(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.H(_.G,4,4030);})},LB=function(a,b){a=a.map(c=>c.Eb(b));return a.some(c=>null==c)?null:a},hB=function(a,b){a.ca.forEach(c=>{c.codecs=b.join(",")})},MB=function(a,b){a=a.ca.find(c=>{c=c.S;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.S.find(c=>c.position===b)||null},NB=function(a,b){a.ca.forEach(c=>{c.pd=b})},OB=function(a,
|
|
22
|
+
b){a.ca.forEach(c=>{c.width=b})},PB=function(a,b){a.ca.forEach(c=>{c.height=b})},QB=function(a,b){a.ca.forEach(c=>{c.frameRate=b})},RB=function(a,b){a.ca.forEach(c=>{c.bandwidth=b})},SB=function(a,b){return a.ca.some(c=>c.id===b)},TB=function(a,b){a=a.map(c=>c.Eb(b));return a.some(c=>null==c)?null:a},YB=function(a,b,c,d){var e=a[0].length();e=nB(e).map(f=>{var g=TB(a,f)||[];const h=LB(b,f)||[];{f=LB(c,f)||[];const k=[...UB(g),...h,...f].filter(Boolean);VB(k);const {xa:l,duration:m}=k[0];g={variants:g,
|
|
23
|
+
textStreams:h,thumbStreams:f,startTime:0,id:`P${l}`,endTime:m,duration:m,xa:l}}return g});d&&WB(e[0]);XB(e);return e},$B=function(a){if(1===a.length)return a[0];const b=a[0],c=a.reduce((e,f)=>e+f.duration,0),d=new Map;a.forEach((e,f)=>{const g=QA(e);0<f&&ZB(g,e.startTime);g.forEach(h=>{const k=h.fc;d.has(k)?d.get(k).push(h):d.set(k,[h])})});RA(b,e=>{var f=d.get(e.fc);const g=f.flatMap(h=>h.S);f=f.map(h=>({keyInfo:h.keyInfo,type:h.Be,drmInfos:h.drmInfos,keyId:h.keyId}));f=AB(f);e.keyInfo=f.keyInfo;
|
|
24
|
+
e.Be=f.type;e.encrypted=f.type===FA;e.drmInfos=f.drmInfos;e.keyId=f.keyId;e.S=g;e.segmentIndex.replace(g)});return Object.assign({},b,{duration:c,endTime:a[0].startTime+c})},aC=function(a,b){a.forEach(c=>{c.startTime+=b;c.endTime+=b;c.sa-=b})},UB=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},WB=function(a){const b=UB(a.variants)[0].S[0].sa;a.startTime+=b;a.endTime+=b},XB=function(a){for(let b=0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:
|
|
25
|
+
c.startTime;c.endTime=c.startTime+c.duration}},ZB=function(a,b){a.forEach(c=>{const d=-c.wc+b;c.segmentIndex.offset(d);c.Qd+=d;c.wc=b})},VB=function(a){const b=bC(a);a.forEach(c=>{_.iv(c.segmentIndex,b);c.duration=b;c.Qd=c.wc+b})},bC=function(a){let b=Infinity;a.filter(SA).forEach(c=>{b=Math.min(b,c.duration)});return b},cC=function(a,b){return _.y(function*(){var c=_.nh([b],a.f.attemptParameters);c.type=1;c=yield a.C(c);let d="";try{d=_.Ig(c.data)}catch(e){throw new _.H(_.G,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,
|
|
26
|
+
"\n");d=d.trim();return{text:d,response:c}})},iC=function(a,b){return _.y(function*(){var c=dC(a,b,a.m,"");if(1===c.type){c=_.Lo(c.S[0].a)||"";c=null!=_.Ko.video[c]?_.w:null!=_.Ko.audio[c]?_.p:null;var d="";c===_.w?d="avc1.42E01E":c===_.p&&(d="mp4a.40.2");{c=a.J;var e=a.m;d=a.f.hlsDefaultCodecs||d;const l=[],m=[];m.push(new _.gh(_.ja,"0"));m.push(new _.gh(_.lb,e));d.length&&m.push(new _.gh(_.ka,d));l.push(new _.hh(c.a++,wA,m));c=new eC(e,0,l)}}d=c.$;c=KA(d,"EXT-X-MEDIA");e=KA(d,wA);d=KA(d,"EXT-X-IMAGE-STREAM-INF");
|
|
27
|
+
c={vc:{rf:LA(c,["AUDIO",_.rb]),closedCaptions:LA(c,iA),sg:LA(c,CA)},Tc:e,Hd:d};const {periods:f,hg:g}=yield fC(a,c);if(!a.D)throw new _.H(_.G,7,7001);e=eB(f[0]);c=gC(a,e.delay,f,g);if(!hC(a)){a.G=e.Sc;e=0;for(var h of a.g.values())e=Math.max(e,h.Eb(0).wc);for(h=0;95443.7176888889<=e;)h+=95443.7176888889,e-=95443.7176888889;if(h){a.a.debug("Offsetting live streams by",h,"to compensate for rollover");for(var k of a.g.values())e=k.Eb(0),95443.7176888889>e.wc?(a.a.debug("Offset applied to",e.type),e.segmentIndex.offset(h)):
|
|
28
|
+
a.a.debug("Offset NOT applied to",e.type)}}k=cB(f);"LIVE"===a.j||"EVENT"===a.j?(k=Math.max(k,c.F),isNaN(a.f.availabilityWindowOverride)||(k=a.f.availabilityWindowOverride),c.j=k):a.j===_.Xt&&(c.f=k);k={presentationTimeline:c,periods:f,offlineSessionIds:[],minBufferTime:0};a.a.debug("HLS playlist parsed",k);return k})},kC=function(a,b){return Promise.all(b.map(c=>jC(a,c)))},mC=function(a,b){b.forEach(c=>{a:{var d=a.g.get(c.a),e=!hC(a),f=NA(c.$,mA);if(f)var g=Number(f.value);else{d?(f=d.ca[d.ca.length-
|
|
29
|
+
1].S,f=f[f.length-1].xa):f=0;if(e&&0<f)try{{const k=NA(c.$,qA);if(!k)throw lC.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),Error(yA);const l=Number(k.value),m=MB(d,l);if(!m)throw lC.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(yA);var h=m.xa}g=h;break a}catch(k){throw new _.H(_.G,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");
|
|
30
|
+
}g=0}}c=c.S||[];for(const k of c)MA(k.$,lA)&&g++,k.xa=g});vB(b)},qC=function(a,b,c,d){return _.y(function*(){const e=b.Ka;var f=b.stream.Eb(0);if(1!==e.type)throw new _.H(_.G,4,4017);var g=yield nC(a,e,f.type,f.codecs);g=oC(a,e.a,g);f.S=g;f.segmentIndex.replace(g);_.qv(c,g,d);f=g[g.length-1];NA(e.$,nA)&&(pC(a,_.Xt),_.nv(c,!0),c.f=f.endTime+d)})},nC=function(a,b,c,d){return _.y(function*(){var e=b.a,f=b.S;var g=void 0===g?0:g;var h=(h=NA(b.$,qA))?Number(h.value):g;g=[];!hC(a)&&DB(f);e=yield rC(a,b.f,
|
|
31
|
+
e,f,h,c,d);if(0===f.length)f=[];else{var k=[],l=[];for(var m of f)MA(m.$,lA)&&0<l.length&&(k.push(l),l=[]),l.push(m);k.push(l);f=k}for(m=0;m<f.length;m++)k=f[m],l=yield sC(a,b.f,k,h,e,c,d,g[g.length-1]||null,f.length),g.push(l),h+=k.length;tC(g);return g})},oC=function(a,b,c){var d=c[0].S;a=uC(a,b,d[0].position);aC(d,a?a.startTime:0);for(d=1;d<c.length;d++)a=c[d-1].S,aC(c[d].S,a[a.length-1].endTime);return c.flatMap(e=>e.S)},pC=function(a,b){a.j=b;hC(a)&&a.h.stop()},dC=function(a,b,c,d){a:{a=a.J;
|
|
32
|
+
b=b.trim().split(/\n+/m);if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.H(_.G,4,4015);var e=b,f=0,g=!0;for(h of e){var h=h.trim();if(!h.length||/^#(?!EXT)/m.test(h)||g)g=!1;else if(e=_.ih(0,h),jB.includes(e.name)){f=1;break}else e.name===wA&&(g=!0)}h=f;f=[];g=!0;for(var k of _.Cu(b)){let {Fd:l,item:m,next:n}=k;m=m.trim();if(!m.length||/^#(?!EXT)/m.test(m)||g)g=!1;else{e=m;e=_.ih(a.a++,e);if(vC.includes(e.name)){if(1!==h)throw new _.H(_.G,4,4017);k=b.splice(l,b.length-l);a=mB(a,c,k);c=new eC(c,
|
|
33
|
+
h,f.concat(a.$),a.S);break a}f.push(e);e.name===wA&&(e.attributes.push(new _.gh(_.lb,n)),g=!0)}}c=new eC(c,h,f)}c.a=d;wC(c);return c},fC=function(a,b){return _.y(function*(){var c=gB(b.vc.closedCaptions),d=xC(a,b.Tc),e=yield yC(a,b),f=Object.values(e).flat().map(g=>g.Ka);mC(a,f);f=yield zC(a,e.te,d);c=yield AC(a,e.Tc,f,c);d=yield BC(a,e.rg,d);f=yield CC(a,e.Hd);e=DC(a,e);d=YB(c,d,f,!hC(a));!hC(a)&&(d=[$B(d)]);a.D.filterAllPeriods(d);return{periods:d,hg:e}})},gC=function(a,b,c,d){let e=!0,f=null,g=
|
|
34
|
+
0;hC(a)||(e=!1,f=0,g=b);const h=new _.Zz(f,g,!0);_.nv(h,e);RA(c,(k,l)=>{_.qv(h,k.S,l.startTime)});d&&(h.H={offsetDateTime:d-_.wv(h,0),seekRangeStartDateTime:d});return h},xC=function(a,b){const c=new Map;for(const f of b){var d=_.J(f,"AUDIO");b=_.J(f,_.rb);var e=_.J(f,CA);const g=EC(a,f);if(e){const h=_.Sh(_.u,g);c.set(e,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=FC(_.p,g),c.set(d,e));b&&(d=FC(_.w,g),c.set(b,d))}return c},yC=function(a,b){return _.y(function*(){const c=yield Promise.all([GC(a,b.vc.rf),
|
|
35
|
+
GC(a,b.vc.sg),GC(a,b.Tc),GC(a,b.Hd)]),[d,e,f,g]=c;return{te:d,rg:e,Tc:f,Hd:g}})},zC=function(a,b,c){return _.y(function*(){if(0===b.length)return new Map;var d=[HC(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>HC(a,e,c)));d=yield Promise.all(d);return fB(d)})},AC=function(a,b,c,d){return _.y(function*(){const e=new Set;var f=[...b];let g=0;var h=Infinity;for(let k=0;k<f.length;++k){const l=Number(HA(f[k].tag,_.ja));l<h&&(h=l,g=k)}h=f.splice(g,1).pop();h=yield IC(a,h,c,d,e);f=f.map(k=>IC(a,k,
|
|
36
|
+
c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.vu,[])})},BC=function(a,b,c){return Promise.all(b.map(d=>HC(a,d,c)))},CC=function(a,b){return Promise.all(b.map(c=>JC(a,c)))},DC=function(a,b){if(hC(a))return null;b=[...b.Tc,...b.te].map(d=>d.Ka).flatMap(d=>d.S[0].$);b=NA(b,uA);if(!b)return null;const c=(new Date(b.value)).getTime();return isNaN(c)?(a.a.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},hC=function(a){return a.j===_.Xt},GC=
|
|
37
|
+
function(a,b){return _.y(function*(){return(yield Promise.all(b.map(c=>_.y(function*(){const d=yield KC(a,c);return d?{tag:c,Ka:d}:null})))).filter(Boolean)})},jC=function(a,b){return _.y(function*(){var c=new _.ig(b.ca[0].pd);if(a.f.hlsLowLatency){var d=c.a;if(b.ca[0].Wc){var e=b.ca[b.ca.length-1].segmentIndex;if(e=e.a[e.a.length-1]){var f=e.a,g=f.length-1;e={$f:e.position,Ve:f&&0<f.length?g:null}}else e=null;e&&(d.add("_HLS_msn",e.$f),null!==e.Ve&&d.add("_HLS_part",e.Ve))}e=d;_.tg(e);e.g&&_.lg(c,
|
|
38
|
+
d)}const {response:h,text:k}=yield cC(a,c.toString());c=b.ca[0].fc;d=b.ca[0].pd;e=h.uri;d!==e&&(d=e,NB(b,d));c=dC(a,k,d,c);return{stream:b,Ka:c}})},EC=function(a,b){var c=_.J(b,_.ka,a.f.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);b=new Set;const d=[];for(const e of c)c=_.Nu(e)[0],b.has(c)?a.a.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},FC=function(a,b){if(1===b.length)return b[0];a=_.Sh(a,b);if(null!=a)return a;throw new _.H(_.G,4,4025,{codecList:b});},HC=function(a,
|
|
39
|
+
b,c){return _.y(function*(){const d=b.tag,e=b.Ka;return LC(a,e.a,()=>_.y(function*(){const f=HA(d,_.Ba);var g={AUDIO:_.p,VIDEO:_.w,SUBTITLES:_.u,"CLOSED-CAPTIONS":_.u}[HA(d,"TYPE").toUpperCase()];if(!g)throw new _.H(_.G,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");const h=c.get(f)||"",k=_.J(d,_.Ga),l=_.J(d,"NAME"),m=d.getAttribute("DEFAULT"),n=d.getAttribute("AUTOSELECT"),q=_.J(d,"CHANNELS");return yield MC(a,{Ka:e,codecs:h,type:g,Jc:k,primary:!!m&&!!n,name:l,channelsCount:g===_.p?q?parseInt(q.split("/")[0],
|
|
40
|
+
10):null:null,groupId:f,closedCaptions:null,ne:null})}))})},JC=function(a,b){return _.y(function*(){const c=b.tag,d=b.Ka;return LC(a,d.a,()=>_.y(function*(){var e=_.J(c,_.ka)||"jpg",f=_.J(c,_.Ga);const g=_.J(c,"NAME");e=yield MC(a,{Ka:d,codecs:e,type:_.fd,Jc:f,name:g,primary:!1,channelsCount:null,closedCaptions:null,groupId:null,ne:null});(f=_.J(c,_.ja))&&RB(e,Number(f));return e}))})},IC=function(a,b,c,d,e){return _.y(function*(){var f=b.tag,g=Number(HA(f,_.ja));if(null!=f.getAttribute("FRAME-RATE")||
|
|
41
|
+
null!=f.getAttribute(_.Za)){var h=_.J(f,"FRAME-RATE");f=_.J(f,_.Za);var [k,l]=f?f.split("x"):[null,null];h={frameRate:JA(h),width:JA(k),height:JA(l)}}else h=null;if(f=yield NC(a,b,h,c,d)){h=f.video;f=f.audio;var m=0<f.length?f:[null];h=0<h.length?h:[null];f=[];for(const I of m)for(const na of h)if(m=(na?na.ca[0].fc:"")+" - "+(I?I.ca[0].fc:""),e.has(m))a.a.debug("Skipping variant which only differs in text streams.");else{a:{var n=a;var q=I,t=na,v=g;const hc=[],jd=(t||q).length();for(let Ob=0;Ob<jd;Ob++){var x=
|
|
42
|
+
q?q.Eb(Ob)||null:null,A=t?t.Eb(Ob)||null:null,D=x,E=A;D=D&&E?_.Fu(D.drmInfos,E.drmInfos)?_.Eu(D.drmInfos,E.drmInfos):null:D?D.drmInfos:E?E.drmInfos:null;if(!D){n=null;break a}E=v;x={id:n.H++,language:x?x.language:_.Ae,primary:!!x&&x.primary||!!A&&A.primary,audio:x,video:A,bandwidth:E,drmInfos:D,allowedByApplication:!0,allowedByKeySystem:!0};hc.push(x)}n=new OC(hc)}null==n?a.a.warn("Incompatible DRM info in HLS variant. Skipping."):(f.push(n),e.add(m))}g=f}else g=[];return g})},uC=function(a,b,c){return(a=
|
|
43
|
+
a.g.get(b))?MB(a,c)||null:null},NC=function(a,b,c,d,e){return _.y(function*(){var f=b.tag,g=b.Ka;let h=EC(a,f);var k=_.J(f,"AUDIO"),l=_.J(f,_.rb),m=k||l;m=m&&d.has(m)?d.get(m):[];k={audio:k?m:[],video:l?m:[]};a.a.debug("Guessing stream type for",f.toString());f=!1;const n=g.a;g=k.audio.find(q=>q.fc===n);l=_.Sh(_.w,h);l=c||l;1!==h.length||l?!m.length&&1<h.length?(a.a.debug("Guessing multiplexed audio+video"),g=_.w,h=[h.join(",")]):k.audio.length&&g?(a.a.debug(zA),g=_.p,f=!0):k.video.length?(a.a.debug(zA),
|
|
44
|
+
g=_.p):(a.a.debug("Guessing video-only"),g=_.w):(g=_.p,a.a.debug(zA));l=null;f||(l=yield PC(a,b,h,g,e,c));if(null==l)return null;k[g]=[l];g===_.p&&c&&m.forEach(q=>{OB(q,c.width);PB(q,c.height);QB(q,c.frameRate)});iB(k);return k})},PC=function(a,b,c,d,e,f){return _.y(function*(){const g=b.tag,h=b.Ka;return LC(a,h.a,()=>_.y(function*(){var k=_.J(g,iA);let l=null;d===_.w&&k&&"NONE"!==k&&(l=e.get(k));k=FC(d,c);return yield MC(a,{Ka:h,codecs:k,type:d,closedCaptions:l,primary:!1,Jc:null,name:null,channelsCount:null,
|
|
45
|
+
groupId:null,ne:f})}))})},LC=function(a,b,c){if(a.g.has(b))return a=a.g.get(b),Promise.resolve(a);if(a.g.a.has(b))return a.g.a.get(b)||null;c=c();a.g.set(b,c);return c},MC=function(a,b){return _.y(function*(){const c=b.Ka,d=b.codecs,e=b.type,f=b.Jc,g=b.groupId,h=b.primary,k=b.name,l=b.channelsCount,m=b.closedCaptions,n=b.ne,q=_.vg(f||_.Ae);if(1!==c.type)throw new _.H(_.G,4,4017);var t=TA(c.$);pC(a,t);const v=dB(c.$,t,a.f.hlsLowLatency||!1);t=yield nC(a,c,e,d);const x=a.f.hlsLowLatency?_.$x:_.du;let A=
|
|
46
|
+
void 0;e===_.u&&(A=_.lu);const {Wc:D}=XA(c.$);t=t.map(E=>{const I=E.S,na=E.Bf,hc=E.mimeType;E=E.xa;const jd=I[0].startTime,Ob=I[I.length-1].endTime,Ta=Ob-jd,sb=new _.$z(I),ic=I[0].initSegment||null;return{id:a.H++,originalId:k,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:sb.f.bind(sb),getSegmentReference:sb.get.bind(sb),adjustSegmentDurations:sb.g.bind(sb),getDuration:sb.getDuration.bind(sb),segmentIndex:sb,segmentLookupStrategy:x,initSegmentReference:ic,mimeType:hc,codecs:d,
|
|
47
|
+
kind:A,Be:na.type,encrypted:na.type===FA,keyId:na.keyId,language:q,originalLanguage:f||_.Ae,label:k,type:e,primary:h,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:n?n.frameRate:void 0,width:n?n.width:void 0,height:n?n.height:void 0,bandwidth:void 0,roles:[],channelsCount:l,closedCaptions:m,keyInfo:na.keyInfo,S:I,drmInfos:na.drmInfos,xa:E,fc:c.a,pd:c.f,wc:jd,Qd:Ob,duration:Ta,Wc:D,groupId:g,Zf:v}});return new QC(t)})},KC=function(a,b){return _.y(function*(){var c="EXT-X-MEDIA"!==b.name?!0:_.J(b,
|
|
48
|
+
"TYPE")===CA;c=_.J(b,_.lb,void 0,{required:c});if(!c)return null;const d=PA(a.m,c),{response:e,text:f}=yield cC(a,d);return dC(a,f,e.uri,c)})},wC=function(a){1===a.type&&a.S.forEach((b,c)=>{if(MA(b.$,pA)&&!MA(b.$,lA)&&0<c)throw new _.H(_.G,4,4046,"Media playlist contains an EXT-X-MAP tag not accompanied by an EXT-X-DISCONTINUITY tag.");})},tC=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.H(_.G,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");
|
|
49
|
+
},RC=function(a){a=a.map(b=>b.a?b.a:b.f.map(c=>_.J(c,_.lb))||null).map(b=>_.Lo(b));if(1<(new Set(a)).size)throw new _.H(_.G,4,4044,"Unexpected change in file format.");},SC=function(a,b,c){a=KA(a.$,pA);if(1<a.length)throw new _.H(_.G,4,4020);a=a[0];if(!a)return null;const d=HA(a,_.lb),e=PA(b,d);b=YA(a,null,!0);return new _.Wz(()=>[e],b.ua,b.ha,c)},TC=function(a,b,c,d,e,f,g){const h=[];for(const q of _.Cu(b.f)){b=q.Fd;const t=q.item;{var k=0===b,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.J(t,"DURATION"));
|
|
50
|
+
n=m+n;k=YA(t,k?null:l.ha,k);l=_.J(t,_.lb);const v=(l=PA(g,l))?[l]:[];m=new ZA(c,m,n,()=>v,k.ua,k.ha,e,f,!1,null,null,null,null);if("YES"===_.J(t,"INDEPENDENT")||0===b)m.g=!0;h.push(m)}}return h},UC=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.$;var q=c.a;const t=null!=q,v=q?[q]:[];if(!t&&!a.f.hlsLowLatency)return null;a=0;q={ua:0,ha:null};let x=null;t?({duration:c}=WA(n),a=e+c,q=VA(n,b?b.ha:null)):(b=TC(b,c,d,e,f,g,k),a=b[b.length-1].endTime,x=b);h=h===_.fd?OA(n):null;d=new ZA(d,e,a,()=>v,q.ua,q.ha,
|
|
51
|
+
f,g,!1,null,h?h.Ge:null,h?h.hf:null,h?h.durationPerTile:null,x);d.xa=l;d.initSegment=m||void 0;return d},rC=function(a,b,c,d,e,f,g){return _.y(function*(){var h=d[0];if(null!=a.w)return a.w;if(!hC(a)&&a.B){h=uC(a,c,e);if(!h)throw new _.H(_.G,4,4030,"Segment not found in pervious playlist update.");h=h.startTime+h.sa;a.a.debug(`Setting playlist start time to ${h}.`);return a.w=h}const k=yield VC(a,f,g,h);var l=EB(h.$,a.m,k)||zB();const m=SC(h,b,l.keyInfo);l=aB(l.keyInfo,e);h=yield WC(a,m,h,l,k,g);
|
|
52
|
+
a.a.debug(`Setting playlist start time to ${h}.`);return a.w=h})},sC=function(a,b,c,d,e,f,g,h,k){return _.y(function*(){var l=c[0],m=null==h;RC(c);const n=yield VC(a,f,g,l);var q=a.m,t=h?h.Yf:null;var v=1===k;if(c.slice(1).some(CB))throw new _.H(_.G,4,4046,v?"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not at the beginning of the playlist.":"Media playlist contains an EXT-X-KEY tag with METHOD\x3dAES-128 which is not marked by an EXT-X-DISCONTINUITY tag and is not at the beginning of the playlist.");
|
|
53
|
+
if(MA(c[0].$,oA)||null===t)if((t=EB(c[0].$,q,n))&&t.type===GA){if(1<GB(c))throw new _.H(_.G,4,4046,DA+`${v?"playlist":"discontinuity"}.`);v=[t]}else v=FB(c,q,n),v=0===v.length?[zB()]:v;else if(q=FB(c,q,n),t.type===_.Cd||t.type===FA)v=[t,...q];else{if(0<GB(c))throw new _.H(_.G,4,4046,DA+`${v?"playlist":"discontinuity"}.`);v=[t]}q=v;v=q[q.length-1];q=AB(q);t=SC(l,b,q.keyInfo)||(h?h.Uf:null);var x=aB(q.keyInfo,d);const A=l.xa;l=m?e:yield XC(a,A,t,l,d,x,n,g);m=[];for(x=0;x<c.length;x++){var D=c[x];const E=
|
|
54
|
+
m[m.length-1]||null,I=0===x?0:E.endTime,na=d+x,hc=aB(q.keyInfo,na);(D=UC(a,E,D,na,I,l,hc,f,b,A,t))&&m.push(D)}return{S:m,Bf:q,Yf:v,mimeType:n,endTime:m[m.length-1].endTime,xa:A,Uf:t}})},VC=function(a,b,c,d){return _.y(function*(){const e=d.a;var f=NA(d.$,pA);f=f?HA(f,_.lb):null;return YC(a,b,c,e,f)})},WC=function(a,b,c,d,e,f){return _.y(function*(){if(null==c.a)return 0;const g=$A(c,d);return KB(a.K,b,g,e,f,null!=d)})},XC=function(a,b,c,d,e,f,g,h){return _.y(function*(){if(a.F.has(b))return a.F.get(b);
|
|
55
|
+
const k=yield WC(a,c,d,f,g,h);a.a.debug(`Segment #${e} has raw media timestamp `+`${k} s.`);a.F.set(b,k);return k})},YC=function(a,b,c,d,e){return _.y(function*(){const f=[d,e].filter(Boolean);var g=_.Vh(f,b,c);if(g)return g;g=_.nh([d],a.f.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.C(g)).headers["content-type"];if(!g)throw new _.H(_.G,4,4021,"Unknown MIME type of: "+f.join(", "));return g.split(";")[0]})},eC=class{constructor(a,b,c,d){if(1===b){if(!d||0===d.length)throw new _.H(_.G,4,
|
|
56
|
+
4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.H(_.G,4,4043,"Media playlist must have at least one full segment!");}this.f=a;this.a="";this.type=b;this.$=c;this.S=1===b?d:null}},lB=class{constructor(a,b,c){c=void 0===c?[]:c;this.$=b;this.a=a;this.f=c;this.xa=-1}},ZA=class extends _.Av{constructor(a,b,c,d,e,f,g,h,k,l,m,n,q,t){t=void 0===t?[]:t;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===q?null:
|
|
57
|
+
q,t);this.initSegment=void 0;this.xa=0}},jB=[mA,nA,"EXT-X-I-FRAMES-ONLY",qA,rA,sA,vA,xA],vC=["EXTINF",kA,"EXT-X-DATERANGE",lA,oA,pA,uA],kB=["EXT-X-PART",tA],ZC=class{constructor(){this.a=0}},$C=class{constructor(){this.f=new Map;this.a=new Map}set(a,b){this.a.set(a,b);return b.then(c=>this.f.set(a,c)).catch(()=>{}).then(()=>this.a.delete(a))}has(a){return this.f.has(a)}get(a){return this.f.get(a)||null}values(){return Array.from(this.f.values())}clear(){this.a.clear();this.f.clear()}},lC=new _.Q("clpp.hls.DiscontinuityUtils");var IB={"com.apple.streamingkeydelivery":function(a,b){if(b===_.Je)throw new _.H(_.G,4,4041);if(HA(a,AA)===BA)throw new _.H(_.G,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.yu(_.Jc,[{initDataType:_.je,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":yB,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":yB,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=HA(a,AA);if(!wB.includes(b))return xB.error("Widevine in HLS is only supported with [",
|
|
58
|
+
wB.join(", "),"], not",b),null;b=HA(a,_.lb);b=_.ao(b);b=_.K(b.data);b=_.yu(_.Lc,[{initDataType:_.uc,initData:b}],"");if(a=_.J(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},wB=["SAMPLE-AES",BA],xB=new _.Q("clpp.hls.DrmParser");var HB=new _.Q("clpp.hls.EncryptionUtils");var aD=class{constructor(a){this.f=new _.Q("clpp.hls.MediaReader");this.g=a;this.a={attemptParameters:_.kh()}}};var QC=class{constructor(a){this.ca=a}length(){return this.ca.length}Eb(a){return this.ca[a]}};var OC=class{constructor(a){this.a=a}length(){return this.a.length}Eb(a){return this.a[a]}};var bD=class{constructor(){this.f=this.D=null;this.H=1;this.g=new $C;this.m="";this.J=new ZC;this.G=0;this.A=new Map;this.h=new _.ci(()=>{this.yb()});this.j=_.Xt;this.B=null;this.o=new _.Oo;this.w=null;this.a=new _.Q("clpp.hls.HlsParser");this.F=new Map;this.K=new aD(this.C.bind(this));this.I=!1}configure(a){this.f=a;this.K.a=a}setCurrentVariant(a){const b=a.video?a.video.id:null;a=a.audio?a.audio.id:null;this.A.clear();for(const c of this.g.values())(null!=b&&SB(c,b)||null!=a&&SB(c,a))&&this.A.set(c.ca[0].fc,
|
|
59
|
+
c)}start(a,b){const c=this;return _.y(function*(){if(c.I)throw Error("start() may be called only once!");c.I=!0;c.D=b;const {response:d,text:e}=yield cC(c,a);c.m=d.uri;const f=yield iC(c,e);c.B=f;const g=c.G;0<g&&c.h.da(g);return f})}stop(){this.h&&(this.h.stop(),this.h=null);const a=[];this.o&&(a.push(this.o.destroy()),this.o=null);this.g.clear();this.A.clear();this.B=this.f=this.D=null;return Promise.all(a)}onExpirationUpdated(){}update(){const a=this;return _.y(function*(){var b=a.B;if(!hC(a)&&
|
|
60
|
+
b){var c=b.presentationTimeline;b=b.periods[0].startTime;var d=[];"LIVE"===a.j&&(a.w=null);var e=Array.from(a.A.values());e=a.f.hlsLowLatency&&0<e.length?e:Array.from(a.g.values());e=yield kC(a,e);var f=e.map(g=>g.Ka);mC(a,f);yield qC(a,e[0],c,b);for(f=1;f<e.length;f++)d.push(qC(a,e[f],c,b));yield Promise.all(d)}})}yb(){const a=this;return _.y(function*(){a.a.debug(_.Wt);if(a.D)try{yield a.update(),a.h.da(a.G)}catch(b){a.D&&(a.D.onError(b),1===b.severity&&a.h.da(.1))}})}C(a){if(!this.o)throw new _.H(_.G,
|
|
61
|
+
7,7001);a=this.D.networkingEngine.fetch(a);_.uh(this.o,a);return a.P}};_.z("clpp.hls.HlsComponent",class extends _.Fp{constructor(){super()}f(){_.Fn.m3u8=bD;_.Dn[_.Zi]=bD;_.Dn[EA]=bD}a(){_.Hv("m3u8");_.Iv(_.Zi);_.Iv(EA)}id(){return"hls"}});};f.call(g, window);
|
package/cl.hlssmpte.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
else a.f.warn("A video element is not available. Skipping.")},
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var sK=function(a){a.a.one(a.l,_.pd,()=>rK(a))},rK=function(a){const b=a.l.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.Mb,d=>tK(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.vd).forEach(d=>{tK(a,{track:d})});!uK(c)&&a.m&&(a.f.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),vK(a,b))}else a.f.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
|
|
2
|
+
else a.f.warn("A video element is not available. Skipping.")},tK=function(a,b){b=b.track;b.kind===_.vd&&(a.f.info("The metadata track has been added."),b.mode=_.ed,a.a.on(b,_.Oc,c=>wK(a,c)))},uK=function(a){return a.some(b=>b.kind===_.vd)},vK=function(a,b){const c=a.l.getTrackManager(),d=c.na(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.ta(d);a.a.on(b.textTracks,_.Mb,g=>{g.track.kind===_.vd&&(a.a.off(b.textTracks,_.Mb,f),c.ta(d))});c.ta(e)}else a.f.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
|
|
3
|
+
wK=function(a,b){const c=xK(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.g&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new yK(d);if(e.f===c&&null!==e.a){a.g=d;d=a.h.parseMedia(_.Mg(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.l.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},xK=function(a){return(a=a.l.getTrackManager().oa())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
yK=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.B(a)){a:{var b=a.info;if(_.qf(b)&&(b=b.toLowerCase().match(/lang:(\w+)/))&&b[1]){b=b[1].toLowerCase();break a}b=null}this.f=b;a=a.data;this.a=a=_.qf(a)?a:null}}};var zK=class{constructor(a,b,c){this.l=a;this.m=b;this.j=c;this.a=new _.po;this.h=(a=_.co[_.Yb]||null)?new a(this.l.getConfiguration()):null;this.f=new _.Q("clpp.hlssmpte.ImageCueHandler");this.g=null;sK(this)}destroy(){this.a.release();this.g=null;return Promise.resolve()}};var AK=class extends _.fq{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.qi()){var b=a.getConfiguration();b=_.lf(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.jc&&(b.patchMetadataTrack=!1);_.rf(b.timestampOffset)||(b.timestampOffset=0);this.a=new zK(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.y(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.z("clpp.hlssmpte.HlsSmptePlugin",AK);
|
|
5
|
+
AK.Id="hlssmpte";_.Nm(new class{create(){return new AK}});};f.call(g, window);
|
package/cl.htmlcue.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
function(a,b){
|
|
3
|
-
0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new
|
|
4
|
-
b.h)&&
|
|
5
|
-
case _.
|
|
6
|
-
case _.
|
|
7
|
-
["+y","-y"];break;case _.
|
|
8
|
-
f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);
|
|
9
|
-
a)},
|
|
10
|
-
d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},
|
|
11
|
-
backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.
|
|
12
|
-
else{
|
|
13
|
-
c;for(;0<=d-1&&
|
|
14
|
-
a)}px`},
|
|
15
|
-
d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this;return _.y(function*(){null!=a.h&&(
|
|
25
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var iJ="Unsupported unit",jJ="clpp-text-plain",kJ="clpp-text-ttml",lJ="clpp.htmlcue.HtmlTextDisplayer",mJ="initial",nJ=function(a){return _.bg(a,{ze:(b,c)=>b.bd(c)})},oJ=function(a,b){if(0===b.length)return a;let c=a;a=a.findIndex(d=>d.startTime>=b[0].startTime);0<=a&&(c=c.slice(0,a));return c.concat(b)},pJ=function(a,b){let c=0,d=a.length-1;for(;c<=d;){const e=c+d>>1,f=b(a[e]);if(0===f)return e;0<f?c=e+1:d=e-1}return-1},qJ=function(a){if(!a.input)return null;var b=a.input.match(/^([^<]*)(<[^>]+>?)?/);
|
|
2
|
+
b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},sJ=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>rJ[c]);return a},uJ=function(a,b){tJ(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{tJ(a,c)})},tJ=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},vJ=function(a,b){return 0===a?"0":a+b},wJ=function(a,b){return 1>Math.abs(a-b)||a<b},xJ=function(a,b){return a<b&&1<Math.abs(a-b)},yJ=function(a,b){return a>b&&1<Math.abs(a-b)},zJ=
|
|
3
|
+
function(a,b){return 1>Math.abs(a-b)||a>b},BJ=function(a){const b=a.getBoundingClientRect();var c=getComputedStyle(a,null);const d=parseFloat(c.getPropertyValue("border-left-width"))||0,e=parseFloat(c.getPropertyValue("border-right-width"))||0;var f=parseFloat(c.getPropertyValue("border-top-width"))||0;c=parseFloat(c.getPropertyValue("border-bottom-width"))||0;const g=(b.top||a.offsetTop)+f;f=(b.height||a.offsetHeight)-f-c;return new AJ(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
|
|
4
|
+
d-e)},CJ=function(a){return new AJ(a.f,a.g,a.h,a.a,a.height,a.width)},DJ=function(a,b){return b.some(c=>xJ(a.f,c.g)&&yJ(a.g,c.f)&&xJ(a.h,c.a)&&yJ(a.a,c.h))},EJ=function(a,b){return zJ(a.h,b.h)&&wJ(a.a,b.a)&&zJ(a.f,b.f)&&wJ(a.g,b.g)},FJ=function(a,b,c){switch(c){case "+x":return xJ(a.f,b.f);case "-x":return yJ(a.g,b.g);case "+y":return xJ(a.h,b.h);case "-y":return yJ(a.a,b.a);default:throw Error("Unknown axis");}},GJ=function(a){return a.f.writingMode===_.to},HJ=function(a){var b=a.a.childNodes[0],
|
|
5
|
+
c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return GJ(a)?b:c},IJ=function(a){switch(a.f.writingMode){case _.to:return"horizontal-tb";case _.He:return _.He;case _.Ie:return _.Ie;default:throw Error("Unknown writing mode");}},JJ=function(a){switch(a.f.positionAlign){case _.nd:return _.id;case "auto":case _.vc:return _.so;case _.od:return _.fe}return a.f.textAlign},KJ=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===_.r)switch(b){case _.nd:return a.f.position;
|
|
6
|
+
case "auto":case _.vc:return a.f.position-a.f.size/2;case _.od:return a.f.position-a.f.size}return 0},LJ=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.id:case _.id:return _.nd;case _.so:return _.vc;case _.fe:case _.fe:return _.od}return a.f.positionAlign},OJ=function(a,b,c){return(MJ(a)||NJ(a))&&_.rf(c)?vJ(c,_.Zd):MJ(a)&&_.B(c)?vJ(0,_.Zd):GJ(a)&&_.rf(b)?vJ(b,"%"):mJ},PJ=function(a,b,c){return GJ(a)&&_.rf(c)?vJ(c,_.Zd):(MJ(a)||NJ(a))&&_.rf(b)?vJ(b,"%"):mJ},NJ=function(a){return a.f.writingMode===
|
|
7
|
+
_.Ie},MJ=function(a){return a.f.writingMode===_.He},QJ=function(a,b){if(a.h)switch(b.writingMode){case _.to:return["-y"];case _.He:return["+x"];case _.Ie:return["-x"]}a=[];switch(b.writingMode){case _.to:a=["+y","-y"];break;case _.He:a=["+x","-x"];break;case _.Ie:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},RJ=function(a){for(a.g=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=BJ(a.j.a)},SJ=function(a,b){RJ(a.g);a.j.unshift(b);for(const c of a.j)a.g.append(c)},TJ=function(a,
|
|
8
|
+
b,c){a=a.f;const d=a.viewportAnchorUnits;if(d===_.Ao)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(iJ);},VJ=function(a,b,c,d){const e=document.createElement(_.re),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);UJ(a,c,b);a.f.debug(`Created HTML style element #${b}.`);return e.sheet},WJ=function(a,b){a=`.${a.j} .clpp-text-container`;const c=`${a} .clpp-text-cue`;return b=b.replace(/::cue\((#[^)]+)\)/g,
|
|
9
|
+
`${a} $1`).replace(/::cue\(([^)]+)\)/g,`${c} $1`).replace(/::cue-region\(([^)]+)\)/g,`${a} $1 .clpp-text-cue`).replace(/::cue/g,c).replace(/::cue-region/g,`${a} .clpp-text-cue-region .clpp-text-cue`).replace(/::ttml/g,a)},XJ=function(a,b){let c=!1;try{a.g.insertRule(b,0);const d=a.g.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.g.cssRules.length&&a.g.deleteRule(0);return c},YJ=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
|
|
10
|
+
a.m=[]}},UJ=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.f.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.o.push(()=>d.disconnect())},ZJ=function(a){a=_.lf(a.getConfiguration().htmlcue||{});_.B(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.B(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},eK=function(a,b){if((b||a.j)&&
|
|
11
|
+
a.C){var c=a.l.getPosition();if(b||a.I!==c&&a.l.getState()===_.Nl)if(a.I=c,c=$J(a,c),b||(b=a.m,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.m=c,aK(a),c)){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.jo(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;var d=k,e=b,f=c.a.a,g=null;switch(d.payloadType){case _.Pe:g="clpp-text-vtt";break;case _.ze:g=kJ;break;case _.ro:g=
|
|
12
|
+
jJ}g&&!f.classList.contains(g)&&_.hm(f,g);f=BJ(c.a.a);if(0===f.width||0===f.height)c.M.warn("The height or width of the `.clpp-text-container` element is zero. Captions will not be displayed. Please check if the `clpp.styles.css` file has been included.");else{tJ({fontSize:bK(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.Pe;var h=d.payloadType===_.ze;d.region&&(g||h||d.backgroundImage)&&(c.A.has(d.region.id)?f=c.A.get(d.region.id):(f=new cK(d.region,{}),c.A.set(d.region.id,f),SJ(c.a,f)));
|
|
13
|
+
d=new dK(d,c.K,e);f?SJ(f,d):SJ(c.a,d)}}}}},fK=function(a){aK(a);a.I=null;a.m=null;a.f=[]},gK=function(a,b){return a.startTime<=b&&a.endTime>b},$J=function(a,b){var c=pJ(a.f,d=>gK(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&gK(a.f[d-1],b);)d--;for(;c+1<a.f.length&&gK(a.f[c+1],b);)c++;return{start:d,end:c}}},aK=function(a){a.A.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(kJ);b.classList.remove(jJ);a=a.a;RJ(a.g);
|
|
14
|
+
a.j=[]}},bK=function(a,b){const c=BJ(a.a.a).height;if(null!==a.H)return a.getFontSize();if(null!==a.B)return a=a.getFontSizePercent(),`${Math.round(c*a)}px`;if(typeof b===_.r&&0<b)return`${Math.round(c/b)}px`;a=a.getFontSizePercent();return`${Math.round(c*a)}px`},kK=class{parse(a){a={input:a};const b=_.jm(_.Rc),c=[];let d=b;for(var e;null!==(e=qJ(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=
|
|
15
|
+
e[1];var g=e[3];var h=hK[f];h?(h=_.jm(h),(f=iK[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||jK[g.localName]&&jK[g.localName]!==d.localName||(e[2]&&(g.className=e[2].substr(1).replace(/\./g," ")),c.push(e[1]),d.appendChild(g),d=g)}}else d.appendChild(document.createTextNode(sJ(e)));return b}},hK={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},iK={v:"voice",lang:"lang"},jK={rt:"ruby"},rJ={"\x26amp;":"\x26","\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f",
|
|
16
|
+
"\x26nbsp;":"\u00a0"};var AJ=class{constructor(a,b,c,d,e,f){this.f=a;this.g=b;this.h=c;this.a=d;this.height=e;this.width=f}};var lK=class{constructor(a,b,c){this.id=a;this.o=b;this.A=c;this.a=this.m();this.h=!1}init(){this.h=!0}w(){return!1}};var dK=class extends lK{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.j=b;this.f=a;this.g=!!this.f.backgroundImage;this.B=c}w(){return!this.g&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.g)_.hm(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.j.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.ze){var c=_.jm(_.Rc);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
17
|
+
_.Pe?b=(new kK).parse(b.payload):(c=_.jm(_.Rc),c.textContent=b.payload,b=c);_.hm(b,this.o);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.hm(b,d);tJ({writingMode:IJ(this)},b);var d=b;this.a.appendChild(d);_.hm(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.hm(this.a,`clpp-text-wrapper__${e}`);_.B(this.f.line)&&(this.f.lineInterpretation=_.uo,this.f.line=GJ(this)?-1:0);e=IJ(this);tJ({writingMode:e,webkitWritingMode:e,direction:mJ,textAlign:JJ(this)},this.a);if(!this.f.region||
|
|
18
|
+
!this.f.region.displayAlign){e=KJ(this,LJ(this));tJ({position:"absolute",left:OJ(this,e,null),right:NJ(this)&&_.B(null)?vJ(0,_.Zd):mJ,top:PJ(this,e,null),width:GJ(this)?vJ(this.f.size,"%"):mJ,height:MJ(this)||NJ(this)?vJ(this.f.size,"%"):mJ},this.a);b=this.f;a=GJ(this)?a.height:a.width;c=HJ(this);if(b.lineInterpretation===_.uo){var f=c*Math.round(b.line);Math.abs(f)>a&&(f=c*(0>b.line?0:-1));0>f&&(f+=a)}else{f=c/a*100;let g=b.line;switch(b.lineAlign){case _.vc:g-=f/2;break;case _.Zc:g-=f}f=Math.round(g/
|
|
19
|
+
100*a)}NJ(this)&&(f=a-f-c);a=f;tJ({left:OJ(this,e,a),right:NJ(this)&&_.B(a)?vJ(0,_.Zd):mJ,top:PJ(this,e,a)},this.a)}uJ(this.B,d)}}m(){return _.jm(_.Rc)}};var mK=class{constructor(a,b){this.j=a;this.f=a.a;this.h=void 0===b?!1:b;this.a=BJ(a.a);this.g=[]}append(a){const b=a.a;b.style.visibility=_.ed;this.f.appendChild(b);a.h||a.init(this.a);if(a.w()){a:{var c=BJ(a.a);var d=QJ(this,a.f),e=HJ(a);const g=CJ(c);let h=null,k=0;for(const l of d){for(;FJ(c,this.a,l)||EJ(c,this.a)&&DJ(c,this.g);){d=c;var f=e;switch(l){case "+x":d.f+=f;d.g+=f;break;case "-x":d.f-=f;d.g-=f;break;case "+y":d.h+=f;d.a+=f;break;case "-y":d.h-=f,d.a-=f}}if(this.h||EJ(c,this.a))break a;
|
|
20
|
+
d=this.a;d=Math.max(0,Math.min(c.g,d.g)-Math.max(c.f,d.f))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.h,d.h))/(c.height*c.width);d>k&&(h=CJ(c),k=d);c=CJ(g)}c=h||g}tJ({top:vJ(c.h-this.a.h,_.Zd),bottom:vJ(this.a.a-c.a,_.Zd),left:vJ(c.f-this.a.f,_.Zd),right:vJ(this.a.g-c.g,_.Zd),height:vJ(c.height,_.Zd),width:vJ(c.width,_.Zd)},a.a)}b.style.visibility="visible";this.g.push(BJ(a.a))}};var nK=class extends lK{constructor(a,b,c){super(a,b,c);this.g=null;this.j=[]}init(){this.g=new mK(this);this.h=!0}m(){const a=_.jm(_.Rc);_.hm(a,this.o);this.id&&(a.id=this.id);return a}};var cK=class extends nK{constructor(a,b){super(a.id,"clpp-text-cue-region",b);this.f=a}init(a){a:{var b=this.f;switch(b.widthUnits){case 0:b=b.width;break a;case _.Ao:b=b.width/100*a.width;break a;default:throw Error(iJ);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.Ao)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(iJ);d=a.height;const e=TJ(this,d,a.height);tJ(this.A,this.a);tJ({left:vJ(c,_.Zd),top:vJ(e,_.Zd),width:vJ(b,
|
|
21
|
+
_.Zd),height:vJ(d,_.Zd)},this.a);this.f.writingMode&&tJ({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&tJ({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.hm(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.Ao:f=f.height/100*a.height;break a;case 2:f=f.height;c=new dK(new _.xo(0,1,"Lorem ipsum",_.ro),{},{});b=c.a;this.a.appendChild(b);c.init(BJ(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
22
|
+
b=c;f*=b;break a;default:throw Error(iJ);}a=TJ(this,f,a.height);tJ({top:vJ(a,_.Zd),height:vJ(f,_.Zd)},this.a);this.g=new mK(this,!0);this.h=!0}getId(){return this.f.id}};var oK=class{constructor(a,b){this.f=new _.Q("clpp.htmlcue.StyleManager");this.o=[];this.j=a.getSurface().getUniqueCssClass();this.h=b;this.m=[];this.a=VJ(this,this.h,this.j);this.g=VJ(this,this.h,this.j,!0);this.g.disabled=!0;this.f.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.m.some(b=>b===a)){const b=WJ(this,a);if(XJ(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.f.debug(`Added CSS rule ${b}`)}catch(c){this.f.error(`An error occurred when adding a CSS rule: ${b}`)}this.m.push(a)}else this.f.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
|
|
23
|
+
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.y(function*(){null!=a.a&&(a.o.forEach(b=>b()),a.o=[],YJ(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.g.ownerNode),a.a=null,a.g=null,a.f.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var pK=class extends _.cq{constructor(a){super(a);this.M=new _.Q(lJ);this.l=a;this.K=ZJ(a);this.j=!1;this.f=[];this.C=a.getSurface().getContainer();this.h=new oK(a,"CLPP Subtitle Styles");this.a=new nK(null,"clpp-text-container",{});this.w=new _.Yp(a.getSurface(),this.V.bind(this));this.I=null;this.C?(this.C.appendChild(this.a.a),this.a.init(null)):this.M.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");this.F=
|
|
24
|
+
new _.ci(()=>{eK(this)});this.A=new Map;this.m=null}append(a,b){if(null!=this.h&&0!==a.length){for(const c of b)this.h.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=oJ(this.f,nJ(a));this.m=null;eK(this,!1)}}g(){null==this.h||eK(this,!0)}destroy(){const a=this;return _.y(function*(){null!=a.h&&(fK(a),a.F.stop(),yield a.h.destroy(),a.h=null,a.C.removeChild(a.a.a),a.a=null,a.w.stop(),a.w=null,a.j=!1)})}remove(a,b){if(null==this.h)return!1;this.f=
|
|
25
|
+
this.f.filter(c=>c.startTime<a||c.endTime>=b);this.m=null;eK(this,!0);return!0}isTextVisible(){return this.j}setTextVisibility(a){null!=this.h&&this.j!==a&&((this.j=a)?(this.F.Xa(.25),this.K.enableResizeObserver&&this.w.start(),eK(this,!0)):(this.F.stop(),this.w.stop(),fK(this)))}V(){eK(this,!0)}};_.z(lJ,pK);pK.prototype.setTextVisibility=pK.prototype.setTextVisibility;pK.prototype.isTextVisible=pK.prototype.isTextVisible;pK.prototype.remove=pK.prototype.remove;pK.prototype.destroy=pK.prototype.destroy;
|
|
26
|
+
pK.prototype.append=pK.prototype.append;var qK=class{ea(a){return!!a.enableHtmlCue&&!_.si()}create(a){return new pK(a)}};_.z("clpp.htmlcue.HtmlCueComponent",class extends _.Fp{f(){_.rl("html",new qK)}a(){}id(){return _.se}});};f.call(g, window);
|