@castlabs/prestoplay 6.34.0 → 6.35.0-beta.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/cjs/cl.adobe.js +3 -3
- package/cjs/cl.airplay.js +3 -3
- package/cjs/cl.broadpeak.js +18 -18
- package/cjs/cl.cast.js +125 -125
- package/cjs/cl.conviva.js +31 -31
- package/cjs/cl.core.js +579 -577
- package/cjs/cl.crypto.js +9 -9
- package/cjs/cl.dash.js +100 -100
- package/cjs/cl.freewheel.js +26 -26
- package/cjs/cl.hls.js +76 -76
- package/cjs/cl.hlssmpte.js +6 -6
- package/cjs/cl.htmlcue.js +30 -30
- package/cjs/cl.ima.js +25 -25
- package/cjs/cl.mediatailor.js +3 -3
- package/cjs/cl.mse.js +345 -345
- package/cjs/cl.muxdata.js +13 -13
- package/cjs/cl.onboard.js +4 -4
- package/cjs/cl.persistent.js +14 -14
- package/cjs/cl.playlist.js +5 -5
- package/cjs/cl.simid.js +16 -16
- package/cjs/cl.smooth.js +70 -70
- package/cjs/cl.thumbnails.js +25 -25
- package/cjs/cl.tizen.js +67 -67
- package/cjs/cl.ttml.js +29 -29
- package/cjs/cl.verimatrix.js +5 -5
- package/cjs/cl.vimond.js +8 -8
- package/cjs/cl.vr.js +19 -19
- package/cjs/cl.vtt.js +14 -14
- package/cjs/cl.yospace.js +3 -3
- package/cjs/cl.youbora.js +38 -38
- package/cl.adobe.js +3 -3
- package/cl.airplay.js +3 -3
- package/cl.broadpeak.js +14 -14
- package/cl.cast.js +97 -97
- package/cl.conviva.js +28 -27
- package/cl.core.js +463 -462
- package/cl.crypto.js +8 -8
- package/cl.dash.js +89 -89
- package/cl.freewheel.js +20 -20
- package/cl.hls.js +82 -82
- package/cl.hlssmpte.js +5 -5
- package/cl.htmlcue.js +26 -26
- package/cl.ima.js +19 -19
- package/cl.mediatailor.js +2 -2
- package/cl.mse.js +299 -299
- package/cl.muxdata.js +11 -11
- package/cl.onboard.js +5 -5
- package/cl.persistent.js +10 -10
- package/cl.playlist.js +5 -5
- package/cl.simid.js +14 -14
- package/cl.smooth.js +60 -60
- package/cl.thumbnails.js +17 -17
- package/cl.tizen.js +55 -55
- package/cl.ttml.js +22 -22
- package/cl.verimatrix.js +4 -4
- package/cl.vimond.js +7 -7
- package/cl.vr.js +14 -14
- package/cl.vtt.js +12 -12
- package/cl.yospace.js +3 -3
- package/cl.youbora.js +31 -31
- package/package.json +1 -1
package/cl.hls.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
{required:!0})},
|
|
3
|
-
for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.Ce&&typeof d===_.Ce){if(
|
|
4
|
-
/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.K(d,"VALUE"),f=_.K(d,_.Sa),g=_.K(d,"IMPORT"),h=_.K(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.J(_.C,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.J(_.C,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.J(_.C,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},
|
|
5
|
-
_.rb);return c.includes(d)})},
|
|
6
|
-
a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},
|
|
7
|
-
},
|
|
8
|
-
if(null==b)throw new _.J(_.C,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{na:d,ka:e}},
|
|
9
|
-
{required:b.Tg});if(!a)return c;const d=e=>null==e?null:Number(e);c.$f="YES"===_.K(a,"CAN-BLOCK-RELOAD");c.Ch="YES"===_.K(a,"CAN-SKIP-DATERANGES");c.Dh=d(_.K(a,"CAN-SKIP-UNTIL"));c.fi=d(_.K(a,"HOLD-BACK"));c.Kg=d(_.K(a,"PART-HOLD-BACK",void 0,{required:b.Tg}));return c},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
0<=f&&(h.duration=f);f=
|
|
14
|
-
l.value;break;case _.Lb:d[_.Lb]=l.value;break;case _.Qb:d[_.Qb]=
|
|
15
|
-
null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=m;h.type=_.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.J(_.C,4,4015);b=b.slice(1);return 0===
|
|
19
|
-
"in the master playlist");d.set(e,f)});return d},
|
|
20
|
-
b));c.length&&e.push(new _.
|
|
21
|
-
21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.J(_.C,4,4030);}
|
|
22
|
-
e+=10;e+=f}while(e<a.byteLength);return d()},
|
|
23
|
-
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 _.J(_.C,4,4030,
|
|
24
|
-
|
|
25
|
-
((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},
|
|
26
|
-
a=null;b=_.E(b.data);try{a=_.
|
|
27
|
-
"AES-128"!==
|
|
28
|
-
4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:
|
|
29
|
-
_.ub),b),iv:e,generatedIv:f}},
|
|
30
|
-
f.uris[0],h),new _.J(_.C,4,4030,"Failed to fetch the media segment.");}}})},
|
|
31
|
-
yield
|
|
32
|
-
|
|
33
|
-
e+1;c<b.length;)a.push(b[c]),c++},
|
|
34
|
-
0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},
|
|
35
|
-
e.ld=d.ld;e.af=d.af;e.duration=d.duration;e.ig=d.ig;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},
|
|
36
|
-
1E3<c-e;){var g=f.T.shift(),h=f.T[0];if(!h)break;
|
|
37
|
-
|
|
38
|
-
d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=
|
|
39
|
-
cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},
|
|
40
|
-
Error(
|
|
41
|
-
thumbStreams:d,xh:e}=yield
|
|
42
|
-
const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},
|
|
43
|
-
|
|
44
|
-
function(a,b,c){a.w=_.Db;_.
|
|
45
|
-
g=f[0];const h=
|
|
46
|
-
void 0;a=new _.
|
|
47
|
-
b,c){c=
|
|
48
|
-
codecs:k.codecs,name:k.originalId,uri:k.
|
|
49
|
-
null:null,l=h,m=k;l=l&&m?_.
|
|
50
|
-
u=b.spatialAudio,x=b.closedCaptions,y=b.ce,B=_.
|
|
51
|
-
adjustSegmentDurations:za.h.bind(za),getDuration:za.getDuration.bind(za),segmentIndex:za,segmentLookupStrategy:G,initSegmentReference:
|
|
52
|
-
drmInfos:Hb.drmInfos,ma:
|
|
53
|
-
b){return _.v(function*(){const c=yield Promise.all([
|
|
54
|
-
g=k)}h=f.splice(g,1).pop();h=yield
|
|
55
|
-
hd:b.originalLanguage,
|
|
56
|
-
b){return _.v(function*(){var c=new URL(b.streams[0].Ke);if(a.a.lowLatencyMode&&a.L&&a.L.$f){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={pi:d.position,Fi:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Fi,d.set("_HLS_msn",e.pi.toString()),null===f&&d.get(
|
|
57
|
-
c);return{stream:b,playlist:c}})},
|
|
58
|
-
|
|
59
|
-
closedCaptions:null,ce:null})}))})},
|
|
60
|
-
f.hasAttribute(_.ib)){var h=_.K(f,"FRAME-RATE");f=_.K(f,_.ib);var [k,l]=f?f.split("x"):[null,null];h={frameRate:
|
|
61
|
-
(f.push(u),e.add(m))}g=f}else g=[];return g})},
|
|
62
|
-
null;c=c();a.j.set(b,c);return c},
|
|
63
|
-
return k})}
|
|
64
|
-
b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=
|
|
65
|
-
void 0,{required:c});if(!c)return null;const d=_.
|
|
66
|
-
|
|
67
|
-
(m=
|
|
68
|
-
a.j.get(c)){var k=h.streams[h.streams.length-1].T;k=k[k.length-1];a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${k.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h)}throw new _.J(_.C,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}k=yield
|
|
69
|
-
c[0];const l=yield
|
|
70
|
-
Ih:n,mi:m,aesEncrypted:B,mimeType:l,endTime:u[u.length-1].endTime,ma:y,hi:x,ni:p}})},
|
|
71
|
-
|
|
72
|
-
m);return m})},
|
|
73
|
-
d){if(1===b){if(!d||0===d.length)throw new _.J(_.C,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.J(_.C,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.T=1===b?d:null}},
|
|
74
|
-
void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===p?null:p,u,void 0===x?null:x);this.ma=0}},
|
|
75
|
-
this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},
|
|
76
|
-
|
|
77
|
-
c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield
|
|
78
|
-
b){var c=b.presentationTimeline,d=Array.from(a.j.values()),e=yield
|
|
79
|
-
k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.
|
|
80
|
-
e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.
|
|
81
|
-
f.verbatimUri,()=>_.v(function*(){const h=yield
|
|
82
|
-
7,7001);a=this.D.networkingEngine.fetch(a);_.
|
|
1
|
+
import {clpp} from "./cl.core.js";import './cl.mse.js';let g={};const _ = clpp._;var f=function(window){'use strict';var WI="CLOSED-CAPTIONS",XI="Could not parse MP4 segment start time.",YI="DURATION",ZI="EXT-X-DATERANGE",$I="EXT-X-DISCONTINUITY",aJ="EXT-X-KEY",bJ="EXT-X-MAP",cJ="EXT-X-MEDIA",dJ="EXT-X-MEDIA-SEQUENCE",eJ="EXT-X-PROGRAM-DATE-TIME",fJ="EXT-X-STREAM-INF",gJ="Failed to infer discontinuity number",hJ="Guessing audio-only",iJ="METHOD",jJ="SAMPLE-AES-CTR",kJ="SUBTITLES",lJ="_HLS_part",mJ="application/vnd.apple.mpegurl",nJ="manifestloaded",oJ="sample",pJ=function(a,b){return _.K(a,b,void 0,
|
|
2
|
+
{required:!0})},qJ=function(a){if(1>a.a)throw _.Dm();--a.a},rJ=function(a,b){for(const c in a){if(!(c in b))return!1;const d=a[c],e=b[c];if(d&&typeof d===_.Ce&&e&&typeof e===_.Ce){if(!rJ(d,e))return!1}else if(void 0!==d&&void 0!==e&&d!==e)return!1}return!0},sJ=function(a,b){if(!rJ(a,b))return!1;for(const c in b){if(!(c in a))return!0;const d=a[c],e=b[c];if(!d&&e||d&&typeof d===_.Ce&&e&&typeof e===_.Ce&&sJ(d,e))return!0}return!1},tJ=function(a,b){if(a===b||_.z(a)||_.z(b))return!1;const c=Object.keys(a);
|
|
3
|
+
for(let e=0;e<c.length;e++){var d=c[e];if(!(d in b))continue;const f=a[d];d=b[d];if(f instanceof Date&&d instanceof Date&&f.getTime()!==d.getTime())return!0;if(typeof f===_.Ce&&typeof d===_.Ce){if(tJ(f,d))return!0}else{if(f instanceof Array&&d instanceof Array){if(f.length!==d.length)return!0;for(let g=0;g<f.length;g++)if(f[g]!==d[g])return!0}if(f!==d)return!0}}return!1},uJ=function(a){if(null!==a&&void 0!==a)return Number(a)},vJ=function(a,b){return a.filter(c=>c.name===b)},wJ=function(a){const b=
|
|
4
|
+
/^[a-zA-Z0-9_-]+$/,c=new Set;a.forEach(d=>{const e=_.K(d,"VALUE"),f=_.K(d,_.Sa),g=_.K(d,"IMPORT"),h=_.K(d,"QUERYPARAM");if(1!==[f,g,h].filter(Boolean).length||f&&null==e)throw new _.J(_.C,4,4044,{message:"Invalid tag.",text:d.toString()});d=f||g||h;if(c.has(d))throw new _.J(_.C,4,4044,`EXT-X-DEFINE redefined variable "${d}".`);if(!b.test(d))throw new _.J(_.C,4,4044,`EXT-X-DEFINE invalid variable name "${d}".`);c.add(d)})},xJ=function(a,b){const c=Array.isArray(b)?b:[b];return a.filter(d=>{d=pJ(d,
|
|
5
|
+
_.rb);return c.includes(d)})},yJ=function(a,b){return a.some(c=>c.name===b)},zJ=function(a,b,c){c=void 0===c?{}:c;a=a.find(d=>d.name===b)||null;if(!a&&c.required)throw new _.J(_.C,4,4024,{missingTag:b});return a},AJ=function(a){var b=zJ(a,"EXT-X-TILES");if(!b)return{Jd:1,ae:1,durationPerTile:null};a=_.K(b,"LAYOUT")||"1x1";b=_.K(b,YI);a=_.AB(a);return{Jd:a.Jd,ae:a.ae,durationPerTile:b?Number(b):null}},BJ=function(a){const b=new Set;a.variants.forEach(c=>{c.audio&&b.add(c.audio);c.video&&b.add(c.video)});
|
|
6
|
+
a.textStreams.forEach(c=>b.add(c));a.thumbStreams.forEach(c=>b.add(c));return Array.from(b)},CJ=function(a,b){Array.isArray(a)||(a=[a]);a.forEach(c=>{for(const d of BJ(c))b(d,c)})},DJ=function(a){return a.some(b=>yJ(b.ba,"EXT-X-ENDLIST"))},EJ=function(a){return a.type===_.q||a.type===_.t},FJ=function(a){if(zJ(a,"EXT-X-ENDLIST"))return _.Db;a=zJ(a,"EXT-X-PLAYLIST-TYPE");if(!a)return"LIVE";if(a.value===_.Db)return _.Db;if("EVENT"===a.value)return"EVENT";throw new _.J(_.C,4,4044,`Invalid EXT-X-PLAYLIST-TYPE value: ${a.value}`);
|
|
7
|
+
},GJ=function(a){a={AUDIO:_.q,VIDEO:_.t,SUBTITLES:_.I,"CLOSED-CAPTIONS":_.I}[a.toUpperCase()];if(!a)throw new _.J(_.C,4,4044,"EXT-X-MEDIA tag has an invalid TYPE attribute.");return a},HJ=function(a,b,c){c=void 0===c?!1:c;var d=0;let e=null;if(a){d=a.split("@");a=Number(d[0]);if(0>=a)throw new _.J(_.C,4,4044,"Byte range length must be positive.");if(d[1]){if(d=Number(d[1]),0>d)throw new _.J(_.C,4,4044,"Byte range start byte must not be negative.");}else{if(c)throw new _.J(_.C,4,4044,"Invalid byte range, offset is required but missing.");
|
|
8
|
+
if(null==b)throw new _.J(_.C,4,4044,"Invalid byte range, cannot calculate offset based on previous byte ranges.");d=b+1}e=d+a-1}return{na:d,ka:e}},IJ=function(a,b){a=zJ(a,"EXT-X-BYTERANGE");return HJ(a?a.value:null,b)},JJ=function(a){a=zJ(a,"EXTINF",{required:!0}).value.split(",");const b=Number(a[0]);if(isNaN(b))throw new _.J(_.C,4,4044,"#EXTINF must be a number.");return{duration:b,title:a[1]||null}},KJ=function(a,b){b=void 0===b?{}:b;const c={$f:!1,Ch:!1,Dh:null,fi:null,Kg:null};a=zJ(a,"EXT-X-SERVER-CONTROL",
|
|
9
|
+
{required:b.Tg});if(!a)return c;const d=e=>null==e?null:Number(e);c.$f="YES"===_.K(a,"CAN-BLOCK-RELOAD");c.Ch="YES"===_.K(a,"CAN-SKIP-DATERANGES");c.Dh=d(_.K(a,"CAN-SKIP-UNTIL"));c.fi=d(_.K(a,"HOLD-BACK"));c.Kg=d(_.K(a,"PART-HOLD-BACK",void 0,{required:b.Tg}));return c},LJ=function(a,b,c){c=void 0===c?!1:c;a=_.K(a,"BYTERANGE");return HJ(a,b,c)},MJ=function(a){const b=vJ(a,cJ),c=vJ(a,fJ);a=vJ(a,"EXT-X-IMAGE-STREAM-INF");return{Mc:{Uf:xJ(b,[_.wA,_.Cb]),closedCaptions:xJ(b,WI),cj:xJ(b,kJ)},be:c,Xe:a}},
|
|
10
|
+
OJ=function(a,b){const c=IJ(a.ba,null);return new NJ(0,0,0,()=>[a.a],c.na,c.ka,0,b)},PJ=function(a){let b=Infinity,c=Infinity;BJ(a).filter(EJ).forEach(d=>{{d=d.T;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{ld:b,duration:c}},QJ=function(a){return a.map(b=>{({duration:b}=PJ(b));return b}).reduce((b,c)=>b+c,0)},RJ=function(a){return(a.video?a.video.cb:"")+" - "+(a.audio?a.audio.cb:"")},SJ=function(a,b,c,d,e){if(b===_.Db)return{delay:0,$d:0};b=
|
|
11
|
+
zJ(a,"EXT-X-PART-INF");if(c&&b){e=Number(pJ(b,"PART-TARGET"));if(null!=d)return{delay:d,$d:e};({Kg:d}=KJ(a,{Tg:!0}));return{delay:d,$d:e}}a=zJ(a,"EXT-X-TARGETDURATION",{required:!0});a=Number(a.value);e=e||a;return null!=d?{delay:d,$d:e}:{delay:3*a,$d:e}},TJ=function(a){const b=new Map;a.forEach(c=>{var d=`${c.Gc()}:${c.streams[0].groupId}`;b.has(d)?(d=b.get(d),d.includes(c)||d.push(c)):b.set(d,[c])});return b},UJ=function(a){const b=new Map;for(const c of a){a=_.K(c,_.Ka);a=_.Uj(a||_.eg);const d=
|
|
12
|
+
pJ(c,_.Ea),e=pJ(c,"INSTREAM-ID");b.has(d)||b.set(d,new Map);b.get(d).set(e,a)}return b},VJ=function(a){return a.filter(b=>"mp4a.40.34"!==b)},WJ=function(a,b,c,d,e){var f=e&&e.Yd,g=e&&e.schemeIdUri,h=_.K(a,"ID");f=_.K(a,"START-DATE")||f;if(null===h||!f)return _.qu.warn("Invalid EXT-X-DATERANGE missing mandatory ID or required START-DATE attribute, ignoring the EXT-X-DATERANGE tag.",a),null;b=d?c-b:-b;d=new Date(f);c=d.getTime()/1E3+b;h={id:h,startTime:c,startDate:d,Yd:f};f=uJ(_.K(a,YI));void 0!==f&&
|
|
13
|
+
0<=f&&(h.duration=f);f=uJ(_.K(a,"PLANNED-DURATION"));void 0!==f&&0<=f&&(h.plannedDuration=f);g=_.K(a,"CLASS")||g||null;null!==g&&(h.schemeIdUri=g);f=(f=_.K(a,"END-DATE"))?new Date(f):null;null!==f&&f.getTime()>=d.getTime()&&(h.endDate=f);f=a.attributes;if(null==f)var k=null;else{d={};for(k of f)k.name.trim().startsWith("X-")&&(d[k.name]=k.value);k=_.$g(d)?d:null}k=k||{};(d=_.K(a,"CUE"))&&(k.CUE=d.split(","));if(_.Ij(g)){f=a.attributes;if(null==f)var l=null;else{d={};for(l of f)switch(l.name){case _.Mb:d[_.Mb]=
|
|
14
|
+
l.value;break;case _.Lb:d[_.Lb]=l.value;break;case _.Qb:d[_.Qb]=uJ(l.value);break;case _.Ob:d[_.Ob]=uJ(l.value);break;case "X-SNAP":d["X-SNAP"]=l.value.split(",");break;case _.Pb:d[_.Pb]=l.value.split(",")}l=_.$g(d)?d:null}l&&(k=Object.assign(k,l))}_.$g(k)&&(h.customAttributes=k);if(tJ(e,h))return _.qu.warn("EXT-X-DATERANGE augmented and previous values differ.Ignoring the EXT-X-DATERANGE tag.",a),null;h=_.Xg(e,h);if(_.Ij(g)&&!_.Jj(h.customAttributes))return _.qu.warn("Invalid EXT-X-DATERANGE Interstitial attributes X-ASSET-URI, X-ASSET-LIST"),
|
|
15
|
+
null;let m;h.endDate?m=h.endDate.getTime()/1E3+b:h.duration?m=c+h.duration:h.plannedDuration?m=c+h.plannedDuration:m=c;h.endTime=m;h.type=_.dj;return h},XJ=function(a,b){if(!a)return null;const c=a.cb;return b.find(d=>d.streams[0].cb===c)||null},YJ=function(a){return(a=_.K(a,"CHANNELS"))?parseInt(a.split("/")[0],10):null},ZJ=function(a){return a.some(b=>b.startsWith("#EXT-X-TARGETDURATION"))?1:0},$J=function(a,b){const c=new Map,d=new URL(b);a.forEach(e=>{var f=_.K(e,_.Sa),g=_.K(e,"QUERYPARAM");if(f)g=
|
|
16
|
+
pJ(e,"VALUE"),c.set(f,g);else if(g){f=d.searchParams.get(g);if(null==f)throw new _.J(_.C,4,4044,`Query param '${g}' missing in playlist URI.`);if(!f)throw new _.J(_.C,4,4044,`Query param '${g}' has no associated value`+" in playlist URI.");c.set(g,decodeURIComponent(f))}});return c},aK=function(a,b){return a.replace(/\{\$([a-zA-Z0-9_-]+)\}/g,(c,d)=>{c=b.get(d);if(null==c)throw new _.J(_.C,4,4044,`Undefined variable '${d}'`);return c})},bK=function(a,b){a.forEach(c=>{c.attributes.forEach(d=>{d.value=
|
|
17
|
+
aK(d.value,b)})})},eK=function(a,b,c){const d=[];for(let e=0;e<b.length;e++){const f=cK(a,b[e]);d.push(f);if(f.name===fJ){const g=b[e+1];if(!g)throw new _.J(_.C,4,4044,"EXT-X-STREAM-INF is not followed by a URI.");f.attributes.push(new _.sk(_.ub,g));e++}}b=vJ(d,"EXT-X-DEFINE");wJ(b);b=$J(b,c);a.a=b;bK(d,a.a);return new dK(c,0,d)},iK=function(a,b,c){const {Qi:d,ei:e,oj:f}=fK(b),g=gK(a,f,c);b=e.map(k=>cK(a,k,g));const h=hK(a,c,d,g);return new dK(c,1,b,h)},jK=function(a,b,c){b=b.trim().split(/\n+/m).map(d=>
|
|
18
|
+
d.trim()).filter(d=>d.length&&!/^#(?!EXT)/m.test(d));if(!/^#EXTM3U($|[ \t\n])/m.test(b[0]))throw new _.J(_.C,4,4015);b=b.slice(1);return 0===ZJ(b)?eK(a,b,c):iK(a,b,c)},fK=function(a){const b=[],c=[],d=[];for(const e of a)kK.test(e)?d.push(e):lK.test(e)?c.push(e):b.push(e);return{Qi:b,ei:c,oj:d}},gK=function(a,b,c){b=b.map(e=>cK(a,e));wJ(b);const d=$J(b,c);b.map(e=>_.K(e,"IMPORT")).filter(Boolean).forEach(e=>{const f=a.a.get(e);if(null==f)throw new _.J(_.C,4,4044,`Cannot import variable '${e}' as it is not defined `+
|
|
19
|
+
"in the master playlist");d.set(e,f)});return d},cK=function(a,b,c){a=_.uk(a.h++,b);c&&bK([a],c);return a},hK=function(a,b,c,d){const e=[];let f=[],g=[];c.forEach(h=>{/^(#EXT)/.test(h)?(h=cK(a,h,d),"EXT-X-PART"===h.name||"EXT-X-PRELOAD-HINT"===h.name&&"PART"===_.K(h,_.rb)?g.push(h):f.push(h)):(yJ(f,"EXT-X-GAP")||(h=aK(h,d),h=_.Dj(h,b),e.push(new mK(h,f,g))),f=[],g=[])});0<g.length&&e.push(new mK(null,f,g));return e},nK=function(a,b,c){const d=[],e=[];e.push(new _.sk(_.na,"0"));e.push(new _.sk(_.ub,
|
|
20
|
+
b));c.length&&e.push(new _.sk(_.qa,c));d.push(new _.tk(a.h++,fJ,e));return new dK(b,0,d)},oK=function(a){return 0>a?[]:Array.from({length:a},(b,c)=>c)},pK=function(a){return new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255])},qK=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},rK=function(a){function b(h,k,l){let m="";for(;k<l;k++)m+="%"+("00"+h[k].toString(16)).slice(-2);return m}function c(h){return h[0]<<
|
|
21
|
+
21|h[1]<<14|h[2]<<7|h[3]}function d(){throw new _.J(_.C,4,4030);}qK(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]<<6|a[7]>>>2,f*=4,f+=a[7]&3,Math.round(f/9E4);break}}qK(a,e)||d();
|
|
22
|
+
e+=10;e+=f}while(e<a.byteLength);return d()},sK=function(a,b){let c=null,d=0;try{(new _.Wm).N(_.ue,_.Pm).N(_.bg,_.Pm).N(_.pe,_.Pm).fa("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 _.Yv.error("Unable to find timescale in init segment!"),new _.J(_.C,4,4030,XI,c);let e=0,f=!1;try{(new _.Wm).N("moof",_.Pm).N("traf",_.Pm).fa("tfdt",g=>{var h=d;if(0===g.version)h=_.P(g.reader)/h;else{{const k=_.P(g.reader),l=_.P(g.reader);if(!(2097151>=
|
|
23
|
+
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 _.J(_.C,4,4030,XI,c);return e},tK=function(a){for(;a.getPosition()<a.Va()-1;){const b=a.getPosition();if(71===_.Em(a))return qJ(a),b}return-1},uK=function(a){function b(){d.seek(e+188);f=_.Em(d);71!==f&&(d.seek(e+192),f=_.Em(d));71!==f&&(d.seek(e+204),f=_.Em(d));71!==f&&c();
|
|
24
|
+
qJ(d)}function c(){throw new _.J(_.C,4,4030);}const d=new _.Dn(new DataView(a),!1);let e=0,f=0;e=tK(d);0>e&&(_.Yv.error("Unable to find sync byte in TS after scanning."),c());for(;;){e=d.getPosition();f=_.Em(d);71!==f&&c();a=_.Fm(d);if(8191===(a&8191)){b();continue}if(!(a&16384)){b();continue}a=(_.Em(d)&48)>>4;0!==a&&2!==a||c();3===a&&(a=_.Em(d),d.skip(a));if(1!==_.P(d)>>8){b();continue}d.skip(3);a=_.Em(d)>>6;0!==a&&1!==a||c();0===_.Em(d)&&c();a=_.Em(d);const g=_.Fm(d),h=_.Fm(d);return(1073741824*
|
|
25
|
+
((a&14)>>1)+((g&65534)<<14|(h&65534)>>1))/9E4}},xK=function(a){const b=vK(a),c=wK(a);a.forEach(d=>{const e=d.T,f=e.findIndex(h=>h.ma===b);let g=e.findIndex(h=>h.ma===c+1);-1===g&&(g=e.length);d.T=e.slice(f,g)})},wK=function(a){a=a.map(b=>b.T[b.T.length-1].ma);return Math.min(...a)},vK=function(a){a=a.map(b=>b.T[0].ma);return Math.max(...a)},AK=function(a){var b=pJ(a,iJ);if(!yK.includes(b))return zK.error("PlayReady in HLS is only supported with [",yK.join(", "),"], not",b),null;a=pJ(a,_.ub);b=_.Uk(a);
|
|
26
|
+
a=null;b=_.E(b.data);try{a=_.lB(_.Ln(b))}catch(c){a=b}return _.yB(_.rd,[{initDataType:_.Vc,initData:a}],"")},CK=function(a){if(0===a.length)return BK();if(a.some(c=>"whole-segment"===c.type)||a.every(c=>c.type===_.Be))return a[0];a=a.filter(c=>c.type===oJ);const b=_.rj(a.flatMap(c=>c.drmInfos));return{keyId:a[a.length-1].keyId,type:oJ,drmInfos:b}},FK=function(a,b){return DK(a).map(c=>EK(c.ba,b)).filter(Boolean)},DK=function(a){return a.filter(b=>yJ(b.ba,aJ))},EK=function(a,b){a=vJ(a,aJ).filter(d=>
|
|
27
|
+
"AES-128"!==pJ(d,iJ));if(0===a.length)return null;var c=pJ(a[0],iJ);if(1===a.length&&"NONE"===c)return BK();c=a.map(d=>pJ(d,iJ));if(!c.every(d=>"SAMPLE-AES"===d)&&!c.every(d=>d===jJ))throw GK.warn(`EXT-X-KEY methods ${c.join(", ")} are incompatible.`),new _.J(_.C,4,4044,"Multiple EXT-X-KEY tags with incompatible METHOD values.");a=a.map(d=>{const e=_.K(d,"KEYFORMAT","identity");{const f=HK[e]||null;d=f?f(d,b):null}d||GK.warn("Unsupported HLS KEYFORMAT",e);return d}).filter(Boolean);if(0===a.length)throw new _.J(_.C,
|
|
28
|
+
4,4026);return{keyId:a.map(d=>d.keyIds).reduce((d,e)=>d.concat(e),[]).reverse()[0]||null,type:oJ,drmInfos:a}},BK=function(){return{type:_.Be,drmInfos:[],keyId:null}},IK=function(a,b,c){a=vJ(a,aJ)[0];if(!a||"AES-128"!==pJ(a,iJ))return null;var d=_.K(a,"IV","");d?c={iv:_.Qk((d||"0x").slice(2)),generatedIv:!1}:(d=_.K(a,"KEYFORMAT"),c=null==d||"identity"===d?{iv:_.Tk(new Uint8Array(12),pK(c)),generatedIv:!0}:{iv:null,generatedIv:!1});const {iv:e,generatedIv:f}=c;return{method:"AES-128",url:_.Dj(pJ(a,
|
|
29
|
+
_.ub),b),iv:e,generatedIv:f}},JK=function(a,b,c){return _.v(function*(){const d=b.f(),e=_.gC(b.Da(),b.na,b.na+2048-1,a.a.attemptParameters);e.type=2;const f=_.gC(b.Da(),b.na,b.ka,a.a.attemptParameters);f.type=2;d&&(f.keyInfo=d);try{return yield a.f(c?f:e)}catch(g){if(7001===g.code||c)throw g;a.g.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.",e.uris[0]);try{return yield a.f(f)}catch(h){throw a.g.error("Failed to fetch media segment to parse its start timestamp.",
|
|
30
|
+
f.uris[0],h),new _.J(_.C,4,4030,"Failed to fetch the media segment.");}}})},KK=function(a,b,c,d,e,f){return _.v(function*(){a.g.debug("Fetching segment to find start time");if("audio/mpeg"===d||d===_.Fc||d===_.Ec)return 0;if(d===_.Dc){var g=yield JK(a,c,f);g=_.E(g.data);if(!qK(g))throw new _.J(_.C,4,4030,"AAC segment does not contain an ID3 tag.");return rK(g)}if(d===_.qg||d===_.Gc)return g=[JK(a,c,f)],b&&g.push(JK(a,b,!0)),g=yield Promise.all(g),sK(g[0].data,(g[1]||g[0]).data);if(d===_.pg)return g=
|
|
31
|
+
yield JK(a,c,f),uK(g.data);if(!_.Rs(`${d.split("/")[0]||""}/mp4;codecs="${e}"`))return 0;throw new _.J(_.C,4,4030);})},LK=function(a,b){a=a.map(c=>c.streams[b]);return a.some(c=>null==c)?null:a},MK=function(a,b){a=a.streams.find(c=>{c=c.T;return c[0].position<=b&&b<=c[c.length-1].position});return null==a?null:a.T.find(c=>c.position===b)||null},NK=function(a,b){a.streams.forEach(c=>{c.Ke=b})},OK=function(a,b){a.streams.forEach(c=>{c.width=b})},PK=function(a,b){a.streams.forEach(c=>{c.height=b})},
|
|
32
|
+
QK=function(a,b){a.streams.forEach(c=>{c.frameRate=b})},RK=function(a,b){a.streams.forEach(c=>{c.bandwidth=b})},SK=function(a,b){a=a.map(c=>c.a[b]);return a.some(c=>null==c)?null:a},TK=function(a,b){const c=new Set(a.map(d=>d.ma));return b.filter(d=>!c.has(d.ma))},VK=function(a,b){for(;a[0].ma<b[0].ma;)a.splice(0,1);var c=a[0];let d=b[0];c.startTime===d.startTime&&c.endTime===d.endTime||UK(c,d);const e=a.length-1;c=a[e];d=b[e];0<e&&(c.startTime!==d.startTime||c.endTime!==d.endTime)&&UK(c,d);for(c=
|
|
33
|
+
e+1;c<b.length;)a.push(b[c]),c++},ZK=function(a,b,c,d,e){var f=b[0].length();f=oK(f).map(g=>{var h=SK(b,g)||[];const k=LK(c,g)||[];g=LK(d,g)||[];{const l=[...WK(h),...k,...g].filter(Boolean);XK(l);const {ma:m,duration:n}=l[0];h={configurationId:a,variants:h,textStreams:k,thumbStreams:g,startTime:0,id:`P${m}`,endTime:n,duration:n,ma:m}}return h});f[0].startTime+=e;f[0].endTime+=e;YK(f);return f},WK=function(a){a=new Set(a.flatMap(b=>[b.video,b.audio]).filter(Boolean));return Array.from(a)},YK=function(a){for(let b=
|
|
34
|
+
0;b<a.length;b++){const c=a[b],d=a[b-1];c.startTime=d?d.endTime:c.startTime;c.endTime=c.startTime+c.duration}},UK=function(a,b){a.startTime=b.startTime;a.endTime=b.endTime;a.duration=b.duration;$K(a.variants,b.variants);aL(BJ(a),BJ(b))},$K=function(a,b){const c=new Map(a.map(d=>[RJ(d),d]));b.forEach(d=>{c.get(RJ(d)).drmInfos=d.drmInfos})},aL=function(a,b){const c=new Map(a.map(d=>[d.cb,d]));b.forEach(d=>{const e=c.get(d.cb);e.T=d.T;d.T.forEach(f=>{f.initSegment=e.initSegmentReference});e.segmentIndex.replace(d.T);
|
|
35
|
+
e.ld=d.ld;e.af=d.af;e.duration=d.duration;e.ig=d.ig;e.encrypted=d.encrypted;e.drmInfos=d.drmInfos;e.keyId=d.keyId})},XK=function(a){const b=bL(a);a.forEach(c=>{_.cC(c.segmentIndex,b);c.duration=b;c.af=c.ld+b})},bL=function(a){let b=Infinity;a.filter(EJ).forEach(c=>{b=Math.min(b,c.duration)});return b},fL=function(a){if(!(2>a.length)&&cL(a)){a=a.map(e=>({playlist:e,eg:dL(e.T[0])}));var b=a.map(e=>e.eg),c=Math.max(...b);b=Math.min(...b);if(!(1E3>c-b)){a.forEach(e=>{const f=e.playlist;for(e=e.eg;0<f.T.length&&
|
|
36
|
+
1E3<c-e;){var g=f.T.shift(),h=f.T[0];if(!h)break;eL(g,h);h=dL(h);null!=h?e=h:({duration:h}=JJ(g.ba),e+=1E3*h)}});a=a.map(e=>e.playlist);if(a.some(e=>0===e.T.length))throw new _.J(_.C,4,4048,"Media playlists are completely out of sync.");var d=Math.min(...a.map(e=>e.T.length));a.forEach(e=>{for(;e.T.length>d;)e.T.pop()})}}},cL=function(a){return a.every(b=>!!dL(b.T[0]))},eL=function(a,b){a&&b&&[bJ,aJ].forEach(c=>{if(!yJ(b.ba,c)){var d=a.ba.filter(e=>e.name===c);0!==d.length&&d.forEach(e=>{b.ba.push(e)})}})},
|
|
37
|
+
gL=function(a,b){CJ(b,(c,d)=>{_.tC(a,c.T,d.startTime)});_.lC(a.a,b[0].startTime,b[b.length-1].endTime)},hL=function(a,b){return _.v(function*(){var c=_.fk([b],a.a.attemptParameters);c.type=1;c=yield a.I(c);let d="";try{d=_.wi(c.data)}catch(e){throw new _.J(_.C,4,4042);}d=d.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");d=d.trim();return{text:d,response:c}})},sL=function(a,b){return _.v(function*(){var c=iL(a,b,a.o,"");if(1===c.type){var d=c.T[0].a;c=jL(d);if(!c)throw new _.J(_.C,4,4021,`Unknown file extension ${d}`);
|
|
38
|
+
d="";c===_.t?d="avc1.42E01E":c===_.q&&(d="mp4a.40.2");c=nK(a.S,a.o,a.a.hlsDefaultCodecs||d)}d=MJ(c.ba);c=kL(d.Mc.Uf);c.forEach(m=>{a.K.add(m.groupId)});var e=yield lL(a,d);var f=e.oi;const g=e.periods;var h=e.Ki;const k=e.ej;d=e.alternativeVariants;const l=e.alternativeTextStreams;e=e.alternativeImageStreams;if(!a.D)throw new _.J(_.C,7,7001);mL(a,g);h=nL(a,f.delay,g,h);oL(a)||(a.G=f.$d,a.g.info(`Update playlist each ${a.G} s`),pL(a));qL(a,h,g);f=rL(a,k);c={presentationTimeline:h,periods:g,minBufferTime:0,
|
|
39
|
+
cues:f,muxedAudioTracks:c};d&&(c.alternativeVariants=d);l&&(c.alternativeTextStreams=l);e&&(c.alternativeImageStreams=e);a.g.debug("HLS playlist parsed",c);return c})},uL=function(a,b){return Promise.all(b.map(c=>tL(a,c)))},wL=function(a,b){b.forEach(c=>{a:{var d=a.j.get(c.verbatimUri),e=!oL(a),f=zJ(c.ba,"EXT-X-DISCONTINUITY-SEQUENCE");if(f)var g=Number(f.value);else{d?(f=d.streams[d.streams.length-1].T,f=f[f.length-1].ma):f=0;if(e&&0<f)try{{const k=zJ(c.ba,dJ);if(!k)throw vL.error("Failed to infer discontinuity number, because EXT-X-MEDIA-SEQUENCE tag is missing."),
|
|
40
|
+
Error(gJ);const l=Number(k.value),m=MK(d,l);if(!m)throw vL.error("Failed to infer discontinuity number, could not find the appropriate segment in the previous playlist"+` (segment position = ${l})`),Error(gJ);var h=m.ma}g=h;break a}catch(k){throw new _.J(_.C,4,4024,"EXT-X-DISCONTINUITY-SEQUENCE tag is required for discontinuous HLS live streams.");}g=0}}c=c.T||[];for(const k of c)yJ(k.ba,$I)&&g++,k.ma=g});xK(b)},zL=function(a,b){return _.v(function*(){"LIVE"===a.w&&(a.M=!0,a.H=!0);const {textStreams:c,
|
|
41
|
+
thumbStreams:d,xh:e}=yield xL(a,b),f=a.f.periods[0].variants.map(g=>{const h=XJ(g.audio,e),k=XJ(g.video,e);g=yL(a,h,k,g.bandwidth);if(!g)throw new _.J(_.C,4,4047,{message:"Video and audio are encrypted in an incompatible way.",Tj:k?k.streams[0].cb:void 0,audio:h?h.streams[0].cb:void 0});return g});return ZK(a.D.configurationId,f,c,d,a.B)})},mL=function(a,b){oL(a)||2!==a.a.timeline.version||(a.J||(a.J=b[0].startTime),_.qD(b,-a.J))},AL=function(a,b){b=b.flatMap(d=>d.T[0].ba);b=zJ(b,eJ);if(!b)return null;
|
|
42
|
+
const c=(new Date(b.value)).getTime();return isNaN(c)?(a.g.warn("Failed to parse EXT-X-PROGRAM-DATE-TIME tag "+`value (value: ${b.value}).`),null):c/1E3},BL=function(a,b,c){b=b.find(e=>null!==zJ(e.ba,ZI));if(!b)return[];if(null===c)throw new _.J(_.C,4,4024,"EXT-X-PROGRAM-DATE-TIME tag is required when EXT-X-DATERANGE tags are present");var d=b.ba.filter(e=>e.name===ZI);b=new Map;for(const e of d)d=(d=_.K(e,"ID"))?b.get(d):void 0,(d=WJ(e,c,a.B,!oL(a),d))&&b.set(d.id,d);return Array.from(b.values())},
|
|
43
|
+
rL=function(a,b){const c=new Set(b.map(d=>d.id));a.A.forEach((d,e)=>{c.has(e)||a.A.delete(e)});for(const d of b){if((b=a.A.get(d.id))&&b.Yd!==d.Yd)a.D.onError(new _.J(1,4,4044,"EXT-X-DATERANGE START-DATE has changed for"+` ID=${d.id}`));const e={configurationId:a.D.configurationId,schemeIdUri:d.schemeIdUri,customAttributes:d.customAttributes,value:"",startTime:d.startTime,Yd:d.Yd,endTime:d.endTime,id:d.id,type:_.dj,eventElement:null};b&&!sJ(b,e)||a.A.set(d.id,e)}return Array.from(a.A.values())},CL=
|
|
44
|
+
function(a,b,c){a.w=_.Db;_.pC(b,!0);b.f=c[c.length-1].endTime},iL=function(a,b,c,d){a=jK(a.S,b,c);a.verbatimUri=d;return a},kL=function(a){return a.filter(b=>b.name===cJ&&_.K(b,_.rb)===_.wA&&!_.K(b,_.ub)).map(b=>{const c=YJ(b),d=_.K(b,_.Ka)||_.eg;return{groupId:pJ(b,_.Ea),id:_.DI++,label:pJ(b,_.Sa),language:d,channelsCount:c,primary:"YES"===_.K(b,"DEFAULT")}})},lL=function(a,b){return _.v(function*(){var c=UJ(b.Mc.closedCaptions),d=DL(a,b.be),e=yield EL(a,b),f=Object.values(e).flat().map(k=>k.playlist),
|
|
45
|
+
g=f[0];const h=FJ(g.ba);a.w=h;h!==_.Db&&(a.H=!0);wL(a,f);!oL(a)&&fL(f);a.L=KJ(g.ba);f=SJ(g.ba,h,a.a.lowLatencyMode||!1,a.a.suggestedPresentationDelay,a.a.liveRefreshPeriod);g=yield FL(a,e.Vf,d);c=yield GL(a,e.be,g,c);d=yield HL(a,e.bj,d);g=yield IL(a,e.Xe);d=ZK(a.D.configurationId,c,d,g,a.B);a.D.filterAllPeriods(d);c=[...e.be,...e.Vf].map(k=>k.playlist);e=AL(a,c);c=BL(a,c,e);return{periods:d,Ki:e,ej:c,oi:f}})},nL=function(a,b,c,d){let e=!0,f=null,g=0;oL(a)||(e=!1,f=0,g=b);b=a.a.timeline||{};b.type=
|
|
46
|
+
void 0;a=new _.GI(b,f,g,!0,void 0,!!a.a.lowLatencyMode);_.pC(a,e);gL(a,c);d&&_.oC(a,d);return a},pL=function(a){var b=0;for(var c of a.j.values())b=Math.max(b,c.streams[0].ld);for(c=0;95443.7176888889<=b;)c+=95443.7176888889,b-=95443.7176888889;if(c){a.g.debug("Offsetting live streams by",c,"to compensate for rollover");for(const d of a.j.values())b=d.streams[0],95443.7176888889>b.ld?(a.g.debug("Offset applied to",b.type),b.segmentIndex.offset(c)):a.g.debug("Offset NOT applied to",b.type)}},qL=function(a,
|
|
47
|
+
b,c){c=QJ(c);"LIVE"===a.w||"EVENT"===a.w?(c=Math.max(c,b.J),isNaN(a.a.availabilityWindowOverride)||(c=a.a.availabilityWindowOverride),b.A=c):a.w===_.Db&&(b.f=c)},xL=function(a,b){return _.v(function*(){const c=h=>h.stream.Gc()===_.t||h.stream.Gc()===_.q;var d=b.filter(c),e=b.filter(h=>!c(h)),f=h=>{var k=h.stream.streams[0];k={language:k.language,channelsCount:k.channelsCount,spatialAudio:k.spatialAudio,closedCaptions:k.closedCaptions,primary:k.primary,kind:k.kind||null,groupId:k.groupId,type:k.type,
|
|
48
|
+
codecs:k.codecs,name:k.originalId,uri:k.cb,ce:{width:k.width,height:k.height,frameRate:k.frameRate}};h=Object.assign({},{playlist:h.playlist,hc:null},k);return JL(a,h)};const g=[];for(const h of d)g.push(yield f(h));d=[];for(const h of e)d.push(yield f(h));KL(a,g.concat(d));e=d.filter(h=>h.Gc()===_.eB);f=d.filter(h=>h.Gc()===_.ae);return{textStreams:e,thumbStreams:f,xh:g}})},yL=function(a,b,c,d,e){const f=[],g=(c||b).length();for(let n=0;n<g;n++){var h=b?b.streams[n]||null:null,k=c?c.streams[n]||
|
|
49
|
+
null:null,l=h,m=k;l=l&&m?_.CB(l.drmInfos,m.drmInfos)?_.BB(l.drmInfos,m.drmInfos):null:l?l.drmInfos:m?m.drmInfos:null;if(!l)return null;m=d;h={id:e?e:a.h++,language:h?h.language:_.eg,primary:!!h&&h.primary||!!k&&k.primary,audio:h,video:k,bandwidth:m,drmInfos:l,allowedByApplication:!0,allowedByKeySystem:!0};f.push(h)}return new LL(f)},JL=function(a,b){return _.v(function*(){const c=b.playlist,d=b.codecs,e=b.type,f=b.hd,g=b.hc,h=b.groupId,k=b.muxedAudioId,l=b.primary;var m=b.kind;const n=b.name,p=b.channelsCount,
|
|
50
|
+
u=b.spatialAudio,x=b.closedCaptions,y=b.ce,B=_.Uj(f||_.eg);if(1!==c.type)throw new _.J(_.C,4,4017);const F=yield ML(a,c,e,d),G=a.a.lowLatencyMode?_.VA:_.UA;let D=m;e!==_.I||m||(D=_.eB);const ka=FJ(c.ba);m=F.map(Da=>{const Xa=Da.T,Hb=Da.Ih,sb=Da.mimeType,hc=Da.ma,ic=Xa[0].startTime,Ib=Xa[Xa.length-1].endTime,jb=Ib-ic,za=new _.HI(Xa),vb=Xa[0].initSegment||null;return{id:null==g?_.DI++:g,originalId:n,createSegmentIndex:Promise.resolve.bind(Promise),findSegmentPosition:za.f.bind(za),getSegmentReference:za.get.bind(za),
|
|
51
|
+
adjustSegmentDurations:za.h.bind(za),getDuration:za.getDuration.bind(za),segmentIndex:za,segmentLookupStrategy:G,initSegmentReference:vb,mimeType:sb,codecs:d,kind:D,ig:Hb.type,encrypted:Hb.type===oJ,aesEncrypted:Da.aesEncrypted,keyId:Hb.keyId,language:B,originalLanguage:f||_.eg,label:n,type:e,primary:l,trickModeVideo:null,emsgSchemeIdUris:null,frameRate:y?y.frameRate:void 0,width:y?y.width:void 0,height:y?y.height:void 0,bandwidth:void 0,roles:[],channelsCount:p,spatialAudio:u,closedCaptions:x,T:Xa,
|
|
52
|
+
drmInfos:Hb.drmInfos,ma:hc,cb:c.verbatimUri,Ke:c.a,ld:ic,af:Ib,duration:jb,groupId:h,Kj:ka,muxedAudioId:k}});return new NL(m)})},KL=function(a,b){b.forEach(c=>{a.j.a.set(c.streams[0].cb,c)})},DL=function(a,b){const c=new Map;for(const f of b){var d=_.K(f,_.wA);b=_.K(f,_.Cb);var e=_.K(f,kJ);const g=OL(a,f);if(e){const h=_.zl(_.I,g);c.set(`${_.I}:${e}`,h);e=g.indexOf(h);-1<e&&g.splice(e,1)}d&&(e=PL(_.q,g),c.set(`${"audio"}:${d}`,e));b&&(d=PL(_.t,g),c.set(`${"video"}:${b}`,d))}return c},EL=function(a,
|
|
53
|
+
b){return _.v(function*(){const c=yield Promise.all([QL(a,b.Mc.Uf),QL(a,b.Mc.cj),QL(a,b.be),QL(a,b.Xe)]),[d,e,f,g]=c;return{Vf:d,bj:e,be:f,Xe:g}})},FL=function(a,b,c){return _.v(function*(){if(0===b.length)return new Map;var d=[RL(a,b[0],c)];yield d[0];d=d.concat(b.slice(1).map(e=>RL(a,e,c)));d=yield Promise.all(d);return TJ(d)})},GL=function(a,b,c,d){return _.v(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(pJ(f[k].tag,_.na));l<h&&(h=l,
|
|
54
|
+
g=k)}h=f.splice(g,1).pop();h=yield SL(a,h,c,d,e);f=f.map(k=>SL(a,k,c,d,e));f=yield Promise.all(f);f.splice(g,0,h);return f.reduce(_.vB,[])})},HL=function(a,b,c){return Promise.all(b.map(d=>RL(a,d,c)))},IL=function(a,b){return Promise.all(b.map(c=>TL(a,c)))},UL=function(a,b){return _.v(function*(){const c=_.Dj(b.verbatimUri,a.o),{response:d,text:e}=yield hL(a,c);return iL(a,e,d.uri,b.verbatimUri)})},VL=function(a,b,c){return _.v(function*(){const d=yield JL(a,{playlist:c,codecs:b.codecs,type:b.type,
|
|
55
|
+
hd:b.originalLanguage,hc:b.id,groupId:b.groupId,primary:b.primary,kind:b.kind||null,name:b.label,channelsCount:b.channelsCount,spatialAudio:b.spatialAudio||!1,closedCaptions:b.closedCaptions,ce:{width:b.width,height:b.height,frameRate:b.frameRate}});b.bandwidth&&RK(d,b.bandwidth);return d})},oL=function(a){return a.w===_.Db},QL=function(a,b){return _.v(function*(){return(yield Promise.all(b.map(c=>_.v(function*(){const d=yield WL(a,c);return d?{tag:c,playlist:d}:null})))).filter(Boolean)})},tL=function(a,
|
|
56
|
+
b){return _.v(function*(){var c=new URL(b.streams[0].Ke);if(a.a.lowLatencyMode&&a.L&&a.L.$f){var d=b.streams[b.streams.length-1].segmentIndex;if(d=d.a[d.a.length-1]){var e=d.a,f=e.length-1;d={pi:d.position,Fi:e&&0<e.length?f:null}}else d=null;if(e=d)d=c.searchParams,f=e.Fi,d.set("_HLS_msn",e.pi.toString()),null===f&&d.get(lJ)&&d.delete(lJ),null!==f&&d.set(lJ,f.toString())}const {response:g,text:h}=yield hL(a,c.toString());c=b.streams[0].cb;d=b.streams[0].Ke;e=g.uri;d!==e&&(d=e,NK(b,d));c=iL(a,h,d,
|
|
57
|
+
c);return{stream:b,playlist:c}})},OL=function(a,b){var c=_.K(b,_.qa,a.a.hlsDefaultCodecs||"avc1.42E01E,mp4a.40.2").split(/\s*,\s*/);c=VJ(c);b=new Set;const d=[];for(const e of c)c=_.HB(e),b.has(c)?a.g.debug("Ignoring duplicate codec"):(d.push(e),b.add(c));return d},PL=function(a,b){if(1===b.length)return b[0];a=_.zl(a,b);if(null!=a)return a;throw new _.J(_.C,4,4025,{codecList:b});},RL=function(a,b,c){return _.v(function*(){const d=b.tag,e=b.playlist;return XL(a,e.verbatimUri,()=>_.v(function*(){const f=
|
|
58
|
+
pJ(d,_.Ea),g=GJ(pJ(d,_.rb));var h=pJ(d,_.rb).toUpperCase();if(GJ(h)!==_.I)h=null;else{var k=d.getAttribute("FORCED");k=!(!k||!k.value||"YES"!==k.value.toUpperCase());var l=_.eB;h===WI&&(l=_.NA);k&&(l=_.Ud);h=l}k=c.get(`${g}:${f}`)||"";l=_.K(d,_.Ka);const m=_.K(d,_.Sa),n=_.K(d,"DEFAULT"),p=g===_.q?YJ(d):null;var u=g===_.q?(u=_.K(d,"CHANNELS"))?u.includes("/JOC"):!1:!1;return yield JL(a,{playlist:e,codecs:k,type:g,hd:l,primary:"YES"===n,name:m,channelsCount:p,spatialAudio:u,groupId:f,kind:h,hc:null,
|
|
59
|
+
closedCaptions:null,ce:null})}))})},TL=function(a,b){return _.v(function*(){const c=b.tag,d=b.playlist;return XL(a,d.verbatimUri,()=>_.v(function*(){var e=_.K(c,_.qa)||"jpg",f=_.K(c,_.Ka);const g=_.K(c,_.Sa);e=yield JL(a,{playlist:d,codecs:e,type:_.ae,hd:f,name:g,primary:!1,kind:null,channelsCount:null,spatialAudio:!1,closedCaptions:null,hc:null,groupId:null,ce:null});(f=_.K(c,_.na))&&RK(e,Number(f));return e}))})},SL=function(a,b,c,d,e){return _.v(function*(){var f=b.tag,g=Number(pJ(f,_.na));if(f.hasAttribute("FRAME-RATE")||
|
|
60
|
+
f.hasAttribute(_.ib)){var h=_.K(f,"FRAME-RATE");f=_.K(f,_.ib);var [k,l]=f?f.split("x"):[null,null];h={frameRate:uJ(h),width:uJ(k),height:uJ(l)}}else h=null;if(f=yield YL(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 n of m)for(const p of h){m=(p?p.streams[0].cb:"")+" - "+(n?n.streams[0].cb:"");if(e.has(m)){a.g.debug("Skipping variant which only differs in text streams.");continue}const u=yL(a,n,p,g);null==u?a.g.warn("Incompatible DRM info in HLS variant. Skipping."):
|
|
61
|
+
(f.push(u),e.add(m))}g=f}else g=[];return g})},ZL=function(a,b,c,d,e,f){let g=OL(a,b);a.g.debug("Guessing stream type for",b.toString());b=!1;const h=_.zl(_.t,g),k=d+e;1!==g.length||c||h?!k&&1<g.length?(a.g.debug("Guessing multiplexed audio+video"),c=_.t,g=[g.join(",")]):d&&f?(a.g.debug(hJ),c=_.q,b=!0):e?(a.g.debug(hJ),c=_.q):(a.g.debug("Guessing video-only"),c=_.t):(c=_.q,a.g.debug(hJ));return{type:c,vh:g,gi:b}},XL=function(a,b,c){if(a.j.has(b))return a=a.j.get(b),Promise.resolve(a);if(a.j.f.has(b))return a.j.f.get(b)||
|
|
62
|
+
null;c=c();a.j.set(b,c);return c},YL=function(a,b,c,d,e){return _.v(function*(){var f=b.tag,g=b.playlist,h=_.K(f,_.wA),k=_.K(f,_.Cb);h=h?d.get(`${"audio"}:${h}`)||[]:[];k=k?d.get(`${"video"}:${k}`)||[]:[];k={audio:h,video:k};const l=g.verbatimUri;g=k.audio.find(u=>u.streams[0].cb===l);const {type:m,vh:n,gi:p}=ZL(a,f,c,k.audio.length,k.video.length,g);f=null;p||(f=yield $L(a,b,n,m,e,c));if(null==f)return null;k[m]=[f];m===_.q&&c&&k.video.forEach(u=>{OK(u,c.width);PK(u,c.height);QK(u,c.frameRate)});
|
|
63
|
+
return k})},$L=function(a,b,c,d,e,f){return _.v(function*(){const g=b.tag,h=b.playlist;return XL(a,h.verbatimUri,()=>_.v(function*(){var k=_.K(g,WI);let l=null;d===_.t&&k&&"NONE"!==k&&(l=e.get(k));k=(k=_.K(g,_.wA)||void 0)&&a.K.has(k)?k:void 0;var m=PL(d,c);if(k){const n=PL(_.q,c);m+=`,${n}`}return yield JL(a,{playlist:h,codecs:m,type:d,closedCaptions:l,primary:!1,kind:null,hd:null,name:null,channelsCount:null,spatialAudio:!1,hc:null,groupId:null,muxedAudioId:k,ce:f})}))})},ML=function(a,b,c,d){return _.v(function*(){var e=
|
|
64
|
+
b.verbatimUri,f=b.T;var g=void 0===g?0:g;var h=zJ(b.ba,dJ);var k=h?Number(h.value):g;g=[];h=null;if(a.H){a.H=!1;var l=a.B;a.B=yield aM(a,b.a,e,f,k,c,d);null!=l&&(h=a.B-l)}e=k;if(0===f.length)f=[];else{k=[];l=[];for(var m of f)yJ(m.ba,$I)&&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 bM(a,b.a,k,e,c,d,g[g.length-1]||null,h),g.push(l),e+=k.length;cM(g);return g})},WL=function(a,b){return _.v(function*(){var c=b.name!==cJ?!0:_.K(b,_.rb)===kJ;c=_.K(b,_.ub,
|
|
65
|
+
void 0,{required:c});if(!c)return null;const d=_.Dj(c,a.o),e=Date.now(),{response:f,text:g}=yield hL(a,d);a.D.onEvent(new _.H(nJ,{detail:{duration:Date.now()-e,type:"media"}}));return iL(a,g,f.uri,c)})},cM=function(a){if(1<(new Set(a.map(b=>b.mimeType))).size)throw new _.J(_.C,4,4045,"Media playlist contains discontinuities with different MIME types. This is valid, but not yet supported.");},dM=function(a,b,c){a=vJ(a.ba,bJ);if(1<a.length)throw new _.J(_.C,4,4020);a=a[0];if(!a)return null;const d=
|
|
66
|
+
pJ(a,_.ub),e=_.Dj(d,b);b=LJ(a,null,!0);return new _.BI(()=>[e],b.na,b.ka,c)},eM=function(a,b,c,d,e,f,g){const h=[];for(let p=0;p<b.f.length;p++){const u=b.f[p];var k=0===p,l=k?a:h[h.length-1],m=k?d:l.endTime,n=Number(_.K(u,YI));n=m+n;k=LJ(u,k?null:l.ka,k);l=String(_.K(u,_.ub));const x=(l=_.Dj(l,g))?[l]:[];m=new NJ(c,m,n,()=>x,k.na,k.ka,e,f,!1,null,null,null,null);if("YES"===_.K(u,"INDEPENDENT")||0===p)m.h=!0;h.push(m)}return h},fM=function(a,b,c,d,e,f,g,h,k,l,m){const n=c.ba;var p=c.a;0<vJ(n,bJ).length&&
|
|
67
|
+
(m=dM(c,k,g));var u=null!=p;const x=p?[p]:[];if(!u&&!a.a.lowLatencyMode)return null;let y=0,B={na:0,ka:null};p=null;u&&({duration:u}=JJ(n),y=e+u,B=IJ(n,b?b.ka:null));a.a.lowLatencyMode&&0<c.f.length&&(p=eM(b,c,d,e,f,g,k),0===y&&(y=p[p.length-1].endTime));a=h===_.ae?AJ(n):null;d=new NJ(d,e,y,()=>x,B.na,B.ka,f,g,!1,null,a?a.Jd:null,a?a.ae:null,a?a.durationPerTile:null,p,m);d.ma=l;return d},aM=function(a,b,c,d,e,f,g){return _.v(function*(){var h=d[0];if(!oL(a)&&a.f)try{return gM(a,c,e)}catch(n){if(h=
|
|
68
|
+
a.j.get(c)){var k=h.streams[h.streams.length-1].T;k=k[k.length-1];a.g.warn(`Last #EXT-X-MEDIA-SEQUENCE values ${h.streams[0].T[0].position} - ${k.position}`+`, new values ${e} - ${e+d.length-1}.`,b,h)}throw new _.J(_.C,4,4047,{message:"The updated playlist does not share any segments with the previous one.",uri:c});}k=yield hM(a,f,g,h);const l=IK(h.ba,a.o,e),m=dM(h,b,l);h=yield iM(a,m,h,l,k,g);a.g.debug(`Setting playlist start time to ${h}.`);return h})},bM=function(a,b,c,d,e,f,g,h){return _.v(function*(){var k=
|
|
69
|
+
c[0];const l=yield hM(a,e,f,k);var m=g?g.mi:null;if(yJ(c[0].ba,aJ)||null===m)m=FK(c,l),m=0===m.length?[BK()]:m;else{var n=FK(c,l);m=[m,...n]}n=m;m=n[n.length-1];n=CK(n);let p=g?g.ni:null;var u=jM(p,k.ba,a.o,d);let x=dM(k,b,u)||(g?g.hi:null);const y=k.ma;k=yield kM(a,y,x,k,d,u,l,f,h,null==g);u=[];let B=!1;for(let G=0;G<c.length;G++){var F=c[G];const D=u[u.length-1]||null,ka=0===G?0:D.endTime,Da=d+G,Xa=jM(p,F.ba,a.o,Da);(p=Xa)&&(B=!0);if(F=fM(a,D,F,Da,ka,k,Xa,e,b,y,x))x=F.initSegment,u.push(F)}return{T:u,
|
|
70
|
+
Ih:n,mi:m,aesEncrypted:B,mimeType:l,endTime:u[u.length-1].endTime,ma:y,hi:x,ni:p}})},gM=function(a,b,c){const d=lM(a,b,c);if(!d)throw new _.J(_.C,4,4030,"Segment not found in previous playlist update.");return a.f.periods.find(e=>e.ma===d.ma).startTime+d.startTime},hM=function(a,b,c,d){return _.v(function*(){const e=d.a;var f=zJ(d.ba,bJ);f=f?pJ(f,_.ub):null;return mM(a,b,c,e,f)})},iM=function(a,b,c,d,e,f){return _.v(function*(){if(null==c.a)return 0;const g=OJ(c,d);return KK(a.U,b,g,e,f,null!=d)})},
|
|
71
|
+
jM=function(a,b,c,d){return b.some(e=>e.name===aJ&&"NONE"===_.K(e,iJ))?null:(b=IK(b,c,d))?b:a&&a.generatedIv?Object.assign({},a,{iv:_.Tk(new Uint8Array(12),pK(d))}):a},kM=function(a,b,c,d,e,f,g,h,k,l){return _.v(function*(){if(a.C.has(b)&&l&&a.M&&null!=k){var m=a.f.periods.filter(p=>p.ma<b).map(p=>p.duration).reduce((p,u)=>p+u,0);m=k-m;const n=a.C.get(b);a.C.set(b,n+m);a.M=!1}if(a.C.has(b))return a.C.get(b);m=yield iM(a,c,d,f,g,h);a.g.debug(`Segment #${e} has raw media timestamp `+`${m} s.`);a.C.set(b,
|
|
72
|
+
m);return m})},lM=function(a,b,c){return(a=a.j.get(b))?MK(a,c)||null:null},mM=function(a,b,c,d,e){return _.v(function*(){const f=[d,e].filter(Boolean);var g=_.Cl(f,b,c);if(g)return g;g=_.fk([d],a.a.attemptParameters);g.method="HEAD";g.type=2;g=(yield a.I(g)).headers["content-type"];if(!g)throw new _.J(_.C,4,4021,"Unknown MIME type of: "+f.join(", "));return g.toLowerCase().split(";")[0]})},jL=a=>{a=_.Fj(a)||"";return null!=_.pu.video[a]?_.t:null!=_.pu.audio[a]?_.q:null},dK=class{constructor(a,b,c,
|
|
73
|
+
d){if(1===b){if(!d||0===d.length)throw new _.J(_.C,4,4043,"Media playlist must have at least one segment!");if(null==d[0].a)throw new _.J(_.C,4,4043,"Media playlist must have at least one full segment!");}this.a=a;this.verbatimUri="";this.type=b;this.ba=c;this.T=1===b?d:null}},mK=class{constructor(a,b,c){c=void 0===c?[]:c;this.ba=b;this.a=a;this.f=c;this.ma=-1}},NJ=class extends _.CI{constructor(a,b,c,d,e,f,g,h,k,l,m,n,p,u,x){u=void 0===u?[]:u;super(a,b,c,d,e,f,g,void 0===h?null:h,void 0===k?!1:k,
|
|
74
|
+
void 0===l?null:l,void 0===m?null:m,void 0===n?null:n,void 0===p?null:p,u,void 0===x?null:x);this.ma=0}},kK=/^#EXT-X-DEFINE/,lK=/^#(EXT-X-DISCONTINUITY-SEQUENCE|EXT-X-ENDLIST|EXT-X-I-FRAMES-ONLY|EXT-X-MEDIA-SEQUENCE|EXT-X-PART-INF|EXT-X-PLAYLIST-TYPE|EXT-X-SERVER-CONTROL|EXT-X-TARGETDURATION|EXT-X-DATERANGE|EXT-X-VERSION)/,nM=class{constructor(){this.h=0;this.a=new Map}},oM=class{constructor(){this.a=new Map;this.f=new Map}set(a,b){this.f.set(a,b);return b.then(c=>this.a.set(a,c)).catch(()=>{}).then(()=>
|
|
75
|
+
this.f.delete(a))}has(a){return this.a.has(a)}get(a){return this.a.get(a)||null}values(){return Array.from(this.a.values())}clear(){this.f.clear();this.a.clear()}},vL=new _.S("clpp.hls.DiscontinuityUtils");var HK={"com.apple.streamingkeydelivery":function(a,b){if(b===_.pg)throw new _.J(_.C,4,4041);if(pJ(a,iJ)===jJ)throw new _.J(_.C,4,4044,"EXT-X-KEY:METHOD SAMPLE-AES-CTR is not supported in FairPlay.");return _.yB(_.pd,[{initDataType:_.Hf,initData:new Uint8Array(0)}],"")},"com.microsoft.playready":AK,"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":AK,"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":function(a){var b=pJ(a,iJ);if(!yK.includes(b))return zK.error("Widevine in HLS is only supported with [",
|
|
76
|
+
yK.join(", "),"], not",b),null;b=pJ(a,_.ub);b=_.Uk(b);b=_.E(b.data);b=_.yB(_.td,[{initDataType:_.Vc,initData:b}],"");if(a=_.K(a,"KEYID"))b.keyIds=[a.substr(2).toLowerCase()];return b}},yK=["SAMPLE-AES",jJ],zK=new _.S("clpp.hls.DrmParser");var GK=new _.S("clpp.hls.EncryptionUtils");var pM=class{constructor(a){this.g=new _.S("clpp.hls.MediaReader");this.f=a;this.a={attemptParameters:_.ak()}}};var NL=class{constructor(a){this.streams=a}length(){return this.streams.length}Gc(){return this.streams[0].type}};var LL=class{constructor(a){this.a=a}length(){return this.a.length}};var dL=a=>{if(!a)return null;a=zJ(a.ba,eJ);if(!a)return null;a=Date.parse(a.value);return isNaN(a)?null:a};var qM=class{constructor(){this.a=this.D=null;this.h=1;this.j=new oM;this.o="";this.S=new nM;this.G=0;this.l=new _.Kh(()=>{this.ec()});this.w=_.Db;this.f=null;this.F=new _.ru;this.B=0;this.L=null;this.g=new _.S("clpp.hls.HlsParser");this.C=new Map;this.H=this.M=!1;this.U=new pM(this.I.bind(this));this.P=!1;this.J=null;this.R=!1;this.A=new Map;this.K=new Set}configure(a){this.a=a;this.U.a=a}setCurrentVariant(){}start(a,b){const c=this;return _.v(function*(){if(c.P)throw Error("start() may be called only once!");
|
|
77
|
+
c.P=!0;c.D=b;var d=Date.now();const {response:e,text:f}=yield hL(c,a);c.D.onEvent(new _.H(nJ,{detail:{duration:Date.now()-d,type:"master"}}));c.o=e.uri;d=yield sL(c,f);c.f=d;const g=c.G;c.l&&0<g&&c.l.la(g);return d})}requestStop(){this.R=!0}stop(){this.l&&(this.l.stop(),this.l=null);const a=[];this.F&&(a.push(this.F.destroy()),this.F=null);this.j.clear();this.f=this.a=this.D=null;this.A.clear();this.K.clear();return Promise.all(a)}update(){const a=this;return _.v(function*(){const b=a.f;if(!oL(a)&&
|
|
78
|
+
b){var c=b.presentationTimeline,d=Array.from(a.j.values()),e=yield uL(a,d);d=e.map(g=>g.playlist);wL(a,d);e=yield zL(a,e);TK(b.periods,e).forEach(g=>{a.D.filterNewPeriod(g)});mL(a,e);var f=AL(a,d);f=BL(a,d,f);b.cues=rL(a,f);VK(b.periods,e);gL(c,e);if(d=DJ(d))!0!==a.a.keepTimelineLive&&CL(a,c,e),a.l.stop(),a.l=null;if(a.D.onUpdate)a.D.onUpdate(b);if(d&&a.D.onTurnedStatic)a.D.onTurnedStatic();a.R&&(yield a.stop());return b}})}loadVariant(a,b){const c=this;return _.v(function*(){const d=a.id;var e=c.f.periods.find(k=>
|
|
79
|
+
k.id===b);if(e&&(e=e.variants.find(k=>k.id===d)))return e;e=c.f.alternativeVariants.find(k=>k.id===d);if(!e)throw new _.wj(`No alternative variant with id: ${d}`);var f=null,g=null;if(e.audio){const k=e.audio;f=XL(c,k.verbatimUri,()=>_.v(function*(){const l=yield UL(c,k);return VL(c,k,l)}))}if(e.video){const k=e.video;g=XL(c,k.verbatimUri,()=>_.v(function*(){const l=yield UL(c,k);return VL(c,k,l)}))}f=yield f;g=yield g;e=yL(c,f,g,e.bandwidth,e.id);let h;e&&(e=ZK(c.D.configurationId,[e],[],[],0),c.D.filterAllPeriods(e),
|
|
80
|
+
e.forEach((k,l)=>{c.f.periods[l].variants.push(k.variants[0]);b===c.f.periods[l].id&&(h=k.variants[0])}));if(!h)throw new _.wj(`Could load variant with id: ${d}`);return h})}loadTextStream(a,b){const c=this;return _.v(function*(){let d;var e=c.f.periods.find(f=>f.id===b);e&&(e=e.textStreams.find(f=>f.id===a)||null)&&(d=e);if(!d&&c.f.alternativeTextStreams){const f=c.f.alternativeTextStreams.find(h=>h.id===a)||null;if(!f)throw new _.wj(`Could not load text stream with id: ${a}`);const g=yield XL(c,
|
|
81
|
+
f.verbatimUri,()=>_.v(function*(){const h=yield UL(c,f);wL(c,[h]);return VL(c,f,h)}));g&&c.f.periods.forEach((h,k)=>{h=g.streams[k];c.f.periods[k].textStreams.push(h);h.id===a&&(d=h)})}if(!d)throw new _.wj(`Could not load text stream with id: ${a}`);return d})}ec(){const a=this;return _.v(function*(){a.g.debug(_.IA);if(a.D)try{yield a.update(),a.l&&0<a.G&&a.l.la(a.G)}catch(b){if(!(b instanceof _.J))throw b;a.D&&(a.D.onError(b),1===b.severity&&a.l&&a.l.la(.1))}})}I(a){if(!this.F)throw new _.J(_.C,
|
|
82
|
+
7,7001);a=this.D.networkingEngine.fetch(a);_.wk(this.F,a);return a.V}};_.w("clpp.hls.HlsComponent",class extends _.Fv{install(){_.Nt.m3u8=qM;_.Mt[_.lm]=qM;_.Mt[mJ]=qM}uninstall(){_.YC("m3u8");_.ZC(_.lm);_.ZC(mJ)}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.g.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 eU=function(a){a.a.one(a.m,_.ke,()=>dU(a))},dU=function(a){const b=a.m.getSurface().getMedia();if(b)if(a.h){a.a.on(b.textTracks,_.nc,d=>fU(a,d));var c=Array.from(b.textTracks);c.filter(d=>d.kind===_.re).forEach(d=>{fU(a,{track:d})});!gU(c)&&a.l&&(a.g.warn("The metadata track is not present. Changing an audio track in order to enforce the creation of the metadata track."),hU(a,b))}else a.g.warn("The clpp.ttml.TextParser class is not available. Please register the ttml component first.");
|
|
2
|
+
else a.g.warn("A video element is not available. Skipping.")},fU=function(a,b){b=b.track;b.kind===_.re&&(a.g.info("The metadata track has been added."),b.mode=_.Yd,a.a.on(b,_.wd,c=>iU(a,c)))},gU=function(a){return a.some(b=>b.kind===_.re)},hU=function(a,b){const c=a.m.getTrackManager(),d=c.ra(),e=c.getAudioTracks().find(g=>g!==d);if(e){var f=()=>c.za(d);a.a.on(b.textTracks,_.nc,g=>{g.track.kind===_.re&&(a.a.off(b.textTracks,_.nc,f),c.za(d))});c.za(e)}else a.g.warn("Can't enforce the creation of the metadata track if single audio track. Skipping.")},
|
|
3
|
+
iU=function(a,b){const c=jU(a);c&&Array.from(b.target.activeCues||[]).forEach(d=>{if(d!==a.f&&Number.isFinite(d.startTime)&&Number.isFinite(d.endTime)&&"org.id3"===d.type&&d.value&&"TXXX"===d.value.key){var e=new kU(d);if(e.f===c&&null!==e.a){a.f=d;d=a.h.parseMedia(_.Ai(e.a),{periodStart:a.j,segmentStart:e.startTime,segmentEnd:e.endTime});const f=a.m.getTextDisplayer();f.remove(0,e.startTime);f.append(d.cues,d.styles)}}})},jU=function(a){return(a=a.m.getTrackManager().ua())&&a.language&&a.language.toLowerCase()},
|
|
4
|
+
kU=class{constructor(a){this.startTime=a.startTime;this.endTime=a.endTime;this.a=this.f=null;a=a.value;if(!_.z(a)){a:{var b=a.info;if(_.dh(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=_.dh(a)?a:null}}};var lU=class{constructor(a,b,c){this.m=a;this.l=b;this.j=c;this.a=new _.Ut;this.h=(a=_.Dt(_.Ac))?new a(this.m.getConfiguration()):null;this.g=new _.S("clpp.hlssmpte.ImageCueHandler");this.f=null;eU(this)}destroy(){this.a.release();this.f=null;return Promise.resolve()}};var mU=class extends _.$v{constructor(){super();this.a=null;this.f=!1}onPlayerCreated(){}onContentWillLoad(a){if(this.f=_.Zh()){var b=a.getConfiguration();b=_.Yg(b.hlssmpte||{});typeof b.patchMetadataTrack!==_.Mc&&(b.patchMetadataTrack=!1);_.eh(b.timestampOffset)||(b.timestampOffset=0);this.a=new lU(a,b.patchMetadataTrack,b.timestampOffset)}}onPlayerWillDestroy(){const a=this;return _.v(function*(){a.a&&(yield a.a.destroy(),a.a=null)})}id(){return"hlssmpte"}};_.w("clpp.hlssmpte.HlsSmptePlugin",mU);
|
|
5
|
+
mU.Id="hlssmpte";_.Tr(new class{create(){return new mU}});};f.call(g, window);
|
package/cl.htmlcue.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var
|
|
2
|
-
b=b[1]?b[1]:b[2];a.input=a.input.substr(b.length);return b},
|
|
3
|
-
function(a,b){return 1>Math.abs(a-b)||a>b},
|
|
4
|
-
d-e)},
|
|
5
|
-
function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return
|
|
6
|
-
_.r)switch(b){case _.ge:return a.f.position;case "auto":case _.Wc:return a.f.position-a.f.size/2;case _.he:return a.f.position-a.f.size}return 0},
|
|
7
|
-
|
|
8
|
-
a.viewportAnchorUnits;if(d===_.
|
|
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)},
|
|
10
|
-
a.o=[]}},
|
|
11
|
-
d;!(d=b)&&(d=a.J!==c)&&(d=a.m instanceof _.R?3===a.m.getState():8===a.m.getState());if(d&&(a.J=c,c=
|
|
12
|
-
|
|
13
|
-
f),c.a.appendChild(f)));d=new
|
|
14
|
-
b.classList.remove(
|
|
15
|
-
else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=
|
|
16
|
-
"\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var
|
|
17
|
-
_.vg?b=(new
|
|
18
|
-
!this.f.region.displayAlign){e=
|
|
19
|
-
100*a)}
|
|
20
|
-
d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=
|
|
21
|
-
_.pf),height:
|
|
22
|
-
b=c;f*=b;break a;default:throw Error(
|
|
23
|
-
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.v(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],
|
|
24
|
-
this.G=new _.
|
|
25
|
-
a.l=!1)})}remove(a,b){if(null==this.j)return!1;this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;
|
|
26
|
-
|
|
1
|
+
import {clpp} from "./cl.core.js";let g={};const _ = clpp._;var f=function(window){'use strict';var WS="Unsupported unit",XS="clpp-text-plain",YS="clpp-text-ttml",ZS="clpp.htmlcue.HtmlTextDisplayer",$S="initial",aT=function(a){return _.rj(a,{dg:(b,c)=>b.Xc(c)})},bT=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)},cT=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},dT=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},fT=function(a){let b=null;for(;b=a.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)a=a.replace(b[0],c=>eT[c]);return a},hT=function(a,b){gT(a,b);Array.from(b.getElementsByTagName("*")).forEach(c=>{gT(a,c)})},gT=function(a,b){for(const c in a)null!=a[c]&&(b.style[c]=a[c])},iT=function(a,b){return 0===a?"0":a+b},jT=function(a,b){return 1>Math.abs(a-b)||a<b},kT=function(a,b){return a<b&&1<Math.abs(a-b)},lT=function(a,b){return a>b&&1<Math.abs(a-b)},mT=
|
|
3
|
+
function(a,b){return 1>Math.abs(a-b)||a>b},oT=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 nT(b.left+d,b.right+e,g,(b.bottom||g+f)+c,f,(b.width||a.offsetWidth)-
|
|
4
|
+
d-e)},pT=function(a){return new nT(a.left,a.f,a.top,a.a,a.height,a.width)},qT=function(a,b){return b.some(c=>kT(a.left,c.f)&&lT(a.f,c.left)&&kT(a.top,c.a)&&lT(a.a,c.top))},rT=function(a,b){return mT(a.top,b.top)&&jT(a.a,b.a)&&mT(a.left,b.left)&&jT(a.f,b.f)},sT=function(a,b,c){switch(c){case "+x":return kT(a.left,b.left);case "-x":return lT(a.f,b.f);case "+y":return kT(a.top,b.top);case "-y":return lT(a.a,b.a);default:throw Error("Unknown axis");}},tT=function(a){return a.f.writingMode===_.bu},uT=
|
|
5
|
+
function(a){var b=a.a.childNodes[0],c=a.a.getBoundingClientRect();const d=b.getClientRects();b=c.height/d.length;c=c.width/d.length;return tT(a)?b:c},vT=function(a){switch(a.f.writingMode){case _.bu:return"horizontal-tb";case _.ng:return _.ng;case _.og:return _.og;default:throw Error("Unknown writing mode");}},wT=function(a){switch(a.f.positionAlign){case _.ge:return _.de;case "auto":case _.Wc:return _.au;case _.he:return _.xf}return a.f.textAlign},xT=function(a,b){if(typeof a.f.position===_.r&&typeof a.f.size===
|
|
6
|
+
_.r)switch(b){case _.ge:return a.f.position;case "auto":case _.Wc:return a.f.position-a.f.size/2;case _.he:return a.f.position-a.f.size}return 0},yT=function(a){if(!a.f.positionAlign)switch(a.f.textAlign){case _.Kf:case _.de:return _.ge;case _.au:return _.Wc;case _.Qd:case _.xf:return _.he}return a.f.positionAlign},BT=function(a,b,c){return(zT(a)||AT(a))&&_.eh(c)?iT(c,_.pf):zT(a)&&_.z(c)?iT(0,_.pf):tT(a)&&_.eh(b)?iT(b,"%"):$S},CT=function(a,b,c){return tT(a)&&_.eh(c)?iT(c,_.pf):(zT(a)||AT(a))&&_.eh(b)?
|
|
7
|
+
iT(b,"%"):$S},AT=function(a){return a.f.writingMode===_.og},zT=function(a){return a.f.writingMode===_.ng},DT=function(a,b){if(a.j)switch(b.writingMode){case _.bu:return["-y"];case _.ng:return["+x"];case _.og:return["-x"]}a=[];switch(b.writingMode){case _.bu:a=["+y","-y"];break;case _.ng:a=["+x","-x"];break;case _.og:a=["-x","+x"]}0>b.line&&(a=a.reverse());return a},ET=function(a){for(a.h=[];0<a.f.childNodes.length;)a.f.removeChild(a.f.childNodes[0]);a.a=oT(a.l.a)},FT=function(a,b,c){a=a.f;const d=
|
|
8
|
+
a.viewportAnchorUnits;if(d===_.iu)return a.viewportAnchorY/100*c-a.regionAnchorY/100*b;if(0===d)return a.viewportAnchorY-a.regionAnchorY;throw Error(WS);},HT=function(a,b,c,d){const e=document.createElement(_.Qf),f=e.dataset;f.name=b;f.for=c;d&&(f.name=`${b} (sandbox)`,f.sandbox=!0);c=document.head;c.appendChild(e);GT(a,c,b);a.g.debug(`Created HTML style element #${b}.`);return e.sheet},IT=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)},JT=function(a,b){let c=!1;try{a.f.insertRule(b,0);const d=a.f.cssRules[0];d instanceof CSSStyleRule&&(c=d.selectorText.split(",").every(e=>0===e.trim().indexOf(`.${a.j} `)))}catch(d){}0<a.f.cssRules.length&&a.f.deleteRule(0);return c},KT=function(a){if(null!=a.a){for(;0<a.a.cssRules.length;)a.a.deleteRule(0);
|
|
10
|
+
a.o=[]}},GT=function(a,b,c){const d=new MutationObserver(e=>{e.forEach(f=>{f.removedNodes.forEach(g=>{g.id===c&&a.g.error(`PRESTOplay HTML style element #${c} has `+"been unexpectedly removed! Some styles will not work!")})})});d.observe(b,{subtree:!1,childList:!0});a.l.push(()=>d.disconnect())},LT=function(a){a=_.Yg(a.htmlcue||{});_.z(a.stretchSmpteImage)&&(a.stretchSmpteImage=!1);_.z(a.enableResizeObserver)&&(a.enableResizeObserver=!0);return a},RT=function(a,b){if((b||a.l)&&a.F){var c=a.m.getPosition(),
|
|
11
|
+
d;!(d=b)&&(d=a.J!==c)&&(d=a.m instanceof _.R?3===a.m.getState():8===a.m.getState());if(d&&(a.J=c,c=MT(a,c),b||(b=a.o,b=!(null===b&&null===c||null!==b&&null!==c&&b.start===c.start&&b.end===c.end)),b&&(a.o=c,NT(a),c))){b={color:a.getFontColor()||void 0,backgroundColor:a.getBackgroundColor()||void 0,fontFamily:a.getFontFamily()||void 0,textShadow:_.Jt(a)||void 0};c=a.f.slice(c.start,c.end+1);for(const k of c){c=a;d=k;var e=b,f=c.a.a,g=null;switch(d.payloadType){case _.vg:g="clpp-text-vtt";break;case _.cg:g=
|
|
12
|
+
YS;break;case _.$t:g=XS}g&&!f.classList.contains(g)&&_.Fp(f,g);f=oT(c.a.a);if(0===f.width||0===f.height)c.g.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{gT({fontSize:OT(c,d.containerRows)},c.a.a);f=null;g=d.payloadType===_.vg;var h=d.payloadType===_.cg;d.region&&(g||h||d.backgroundImage)&&(c.B.has(d.region.id)?f=c.B.get(d.region.id):(f=new PT(d.region,{}),c.B.set(d.region.id,
|
|
13
|
+
f),c.a.appendChild(f)));d=new QT(d,c.L,e);f?f.appendChild(d):c.a.appendChild(d)}}}}},ST=function(a){NT(a);a.J=null;a.o=null;a.f=[]},TT=function(a,b){return a.startTime<=b&&a.endTime>b},MT=function(a,b){var c=cT(a.f,d=>TT(d,b)?0:b!==d.startTime?b-d.startTime:b-d.endTime);if(-1===c)return null;{let d=c;for(;0<=d-1&&TT(a.f[d-1],b);)d--;for(;c+1<a.f.length&&TT(a.f[c+1],b);)c++;return{start:d,end:c}}},NT=function(a){a.B.clear();if(a.a){const b=a.a.a;b.classList.remove("clpp-text-vtt");b.classList.remove(YS);
|
|
14
|
+
b.classList.remove(XS);a=a.a;ET(a.h);a.l=[]}},OT=function(a,b){const c=oT(a.a.a).height;if(null!==a.I)return a.getFontSize();if(null!==a.C)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`},XT=class{parse(a){a={input:a};const b=_.Hp(_.Ad),c=[];let d=b;for(var e;null!==(e=dT(a));)if("\x3c"===e[0])if("/"===e[1])c.length&&c[c.length-1]===e.substr(2).replace("\x3e","")&&(c.pop(),d=d.parentNode);
|
|
15
|
+
else{if(e=e.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/)){var f=e[1];var g=e[3];var h=UT[f];h?(h=_.Hp(h),(f=VT[f])&&g&&h.setAttribute(f,g.trim()),g=h):g=null;!g||WT[g.localName]&&WT[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(fT(e)));return b}},UT={c:"c",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"v",lang:"lang"},VT={v:"voice",lang:"lang"},WT={rt:"ruby"},eT={"\x26amp;":"\x26",
|
|
16
|
+
"\x26lt;":"\x3c","\x26gt;":"\x3e","\x26lrm;":"\u200e","\x26rlm;":"\u200f","\x26nbsp;":"\u00a0"};var nT=class{constructor(a,b,c,d,e,f){this.left=a;this.f=b;this.top=c;this.a=d;this.height=e;this.width=f}};var YT=class{constructor(a,b,c){this.id=a;this.w=b;this.B=c;this.a=this.o();this.j=!1}init(){this.j=!0}A(){return!1}};var QT=class extends YT{constructor(a,b,c){super(a.id,"clpp-text-cue",{});this.l=b;this.f=a;this.h=!!this.f.backgroundImage;this.C=c}A(){return!this.h&&!(this.f.region&&this.f.region.displayAlign)}init(a){super.init(a);if(this.h)_.Fp(this.a,"clpp-text-cue-image"),this.a.style.backgroundImage=`url("${this.f.backgroundImage}")`,this.l.stretchSmpteImage&&(this.a.style.backgroundSize="contain");else if(a){var b=this.f;if(b.payloadType===_.cg){var c=_.Hp(_.Ad);c.innerHTML=b.payload;b=c}else b.payloadType===
|
|
17
|
+
_.vg?b=(new XT).parse(b.payload):(c=_.Hp(_.Ad),c.textContent=b.payload,b=c);_.Fp(b,this.w);this.id&&(b.id=this.id);for(d of this.f.cssClassList)_.Fp(b,d);gT({writingMode:vT(this)},b);var d=b;this.a.appendChild(d);_.Fp(this.a,"clpp-text-wrapper");for(var e of this.f.cssClassList)_.Fp(this.a,`clpp-text-wrapper__${e}`);_.z(this.f.line)&&(this.f.lineInterpretation=_.cu,this.f.line=tT(this)?-1:0);e=vT(this);gT({writingMode:e,webkitWritingMode:e,direction:$S,textAlign:wT(this)},this.a);if(!this.f.region||
|
|
18
|
+
!this.f.region.displayAlign){e=xT(this,yT(this));gT({position:"absolute",left:BT(this,e,null),right:AT(this)&&_.z(null)?iT(0,_.pf):$S,top:CT(this,e,null),width:tT(this)?iT(this.f.size,"%"):$S,height:zT(this)||AT(this)?iT(this.f.size,"%"):$S},this.a);b=this.f;a=tT(this)?a.height:a.width;c=uT(this);if(b.lineInterpretation===_.cu){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 _.Wc:g-=f/2;break;case _.Qd:g-=f}f=Math.round(g/
|
|
19
|
+
100*a)}AT(this)&&(f=a-f-c);a=f;gT({left:BT(this,e,a),right:AT(this)&&_.z(a)?iT(0,_.pf):$S,top:CT(this,e,a)},this.a)}hT(this.C,d)}}o(){return _.Hp(_.Ad)}};var ZT=class{constructor(a,b){this.l=a;this.f=a.a;this.j=void 0===b?!1:b;this.a=oT(a.a);this.h=[]}append(a){const b=a.a;b.style.visibility=_.Yd;this.f.appendChild(b);a.j||a.init(this.a);if(a.A()){a:{var c=oT(a.a);var d=DT(this,a.f),e=uT(a);const g=pT(c);let h=null,k=0;for(const l of d){for(;sT(c,this.a,l)||rT(c,this.a)&&qT(c,this.h);){d=c;var f=e;switch(l){case "+x":d.left+=f;d.f+=f;break;case "-x":d.left-=f;d.f-=f;break;case "+y":d.top+=f;d.a+=f;break;case "-y":d.top-=f,d.a-=f}}if(this.j||rT(c,this.a))break a;
|
|
20
|
+
d=this.a;d=Math.max(0,Math.min(c.f,d.f)-Math.max(c.left,d.left))*Math.max(0,Math.min(c.a,d.a)-Math.max(c.top,d.top))/(c.height*c.width);d>k&&(h=pT(c),k=d);c=pT(g)}c=h||g}gT({top:iT(c.top-this.a.top,_.pf),bottom:iT(this.a.a-c.a,_.pf),left:iT(c.left-this.a.left,_.pf),right:iT(this.a.f-c.f,_.pf),height:iT(c.height,_.pf),width:iT(c.width,_.pf)},a.a)}b.style.visibility="visible";this.h.push(oT(a.a))}};var $T=class extends YT{constructor(a,b,c){super(a,b,c);this.h=null;this.l=[]}init(){this.h=new ZT(this);this.j=!0}o(){const a=_.Hp(_.Ad);_.Fp(a,this.w);this.id&&(a.id=this.id);return a}appendChild(a){ET(this.h);this.l.unshift(a);for(const b of this.l)this.h.append(b)}};var PT=class extends $T{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 _.iu:b=b.width/100*a.width;break a;default:throw Error(WS);}}var c=this.f;var d=c.viewportAnchorUnits;if(d===_.iu)c=c.viewportAnchorX/100*a.width-c.regionAnchorX/100*b;else if(0===d)c=c.viewportAnchorX-c.regionAnchorX;else throw Error(WS);d=a.height;const e=FT(this,d,a.height);gT(this.B,this.a);gT({left:iT(c,_.pf),top:iT(e,_.pf),width:iT(b,
|
|
21
|
+
_.pf),height:iT(d,_.pf)},this.a);this.f.writingMode&&gT({display:"flex","flex-direction":this.f.writingMode},this.a);this.f.displayAlign&&gT({"justify-content":this.f.displayAlign},this.a);for(var f of this.f.cssClassList)_.Fp(this.a,f);a:switch(f=this.f,f.heightUnits){case 0:f=f.height;break a;case _.iu:f=f.height/100*a.height;break a;case 2:f=f.height;c=new QT(new _.fu(0,1,"Lorem ipsum",_.$t),{},{});b=c.a;this.a.appendChild(b);c.init(oT(this.a));c=b.getBoundingClientRect().height;this.a.removeChild(b);
|
|
22
|
+
b=c;f*=b;break a;default:throw Error(WS);}a=FT(this,f,a.height);gT({top:iT(a,_.pf),height:iT(f,_.pf)},this.a);this.h=new ZT(this,!0);this.j=!0}getId(){return this.f.id}};var aU=class{constructor(a,b){this.g=new _.S("clpp.htmlcue.StyleManager");this.l=[];this.j=a;this.h=b;this.o=[];this.a=HT(this,this.h,this.j);this.f=HT(this,this.h,this.j,!0);this.f.disabled=!0;this.g.debug(`Stylesheet ${this.h} has been created.`)}appendRule(a){if(null!=this.a&&!this.o.some(b=>b===a)){const b=IT(this,a);if(JT(this,b)){try{this.a.insertRule(b,this.a.cssRules.length),this.g.debug(`Added CSS rule ${b}`)}catch(c){this.g.error(`An error occurred when adding a CSS rule: ${b}`)}this.o.push(a)}else this.g.warn(`Stylesheet ${this.h} ignoring the CSS rule `+
|
|
23
|
+
`because it's not safe: ${b}`)}}destroy(){const a=this;return _.v(function*(){null!=a.a&&(a.l.forEach(b=>b()),a.l=[],KT(a),document.head.removeChild(a.a.ownerNode),document.head.removeChild(a.f.ownerNode),a.a=null,a.f=null,a.g.debug(`Stylesheet ${a.h} has been destroyed.`))})}};var bU=class extends _.Sv{constructor(a){super(a);this.g=new _.S(ZS);this.m=a;this.L=LT(a.getConfiguration());this.l=!1;this.f=[];this.F=a.getSurface().getContainer();this.j=new aU(a.getSurface().getUniqueCssClass(),"CLPP Subtitle Styles");this.a=new $T(null,"clpp-text-container",{});this.A=new _.Ov(a.getSurface(),this.S.bind(this));this.J=null;this.F?(this.F.appendChild(this.a.a),this.a.init(null)):this.g.warn("No container element! Subtitles will not appear. Please check your player surface configuration or switch to NativeTextDisplayer.");
|
|
24
|
+
this.G=new _.Kh(()=>{RT(this)});this.B=new Map;this.o=null}getClass(){return _.Zd}isRenderer(){return!0}append(a,b){if(null!=this.j&&0!==a.length){for(const c of b)this.j.appendRule(c);a.sort((c,d)=>c.startTime!==d.startTime?c.startTime-d.startTime:c.endTime-d.endTime);this.f=bT(this.f,aT(a));this.o=null;RT(this,!1)}}h(){null==this.j||RT(this,!0)}destroy(){const a=this;return _.v(function*(){null!=a.j&&(ST(a),a.G.stop(),yield a.j.destroy(),a.j=null,a.F.removeChild(a.a.a),a.a=null,a.A.stop(),a.A=null,
|
|
25
|
+
a.l=!1)})}remove(a,b){if(null==this.j)return!1;this.f=this.f.filter(c=>c.startTime<a||c.endTime>=b);this.o=null;RT(this,!0);return!0}isTextVisible(){return this.l}setTextVisibility(a){null!=this.j&&this.l!==a&&((this.l=a)?(this.G.Hb(.25),this.L.enableResizeObserver&&this.A.start(),RT(this,!0)):(this.G.stop(),this.A.stop(),ST(this)))}S(){RT(this,!0)}};_.w(ZS,bU);bU.prototype.setTextVisibility=bU.prototype.setTextVisibility;bU.prototype.isTextVisible=bU.prototype.isTextVisible;bU.prototype.remove=bU.prototype.remove;
|
|
26
|
+
bU.prototype.destroy=bU.prototype.destroy;bU.prototype.append=bU.prototype.append;var cU=class{a(a){return!!a.enableHtmlCue&&!_.ai()}create(a){return new bU(a)}};_.w("clpp.htmlcue.HtmlCueComponent",class extends _.Fv{install(){_.To(_.Zd,new cU)}uninstall(){_.Ro.has(_.Zd)&&(_.Ro.delete(_.Zd),_.So.info("Removed factory: 'html'"))}id(){return"subtitles-htmlcue"}});};f.call(g, window);
|