@gamelearn/arcade-components 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arcade-components.cjs +1 -1
- package/dist/arcade-components.js +16 -13
- package/package.json +1 -2
|
@@ -49,7 +49,7 @@ object-assign
|
|
|
49
49
|
*/var objectAssign,hasRequiredObjectAssign;function requireObjectAssign(){if(hasRequiredObjectAssign)return objectAssign;hasRequiredObjectAssign=1;var o=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function t(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function n(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var l={},u=0;u<10;u++)l["_"+String.fromCharCode(u)]=u;var f=Object.getOwnPropertyNames(l).map(function(h){return l[h]});if(f.join("")!=="0123456789")return!1;var d={};return"abcdefghijklmnopqrst".split("").forEach(function(h){d[h]=h}),Object.keys(Object.assign({},d)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return objectAssign=n()?Object.assign:function(a,l){for(var u,f=t(a),d,h=1;h<arguments.length;h++){u=Object(arguments[h]);for(var y in u)e.call(u,y)&&(f[y]=u[y]);if(o){d=o(u);for(var E=0;E<d.length;E++)r.call(u,d[E])&&(f[d[E]]=u[d[E]])}}return f},objectAssign}var ReactPropTypesSecret_1$1,hasRequiredReactPropTypesSecret$1;function requireReactPropTypesSecret$1(){if(hasRequiredReactPropTypesSecret$1)return ReactPropTypesSecret_1$1;hasRequiredReactPropTypesSecret$1=1;var o="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ReactPropTypesSecret_1$1=o,ReactPropTypesSecret_1$1}var has,hasRequiredHas;function requireHas(){return hasRequiredHas||(hasRequiredHas=1,has=Function.call.bind(Object.prototype.hasOwnProperty)),has}var checkPropTypes_1$1,hasRequiredCheckPropTypes$1;function requireCheckPropTypes$1(){if(hasRequiredCheckPropTypes$1)return checkPropTypes_1$1;hasRequiredCheckPropTypes$1=1;var o=function(){};if(process.env.NODE_ENV!=="production"){var e=requireReactPropTypesSecret$1(),r={},t=requireHas();o=function(a){var l="Warning: "+a;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function n(a,l,u,f,d){if(process.env.NODE_ENV!=="production"){for(var h in a)if(t(a,h)){var y;try{if(typeof a[h]!="function"){var E=Error((f||"React class")+": "+u+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw E.name="Invariant Violation",E}y=a[h](l,h,f,u,null,e)}catch(_){y=_}if(y&&!(y instanceof Error)&&o((f||"React class")+": type specification of "+u+" `"+h+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof y+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),y instanceof Error&&!(y.message in r)){r[y.message]=!0;var p=d?d():"";o("Failed "+u+" type: "+y.message+(p??""))}}}}return n.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(r={})},checkPropTypes_1$1=n,checkPropTypes_1$1}var factoryWithTypeCheckers$1,hasRequiredFactoryWithTypeCheckers$1;function requireFactoryWithTypeCheckers$1(){if(hasRequiredFactoryWithTypeCheckers$1)return factoryWithTypeCheckers$1;hasRequiredFactoryWithTypeCheckers$1=1;var o=requireReactIs(),e=requireObjectAssign(),r=requireReactPropTypesSecret$1(),t=requireHas(),n=requireCheckPropTypes$1(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(u){var f="Warning: "+u;typeof console<"u"&&console.error(f);try{throw new Error(f)}catch{}});function l(){return null}return factoryWithTypeCheckers$1=function(u,f){var d=typeof Symbol=="function"&&Symbol.iterator,h="@@iterator";function y(I){var B=I&&(d&&I[d]||I[h]);if(typeof B=="function")return B}var E="<<anonymous>>",p={array:C("array"),bigint:C("bigint"),bool:C("boolean"),func:C("function"),number:C("number"),object:C("object"),string:C("string"),symbol:C("symbol"),any:R(),arrayOf:S,element:A(),elementType:T(),instanceOf:w,node:D(),objectOf:O,oneOf:P,oneOfType:k,shape:G,exact:V};function _(I,B){return I===B?I!==0||1/I===1/B:I!==I&&B!==B}function g(I,B){this.message=I,this.data=B&&typeof B=="object"?B:{},this.stack=""}g.prototype=Error.prototype;function x(I){if(process.env.NODE_ENV!=="production")var B={},X=0;function Q(ne,ae,Z,se,oe,fe,de){if(se=se||E,fe=fe||Z,de!==r){if(f){var ce=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw ce.name="Invariant Violation",ce}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Ee=se+":"+Z;!B[Ee]&&X<3&&(a("You are manually calling a React.PropTypes validation function for the `"+fe+"` prop on `"+se+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),B[Ee]=!0,X++)}}return ae[Z]==null?ne?ae[Z]===null?new g("The "+oe+" `"+fe+"` is marked as required "+("in `"+se+"`, but its value is `null`.")):new g("The "+oe+" `"+fe+"` is marked as required in "+("`"+se+"`, but its value is `undefined`.")):null:I(ae,Z,se,oe,fe)}var J=Q.bind(null,!1);return J.isRequired=Q.bind(null,!0),J}function C(I){function B(X,Q,J,ne,ae,Z){var se=X[Q],oe=q(se);if(oe!==I){var fe=z(se);return new g("Invalid "+ne+" `"+ae+"` of type "+("`"+fe+"` supplied to `"+J+"`, expected ")+("`"+I+"`."),{expectedType:I})}return null}return x(B)}function R(){return x(l)}function S(I){function B(X,Q,J,ne,ae){if(typeof I!="function")return new g("Property `"+ae+"` of component `"+J+"` has invalid PropType notation inside arrayOf.");var Z=X[Q];if(!Array.isArray(Z)){var se=q(Z);return new g("Invalid "+ne+" `"+ae+"` of type "+("`"+se+"` supplied to `"+J+"`, expected an array."))}for(var oe=0;oe<Z.length;oe++){var fe=I(Z,oe,J,ne,ae+"["+oe+"]",r);if(fe instanceof Error)return fe}return null}return x(B)}function A(){function I(B,X,Q,J,ne){var ae=B[X];if(!u(ae)){var Z=q(ae);return new g("Invalid "+J+" `"+ne+"` of type "+("`"+Z+"` supplied to `"+Q+"`, expected a single ReactElement."))}return null}return x(I)}function T(){function I(B,X,Q,J,ne){var ae=B[X];if(!o.isValidElementType(ae)){var Z=q(ae);return new g("Invalid "+J+" `"+ne+"` of type "+("`"+Z+"` supplied to `"+Q+"`, expected a single ReactElement type."))}return null}return x(I)}function w(I){function B(X,Q,J,ne,ae){if(!(X[Q]instanceof I)){var Z=I.name||E,se=$(X[Q]);return new g("Invalid "+ne+" `"+ae+"` of type "+("`"+se+"` supplied to `"+J+"`, expected ")+("instance of `"+Z+"`."))}return null}return x(B)}function P(I){if(!Array.isArray(I))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):a("Invalid argument supplied to oneOf, expected an array.")),l;function B(X,Q,J,ne,ae){for(var Z=X[Q],se=0;se<I.length;se++)if(_(Z,I[se]))return null;var oe=JSON.stringify(I,function(de,ce){var Ee=z(ce);return Ee==="symbol"?String(ce):ce});return new g("Invalid "+ne+" `"+ae+"` of value `"+String(Z)+"` "+("supplied to `"+J+"`, expected one of "+oe+"."))}return x(B)}function O(I){function B(X,Q,J,ne,ae){if(typeof I!="function")return new g("Property `"+ae+"` of component `"+J+"` has invalid PropType notation inside objectOf.");var Z=X[Q],se=q(Z);if(se!=="object")return new g("Invalid "+ne+" `"+ae+"` of type "+("`"+se+"` supplied to `"+J+"`, expected an object."));for(var oe in Z)if(t(Z,oe)){var fe=I(Z,oe,J,ne,ae+"."+oe,r);if(fe instanceof Error)return fe}return null}return x(B)}function k(I){if(!Array.isArray(I))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var B=0;B<I.length;B++){var X=I[B];if(typeof X!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+U(X)+" at index "+B+"."),l}function Q(J,ne,ae,Z,se){for(var oe=[],fe=0;fe<I.length;fe++){var de=I[fe],ce=de(J,ne,ae,Z,se,r);if(ce==null)return null;ce.data&&t(ce.data,"expectedType")&&oe.push(ce.data.expectedType)}var Ee=oe.length>0?", expected one of type ["+oe.join(", ")+"]":"";return new g("Invalid "+Z+" `"+se+"` supplied to "+("`"+ae+"`"+Ee+"."))}return x(Q)}function D(){function I(B,X,Q,J,ne){return W(B[X])?null:new g("Invalid "+J+" `"+ne+"` supplied to "+("`"+Q+"`, expected a ReactNode."))}return x(I)}function F(I,B,X,Q,J){return new g((I||"React class")+": "+B+" type `"+X+"."+Q+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+J+"`.")}function G(I){function B(X,Q,J,ne,ae){var Z=X[Q],se=q(Z);if(se!=="object")return new g("Invalid "+ne+" `"+ae+"` of type `"+se+"` "+("supplied to `"+J+"`, expected `object`."));for(var oe in I){var fe=I[oe];if(typeof fe!="function")return F(J,ne,ae,oe,z(fe));var de=fe(Z,oe,J,ne,ae+"."+oe,r);if(de)return de}return null}return x(B)}function V(I){function B(X,Q,J,ne,ae){var Z=X[Q],se=q(Z);if(se!=="object")return new g("Invalid "+ne+" `"+ae+"` of type `"+se+"` "+("supplied to `"+J+"`, expected `object`."));var oe=e({},X[Q],I);for(var fe in oe){var de=I[fe];if(t(I,fe)&&typeof de!="function")return F(J,ne,ae,fe,z(de));if(!de)return new g("Invalid "+ne+" `"+ae+"` key `"+fe+"` supplied to `"+J+"`.\nBad object: "+JSON.stringify(X[Q],null," ")+`
|
|
50
50
|
Valid keys: `+JSON.stringify(Object.keys(I),null," "));var ce=de(Z,fe,J,ne,ae+"."+fe,r);if(ce)return ce}return null}return x(B)}function W(I){switch(typeof I){case"number":case"string":case"undefined":return!0;case"boolean":return!I;case"object":if(Array.isArray(I))return I.every(W);if(I===null||u(I))return!0;var B=y(I);if(B){var X=B.call(I),Q;if(B!==I.entries){for(;!(Q=X.next()).done;)if(!W(Q.value))return!1}else for(;!(Q=X.next()).done;){var J=Q.value;if(J&&!W(J[1]))return!1}}else return!1;return!0;default:return!1}}function ee(I,B){return I==="symbol"?!0:B?B["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&B instanceof Symbol:!1}function q(I){var B=typeof I;return Array.isArray(I)?"array":I instanceof RegExp?"object":ee(B,I)?"symbol":B}function z(I){if(typeof I>"u"||I===null)return""+I;var B=q(I);if(B==="object"){if(I instanceof Date)return"date";if(I instanceof RegExp)return"regexp"}return B}function U(I){var B=z(I);switch(B){case"array":case"object":return"an "+B;case"boolean":case"date":case"regexp":return"a "+B;default:return B}}function $(I){return!I.constructor||!I.constructor.name?E:I.constructor.name}return p.checkPropTypes=n,p.resetWarningCache=n.resetWarningCache,p.PropTypes=p,p},factoryWithTypeCheckers$1}var factoryWithThrowingShims$1,hasRequiredFactoryWithThrowingShims$1;function requireFactoryWithThrowingShims$1(){if(hasRequiredFactoryWithThrowingShims$1)return factoryWithThrowingShims$1;hasRequiredFactoryWithThrowingShims$1=1;var o=requireReactPropTypesSecret$1();function e(){}function r(){}return r.resetWarningCache=e,factoryWithThrowingShims$1=function(){function t(l,u,f,d,h,y){if(y!==o){var E=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw E.name="Invariant Violation",E}}t.isRequired=t;function n(){return t}var a={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:n,element:t,elementType:t,instanceOf:n,node:t,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:r,resetWarningCache:e};return a.PropTypes=a,a},factoryWithThrowingShims$1}if(process.env.NODE_ENV!=="production"){var ReactIs$1=requireReactIs(),throwOnDirectAccess$1=!0;propTypes$1.exports=requireFactoryWithTypeCheckers$1()(ReactIs$1.isElement,throwOnDirectAccess$1)}else propTypes$1.exports=requireFactoryWithThrowingShims$1()();var propTypesExports$1=propTypes$1.exports;const PropTypes$1=getDefaultExportFromCjs(propTypesExports$1);var __spreadArray=globalThis&&globalThis.__spreadArray||function(o,e,r){if(r||arguments.length===2)for(var t=0,n=e.length,a;t<n;t++)(a||!(t in e))&&(a||(a=Array.prototype.slice.call(e,0,t)),a[t]=e[t]);return o.concat(a||Array.prototype.slice.call(e))},clipboardEvents=["onCopy","onCut","onPaste"],compositionEvents=["onCompositionEnd","onCompositionStart","onCompositionUpdate"],focusEvents=["onFocus","onBlur"],formEvents=["onInput","onInvalid","onReset","onSubmit"],imageEvents=["onLoad","onError"],keyboardEvents=["onKeyDown","onKeyPress","onKeyUp"],mediaEvents=["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],mouseEvents=["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],dragEvents=["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],selectionEvents=["onSelect"],touchEvents=["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],pointerEvents=["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],uiEvents=["onScroll"],wheelEvents=["onWheel"],animationEvents=["onAnimationStart","onAnimationEnd","onAnimationIteration"],transitionEvents=["onTransitionEnd"],otherEvents=["onToggle"],changeEvents=["onChange"],allEvents=__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([],clipboardEvents,!0),compositionEvents,!0),focusEvents,!0),formEvents,!0),imageEvents,!0),keyboardEvents,!0),mediaEvents,!0),mouseEvents,!0),dragEvents,!0),selectionEvents,!0),touchEvents,!0),pointerEvents,!0),uiEvents,!0),wheelEvents,!0),animationEvents,!0),transitionEvents,!0),changeEvents,!0),otherEvents,!0);function makeEventProps(o,e){var r={};return allEvents.forEach(function(t){var n=o[t];n&&(e?r[t]=function(a){return n(a,e(t))}:r[t]=n)}),r}function makeCancellablePromise(o){var e=!1,r=new Promise(function(t,n){o.then(function(a){return!e&&t(a)}).catch(function(a){return!e&&n(a)})});return{promise:r,cancel:function(){e=!0}}}function mergeClassNames(){return Array.prototype.slice.call(arguments).reduce(function(o,e){return o.concat(e)},[]).filter(function(o){return typeof o=="string"}).join(" ")}const DocumentContext=React$2.createContext(null);function Message$1(o){var e=o.children,r=o.type;return React$2.createElement("div",{className:"react-pdf__message react-pdf__message--".concat(r)},e)}Message$1.propTypes={children:PropTypes$1.node,type:PropTypes$1.oneOf(["error","loading","no-data"]).isRequired};var pdf_link_service={},ui_utils={};Object.defineProperty(ui_utils,"__esModule",{value:!0});ui_utils.isValidRotation=isValidRotation;ui_utils.isValidScrollMode=isValidScrollMode;ui_utils.isValidSpreadMode=isValidSpreadMode;ui_utils.isPortraitOrientation=isPortraitOrientation;ui_utils.clamp=clamp$1;ui_utils.getPDFFileNameFromURL=getPDFFileNameFromURL;ui_utils.noContextMenuHandler=noContextMenuHandler;ui_utils.parseQueryString=parseQueryString;ui_utils.backtrackBeforeAllVisibleElements=backtrackBeforeAllVisibleElements;ui_utils.getVisibleElements=getVisibleElements;ui_utils.roundToDivide=roundToDivide;ui_utils.getPageSizeInches=getPageSizeInches;ui_utils.approximateFraction=approximateFraction;ui_utils.getOutputScale=getOutputScale;ui_utils.scrollIntoView=scrollIntoView;ui_utils.watchScroll=watchScroll;ui_utils.binarySearchFirstItem=binarySearchFirstItem;ui_utils.normalizeWheelEventDelta=normalizeWheelEventDelta;ui_utils.waitOnEventOrTimeout=waitOnEventOrTimeout;ui_utils.moveToEndOfArray=moveToEndOfArray;ui_utils.WaitOnType=ui_utils.animationStarted=ui_utils.ProgressBar=EventBus_1=ui_utils.EventBus=ui_utils.NullL10n=ui_utils.SpreadMode=ui_utils.ScrollMode=ui_utils.TextLayerMode=ui_utils.RendererType=ui_utils.PresentationModeState=ui_utils.VERTICAL_PADDING=ui_utils.SCROLLBAR_PADDING=ui_utils.MAX_AUTO_SCALE=ui_utils.UNKNOWN_SCALE=ui_utils.MAX_SCALE=ui_utils.MIN_SCALE=ui_utils.DEFAULT_SCALE=ui_utils.DEFAULT_SCALE_VALUE=ui_utils.CSS_UNITS=ui_utils.AutoPrintRegExp=void 0;const CSS_UNITS=96/72;ui_utils.CSS_UNITS=CSS_UNITS;const DEFAULT_SCALE_VALUE="auto";ui_utils.DEFAULT_SCALE_VALUE=DEFAULT_SCALE_VALUE;const DEFAULT_SCALE=1;ui_utils.DEFAULT_SCALE=DEFAULT_SCALE;const MIN_SCALE=.1;ui_utils.MIN_SCALE=MIN_SCALE;const MAX_SCALE=10;ui_utils.MAX_SCALE=MAX_SCALE;const UNKNOWN_SCALE=0;ui_utils.UNKNOWN_SCALE=UNKNOWN_SCALE;const MAX_AUTO_SCALE=1.25;ui_utils.MAX_AUTO_SCALE=MAX_AUTO_SCALE;const SCROLLBAR_PADDING=40;ui_utils.SCROLLBAR_PADDING=SCROLLBAR_PADDING;const VERTICAL_PADDING=5;ui_utils.VERTICAL_PADDING=VERTICAL_PADDING;const PresentationModeState={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3};ui_utils.PresentationModeState=PresentationModeState;const RendererType={CANVAS:"canvas",SVG:"svg"};ui_utils.RendererType=RendererType;const TextLayerMode={DISABLE:0,ENABLE:1,ENABLE_ENHANCE:2};ui_utils.TextLayerMode=TextLayerMode;const ScrollMode={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2};ui_utils.ScrollMode=ScrollMode;const SpreadMode={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};ui_utils.SpreadMode=SpreadMode;const AutoPrintRegExp=/\bprint\s*\(/;ui_utils.AutoPrintRegExp=AutoPrintRegExp;function formatL10nValue(o,e){return e?o.replace(/\{\{\s*(\w+)\s*\}\}/g,(r,t)=>t in e?e[t]:"{{"+t+"}}"):o}const NullL10n={async getLanguage(){return"en-us"},async getDirection(){return"ltr"},async get(o,e,r){return formatL10nValue(r,e)},async translate(o){}};ui_utils.NullL10n=NullL10n;function getOutputScale(o){const e=window.devicePixelRatio||1,r=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1,t=e/r;return{sx:t,sy:t,scaled:t!==1}}function scrollIntoView(o,e,r=!1){let t=o.offsetParent;if(!t){console.error("offsetParent is not set -- cannot scroll");return}let n=o.offsetTop+o.clientTop,a=o.offsetLeft+o.clientLeft;for(;t.clientHeight===t.scrollHeight&&t.clientWidth===t.scrollWidth||r&&getComputedStyle(t).overflow==="hidden";)if(t.dataset._scaleY&&(n/=t.dataset._scaleY,a/=t.dataset._scaleX),n+=t.offsetTop,a+=t.offsetLeft,t=t.offsetParent,!t)return;e&&(e.top!==void 0&&(n+=e.top),e.left!==void 0&&(a+=e.left,t.scrollLeft=a)),t.scrollTop=n}function watchScroll(o,e){const r=function(a){n||(n=window.requestAnimationFrame(function(){n=null;const u=o.scrollLeft,f=t.lastX;u!==f&&(t.right=u>f),t.lastX=u;const d=o.scrollTop,h=t.lastY;d!==h&&(t.down=d>h),t.lastY=d,e(t)}))},t={right:!0,down:!0,lastX:o.scrollLeft,lastY:o.scrollTop,_eventHandler:r};let n=null;return o.addEventListener("scroll",r,!0),t}function parseQueryString(o){const e=o.split("&"),r=Object.create(null);for(let t=0,n=e.length;t<n;++t){const a=e[t].split("="),l=a[0].toLowerCase(),u=a.length>1?a[1]:null;r[decodeURIComponent(l)]=decodeURIComponent(u)}return r}function binarySearchFirstItem(o,e){let r=0,t=o.length-1;if(t<0||!e(o[t]))return o.length;if(e(o[r]))return r;for(;r<t;){const n=r+t>>1,a=o[n];e(a)?t=n:r=n+1}return r}function approximateFraction(o){if(Math.floor(o)===o)return[o,1];const e=1/o,r=8;if(e>r)return[1,r];if(Math.floor(e)===e)return[1,e];const t=o>1?e:o;let n=0,a=1,l=1,u=1;for(;;){const d=n+l,h=a+u;if(h>r)break;t<=d/h?(l=d,u=h):(n=d,a=h)}let f;return t-n/a<l/u-t?f=t===o?[n,a]:[a,n]:f=t===o?[l,u]:[u,l],f}function roundToDivide(o,e){const r=o%e;return r===0?o:Math.round(o-r+e)}function getPageSizeInches({view:o,userUnit:e,rotate:r}){const[t,n,a,l]=o,u=r%180!==0,f=(a-t)/72*e,d=(l-n)/72*e;return{width:u?d:f,height:u?f:d}}function backtrackBeforeAllVisibleElements(o,e,r){if(o<2)return o;let t=e[o].div,n=t.offsetTop+t.clientTop;n>=r&&(t=e[o-1].div,n=t.offsetTop+t.clientTop);for(let a=o-2;a>=0&&(t=e[a].div,!(t.offsetTop+t.clientTop+t.clientHeight<=n));--a)o=a;return o}function getVisibleElements(o,e,r=!1,t=!1){const n=o.scrollTop,a=n+o.clientHeight,l=o.scrollLeft,u=l+o.clientWidth;function f(x){const C=x.div;return C.offsetTop+C.clientTop+C.clientHeight>n}function d(x){const C=x.div;return C.offsetLeft+C.clientLeft+C.clientWidth>l}const h=[],y=e.length;let E=y===0?0:binarySearchFirstItem(e,t?d:f);E>0&&E<y&&!t&&(E=backtrackBeforeAllVisibleElements(E,e,n));let p=t?u:-1;for(let x=E;x<y;x++){const C=e[x],R=C.div,S=R.offsetLeft+R.clientLeft,A=R.offsetTop+R.clientTop,T=R.clientWidth,w=R.clientHeight,P=S+T,O=A+w;if(p===-1)O>=a&&(p=O);else if((t?S:A)>p)break;if(O<=n||A>=a||P<=l||S>=u)continue;const k=Math.max(0,n-A)+Math.max(0,O-a),D=Math.max(0,l-S)+Math.max(0,P-u),F=(w-k)*(T-D)*100/w/T|0;h.push({id:C.id,x:S,y:A,view:C,percent:F})}const _=h[0],g=h[h.length-1];return r&&h.sort(function(x,C){const R=x.percent-C.percent;return Math.abs(R)>.001?-R:x.id-C.id}),{first:_,last:g,views:h}}function noContextMenuHandler(o){o.preventDefault()}function isDataSchema(o){let e=0;const r=o.length;for(;e<r&&o[e].trim()==="";)e++;return o.substring(e,e+5).toLowerCase()==="data:"}function getPDFFileNameFromURL(o,e="document.pdf"){if(typeof o!="string")return e;if(isDataSchema(o))return console.warn('getPDFFileNameFromURL: ignoring "data:" URL for performance reasons.'),e;const r=/^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,t=/[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=r.exec(o);let a=t.exec(n[1])||t.exec(n[2])||t.exec(n[3]);if(a&&(a=a[0],a.includes("%")))try{a=t.exec(decodeURIComponent(a))[0]}catch{}return a||e}function normalizeWheelEventDelta(o){let e=Math.sqrt(o.deltaX*o.deltaX+o.deltaY*o.deltaY);const r=Math.atan2(o.deltaY,o.deltaX);-.25*Math.PI<r&&r<.75*Math.PI&&(e=-e);const t=0,n=1,a=30,l=30;return o.deltaMode===t?e/=a*l:o.deltaMode===n&&(e/=l),e}function isValidRotation(o){return Number.isInteger(o)&&o%90===0}function isValidScrollMode(o){return Number.isInteger(o)&&Object.values(ScrollMode).includes(o)&&o!==ScrollMode.UNKNOWN}function isValidSpreadMode(o){return Number.isInteger(o)&&Object.values(SpreadMode).includes(o)&&o!==SpreadMode.UNKNOWN}function isPortraitOrientation(o){return o.width<=o.height}const WaitOnType={EVENT:"event",TIMEOUT:"timeout"};ui_utils.WaitOnType=WaitOnType;function waitOnEventOrTimeout({target:o,name:e,delay:r=0}){return new Promise(function(t,n){if(typeof o!="object"||!(e&&typeof e=="string")||!(Number.isInteger(r)&&r>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");function a(d){o instanceof EventBus?o._off(e,l):o.removeEventListener(e,l),f&&clearTimeout(f),t(d)}const l=a.bind(null,WaitOnType.EVENT);o instanceof EventBus?o._on(e,l):o.addEventListener(e,l);const u=a.bind(null,WaitOnType.TIMEOUT),f=setTimeout(u,r)})}const animationStarted=new Promise(function(o){window.requestAnimationFrame(o)});ui_utils.animationStarted=animationStarted;class EventBus{constructor(e){this._listeners=Object.create(null)}on(e,r){this._on(e,r,{external:!0})}off(e,r){this._off(e,r,{external:!0})}dispatch(e){const r=this._listeners[e];if(!r||r.length===0)return;const t=Array.prototype.slice.call(arguments,1);let n;r.slice(0).forEach(function({listener:a,external:l}){if(l){n||(n=[]),n.push(a);return}a.apply(null,t)}),n&&(n.forEach(function(a){a.apply(null,t)}),n=null)}_on(e,r,t=null){let n=this._listeners[e];n||(this._listeners[e]=n=[]),n.push({listener:r,external:(t&&t.external)===!0})}_off(e,r,t=null){const n=this._listeners[e];if(n){for(let a=0,l=n.length;a<l;a++)if(n[a].listener===r){n.splice(a,1);return}}}}var EventBus_1=ui_utils.EventBus=EventBus;function clamp$1(o,e,r){return Math.min(Math.max(o,e),r)}let ProgressBar$1=class{constructor(e,{height:r,width:t,units:n}={}){this.visible=!0,this.div=document.querySelector(e+" .progress"),this.bar=this.div.parentNode,this.height=r||100,this.width=t||100,this.units=n||"%",this.div.style.height=this.height+this.units,this.percent=0}_updateBar(){if(this._indeterminate){this.div.classList.add("indeterminate"),this.div.style.width=this.width+this.units;return}this.div.classList.remove("indeterminate");const e=this.width*this._percent/100;this.div.style.width=e+this.units}get percent(){return this._percent}set percent(e){this._indeterminate=isNaN(e),this._percent=clamp$1(e,0,100),this._updateBar()}setWidth(e){if(!e)return;const t=e.parentNode.offsetWidth-e.offsetWidth;t>0&&(this.bar.style.width=`calc(100% - ${t}px)`)}hide(){this.visible&&(this.visible=!1,this.bar.classList.add("hidden"),document.body.classList.remove("loadingInProgress"))}show(){this.visible||(this.visible=!0,document.body.classList.add("loadingInProgress"),this.bar.classList.remove("hidden"))}};ui_utils.ProgressBar=ProgressBar$1;function moveToEndOfArray(o,e){const r=[],t=o.length;let n=0;for(let a=0;a<t;++a)e(o[a])?r.push(o[a]):(o[n]=o[a],++n);for(let a=0;n<t;++a,++n)o[n]=r[a]}Object.defineProperty(pdf_link_service,"__esModule",{value:!0});pdf_link_service.SimpleLinkService=PDFLinkService_1=pdf_link_service.PDFLinkService=void 0;var _ui_utils=ui_utils;class PDFLinkService{constructor({eventBus:e,externalLinkTarget:r=null,externalLinkRel:t=null,externalLinkEnabled:n=!0,ignoreDestinationZoom:a=!1}={}){this.eventBus=e,this.externalLinkTarget=r,this.externalLinkRel=t,this.externalLinkEnabled=n,this._ignoreDestinationZoom=a,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null,this._pagesRefCache=null}setDocument(e,r=null){this.baseUrl=r,this.pdfDocument=e,this._pagesRefCache=Object.create(null)}setViewer(e){this.pdfViewer=e}setHistory(e){this.pdfHistory=e}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfViewer.currentPageNumber}set page(e){this.pdfViewer.currentPageNumber=e}get rotation(){return this.pdfViewer.pagesRotation}set rotation(e){this.pdfViewer.pagesRotation=e}navigateTo(e){const r=({namedDest:t,explicitDest:n})=>{const a=n[0];let l;if(a instanceof Object){if(l=this._cachedPageNumber(a),l===null){this.pdfDocument.getPageIndex(a).then(u=>{this.cachePageRef(u+1,a),r({namedDest:t,explicitDest:n})}).catch(()=>{console.error(`PDFLinkService.navigateTo: "${a}" is not a valid page reference, for dest="${e}".`)});return}}else if(Number.isInteger(a))l=a+1;else{console.error(`PDFLinkService.navigateTo: "${a}" is not a valid destination reference, for dest="${e}".`);return}if(!l||l<1||l>this.pagesCount){console.error(`PDFLinkService.navigateTo: "${l}" is not a valid page number, for dest="${e}".`);return}this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:t,explicitDest:n,pageNumber:l})),this.pdfViewer.scrollPageIntoView({pageNumber:l,destArray:n,ignoreDestinationZoom:this._ignoreDestinationZoom})};new Promise((t,n)=>{if(typeof e=="string"){this.pdfDocument.getDestination(e).then(a=>{t({namedDest:e,explicitDest:a})});return}t({namedDest:"",explicitDest:e})}).then(t=>{if(!Array.isArray(t.explicitDest)){console.error(`PDFLinkService.navigateTo: "${t.explicitDest}" is not a valid destination array, for dest="${e}".`);return}r(t)})}getDestinationHash(e){if(typeof e=="string")return this.getAnchorUrl("#"+escape(e));if(Array.isArray(e)){const r=JSON.stringify(e);return this.getAnchorUrl("#"+escape(r))}return this.getAnchorUrl("")}getAnchorUrl(e){return(this.baseUrl||"")+e}setHash(e){let r,t;if(e.includes("=")){const n=(0,_ui_utils.parseQueryString)(e);if("search"in n&&this.eventBus.dispatch("findfromurlhash",{source:this,query:n.search.replace(/"/g,""),phraseSearch:n.phrase==="true"}),"page"in n&&(r=n.page|0||1),"zoom"in n){const a=n.zoom.split(","),l=a[0],u=parseFloat(l);l.includes("Fit")?l==="Fit"||l==="FitB"?t=[null,{name:l}]:l==="FitH"||l==="FitBH"||l==="FitV"||l==="FitBV"?t=[null,{name:l},a.length>1?a[1]|0:null]:l==="FitR"?a.length!==5?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):t=[null,{name:l},a[1]|0,a[2]|0,a[3]|0,a[4]|0]:console.error(`PDFLinkService.setHash: "${l}" is not a valid zoom value.`):t=[null,{name:"XYZ"},a.length>1?a[1]|0:null,a.length>2?a[2]|0:null,u?u/100:l]}t?this.pdfViewer.scrollPageIntoView({pageNumber:r||this.page,destArray:t,allowNegativeOffset:!0}):r&&(this.page=r),"pagemode"in n&&this.eventBus.dispatch("pagemode",{source:this,mode:n.pagemode}),"nameddest"in n&&this.navigateTo(n.nameddest)}else{t=unescape(e);try{t=JSON.parse(t),Array.isArray(t)||(t=t.toString())}catch{}if(typeof t=="string"||isValidExplicitDestination(t)){this.navigateTo(t);return}console.error(`PDFLinkService.setHash: "${unescape(e)}" is not a valid destination.`)}}executeNamedAction(e){switch(e){case"GoBack":this.pdfHistory&&this.pdfHistory.back();break;case"GoForward":this.pdfHistory&&this.pdfHistory.forward();break;case"NextPage":this.page<this.pagesCount&&this.page++;break;case"PrevPage":this.page>1&&this.page--;break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1;break}this.eventBus.dispatch("namedaction",{source:this,action:e})}cachePageRef(e,r){if(!r)return;const t=r.gen===0?`${r.num}R`:`${r.num}R${r.gen}`;this._pagesRefCache[t]=e}_cachedPageNumber(e){const r=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return this._pagesRefCache&&this._pagesRefCache[r]||null}isPageVisible(e){return this.pdfViewer.isPageVisible(e)}}var PDFLinkService_1=pdf_link_service.PDFLinkService=PDFLinkService;function isValidExplicitDestination(o){if(!Array.isArray(o))return!1;const e=o.length;if(e<2)return!1;const r=o[0];if(!(typeof r=="object"&&Number.isInteger(r.num)&&Number.isInteger(r.gen))&&!(Number.isInteger(r)&&r>=0))return!1;const t=o[1];if(!(typeof t=="object"&&typeof t.name=="string"))return!1;let n=!0;switch(t.name){case"XYZ":if(e!==5)return!1;break;case"Fit":case"FitB":return e===2;case"FitH":case"FitBH":case"FitV":case"FitBV":if(e!==3)return!1;break;case"FitR":if(e!==6)return!1;n=!1;break;default:return!1}for(let a=2;a<e;a++){const l=o[a];if(!(typeof l=="number"||n&&l===null))return!1}return!0}class SimpleLinkService{constructor(){this.externalLinkTarget=null,this.externalLinkRel=null,this.externalLinkEnabled=!0,this._ignoreDestinationZoom=!1}get pagesCount(){return 0}get page(){return 0}set page(e){}get rotation(){return 0}set rotation(e){}navigateTo(e){}getDestinationHash(e){return"#"}getAnchorUrl(e){return"#"}setHash(e){}executeNamedAction(e){}cachePageRef(e,r){}isPageVisible(e){return!0}}pdf_link_service.SimpleLinkService=SimpleLinkService;const LinkService=PDFLinkService_1;var PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};const eventBus=new EventBus_1;function _arrayWithHoles$1(o){if(Array.isArray(o))return o}function _iterableToArrayLimit$1(o,e){var r=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(r!=null){var t,n,a,l,u=[],f=!0,d=!1;try{if(a=(r=r.call(o)).next,e===0){if(Object(r)!==r)return;f=!1}else for(;!(f=(t=a.call(r)).done)&&(u.push(t.value),u.length!==e);f=!0);}catch(h){d=!0,n=h}finally{try{if(!f&&r.return!=null&&(l=r.return(),Object(l)!==l))return}finally{if(d)throw n}}return u}}function _arrayLikeToArray$1(o,e){(e==null||e>o.length)&&(e=o.length);for(var r=0,t=new Array(e);r<e;r++)t[r]=o[r];return t}function _unsupportedIterableToArray$1(o,e){if(o){if(typeof o=="string")return _arrayLikeToArray$1(o,e);var r=Object.prototype.toString.call(o).slice(8,-1);if(r==="Object"&&o.constructor&&(r=o.constructor.name),r==="Map"||r==="Set")return Array.from(o);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _arrayLikeToArray$1(o,e)}}function _nonIterableRest$1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
51
51
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _slicedToArray$1(o,e){return _arrayWithHoles$1(o)||_iterableToArrayLimit$1(o,e)||_unsupportedIterableToArray$1(o,e)||_nonIterableRest$1()}var isBrowser=typeof window<"u",isLocalFileSystem=isBrowser&&window.location.protocol==="file:",isProduction=process.env.NODE_ENV==="production",isDefined=function o(e){return typeof e<"u"},isProvided=function o(e){return isDefined(e)&&e!==null},isString=function o(e){return typeof e=="string"},isArrayBuffer=function o(e){return e instanceof ArrayBuffer},isBlob=function o(e){if(!isBrowser)throw new Error("Attempted to check if a variable is a Blob on a non-browser environment.");return e instanceof Blob},isFile=function o(e){if(!isBrowser)throw new Error("Attempted to check if a variable is a File on a non-browser environment.");return e instanceof File},isDataURI=function o(e){return isString(e)&&/^data:/.test(e)},dataURItoByteString=function o(e){if(!isDataURI(e))throw new Error("Invalid data URI.");var r=e.split(";"),t=_slicedToArray$1(r,2),n=t[1];return n.indexOf("base64")===0?atob(n.slice(7)):unescape(n)},getPixelRatio=function o(){return isBrowser&&window.devicePixelRatio||1},consoleOnDev=function o(e){if(!isProduction){for(var r,t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];(r=console)[e].apply(r,n)}},warnOnDev=function o(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return consoleOnDev.apply(void 0,["warn"].concat(r))},errorOnDev=function o(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return consoleOnDev.apply(void 0,["error"].concat(r))},displayCORSWarning=function o(){isLocalFileSystem&&warnOnDev("Loading PDF as base64 strings/URLs might not work on protocols other than HTTP/HTTPS. On Google Chrome, you can use --allow-file-access-from-files flag for debugging purposes.")},cancelRunningTask=function o(e){e&&e.cancel&&e.cancel()},makePageCallback=function o(e,r){return Object.defineProperty(e,"width",{get:function(){return this.view[2]*r},configurable:!0}),Object.defineProperty(e,"height",{get:function(){return this.view[3]*r},configurable:!0}),Object.defineProperty(e,"originalWidth",{get:function(){return this.view[2]},configurable:!0}),Object.defineProperty(e,"originalHeight",{get:function(){return this.view[3]},configurable:!0}),e},isCancelException=function o(e){return e.name==="RenderingCancelledException"},loadFromFile=function o(e){return new Promise(function(r,t){var n=new FileReader;return n.onload=function(){return r(new Uint8Array(n.result))},n.onerror=function(a){switch(a.target.error.code){case a.target.error.NOT_FOUND_ERR:return t(new Error("Error while reading a file: File not found."));case a.target.error.NOT_READABLE_ERR:return t(new Error("Error while reading a file: File not readable."));case a.target.error.SECURITY_ERR:return t(new Error("Error while reading a file: Security error."));case a.target.error.ABORT_ERR:return t(new Error("Error while reading a file: Aborted."));default:return t(new Error("Error while reading a file."))}},n.readAsArrayBuffer(e),null})};function _arrayWithoutHoles(o){if(Array.isArray(o))return _arrayLikeToArray$1(o)}function _iterableToArray(o){if(typeof Symbol<"u"&&o[Symbol.iterator]!=null||o["@@iterator"]!=null)return Array.from(o)}function _nonIterableSpread(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
52
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _toConsumableArray(o){return _arrayWithoutHoles(o)||_iterableToArray(o)||_unsupportedIterableToArray$1(o)||_nonIterableSpread()}var eventProps=function(){var o={};return[].concat(_toConsumableArray(mouseEvents),_toConsumableArray(touchEvents),_toConsumableArray(keyboardEvents)).forEach(function(e){o[e]=PropTypes$1.func}),o}(),fileTypes=[PropTypes$1.string,PropTypes$1.instanceOf(ArrayBuffer),PropTypes$1.shape({data:PropTypes$1.object,httpHeaders:PropTypes$1.object,range:PropTypes$1.object,url:PropTypes$1.string,withCredentials:PropTypes$1.bool})];typeof File<"u"&&fileTypes.push(PropTypes$1.instanceOf(File));typeof Blob<"u"&&fileTypes.push(PropTypes$1.instanceOf(Blob));var isClassName=PropTypes$1.oneOfType([PropTypes$1.string,PropTypes$1.arrayOf(PropTypes$1.string)]);PropTypes$1.oneOfType(fileTypes);var isLinkService=PropTypes$1.instanceOf(LinkService);PropTypes$1.oneOf(["_self","_blank","_parent","_top"]);var isPage=PropTypes$1.shape({_transport:PropTypes$1.shape({fontLoader:PropTypes$1.object.isRequired}).isRequired,commonObjs:PropTypes$1.shape({_objs:PropTypes$1.object.isRequired}).isRequired,getAnnotations:PropTypes$1.func.isRequired,getTextContent:PropTypes$1.func.isRequired,getViewport:PropTypes$1.func.isRequired,render:PropTypes$1.func.isRequired}),isPageIndex=function o(e,r,t){var n=e[r],a=e.pageNumber,l=e.pdf;if(!isDefined(l))return null;if(isDefined(n)){if(typeof n!="number")return new Error("`".concat(r,"` of type `").concat(_typeof$1(n),"` supplied to `").concat(t,"`, expected `number`."));if(n<0)return new Error("Expected `".concat(r,"` to be greater or equal to 0."));var u=l.numPages;if(n+1>u)return new Error("Expected `".concat(r,"` to be less or equal to ").concat(u-1,"."))}else if(!isDefined(a))return new Error("`".concat(r,"` not supplied. Either pageIndex or pageNumber must be supplied to `").concat(t,"`."));return null},isPageNumber=function o(e,r,t){var n=e[r],a=e.pageIndex,l=e.pdf;if(!isDefined(l))return null;if(isDefined(n)){if(typeof n!="number")return new Error("`".concat(r,"` of type `").concat(_typeof$1(n),"` supplied to `").concat(t,"`, expected `number`."));if(n<1)return new Error("Expected `".concat(r,"` to be greater or equal to 1."));var u=l.numPages;if(n>u)return new Error("Expected `".concat(r,"` to be less or equal to ").concat(u,"."))}else if(!isDefined(a))return new Error("`".concat(r,"` not supplied. Either pageIndex or pageNumber must be supplied to `").concat(t,"`."));return null},isPdf=PropTypes$1.oneOfType([PropTypes$1.shape({getDestination:PropTypes$1.func.isRequired,getOutline:PropTypes$1.func.isRequired,getPage:PropTypes$1.func.isRequired,numPages:PropTypes$1.number.isRequired}),PropTypes$1.bool]),isRef=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.shape({current:PropTypes$1.any})]),isRenderMode=PropTypes$1.oneOf(["canvas","none","svg"]),isRotate=PropTypes$1.oneOf([0,90,180,270]);function ownKeys$2(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread$2(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$2(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function _createSuper$6(o){var e=_isNativeReflectConstruct$6();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$6(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PDFDataRangeTransport=pdfExports.PDFDataRangeTransport,Document$1=function(o){_inherits(r,o);var e=_createSuper$6(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{pdf:null}),_defineProperty(_assertThisInitialized$1(t),"viewer",{scrollPageIntoView:function(f){var d=f.pageNumber,h=t.props.onItemClick;if(h){h({pageNumber:d});return}var y=t.pages[d-1];if(y){y.scrollIntoView();return}warnOnDev("Warning: An internal link leading to page ".concat(d," was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>."))}}),_defineProperty(_assertThisInitialized$1(t),"linkService",new LinkService({eventBus})),_defineProperty(_assertThisInitialized$1(t),"loadDocument",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y,E,p,_;return _regeneratorRuntime.wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return f=null,x.prev=1,x.next=4,t.findDocumentSource();case 4:f=x.sent,t.onSourceSuccess(),x.next=11;break;case 8:x.prev=8,x.t0=x.catch(1),t.onSourceError(x.t0);case 11:if(f){x.next=13;break}return x.abrupt("return");case 13:return t.setState(function(C){return C.pdf?{pdf:null}:null}),d=t.props,h=d.options,y=d.onLoadProgress,E=d.onPassword,x.prev=15,cancelRunningTask(t.runningTask),t.loadingTask=pdfExports.getDocument(_objectSpread$2(_objectSpread$2({},f),h)),t.loadingTask.onPassword=E,y&&(t.loadingTask.onProgress=y),p=makeCancellablePromise(t.loadingTask.promise),t.runningTask=p,x.next=24,p.promise;case 24:_=x.sent,t.setState(function(C){return C.pdf&&C.pdf.fingerprint===_.fingerprint?null:{pdf:_}},t.onLoadSuccess),x.next=31;break;case 28:x.prev=28,x.t1=x.catch(15),t.onLoadError(x.t1);case 31:case"end":return x.stop()}},u,null,[[1,8],[15,28]])}))),_defineProperty(_assertThisInitialized$1(t),"setupLinkService",function(){t.linkService.setViewer(t.viewer);var u=_assertThisInitialized$1(t);Object.defineProperty(t.linkService,"externalLinkTarget",{get:function(){var d=u.props.externalLinkTarget;switch(d){case"_self":return 1;case"_blank":return 2;case"_parent":return 3;case"_top":return 4;default:return 0}}})}),_defineProperty(_assertThisInitialized$1(t),"onSourceSuccess",function(){var u=t.props.onSourceSuccess;u&&u()}),_defineProperty(_assertThisInitialized$1(t),"onSourceError",function(u){errorOnDev(u);var f=t.props.onSourceError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onLoadSuccess,f=t.state.pdf;u&&u(f),t.pages=new Array(f.numPages),t.linkService.setDocument(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({pdf:!1}),errorOnDev(u);var f=t.props.onLoadError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"findDocumentSource",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y,E;return _regeneratorRuntime.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=t.props.file,f){_.next=3;break}return _.abrupt("return",null);case 3:if(typeof f!="string"){_.next=9;break}if(!isDataURI(f)){_.next=7;break}return d=dataURItoByteString(f),_.abrupt("return",{data:d});case 7:return displayCORSWarning(),_.abrupt("return",{url:f});case 9:if(!(f instanceof PDFDataRangeTransport)){_.next=11;break}return _.abrupt("return",{range:f});case 11:if(!isArrayBuffer(f)){_.next=13;break}return _.abrupt("return",{data:f});case 13:if(!isBrowser){_.next=19;break}if(!(isBlob(f)||isFile(f))){_.next=19;break}return _.next=17,loadFromFile(f);case 17:return _.t0=_.sent,_.abrupt("return",{data:_.t0});case 19:if(_typeof$1(f)==="object"){_.next=21;break}throw new Error("Invalid parameter in file, need either Uint8Array, string or a parameter object");case 21:if(!(!f.url&&!f.data&&!f.range)){_.next=23;break}throw new Error("Invalid parameter object: need either .data, .range or .url");case 23:if(typeof f.url!="string"){_.next=29;break}if(!isDataURI(f.url)){_.next=28;break}return h=f.url,y=_objectWithoutProperties(f,["url"]),E=dataURItoByteString(h),_.abrupt("return",_objectSpread$2({data:E},y));case 28:displayCORSWarning();case 29:return _.abrupt("return",f);case 30:case"end":return _.stop()}},u)}))),_defineProperty(_assertThisInitialized$1(t),"registerPage",function(u,f){t.pages[u]=f}),_defineProperty(_assertThisInitialized$1(t),"unregisterPage",function(u){delete t.pages[u]}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.loadDocument(),this.setupLinkService()}},{key:"componentDidUpdate",value:function(n){var a=this.props.file;a!==n.file&&this.loadDocument()}},{key:"componentWillUnmount",value:function(){this.loadingTask&&this.loadingTask.destroy(),cancelRunningTask(this.runningTask)}},{key:"renderChildren",value:function(){var n=this.props.children;return React$2.createElement(DocumentContext.Provider,{value:this.childContext},n)}},{key:"renderContent",value:function(){var n=this.props.file,a=this.state.pdf;if(!n){var l=this.props.noData;return React$2.createElement(Message$1,{type:"no-data"},typeof l=="function"?l():l)}if(a===null){var u=this.props.loading;return React$2.createElement(Message$1,{type:"loading"},typeof u=="function"?u():u)}if(a===!1){var f=this.props.error;return React$2.createElement(Message$1,{type:"error"},typeof f=="function"?f():f)}return this.renderChildren()}},{key:"render",value:function(){var n=this.props,a=n.className,l=n.inputRef;return React$2.createElement("div",_extends({className:mergeClassNames("react-pdf__Document",a),ref:l},this.eventProps),this.renderContent())}},{key:"childContext",get:function(){var n=this.linkService,a=this.registerPage,l=this.unregisterPage,u=this.props,f=u.imageResourcesPath,d=u.renderMode,h=u.rotate,y=this.state.pdf;return{imageResourcesPath:f,linkService:n,pdf:y,registerPage:a,renderMode:d,rotate:h,unregisterPage:l}}},{key:"eventProps",get:function(){var n=this;return makeEventProps(this.props,function(){return n.state.pdf})}}]),r}(React$2.PureComponent);Document$1.defaultProps={error:"Failed to load PDF file.",loading:"Loading PDF…",noData:"No PDF file specified.",onPassword:function o(e,r){switch(r){case PasswordResponses.NEED_PASSWORD:{var t=prompt("Enter the password to open this PDF file.");e(t);break}case PasswordResponses.INCORRECT_PASSWORD:{var n=prompt("Invalid password. Please try again.");e(n);break}}}};var isFunctionOrNode$1=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.node]);Document$1.propTypes=_objectSpread$2(_objectSpread$2({},eventProps),{},{children:PropTypes$1.node,className:isClassName,error:isFunctionOrNode$1,file:isFile,imageResourcesPath:PropTypes$1.string,inputRef:isRef,loading:isFunctionOrNode$1,noData:isFunctionOrNode$1,onItemClick:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadProgress:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,onPassword:PropTypes$1.func,onSourceError:PropTypes$1.func,onSourceSuccess:PropTypes$1.func,rotate:PropTypes$1.number});var isDestination=PropTypes$1.oneOfType([PropTypes$1.string,PropTypes$1.arrayOf(PropTypes$1.any)]);PropTypes$1.shape({dest:isDestination,items:PropTypes$1.arrayOf(PropTypes$1.shape({dest:isDestination,title:PropTypes$1.string})),title:PropTypes$1.string}).isRequired,PropTypes$1.func,isPdf.isRequired;function ownKeys$1(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread$1(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$1(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys$1(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}_objectSpread$1({className:isClassName,inputRef:isRef,onItemClick:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,pdf:isPdf},eventProps);function mergeRefs(){for(var o=[],e=0;e<arguments.length;e++)o[e]=arguments[e];var r=o.filter(Boolean);if(r.length<=1){var t=r[0];return t||null}return function(a){r.forEach(function(l){typeof l=="function"?l(a):l&&(l.current=a)})}}const PageContext=React$2.createContext(null);function _createSuper$5(o){var e=_isNativeReflectConstruct$5();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$5(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PageCanvasInternal=function(o){_inherits(r,o);var e=_createSuper$5(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){t.renderer=null;var u=t.props,f=u.onRenderSuccess,d=u.page,h=u.scale;f&&f(makePageCallback(d,h))}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){if(!isCancelException(u)){errorOnDev(u);var f=t.props.onRenderError;f&&f(u)}}),_defineProperty(_assertThisInitialized$1(t),"drawPageOnCanvas",function(){var u=_assertThisInitialized$1(t),f=u.canvasLayer;if(!f)return null;var d=_assertThisInitialized$1(t),h=d.renderViewport,y=d.viewport,E=t.props,p=E.page,_=E.renderInteractiveForms;f.width=h.width,f.height=h.height,f.style.width="".concat(Math.floor(y.width),"px"),f.style.height="".concat(Math.floor(y.height),"px");var g={get canvasContext(){return f.getContext("2d")},viewport:h,renderInteractiveForms:_};return t.cancelRenderingTask(),t.renderer=p.render(g),t.renderer.promise.then(t.onRenderSuccess).catch(t.onRenderError)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.drawPageOnCanvas()}},{key:"componentDidUpdate",value:function(n){var a=this.props,l=a.page,u=a.renderInteractiveForms;u!==n.renderInteractiveForms&&(l.cleanup(),this.drawPageOnCanvas())}},{key:"componentWillUnmount",value:function(){this.cancelRenderingTask(),this.canvasLayer&&(this.canvasLayer.width=0,this.canvasLayer.height=0,this.canvasLayer=null)}},{key:"cancelRenderingTask",value:function(){this.renderer&&this.renderer._internalRenderTask.running&&this.renderer._internalRenderTask.cancel()}},{key:"render",value:function(){var n=this,a=this.props.canvasRef;return React$2.createElement("canvas",{className:"react-pdf__Page__canvas",dir:"ltr",ref:mergeRefs(a,function(l){n.canvasLayer=l}),style:{display:"block",userSelect:"none"}})}},{key:"renderViewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale,f=getPixelRatio();return a.getViewport({scale:u*f,rotation:l})}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);PageCanvasInternal.propTypes={canvasRef:isRef,onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,page:isPage.isRequired,renderInteractiveForms:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number};function PageCanvas(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(PageCanvasInternal,_extends({},e,o))})}function _createSuper$4(o){var e=_isNativeReflectConstruct$4();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$4(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PageSVGInternal=function(o){_inherits(r,o);var e=_createSuper$4(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{svg:null}),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){t.renderer=null;var u=t.props,f=u.onRenderSuccess,d=u.page,h=u.scale;f&&f(makePageCallback(d,h))}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){if(!isCancelException(u)){errorOnDev(u);var f=t.props.onRenderError;f&&f(u)}}),_defineProperty(_assertThisInitialized$1(t),"renderSVG",function(){var u=t.props.page;return t.renderer=u.getOperatorList(),t.renderer.then(function(f){var d=new pdfExports.SVGGraphics(u.commonObjs,u.objs);t.renderer=d.getSVG(f,t.viewport).then(function(h){t.setState({svg:h},t.onRenderSuccess)}).catch(t.onRenderError)}).catch(t.onRenderError)}),_defineProperty(_assertThisInitialized$1(t),"drawPageOnContainer",function(u){var f=t.state.svg;if(!(!u||!f)){u.firstElementChild||u.appendChild(f);var d=t.viewport,h=d.width,y=d.height;f.setAttribute("width",h),f.setAttribute("height",y)}}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.renderSVG()}},{key:"render",value:function(){var n=this,a=this.viewport,l=a.width,u=a.height;return React$2.createElement("div",{className:"react-pdf__Page__svg",ref:function(d){return n.drawPageOnContainer(d)},style:{display:"block",backgroundColor:"white",overflow:"hidden",width:l,height:u,userSelect:"none"}})}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);PageSVGInternal.propTypes={onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number};function PageSVG(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(PageSVGInternal,_extends({},e,o))})}function _createSuper$3(o){var e=_isNativeReflectConstruct$3();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$3(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var TextLayerItemInternal=function(o){_inherits(r,o);var e=_createSuper$3(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"getElementWidth",function(u){var f=_assertThisInitialized$1(t),d=f.sideways;return u.getBoundingClientRect()[d?"height":"width"]}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.alignTextItem()}},{key:"componentDidUpdate",value:function(){this.alignTextItem()}},{key:"getFontData",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function a(l){var u,f;return _regeneratorRuntime.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return u=this.props.page,h.next=3,new Promise(function(y){u.commonObjs.get(l,y)});case 3:return f=h.sent,h.abrupt("return",f);case 5:case"end":return h.stop()}},a,this)}));function n(a){return t.apply(this,arguments)}return n}()},{key:"alignTextItem",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function a(){var l,u,f,d,h,y,E,p,_,g,x;return _regeneratorRuntime.wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(l=this.item,l){R.next=3;break}return R.abrupt("return");case 3:return l.style.transform="",u=this.props,f=u.fontName,d=u.scale,h=u.width,l.style.fontFamily="".concat(f,", sans-serif"),R.next=8,this.getFontData(f);case 8:y=R.sent,E=y?y.fallbackName:"sans-serif",l.style.fontFamily="".concat(f,", ").concat(E),p=h*d,_=this.getElementWidth(l),g="scaleX(".concat(p/_,")"),x=y?y.ascent:0,x&&(g+=" translateY(".concat((1-x)*100,"%)")),l.style.transform=g,l.style.WebkitTransform=g;case 18:case"end":return R.stop()}},a,this)}));function n(){return t.apply(this,arguments)}return n}()},{key:"render",value:function(){var n=this,a=this.fontSize,l=this.top,u=this.left,f=this.props,d=f.customTextRenderer,h=f.scale,y=f.str;return React$2.createElement("span",{ref:function(p){n.item=p},style:{height:"1em",fontFamily:"sans-serif",fontSize:"".concat(a*h,"px"),position:"absolute",top:"".concat(l*h,"px"),left:"".concat(u*h,"px"),transformOrigin:"left bottom",whiteSpace:"pre",pointerEvents:"all"}},d?d(this.props):y)}},{key:"unrotatedViewport",get:function(){var n=this.props,a=n.page,l=n.scale;return a.getViewport({scale:l})}},{key:"rotate",get:function(){var n=this.props,a=n.page,l=n.rotate;return l-a.rotate}},{key:"sideways",get:function(){var n=this.rotate;return n%180!==0}},{key:"defaultSideways",get:function(){var n=this.unrotatedViewport.rotation;return n%180!==0}},{key:"fontSize",get:function(){var n=this.props.transform,a=this.defaultSideways,l=_slicedToArray$1(n,2),u=l[0],f=l[1];return a?f:u}},{key:"top",get:function(){var n=this.props.transform,a=this.unrotatedViewport,l=this.defaultSideways,u=_slicedToArray$1(n,6),f=u[2],d=u[3],h=u[4],y=u[5],E=_slicedToArray$1(a.viewBox,4),p=E[1],_=E[3];return l?h+f+p:_-(y+d)}},{key:"left",get:function(){var n=this.props.transform,a=this.unrotatedViewport,l=this.defaultSideways,u=_slicedToArray$1(n,6),f=u[4],d=u[5],h=_slicedToArray$1(a.viewBox,1),y=h[0];return l?d-y:f-y}}]),r}(React$2.PureComponent);TextLayerItemInternal.propTypes={customTextRenderer:PropTypes$1.func,fontName:PropTypes$1.string.isRequired,itemIndex:PropTypes$1.number.isRequired,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number,str:PropTypes$1.string.isRequired,transform:PropTypes$1.arrayOf(PropTypes$1.number).isRequired,width:PropTypes$1.number.isRequired};function TextLayerItem(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(TextLayerItemInternal,_extends({},e,o))})}function _createSuper$2(o){var e=_isNativeReflectConstruct$2();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$2(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var TextLayerInternal=function(o){_inherits(r,o);var e=_createSuper$2(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{textItems:null}),_defineProperty(_assertThisInitialized$1(t),"loadTextItems",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y;return _regeneratorRuntime.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return f=t.props.page,p.prev=1,d=makeCancellablePromise(f.getTextContent()),t.runningTask=d,p.next=6,d.promise;case 6:h=p.sent,y=h.items,t.setState({textItems:y},t.onLoadSuccess),p.next=14;break;case 11:p.prev=11,p.t0=p.catch(1),t.onLoadError(p.t0);case 14:case"end":return p.stop()}},u,null,[[1,11]])}))),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onGetTextSuccess,f=t.state.textItems;u&&u(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({textItems:!1}),errorOnDev(u);var f=t.props.onGetTextError;f&&f(u)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.page;if(!n)throw new Error("Attempted to load page text content, but no page was specified.");this.loadTextItems()}},{key:"componentDidUpdate",value:function(n){var a=this.props.page;n.page&&a!==n.page&&this.loadTextItems()}},{key:"componentWillUnmount",value:function(){cancelRunningTask(this.runningTask)}},{key:"renderTextItems",value:function(){var n=this.state.textItems;return n?n.map(function(a,l){return React$2.createElement(TextLayerItem,_extends({key:l,itemIndex:l},a))}):null}},{key:"render",value:function(){var n=this.unrotatedViewport,a=this.rotate;return React$2.createElement("div",{className:"react-pdf__Page__textContent",style:{position:"absolute",top:"50%",left:"50%",width:"".concat(n.width,"px"),height:"".concat(n.height,"px"),color:"transparent",transform:"translate(-50%, -50%) rotate(".concat(a,"deg)"),WebkitTransform:"translate(-50%, -50%) rotate(".concat(a,"deg)"),pointerEvents:"none"}},this.renderTextItems())}},{key:"unrotatedViewport",get:function(){var n=this.props,a=n.page,l=n.scale;return a.getViewport({scale:l})}},{key:"rotate",get:function(){var n=this.props,a=n.page,l=n.rotate;return l-a.rotate}}]),r}(React$2.PureComponent);TextLayerInternal.propTypes={onGetTextError:PropTypes$1.func,onGetTextSuccess:PropTypes$1.func,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number};function TextLayer(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(TextLayerInternal,_extends({},e,o))})}function _createSuper$1(o){var e=_isNativeReflectConstruct$1();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$1(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var AnnotationLayerInternal=function(o){_inherits(r,o);var e=_createSuper$1(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{annotations:null}),_defineProperty(_assertThisInitialized$1(t),"loadAnnotations",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h;return _regeneratorRuntime.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return f=t.props.page,E.prev=1,d=makeCancellablePromise(f.getAnnotations()),t.runningTask=d,E.next=6,d.promise;case 6:h=E.sent,t.setState({annotations:h},t.onLoadSuccess),E.next=13;break;case 10:E.prev=10,E.t0=E.catch(1),t.onLoadError(E.t0);case 13:case"end":return E.stop()}},u,null,[[1,10]])}))),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onGetAnnotationsSuccess,f=t.state.annotations;u&&u(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({annotations:!1}),errorOnDev(u);var f=t.props.onGetAnnotationsError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){var u=t.props.onRenderAnnotationLayerSuccess;u&&u()}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){errorOnDev(u);var f=t.props.onRenderAnnotationLayerError;f&&f(u)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.page;if(!n)throw new Error("Attempted to load page annotations, but no page was specified.");this.loadAnnotations()}},{key:"componentDidUpdate",value:function(n){var a=this.props,l=a.page,u=a.renderInteractiveForms;(n.page&&l!==n.page||u!==n.renderInteractiveForms)&&this.loadAnnotations()}},{key:"componentWillUnmount",value:function(){cancelRunningTask(this.runningTask)}},{key:"renderAnnotationLayer",value:function(){var n=this.state.annotations;if(n){var a=this.props,l=a.imageResourcesPath,u=a.linkService,f=a.page,d=a.renderInteractiveForms,h=this.viewport.clone({dontFlip:!0}),y={annotations:n,div:this.annotationLayer,imageResourcesPath:l,linkService:u,page:f,renderInteractiveForms:d,viewport:h};this.annotationLayer.innerHTML="";try{pdfExports.AnnotationLayer.render(y),this.onRenderSuccess()}catch(E){this.onRenderError(E)}}}},{key:"render",value:function(){var n=this;return React$2.createElement("div",{className:"react-pdf__Page__annotations annotationLayer",ref:function(l){n.annotationLayer=l}},this.renderAnnotationLayer())}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);AnnotationLayerInternal.propTypes={imageResourcesPath:PropTypes$1.string,linkService:isLinkService.isRequired,onGetAnnotationsError:PropTypes$1.func,onGetAnnotationsSuccess:PropTypes$1.func,onRenderAnnotationLayerError:PropTypes$1.func,onRenderAnnotationLayerSuccess:PropTypes$1.func,page:isPage,renderInteractiveForms:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number};var AnnotationLayer=function o(e){return React$2.createElement(DocumentContext.Consumer,null,function(r){return React$2.createElement(PageContext.Consumer,null,function(t){return React$2.createElement(AnnotationLayerInternal,_extends({},r,t,e))})})};function ownKeys(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function _createSuper(o){var e=_isNativeReflectConstruct();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var defaultScale=1,PageInternal=function(o){_inherits(r,o);var e=_createSuper(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{page:null}),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props,f=u.onLoadSuccess,d=u.registerPage,h=t.state.page;f&&f(makePageCallback(h,t.scale)),d&&d(t.pageIndex,t.ref)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){errorOnDev(u);var f=t.props.onLoadError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"loadPage",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y;return _regeneratorRuntime.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(f=t.props.pdf,d=t.getPageNumber(),d){p.next=4;break}return p.abrupt("return");case 4:return t.setState(function(_){return _.page?{page:null}:null}),p.prev=5,h=makeCancellablePromise(f.getPage(d)),t.runningTask=h,p.next=10,h.promise;case 10:y=p.sent,t.setState({page:y},t.onLoadSuccess),p.next=18;break;case 14:p.prev=14,p.t0=p.catch(5),t.setState({page:!1}),t.onLoadError(p.t0);case 18:case"end":return p.stop()}},u,null,[[5,14]])}))),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.pdf;if(!n)throw new Error("Attempted to load a page, but no document was specified.");this.loadPage()}},{key:"componentDidUpdate",value:function(n){var a=this.props.pdf;if(n.pdf&&a!==n.pdf||this.getPageNumber()!==this.getPageNumber(n)){var l=this.props.unregisterPage;l&&l(this.getPageIndex(n)),this.loadPage()}}},{key:"componentWillUnmount",value:function(){var n=this.props.unregisterPage;n&&n(this.pageIndex),cancelRunningTask(this.runningTask)}},{key:"getPageIndex",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return isProvided(n.pageNumber)?n.pageNumber-1:isProvided(n.pageIndex)?n.pageIndex:null}},{key:"getPageNumber",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return isProvided(n.pageNumber)?n.pageNumber:isProvided(n.pageIndex)?n.pageIndex+1:null}},{key:"renderMainLayer",value:function(){var n=this.props,a=n.canvasRef,l=n.renderMode;switch(l){case"none":return null;case"svg":return React$2.createElement(PageSVG,{key:"".concat(this.pageKeyNoScale,"_svg")});case"canvas":default:return React$2.createElement(PageCanvas,{key:"".concat(this.pageKey,"_canvas"),canvasRef:a})}}},{key:"renderTextLayer",value:function(){var n=this.props.renderTextLayer;return n?React$2.createElement(TextLayer,{key:"".concat(this.pageKey,"_text")}):null}},{key:"renderAnnotationLayer",value:function(){var n=this.props.renderAnnotationLayer;return n?React$2.createElement(AnnotationLayer,{key:"".concat(this.pageKey,"_annotations")}):null}},{key:"renderChildren",value:function(){var n=this.props.children;return React$2.createElement(PageContext.Provider,{value:this.childContext},this.renderMainLayer(),this.renderTextLayer(),this.renderAnnotationLayer(),n)}},{key:"renderContent",value:function(){var n=this.pageNumber,a=this.props.pdf,l=this.state.page;if(!n){var u=this.props.noData;return React$2.createElement(Message$1,{type:"no-data"},typeof u=="function"?u():u)}if(a===null||l===null){var f=this.props.loading;return React$2.createElement(Message$1,{type:"loading"},typeof f=="function"?f():f)}if(a===!1||l===!1){var d=this.props.error;return React$2.createElement(Message$1,{type:"error"},typeof d=="function"?d():d)}return this.renderChildren()}},{key:"render",value:function(){var n=this.pageNumber,a=this.props,l=a.className,u=a.inputRef;return React$2.createElement("div",_extends({className:mergeClassNames("react-pdf__Page",l),"data-page-number":n,ref:mergeRefs(u,this.ref),style:{position:"relative"}},this.eventProps),this.renderContent())}},{key:"childContext",get:function(){var n=this.state.page;if(!n)return{};var a=this.props,l=a.customTextRenderer,u=a.onGetAnnotationsError,f=a.onGetAnnotationsSuccess,d=a.onGetTextError,h=a.onGetTextSuccess,y=a.onRenderAnnotationLayerError,E=a.onRenderAnnotationLayerSuccess,p=a.onRenderError,_=a.onRenderSuccess,g=a.renderInteractiveForms;return{customTextRenderer:l,onGetAnnotationsError:u,onGetAnnotationsSuccess:f,onGetTextError:d,onGetTextSuccess:h,onRenderAnnotationLayerError:y,onRenderAnnotationLayerSuccess:E,onRenderError:p,onRenderSuccess:_,page:n,renderInteractiveForms:g,rotate:this.rotate,scale:this.scale}}},{key:"pageIndex",get:function(){return this.getPageIndex()}},{key:"pageNumber",get:function(){return this.getPageNumber()}},{key:"rotate",get:function(){var n=this.props.rotate;if(isProvided(n))return n;var a=this.state.page;return a?a.rotate:null}},{key:"scale",get:function(){var n=this.state.page;if(!n)return null;var a=this.props,l=a.scale,u=a.width,f=a.height,d=this.rotate,h=1,y=l===null?defaultScale:l;if(u||f){var E=n.getViewport({scale:1,rotation:d});h=u?u/E.width:f/E.height}return y*h}},{key:"eventProps",get:function(){var n=this;return makeEventProps(this.props,function(){var a=n.state.page;return a&&makePageCallback(a,n.scale)})}},{key:"pageKey",get:function(){var n=this.state.page;return"".concat(n.pageIndex,"@").concat(this.scale,"/").concat(this.rotate)}},{key:"pageKeyNoScale",get:function(){var n=this.state.page;return"".concat(n.pageIndex,"/").concat(this.rotate)}}]),r}(React$2.PureComponent);PageInternal.defaultProps={error:"Failed to load the page.",loading:"Loading page…",noData:"No page specified.",renderAnnotationLayer:!0,renderInteractiveForms:!1,renderMode:"canvas",renderTextLayer:!0,scale:defaultScale};var isFunctionOrNode=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.node]);PageInternal.propTypes=_objectSpread(_objectSpread({},eventProps),{},{children:PropTypes$1.node,className:isClassName,customTextRenderer:PropTypes$1.func,error:isFunctionOrNode,height:PropTypes$1.number,imageResourcesPath:PropTypes$1.string,inputRef:isRef,loading:isFunctionOrNode,noData:isFunctionOrNode,onGetTextError:PropTypes$1.func,onGetTextSuccess:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,pageIndex:isPageIndex,pageNumber:isPageNumber,pdf:isPdf,registerPage:PropTypes$1.func,renderAnnotationLayer:PropTypes$1.bool,renderInteractiveForms:PropTypes$1.bool,renderMode:isRenderMode,renderTextLayer:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number,unregisterPage:PropTypes$1.func,width:PropTypes$1.number});function Page(o,e){return React$2.createElement(DocumentContext.Consumer,null,function(r){return React$2.createElement(PageInternal,_extends({ref:e},r,o))})}const Page$1=React$2.forwardRef(Page);isLocalFileSystem&&warnOnDev("You are running React-PDF from your local file system. PDF.js Worker may fail to load due to browser's security policies. If you're on Google Chrome, you can use --allow-file-access-from-files flag for debugging purposes.");pdfExports.GlobalWorkerOptions.workerSrc="pdf.worker.js";const DeviceDetection=()=>navigator.userAgent.match(/(android)/i)||["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,BrowserDetection=()=>{const o=navigator.userAgent.toLowerCase(),e=o.indexOf("firefox")>-1,r=o.indexOf("safari")>-1&&o.indexOf("chrome")<=-1;let t="default";return e?t="firefox":r&&(t="safari"),t};pdfExports.GlobalWorkerOptions.workerSrc=`//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfExports.version}/pdf.worker.js`;const SCALE_LIMIT=2,maxValues={default:{area:268435456,sideBig:65535},firefox:{area:124992400,sideBig:32767},safari:{area:16777216,sideBig:4194303}},getMaxPermitted=()=>{const o=BrowserDetection();return maxValues[o]},formatScale=o=>o>1?Math.floor(o):Math.floor(o*100)/100,getMaxScaleByArea=(o,e,r)=>{const t=e*r*window.devicePixelRatio**2,n=Math.sqrt(o/t);return formatScale(n)},getMaxScaleBySide=(o,e,r)=>{const t=e>r?e:r,a=o/window.devicePixelRatio/t;return formatScale(a)};function PdfVisor({url:o,endPdf:e,emitNumberOfPages:r,translate:t,soundActions:n,keyboardControl:a}){const l=React$2.useRef(),[u,f]=React$2.useState(1),[d,h]=React$2.useState(!0),[y,E]=React$2.useState(),[p,_]=React$2.useState(1),[g]=n,x=React$2.useCallback(A=>{A.getPage(1).then(w=>{const P=w.getViewport(1),O=P.viewBox[2]-P.viewBox[0],k=P.viewBox[3]-P.viewBox[1],D=getMaxPermitted(),F=getMaxScaleByArea(D.area,O,k),G=getMaxScaleBySide(D.sideBig,O,k),V=F<G?F:G;_(V>SCALE_LIMIT?SCALE_LIMIT:V)}),f(A.numPages),A.numPages&&r({numPages:A.numPages,currentPage:y});const T=()=>(setTimeout(()=>{l.current&&l.current.scrollHeight<=l.current.offsetHeight&&h(!1)},1e3),()=>{T&&clearTimeout(T)});T()},[y,r]);React$2.useEffect(()=>{E(1)},[]);const C={file:o,loading:"Loading file...",onLoadSuccess:x,onLoadError:A=>console.error(A)},R=A=>{g("click-ui"),l.current.scrollTo(0,0),h(!1),E(y+A),r({numPages:u,currentPage:y+A}),y===u-1&&e()};a(u>1&&y!==1?()=>R(-1):null,u>1&&y!==u?()=>R(1):null);const S=()=>{h(!1)};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"pdf-box",dir:LangIsRtl()?"rtl":"auto",children:[jsxRuntimeExports.jsxs("div",{className:"pdf-box__scrollwrap",children:[jsxRuntimeExports.jsxs("div",{tabIndex:"0",onScroll:S,ref:l,className:`pdf-box__scroll ${d?"pdf-box__scroll--overlay":""}`,children:[jsxRuntimeExports.jsx(Document$1,{...C,children:jsxRuntimeExports.jsx(Page$1,{renderTextLayer:!1,scale:p,pageNumber:y})}),jsxRuntimeExports.jsx("div",{className:"pdf-box__mouse icon-scroll-down-black"})]}),u>1&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:"pdf-box__paginator",children:jsxRuntimeExports.jsxs("span",{children:[t("storylines.misc.page")," ",y," ",t("storylines.misc.of")," ",u]})})})]}),u>1&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{className:`pdf-box__arrow pdf-box__arrow--left gat--btn__round ${y===1?"pdf-box__arrow--hidden":""}`,type:"button",disabled:y===1,onClick:()=>R(-1),"aria-label":LangIsRtl()?t("storylines.misc.nextPage"):t("storylines.misc.previousPage"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{className:`pdf-box__arrow pdf-box__arrow--right gat--btn__round ${y===u?"pdf-box__arrow--hidden":""}`,type:"button",disabled:y===u,onClick:()=>R(1),"aria-label":LangIsRtl()?t("storylines.misc.previousPage"):t("storylines.misc.nextPage"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})})}function PdfComponent({emitEvent:o,soundActions:e,keyboardControl:r,documentType:t,name:n,required:a,viewed:l,visible:u,documentId:f,documentId_labelId:d,...h}){const y=k=>o({type:"translate",payload:k}),[E]=e,p=h.document,{url:_}=p||"",[g,x]=React$2.useState(!1),C=React$2.useMemo(()=>({documentType:t,name:n,documentId:d,type:"pdf"}),[t,n,d]),R=React$2.useCallback(()=>{o({type:"finishMedia",payload:C})},[C,o]),[S,A]=React$2.useState(!1),[T,w]=React$2.useState(!1);if(React$2.useEffect(()=>{u||R(),a||x(!0)},[u,R,a]),!u)return null;const P=()=>{x(!0)},O=k=>{k.numPages===k.currentPage?w(!0):w(!1),k.numPages===1&&A(!0)};return r(null,S||!l&&T||T&&!a?R:null,S||!l&&T||!a?R:null),jsxRuntimeExports.jsxs("div",{className:`${l?"notes--results":""}`,children:[(S||!l&&g)&&jsxRuntimeExports.jsx("div",{className:"position--absolute top right z-index1",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:()=>{R(),E("click-ui")},"aria-label":y("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}),_&&jsxRuntimeExports.jsx(PdfVisor,{soundActions:e,emitNumberOfPages:k=>O(k),url:_,endPdf:P,translate:y,keyboardControl:r})]})}function UrlComponent({emitEvent:o,name:e,name_labelId:r,link:t,link_labelId:n,text:a,text_labelId:l,textForLink:u,viewed:f,documentType:d,soundActions:h,keyboardControl:y}){const E=S=>o({type:"translate",payload:S}),p={documentType:d,name:r,text:l,link:n,type:"url"},[_]=h,g=()=>{_("click-ui"),o({type:"finishMedia",payload:p})},[x,C]=React$2.useState(!1);y(null,!f&&x?g:null,!f&&x?g:null);const R=t.indexOf("http")!==0?`http://${t}`:t;return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup popup--link",children:[!f&&x?jsxRuntimeExports.jsx("button",{className:"popup--close unset-button","data-testid":"close",type:"button","aria-label":E("storylines.misc.closePiece"),onClick:()=>g(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})}):null,jsxRuntimeExports.jsx("span",{className:"popup--link__title",children:e}),jsxRuntimeExports.jsx("span",{className:"popup--link__desc",children:a}),jsxRuntimeExports.jsx("a",{className:"popup--link__lineclamp popup--link__url",href:R,target:"_blank",rel:"noopener noreferrer",onClick:()=>{_("click-ui"),C(!0)},children:u||t})]})})}var hls={exports:{}};(function(o,e){typeof window<"u"&&function(t,n){o.exports=n()}(commonjsGlobal,function(){return function(r){var t={};function n(a){if(t[a])return t[a].exports;var l=t[a]={i:a,l:!1,exports:{}};return r[a].call(l.exports,l,l.exports,n),l.l=!0,l.exports}return n.m=r,n.c=t,n.d=function(a,l,u){n.o(a,l)||Object.defineProperty(a,l,{enumerable:!0,get:u})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,l){if(l&1&&(a=n(a)),l&8||l&4&&typeof a=="object"&&a&&a.__esModule)return a;var u=Object.create(null);if(n.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:a}),l&2&&typeof a!="string")for(var f in a)n.d(u,f,(function(d){return a[d]}).bind(null,f));return u},n.n=function(a){var l=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(l,"a",l),l},n.o=function(a,l){return Object.prototype.hasOwnProperty.call(a,l)},n.p="/dist/",n(n.s="./src/hls.js")}({"./node_modules/eventemitter3/index.js":function(r,t,n){var a=Object.prototype.hasOwnProperty,l="~";function u(){}Object.create&&(u.prototype=Object.create(null),new u().__proto__||(l=!1));function f(E,p,_){this.fn=E,this.context=p,this.once=_||!1}function d(E,p,_,g,x){if(typeof _!="function")throw new TypeError("The listener must be a function");var C=new f(_,g||E,x),R=l?l+p:p;return E._events[R]?E._events[R].fn?E._events[R]=[E._events[R],C]:E._events[R].push(C):(E._events[R]=C,E._eventsCount++),E}function h(E,p){--E._eventsCount===0?E._events=new u:delete E._events[p]}function y(){this._events=new u,this._eventsCount=0}y.prototype.eventNames=function(){var p=[],_,g;if(this._eventsCount===0)return p;for(g in _=this._events)a.call(_,g)&&p.push(l?g.slice(1):g);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(_)):p},y.prototype.listeners=function(p){var _=l?l+p:p,g=this._events[_];if(!g)return[];if(g.fn)return[g.fn];for(var x=0,C=g.length,R=new Array(C);x<C;x++)R[x]=g[x].fn;return R},y.prototype.listenerCount=function(p){var _=l?l+p:p,g=this._events[_];return g?g.fn?1:g.length:0},y.prototype.emit=function(p,_,g,x,C,R){var S=l?l+p:p;if(!this._events[S])return!1;var A=this._events[S],T=arguments.length,w,P;if(A.fn){switch(A.once&&this.removeListener(p,A.fn,void 0,!0),T){case 1:return A.fn.call(A.context),!0;case 2:return A.fn.call(A.context,_),!0;case 3:return A.fn.call(A.context,_,g),!0;case 4:return A.fn.call(A.context,_,g,x),!0;case 5:return A.fn.call(A.context,_,g,x,C),!0;case 6:return A.fn.call(A.context,_,g,x,C,R),!0}for(P=1,w=new Array(T-1);P<T;P++)w[P-1]=arguments[P];A.fn.apply(A.context,w)}else{var O=A.length,k;for(P=0;P<O;P++)switch(A[P].once&&this.removeListener(p,A[P].fn,void 0,!0),T){case 1:A[P].fn.call(A[P].context);break;case 2:A[P].fn.call(A[P].context,_);break;case 3:A[P].fn.call(A[P].context,_,g);break;case 4:A[P].fn.call(A[P].context,_,g,x);break;default:if(!w)for(k=1,w=new Array(T-1);k<T;k++)w[k-1]=arguments[k];A[P].fn.apply(A[P].context,w)}}return!0},y.prototype.on=function(p,_,g){return d(this,p,_,g,!1)},y.prototype.once=function(p,_,g){return d(this,p,_,g,!0)},y.prototype.removeListener=function(p,_,g,x){var C=l?l+p:p;if(!this._events[C])return this;if(!_)return h(this,C),this;var R=this._events[C];if(R.fn)R.fn===_&&(!x||R.once)&&(!g||R.context===g)&&h(this,C);else{for(var S=0,A=[],T=R.length;S<T;S++)(R[S].fn!==_||x&&!R[S].once||g&&R[S].context!==g)&&A.push(R[S]);A.length?this._events[C]=A.length===1?A[0]:A:h(this,C)}return this},y.prototype.removeAllListeners=function(p){var _;return p?(_=l?l+p:p,this._events[_]&&h(this,_)):(this._events=new u,this._eventsCount=0),this},y.prototype.off=y.prototype.removeListener,y.prototype.addListener=y.prototype.on,y.prefixed=l,y.EventEmitter=y,r.exports=y},"./node_modules/node-libs-browser/node_modules/events/events.js":function(r,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}r.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(d){if(!l(d)||d<0||isNaN(d))throw TypeError("n must be a positive number");return this._maxListeners=d,this},n.prototype.emit=function(d){var h,y,E,p,_,g;if(this._events||(this._events={}),d==="error"&&(!this._events.error||u(this._events.error)&&!this._events.error.length)){if(h=arguments[1],h instanceof Error)throw h;var x=new Error('Uncaught, unspecified "error" event. ('+h+")");throw x.context=h,x}if(y=this._events[d],f(y))return!1;if(a(y))switch(arguments.length){case 1:y.call(this);break;case 2:y.call(this,arguments[1]);break;case 3:y.call(this,arguments[1],arguments[2]);break;default:p=Array.prototype.slice.call(arguments,1),y.apply(this,p)}else if(u(y))for(p=Array.prototype.slice.call(arguments,1),g=y.slice(),E=g.length,_=0;_<E;_++)g[_].apply(this,p);return!0},n.prototype.addListener=function(d,h){var y;if(!a(h))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",d,a(h.listener)?h.listener:h),this._events[d]?u(this._events[d])?this._events[d].push(h):this._events[d]=[this._events[d],h]:this._events[d]=h,u(this._events[d])&&!this._events[d].warned&&(f(this._maxListeners)?y=n.defaultMaxListeners:y=this._maxListeners,y&&y>0&&this._events[d].length>y&&(this._events[d].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[d].length),typeof console.trace=="function"&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(d,h){if(!a(h))throw TypeError("listener must be a function");var y=!1;function E(){this.removeListener(d,E),y||(y=!0,h.apply(this,arguments))}return E.listener=h,this.on(d,E),this},n.prototype.removeListener=function(d,h){var y,E,p,_;if(!a(h))throw TypeError("listener must be a function");if(!this._events||!this._events[d])return this;if(y=this._events[d],p=y.length,E=-1,y===h||a(y.listener)&&y.listener===h)delete this._events[d],this._events.removeListener&&this.emit("removeListener",d,h);else if(u(y)){for(_=p;_-- >0;)if(y[_]===h||y[_].listener&&y[_].listener===h){E=_;break}if(E<0)return this;y.length===1?(y.length=0,delete this._events[d]):y.splice(E,1),this._events.removeListener&&this.emit("removeListener",d,h)}return this},n.prototype.removeAllListeners=function(d){var h,y;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[d]&&delete this._events[d],this;if(arguments.length===0){for(h in this._events)h!=="removeListener"&&this.removeAllListeners(h);return this.removeAllListeners("removeListener"),this._events={},this}if(y=this._events[d],a(y))this.removeListener(d,y);else if(y)for(;y.length;)this.removeListener(d,y[y.length-1]);return delete this._events[d],this},n.prototype.listeners=function(d){var h;return!this._events||!this._events[d]?h=[]:a(this._events[d])?h=[this._events[d]]:h=this._events[d].slice(),h},n.prototype.listenerCount=function(d){if(this._events){var h=this._events[d];if(a(h))return 1;if(h)return h.length}return 0},n.listenerCount=function(d,h){return d.listenerCount(h)};function a(d){return typeof d=="function"}function l(d){return typeof d=="number"}function u(d){return typeof d=="object"&&d!==null}function f(d){return d===void 0}},"./node_modules/url-toolkit/src/url-toolkit.js":function(r,t,n){(function(a){var l=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,u=/^([^\/?#]*)(.*)$/,f=/(?:\/|^)\.(?=\/)/g,d=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,h={buildAbsoluteURL:function(y,E,p){if(p=p||{},y=y.trim(),E=E.trim(),!E){if(!p.alwaysNormalize)return y;var _=h.parseURL(y);if(!_)throw new Error("Error trying to parse base URL.");return _.path=h.normalizePath(_.path),h.buildURLFromParts(_)}var g=h.parseURL(E);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return p.alwaysNormalize?(g.path=h.normalizePath(g.path),h.buildURLFromParts(g)):E;var x=h.parseURL(y);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var C=u.exec(x.path);x.netLoc=C[1],x.path=C[2]}x.netLoc&&!x.path&&(x.path="/");var R={scheme:x.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(R.netLoc=x.netLoc,g.path[0]!=="/"))if(!g.path)R.path=x.path,g.params||(R.params=x.params,g.query||(R.query=x.query));else{var S=x.path,A=S.substring(0,S.lastIndexOf("/")+1)+g.path;R.path=h.normalizePath(A)}return R.path===null&&(R.path=p.alwaysNormalize?h.normalizePath(g.path):g.path),h.buildURLFromParts(R)},parseURL:function(y){var E=l.exec(y);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(y){for(y=y.split("").reverse().join("").replace(f,"");y.length!==(y=y.replace(d,"")).length;);return y.split("").reverse().join("")},buildURLFromParts:function(y){return y.scheme+y.netLoc+y.path+y.params+y.query+y.fragment}};r.exports=h})()},"./node_modules/webworkify-webpack/index.js":function(r,t,n){function a(p){var _={};function g(C){if(_[C])return _[C].exports;var R=_[C]={i:C,l:!1,exports:{}};return p[C].call(R.exports,R,R.exports,g),R.l=!0,R.exports}g.m=p,g.c=_,g.i=function(C){return C},g.d=function(C,R,S){g.o(C,R)||Object.defineProperty(C,R,{configurable:!1,enumerable:!0,get:S})},g.r=function(C){Object.defineProperty(C,"__esModule",{value:!0})},g.n=function(C){var R=C&&C.__esModule?function(){return C.default}:function(){return C};return g.d(R,"a",R),R},g.o=function(C,R){return Object.prototype.hasOwnProperty.call(C,R)},g.p="/",g.oe=function(C){throw console.error(C),C};var x=g(g.s=ENTRY_MODULE);return x.default||x}var l="[\\.|\\-|\\+|\\w|/|@]+",u="\\((/\\*.*?\\*/)?s?.*?("+l+").*?\\)";function f(p){return(p+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function d(p){return!isNaN(1*p)}function h(p,_,g){var x={};x[g]=[];var C=_.toString(),R=C.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!R)return x;for(var S=R[1],A=new RegExp("(\\\\n|\\W)"+f(S)+u,"g"),T;T=A.exec(C);)T[3]!=="dll-reference"&&x[g].push(T[3]);for(A=new RegExp("\\("+f(S)+'\\("(dll-reference\\s('+l+'))"\\)\\)'+u,"g");T=A.exec(C);)p[T[2]]||(x[g].push(T[1]),p[T[2]]=n(T[1]).m),x[T[2]]=x[T[2]]||[],x[T[2]].push(T[4]);for(var w=Object.keys(x),P=0;P<w.length;P++)for(var O=0;O<x[w[P]].length;O++)d(x[w[P]][O])&&(x[w[P]][O]=1*x[w[P]][O]);return x}function y(p){var _=Object.keys(p);return _.reduce(function(g,x){return g||p[x].length>0},!1)}function E(p,_){for(var g={main:[_]},x={main:[]},C={main:{}};y(g);)for(var R=Object.keys(g),S=0;S<R.length;S++){var A=R[S],T=g[A],w=T.pop();if(C[A]=C[A]||{},!(C[A][w]||!p[A][w])){C[A][w]=!0,x[A]=x[A]||[],x[A].push(w);for(var P=h(p,p[A][w],A),O=Object.keys(P),k=0;k<O.length;k++)g[O[k]]=g[O[k]]||[],g[O[k]]=g[O[k]].concat(P[O[k]])}}return x}r.exports=function(p,_){_=_||{};var g={main:n.m},x=_.all?{main:Object.keys(g.main)}:E(g,p),C="";Object.keys(x).filter(function(w){return w!=="main"}).forEach(function(w){for(var P=0;x[w][P];)P++;x[w].push(P),g[w][P]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",C=C+"var "+w+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(P))+")({"+x[w].map(function(O){return""+JSON.stringify(O)+": "+g[w][O].toString()}).join(",")+`});
|
|
52
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _toConsumableArray(o){return _arrayWithoutHoles(o)||_iterableToArray(o)||_unsupportedIterableToArray$1(o)||_nonIterableSpread()}var eventProps=function(){var o={};return[].concat(_toConsumableArray(mouseEvents),_toConsumableArray(touchEvents),_toConsumableArray(keyboardEvents)).forEach(function(e){o[e]=PropTypes$1.func}),o}(),fileTypes=[PropTypes$1.string,PropTypes$1.instanceOf(ArrayBuffer),PropTypes$1.shape({data:PropTypes$1.object,httpHeaders:PropTypes$1.object,range:PropTypes$1.object,url:PropTypes$1.string,withCredentials:PropTypes$1.bool})];typeof File<"u"&&fileTypes.push(PropTypes$1.instanceOf(File));typeof Blob<"u"&&fileTypes.push(PropTypes$1.instanceOf(Blob));var isClassName=PropTypes$1.oneOfType([PropTypes$1.string,PropTypes$1.arrayOf(PropTypes$1.string)]);PropTypes$1.oneOfType(fileTypes);var isLinkService=PropTypes$1.instanceOf(LinkService);PropTypes$1.oneOf(["_self","_blank","_parent","_top"]);var isPage=PropTypes$1.shape({_transport:PropTypes$1.shape({fontLoader:PropTypes$1.object.isRequired}).isRequired,commonObjs:PropTypes$1.shape({_objs:PropTypes$1.object.isRequired}).isRequired,getAnnotations:PropTypes$1.func.isRequired,getTextContent:PropTypes$1.func.isRequired,getViewport:PropTypes$1.func.isRequired,render:PropTypes$1.func.isRequired}),isPageIndex=function o(e,r,t){var n=e[r],a=e.pageNumber,l=e.pdf;if(!isDefined(l))return null;if(isDefined(n)){if(typeof n!="number")return new Error("`".concat(r,"` of type `").concat(_typeof$1(n),"` supplied to `").concat(t,"`, expected `number`."));if(n<0)return new Error("Expected `".concat(r,"` to be greater or equal to 0."));var u=l.numPages;if(n+1>u)return new Error("Expected `".concat(r,"` to be less or equal to ").concat(u-1,"."))}else if(!isDefined(a))return new Error("`".concat(r,"` not supplied. Either pageIndex or pageNumber must be supplied to `").concat(t,"`."));return null},isPageNumber=function o(e,r,t){var n=e[r],a=e.pageIndex,l=e.pdf;if(!isDefined(l))return null;if(isDefined(n)){if(typeof n!="number")return new Error("`".concat(r,"` of type `").concat(_typeof$1(n),"` supplied to `").concat(t,"`, expected `number`."));if(n<1)return new Error("Expected `".concat(r,"` to be greater or equal to 1."));var u=l.numPages;if(n>u)return new Error("Expected `".concat(r,"` to be less or equal to ").concat(u,"."))}else if(!isDefined(a))return new Error("`".concat(r,"` not supplied. Either pageIndex or pageNumber must be supplied to `").concat(t,"`."));return null},isPdf=PropTypes$1.oneOfType([PropTypes$1.shape({getDestination:PropTypes$1.func.isRequired,getOutline:PropTypes$1.func.isRequired,getPage:PropTypes$1.func.isRequired,numPages:PropTypes$1.number.isRequired}),PropTypes$1.bool]),isRef=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.shape({current:PropTypes$1.any})]),isRenderMode=PropTypes$1.oneOf(["canvas","none","svg"]),isRotate=PropTypes$1.oneOf([0,90,180,270]);function ownKeys$2(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread$2(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$2(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys$2(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function _createSuper$6(o){var e=_isNativeReflectConstruct$6();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$6(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PDFDataRangeTransport=pdfExports.PDFDataRangeTransport,Document$1=function(o){_inherits(r,o);var e=_createSuper$6(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{pdf:null}),_defineProperty(_assertThisInitialized$1(t),"viewer",{scrollPageIntoView:function(f){var d=f.pageNumber,h=t.props.onItemClick;if(h){h({pageNumber:d});return}var y=t.pages[d-1];if(y){y.scrollIntoView();return}warnOnDev("Warning: An internal link leading to page ".concat(d," was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>."))}}),_defineProperty(_assertThisInitialized$1(t),"linkService",new LinkService({eventBus})),_defineProperty(_assertThisInitialized$1(t),"loadDocument",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y,E,p,_;return _regeneratorRuntime.wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return f=null,x.prev=1,x.next=4,t.findDocumentSource();case 4:f=x.sent,t.onSourceSuccess(),x.next=11;break;case 8:x.prev=8,x.t0=x.catch(1),t.onSourceError(x.t0);case 11:if(f){x.next=13;break}return x.abrupt("return");case 13:return t.setState(function(C){return C.pdf?{pdf:null}:null}),d=t.props,h=d.options,y=d.onLoadProgress,E=d.onPassword,x.prev=15,cancelRunningTask(t.runningTask),t.loadingTask=pdfExports.getDocument(_objectSpread$2(_objectSpread$2({},f),h)),t.loadingTask.onPassword=E,y&&(t.loadingTask.onProgress=y),p=makeCancellablePromise(t.loadingTask.promise),t.runningTask=p,x.next=24,p.promise;case 24:_=x.sent,t.setState(function(C){return C.pdf&&C.pdf.fingerprint===_.fingerprint?null:{pdf:_}},t.onLoadSuccess),x.next=31;break;case 28:x.prev=28,x.t1=x.catch(15),t.onLoadError(x.t1);case 31:case"end":return x.stop()}},u,null,[[1,8],[15,28]])}))),_defineProperty(_assertThisInitialized$1(t),"setupLinkService",function(){t.linkService.setViewer(t.viewer);var u=_assertThisInitialized$1(t);Object.defineProperty(t.linkService,"externalLinkTarget",{get:function(){var d=u.props.externalLinkTarget;switch(d){case"_self":return 1;case"_blank":return 2;case"_parent":return 3;case"_top":return 4;default:return 0}}})}),_defineProperty(_assertThisInitialized$1(t),"onSourceSuccess",function(){var u=t.props.onSourceSuccess;u&&u()}),_defineProperty(_assertThisInitialized$1(t),"onSourceError",function(u){errorOnDev(u);var f=t.props.onSourceError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onLoadSuccess,f=t.state.pdf;u&&u(f),t.pages=new Array(f.numPages),t.linkService.setDocument(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({pdf:!1}),errorOnDev(u);var f=t.props.onLoadError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"findDocumentSource",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y,E;return _regeneratorRuntime.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(f=t.props.file,f){_.next=3;break}return _.abrupt("return",null);case 3:if(typeof f!="string"){_.next=9;break}if(!isDataURI(f)){_.next=7;break}return d=dataURItoByteString(f),_.abrupt("return",{data:d});case 7:return displayCORSWarning(),_.abrupt("return",{url:f});case 9:if(!(f instanceof PDFDataRangeTransport)){_.next=11;break}return _.abrupt("return",{range:f});case 11:if(!isArrayBuffer(f)){_.next=13;break}return _.abrupt("return",{data:f});case 13:if(!isBrowser){_.next=19;break}if(!(isBlob(f)||isFile(f))){_.next=19;break}return _.next=17,loadFromFile(f);case 17:return _.t0=_.sent,_.abrupt("return",{data:_.t0});case 19:if(_typeof$1(f)==="object"){_.next=21;break}throw new Error("Invalid parameter in file, need either Uint8Array, string or a parameter object");case 21:if(!(!f.url&&!f.data&&!f.range)){_.next=23;break}throw new Error("Invalid parameter object: need either .data, .range or .url");case 23:if(typeof f.url!="string"){_.next=29;break}if(!isDataURI(f.url)){_.next=28;break}return h=f.url,y=_objectWithoutProperties(f,["url"]),E=dataURItoByteString(h),_.abrupt("return",_objectSpread$2({data:E},y));case 28:displayCORSWarning();case 29:return _.abrupt("return",f);case 30:case"end":return _.stop()}},u)}))),_defineProperty(_assertThisInitialized$1(t),"registerPage",function(u,f){t.pages[u]=f}),_defineProperty(_assertThisInitialized$1(t),"unregisterPage",function(u){delete t.pages[u]}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.loadDocument(),this.setupLinkService()}},{key:"componentDidUpdate",value:function(n){var a=this.props.file;a!==n.file&&this.loadDocument()}},{key:"componentWillUnmount",value:function(){this.loadingTask&&this.loadingTask.destroy(),cancelRunningTask(this.runningTask)}},{key:"renderChildren",value:function(){var n=this.props.children;return React$2.createElement(DocumentContext.Provider,{value:this.childContext},n)}},{key:"renderContent",value:function(){var n=this.props.file,a=this.state.pdf;if(!n){var l=this.props.noData;return React$2.createElement(Message$1,{type:"no-data"},typeof l=="function"?l():l)}if(a===null){var u=this.props.loading;return React$2.createElement(Message$1,{type:"loading"},typeof u=="function"?u():u)}if(a===!1){var f=this.props.error;return React$2.createElement(Message$1,{type:"error"},typeof f=="function"?f():f)}return this.renderChildren()}},{key:"render",value:function(){var n=this.props,a=n.className,l=n.inputRef;return React$2.createElement("div",_extends({className:mergeClassNames("react-pdf__Document",a),ref:l},this.eventProps),this.renderContent())}},{key:"childContext",get:function(){var n=this.linkService,a=this.registerPage,l=this.unregisterPage,u=this.props,f=u.imageResourcesPath,d=u.renderMode,h=u.rotate,y=this.state.pdf;return{imageResourcesPath:f,linkService:n,pdf:y,registerPage:a,renderMode:d,rotate:h,unregisterPage:l}}},{key:"eventProps",get:function(){var n=this;return makeEventProps(this.props,function(){return n.state.pdf})}}]),r}(React$2.PureComponent);Document$1.defaultProps={error:"Failed to load PDF file.",loading:"Loading PDF…",noData:"No PDF file specified.",onPassword:function o(e,r){switch(r){case PasswordResponses.NEED_PASSWORD:{var t=prompt("Enter the password to open this PDF file.");e(t);break}case PasswordResponses.INCORRECT_PASSWORD:{var n=prompt("Invalid password. Please try again.");e(n);break}}}};var isFunctionOrNode$1=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.node]);Document$1.propTypes=_objectSpread$2(_objectSpread$2({},eventProps),{},{children:PropTypes$1.node,className:isClassName,error:isFunctionOrNode$1,file:isFile,imageResourcesPath:PropTypes$1.string,inputRef:isRef,loading:isFunctionOrNode$1,noData:isFunctionOrNode$1,onItemClick:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadProgress:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,onPassword:PropTypes$1.func,onSourceError:PropTypes$1.func,onSourceSuccess:PropTypes$1.func,rotate:PropTypes$1.number});var isDestination=PropTypes$1.oneOfType([PropTypes$1.string,PropTypes$1.arrayOf(PropTypes$1.any)]);PropTypes$1.shape({dest:isDestination,items:PropTypes$1.arrayOf(PropTypes$1.shape({dest:isDestination,title:PropTypes$1.string})),title:PropTypes$1.string}).isRequired,PropTypes$1.func,isPdf.isRequired;function ownKeys$1(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread$1(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$1(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys$1(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}_objectSpread$1({className:isClassName,inputRef:isRef,onItemClick:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,pdf:isPdf},eventProps);function mergeRefs(){for(var o=[],e=0;e<arguments.length;e++)o[e]=arguments[e];var r=o.filter(Boolean);if(r.length<=1){var t=r[0];return t||null}return function(a){r.forEach(function(l){typeof l=="function"?l(a):l&&(l.current=a)})}}const PageContext=React$2.createContext(null);function _createSuper$5(o){var e=_isNativeReflectConstruct$5();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$5(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PageCanvasInternal=function(o){_inherits(r,o);var e=_createSuper$5(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){t.renderer=null;var u=t.props,f=u.onRenderSuccess,d=u.page,h=u.scale;f&&f(makePageCallback(d,h))}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){if(!isCancelException(u)){errorOnDev(u);var f=t.props.onRenderError;f&&f(u)}}),_defineProperty(_assertThisInitialized$1(t),"drawPageOnCanvas",function(){var u=_assertThisInitialized$1(t),f=u.canvasLayer;if(!f)return null;var d=_assertThisInitialized$1(t),h=d.renderViewport,y=d.viewport,E=t.props,p=E.page,_=E.renderInteractiveForms;f.width=h.width,f.height=h.height,f.style.width="".concat(Math.floor(y.width),"px"),f.style.height="".concat(Math.floor(y.height),"px");var g={get canvasContext(){return f.getContext("2d")},viewport:h,renderInteractiveForms:_};return t.cancelRenderingTask(),t.renderer=p.render(g),t.renderer.promise.then(t.onRenderSuccess).catch(t.onRenderError)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.drawPageOnCanvas()}},{key:"componentDidUpdate",value:function(n){var a=this.props,l=a.page,u=a.renderInteractiveForms;u!==n.renderInteractiveForms&&(l.cleanup(),this.drawPageOnCanvas())}},{key:"componentWillUnmount",value:function(){this.cancelRenderingTask(),this.canvasLayer&&(this.canvasLayer.width=0,this.canvasLayer.height=0,this.canvasLayer=null)}},{key:"cancelRenderingTask",value:function(){this.renderer&&this.renderer._internalRenderTask.running&&this.renderer._internalRenderTask.cancel()}},{key:"render",value:function(){var n=this,a=this.props.canvasRef;return React$2.createElement("canvas",{className:"react-pdf__Page__canvas",dir:"ltr",ref:mergeRefs(a,function(l){n.canvasLayer=l}),style:{display:"block",userSelect:"none"}})}},{key:"renderViewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale,f=getPixelRatio();return a.getViewport({scale:u*f,rotation:l})}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);PageCanvasInternal.propTypes={canvasRef:isRef,onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,page:isPage.isRequired,renderInteractiveForms:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number};function PageCanvas(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(PageCanvasInternal,_extends({},e,o))})}function _createSuper$4(o){var e=_isNativeReflectConstruct$4();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$4(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var PageSVGInternal=function(o){_inherits(r,o);var e=_createSuper$4(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{svg:null}),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){t.renderer=null;var u=t.props,f=u.onRenderSuccess,d=u.page,h=u.scale;f&&f(makePageCallback(d,h))}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){if(!isCancelException(u)){errorOnDev(u);var f=t.props.onRenderError;f&&f(u)}}),_defineProperty(_assertThisInitialized$1(t),"renderSVG",function(){var u=t.props.page;return t.renderer=u.getOperatorList(),t.renderer.then(function(f){var d=new pdfExports.SVGGraphics(u.commonObjs,u.objs);t.renderer=d.getSVG(f,t.viewport).then(function(h){t.setState({svg:h},t.onRenderSuccess)}).catch(t.onRenderError)}).catch(t.onRenderError)}),_defineProperty(_assertThisInitialized$1(t),"drawPageOnContainer",function(u){var f=t.state.svg;if(!(!u||!f)){u.firstElementChild||u.appendChild(f);var d=t.viewport,h=d.width,y=d.height;f.setAttribute("width",h),f.setAttribute("height",y)}}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.renderSVG()}},{key:"render",value:function(){var n=this,a=this.viewport,l=a.width,u=a.height;return React$2.createElement("div",{className:"react-pdf__Page__svg",ref:function(d){return n.drawPageOnContainer(d)},style:{display:"block",backgroundColor:"white",overflow:"hidden",width:l,height:u,userSelect:"none"}})}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);PageSVGInternal.propTypes={onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number};function PageSVG(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(PageSVGInternal,_extends({},e,o))})}function _createSuper$3(o){var e=_isNativeReflectConstruct$3();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$3(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var TextLayerItemInternal=function(o){_inherits(r,o);var e=_createSuper$3(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"getElementWidth",function(u){var f=_assertThisInitialized$1(t),d=f.sideways;return u.getBoundingClientRect()[d?"height":"width"]}),t}return _createClass(r,[{key:"componentDidMount",value:function(){this.alignTextItem()}},{key:"componentDidUpdate",value:function(){this.alignTextItem()}},{key:"getFontData",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function a(l){var u,f;return _regeneratorRuntime.wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return u=this.props.page,h.next=3,new Promise(function(y){u.commonObjs.get(l,y)});case 3:return f=h.sent,h.abrupt("return",f);case 5:case"end":return h.stop()}},a,this)}));function n(a){return t.apply(this,arguments)}return n}()},{key:"alignTextItem",value:function(){var t=_asyncToGenerator(_regeneratorRuntime.mark(function a(){var l,u,f,d,h,y,E,p,_,g,x;return _regeneratorRuntime.wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(l=this.item,l){R.next=3;break}return R.abrupt("return");case 3:return l.style.transform="",u=this.props,f=u.fontName,d=u.scale,h=u.width,l.style.fontFamily="".concat(f,", sans-serif"),R.next=8,this.getFontData(f);case 8:y=R.sent,E=y?y.fallbackName:"sans-serif",l.style.fontFamily="".concat(f,", ").concat(E),p=h*d,_=this.getElementWidth(l),g="scaleX(".concat(p/_,")"),x=y?y.ascent:0,x&&(g+=" translateY(".concat((1-x)*100,"%)")),l.style.transform=g,l.style.WebkitTransform=g;case 18:case"end":return R.stop()}},a,this)}));function n(){return t.apply(this,arguments)}return n}()},{key:"render",value:function(){var n=this,a=this.fontSize,l=this.top,u=this.left,f=this.props,d=f.customTextRenderer,h=f.scale,y=f.str;return React$2.createElement("span",{ref:function(p){n.item=p},style:{height:"1em",fontFamily:"sans-serif",fontSize:"".concat(a*h,"px"),position:"absolute",top:"".concat(l*h,"px"),left:"".concat(u*h,"px"),transformOrigin:"left bottom",whiteSpace:"pre",pointerEvents:"all"}},d?d(this.props):y)}},{key:"unrotatedViewport",get:function(){var n=this.props,a=n.page,l=n.scale;return a.getViewport({scale:l})}},{key:"rotate",get:function(){var n=this.props,a=n.page,l=n.rotate;return l-a.rotate}},{key:"sideways",get:function(){var n=this.rotate;return n%180!==0}},{key:"defaultSideways",get:function(){var n=this.unrotatedViewport.rotation;return n%180!==0}},{key:"fontSize",get:function(){var n=this.props.transform,a=this.defaultSideways,l=_slicedToArray$1(n,2),u=l[0],f=l[1];return a?f:u}},{key:"top",get:function(){var n=this.props.transform,a=this.unrotatedViewport,l=this.defaultSideways,u=_slicedToArray$1(n,6),f=u[2],d=u[3],h=u[4],y=u[5],E=_slicedToArray$1(a.viewBox,4),p=E[1],_=E[3];return l?h+f+p:_-(y+d)}},{key:"left",get:function(){var n=this.props.transform,a=this.unrotatedViewport,l=this.defaultSideways,u=_slicedToArray$1(n,6),f=u[4],d=u[5],h=_slicedToArray$1(a.viewBox,1),y=h[0];return l?d-y:f-y}}]),r}(React$2.PureComponent);TextLayerItemInternal.propTypes={customTextRenderer:PropTypes$1.func,fontName:PropTypes$1.string.isRequired,itemIndex:PropTypes$1.number.isRequired,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number,str:PropTypes$1.string.isRequired,transform:PropTypes$1.arrayOf(PropTypes$1.number).isRequired,width:PropTypes$1.number.isRequired};function TextLayerItem(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(TextLayerItemInternal,_extends({},e,o))})}function _createSuper$2(o){var e=_isNativeReflectConstruct$2();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$2(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var TextLayerInternal=function(o){_inherits(r,o);var e=_createSuper$2(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{textItems:null}),_defineProperty(_assertThisInitialized$1(t),"loadTextItems",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y;return _regeneratorRuntime.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return f=t.props.page,p.prev=1,d=makeCancellablePromise(f.getTextContent()),t.runningTask=d,p.next=6,d.promise;case 6:h=p.sent,y=h.items,t.setState({textItems:y},t.onLoadSuccess),p.next=14;break;case 11:p.prev=11,p.t0=p.catch(1),t.onLoadError(p.t0);case 14:case"end":return p.stop()}},u,null,[[1,11]])}))),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onGetTextSuccess,f=t.state.textItems;u&&u(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({textItems:!1}),errorOnDev(u);var f=t.props.onGetTextError;f&&f(u)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.page;if(!n)throw new Error("Attempted to load page text content, but no page was specified.");this.loadTextItems()}},{key:"componentDidUpdate",value:function(n){var a=this.props.page;n.page&&a!==n.page&&this.loadTextItems()}},{key:"componentWillUnmount",value:function(){cancelRunningTask(this.runningTask)}},{key:"renderTextItems",value:function(){var n=this.state.textItems;return n?n.map(function(a,l){return React$2.createElement(TextLayerItem,_extends({key:l,itemIndex:l},a))}):null}},{key:"render",value:function(){var n=this.unrotatedViewport,a=this.rotate;return React$2.createElement("div",{className:"react-pdf__Page__textContent",style:{position:"absolute",top:"50%",left:"50%",width:"".concat(n.width,"px"),height:"".concat(n.height,"px"),color:"transparent",transform:"translate(-50%, -50%) rotate(".concat(a,"deg)"),WebkitTransform:"translate(-50%, -50%) rotate(".concat(a,"deg)"),pointerEvents:"none"}},this.renderTextItems())}},{key:"unrotatedViewport",get:function(){var n=this.props,a=n.page,l=n.scale;return a.getViewport({scale:l})}},{key:"rotate",get:function(){var n=this.props,a=n.page,l=n.rotate;return l-a.rotate}}]),r}(React$2.PureComponent);TextLayerInternal.propTypes={onGetTextError:PropTypes$1.func,onGetTextSuccess:PropTypes$1.func,page:isPage.isRequired,rotate:isRotate,scale:PropTypes$1.number};function TextLayer(o){return React$2.createElement(PageContext.Consumer,null,function(e){return React$2.createElement(TextLayerInternal,_extends({},e,o))})}function _createSuper$1(o){var e=_isNativeReflectConstruct$1();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct$1(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var AnnotationLayerInternal=function(o){_inherits(r,o);var e=_createSuper$1(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{annotations:null}),_defineProperty(_assertThisInitialized$1(t),"loadAnnotations",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h;return _regeneratorRuntime.wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return f=t.props.page,E.prev=1,d=makeCancellablePromise(f.getAnnotations()),t.runningTask=d,E.next=6,d.promise;case 6:h=E.sent,t.setState({annotations:h},t.onLoadSuccess),E.next=13;break;case 10:E.prev=10,E.t0=E.catch(1),t.onLoadError(E.t0);case 13:case"end":return E.stop()}},u,null,[[1,10]])}))),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props.onGetAnnotationsSuccess,f=t.state.annotations;u&&u(f)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){t.setState({annotations:!1}),errorOnDev(u);var f=t.props.onGetAnnotationsError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"onRenderSuccess",function(){var u=t.props.onRenderAnnotationLayerSuccess;u&&u()}),_defineProperty(_assertThisInitialized$1(t),"onRenderError",function(u){errorOnDev(u);var f=t.props.onRenderAnnotationLayerError;f&&f(u)}),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.page;if(!n)throw new Error("Attempted to load page annotations, but no page was specified.");this.loadAnnotations()}},{key:"componentDidUpdate",value:function(n){var a=this.props,l=a.page,u=a.renderInteractiveForms;(n.page&&l!==n.page||u!==n.renderInteractiveForms)&&this.loadAnnotations()}},{key:"componentWillUnmount",value:function(){cancelRunningTask(this.runningTask)}},{key:"renderAnnotationLayer",value:function(){var n=this.state.annotations;if(n){var a=this.props,l=a.imageResourcesPath,u=a.linkService,f=a.page,d=a.renderInteractiveForms,h=this.viewport.clone({dontFlip:!0}),y={annotations:n,div:this.annotationLayer,imageResourcesPath:l,linkService:u,page:f,renderInteractiveForms:d,viewport:h};this.annotationLayer.innerHTML="";try{pdfExports.AnnotationLayer.render(y),this.onRenderSuccess()}catch(E){this.onRenderError(E)}}}},{key:"render",value:function(){var n=this;return React$2.createElement("div",{className:"react-pdf__Page__annotations annotationLayer",ref:function(l){n.annotationLayer=l}},this.renderAnnotationLayer())}},{key:"viewport",get:function(){var n=this.props,a=n.page,l=n.rotate,u=n.scale;return a.getViewport({scale:u,rotation:l})}}]),r}(React$2.PureComponent);AnnotationLayerInternal.propTypes={imageResourcesPath:PropTypes$1.string,linkService:isLinkService.isRequired,onGetAnnotationsError:PropTypes$1.func,onGetAnnotationsSuccess:PropTypes$1.func,onRenderAnnotationLayerError:PropTypes$1.func,onRenderAnnotationLayerSuccess:PropTypes$1.func,page:isPage,renderInteractiveForms:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number};var AnnotationLayer=function o(e){return React$2.createElement(DocumentContext.Consumer,null,function(r){return React$2.createElement(PageContext.Consumer,null,function(t){return React$2.createElement(AnnotationLayerInternal,_extends({},r,t,e))})})};function ownKeys(o,e){var r=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);e&&(t=t.filter(function(n){return Object.getOwnPropertyDescriptor(o,n).enumerable})),r.push.apply(r,t)}return r}function _objectSpread(o){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(o,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(o,t,Object.getOwnPropertyDescriptor(r,t))})}return o}function _createSuper(o){var e=_isNativeReflectConstruct();return function(){var t=_getPrototypeOf(o),n;if(e){var a=_getPrototypeOf(this).constructor;n=Reflect.construct(t,arguments,a)}else n=t.apply(this,arguments);return _possibleConstructorReturn(this,n)}}function _isNativeReflectConstruct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}var defaultScale=1,PageInternal=function(o){_inherits(r,o);var e=_createSuper(r);function r(){var t;_classCallCheck(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=e.call.apply(e,[this].concat(a)),_defineProperty(_assertThisInitialized$1(t),"state",{page:null}),_defineProperty(_assertThisInitialized$1(t),"onLoadSuccess",function(){var u=t.props,f=u.onLoadSuccess,d=u.registerPage,h=t.state.page;f&&f(makePageCallback(h,t.scale)),d&&d(t.pageIndex,t.ref)}),_defineProperty(_assertThisInitialized$1(t),"onLoadError",function(u){errorOnDev(u);var f=t.props.onLoadError;f&&f(u)}),_defineProperty(_assertThisInitialized$1(t),"loadPage",_asyncToGenerator(_regeneratorRuntime.mark(function u(){var f,d,h,y;return _regeneratorRuntime.wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(f=t.props.pdf,d=t.getPageNumber(),d){p.next=4;break}return p.abrupt("return");case 4:return t.setState(function(_){return _.page?{page:null}:null}),p.prev=5,h=makeCancellablePromise(f.getPage(d)),t.runningTask=h,p.next=10,h.promise;case 10:y=p.sent,t.setState({page:y},t.onLoadSuccess),p.next=18;break;case 14:p.prev=14,p.t0=p.catch(5),t.setState({page:!1}),t.onLoadError(p.t0);case 18:case"end":return p.stop()}},u,null,[[5,14]])}))),t}return _createClass(r,[{key:"componentDidMount",value:function(){var n=this.props.pdf;if(!n)throw new Error("Attempted to load a page, but no document was specified.");this.loadPage()}},{key:"componentDidUpdate",value:function(n){var a=this.props.pdf;if(n.pdf&&a!==n.pdf||this.getPageNumber()!==this.getPageNumber(n)){var l=this.props.unregisterPage;l&&l(this.getPageIndex(n)),this.loadPage()}}},{key:"componentWillUnmount",value:function(){var n=this.props.unregisterPage;n&&n(this.pageIndex),cancelRunningTask(this.runningTask)}},{key:"getPageIndex",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return isProvided(n.pageNumber)?n.pageNumber-1:isProvided(n.pageIndex)?n.pageIndex:null}},{key:"getPageNumber",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return isProvided(n.pageNumber)?n.pageNumber:isProvided(n.pageIndex)?n.pageIndex+1:null}},{key:"renderMainLayer",value:function(){var n=this.props,a=n.canvasRef,l=n.renderMode;switch(l){case"none":return null;case"svg":return React$2.createElement(PageSVG,{key:"".concat(this.pageKeyNoScale,"_svg")});case"canvas":default:return React$2.createElement(PageCanvas,{key:"".concat(this.pageKey,"_canvas"),canvasRef:a})}}},{key:"renderTextLayer",value:function(){var n=this.props.renderTextLayer;return n?React$2.createElement(TextLayer,{key:"".concat(this.pageKey,"_text")}):null}},{key:"renderAnnotationLayer",value:function(){var n=this.props.renderAnnotationLayer;return n?React$2.createElement(AnnotationLayer,{key:"".concat(this.pageKey,"_annotations")}):null}},{key:"renderChildren",value:function(){var n=this.props.children;return React$2.createElement(PageContext.Provider,{value:this.childContext},this.renderMainLayer(),this.renderTextLayer(),this.renderAnnotationLayer(),n)}},{key:"renderContent",value:function(){var n=this.pageNumber,a=this.props.pdf,l=this.state.page;if(!n){var u=this.props.noData;return React$2.createElement(Message$1,{type:"no-data"},typeof u=="function"?u():u)}if(a===null||l===null){var f=this.props.loading;return React$2.createElement(Message$1,{type:"loading"},typeof f=="function"?f():f)}if(a===!1||l===!1){var d=this.props.error;return React$2.createElement(Message$1,{type:"error"},typeof d=="function"?d():d)}return this.renderChildren()}},{key:"render",value:function(){var n=this.pageNumber,a=this.props,l=a.className,u=a.inputRef;return React$2.createElement("div",_extends({className:mergeClassNames("react-pdf__Page",l),"data-page-number":n,ref:mergeRefs(u,this.ref),style:{position:"relative"}},this.eventProps),this.renderContent())}},{key:"childContext",get:function(){var n=this.state.page;if(!n)return{};var a=this.props,l=a.customTextRenderer,u=a.onGetAnnotationsError,f=a.onGetAnnotationsSuccess,d=a.onGetTextError,h=a.onGetTextSuccess,y=a.onRenderAnnotationLayerError,E=a.onRenderAnnotationLayerSuccess,p=a.onRenderError,_=a.onRenderSuccess,g=a.renderInteractiveForms;return{customTextRenderer:l,onGetAnnotationsError:u,onGetAnnotationsSuccess:f,onGetTextError:d,onGetTextSuccess:h,onRenderAnnotationLayerError:y,onRenderAnnotationLayerSuccess:E,onRenderError:p,onRenderSuccess:_,page:n,renderInteractiveForms:g,rotate:this.rotate,scale:this.scale}}},{key:"pageIndex",get:function(){return this.getPageIndex()}},{key:"pageNumber",get:function(){return this.getPageNumber()}},{key:"rotate",get:function(){var n=this.props.rotate;if(isProvided(n))return n;var a=this.state.page;return a?a.rotate:null}},{key:"scale",get:function(){var n=this.state.page;if(!n)return null;var a=this.props,l=a.scale,u=a.width,f=a.height,d=this.rotate,h=1,y=l===null?defaultScale:l;if(u||f){var E=n.getViewport({scale:1,rotation:d});h=u?u/E.width:f/E.height}return y*h}},{key:"eventProps",get:function(){var n=this;return makeEventProps(this.props,function(){var a=n.state.page;return a&&makePageCallback(a,n.scale)})}},{key:"pageKey",get:function(){var n=this.state.page;return"".concat(n.pageIndex,"@").concat(this.scale,"/").concat(this.rotate)}},{key:"pageKeyNoScale",get:function(){var n=this.state.page;return"".concat(n.pageIndex,"/").concat(this.rotate)}}]),r}(React$2.PureComponent);PageInternal.defaultProps={error:"Failed to load the page.",loading:"Loading page…",noData:"No page specified.",renderAnnotationLayer:!0,renderInteractiveForms:!1,renderMode:"canvas",renderTextLayer:!0,scale:defaultScale};var isFunctionOrNode=PropTypes$1.oneOfType([PropTypes$1.func,PropTypes$1.node]);PageInternal.propTypes=_objectSpread(_objectSpread({},eventProps),{},{children:PropTypes$1.node,className:isClassName,customTextRenderer:PropTypes$1.func,error:isFunctionOrNode,height:PropTypes$1.number,imageResourcesPath:PropTypes$1.string,inputRef:isRef,loading:isFunctionOrNode,noData:isFunctionOrNode,onGetTextError:PropTypes$1.func,onGetTextSuccess:PropTypes$1.func,onLoadError:PropTypes$1.func,onLoadSuccess:PropTypes$1.func,onRenderError:PropTypes$1.func,onRenderSuccess:PropTypes$1.func,pageIndex:isPageIndex,pageNumber:isPageNumber,pdf:isPdf,registerPage:PropTypes$1.func,renderAnnotationLayer:PropTypes$1.bool,renderInteractiveForms:PropTypes$1.bool,renderMode:isRenderMode,renderTextLayer:PropTypes$1.bool,rotate:isRotate,scale:PropTypes$1.number,unregisterPage:PropTypes$1.func,width:PropTypes$1.number});function Page(o,e){return React$2.createElement(DocumentContext.Consumer,null,function(r){return React$2.createElement(PageInternal,_extends({ref:e},r,o))})}const Page$1=React$2.forwardRef(Page);isLocalFileSystem&&warnOnDev("You are running React-PDF from your local file system. PDF.js Worker may fail to load due to browser's security policies. If you're on Google Chrome, you can use --allow-file-access-from-files flag for debugging purposes.");pdfExports.GlobalWorkerOptions.workerSrc="pdf.worker.js";const DeviceDetection=()=>navigator.userAgent.match(/(android)/i)||["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,BrowserDetection=()=>{const o=navigator.userAgent.toLowerCase(),e=o.indexOf("firefox")>-1,r=o.indexOf("safari")>-1&&o.indexOf("chrome")<=-1;let t="default";return e?t="firefox":r&&(t="safari"),t};pdfExports.GlobalWorkerOptions.workerSrc=`//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfExports.version}/pdf.worker.js`;const SCALE_LIMIT=2,maxValues={default:{area:268435456,sideBig:65535},firefox:{area:124992400,sideBig:32767},safari:{area:16777216,sideBig:4194303}},getMaxPermitted=()=>{const o=BrowserDetection();return maxValues[o]},formatScale=o=>o>1?Math.floor(o):Math.floor(o*100)/100,getMaxScaleByArea=(o,e,r)=>{const t=e*r*window.devicePixelRatio**2,n=Math.sqrt(o/t);return formatScale(n)},getMaxScaleBySide=(o,e,r)=>{const t=e>r?e:r,a=o/window.devicePixelRatio/t;return formatScale(a)};function PdfVisor({url:o,endPdf:e,emitNumberOfPages:r,translate:t,soundActions:n,keyboardControl:a}){const l=React$2.useRef(),[u,f]=React$2.useState(1),[d,h]=React$2.useState(!0),[y,E]=React$2.useState(),[p,_]=React$2.useState(1),[g]=n,x=React$2.useCallback(A=>{A.getPage(1).then(w=>{const P=w.getViewport(1),O=P.viewBox[2]-P.viewBox[0],k=P.viewBox[3]-P.viewBox[1],D=getMaxPermitted(),F=getMaxScaleByArea(D.area,O,k),G=getMaxScaleBySide(D.sideBig,O,k),V=F<G?F:G;_(V>SCALE_LIMIT?SCALE_LIMIT:V)}),f(A.numPages),A.numPages&&r({numPages:A.numPages,currentPage:y});const T=()=>(setTimeout(()=>{l.current&&l.current.scrollHeight<=l.current.offsetHeight&&h(!1)},1e3),()=>{T&&clearTimeout(T)});T()},[y,r]);React$2.useEffect(()=>{E(1)},[]);const C={file:o,loading:"Loading file...",onLoadSuccess:x,onLoadError:A=>console.error(A)},R=A=>{g("click-ui"),l.current.scrollTo(0,0),h(!1),E(y+A),r({numPages:u,currentPage:y+A}),y===u-1&&e()};a(u>1&&y!==1?()=>R(-1):null,u>1&&y!==u?()=>R(1):null);const S=()=>{h(!1)};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"pdf-box",dir:LangIsRtl()?"rtl":"auto",children:[jsxRuntimeExports.jsxs("div",{className:"pdf-box__scrollwrap",children:[jsxRuntimeExports.jsxs("div",{tabIndex:"0",onScroll:S,ref:l,className:`pdf-box__scroll ${d?"pdf-box__scroll--overlay":""}`,children:[jsxRuntimeExports.jsx(Document$1,{...C,children:jsxRuntimeExports.jsx(Page$1,{renderTextLayer:!1,scale:p,pageNumber:y})}),jsxRuntimeExports.jsx("div",{className:"pdf-box__mouse icon-scroll-down-black"})]}),u>1&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:"pdf-box__paginator",children:jsxRuntimeExports.jsxs("span",{children:[t("storylines.misc.page")," ",y," ",t("storylines.misc.of")," ",u]})})})]}),u>1&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{className:`pdf-box__arrow pdf-box__arrow--left gat--btn__round ${y===1?"pdf-box__arrow--hidden":""}`,type:"button",disabled:y===1,onClick:()=>R(-1),"aria-label":LangIsRtl()?t("storylines.misc.nextPage"):t("storylines.misc.previousPage"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{className:`pdf-box__arrow pdf-box__arrow--right gat--btn__round ${y===u?"pdf-box__arrow--hidden":""}`,type:"button",disabled:y===u,onClick:()=>R(1),"aria-label":LangIsRtl()?t("storylines.misc.previousPage"):t("storylines.misc.nextPage"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})})}function PdfComponent({emitEvent:o,soundActions:e,keyboardControl:r,documentType:t,name:n,required:a,viewed:l,visible:u,documentId:f,documentId_labelId:d,...h}){const y=k=>o({type:"translate",payload:k}),[E]=e,p=h.document,{url:_}=p||"",[g,x]=React$2.useState(!1),C=React$2.useMemo(()=>({documentType:t,name:n,documentId:d,type:"pdf"}),[t,n,d]),R=React$2.useCallback(()=>{o({type:"finishMedia",payload:C})},[C,o]),[S,A]=React$2.useState(!1),[T,w]=React$2.useState(!1);if(React$2.useEffect(()=>{u||R(),a||x(!0)},[u,R,a]),!u)return null;const P=()=>{x(!0)},O=k=>{k.numPages===k.currentPage?w(!0):w(!1),k.numPages===1&&A(!0)};return r(null,S||!l&&T||T&&!a?R:null,S||!l&&T||!a?R:null),jsxRuntimeExports.jsxs("div",{className:`${l?"notes--results":""}`,children:[(S||!l&&g)&&jsxRuntimeExports.jsx("div",{className:"position--absolute top right z-index1",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:()=>{R(),E("click-ui")},"aria-label":y("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}),_&&jsxRuntimeExports.jsx(PdfVisor,{soundActions:e,emitNumberOfPages:k=>O(k),url:_,endPdf:P,translate:y,keyboardControl:r})]})}function UrlComponent({emitEvent:o,name:e,name_labelId:r,link:t,link_labelId:n,text:a,text_labelId:l,textForLink:u,viewed:f,documentType:d,soundActions:h,keyboardControl:y,visible:E}){const p=A=>o({type:"translate",payload:A}),_={documentType:d,name:r,text:l,link:n,type:"url"},[g]=h,x=()=>{g("click-ui"),o({type:"finishMedia",payload:_})},[C,R]=React$2.useState(!1);y(null,!f&&C?x:null,!f&&C?x:null);const S=t.indexOf("http")!==0?`http://${t}`:t;return React$2.useEffect(()=>{E||x()}),E&&jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup popup--link",children:[!f&&C?jsxRuntimeExports.jsx("button",{className:"popup--close unset-button","data-testid":"close",type:"button","aria-label":p("storylines.misc.closePiece"),onClick:()=>x(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})}):null,jsxRuntimeExports.jsx("span",{className:"popup--link__title",children:e}),jsxRuntimeExports.jsx("span",{className:"popup--link__desc",children:a}),jsxRuntimeExports.jsx("a",{className:"popup--link__lineclamp popup--link__url",href:S,target:"_blank",rel:"noopener noreferrer",onClick:()=>{g("click-ui"),R(!0)},children:u||t})]})})}var hls={exports:{}};(function(o,e){typeof window<"u"&&function(t,n){o.exports=n()}(commonjsGlobal,function(){return function(r){var t={};function n(a){if(t[a])return t[a].exports;var l=t[a]={i:a,l:!1,exports:{}};return r[a].call(l.exports,l,l.exports,n),l.l=!0,l.exports}return n.m=r,n.c=t,n.d=function(a,l,u){n.o(a,l)||Object.defineProperty(a,l,{enumerable:!0,get:u})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,l){if(l&1&&(a=n(a)),l&8||l&4&&typeof a=="object"&&a&&a.__esModule)return a;var u=Object.create(null);if(n.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:a}),l&2&&typeof a!="string")for(var f in a)n.d(u,f,(function(d){return a[d]}).bind(null,f));return u},n.n=function(a){var l=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(l,"a",l),l},n.o=function(a,l){return Object.prototype.hasOwnProperty.call(a,l)},n.p="/dist/",n(n.s="./src/hls.js")}({"./node_modules/eventemitter3/index.js":function(r,t,n){var a=Object.prototype.hasOwnProperty,l="~";function u(){}Object.create&&(u.prototype=Object.create(null),new u().__proto__||(l=!1));function f(E,p,_){this.fn=E,this.context=p,this.once=_||!1}function d(E,p,_,g,x){if(typeof _!="function")throw new TypeError("The listener must be a function");var C=new f(_,g||E,x),R=l?l+p:p;return E._events[R]?E._events[R].fn?E._events[R]=[E._events[R],C]:E._events[R].push(C):(E._events[R]=C,E._eventsCount++),E}function h(E,p){--E._eventsCount===0?E._events=new u:delete E._events[p]}function y(){this._events=new u,this._eventsCount=0}y.prototype.eventNames=function(){var p=[],_,g;if(this._eventsCount===0)return p;for(g in _=this._events)a.call(_,g)&&p.push(l?g.slice(1):g);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(_)):p},y.prototype.listeners=function(p){var _=l?l+p:p,g=this._events[_];if(!g)return[];if(g.fn)return[g.fn];for(var x=0,C=g.length,R=new Array(C);x<C;x++)R[x]=g[x].fn;return R},y.prototype.listenerCount=function(p){var _=l?l+p:p,g=this._events[_];return g?g.fn?1:g.length:0},y.prototype.emit=function(p,_,g,x,C,R){var S=l?l+p:p;if(!this._events[S])return!1;var A=this._events[S],T=arguments.length,w,P;if(A.fn){switch(A.once&&this.removeListener(p,A.fn,void 0,!0),T){case 1:return A.fn.call(A.context),!0;case 2:return A.fn.call(A.context,_),!0;case 3:return A.fn.call(A.context,_,g),!0;case 4:return A.fn.call(A.context,_,g,x),!0;case 5:return A.fn.call(A.context,_,g,x,C),!0;case 6:return A.fn.call(A.context,_,g,x,C,R),!0}for(P=1,w=new Array(T-1);P<T;P++)w[P-1]=arguments[P];A.fn.apply(A.context,w)}else{var O=A.length,k;for(P=0;P<O;P++)switch(A[P].once&&this.removeListener(p,A[P].fn,void 0,!0),T){case 1:A[P].fn.call(A[P].context);break;case 2:A[P].fn.call(A[P].context,_);break;case 3:A[P].fn.call(A[P].context,_,g);break;case 4:A[P].fn.call(A[P].context,_,g,x);break;default:if(!w)for(k=1,w=new Array(T-1);k<T;k++)w[k-1]=arguments[k];A[P].fn.apply(A[P].context,w)}}return!0},y.prototype.on=function(p,_,g){return d(this,p,_,g,!1)},y.prototype.once=function(p,_,g){return d(this,p,_,g,!0)},y.prototype.removeListener=function(p,_,g,x){var C=l?l+p:p;if(!this._events[C])return this;if(!_)return h(this,C),this;var R=this._events[C];if(R.fn)R.fn===_&&(!x||R.once)&&(!g||R.context===g)&&h(this,C);else{for(var S=0,A=[],T=R.length;S<T;S++)(R[S].fn!==_||x&&!R[S].once||g&&R[S].context!==g)&&A.push(R[S]);A.length?this._events[C]=A.length===1?A[0]:A:h(this,C)}return this},y.prototype.removeAllListeners=function(p){var _;return p?(_=l?l+p:p,this._events[_]&&h(this,_)):(this._events=new u,this._eventsCount=0),this},y.prototype.off=y.prototype.removeListener,y.prototype.addListener=y.prototype.on,y.prefixed=l,y.EventEmitter=y,r.exports=y},"./node_modules/node-libs-browser/node_modules/events/events.js":function(r,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}r.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(d){if(!l(d)||d<0||isNaN(d))throw TypeError("n must be a positive number");return this._maxListeners=d,this},n.prototype.emit=function(d){var h,y,E,p,_,g;if(this._events||(this._events={}),d==="error"&&(!this._events.error||u(this._events.error)&&!this._events.error.length)){if(h=arguments[1],h instanceof Error)throw h;var x=new Error('Uncaught, unspecified "error" event. ('+h+")");throw x.context=h,x}if(y=this._events[d],f(y))return!1;if(a(y))switch(arguments.length){case 1:y.call(this);break;case 2:y.call(this,arguments[1]);break;case 3:y.call(this,arguments[1],arguments[2]);break;default:p=Array.prototype.slice.call(arguments,1),y.apply(this,p)}else if(u(y))for(p=Array.prototype.slice.call(arguments,1),g=y.slice(),E=g.length,_=0;_<E;_++)g[_].apply(this,p);return!0},n.prototype.addListener=function(d,h){var y;if(!a(h))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",d,a(h.listener)?h.listener:h),this._events[d]?u(this._events[d])?this._events[d].push(h):this._events[d]=[this._events[d],h]:this._events[d]=h,u(this._events[d])&&!this._events[d].warned&&(f(this._maxListeners)?y=n.defaultMaxListeners:y=this._maxListeners,y&&y>0&&this._events[d].length>y&&(this._events[d].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[d].length),typeof console.trace=="function"&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(d,h){if(!a(h))throw TypeError("listener must be a function");var y=!1;function E(){this.removeListener(d,E),y||(y=!0,h.apply(this,arguments))}return E.listener=h,this.on(d,E),this},n.prototype.removeListener=function(d,h){var y,E,p,_;if(!a(h))throw TypeError("listener must be a function");if(!this._events||!this._events[d])return this;if(y=this._events[d],p=y.length,E=-1,y===h||a(y.listener)&&y.listener===h)delete this._events[d],this._events.removeListener&&this.emit("removeListener",d,h);else if(u(y)){for(_=p;_-- >0;)if(y[_]===h||y[_].listener&&y[_].listener===h){E=_;break}if(E<0)return this;y.length===1?(y.length=0,delete this._events[d]):y.splice(E,1),this._events.removeListener&&this.emit("removeListener",d,h)}return this},n.prototype.removeAllListeners=function(d){var h,y;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[d]&&delete this._events[d],this;if(arguments.length===0){for(h in this._events)h!=="removeListener"&&this.removeAllListeners(h);return this.removeAllListeners("removeListener"),this._events={},this}if(y=this._events[d],a(y))this.removeListener(d,y);else if(y)for(;y.length;)this.removeListener(d,y[y.length-1]);return delete this._events[d],this},n.prototype.listeners=function(d){var h;return!this._events||!this._events[d]?h=[]:a(this._events[d])?h=[this._events[d]]:h=this._events[d].slice(),h},n.prototype.listenerCount=function(d){if(this._events){var h=this._events[d];if(a(h))return 1;if(h)return h.length}return 0},n.listenerCount=function(d,h){return d.listenerCount(h)};function a(d){return typeof d=="function"}function l(d){return typeof d=="number"}function u(d){return typeof d=="object"&&d!==null}function f(d){return d===void 0}},"./node_modules/url-toolkit/src/url-toolkit.js":function(r,t,n){(function(a){var l=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,u=/^([^\/?#]*)(.*)$/,f=/(?:\/|^)\.(?=\/)/g,d=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,h={buildAbsoluteURL:function(y,E,p){if(p=p||{},y=y.trim(),E=E.trim(),!E){if(!p.alwaysNormalize)return y;var _=h.parseURL(y);if(!_)throw new Error("Error trying to parse base URL.");return _.path=h.normalizePath(_.path),h.buildURLFromParts(_)}var g=h.parseURL(E);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return p.alwaysNormalize?(g.path=h.normalizePath(g.path),h.buildURLFromParts(g)):E;var x=h.parseURL(y);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var C=u.exec(x.path);x.netLoc=C[1],x.path=C[2]}x.netLoc&&!x.path&&(x.path="/");var R={scheme:x.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(R.netLoc=x.netLoc,g.path[0]!=="/"))if(!g.path)R.path=x.path,g.params||(R.params=x.params,g.query||(R.query=x.query));else{var S=x.path,A=S.substring(0,S.lastIndexOf("/")+1)+g.path;R.path=h.normalizePath(A)}return R.path===null&&(R.path=p.alwaysNormalize?h.normalizePath(g.path):g.path),h.buildURLFromParts(R)},parseURL:function(y){var E=l.exec(y);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(y){for(y=y.split("").reverse().join("").replace(f,"");y.length!==(y=y.replace(d,"")).length;);return y.split("").reverse().join("")},buildURLFromParts:function(y){return y.scheme+y.netLoc+y.path+y.params+y.query+y.fragment}};r.exports=h})()},"./node_modules/webworkify-webpack/index.js":function(r,t,n){function a(p){var _={};function g(C){if(_[C])return _[C].exports;var R=_[C]={i:C,l:!1,exports:{}};return p[C].call(R.exports,R,R.exports,g),R.l=!0,R.exports}g.m=p,g.c=_,g.i=function(C){return C},g.d=function(C,R,S){g.o(C,R)||Object.defineProperty(C,R,{configurable:!1,enumerable:!0,get:S})},g.r=function(C){Object.defineProperty(C,"__esModule",{value:!0})},g.n=function(C){var R=C&&C.__esModule?function(){return C.default}:function(){return C};return g.d(R,"a",R),R},g.o=function(C,R){return Object.prototype.hasOwnProperty.call(C,R)},g.p="/",g.oe=function(C){throw console.error(C),C};var x=g(g.s=ENTRY_MODULE);return x.default||x}var l="[\\.|\\-|\\+|\\w|/|@]+",u="\\((/\\*.*?\\*/)?s?.*?("+l+").*?\\)";function f(p){return(p+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function d(p){return!isNaN(1*p)}function h(p,_,g){var x={};x[g]=[];var C=_.toString(),R=C.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!R)return x;for(var S=R[1],A=new RegExp("(\\\\n|\\W)"+f(S)+u,"g"),T;T=A.exec(C);)T[3]!=="dll-reference"&&x[g].push(T[3]);for(A=new RegExp("\\("+f(S)+'\\("(dll-reference\\s('+l+'))"\\)\\)'+u,"g");T=A.exec(C);)p[T[2]]||(x[g].push(T[1]),p[T[2]]=n(T[1]).m),x[T[2]]=x[T[2]]||[],x[T[2]].push(T[4]);for(var w=Object.keys(x),P=0;P<w.length;P++)for(var O=0;O<x[w[P]].length;O++)d(x[w[P]][O])&&(x[w[P]][O]=1*x[w[P]][O]);return x}function y(p){var _=Object.keys(p);return _.reduce(function(g,x){return g||p[x].length>0},!1)}function E(p,_){for(var g={main:[_]},x={main:[]},C={main:{}};y(g);)for(var R=Object.keys(g),S=0;S<R.length;S++){var A=R[S],T=g[A],w=T.pop();if(C[A]=C[A]||{},!(C[A][w]||!p[A][w])){C[A][w]=!0,x[A]=x[A]||[],x[A].push(w);for(var P=h(p,p[A][w],A),O=Object.keys(P),k=0;k<O.length;k++)g[O[k]]=g[O[k]]||[],g[O[k]]=g[O[k]].concat(P[O[k]])}}return x}r.exports=function(p,_){_=_||{};var g={main:n.m},x=_.all?{main:Object.keys(g.main)}:E(g,p),C="";Object.keys(x).filter(function(w){return w!=="main"}).forEach(function(w){for(var P=0;x[w][P];)P++;x[w].push(P),g[w][P]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",C=C+"var "+w+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(P))+")({"+x[w].map(function(O){return""+JSON.stringify(O)+": "+g[w][O].toString()}).join(",")+`});
|
|
53
53
|
`}),C=C+"new (("+a.toString().replace("ENTRY_MODULE",JSON.stringify(p))+")({"+x.main.map(function(w){return""+JSON.stringify(w)+": "+g.main[w].toString()}).join(",")+"}))(self);";var R=new window.Blob([C],{type:"text/javascript"});if(_.bare)return R;var S=window.URL||window.webkitURL||window.mozURL||window.msURL,A=S.createObjectURL(R),T=new window.Worker(A);return T.objectURL=A,T}},"./src/config.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/controller/abr-controller.js"),l=n("./src/controller/buffer-controller.js"),u=n("./src/controller/cap-level-controller.js"),f=n("./src/controller/fps-controller.js"),d=n("./src/utils/xhr-loader.js"),h=n("./src/controller/audio-track-controller.js"),y=n("./src/controller/audio-stream-controller.js"),E=n("./src/utils/cues.js"),p=n("./src/controller/timeline-controller.js"),_=n("./src/controller/subtitle-track-controller.js"),g=n("./src/controller/subtitle-stream-controller.js"),x=n("./src/controller/eme-controller.js"),C=n("./src/utils/mediakeys-helper.js");t.hlsDefaultConfig={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:60*1e3*1e3,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:1/0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:d.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:a.default,bufferController:l.default,capLevelController:u.default,fpsController:f.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,requestMediaKeySystemAccessFunc:C.requestMediaKeySystemAccess},t.hlsDefaultConfig.subtitleStreamController=g.SubtitleStreamController,t.hlsDefaultConfig.subtitleTrackController=_.default,t.hlsDefaultConfig.timelineController=p.default,t.hlsDefaultConfig.cueHandler=E,t.hlsDefaultConfig.enableCEA708Captions=!0,t.hlsDefaultConfig.enableWebVTT=!0,t.hlsDefaultConfig.captionsTextTrack1Label="English",t.hlsDefaultConfig.captionsTextTrack1LanguageCode="en",t.hlsDefaultConfig.captionsTextTrack2Label="Spanish",t.hlsDefaultConfig.captionsTextTrack2LanguageCode="es",t.hlsDefaultConfig.audioStreamController=y.default,t.hlsDefaultConfig.audioTrackController=h.default,t.hlsDefaultConfig.emeController=x.default},"./src/controller/abr-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,C){x.__proto__=C}||function(x,C){for(var R in C)C.hasOwnProperty(R)&&(x[R]=C[R])};return function(x,C){g(x,C);function R(){this.constructor=x}x.prototype=C===null?Object.create(C):(R.prototype=C.prototype,new R)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/utils/buffer-helper.js"),h=n("./src/errors.js"),y=n("./src/utils/logger.js"),E=n("./src/utils/ewma-bandwidth-estimator.js"),p=window.performance,_=function(g){l(x,g);function x(C){var R=g.call(this,C,u.default.FRAG_LOADING,u.default.FRAG_LOADED,u.default.FRAG_BUFFERED,u.default.ERROR)||this;return R.lastLoadedFragLevel=0,R._nextAutoLevel=-1,R.hls=C,R.timer=null,R._bwEstimator=null,R.onCheck=R._abandonRulesCheck.bind(R),R}return x.prototype.destroy=function(){this.clearTimer(),f.default.prototype.destroy.call(this)},x.prototype.onFragLoading=function(C){var R=C.frag;if(R.type==="main"&&(this.timer||(this.fragCurrent=R,this.timer=setInterval(this.onCheck,100)),!this._bwEstimator)){var S=this.hls,A=S.config,T=R.level,w=S.levels[T].details.live,P=void 0,O=void 0;w?(P=A.abrEwmaFastLive,O=A.abrEwmaSlowLive):(P=A.abrEwmaFastVoD,O=A.abrEwmaSlowVoD),this._bwEstimator=new E.default(S,O,P,A.abrEwmaDefaultEstimate)}},x.prototype._abandonRulesCheck=function(){var C=this.hls,R=C.media,S=this.fragCurrent;if(S){var A=S.loader,T=C.minAutoLevel;if(!A||A.stats&&A.stats.aborted){y.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}var w=A.stats;if(R&&w&&(!R.paused&&R.playbackRate!==0||!R.readyState)&&S.autoLevel&&S.level){var P=p.now()-w.trequest,O=Math.abs(R.playbackRate);if(P>500*S.duration/O){var k=C.levels,D=Math.max(1,w.bw?w.bw/8:w.loaded*1e3/P),F=k[S.level],G=F.realBitrate?Math.max(F.realBitrate,F.bitrate):F.bitrate,V=w.total?w.total:Math.max(w.loaded,Math.round(S.duration*G/8)),W=R.currentTime,ee=(V-w.loaded)/D,q=(d.BufferHelper.bufferInfo(R,W,C.config.maxBufferHole).end-W)/O;if(q<2*S.duration/O&&ee>q){var z=void 0,U=void 0;for(U=S.level-1;U>T;U--){var $=k[U].realBitrate?Math.max(k[U].realBitrate,k[U].bitrate):k[U].bitrate;if(z=S.duration*$/(8*.8*D),z<q)break}z<ee&&(y.logger.warn("loading too slow, abort fragment loading and switch to level "+U+":fragLoadedDelay["+U+"]<fragLoadedDelay["+(S.level-1)+"];bufferStarvationDelay:"+z.toFixed(1)+"<"+ee.toFixed(1)+":"+q.toFixed(1)),C.nextLoadLevel=U,this._bwEstimator.sample(P,w.loaded),A.abort(),this.clearTimer(),C.trigger(u.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:S,stats:w}))}}}}},x.prototype.onFragLoaded=function(C){var R=C.frag;if(R.type==="main"&&a.isFinite(R.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=R.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var S=this.hls.levels[R.level],A=(S.loaded?S.loaded.bytes:0)+C.stats.loaded,T=(S.loaded?S.loaded.duration:0)+C.frag.duration;S.loaded={bytes:A,duration:T},S.realBitrate=Math.round(8*A/T)}if(C.frag.bitrateTest){var w=C.stats;w.tparsed=w.tbuffered=w.tload,this.onFragBuffered(C)}}},x.prototype.onFragBuffered=function(C){var R=C.stats,S=C.frag;if(R.aborted!==!0&&S.type==="main"&&a.isFinite(S.sn)&&(!S.bitrateTest||R.tload===R.tbuffered)){var A=R.tparsed-R.trequest;y.logger.log("latency/loading/parsing/append/kbps:"+Math.round(R.tfirst-R.trequest)+"/"+Math.round(R.tload-R.tfirst)+"/"+Math.round(R.tparsed-R.tload)+"/"+Math.round(R.tbuffered-R.tparsed)+"/"+Math.round(8*R.loaded/(R.tbuffered-R.trequest))),this._bwEstimator.sample(A,R.loaded),R.bwEstimate=this._bwEstimator.getEstimate(),S.bitrateTest?this.bitrateTestDelay=A/1e3:this.bitrateTestDelay=0}},x.prototype.onError=function(C){switch(C.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break}},x.prototype.clearTimer=function(){clearInterval(this.timer),this.timer=null},Object.defineProperty(x.prototype,"nextAutoLevel",{get:function(){var C=this._nextAutoLevel,R=this._bwEstimator;if(C!==-1&&(!R||!R.canEstimate()))return C;var S=this._nextABRAutoLevel;return C!==-1&&(S=Math.min(C,S)),S},set:function(C){this._nextAutoLevel=C},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"_nextABRAutoLevel",{get:function(){var C=this.hls,R=C.maxAutoLevel,S=C.levels,A=C.config,T=C.minAutoLevel,w=C.media,P=this.lastLoadedFragLevel,O=this.fragCurrent?this.fragCurrent.duration:0,k=w?w.currentTime:0,D=w&&w.playbackRate!==0?Math.abs(w.playbackRate):1,F=this._bwEstimator?this._bwEstimator.getEstimate():A.abrEwmaDefaultEstimate,G=(d.BufferHelper.bufferInfo(w,k,A.maxBufferHole).end-k)/D,V=this._findBestLevel(P,O,F,T,R,G,A.abrBandWidthFactor,A.abrBandWidthUpFactor,S);if(V>=0)return V;y.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var W=O?Math.min(O,A.maxStarvationDelay):A.maxStarvationDelay,ee=A.abrBandWidthFactor,q=A.abrBandWidthUpFactor;if(G===0){var z=this.bitrateTestDelay;if(z){var U=O?Math.min(O,A.maxLoadingDelay):A.maxLoadingDelay;W=U-z,y.logger.trace("bitrate test took "+Math.round(1e3*z)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*W)+" ms"),ee=q=1}}return V=this._findBestLevel(P,O,F,T,R,G+W,ee,q,S),Math.max(V,0)},enumerable:!0,configurable:!0}),x.prototype._findBestLevel=function(C,R,S,A,T,w,P,O,k){for(var D=T;D>=A;D--){var F=k[D];if(F){var G=F.details,V=G?G.totalduration/G.fragments.length:R,W=G?G.live:!1,ee=void 0;D<=C?ee=P*S:ee=O*S;var q=k[D].realBitrate?Math.max(k[D].realBitrate,k[D].bitrate):k[D].bitrate,z=q*V/ee;if(y.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+D+"/"+Math.round(ee)+"/"+q+"/"+V+"/"+w+"/"+z),ee>q&&(!z||W&&!this.bitrateTestDelay||z<w))return D}}return-1},x}(f.default);t.default=_}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/audio-stream-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(P,O){P.__proto__=O}||function(P,O){for(var k in O)O.hasOwnProperty(k)&&(P[k]=O[k])};return function(P,O){w(P,O);function k(){this.constructor=P}P.prototype=O===null?Object.create(O):(k.prototype=O.prototype,new k)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/utils/binary-search.js"),f=n("./src/utils/buffer-helper.js"),d=n("./src/demux/demuxer.js"),h=n("./src/events.js"),y=n("./src/controller/level-helper.js"),E=n("./src/utils/time-ranges.js"),p=n("./src/errors.js"),_=n("./src/utils/logger.js"),g=n("./src/utils/discontinuities.js"),x=n("./src/controller/fragment-tracker.js"),C=n("./src/loader/fragment.js"),R=n("./src/controller/base-stream-controller.js"),S=window.performance,A=100,T=function(w){l(P,w);function P(O,k){var D=w.call(this,O,h.default.MEDIA_ATTACHED,h.default.MEDIA_DETACHING,h.default.AUDIO_TRACKS_UPDATED,h.default.AUDIO_TRACK_SWITCHING,h.default.AUDIO_TRACK_LOADED,h.default.KEY_LOADED,h.default.FRAG_LOADED,h.default.FRAG_PARSING_INIT_SEGMENT,h.default.FRAG_PARSING_DATA,h.default.FRAG_PARSED,h.default.ERROR,h.default.BUFFER_RESET,h.default.BUFFER_CREATED,h.default.BUFFER_APPENDED,h.default.BUFFER_FLUSHED,h.default.INIT_PTS_FOUND)||this;return D.fragmentTracker=k,D.config=O.config,D.audioCodecSwap=!1,D._state=R.State.STOPPED,D.initPTS=[],D.waitingFragment=null,D.videoTrackCC=null,D}return P.prototype.onInitPtsFound=function(O){var k=O.id,D=O.frag.cc,F=O.initPTS;k==="main"&&(this.initPTS[D]=F,this.videoTrackCC=D,_.logger.log("InitPTS for cc: "+D+" found from video track: "+F),this.state===R.State.WAITING_INIT_PTS&&this.tick())},P.prototype.startLoad=function(O){if(this.tracks){var k=this.lastCurrentTime;this.stopLoad(),this.setInterval(A),this.fragLoadError=0,k>0&&O===-1?(_.logger.log("audio:override startPosition with lastCurrentTime @"+k.toFixed(3)),this.state=R.State.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:O,this.state=R.State.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=O,this.state=R.State.STOPPED},Object.defineProperty(P.prototype,"state",{get:function(){return this._state},set:function(O){if(this.state!==O){var k=this.state;this._state=O,_.logger.log("audio stream:"+k+"->"+O)}},enumerable:!0,configurable:!0}),P.prototype.doTick=function(){var O,k,D,F=this.hls,G=F.config;switch(this.state){case R.State.ERROR:case R.State.PAUSED:case R.State.BUFFER_FLUSHING:break;case R.State.STARTING:this.state=R.State.WAITING_TRACK,this.loadedmetadata=!1;break;case R.State.IDLE:var V=this.tracks;if(!V||!this.media&&(this.startFragRequested||!G.startFragPrefetch))break;if(this.loadedmetadata)O=this.media.currentTime;else if(O=this.nextLoadPosition,O===void 0)break;var W=this.mediaBuffer?this.mediaBuffer:this.media,ee=this.videoBuffer?this.videoBuffer:this.media,q=f.BufferHelper.bufferInfo(W,O,G.maxBufferHole),z=f.BufferHelper.bufferInfo(ee,O,G.maxBufferHole),U=q.len,$=q.end,I=this.fragPrevious,B=Math.min(G.maxBufferLength,G.maxMaxBufferLength),X=Math.max(B,z.len),Q=this.audioSwitch,J=this.trackId;if((U<X||Q)&&J<V.length){if(D=V[J].details,typeof D>"u"){this.state=R.State.WAITING_TRACK;break}if(!Q&&this._streamEnded(q,D)){this.hls.trigger(h.default.BUFFER_EOS,{type:"audio"}),this.state=R.State.ENDED;return}var ne=D.fragments,ae=ne.length,Z=ne[0].start,se=ne[ae-1].start+ne[ae-1].duration,oe=void 0;if(Q){if(D.live&&!D.PTSKnown)_.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),$=0;else if($=O,D.PTSKnown&&O<Z)if(q.end>Z||q.nextStart)_.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=Z+.05;else return}if(D.initSegment&&!D.initSegment.data)oe=D.initSegment;else if($<=Z){if(oe=ne[0],this.videoTrackCC!==null&&oe.cc!==this.videoTrackCC&&(oe=g.findFragWithCC(ne,this.videoTrackCC)),D.live&&oe.loadIdx&&oe.loadIdx===this.fragLoadIdx){var fe=q.nextStart?q.nextStart:Z;_.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(fe+.05)),this.media.currentTime=fe+.05;return}}else{var de=void 0,ce=G.maxFragLookUpTolerance,Ee=I?ne[I.sn-ne[0].sn+1]:void 0,De=function(ut){var ft=Math.min(ce,ut.duration);return ut.start+ut.duration-ft<=$?1:ut.start-ft>$&&ut.start?-1:0};$<se?($>se-ce&&(ce=0),Ee&&!De(Ee)?de=Ee:de=u.default.search(ne,De)):de=ne[ae-1],de&&(oe=de,Z=de.start,I&&oe.level===I.level&&oe.sn===I.sn&&(oe.sn<D.endSN?(oe=ne[oe.sn+1-D.startSN],_.logger.log("SN just loaded, load next one: "+oe.sn)):oe=null))}oe&&(oe.encrypted?(_.logger.log("Loading key for "+oe.sn+" of ["+D.startSN+" ,"+D.endSN+"],track "+J),this.state=R.State.KEY_LOADING,F.trigger(h.default.KEY_LOADING,{frag:oe})):(_.logger.log("Loading "+oe.sn+", cc: "+oe.cc+" of ["+D.startSN+" ,"+D.endSN+"],track "+J+", currentTime:"+O+",bufferEnd:"+$.toFixed(3)),this.fragCurrent=oe,(Q||this.fragmentTracker.getState(oe)===x.FragmentState.NOT_LOADED)&&(this.startFragRequested=!0,a.isFinite(oe.sn)&&(this.nextLoadPosition=oe.start+oe.duration),F.trigger(h.default.FRAG_LOADING,{frag:oe}),this.state=R.State.FRAG_LOADING)))}break;case R.State.WAITING_TRACK:k=this.tracks[this.trackId],k&&k.details&&(this.state=R.State.IDLE);break;case R.State.FRAG_LOADING_WAITING_RETRY:var we=S.now(),He=this.retryDate;W=this.media;var Xe=W&&W.seeking;(!He||we>=He||Xe)&&(_.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=R.State.IDLE);break;case R.State.WAITING_INIT_PTS:var Qe=this.videoTrackCC;if(this.initPTS[Qe]===void 0)break;var dt=this.waitingFragment;if(dt){var _t=dt.frag.cc;Qe!==_t?(k=this.tracks[this.trackId],k.details&&k.details.live&&(_.logger.warn("Waiting fragment CC ("+_t+") does not match video track CC ("+Qe+")"),this.waitingFragment=null,this.state=R.State.IDLE)):(this.state=R.State.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=R.State.IDLE;break;case R.State.STOPPED:case R.State.FRAG_LOADING:case R.State.PARSING:case R.State.PARSED:case R.State.ENDED:break}},P.prototype.onMediaAttached=function(O){var k=this.media=this.mediaBuffer=O.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),k.addEventListener("seeking",this.onvseeking),k.addEventListener("ended",this.onvended);var D=this.config;this.tracks&&D.autoStartLoad&&this.startLoad(D.startPosition)},P.prototype.onMediaDetaching=function(){var O=this.media;O&&O.ended&&(_.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),O&&(O.removeEventListener("seeking",this.onvseeking),O.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.stopLoad()},P.prototype.onAudioTracksUpdated=function(O){_.logger.log("audio tracks updated"),this.tracks=O.audioTracks},P.prototype.onAudioTrackSwitching=function(O){var k=!!O.url;this.trackId=O.id,this.fragCurrent=null,this.state=R.State.PAUSED,this.waitingFragment=null,k?this.setInterval(A):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),k&&(this.audioSwitch=!0,this.state=R.State.IDLE),this.tick()},P.prototype.onAudioTrackLoaded=function(O){var k=O.details,D=O.id,F=this.tracks[D],G=k.totalduration,V=0;if(_.logger.log("track "+D+" loaded ["+k.startSN+","+k.endSN+"],duration:"+G),k.live){var W=F.details;W&&k.fragments.length>0?(y.mergeDetails(W,k),V=k.fragments[0].start,k.PTSKnown?_.logger.log("live audio playlist sliding:"+V.toFixed(3)):_.logger.log("live audio playlist - outdated PTS, unknown sliding")):(k.PTSKnown=!1,_.logger.log("live audio playlist - first load, unknown sliding"))}else k.PTSKnown=!1;if(F.details=k,!this.startFragRequested){if(this.startPosition===-1){var ee=k.startTimeOffset;a.isFinite(ee)?(_.logger.log("start time offset found in playlist, adjust startPosition to "+ee),this.startPosition=ee):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===R.State.WAITING_TRACK&&(this.state=R.State.IDLE),this.tick()},P.prototype.onKeyLoaded=function(){this.state===R.State.KEY_LOADING&&(this.state=R.State.IDLE,this.tick())},P.prototype.onFragLoaded=function(O){var k=this.fragCurrent,D=O.frag;if(this.state===R.State.FRAG_LOADING&&k&&D.type==="audio"&&D.level===k.level&&D.sn===k.sn){var F=this.tracks[this.trackId],G=F.details,V=G.totalduration,W=k.level,ee=k.sn,q=k.cc,z=this.config.defaultAudioCodec||F.audioCodec||"mp4a.40.2",U=this.stats=O.stats;if(ee==="initSegment")this.state=R.State.IDLE,U.tparsed=U.tbuffered=S.now(),G.initSegment.data=O.payload,this.hls.trigger(h.default.FRAG_BUFFERED,{stats:U,frag:k,id:"audio"}),this.tick();else{this.state=R.State.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new d.default(this.hls,"audio"));var $=this.initPTS[q],I=G.initSegment?G.initSegment.data:[];if(G.initSegment||$!==void 0){this.pendingBuffering=!0,_.logger.log("Demuxing "+ee+" of ["+G.startSN+" ,"+G.endSN+"],track "+W);var B=!1;this.demuxer.push(O.payload,I,z,null,k,V,B,$)}else _.logger.log("unknown video PTS for continuity counter "+q+", waiting for video PTS before demuxing audio frag "+ee+" of ["+G.startSN+" ,"+G.endSN+"],track "+W),this.waitingFragment=O,this.state=R.State.WAITING_INIT_PTS}}this.fragLoadError=0},P.prototype.onFragParsingInitSegment=function(O){var k=this.fragCurrent,D=O.frag;if(k&&O.id==="audio"&&D.sn===k.sn&&D.level===k.level&&this.state===R.State.PARSING){var F=O.tracks,G=void 0;if(F.video&&delete F.video,G=F.audio,G){G.levelCodec=G.codec,G.id=O.id,this.hls.trigger(h.default.BUFFER_CODECS,F),_.logger.log("audio track:audio,container:"+G.container+",codecs[level/parsed]=["+G.levelCodec+"/"+G.codec+"]");var V=G.initSegment;if(V){var W={type:"audio",data:V,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[W]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(h.default.BUFFER_APPENDING,W))}this.tick()}}},P.prototype.onFragParsingData=function(O){var k=this,D=this.fragCurrent,F=O.frag;if(D&&O.id==="audio"&&O.type==="audio"&&F.sn===D.sn&&F.level===D.level&&this.state===R.State.PARSING){var G=this.trackId,V=this.tracks[G],W=this.hls;a.isFinite(O.endPTS)||(O.endPTS=O.startPTS+D.duration,O.endDTS=O.startDTS+D.duration),D.addElementaryStream(C.default.ElementaryStreamTypes.AUDIO),_.logger.log("parsed "+O.type+",PTS:["+O.startPTS.toFixed(3)+","+O.endPTS.toFixed(3)+"],DTS:["+O.startDTS.toFixed(3)+"/"+O.endDTS.toFixed(3)+"],nb:"+O.nb),y.updateFragPTSDTS(V.details,D,O.startPTS,O.endPTS);var ee=this.audioSwitch,q=this.media,z=!1;if(ee&&q)if(q.readyState){var U=q.currentTime;_.logger.log("switching audio track : currentTime:"+U),U>=O.startPTS&&(_.logger.log("switching audio track : flushing all audio"),this.state=R.State.BUFFER_FLUSHING,W.trigger(h.default.BUFFER_FLUSHING,{startOffset:0,endOffset:a.POSITIVE_INFINITY,type:"audio"}),z=!0,this.audioSwitch=!1,W.trigger(h.default.AUDIO_TRACK_SWITCHED,{id:G}))}else this.audioSwitch=!1,W.trigger(h.default.AUDIO_TRACK_SWITCHED,{id:G});var $=this.pendingData;if(!$){_.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),W.trigger(h.default.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});return}this.audioSwitch||([O.data1,O.data2].forEach(function(I){I&&I.length&&$.push({type:O.type,data:I,parent:"audio",content:"data"})}),!z&&$.length&&($.forEach(function(I){k.state===R.State.PARSING&&(k.pendingBuffering=!0,k.hls.trigger(h.default.BUFFER_APPENDING,I))}),this.pendingData=[],this.appended=!0)),this.tick()}},P.prototype.onFragParsed=function(O){var k=this.fragCurrent,D=O.frag;k&&O.id==="audio"&&D.sn===k.sn&&D.level===k.level&&this.state===R.State.PARSING&&(this.stats.tparsed=S.now(),this.state=R.State.PARSED,this._checkAppendedParsed())},P.prototype.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},P.prototype.onBufferCreated=function(O){var k=O.tracks.audio;k&&(this.mediaBuffer=k.buffer,this.loadedmetadata=!0),O.tracks.video&&(this.videoBuffer=O.tracks.video.buffer)},P.prototype.onBufferAppended=function(O){if(O.parent==="audio"){var k=this.state;(k===R.State.PARSING||k===R.State.PARSED)&&(this.pendingBuffering=O.pending>0,this._checkAppendedParsed())}},P.prototype._checkAppendedParsed=function(){if(this.state===R.State.PARSED&&(!this.appended||!this.pendingBuffering)){var O=this.fragCurrent,k=this.stats,D=this.hls;if(O){this.fragPrevious=O,k.tbuffered=S.now(),D.trigger(h.default.FRAG_BUFFERED,{stats:k,frag:O,id:"audio"});var F=this.mediaBuffer?this.mediaBuffer:this.media;_.logger.log("audio buffered : "+E.default.toString(F.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,D.trigger(h.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=R.State.IDLE}this.tick()}},P.prototype.onError=function(O){var k=O.frag;if(!(k&&k.type!=="audio"))switch(O.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:var D=O.frag;if(D&&D.type!=="audio")break;if(!O.fatal){var F=this.fragLoadError;F?F++:F=1;var G=this.config;if(F<=G.fragLoadingMaxRetry){this.fragLoadError=F;var V=Math.min(Math.pow(2,F-1)*G.fragLoadingRetryDelay,G.fragLoadingMaxRetryTimeout);_.logger.warn("AudioStreamController: frag loading failed, retry in "+V+" ms"),this.retryDate=S.now()+V,this.state=R.State.FRAG_LOADING_WAITING_RETRY}else _.logger.error("AudioStreamController: "+O.details+" reaches max retry, redispatch as fatal ..."),O.fatal=!0,this.state=R.State.ERROR}break;case p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==R.State.ERROR&&(this.state=O.fatal?R.State.ERROR:R.State.IDLE,_.logger.warn("AudioStreamController: "+O.details+" while loading frag, now switching to "+this.state+" state ..."));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if(O.parent==="audio"&&(this.state===R.State.PARSING||this.state===R.State.PARSED)){var W=this.mediaBuffer,ee=this.media.currentTime,q=W&&f.BufferHelper.isBuffered(W,ee)&&f.BufferHelper.isBuffered(W,ee+.5);if(q){var G=this.config;G.maxMaxBufferLength>=G.maxBufferLength&&(G.maxMaxBufferLength/=2,_.logger.warn("AudioStreamController: reduce max buffer length to "+G.maxMaxBufferLength+"s")),this.state=R.State.IDLE}else _.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=R.State.BUFFER_FLUSHING,this.hls.trigger(h.default.BUFFER_FLUSHING,{startOffset:0,endOffset:a.POSITIVE_INFINITY,type:"audio"})}break}},P.prototype.onBufferFlushed=function(){var O=this,k=this.pendingData;k&&k.length?(_.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),k.forEach(function(D){O.hls.trigger(h.default.BUFFER_APPENDING,D)}),this.appended=!0,this.pendingData=[],this.state=R.State.PARSED):(this.state=R.State.IDLE,this.fragPrevious=null,this.tick())},P}(R.default);t.default=T}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/audio-track-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,p){E.__proto__=p}||function(E,p){for(var _ in p)p.hasOwnProperty(_)&&(E[_]=p[_])};return function(E,p){y(E,p);function _(){this.constructor=E}E.prototype=p===null?Object.create(p):(_.prototype=p.prototype,new _)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/task-loop.js"),f=n("./src/utils/logger.js"),d=n("./src/errors.js"),h=function(y){a(E,y);function E(p){var _=y.call(this,p,l.default.MANIFEST_LOADING,l.default.MANIFEST_PARSED,l.default.AUDIO_TRACK_LOADED,l.default.AUDIO_TRACK_SWITCHED,l.default.LEVEL_LOADED,l.default.ERROR)||this;return _._trackId=-1,_._selectDefaultTrack=!0,_.tracks=[],_.trackIdBlacklist=Object.create(null),_.audioGroupId=null,_}return E.prototype.onManifestLoading=function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0},E.prototype.onManifestParsed=function(p){var _=this.tracks=p.audioTracks||[];this.hls.trigger(l.default.AUDIO_TRACKS_UPDATED,{audioTracks:_})},E.prototype.onAudioTrackLoaded=function(p){if(p.id>=this.tracks.length){f.logger.warn("Invalid audio track id:",p.id);return}if(f.logger.log("audioTrack "+p.id+" loaded"),this.tracks[p.id].details=p.details,p.details.live&&!this.hasInterval()){var _=p.details.targetduration*1e3;this.setInterval(_)}!p.details.live&&this.hasInterval()&&this.clearInterval()},E.prototype.onAudioTrackSwitched=function(p){var _=this.tracks[p.id].groupId;_&&this.audioGroupId!==_&&(this.audioGroupId=_)},E.prototype.onLevelLoaded=function(p){var _=this.hls.levels[p.level];if(_.audioGroupIds){var g=_.audioGroupIds[_.urlId];this.audioGroupId!==g&&(this.audioGroupId=g,this._selectInitialAudioTrack())}},E.prototype.onError=function(p){p.type===d.ErrorTypes.NETWORK_ERROR&&(p.fatal&&this.clearInterval(),p.details===d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(f.logger.warn("Network failure on audio-track id:",p.context.id),this._handleLoadError()))},Object.defineProperty(E.prototype,"audioTracks",{get:function(){return this.tracks},enumerable:!0,configurable:!0}),Object.defineProperty(E.prototype,"audioTrack",{get:function(){return this._trackId},set:function(p){this._setAudioTrack(p),this._selectDefaultTrack=!1},enumerable:!0,configurable:!0}),E.prototype._setAudioTrack=function(p){if(this._trackId===p&&this.tracks[this._trackId].details){f.logger.debug("Same id as current audio-track passed, and track details available -> no-op");return}if(p<0||p>=this.tracks.length){f.logger.warn("Invalid id passed to audio-track controller");return}var _=this.tracks[p];f.logger.log("Now switching to audio-track index "+p),this.clearInterval(),this._trackId=p;var g=_.url,x=_.type,C=_.id;this.hls.trigger(l.default.AUDIO_TRACK_SWITCHING,{id:C,type:x,url:g}),this._loadTrackDetailsIfNeeded(_)},E.prototype.doTick=function(){this._updateTrack(this._trackId)},E.prototype._selectInitialAudioTrack=function(){var p=this,_=this.tracks;if(_.length){var g=this.tracks[this._trackId],x=null;if(g&&(x=g.name),this._selectDefaultTrack){var C=_.filter(function(A){return A.default});C.length?_=C:f.logger.warn("No default audio tracks defined")}var R=!1,S=function(){_.forEach(function(A){R||(!p.audioGroupId||A.groupId===p.audioGroupId)&&(!x||x===A.name)&&(p._setAudioTrack(A.id),R=!0)})};S(),R||(x=null,S()),R||(f.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(l.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}},E.prototype._needsTrackLoading=function(p){var _=p.details,g=p.url;return!_||_.live?!!g:!1},E.prototype._loadTrackDetailsIfNeeded=function(p){if(this._needsTrackLoading(p)){var _=p.url,g=p.id;f.logger.log("loading audio-track playlist for id: "+g),this.hls.trigger(l.default.AUDIO_TRACK_LOADING,{url:_,id:g})}},E.prototype._updateTrack=function(p){if(!(p<0||p>=this.tracks.length)){this.clearInterval(),this._trackId=p,f.logger.log("trying to update audio-track "+p);var _=this.tracks[p];this._loadTrackDetailsIfNeeded(_)}},E.prototype._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var p=this._trackId,_=this.tracks[p],g=_.name,x=_.language,C=_.groupId;f.logger.warn("Loading failed on audio track id: "+p+", group-id: "+C+', name/language: "'+g+'" / "'+x+'"');for(var R=p,S=0;S<this.tracks.length;S++)if(!this.trackIdBlacklist[S]){var A=this.tracks[S];if(A.name===g){R=S;break}}if(R===p){f.logger.warn('No fallback audio-track found for name/language: "'+g+'" / "'+x+'"');return}f.logger.log("Attempting audio-track fallback id:",R,"group-id:",this.tracks[R].groupId),this._setAudioTrack(R)},E}(u.default);t.default=h},"./src/controller/base-stream-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,_){p.__proto__=_}||function(p,_){for(var g in _)_.hasOwnProperty(g)&&(p[g]=_[g])};return function(p,_){E(p,_);function g(){this.constructor=p}p.prototype=_===null?Object.create(_):(g.prototype=_.prototype,new g)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/task-loop.js"),f=n("./src/controller/fragment-tracker.js"),d=n("./src/utils/buffer-helper.js"),h=n("./src/utils/logger.js");t.State={STOPPED:"STOPPED",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};var y=function(E){l(p,E);function p(){return E!==null&&E.apply(this,arguments)||this}return p.prototype.doTick=function(){},p.prototype.startLoad=function(){},p.prototype.stopLoad=function(){var _=this.fragCurrent;_&&(_.loader&&_.loader.abort(),this.fragmentTracker.removeFragment(_)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=t.State.STOPPED},p.prototype._streamEnded=function(_,g){var x=this,C=x.fragCurrent,R=x.fragmentTracker;if(!g.live&&C&&!C.backtracked&&C.sn===g.endSN&&!_.nextStart){var S=R.getState(C);return S===f.FragmentState.PARTIAL||S===f.FragmentState.OK}return!1},p.prototype.onMediaSeeking=function(){var _=this,g=_.config,x=_.media,C=_.mediaBuffer,R=_.state,S=x?x.currentTime:null,A=d.BufferHelper.bufferInfo(C||x,S,this.config.maxBufferHole);if(a.isFinite(S)&&h.logger.log("media seeking to "+S.toFixed(3)),R===t.State.FRAG_LOADING){var T=this.fragCurrent;if(A.len===0&&T){var w=g.maxFragLookUpTolerance,P=T.start-w,O=T.start+T.duration+w;S<P||S>O?(T.loader&&(h.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),T.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=t.State.IDLE):h.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else R===t.State.ENDED&&(A.len===0&&(this.fragPrevious=null,this.fragCurrent=null),this.state=t.State.IDLE);x&&(this.lastCurrentTime=S),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=S),this.tick()},p.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},p.prototype.onHandlerDestroying=function(){this.stopLoad(),E.prototype.onHandlerDestroying.call(this)},p.prototype.onHandlerDestroyed=function(){this.state=t.State.STOPPED,this.fragmentTracker=null},p}(u.default);t.default=y}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/buffer-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,x){g.__proto__=x}||function(g,x){for(var C in x)x.hasOwnProperty(C)&&(g[C]=x[C])};return function(g,x){_(g,x);function C(){this.constructor=g}g.prototype=x===null?Object.create(x):(C.prototype=x.prototype,new C)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/utils/logger.js"),h=n("./src/errors.js"),y=n("./src/utils/mediasource-helper.js"),E=y.getMediaSource(),p=function(_){l(g,_);function g(x){var C=_.call(this,x,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.MANIFEST_PARSED,u.default.BUFFER_RESET,u.default.BUFFER_APPENDING,u.default.BUFFER_CODECS,u.default.BUFFER_EOS,u.default.BUFFER_FLUSHING,u.default.LEVEL_PTS_UPDATED,u.default.LEVEL_UPDATED)||this;return C._msDuration=null,C._levelDuration=null,C._levelTargetDuration=10,C._live=null,C._objectUrl=null,C.bufferCodecEventsExpected=0,C.onsbue=C.onSBUpdateEnd.bind(C),C.onsbe=C.onSBUpdateError.bind(C),C.pendingTracks={},C.tracks={},C}return g.prototype.destroy=function(){f.default.prototype.destroy.call(this)},g.prototype.onLevelPtsUpdated=function(x){var C=x.type,R=this.tracks.audio;if(C==="audio"&&R&&R.container==="audio/mpeg"){var S=this.sourceBuffer.audio,A=Math.abs(S.timestampOffset-x.start);if(A>.1){var T=S.updating;try{S.abort()}catch(w){d.logger.warn("can not abort audio buffer: "+w)}T?this.audioTimestampOffset=x.start:(d.logger.warn("change mpeg audio timestamp offset from "+S.timestampOffset+" to "+x.start),S.timestampOffset=x.start)}}},g.prototype.onManifestParsed=function(x){this.bufferCodecEventsExpected=x.altAudio?2:1,d.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},g.prototype.onMediaAttaching=function(x){var C=this.media=x.media;if(C){var R=this.mediaSource=new E;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),R.addEventListener("sourceopen",this.onmso),R.addEventListener("sourceended",this.onmse),R.addEventListener("sourceclose",this.onmsc),C.src=window.URL.createObjectURL(R),this._objectUrl=C.src}},g.prototype.onMediaDetaching=function(){d.logger.log("media source detaching");var x=this.mediaSource;if(x){if(x.readyState==="open")try{x.endOfStream()}catch(C){d.logger.warn("onMediaDetaching:"+C.message+" while calling endOfStream")}x.removeEventListener("sourceopen",this.onmso),x.removeEventListener("sourceended",this.onmse),x.removeEventListener("sourceclose",this.onmsc),this.media&&(window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):d.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(u.default.MEDIA_DETACHED)},g.prototype.onMediaSourceOpen=function(){d.logger.log("media source opened"),this.hls.trigger(u.default.MEDIA_ATTACHED,{media:this.media});var x=this.mediaSource;x&&x.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()},g.prototype.checkPendingTracks=function(){var x=this,C=x.bufferCodecEventsExpected,R=x.pendingTracks,S=Object.keys(R).length;(S&&!C||S===2)&&(this.createSourceBuffers(R),this.pendingTracks={},this.doAppending())},g.prototype.onMediaSourceClose=function(){d.logger.log("media source closed")},g.prototype.onMediaSourceEnded=function(){d.logger.log("media source ended")},g.prototype.onSBUpdateEnd=function(){if(this.audioTimestampOffset){var x=this.sourceBuffer.audio;d.logger.warn("change mpeg audio timestamp offset from "+x.timestampOffset+" to "+this.audioTimestampOffset),x.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var C=this.parent,R=this.segments.reduce(function(w,P){return P.parent===C?w+1:w},0),S={},A=this.sourceBuffer;for(var T in A)S[T]=A[T].buffered;this.hls.trigger(u.default.BUFFER_APPENDED,{parent:C,pending:R,timeRanges:S}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration(),R===0&&this.flushLiveBackBuffer()},g.prototype.onSBUpdateError=function(x){d.logger.error("sourceBuffer error:",x),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},g.prototype.onBufferReset=function(){var x=this.sourceBuffer;for(var C in x){var R=x[C];try{this.mediaSource.removeSourceBuffer(R),R.removeEventListener("updateend",this.onsbue),R.removeEventListener("error",this.onsbe)}catch{}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},g.prototype.onBufferCodecs=function(x){var C=this;if(!Object.keys(this.sourceBuffer).length){Object.keys(x).forEach(function(S){C.pendingTracks[S]=x[S]});var R=this.mediaSource;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),R&&R.readyState==="open"&&this.checkPendingTracks()}},g.prototype.createSourceBuffers=function(x){var C=this.sourceBuffer,R=this.mediaSource;for(var S in x)if(!C[S]){var A=x[S],T=A.levelCodec||A.codec,w=A.container+";codecs="+T;d.logger.log("creating sourceBuffer("+w+")");try{var P=C[S]=R.addSourceBuffer(w);P.addEventListener("updateend",this.onsbue),P.addEventListener("error",this.onsbe),this.tracks[S]={codec:T,container:A.container},A.buffer=P}catch(O){d.logger.error("error while trying to add sourceBuffer:"+O.message),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:O,mimeType:w})}}this.hls.trigger(u.default.BUFFER_CREATED,{tracks:x})},g.prototype.onBufferAppending=function(x){this._needsFlush||(this.segments?this.segments.push(x):this.segments=[x],this.doAppending())},g.prototype.onBufferAppendFail=function(x){d.logger.error("sourceBuffer error:",x.event),this.hls.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},g.prototype.onBufferEos=function(x){var C=this.sourceBuffer,R=x.type;for(var S in C)(!R||S===R)&&(C[S].ended||(C[S].ended=!0,d.logger.log(S+" sourceBuffer now EOS")));this.checkEos()},g.prototype.checkEos=function(){var x=this.sourceBuffer,C=this.mediaSource;if(!C||C.readyState!=="open"){this._needsEos=!1;return}for(var R in x){var S=x[R];if(!S.ended)return;if(S.updating){this._needsEos=!0;return}}d.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{C.endOfStream()}catch{d.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1},g.prototype.onBufferFlushing=function(x){this.flushRange.push({start:x.startOffset,end:x.endOffset,type:x.type}),this.flushBufferCounter=0,this.doFlush()},g.prototype.flushLiveBackBuffer=function(){if(this._live){var x=this.hls.config.liveBackBufferLength;if(!(!isFinite(x)||x<0))for(var C=this.media.currentTime,R=this.sourceBuffer,S=Object.keys(R),A=C-Math.max(x,this._levelTargetDuration),T=S.length-1;T>=0;T--){var w=S[T],P=R[w].buffered;P.length>0&&A>P.start(0)&&this.removeBufferRange(w,R[w],0,A)}}},g.prototype.onLevelUpdated=function(x){var C=x.details;C.fragments.length>0&&(this._levelDuration=C.totalduration+C.fragments[0].start,this._levelTargetDuration=C.averagetargetduration||C.targetduration||10,this._live=C.live,this.updateMediaElementDuration())},g.prototype.updateMediaElementDuration=function(){var x=this.hls.config,C;if(!(this._levelDuration===null||!this.media||!this.mediaSource||!this.sourceBuffer||this.media.readyState===0||this.mediaSource.readyState!=="open")){for(var R in this.sourceBuffer)if(this.sourceBuffer[R].updating===!0)return;C=this.media.duration,this._msDuration===null&&(this._msDuration=this.mediaSource.duration),this._live===!0&&x.liveDurationInfinity===!0?(d.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>C||!a.isFinite(C))&&(d.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},g.prototype.doFlush=function(){for(;this.flushRange.length;){var x=this.flushRange[0];if(this.flushBuffer(x.start,x.end,x.type))this.flushRange.shift(),this.flushBufferCounter=0;else{this._needsFlush=!0;return}}if(this.flushRange.length===0){this._needsFlush=!1;var C=0,R=this.sourceBuffer;try{for(var S in R)C+=R[S].buffered.length}catch{d.logger.error("error while accessing sourceBuffer.buffered")}this.appended=C,this.hls.trigger(u.default.BUFFER_FLUSHED)}},g.prototype.doAppending=function(){var x=this,C=x.hls,R=x.segments,S=x.sourceBuffer;if(Object.keys(S).length){if(this.media.error){this.segments=[],d.logger.error("trying to append although a media error occured, flush segment and abort");return}if(this.appending)return;if(R&&R.length){var A=R.shift();try{var T=A.type,w=S[T];w?w.updating?R.unshift(A):(w.ended=!1,this.parent=A.parent,w.appendBuffer(A.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(O){d.logger.error("error while trying to append buffer:"+O.message),R.unshift(A);var P={type:h.ErrorTypes.MEDIA_ERROR,parent:A.parent};O.code!==22?(this.appendError?this.appendError++:this.appendError=1,P.details=h.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>C.config.appendErrorMaxRetry?(d.logger.log("fail "+C.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],P.fatal=!0,C.trigger(u.default.ERROR,P)):(P.fatal=!1,C.trigger(u.default.ERROR,P))):(this.segments=[],P.details=h.ErrorDetails.BUFFER_FULL_ERROR,P.fatal=!1,C.trigger(u.default.ERROR,P))}}}},g.prototype.flushBuffer=function(x,C,R){var S,A=this.sourceBuffer;if(Object.keys(A).length){if(d.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+x+"/"+C),this.flushBufferCounter<this.appended){for(var T in A)if(!(R&&T!==R)){if(S=A[T],S.ended=!1,S.updating)return d.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(T,S,x,C))return this.flushBufferCounter++,!1}}else d.logger.warn("abort flushing too many retries");d.logger.log("buffer flushed")}return!0},g.prototype.removeBufferRange=function(x,C,R,S){try{for(var A=0;A<C.buffered.length;A++){var T=C.buffered.start(A),w=C.buffered.end(A),P=Math.max(T,R),O=Math.min(w,S);if(Math.min(O,w)-P>.5)return d.logger.log("sb remove "+x+" ["+P+","+O+"], of ["+T+","+w+"], pos:"+this.media.currentTime),C.remove(P,O),!0}}catch(k){d.logger.warn("removeBufferRange failed",k)}return!1},g}(f.default);t.default=p}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/cap-level-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,E){y.__proto__=E}||function(y,E){for(var p in E)E.hasOwnProperty(p)&&(y[p]=E[p])};return function(y,E){h(y,E);function p(){this.constructor=y}y.prototype=E===null?Object.create(E):(p.prototype=E.prototype,new p)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=function(h){l(y,h);function y(E){var p=h.call(this,E,u.default.FPS_DROP_LEVEL_CAPPING,u.default.MEDIA_ATTACHING,u.default.MANIFEST_PARSED,u.default.BUFFER_CODECS,u.default.MEDIA_DETACHING)||this;return p.autoLevelCapping=a.POSITIVE_INFINITY,p.firstLevel=null,p.levels=[],p.media=null,p.restrictedLevels=[],p.timer=null,p}return y.prototype.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this._stopCapping())},y.prototype.onFpsDropLevelCapping=function(E){y.isLevelAllowed(E.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(E.droppedLevel)},y.prototype.onMediaAttaching=function(E){this.media=E.media instanceof window.HTMLVideoElement?E.media:null},y.prototype.onManifestParsed=function(E){var p=this.hls;this.restrictedLevels=[],this.levels=E.levels,this.firstLevel=E.firstLevel,p.config.capLevelToPlayerSize&&E.video&&this._startCapping()},y.prototype.onBufferCodecs=function(E){var p=this.hls;p.config.capLevelToPlayerSize&&E.video&&this._startCapping()},y.prototype.onLevelsUpdated=function(E){this.levels=E.levels},y.prototype.onMediaDetaching=function(){this._stopCapping()},y.prototype.detectPlayerSize=function(){if(this.media){var E=this.levels?this.levels.length:0;if(E){var p=this.hls;p.autoLevelCapping=this.getMaxLevel(E-1),p.autoLevelCapping>this.autoLevelCapping&&p.streamController.nextLevelSwitch(),this.autoLevelCapping=p.autoLevelCapping}}},y.prototype.getMaxLevel=function(E){var p=this;if(!this.levels)return-1;var _=this.levels.filter(function(g,x){return y.isLevelAllowed(x,p.restrictedLevels)&&x<=E});return y.getMaxLevelByMediaSize(_,this.mediaWidth,this.mediaHeight)},y.prototype._startCapping=function(){this.timer||(this.autoLevelCapping=a.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},y.prototype._stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=a.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},Object.defineProperty(y.prototype,"mediaWidth",{get:function(){var E,p=this.media;return p&&(E=p.width||p.clientWidth||p.offsetWidth,E*=y.contentScaleFactor),E},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"mediaHeight",{get:function(){var E,p=this.media;return p&&(E=p.height||p.clientHeight||p.offsetHeight,E*=y.contentScaleFactor),E},enumerable:!0,configurable:!0}),Object.defineProperty(y,"contentScaleFactor",{get:function(){var E=1;try{E=window.devicePixelRatio}catch{}return E},enumerable:!0,configurable:!0}),y.isLevelAllowed=function(E,p){return p===void 0&&(p=[]),p.indexOf(E)===-1},y.getMaxLevelByMediaSize=function(E,p,_){if(!E||E&&!E.length)return-1;for(var g=function(S,A){return A?S.width!==A.width||S.height!==A.height:!0},x=E.length-1,C=0;C<E.length;C+=1){var R=E[C];if((R.width>=p||R.height>=_)&&g(R,E[C+1])){x=C;break}}return x},y}(f.default);t.default=d}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/eme-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(C,R){C.__proto__=R}||function(C,R){for(var S in R)R.hasOwnProperty(S)&&(C[S]=R[S])};return function(C,R){x(C,R);function S(){this.constructor=C}C.prototype=R===null?Object.create(R):(S.prototype=R.prototype,new S)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/event-handler.js"),u=n("./src/events.js"),f=n("./src/errors.js"),d=n("./src/utils/logger.js"),h=window.XMLHttpRequest,y=3,E={WIDEVINE:"com.widevine.alpha",PLAYREADY:"com.microsoft.playready"},p=function(x,C,R){var S={videoCapabilities:[]};return C.forEach(function(A){S.videoCapabilities.push({contentType:'video/mp4; codecs="'+A+'"'})}),[S]},_=function(x,C,R){switch(x){case E.WIDEVINE:return p(C,R);default:throw Error("Unknown key-system: "+x)}},g=function(x){a(C,x);function C(R){var S=x.call(this,R,u.default.MEDIA_ATTACHED,u.default.MANIFEST_PARSED)||this;return S._widevineLicenseUrl=R.config.widevineLicenseUrl,S._licenseXhrSetup=R.config.licenseXhrSetup,S._emeEnabled=R.config.emeEnabled,S._requestMediaKeySystemAccess=R.config.requestMediaKeySystemAccessFunc,S._mediaKeysList=[],S._media=null,S._hasSetMediaKeys=!1,S._isMediaEncrypted=!1,S._requestLicenseFailureCount=0,S}return C.prototype.getLicenseServerUrl=function(R){var S;switch(R){case E.WIDEVINE:S=this._widevineLicenseUrl;break;default:S=null;break}return S||(d.logger.error('No license server URL configured for key-system "'+R+'"'),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})),S},C.prototype._attemptKeySystemAccess=function(R,S,A){var T=this,w=_(R,S,A);if(!w){d.logger.warn("Can not create config for key-system (maybe because platform is not supported):",R);return}d.logger.log("Requesting encrypted media key-system access"),this.requestMediaKeySystemAccess(R,w).then(function(P){T._onMediaKeySystemAccessObtained(R,P)}).catch(function(P){d.logger.error('Failed to obtain key-system "'+R+'" access:',P)})},Object.defineProperty(C.prototype,"requestMediaKeySystemAccess",{get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess},enumerable:!0,configurable:!0}),C.prototype._onMediaKeySystemAccessObtained=function(R,S){var A=this;d.logger.log('Access for key-system "'+R+'" obtained');var T={mediaKeys:null,mediaKeysSession:null,mediaKeysSessionInitialized:!1,mediaKeySystemAccess:S,mediaKeySystemDomain:R};this._mediaKeysList.push(T),S.createMediaKeys().then(function(w){T.mediaKeys=w,d.logger.log('Media-keys created for key-system "'+R+'"'),A._onMediaKeysCreated()}).catch(function(w){d.logger.error("Failed to create media-keys:",w)})},C.prototype._onMediaKeysCreated=function(){var R=this;this._mediaKeysList.forEach(function(S){S.mediaKeysSession||(S.mediaKeysSession=S.mediaKeys.createSession(),R._onNewMediaKeySession(S.mediaKeysSession))})},C.prototype._onNewMediaKeySession=function(R){var S=this;d.logger.log("New key-system session "+R.sessionId),R.addEventListener("message",function(A){S._onKeySessionMessage(R,A.message)},!1)},C.prototype._onKeySessionMessage=function(R,S){d.logger.log("Got EME message event, creating license request"),this._requestLicense(S,function(A){d.logger.log("Received license data, updating key-session"),R.update(A)})},C.prototype._onMediaEncrypted=function(R,S){d.logger.log('Media is encrypted using "'+R+'" init data type'),this._isMediaEncrypted=!0,this._mediaEncryptionInitDataType=R,this._mediaEncryptionInitData=S,this._attemptSetMediaKeys(),this._generateRequestWithPreferredKeySession()},C.prototype._attemptSetMediaKeys=function(){if(!this._hasSetMediaKeys){var R=this._mediaKeysList[0];if(!R||!R.mediaKeys){d.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}d.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(R.mediaKeys),this._hasSetMediaKeys=!0}},C.prototype._generateRequestWithPreferredKeySession=function(){var R=this,S=this._mediaKeysList[0];if(!S){d.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(S.mediaKeysSessionInitialized){d.logger.warn("Key-Session already initialized but requested again");return}var A=S.mediaKeysSession;A||(d.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0}));var T=this._mediaEncryptionInitDataType,w=this._mediaEncryptionInitData;d.logger.log('Generating key-session request for "'+T+'" init data type'),S.mediaKeysSessionInitialized=!0,A.generateRequest(T,w).then(function(){d.logger.debug("Key-session generation succeeded")}).catch(function(P){d.logger.error("Error generating key-session request:",P),R.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},C.prototype._createLicenseXhr=function(R,S,A){var T=new h,w=this._licenseXhrSetup;try{if(w)try{w(T,R)}catch{T.open("POST",R,!0),w(T,R)}T.readyState||T.open("POST",R,!0)}catch(P){d.logger.error("Error setting up key-system license XHR",P),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}return T.responseType="arraybuffer",T.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,T,R,S,A),T},C.prototype._onLicenseRequestReadyStageChange=function(R,S,A,T){switch(R.readyState){case 4:if(R.status===200)this._requestLicenseFailureCount=0,d.logger.log("License request succeeded"),T(R.response);else{if(d.logger.error("License Request XHR failed ("+S+"). Status: "+R.status+" ("+R.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount<=y){var w=y-this._requestLicenseFailureCount+1;d.logger.warn("Retrying license request, "+w+" attempts left"),this._requestLicense(A,T);return}this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}break}},C.prototype._generateLicenseRequestChallenge=function(R,S){var A;return R.mediaKeySystemDomain===E.PLAYREADY?d.logger.error("PlayReady is not supported (yet)"):R.mediaKeySystemDomain===E.WIDEVINE?A=S:d.logger.error("Unsupported key-system:",R.mediaKeySystemDomain),A},C.prototype._requestLicense=function(R,S){d.logger.log("Requesting content license for key-system");var A=this._mediaKeysList[0];if(!A){d.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(u.default.ERROR,{type:f.ErrorTypes.KEY_SYSTEM_ERROR,details:f.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}var T=this.getLicenseServerUrl(A.mediaKeySystemDomain),w=this._createLicenseXhr(T,R,S);d.logger.log("Sending license request to URL: "+T),w.send(this._generateLicenseRequestChallenge(A,R))},C.prototype.onMediaAttached=function(R){var S=this;if(this._emeEnabled){var A=R.media;this._media=A,A.addEventListener("encrypted",function(T){S._onMediaEncrypted(T.initDataType,T.initData)})}},C.prototype.onManifestParsed=function(R){if(this._emeEnabled){var S=R.levels.map(function(T){return T.audioCodec}),A=R.levels.map(function(T){return T.videoCodec});this._attemptKeySystemAccess(E.WIDEVINE,S,A)}},C}(l.default);t.default=g},"./src/controller/fps-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,p){E.__proto__=p}||function(E,p){for(var _ in p)p.hasOwnProperty(_)&&(E[_]=p[_])};return function(E,p){y(E,p);function _(){this.constructor=E}E.prototype=p===null?Object.create(p):(_.prototype=p.prototype,new _)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/event-handler.js"),f=n("./src/utils/logger.js"),d=window.performance,h=function(y){a(E,y);function E(p){return y.call(this,p,l.default.MEDIA_ATTACHING)||this}return E.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},E.prototype.onMediaAttaching=function(p){var _=this.hls.config;if(_.capLevelOnFPSDrop){var g=this.video=p.media instanceof window.HTMLVideoElement?p.media:null;typeof g.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),_.fpsDroppedMonitoringPeriod)}},E.prototype.checkFPS=function(p,_,g){var x=d.now();if(_){if(this.lastTime){var C=x-this.lastTime,R=g-this.lastDroppedFrames,S=_-this.lastDecodedFrames,A=1e3*R/C,T=this.hls;if(T.trigger(l.default.FPS_DROP,{currentDropped:R,currentDecoded:S,totalDroppedFrames:g}),A>0&&R>T.config.fpsDroppedMonitoringThreshold*S){var w=T.currentLevel;f.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+w),w>0&&(T.autoLevelCapping===-1||T.autoLevelCapping>=w)&&(w=w-1,T.trigger(l.default.FPS_DROP_LEVEL_CAPPING,{level:w,droppedLevel:T.currentLevel}),T.autoLevelCapping=w,T.streamController.nextLevelSwitch())}}this.lastTime=x,this.lastDroppedFrames=g,this.lastDecodedFrames=_}},E.prototype.checkFPSInterval=function(){var p=this.video;if(p)if(this.isVideoPlaybackQualityAvailable){var _=p.getVideoPlaybackQuality();this.checkFPS(p,_.totalVideoFrames,_.droppedVideoFrames)}else this.checkFPS(p,p.webkitDecodedFrameCount,p.webkitDroppedFrameCount)},E}(u.default);t.default=h},"./src/controller/fragment-finders.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/utils/binary-search.js");function u(y,E,p){if(!Array.isArray(y)||!y.length||!a.isFinite(E)||E<y[0].programDateTime||E>=y[y.length-1].endProgramDateTime)return null;p=p||0;for(var _=0;_<y.length;++_){var g=y[_];if(h(E,p,g))return g}return null}t.findFragmentByPDT=u;function f(y,E,p,_){p===void 0&&(p=0),_===void 0&&(_=0);var g=y?E[y.sn-E[0].sn+1]:null;return g&&!d(p,_,g)?g:l.default.search(E,d.bind(null,p,_))}t.findFragmentByPTS=f;function d(y,E,p){y===void 0&&(y=0),E===void 0&&(E=0);var _=Math.min(E,p.duration+(p.deltaPTS?p.deltaPTS:0));return p.start+p.duration-_<=y?1:p.start-_>y&&p.start?-1:0}t.fragmentWithinToleranceTest=d;function h(y,E,p){var _=Math.min(E,p.duration+(p.deltaPTS?p.deltaPTS:0))*1e3;return p.endProgramDateTime-_>y}t.pdtWithinToleranceTest=h}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/fragment-tracker.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,E){y.__proto__=E}||function(y,E){for(var p in E)E.hasOwnProperty(p)&&(y[p]=E[p])};return function(y,E){h(y,E);function p(){this.constructor=y}y.prototype=E===null?Object.create(E):(p.prototype=E.prototype,new p)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/event-handler.js"),f=n("./src/events.js");t.FragmentState={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};var d=function(h){l(y,h);function y(E){var p=h.call(this,E,f.default.BUFFER_APPENDED,f.default.FRAG_BUFFERED,f.default.FRAG_LOADED)||this;return p.bufferPadding=.2,p.fragments=Object.create(null),p.timeRanges=Object.create(null),p.config=E.config,p}return y.prototype.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,u.default.prototype.destroy.call(this),h.prototype.destroy.call(this)},y.prototype.getBufferedFrag=function(E,p){var _=this.fragments,g=Object.keys(_).filter(function(C){var R=_[C];if(R.body.type!==p||!R.buffered)return!1;var S=R.body;return S.startPTS<=E&&E<=S.endPTS});if(g.length===0)return null;var x=g.pop();return _[x].body},y.prototype.detectEvictedFragments=function(E,p){var _=this,g,x;Object.keys(this.fragments).forEach(function(C){var R=_.fragments[C];if(R.buffered===!0){var S=R.range[E];if(S){g=S.time;for(var A=0;A<g.length;A++)if(x=g[A],_.isTimeBuffered(x.startPTS,x.endPTS,p)===!1){_.removeFragment(R.body);break}}}})},y.prototype.detectPartialFragments=function(E){var p=this,_=this.getFragmentKey(E),g=this.fragments[_];g&&(g.buffered=!0,Object.keys(this.timeRanges).forEach(function(x){if(E.hasElementaryStream(x)){var C=p.timeRanges[x];g.range[x]=p.getBufferedTimes(E.startPTS,E.endPTS,C)}}))},y.prototype.getBufferedTimes=function(E,p,_){for(var g=[],x,C,R=!1,S=0;S<_.length;S++)if(x=_.start(S)-this.bufferPadding,C=_.end(S)+this.bufferPadding,E>=x&&p<=C){g.push({startPTS:Math.max(E,_.start(S)),endPTS:Math.min(p,_.end(S))});break}else if(E<C&&p>x)g.push({startPTS:Math.max(E,_.start(S)),endPTS:Math.min(p,_.end(S))}),R=!0;else if(p<=x)break;return{time:g,partial:R}},y.prototype.getFragmentKey=function(E){return E.type+"_"+E.level+"_"+E.urlId+"_"+E.sn},y.prototype.getPartialFragment=function(E){var p=this,_,g,x,C=null,R=0;return Object.keys(this.fragments).forEach(function(S){var A=p.fragments[S];p.isPartial(A)&&(g=A.body.startPTS-p.bufferPadding,x=A.body.endPTS+p.bufferPadding,E>=g&&E<=x&&(_=Math.min(E-g,x-E),R<=_&&(C=A.body,R=_)))}),C},y.prototype.getState=function(E){var p=this.getFragmentKey(E),_=this.fragments[p],g=t.FragmentState.NOT_LOADED;return _!==void 0&&(_.buffered?this.isPartial(_)===!0?g=t.FragmentState.PARTIAL:g=t.FragmentState.OK:g=t.FragmentState.APPENDING),g},y.prototype.isPartial=function(E){return E.buffered===!0&&(E.range.video!==void 0&&E.range.video.partial===!0||E.range.audio!==void 0&&E.range.audio.partial===!0)},y.prototype.isTimeBuffered=function(E,p,_){for(var g,x,C=0;C<_.length;C++){if(g=_.start(C)-this.bufferPadding,x=_.end(C)+this.bufferPadding,E>=g&&p<=x)return!0;if(p<=g)return!1}return!1},y.prototype.onFragLoaded=function(E){var p=E.frag;!a.isFinite(p.sn)||p.bitrateTest||(this.fragments[this.getFragmentKey(p)]={body:p,range:Object.create(null),buffered:!1})},y.prototype.onBufferAppended=function(E){var p=this;this.timeRanges=E.timeRanges,Object.keys(this.timeRanges).forEach(function(_){var g=p.timeRanges[_];p.detectEvictedFragments(_,g)})},y.prototype.onFragBuffered=function(E){this.detectPartialFragments(E.frag)},y.prototype.hasFragment=function(E){var p=this.getFragmentKey(E);return this.fragments[p]!==void 0},y.prototype.removeFragment=function(E){var p=this.getFragmentKey(E);delete this.fragments[p]},y.prototype.removeAllFragments=function(){this.fragments=Object.create(null)},y}(u.default);t.FragmentTracker=d}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/gap-controller.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/buffer-helper.js"),l=n("./src/errors.js"),u=n("./src/events.js"),f=n("./src/utils/logger.js"),d=1e3,h=.5,y=function(){function E(p,_,g,x){this.config=p,this.media=_,this.fragmentTracker=g,this.hls=x,this.stallReported=!1}return E.prototype.poll=function(p,_){var g=this,x=g.config,C=g.media,R=C.currentTime,S=window.performance.now();if(R!==p){this.stallReported&&(f.logger.warn("playback not stuck anymore @"+R+", after "+Math.round(S-this.stalled)+"ms"),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0;return}if(!(C.ended||!C.buffered.length||C.readyState>2)&&!(C.seeking&&a.BufferHelper.isBuffered(C,R))){var A=S-this.stalled,T=a.BufferHelper.bufferInfo(C,R,x.maxBufferHole);if(this.stalled)A>=d&&this._reportStall(T.len);else{this.stalled=S;return}this._tryFixBufferStall(T,A)}},E.prototype._tryFixBufferStall=function(p,_){var g=this,x=g.config,C=g.fragmentTracker,R=g.media,S=R.currentTime,A=C.getPartialFragment(S);A&&this._trySkipBufferHole(A),p.len>h&&_>x.highBufferWatchdogPeriod*1e3&&(this.stalled=null,this._tryNudgeBuffer())},E.prototype._reportStall=function(p){var _=this,g=_.hls,x=_.media,C=_.stallReported;C||(this.stallReported=!0,f.logger.warn("Playback stalling at @"+x.currentTime+" due to low buffer"),g.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p}))},E.prototype._trySkipBufferHole=function(p){for(var _=this,g=_.hls,x=_.media,C=x.currentTime,R=0,S=0;S<x.buffered.length;S++){var A=x.buffered.start(S);if(C>=R&&C<A){x.currentTime=Math.max(A,x.currentTime+.1),f.logger.warn("skipping hole, adjusting currentTime from "+C+" to "+x.currentTime),this.stalled=null,g.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+C+" to "+x.currentTime,frag:p});return}R=x.buffered.end(S)}},E.prototype._tryNudgeBuffer=function(){var p=this,_=p.config,g=p.hls,x=p.media,C=x.currentTime,R=(this.nudgeRetry||0)+1;if(this.nudgeRetry=R,R<_.nudgeMaxRetry){var S=C+R*_.nudgeOffset;f.logger.log("adjust currentTime from "+C+" to "+S),x.currentTime=S,g.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else f.logger.error("still stuck in high buffer @"+C+" after "+_.nudgeMaxRetry+", raise fatal error"),g.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},E}();t.default=y},"./src/controller/id3-track-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,p){E.__proto__=p}||function(E,p){for(var _ in p)p.hasOwnProperty(_)&&(E[_]=p[_])};return function(E,p){y(E,p);function _(){this.constructor=E}E.prototype=p===null?Object.create(p):(_.prototype=p.prototype,new _)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/event-handler.js"),f=n("./src/demux/id3.js"),d=n("./src/utils/texttrack-utils.js"),h=function(y){a(E,y);function E(p){var _=y.call(this,p,l.default.MEDIA_ATTACHED,l.default.MEDIA_DETACHING,l.default.FRAG_PARSING_METADATA)||this;return _.id3Track=void 0,_.media=void 0,_}return E.prototype.destroy=function(){u.default.prototype.destroy.call(this)},E.prototype.onMediaAttached=function(p){this.media=p.media,this.media},E.prototype.onMediaDetaching=function(){d.clearCurrentCues(this.id3Track),this.id3Track=void 0,this.media=void 0},E.prototype.getID3Track=function(p){for(var _=0;_<p.length;_++){var g=p[_];if(g.kind==="metadata"&&g.label==="id3")return d.sendAddTrackEvent(g,this.media),g}return this.media.addTextTrack("metadata","id3")},E.prototype.onFragParsingMetadata=function(p){var _=p.frag,g=p.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var x=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,C=0;C<g.length;C++){var R=f.default.getID3Frames(g[C].data);if(R){var S=g[C].pts,A=C<g.length-1?g[C+1].pts:_.endPTS;S===A&&(A+=1e-4);for(var T=0;T<R.length;T++){var w=R[T];if(!f.default.isTimeStampFrame(w)){var P=new x(S,A,"");P.value=w,this.id3Track.addCue(P)}}}}},E}(u.default);t.default=h},"./src/controller/level-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,x){g.__proto__=x}||function(g,x){for(var C in x)x.hasOwnProperty(C)&&(g[C]=x[C])};return function(g,x){_(g,x);function C(){this.constructor=g}g.prototype=x===null?Object.create(x):(C.prototype=x.prototype,new C)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/event-handler.js"),f=n("./src/utils/logger.js"),d=n("./src/errors.js"),h=n("./src/utils/codecs.js"),y=n("./src/controller/level-helper.js"),E,p=function(_){a(g,_);function g(x){var C=_.call(this,x,l.default.MANIFEST_LOADED,l.default.LEVEL_LOADED,l.default.AUDIO_TRACK_SWITCHED,l.default.FRAG_LOADED,l.default.ERROR)||this;return C.canload=!1,C.currentLevelIndex=null,C.manualLevelIndex=-1,C.timer=null,E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),C}return g.prototype.onHandlerDestroying=function(){this.clearTimer(),this.manualLevelIndex=-1},g.prototype.clearTimer=function(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)},g.prototype.startLoad=function(){var x=this._levels;this.canload=!0,this.levelRetryCount=0,x&&x.forEach(function(C){C.loadError=0;var R=C.details;R&&R.live&&(C.details=void 0)}),this.timer!==null&&this.loadLevel()},g.prototype.stopLoad=function(){this.canload=!1},g.prototype.onManifestLoaded=function(x){var C=[],R=[],S,A={},T=null,w=!1,P=!1;if(x.levels.forEach(function(k){var D=k.attrs;k.loadError=0,k.fragmentError=!1,w=w||!!k.videoCodec,P=P||!!k.audioCodec,E&&k.audioCodec&&k.audioCodec.indexOf("mp4a.40.34")!==-1&&(k.audioCodec=void 0),T=A[k.bitrate],T?T.url.push(k.url):(k.url=[k.url],k.urlId=0,A[k.bitrate]=k,C.push(k)),D&&(D.AUDIO&&(P=!0,y.addGroupId(T||k,"audio",D.AUDIO)),D.SUBTITLES&&y.addGroupId(T||k,"text",D.SUBTITLES))}),w&&P&&(C=C.filter(function(k){var D=k.videoCodec;return!!D})),C=C.filter(function(k){var D=k.audioCodec,F=k.videoCodec;return(!D||h.isCodecSupportedInMp4(D,"audio"))&&(!F||h.isCodecSupportedInMp4(F,"video"))}),x.audioTracks&&(R=x.audioTracks.filter(function(k){return!k.audioCodec||h.isCodecSupportedInMp4(k.audioCodec,"audio")}),R.forEach(function(k,D){k.id=D})),C.length>0){S=C[0].bitrate,C.sort(function(k,D){return k.bitrate-D.bitrate}),this._levels=C;for(var O=0;O<C.length;O++)if(C[O].bitrate===S){this._firstLevel=O,f.logger.log("manifest loaded,"+C.length+" level(s) found, first bitrate:"+S);break}this.hls.trigger(l.default.MANIFEST_PARSED,{levels:C,audioTracks:R,firstLevel:this._firstLevel,stats:x.stats,audio:P,video:w,altAudio:R.some(function(k){return!!k.url})})}else this.hls.trigger(l.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})},Object.defineProperty(g.prototype,"levels",{get:function(){return this._levels},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"level",{get:function(){return this.currentLevelIndex},set:function(x){var C=this._levels;C&&(x=Math.min(x,C.length-1),(this.currentLevelIndex!==x||!C[x].details)&&this.setLevelInternal(x))},enumerable:!0,configurable:!0}),g.prototype.setLevelInternal=function(x){var C=this._levels,R=this.hls;if(x>=0&&x<C.length){if(this.clearTimer(),this.currentLevelIndex!==x){f.logger.log("switching to level "+x),this.currentLevelIndex=x;var S=C[x];S.level=x,R.trigger(l.default.LEVEL_SWITCHING,S)}var A=C[x],T=A.details;if(!T||T.live){var w=A.urlId;R.trigger(l.default.LEVEL_LOADING,{url:A.url[w],level:x,id:w})}}else R.trigger(l.default.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.LEVEL_SWITCH_ERROR,level:x,fatal:!1,reason:"invalid level idx"})},Object.defineProperty(g.prototype,"manualLevel",{get:function(){return this.manualLevelIndex},set:function(x){this.manualLevelIndex=x,this._startLevel===void 0&&(this._startLevel=x),x!==-1&&(this.level=x)},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"firstLevel",{get:function(){return this._firstLevel},set:function(x){this._firstLevel=x},enumerable:!0,configurable:!0}),Object.defineProperty(g.prototype,"startLevel",{get:function(){if(this._startLevel===void 0){var x=this.hls.config.startLevel;return x!==void 0?x:this._firstLevel}else return this._startLevel},set:function(x){this._startLevel=x},enumerable:!0,configurable:!0}),g.prototype.onError=function(x){if(x.fatal){x.type===d.ErrorTypes.NETWORK_ERROR&&this.clearTimer();return}var C=!1,R=!1,S;switch(x.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:S=x.frag.level,R=!0;break;case d.ErrorDetails.LEVEL_LOAD_ERROR:case d.ErrorDetails.LEVEL_LOAD_TIMEOUT:S=x.context.level,C=!0;break;case d.ErrorDetails.REMUX_ALLOC_ERROR:S=x.level,C=!0;break}S!==void 0&&this.recoverLevel(x,S,C,R)},g.prototype.recoverLevel=function(x,C,R,S){var A=this,T=this.hls.config,w=x.details,P=this._levels[C],O,k,D;if(P.loadError++,P.fragmentError=S,R)if(this.levelRetryCount+1<=T.levelLoadingMaxRetry)k=Math.min(Math.pow(2,this.levelRetryCount)*T.levelLoadingRetryDelay,T.levelLoadingMaxRetryTimeout),this.timer=setTimeout(function(){return A.loadLevel()},k),x.levelRetry=!0,this.levelRetryCount++,f.logger.warn("level controller, "+w+", retry in "+k+" ms, current retry count is "+this.levelRetryCount);else{f.logger.error("level controller, cannot recover from "+w+" error"),this.currentLevelIndex=null,this.clearTimer(),x.fatal=!0;return}(R||S)&&(O=P.url.length,O>1&&P.loadError<O?(P.urlId=(P.urlId+1)%O,P.details=void 0,f.logger.warn("level controller, "+w+" for level "+C+": switching to redundant URL-id "+P.urlId)):this.manualLevelIndex===-1?(D=C===0?this._levels.length-1:C-1,f.logger.warn("level controller, "+w+": switch to "+D),this.hls.nextAutoLevel=this.currentLevelIndex=D):S&&(f.logger.warn("level controller, "+w+": reload a fragment"),this.currentLevelIndex=null))},g.prototype.onFragLoaded=function(x){var C=x.frag;if(C!==void 0&&C.type==="main"){var R=this._levels[C.level];R!==void 0&&(R.fragmentError=!1,R.loadError=0,this.levelRetryCount=0)}},g.prototype.onLevelLoaded=function(x){var C=this,R=x.level,S=x.details;if(R===this.currentLevelIndex){var A=this._levels[R];if(A.fragmentError||(A.loadError=0,this.levelRetryCount=0),S.live){var T=y.computeReloadInterval(A.details,S,x.stats.trequest);f.logger.log("live playlist, reload in "+Math.round(T)+" ms"),this.timer=setTimeout(function(){return C.loadLevel()},T)}else this.clearTimer()}},g.prototype.onAudioTrackSwitched=function(x){var C=this.hls.audioTracks[x.id].groupId,R=this.hls.levels[this.currentLevelIndex];if(R&&R.audioGroupIds){for(var S=-1,A=0;A<R.audioGroupIds.length;A++)if(R.audioGroupIds[A]===C){S=A;break}S!==R.urlId&&(R.urlId=S,this.startLoad())}},g.prototype.loadLevel=function(){if(f.logger.debug("call to loadLevel"),this.currentLevelIndex!==null&&this.canload){var x=this._levels[this.currentLevelIndex];if(typeof x=="object"&&x.url.length>0){var C=this.currentLevelIndex,R=x.urlId,S=x.url[R];f.logger.log("Attempt loading level index "+C+" with URL-id "+R),this.hls.trigger(l.default.LEVEL_LOADING,{url:S,level:C,id:R})}}},Object.defineProperty(g.prototype,"nextLoadLevel",{get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(x){this.level=x,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=x)},enumerable:!0,configurable:!0}),g}(u.default);t.default=p},"./src/controller/level-helper.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/utils/logger.js");function u(g,x,C){switch(x){case"audio":g.audioGroupIds||(g.audioGroupIds=[]),g.audioGroupIds.push(C);break;case"text":g.textGroupIds||(g.textGroupIds=[]),g.textGroupIds.push(C);break}}t.addGroupId=u;function f(g,x,C){var R=g[x],S=g[C],A=S.startPTS;a.isFinite(A)?C>x?(R.duration=A-R.start,R.duration<0&&l.logger.warn("negative duration computed for frag "+R.sn+",level "+R.level+", there should be some duration drift between playlist and fragment!")):(S.duration=R.start-A,S.duration<0&&l.logger.warn("negative duration computed for frag "+S.sn+",level "+S.level+", there should be some duration drift between playlist and fragment!")):C>x?S.start=R.start+R.duration:S.start=Math.max(R.start-S.duration,0)}t.updatePTS=f;function d(g,x,C,R,S,A){var T=C;if(a.isFinite(x.startPTS)){var w=Math.abs(x.startPTS-C);a.isFinite(x.deltaPTS)?x.deltaPTS=Math.max(w,x.deltaPTS):x.deltaPTS=w,T=Math.max(C,x.startPTS),C=Math.min(C,x.startPTS),R=Math.max(R,x.endPTS),S=Math.min(S,x.startDTS),A=Math.max(A,x.endDTS)}var P=C-x.start;x.start=x.startPTS=C,x.maxStartPTS=T,x.endPTS=R,x.startDTS=S,x.endDTS=A,x.duration=R-C;var O=x.sn;if(!g||O<g.startSN||O>g.endSN)return 0;var k,D,F;for(k=O-g.startSN,D=g.fragments,D[k]=x,F=k;F>0;F--)f(D,F,F-1);for(F=k;F<D.length-1;F++)f(D,F,F+1);return g.PTSKnown=!0,P}t.updateFragPTSDTS=d;function h(g,x){x.initSegment&&g.initSegment&&(x.initSegment=g.initSegment);var C=0,R;if(E(g,x,function(T,w){C=T.cc-w.cc,a.isFinite(T.startPTS)&&(w.start=w.startPTS=T.startPTS,w.endPTS=T.endPTS,w.duration=T.duration,w.backtracked=T.backtracked,w.dropped=T.dropped,R=w),x.PTSKnown=!0}),!!x.PTSKnown){if(C){l.logger.log("discontinuity sliding from playlist, take drift into account");for(var S=x.fragments,A=0;A<S.length;A++)S[A].cc+=C}R?d(x,R,R.startPTS,R.endPTS,R.startDTS,R.endDTS):p(g,x),x.PTSKnown=g.PTSKnown}}t.mergeDetails=h;function y(g,x,C){C===void 0&&(C=0);var R=-1;E(g,x,function(T,w,P){w.start=T.start,R=P});var S=x.fragments;if(R<0){S.forEach(function(T){T.start+=C});return}for(var A=R+1;A<S.length;A++)S[A].start=S[A-1].start+S[A-1].duration}t.mergeSubtitlePlaylists=y;function E(g,x,C){if(!(!g||!x))for(var R=Math.max(g.startSN,x.startSN)-x.startSN,S=Math.min(g.endSN,x.endSN)-x.startSN,A=x.startSN-g.startSN,T=R;T<=S;T++){var w=g.fragments[A+T],P=x.fragments[T];if(!w||!P)break;C(w,P,T)}}t.mapFragmentIntersection=E;function p(g,x){var C=x.startSN-g.startSN,R=g.fragments,S=x.fragments;if(!(C<0||C>R.length))for(var A=0;A<S.length;A++)S[A].start+=R[C].start}t.adjustSliding=p;function _(g,x,C){var R=1e3*(x.averagetargetduration?x.averagetargetduration:x.targetduration),S=R/2;return g&&x.endSN===g.endSN&&(R=S),C&&(R=Math.max(S,R-(window.performance.now()-C))),Math.round(R)}t.computeReloadInterval=_}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/stream-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var O=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(k,D){k.__proto__=D}||function(k,D){for(var F in D)D.hasOwnProperty(F)&&(k[F]=D[F])};return function(k,D){O(k,D);function F(){this.constructor=k}k.prototype=D===null?Object.create(D):(F.prototype=D.prototype,new F)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/utils/binary-search.js"),f=n("./src/utils/buffer-helper.js"),d=n("./src/demux/demuxer.js"),h=n("./src/events.js"),y=n("./src/controller/fragment-tracker.js"),E=n("./src/loader/fragment.js"),p=n("./src/loader/playlist-loader.js"),_=n("./src/controller/level-helper.js"),g=n("./src/utils/time-ranges.js"),x=n("./src/errors.js"),C=n("./src/utils/logger.js"),R=n("./src/utils/discontinuities.js"),S=n("./src/controller/fragment-finders.js"),A=n("./src/controller/gap-controller.js"),T=n("./src/controller/base-stream-controller.js"),w=100,P=function(O){l(k,O);function k(D,F){var G=O.call(this,D,h.default.MEDIA_ATTACHED,h.default.MEDIA_DETACHING,h.default.MANIFEST_LOADING,h.default.MANIFEST_PARSED,h.default.LEVEL_LOADED,h.default.KEY_LOADED,h.default.FRAG_LOADED,h.default.FRAG_LOAD_EMERGENCY_ABORTED,h.default.FRAG_PARSING_INIT_SEGMENT,h.default.FRAG_PARSING_DATA,h.default.FRAG_PARSED,h.default.ERROR,h.default.AUDIO_TRACK_SWITCHING,h.default.AUDIO_TRACK_SWITCHED,h.default.BUFFER_CREATED,h.default.BUFFER_APPENDED,h.default.BUFFER_FLUSHED)||this;return G.fragmentTracker=F,G.config=D.config,G.audioCodecSwap=!1,G._state=T.State.STOPPED,G.stallReported=!1,G.gapController=null,G}return k.prototype.startLoad=function(D){if(this.levels){var F=this.lastCurrentTime,G=this.hls;if(this.stopLoad(),this.setInterval(w),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var V=G.startLevel;V===-1&&(V=0,this.bitrateTest=!0),this.level=G.nextLoadLevel=V,this.loadedmetadata=!1}F>0&&D===-1&&(C.logger.log("override startPosition with lastCurrentTime @"+F.toFixed(3)),D=F),this.state=T.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=D,this.tick()}else this.forceStartLoad=!0,this.state=T.State.STOPPED},k.prototype.stopLoad=function(){this.forceStartLoad=!1,O.prototype.stopLoad.call(this)},k.prototype.doTick=function(){switch(this.state){case T.State.BUFFER_FLUSHING:this.fragLoadError=0;break;case T.State.IDLE:this._doTickIdle();break;case T.State.WAITING_LEVEL:var D=this.levels[this.level];D&&D.details&&(this.state=T.State.IDLE);break;case T.State.FRAG_LOADING_WAITING_RETRY:var F=window.performance.now(),G=this.retryDate;(!G||F>=G||this.media&&this.media.seeking)&&(C.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=T.State.IDLE);break;case T.State.ERROR:case T.State.STOPPED:case T.State.FRAG_LOADING:case T.State.PARSING:case T.State.PARSED:case T.State.ENDED:break}this._checkBuffer(),this._checkFragmentChanged()},k.prototype._doTickIdle=function(){var D=this.hls,F=D.config,G=this.media;if(!(this.levelLastLoaded===void 0||!G&&(this.startFragRequested||!F.startFragPrefetch))){var V;this.loadedmetadata?V=G.currentTime:V=this.nextLoadPosition;var W=D.nextLoadLevel,ee=this.levels[W];if(ee){var q=ee.bitrate,z;q?z=Math.max(8*F.maxBufferSize/q,F.maxBufferLength):z=F.maxBufferLength,z=Math.min(z,F.maxMaxBufferLength);var U=f.BufferHelper.bufferInfo(this.mediaBuffer?this.mediaBuffer:G,V,F.maxBufferHole),$=U.len;if(!($>=z)){C.logger.trace("buffer length of "+$.toFixed(3)+" is below max of "+z.toFixed(3)+". checking for more payload ..."),this.level=D.nextLoadLevel=W;var I=ee.details;if(!I||I.live&&this.levelLastLoaded!==W){this.state=T.State.WAITING_LEVEL;return}if(this._streamEnded(U,I)){var B={};this.altAudio&&(B.type="video"),this.hls.trigger(h.default.BUFFER_EOS,B),this.state=T.State.ENDED;return}this._fetchPayloadOrEos(V,U,I)}}}},k.prototype._fetchPayloadOrEos=function(D,F,G){var V=this.fragPrevious,W=this.level,ee=G.fragments,q=ee.length;if(q!==0){var z=ee[0].start,U=ee[q-1].start+ee[q-1].duration,$=F.end,I;if(G.initSegment&&!G.initSegment.data)I=G.initSegment;else if(G.live){var B=this.config.initialLiveManifestSize;if(q<B){C.logger.warn("Can not start playback of a level, reason: not enough fragments "+q+" < "+B);return}if(I=this._ensureFragmentAtLivePoint(G,$,z,U,V,ee,q),I===null)return}else $<z&&(I=ee[0]);I||(I=this._findFragment(z,V,q,ee,$,U,G)),I&&(I.encrypted?(C.logger.log("Loading key for "+I.sn+" of ["+G.startSN+" ,"+G.endSN+"],level "+W),this._loadKey(I)):(C.logger.log("Loading "+I.sn+" of ["+G.startSN+" ,"+G.endSN+"],level "+W+", currentTime:"+D.toFixed(3)+",bufferEnd:"+$.toFixed(3)),this._loadFragment(I)))}},k.prototype._ensureFragmentAtLivePoint=function(D,F,G,V,W,ee,q){var z=this.hls.config,U=this.media,$,I=z.liveMaxLatencyDuration!==void 0?z.liveMaxLatencyDuration:z.liveMaxLatencyDurationCount*D.targetduration;if(F<Math.max(G-z.maxFragLookUpTolerance,V-I)){var B=this.liveSyncPosition=this.computeLivePosition(G,D);C.logger.log("buffer end: "+F.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+B.toFixed(3)),F=B,U&&U.readyState&&U.duration>B&&(U.currentTime=B),this.nextLoadPosition=B}if(D.PTSKnown&&F>V&&U&&U.readyState)return null;if(this.startFragRequested&&!D.PTSKnown){if(W)if(D.hasProgramDateTime)C.logger.log("live playlist, switching playlist, load frag with same PDT: "+W.programDateTime),$=S.findFragmentByPDT(ee,W.endProgramDateTime,z.maxFragLookUpTolerance);else{var X=W.sn+1;if(X>=D.startSN&&X<=D.endSN){var Q=ee[X-D.startSN];W.cc===Q.cc&&($=Q,C.logger.log("live playlist, switching playlist, load frag with next SN: "+$.sn))}$||($=u.default.search(ee,function(J){return W.cc-J.cc}),$&&C.logger.log("live playlist, switching playlist, load frag with same CC: "+$.sn))}$||($=ee[Math.min(q-1,Math.round(q/2))],C.logger.log("live playlist, switching playlist, unknown, load middle frag : "+$.sn))}return $},k.prototype._findFragment=function(D,F,G,V,W,ee,q){var z=this.hls.config,U;if(W<ee){var $=W>ee-z.maxFragLookUpTolerance?0:z.maxFragLookUpTolerance;U=S.findFragmentByPTS(F,V,W,$)}else U=V[G-1];if(U){var I=U.sn-q.startSN,B=F&&U.level===F.level,X=V[I-1],Q=V[I+1];if(F&&U.sn===F.sn)if(B&&!U.backtracked)if(U.sn<q.endSN){var J=F.deltaPTS;J&&J>z.maxBufferHole&&F.dropped&&I?(U=X,C.logger.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this")):(U=Q,C.logger.log("SN just loaded, load next one: "+U.sn,U))}else U=null;else U.backtracked&&(Q&&Q.backtracked?(C.logger.warn("Already backtracked from fragment "+Q.sn+", will not backtrack to fragment "+U.sn+". Loading fragment "+Q.sn),U=Q):(C.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),U.dropped=0,X?(U=X,U.backtracked=!0):I&&(U=null)))}return U},k.prototype._loadKey=function(D){this.state=T.State.KEY_LOADING,this.hls.trigger(h.default.KEY_LOADING,{frag:D})},k.prototype._loadFragment=function(D){var F=this.fragmentTracker.getState(D);this.fragCurrent=D,this.startFragRequested=!0,a.isFinite(D.sn)&&!D.bitrateTest&&(this.nextLoadPosition=D.start+D.duration),D.backtracked||F===y.FragmentState.NOT_LOADED||F===y.FragmentState.PARTIAL?(D.autoLevel=this.hls.autoLevelEnabled,D.bitrateTest=this.bitrateTest,this.hls.trigger(h.default.FRAG_LOADING,{frag:D}),this.demuxer||(this.demuxer=new d.default(this.hls,"main")),this.state=T.State.FRAG_LOADING):F===y.FragmentState.APPENDING&&this._reduceMaxBufferLength(D.duration)&&this.fragmentTracker.removeFragment(D)},Object.defineProperty(k.prototype,"state",{get:function(){return this._state},set:function(D){if(this.state!==D){var F=this.state;this._state=D,C.logger.log("main stream:"+F+"->"+D),this.hls.trigger(h.default.STREAM_STATE_TRANSITION,{previousState:F,nextState:D})}},enumerable:!0,configurable:!0}),k.prototype.getBufferedFrag=function(D){return this.fragmentTracker.getBufferedFrag(D,p.default.LevelType.MAIN)},Object.defineProperty(k.prototype,"currentLevel",{get:function(){var D=this.media;if(D){var F=this.getBufferedFrag(D.currentTime);if(F)return F.level}return-1},enumerable:!0,configurable:!0}),Object.defineProperty(k.prototype,"nextBufferedFrag",{get:function(){var D=this.media;return D?this.followingBufferedFrag(this.getBufferedFrag(D.currentTime)):null},enumerable:!0,configurable:!0}),k.prototype.followingBufferedFrag=function(D){return D?this.getBufferedFrag(D.endPTS+.5):null},Object.defineProperty(k.prototype,"nextLevel",{get:function(){var D=this.nextBufferedFrag;return D?D.level:-1},enumerable:!0,configurable:!0}),k.prototype._checkFragmentChanged=function(){var D,F,G=this.media;if(G&&G.readyState&&G.seeking===!1&&(F=G.currentTime,F>this.lastCurrentTime&&(this.lastCurrentTime=F),f.BufferHelper.isBuffered(G,F)?D=this.getBufferedFrag(F):f.BufferHelper.isBuffered(G,F+.1)&&(D=this.getBufferedFrag(F+.1)),D)){var V=D;if(V!==this.fragPlaying){this.hls.trigger(h.default.FRAG_CHANGED,{frag:V});var W=V.level;(!this.fragPlaying||this.fragPlaying.level!==W)&&this.hls.trigger(h.default.LEVEL_SWITCHED,{level:W}),this.fragPlaying=V}}},k.prototype.immediateLevelSwitch=function(){if(C.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var D=this.media,F=void 0;D?(F=D.paused,D.pause()):F=!0,this.previouslyPaused=F}var G=this.fragCurrent;G&&G.loader&&G.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,a.POSITIVE_INFINITY)},k.prototype.immediateLevelSwitchEnd=function(){var D=this.media;D&&D.buffered.length&&(this.immediateSwitch=!1,f.BufferHelper.isBuffered(D,D.currentTime)&&(D.currentTime-=1e-4),this.previouslyPaused||D.play())},k.prototype.nextLevelSwitch=function(){var D=this.media;if(D&&D.readyState){var F=void 0,G=void 0,V=void 0;if(G=this.getBufferedFrag(D.currentTime),G&&G.startPTS>1&&this.flushMainBuffer(0,G.startPTS-1),D.paused)F=0;else{var W=this.hls.nextLoadLevel,ee=this.levels[W],q=this.fragLastKbps;q&&this.fragCurrent?F=this.fragCurrent.duration*ee.bitrate/(1e3*q)+1:F=0}if(V=this.getBufferedFrag(D.currentTime+F),V&&(V=this.followingBufferedFrag(V),V)){var z=this.fragCurrent;z&&z.loader&&z.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(V.maxStartPTS,a.POSITIVE_INFINITY)}}},k.prototype.flushMainBuffer=function(D,F){this.state=T.State.BUFFER_FLUSHING;var G={startOffset:D,endOffset:F};this.altAudio&&(G.type="video"),this.hls.trigger(h.default.BUFFER_FLUSHING,G)},k.prototype.onMediaAttached=function(D){var F=this.media=this.mediaBuffer=D.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),F.addEventListener("seeking",this.onvseeking),F.addEventListener("seeked",this.onvseeked),F.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.hls.startLoad(G.startPosition),this.gapController=new A.default(G,F,this.fragmentTracker,this.hls)},k.prototype.onMediaDetaching=function(){var D=this.media;D&&D.ended&&(C.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var F=this.levels;F&&F.forEach(function(G){G.details&&G.details.fragments.forEach(function(V){V.backtracked=void 0})}),D&&(D.removeEventListener("seeking",this.onvseeking),D.removeEventListener("seeked",this.onvseeked),D.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},k.prototype.onMediaSeeked=function(){var D=this.media,F=D?D.currentTime:void 0;a.isFinite(F)&&C.logger.log("media seeked to "+F.toFixed(3)),this.tick()},k.prototype.onManifestLoading=function(){C.logger.log("trigger BUFFER_RESET"),this.hls.trigger(h.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},k.prototype.onManifestParsed=function(D){var F=!1,G=!1,V;D.levels.forEach(function(ee){V=ee.audioCodec,V&&(V.indexOf("mp4a.40.2")!==-1&&(F=!0),V.indexOf("mp4a.40.5")!==-1&&(G=!0))}),this.audioCodecSwitch=F&&G,this.audioCodecSwitch&&C.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=D.levels,this.startFragRequested=!1;var W=this.config;(W.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(W.startPosition)},k.prototype.onLevelLoaded=function(D){var F=D.details,G=D.level,V=this.levels[this.levelLastLoaded],W=this.levels[G],ee=F.totalduration,q=0;if(C.logger.log("level "+G+" loaded ["+F.startSN+","+F.endSN+"],duration:"+ee),F.live){var z=W.details;z&&F.fragments.length>0?(_.mergeDetails(z,F),q=F.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(q,z),F.PTSKnown&&a.isFinite(q)?C.logger.log("live playlist sliding:"+q.toFixed(3)):(C.logger.log("live playlist - outdated PTS, unknown sliding"),R.alignStream(this.fragPrevious,V,F))):(C.logger.log("live playlist - first load, unknown sliding"),F.PTSKnown=!1,R.alignStream(this.fragPrevious,V,F))}else F.PTSKnown=!1;if(W.details=F,this.levelLastLoaded=G,this.hls.trigger(h.default.LEVEL_UPDATED,{details:F,level:G}),this.startFragRequested===!1){if(this.startPosition===-1||this.lastCurrentTime===-1){var U=F.startTimeOffset;a.isFinite(U)?(U<0&&(C.logger.log("negative start time offset "+U+", count from end of last fragment"),U=q+ee+U),C.logger.log("start time offset found in playlist, adjust startPosition to "+U),this.startPosition=U):F.live?(this.startPosition=this.computeLivePosition(q,F),C.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===T.State.WAITING_LEVEL&&(this.state=T.State.IDLE),this.tick()},k.prototype.onKeyLoaded=function(){this.state===T.State.KEY_LOADING&&(this.state=T.State.IDLE,this.tick())},k.prototype.onFragLoaded=function(D){var F=this,G=F.fragCurrent,V=F.hls,W=F.levels,ee=F.media,q=D.frag;if(this.state===T.State.FRAG_LOADING&&G&&q.type==="main"&&q.level===G.level&&q.sn===G.sn){var z=D.stats,U=W[G.level],$=U.details;if(this.bitrateTest=!1,this.stats=z,C.logger.log("Loaded "+G.sn+" of ["+$.startSN+" ,"+$.endSN+"],level "+G.level),q.bitrateTest&&V.nextLoadLevel)this.state=T.State.IDLE,this.startFragRequested=!1,z.tparsed=z.tbuffered=window.performance.now(),V.trigger(h.default.FRAG_BUFFERED,{stats:z,frag:G,id:"main"}),this.tick();else if(q.sn==="initSegment")this.state=T.State.IDLE,z.tparsed=z.tbuffered=window.performance.now(),$.initSegment.data=D.payload,V.trigger(h.default.FRAG_BUFFERED,{stats:z,frag:G,id:"main"}),this.tick();else{C.logger.log("Parsing "+G.sn+" of ["+$.startSN+" ,"+$.endSN+"],level "+G.level+", cc "+G.cc),this.state=T.State.PARSING,this.pendingBuffering=!0,this.appended=!1,q.bitrateTest&&(q.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:q}));var I=!(ee&&ee.seeking)&&($.PTSKnown||!$.live),B=$.initSegment?$.initSegment.data:[],X=this._getAudioCodec(U),Q=this.demuxer=this.demuxer||new d.default(this.hls,"main");Q.push(D.payload,B,X,U.videoCodec,G,$.totalduration,I)}}this.fragLoadError=0},k.prototype.onFragParsingInitSegment=function(D){var F=this.fragCurrent,G=D.frag;if(F&&D.id==="main"&&G.sn===F.sn&&G.level===F.level&&this.state===T.State.PARSING){var V=D.tracks,W=void 0,ee=void 0;if(V.audio&&this.altAudio&&delete V.audio,ee=V.audio,ee){var q=this.levels[this.level].audioCodec,z=navigator.userAgent.toLowerCase();q&&this.audioCodecSwap&&(C.logger.log("swapping playlist audio codec"),q.indexOf("mp4a.40.5")!==-1?q="mp4a.40.2":q="mp4a.40.5"),this.audioCodecSwitch&&ee.metadata.channelCount!==1&&z.indexOf("firefox")===-1&&(q="mp4a.40.5"),z.indexOf("android")!==-1&&ee.container!=="audio/mpeg"&&(q="mp4a.40.2",C.logger.log("Android: force audio codec to "+q)),ee.levelCodec=q,ee.id=D.id}ee=V.video,ee&&(ee.levelCodec=this.levels[this.level].videoCodec,ee.id=D.id),this.hls.trigger(h.default.BUFFER_CODECS,V);for(W in V){ee=V[W],C.logger.log("main track:"+W+",container:"+ee.container+",codecs[level/parsed]=["+ee.levelCodec+"/"+ee.codec+"]");var U=ee.initSegment;U&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(h.default.BUFFER_APPENDING,{type:W,data:U,parent:"main",content:"initSegment"}))}this.tick()}},k.prototype.onFragParsingData=function(D){var F=this,G=this.fragCurrent,V=D.frag;if(G&&D.id==="main"&&V.sn===G.sn&&V.level===G.level&&!(D.type==="audio"&&this.altAudio)&&this.state===T.State.PARSING){var W=this.levels[this.level],ee=G;if(a.isFinite(D.endPTS)||(D.endPTS=D.startPTS+G.duration,D.endDTS=D.startDTS+G.duration),D.hasAudio===!0&&ee.addElementaryStream(E.default.ElementaryStreamTypes.AUDIO),D.hasVideo===!0&&ee.addElementaryStream(E.default.ElementaryStreamTypes.VIDEO),C.logger.log("Parsed "+D.type+",PTS:["+D.startPTS.toFixed(3)+","+D.endPTS.toFixed(3)+"],DTS:["+D.startDTS.toFixed(3)+"/"+D.endDTS.toFixed(3)+"],nb:"+D.nb+",dropped:"+(D.dropped||0)),D.type==="video")if(ee.dropped=D.dropped,ee.dropped)if(ee.backtracked)C.logger.warn("Already backtracked on this fragment, appending with the gap",ee.sn);else{var q=W.details;if(q&&ee.sn===q.startSN)C.logger.warn("missing video frame(s) on first frag, appending with gap",ee.sn);else{C.logger.warn("missing video frame(s), backtracking fragment",ee.sn),this.fragmentTracker.removeFragment(ee),ee.backtracked=!0,this.nextLoadPosition=D.startPTS,this.state=T.State.IDLE,this.fragPrevious=ee,this.tick();return}}else ee.backtracked=!1;var z=_.updateFragPTSDTS(W.details,ee,D.startPTS,D.endPTS,D.startDTS,D.endDTS),U=this.hls;U.trigger(h.default.LEVEL_PTS_UPDATED,{details:W.details,level:this.level,drift:z,type:D.type,start:D.startPTS,end:D.endPTS}),[D.data1,D.data2].forEach(function($){$&&$.length&&F.state===T.State.PARSING&&(F.appended=!0,F.pendingBuffering=!0,U.trigger(h.default.BUFFER_APPENDING,{type:D.type,data:$,parent:"main",content:"data"}))}),this.tick()}},k.prototype.onFragParsed=function(D){var F=this.fragCurrent,G=D.frag;F&&D.id==="main"&&G.sn===F.sn&&G.level===F.level&&this.state===T.State.PARSING&&(this.stats.tparsed=window.performance.now(),this.state=T.State.PARSED,this._checkAppendedParsed())},k.prototype.onAudioTrackSwitching=function(D){var F=!!D.url,G=D.id;if(!F){if(this.mediaBuffer!==this.media){C.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var V=this.fragCurrent;V.loader&&(C.logger.log("switching to main audio track, cancel main fragment load"),V.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=T.State.IDLE}var W=this.hls;W.trigger(h.default.BUFFER_FLUSHING,{startOffset:0,endOffset:a.POSITIVE_INFINITY,type:"audio"}),W.trigger(h.default.AUDIO_TRACK_SWITCHED,{id:G}),this.altAudio=!1}},k.prototype.onAudioTrackSwitched=function(D){var F=D.id,G=!!this.hls.audioTracks[F].url;if(G){var V=this.videoBuffer;V&&this.mediaBuffer!==V&&(C.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=V)}this.altAudio=G,this.tick()},k.prototype.onBufferCreated=function(D){var F=D.tracks,G,V,W=!1;for(var ee in F){var q=F[ee];q.id==="main"?(V=ee,G=q,ee==="video"&&(this.videoBuffer=F[ee].buffer)):W=!0}W&&G?(C.logger.log("alternate track found, use "+V+".buffered to schedule main fragment loading"),this.mediaBuffer=G.buffer):this.mediaBuffer=this.media},k.prototype.onBufferAppended=function(D){if(D.parent==="main"){var F=this.state;(F===T.State.PARSING||F===T.State.PARSED)&&(this.pendingBuffering=D.pending>0,this._checkAppendedParsed())}},k.prototype._checkAppendedParsed=function(){if(this.state===T.State.PARSED&&(!this.appended||!this.pendingBuffering)){var D=this.fragCurrent;if(D){var F=this.mediaBuffer?this.mediaBuffer:this.media;C.logger.log("main buffered : "+g.default.toString(F.buffered)),this.fragPrevious=D;var G=this.stats;G.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*G.total/(G.tbuffered-G.tfirst)),this.hls.trigger(h.default.FRAG_BUFFERED,{stats:G,frag:D,id:"main"}),this.state=T.State.IDLE}this.tick()}},k.prototype.onError=function(D){var F=D.frag||this.fragCurrent;if(!(F&&F.type!=="main")){var G=!!this.media&&f.BufferHelper.isBuffered(this.media,this.media.currentTime)&&f.BufferHelper.isBuffered(this.media,this.media.currentTime+.5);switch(D.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.KEY_LOAD_ERROR:case x.ErrorDetails.KEY_LOAD_TIMEOUT:if(!D.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var V=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);C.logger.warn("mediaController: frag loading failed, retry in "+V+" ms"),this.retryDate=window.performance.now()+V,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=T.State.FRAG_LOADING_WAITING_RETRY}else C.logger.error("mediaController: "+D.details+" reaches max retry, redispatch as fatal ..."),D.fatal=!0,this.state=T.State.ERROR;break;case x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==T.State.ERROR&&(D.fatal?(this.state=T.State.ERROR,C.logger.warn("streamController: "+D.details+",switch to "+this.state+" state ...")):!D.levelRetry&&this.state===T.State.WAITING_LEVEL&&(this.state=T.State.IDLE));break;case x.ErrorDetails.BUFFER_FULL_ERROR:D.parent==="main"&&(this.state===T.State.PARSING||this.state===T.State.PARSED)&&(G?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=T.State.IDLE):(C.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,a.POSITIVE_INFINITY)));break}}},k.prototype._reduceMaxBufferLength=function(D){var F=this.config;return F.maxMaxBufferLength>=D?(F.maxMaxBufferLength/=2,C.logger.warn("main:reduce max buffer length to "+F.maxMaxBufferLength+"s"),!0):!1},k.prototype._checkBuffer=function(){var D=this.media;if(!(!D||D.readyState===0)){var F=this.mediaBuffer?this.mediaBuffer:D,G=F.buffered;!this.loadedmetadata&&G.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,G)}},k.prototype.onFragLoadEmergencyAborted=function(){this.state=T.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},k.prototype.onBufferFlushed=function(){var D=this.mediaBuffer?this.mediaBuffer:this.media;D&&this.fragmentTracker.detectEvictedFragments(E.default.ElementaryStreamTypes.VIDEO,D.buffered),this.state=T.State.IDLE,this.fragPrevious=null},k.prototype.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},k.prototype.computeLivePosition=function(D,F){var G=this.config.liveSyncDuration!==void 0?this.config.liveSyncDuration:this.config.liveSyncDurationCount*F.targetduration;return D+Math.max(0,F.totalduration-G)},k.prototype._seekToStartPos=function(){var D=this.media,F=D.currentTime,G=D.seeking?F:this.startPosition;F!==G&&(C.logger.log("target start position not buffered, seek to buffered.start(0) "+G+" from current time "+F+" "),D.currentTime=G)},k.prototype._getAudioCodec=function(D){var F=this.config.defaultAudioCodec||D.audioCodec;return this.audioCodecSwap&&(C.logger.log("swapping playlist audio codec"),F&&(F.indexOf("mp4a.40.5")!==-1?F="mp4a.40.2":F="mp4a.40.5")),F},Object.defineProperty(k.prototype,"liveSyncPosition",{get:function(){return this._liveSyncPosition},set:function(D){this._liveSyncPosition=D},enumerable:!0,configurable:!0}),k}(T.default);t.default=P}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/subtitle-stream-controller.js":function(r,t,n){var a=this&&this.__extends||function(){var C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,S){R.__proto__=S}||function(R,S){for(var A in S)S.hasOwnProperty(A)&&(R[A]=S[A])};return function(R,S){C(R,S);function A(){this.constructor=R}R.prototype=S===null?Object.create(S):(A.prototype=S.prototype,new A)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/utils/logger.js"),f=n("./src/crypt/decrypter.js"),d=n("./src/utils/buffer-helper.js"),h=n("./src/controller/fragment-finders.js"),y=n("./src/controller/fragment-tracker.js"),E=n("./src/controller/base-stream-controller.js"),p=n("./src/controller/level-helper.js"),_=window.performance,g=500,x=function(C){a(R,C);function R(S,A){var T=C.call(this,S,l.default.MEDIA_ATTACHED,l.default.MEDIA_DETACHING,l.default.ERROR,l.default.KEY_LOADED,l.default.FRAG_LOADED,l.default.SUBTITLE_TRACKS_UPDATED,l.default.SUBTITLE_TRACK_SWITCH,l.default.SUBTITLE_TRACK_LOADED,l.default.SUBTITLE_FRAG_PROCESSED,l.default.LEVEL_UPDATED)||this;return T.fragmentTracker=A,T.config=S.config,T.state=E.State.STOPPED,T.tracks=[],T.tracksBuffered=[],T.currentTrackId=-1,T.decrypter=new f.default(S,S.config),T.lastAVStart=0,T._onMediaSeeking=T.onMediaSeeking.bind(T),T}return R.prototype.onSubtitleFragProcessed=function(S){var A=S.frag,T=S.success;if(this.fragPrevious=A,this.state=E.State.IDLE,!!T){var w=this.tracksBuffered[this.currentTrackId];if(w){for(var P,O=A.start,k=0;k<w.length;k++)if(O>=w[k].start&&O<=w[k].end){P=w[k];break}var D=A.start+A.duration;P?P.end=D:(P={start:O,end:D},w.push(P))}}},R.prototype.onMediaAttached=function(S){var A=S.media;this.media=A,A.addEventListener("seeking",this._onMediaSeeking),this.state=E.State.IDLE},R.prototype.onMediaDetaching=function(){this.media.removeEventListener("seeking",this._onMediaSeeking),this.media=null,this.state=E.State.STOPPED},R.prototype.onError=function(S){var A=S.frag;!A||A.type!=="subtitle"||(this.state=E.State.IDLE)},R.prototype.onSubtitleTracksUpdated=function(S){var A=this;u.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=S.subtitleTracks,this.tracks.forEach(function(T){A.tracksBuffered[T.id]=[]})},R.prototype.onSubtitleTrackSwitch=function(S){if(this.currentTrackId=S.id,!this.tracks||this.currentTrackId===-1){this.clearInterval();return}var A=this.tracks[this.currentTrackId];A&&A.details&&this.setInterval(g)},R.prototype.onSubtitleTrackLoaded=function(S){var A=S.id,T=S.details,w=this,P=w.currentTrackId,O=w.tracks,k=O[P];A>=O.length||A!==P||!k||(T.live&&p.mergeSubtitlePlaylists(k.details,T,this.lastAVStart),k.details=T,this.setInterval(g))},R.prototype.onKeyLoaded=function(){this.state===E.State.KEY_LOADING&&(this.state=E.State.IDLE)},R.prototype.onFragLoaded=function(S){var A=this.fragCurrent,T=S.frag.decryptdata,w=S.frag,P=this.hls;if(this.state===E.State.FRAG_LOADING&&A&&S.frag.type==="subtitle"&&A.sn===S.frag.sn&&S.payload.byteLength>0&&T&&T.key&&T.method==="AES-128"){var O=_.now();this.decrypter.decrypt(S.payload,T.key.buffer,T.iv.buffer,function(k){var D=_.now();P.trigger(l.default.FRAG_DECRYPTED,{frag:w,payload:k,stats:{tstart:O,tdecrypt:D}})})}},R.prototype.onLevelUpdated=function(S){var A=S.details,T=A.fragments;this.lastAVStart=T.length?T[0].start:0},R.prototype.doTick=function(){if(!this.media){this.state=E.State.IDLE;return}switch(this.state){case E.State.IDLE:{var S=this,A=S.config,T=S.currentTrackId,w=S.fragmentTracker,P=S.media,O=S.tracks;if(!O||!O[T]||!O[T].details)break;var k=A.maxBufferHole,D=A.maxFragLookUpTolerance,F=Math.min(A.maxBufferLength,A.maxMaxBufferLength),G=d.BufferHelper.bufferedInfo(this._getBuffered(),P.currentTime,k),V=G.end,W=G.len,ee=O[T].details,q=ee.fragments,z=q.length,U=q[z-1].start+q[z-1].duration;if(W>F)return;var $=void 0,I=this.fragPrevious;V<U?(I&&ee.hasProgramDateTime&&($=h.findFragmentByPDT(q,I.endProgramDateTime,D)),$||($=h.findFragmentByPTS(I,q,V,D))):$=q[z-1],$&&$.encrypted?(u.logger.log("Loading key for "+$.sn),this.state=E.State.KEY_LOADING,this.hls.trigger(l.default.KEY_LOADING,{frag:$})):$&&w.getState($)===y.FragmentState.NOT_LOADED&&(this.fragCurrent=$,this.state=E.State.FRAG_LOADING,this.hls.trigger(l.default.FRAG_LOADING,{frag:$}))}}},R.prototype.stopLoad=function(){this.lastAVStart=0,C.prototype.stopLoad.call(this)},R.prototype._getBuffered=function(){return this.tracksBuffered[this.currentTrackId]||[]},R.prototype.onMediaSeeking=function(){this.fragPrevious=null},R}(E.default);t.SubtitleStreamController=x},"./src/controller/subtitle-track-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,g){_.__proto__=g}||function(_,g){for(var x in g)g.hasOwnProperty(x)&&(_[x]=g[x])};return function(_,g){p(_,g);function x(){this.constructor=_}_.prototype=g===null?Object.create(g):(x.prototype=g.prototype,new x)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/utils/logger.js"),h=n("./src/controller/level-helper.js"),y=function(p){l(_,p);function _(g){var x=p.call(this,g,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.MANIFEST_LOADED,u.default.SUBTITLE_TRACK_LOADED)||this;return x.tracks=[],x.trackId=-1,x.media=null,x.stopped=!0,x.subtitleDisplay=!0,x}return _.prototype.destroy=function(){f.default.prototype.destroy.call(this)},_.prototype.onMediaAttached=function(g){var x=this;this.media=g.media,this.media&&(this.queuedDefaultTrack&&(this.subtitleTrack=this.queuedDefaultTrack,delete this.queuedDefaultTrack),this.trackChangeListener=this._onTextTracksChanged.bind(this),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.subtitlePollingInterval=setInterval(function(){x.trackChangeListener()},500):this.media.textTracks.addEventListener("change",this.trackChangeListener))},_.prototype.onMediaDetaching=function(){this.media&&(this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),this.media=null)},_.prototype.onManifestLoaded=function(g){var x=this,C=g.subtitles||[];this.tracks=C,this.hls.trigger(u.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:C}),C.forEach(function(R){R.default&&(x.media?x.subtitleTrack=R.id:x.queuedDefaultTrack=R.id)})},_.prototype.onSubtitleTrackLoaded=function(g){var x=this,C=g.id,R=g.details,S=this,A=S.trackId,T=S.tracks,w=T[A];if(C>=T.length||C!==A||!w||this.stopped){this._clearReloadTimer();return}if(d.logger.log("subtitle track "+C+" loaded"),R.live){var P=h.computeReloadInterval(w.details,R,g.stats.trequest);d.logger.log("Reloading live subtitle playlist in "+P+"ms"),this.timer=setTimeout(function(){x._loadCurrentTrack()},P)}else this._clearReloadTimer()},_.prototype.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},_.prototype.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},Object.defineProperty(_.prototype,"subtitleTracks",{get:function(){return this.tracks},enumerable:!0,configurable:!0}),Object.defineProperty(_.prototype,"subtitleTrack",{get:function(){return this.trackId},set:function(g){this.trackId!==g&&(this._toggleTrackModes(g),this._setSubtitleTrackInternal(g))},enumerable:!0,configurable:!0}),_.prototype._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},_.prototype._loadCurrentTrack=function(){var g=this,x=g.trackId,C=g.tracks,R=g.hls,S=C[x];x<0||!S||S.details&&!S.details.live||(d.logger.log("Loading subtitle track "+x),R.trigger(u.default.SUBTITLE_TRACK_LOADING,{url:S.url,id:x}))},_.prototype._toggleTrackModes=function(g){var x=this,C=x.media,R=x.subtitleDisplay,S=x.trackId;if(C){var A=E(C.textTracks);if(g===-1)[].slice.call(A).forEach(function(P){P.mode="disabled"});else{var T=A[S];T&&(T.mode="disabled")}var w=A[g];w&&(w.mode=R?"showing":"hidden")}},_.prototype._setSubtitleTrackInternal=function(g){var x=this,C=x.hls,R=x.tracks;!a.isFinite(g)||g<-1||g>=R.length||(this.trackId=g,d.logger.log("Switching to subtitle track "+g),C.trigger(u.default.SUBTITLE_TRACK_SWITCH,{id:g}),this._loadCurrentTrack())},_.prototype._onTextTracksChanged=function(){if(this.media){for(var g=-1,x=E(this.media.textTracks),C=0;C<x.length;C++)if(x[C].mode==="hidden")g=C;else if(x[C].mode==="showing"){g=C;break}this.subtitleTrack=g}},_}(f.default);function E(p){for(var _=[],g=0;g<p.length;g++){var x=p[g];x.kind==="subtitles"&&x.label&&_.push(p[g])}return _}t.default=y}).call(this,n("./src/polyfills/number.js").Number)},"./src/controller/timeline-controller.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,S){R.__proto__=S}||function(R,S){for(var A in S)S.hasOwnProperty(A)&&(R[A]=S[A])};return function(R,S){C(R,S);function A(){this.constructor=R}R.prototype=S===null?Object.create(S):(A.prototype=S.prototype,new A)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/utils/cea-608-parser.js"),h=n("./src/utils/output-filter.js"),y=n("./src/utils/webvtt-parser.js"),E=n("./src/utils/logger.js"),p=n("./src/utils/texttrack-utils.js");function _(C,R){return C&&C.label===R.name&&!(C.textTrack1||C.textTrack2)}function g(C,R,S,A){return Math.min(R,A)-Math.max(C,S)}var x=function(C){l(R,C);function R(S){var A=C.call(this,S,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.FRAG_PARSING_USERDATA,u.default.FRAG_DECRYPTED,u.default.MANIFEST_LOADING,u.default.MANIFEST_LOADED,u.default.FRAG_LOADED,u.default.LEVEL_SWITCHING,u.default.INIT_PTS_FOUND)||this;if(A.hls=S,A.config=S.config,A.enabled=!0,A.Cues=S.config.cueHandler,A.textTracks=[],A.tracks=[],A.unparsedVttFrags=[],A.initPTS=[],A.cueRanges=[],A.captionsTracks={},A.captionsProperties={textTrack1:{label:A.config.captionsTextTrack1Label,languageCode:A.config.captionsTextTrack1LanguageCode},textTrack2:{label:A.config.captionsTextTrack2Label,languageCode:A.config.captionsTextTrack2LanguageCode}},A.config.enableCEA708Captions){var T=new h.default(A,"textTrack1"),w=new h.default(A,"textTrack2");A.cea608Parser=new d.default(0,T,w)}return A}return R.prototype.addCues=function(S,A,T,w){for(var P=this.cueRanges,O=!1,k=P.length;k--;){var D=P[k],F=g(D[0],D[1],A,T);if(F>=0&&(D[0]=Math.min(D[0],A),D[1]=Math.max(D[1],T),O=!0,F/(T-A)>.5))return}O||P.push([A,T]),this.Cues.newCue(this.captionsTracks[S],A,T,w)},R.prototype.onInitPtsFound=function(S){var A=this;if(S.id==="main"&&(this.initPTS[S.frag.cc]=S.initPTS),this.unparsedVttFrags.length){var T=this.unparsedVttFrags;this.unparsedVttFrags=[],T.forEach(function(w){A.onFragLoaded(w)})}},R.prototype.getExistingTrack=function(S){var A=this.media;if(A)for(var T=0;T<A.textTracks.length;T++){var w=A.textTracks[T];if(w[S])return w}return null},R.prototype.createCaptionsTrack=function(S){var A=this.captionsProperties[S],T=A.label,w=A.languageCode,P=this.captionsTracks;if(!P[S]){var O=this.getExistingTrack(S);if(O)P[S]=O,p.clearCurrentCues(P[S]),p.sendAddTrackEvent(P[S],this.media);else{var k=this.createTextTrack("captions",T,w);k&&(k[S]=!0,P[S]=k)}}},R.prototype.createTextTrack=function(S,A,T){var w=this.media;if(w)return w.addTextTrack(S,A,T)},R.prototype.destroy=function(){f.default.prototype.destroy.call(this)},R.prototype.onMediaAttaching=function(S){this.media=S.media,this._cleanTracks()},R.prototype.onMediaDetaching=function(){var S=this.captionsTracks;Object.keys(S).forEach(function(A){p.clearCurrentCues(S[A]),delete S[A]})},R.prototype.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks()},R.prototype._cleanTracks=function(){var S=this.media;if(S){var A=S.textTracks;if(A)for(var T=0;T<A.length;T++)p.clearCurrentCues(A[T])}},R.prototype.onManifestLoaded=function(S){var A=this;if(this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cueRanges=[],this.config.enableWebVTT){this.tracks=S.subtitles||[];var T=this.media?this.media.textTracks:[];this.tracks.forEach(function(w,P){var O;if(P<T.length){for(var k=null,D=0;D<T.length;D++)if(_(T[D],w)){k=T[D];break}k&&(O=k)}O||(O=A.createTextTrack("subtitles",w.name,w.lang)),w.default?O.mode=A.hls.subtitleDisplay?"showing":"hidden":O.mode="disabled",A.textTracks.push(O)})}},R.prototype.onLevelSwitching=function(){this.enabled=this.hls.currentLevel.closedCaptions!=="NONE"},R.prototype.onFragLoaded=function(S){var A=S.frag,T=S.payload;if(A.type==="main"){var w=A.sn;if(w!==this.lastSn+1){var P=this.cea608Parser;P&&P.reset()}this.lastSn=w}else if(A.type==="subtitle")if(T.byteLength){if(!a.isFinite(this.initPTS[A.cc])){this.unparsedVttFrags.push(S),this.initPTS.length&&this.hls.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:A});return}var O=A.decryptdata;(O==null||O.key==null||O.method!=="AES-128")&&this._parseVTTs(A,T)}else this.hls.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:A})},R.prototype._parseVTTs=function(S,A){var T=this.vttCCs;T[S.cc]||(T[S.cc]={start:S.start,prevCC:this.prevCC,new:!0},this.prevCC=S.cc);var w=this.textTracks,P=this.hls;y.default.parse(A,this.initPTS[S.cc],T,S.cc,function(O){var k=w[S.level];if(k.mode==="disabled"){P.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:S});return}O.forEach(function(D){if(!k.cues.getCueById(D.id))try{k.addCue(D)}catch{var F=new window.TextTrackCue(D.startTime,D.endTime,D.text);F.id=D.id,k.addCue(F)}}),P.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:S})},function(O){E.logger.log("Failed to parse VTT cue: "+O),P.trigger(u.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:S})})},R.prototype.onFragDecrypted=function(S){var A=S.payload,T=S.frag;if(T.type==="subtitle"){if(!a.isFinite(this.initPTS[T.cc])){this.unparsedVttFrags.push(S);return}this._parseVTTs(T,A)}},R.prototype.onFragParsingUserdata=function(S){if(this.enabled&&this.config.enableCEA708Captions)for(var A=0;A<S.samples.length;A++){var T=this.extractCea608Data(S.samples[A].bytes);this.cea608Parser.addData(S.samples[A].pts,T)}},R.prototype.extractCea608Data=function(S){for(var A=S[0]&31,T=2,w,P,O,k,D,F=[],G=0;G<A;G++)w=S[T++],P=127&S[T++],O=127&S[T++],k=(4&w)!==0,D=3&w,!(P===0&&O===0)&&k&&D===0&&(F.push(P),F.push(O));return F},R}(f.default);t.default=x}).call(this,n("./src/polyfills/number.js").Number)},"./src/crypt/aes-crypto.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(u,f){this.subtle=u,this.aesIV=f}return l.prototype.decrypt=function(u,f){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},f,u)},l}();t.default=a},"./src/crypt/aes-decryptor.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});function a(u){var f=u.byteLength,d=f&&new DataView(u).getUint8(f-1);return d?u.slice(0,f-d):u}t.removePadding=a;var l=function(){function u(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}return u.prototype.uint8ArrayToUint32Array_=function(f){for(var d=new DataView(f),h=new Uint32Array(4),y=0;y<4;y++)h[y]=d.getUint32(y*4);return h},u.prototype.initTable=function(){var f=this.sBox,d=this.invSBox,h=this.subMix,y=h[0],E=h[1],p=h[2],_=h[3],g=this.invSubMix,x=g[0],C=g[1],R=g[2],S=g[3],A=new Uint32Array(256),T=0,w=0,P=0;for(P=0;P<256;P++)P<128?A[P]=P<<1:A[P]=P<<1^283;for(P=0;P<256;P++){var O=w^w<<1^w<<2^w<<3^w<<4;O=O>>>8^O&255^99,f[T]=O,d[O]=T;var k=A[T],D=A[k],F=A[D],G=A[O]*257^O*16843008;y[T]=G<<24|G>>>8,E[T]=G<<16|G>>>16,p[T]=G<<8|G>>>24,_[T]=G,G=F*16843009^D*65537^k*257^T*16843008,x[O]=G<<24|G>>>8,C[O]=G<<16|G>>>16,R[O]=G<<8|G>>>24,S[O]=G,T?(T=k^A[A[A[F^k]]],w^=A[A[w]]):T=w=1}},u.prototype.expandKey=function(f){for(var d=this.uint8ArrayToUint32Array_(f),h=!0,y=0;y<d.length&&h;)h=d[y]===this.key[y],y++;if(!h){this.key=d;var E=this.keySize=d.length;if(E!==4&&E!==6&&E!==8)throw new Error("Invalid aes key size="+E);var p=this.ksRows=(E+6+1)*4,_,g,x=this.keySchedule=new Uint32Array(p),C=this.invKeySchedule=new Uint32Array(p),R=this.sBox,S=this.rcon,A=this.invSubMix,T=A[0],w=A[1],P=A[2],O=A[3],k,D;for(_=0;_<p;_++){if(_<E){k=x[_]=d[_];continue}D=k,_%E===0?(D=D<<8|D>>>24,D=R[D>>>24]<<24|R[D>>>16&255]<<16|R[D>>>8&255]<<8|R[D&255],D^=S[_/E|0]<<24):E>6&&_%E===4&&(D=R[D>>>24]<<24|R[D>>>16&255]<<16|R[D>>>8&255]<<8|R[D&255]),x[_]=k=(x[_-E]^D)>>>0}for(g=0;g<p;g++)_=p-g,g&3?D=x[_]:D=x[_-4],g<4||_<=4?C[g]=D:C[g]=T[R[D>>>24]]^w[R[D>>>16&255]]^P[R[D>>>8&255]]^O[R[D&255]],C[g]=C[g]>>>0}},u.prototype.networkToHostOrderSwap=function(f){return f<<24|(f&65280)<<8|(f&16711680)>>8|f>>>24},u.prototype.decrypt=function(f,d,h,y){for(var E=this.keySize+6,p=this.invKeySchedule,_=this.invSBox,g=this.invSubMix,x=g[0],C=g[1],R=g[2],S=g[3],A=this.uint8ArrayToUint32Array_(h),T=A[0],w=A[1],P=A[2],O=A[3],k=new Int32Array(f),D=new Int32Array(k.length),F,G,V,W,ee,q,z,U,$,I,B,X,Q,J,ne=this.networkToHostOrderSwap;d<k.length;){for($=ne(k[d]),I=ne(k[d+1]),B=ne(k[d+2]),X=ne(k[d+3]),ee=$^p[0],q=X^p[1],z=B^p[2],U=I^p[3],Q=4,J=1;J<E;J++)F=x[ee>>>24]^C[q>>16&255]^R[z>>8&255]^S[U&255]^p[Q],G=x[q>>>24]^C[z>>16&255]^R[U>>8&255]^S[ee&255]^p[Q+1],V=x[z>>>24]^C[U>>16&255]^R[ee>>8&255]^S[q&255]^p[Q+2],W=x[U>>>24]^C[ee>>16&255]^R[q>>8&255]^S[z&255]^p[Q+3],ee=F,q=G,z=V,U=W,Q=Q+4;F=_[ee>>>24]<<24^_[q>>16&255]<<16^_[z>>8&255]<<8^_[U&255]^p[Q],G=_[q>>>24]<<24^_[z>>16&255]<<16^_[U>>8&255]<<8^_[ee&255]^p[Q+1],V=_[z>>>24]<<24^_[U>>16&255]<<16^_[ee>>8&255]<<8^_[q&255]^p[Q+2],W=_[U>>>24]<<24^_[ee>>16&255]<<16^_[q>>8&255]<<8^_[z&255]^p[Q+3],Q=Q+3,D[d]=ne(F^T),D[d+1]=ne(W^w),D[d+2]=ne(V^P),D[d+3]=ne(G^O),T=$,w=I,P=B,O=X,d=d+4}return y?a(D.buffer):D.buffer},u.prototype.destroy=function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0},u}();t.default=l},"./src/crypt/decrypter.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/crypt/aes-crypto.js"),l=n("./src/crypt/fast-aes-key.js"),u=n("./src/crypt/aes-decryptor.js"),f=n("./src/errors.js"),d=n("./src/utils/logger.js"),h=n("./src/events.js"),y=n("./src/utils/get-self-scope.js"),E=y.getSelfScope(),p=function(){function _(g,x,C){var R=(C===void 0?{}:C).removePKCS7Padding,S=R===void 0?!0:R;if(this.logEnabled=!0,this.observer=g,this.config=x,this.removePKCS7Padding=S,S)try{var A=E.crypto;A&&(this.subtle=A.subtle||A.webkitSubtle)}catch{}this.disableWebCrypto=!this.subtle}return _.prototype.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},_.prototype.decrypt=function(g,x,C,R){var S=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(d.logger.log("JS AES decrypt"),this.logEnabled=!1);var A=this.decryptor;A||(this.decryptor=A=new u.default),A.expandKey(x),R(A.decrypt(g,0,C,this.removePKCS7Padding))}else{this.logEnabled&&(d.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var T=this.subtle;this.key!==x&&(this.key=x,this.fastAesKey=new l.default(T,x)),this.fastAesKey.expandKey().then(function(w){var P=new a.default(T,C);P.decrypt(g,w).catch(function(O){S.onWebCryptoError(O,g,x,C,R)}).then(function(O){R(O)})}).catch(function(w){S.onWebCryptoError(w,g,x,C,R)})}},_.prototype.onWebCryptoError=function(g,x,C,R,S){this.config.enableSoftwareAES?(d.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(x,C,R,S)):(d.logger.error("decrypting error : "+g.message),this.observer.trigger(h.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:g.message}))},_.prototype.destroy=function(){var g=this.decryptor;g&&(g.destroy(),this.decryptor=void 0)},_}();t.default=p},"./src/crypt/fast-aes-key.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(u,f){this.subtle=u,this.key=f}return l.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},l}();t.default=a},"./src/demux/aacdemuxer.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/demux/adts.js"),u=n("./src/utils/logger.js"),f=n("./src/demux/id3.js"),d=function(){function h(y,E,p){this.observer=y,this.config=p,this.remuxer=E}return h.prototype.resetInitSegment=function(y,E,p,_){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:E,duration:_,inputTimeScale:9e4}},h.prototype.resetTimeStamp=function(){},h.probe=function(y){if(!y)return!1;for(var E=f.default.getID3Data(y,0)||[],p=E.length,_=y.length;p<_;p++)if(l.probe(y,p))return u.logger.log("ADTS sync word found !"),!0;return!1},h.prototype.append=function(y,E,p,_){for(var g=this._audioTrack,x=f.default.getID3Data(y,0)||[],C=f.default.getTimeStamp(x),R=a.isFinite(C)?C*90:E*9e4,S=0,A=R,T=y.length,w=x.length,P=[{pts:A,dts:A,data:x}];w<T-1;)if(l.isHeader(y,w)&&w+5<T){l.initTrackConfig(g,this.observer,y,w,g.manifestCodec);var O=l.appendFrame(g,y,w,R,S);if(O)w+=O.length,A=O.sample.pts,S++;else{u.logger.log("Unable to parse AAC frame");break}}else f.default.isHeader(y,w)?(x=f.default.getID3Data(y,w),P.push({pts:A,dts:A,data:x}),w+=x.length):w++;this.remuxer.remux(g,{samples:[]},{samples:P,inputTimeScale:9e4},{samples:[]},E,p,_)},h.prototype.destroy=function(){},h}();t.default=d}).call(this,n("./src/polyfills/number.js").Number)},"./src/demux/adts.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/logger.js"),l=n("./src/errors.js"),u=n("./src/events.js");function f(R,S,A,T){var w,P,O,k,D,F=navigator.userAgent.toLowerCase(),G=T,V=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(w=((S[A+2]&192)>>>6)+1,P=(S[A+2]&60)>>>2,P>V.length-1){R.trigger(u.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+P});return}return k=(S[A+2]&1)<<2,k|=(S[A+3]&192)>>>6,a.logger.log("manifest codec:"+T+",ADTS data:type:"+w+",sampleingIndex:"+P+"["+V[P]+"Hz],channelConfig:"+k),/firefox/i.test(F)?P>=6?(w=5,D=new Array(4),O=P-3):(w=2,D=new Array(2),O=P):F.indexOf("android")!==-1?(w=2,D=new Array(2),O=P):(w=5,D=new Array(4),T&&(T.indexOf("mp4a.40.29")!==-1||T.indexOf("mp4a.40.5")!==-1)||!T&&P>=6?O=P-3:((T&&T.indexOf("mp4a.40.2")!==-1&&(P>=6&&k===1||/vivaldi/i.test(F))||!T&&k===1)&&(w=2,D=new Array(2)),O=P)),D[0]=w<<3,D[0]|=(P&14)>>1,D[1]|=(P&1)<<7,D[1]|=k<<3,w===5&&(D[1]|=(O&14)>>1,D[2]=(O&1)<<7,D[2]|=8,D[3]=0),{config:D,samplerate:V[P],channelCount:k,codec:"mp4a.40."+w,manifestCodec:G}}t.getAudioConfig=f;function d(R,S){return R[S]===255&&(R[S+1]&246)===240}t.isHeaderPattern=d;function h(R,S){return R[S+1]&1?7:9}t.getHeaderLength=h;function y(R,S){return(R[S+3]&3)<<11|R[S+4]<<3|(R[S+5]&224)>>>5}t.getFullFrameLength=y;function E(R,S){return!!(S+1<R.length&&d(R,S))}t.isHeader=E;function p(R,S){if(S+1<R.length&&d(R,S)){var A=h(R,S),T=A;S+5<R.length&&(T=y(R,S));var w=S+T;if(w===R.length||w+1<R.length&&d(R,w))return!0}return!1}t.probe=p;function _(R,S,A,T,w){if(!R.samplerate){var P=f(S,A,T,w);R.config=P.config,R.samplerate=P.samplerate,R.channelCount=P.channelCount,R.codec=P.codec,R.manifestCodec=P.manifestCodec,a.logger.log("parsed codec:"+R.codec+",rate:"+P.samplerate+",nb channel:"+P.channelCount)}}t.initTrackConfig=_;function g(R){return 1024*9e4/R}t.getFrameDuration=g;function x(R,S,A,T,w){var P,O,k,D=R.length;if(P=h(R,S),O=y(R,S),O-=P,O>0&&S+P+O<=D)return k=A+T*w,{headerLength:P,frameLength:O,stamp:k}}t.parseFrameHeader=x;function C(R,S,A,T,w){var P=g(R.samplerate),O=x(S,A,T,w,P);if(O){var k=O.stamp,D=O.headerLength,F=O.frameLength,G={unit:S.subarray(A+D,A+D+F),pts:k,dts:k};return R.samples.push(G),R.len+=F,{sample:G,length:F+D}}}t.appendFrame=C},"./src/demux/demuxer-inline.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/events.js"),l=n("./src/errors.js"),u=n("./src/crypt/decrypter.js"),f=n("./src/demux/aacdemuxer.js"),d=n("./src/demux/mp4demuxer.js"),h=n("./src/demux/tsdemuxer.js"),y=n("./src/demux/mp3demuxer.js"),E=n("./src/remux/mp4-remuxer.js"),p=n("./src/remux/passthrough-remuxer.js"),_=n("./src/utils/get-self-scope.js"),g=n("./src/utils/logger.js"),x=_.getSelfScope(),C;try{C=x.performance.now.bind(x.performance)}catch{g.logger.debug("Unable to use Performance API on this environment"),C=x.Date.now}var R=function(){function S(A,T,w,P){this.observer=A,this.typeSupported=T,this.config=w,this.vendor=P}return S.prototype.destroy=function(){var A=this.demuxer;A&&A.destroy()},S.prototype.push=function(A,T,w,P,O,k,D,F,G,V,W,ee){var q=this;if(A.byteLength>0&&T!=null&&T.key!=null&&T.method==="AES-128"){var z=this.decrypter;z==null&&(z=this.decrypter=new u.default(this.observer,this.config));var U=C();z.decrypt(A,T.key.buffer,T.iv.buffer,function($){var I=C();q.observer.trigger(a.default.FRAG_DECRYPTED,{stats:{tstart:U,tdecrypt:I}}),q.pushDecrypted(new Uint8Array($),T,new Uint8Array(w),P,O,k,D,F,G,V,W,ee)})}else this.pushDecrypted(new Uint8Array(A),T,new Uint8Array(w),P,O,k,D,F,G,V,W,ee)},S.prototype.pushDecrypted=function(A,T,w,P,O,k,D,F,G,V,W,ee){var q=this.demuxer;if(!q||(D||F)&&!this.probe(A)){for(var z=this.observer,U=this.typeSupported,$=this.config,I=[{demux:h.default,remux:E.default},{demux:d.default,remux:p.default},{demux:f.default,remux:E.default},{demux:y.default,remux:E.default}],B=0,X=I.length;B<X;B++){var Q=I[B],J=Q.demux.probe;if(J(A)){var ne=this.remuxer=new Q.remux(z,$,U,this.vendor);q=new Q.demux(z,ne,$,U),this.probe=J;break}}if(!q){z.trigger(a.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});return}this.demuxer=q}var ae=this.remuxer;(D||F)&&(q.resetInitSegment(w,P,O,V),ae.resetInitSegment()),D&&(q.resetTimeStamp(ee),ae.resetTimeStamp(ee)),typeof q.setDecryptData=="function"&&q.setDecryptData(T),q.append(A,k,G,W)},S}();t.default=R},"./src/demux/demuxer-worker.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/demux/demuxer-inline.js"),l=n("./src/events.js"),u=n("./src/utils/logger.js"),f=n("./node_modules/node-libs-browser/node_modules/events/events.js"),d=function(h){var y=new f.EventEmitter;y.trigger=function(_){for(var g=[],x=1;x<arguments.length;x++)g[x-1]=arguments[x];y.emit.apply(y,[_,_].concat(g))},y.off=function(_){for(var g=[],x=1;x<arguments.length;x++)g[x-1]=arguments[x];y.removeListener.apply(y,[_].concat(g))};var E=function(p,_){h.postMessage({event:p,data:_})};h.addEventListener("message",function(p){var _=p.data;switch(_.cmd){case"init":var g=JSON.parse(_.config);h.demuxer=new a.default(y,_.typeSupported,g,_.vendor),u.enableLogs(g.debug),E("init",null);break;case"demux":h.demuxer.push(_.data,_.decryptdata,_.initSegment,_.audioCodec,_.videoCodec,_.timeOffset,_.discontinuity,_.trackSwitch,_.contiguous,_.duration,_.accurateTimeOffset,_.defaultInitPTS);break}}),y.on(l.default.FRAG_DECRYPTED,E),y.on(l.default.FRAG_PARSING_INIT_SEGMENT,E),y.on(l.default.FRAG_PARSED,E),y.on(l.default.ERROR,E),y.on(l.default.FRAG_PARSING_METADATA,E),y.on(l.default.FRAG_PARSING_USERDATA,E),y.on(l.default.INIT_PTS_FOUND,E),y.on(l.default.FRAG_PARSING_DATA,function(p,_){var g=[],x={event:p,data:_};_.data1&&(x.data1=_.data1.buffer,g.push(_.data1.buffer),delete _.data1),_.data2&&(x.data2=_.data2.buffer,g.push(_.data2.buffer),delete _.data2),h.postMessage(x,g)})};t.default=d},"./src/demux/demuxer.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/webworkify-webpack/index.js"),u=n("./src/events.js"),f=n("./src/demux/demuxer-inline.js"),d=n("./src/utils/logger.js"),h=n("./src/errors.js"),y=n("./src/utils/mediasource-helper.js"),E=n("./src/utils/get-self-scope.js"),p=n("./src/observer.js"),_=E.getSelfScope(),g=y.getMediaSource(),x=function(){function C(R,S){var A=this;this.hls=R,this.id=S;var T=this.observer=new p.Observer,w=R.config,P=function(F,G){G=G||{},G.frag=A.frag,G.id=A.id,R.trigger(F,G)};T.on(u.default.FRAG_DECRYPTED,P),T.on(u.default.FRAG_PARSING_INIT_SEGMENT,P),T.on(u.default.FRAG_PARSING_DATA,P),T.on(u.default.FRAG_PARSED,P),T.on(u.default.ERROR,P),T.on(u.default.FRAG_PARSING_METADATA,P),T.on(u.default.FRAG_PARSING_USERDATA,P),T.on(u.default.INIT_PTS_FOUND,P);var O={mp4:g.isTypeSupported("video/mp4"),mpeg:g.isTypeSupported("audio/mpeg"),mp3:g.isTypeSupported('audio/mp4; codecs="mp3"')},k=navigator.vendor;if(w.enableWorker&&typeof Worker<"u"){d.logger.log("demuxing in webworker");var D=void 0;try{D=this.w=l("./src/demux/demuxer-worker.js"),this.onwmsg=this.onWorkerMessage.bind(this),D.addEventListener("message",this.onwmsg),D.onerror=function(F){R.trigger(u.default.ERROR,{type:h.ErrorTypes.OTHER_ERROR,details:h.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:F.message+" ("+F.filename+":"+F.lineno+")"}})},D.postMessage({cmd:"init",typeSupported:O,vendor:k,id:S,config:JSON.stringify(w)})}catch(F){d.logger.warn("Error in worker:",F),d.logger.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),D&&_.URL.revokeObjectURL(D.objectURL),this.demuxer=new f.default(T,O,w,k),this.w=void 0}}else this.demuxer=new f.default(T,O,w,k)}return C.prototype.destroy=function(){var R=this.w;if(R)R.removeEventListener("message",this.onwmsg),R.terminate(),this.w=null;else{var S=this.demuxer;S&&(S.destroy(),this.demuxer=null)}var A=this.observer;A&&(A.removeAllListeners(),this.observer=null)},C.prototype.push=function(R,S,A,T,w,P,O,k){var D=this.w,F=a.isFinite(w.startPTS)?w.startPTS:w.start,G=w.decryptdata,V=this.frag,W=!(V&&w.cc===V.cc),ee=!(V&&w.level===V.level),q=V&&w.sn===V.sn+1,z=!ee&&q;if(W&&d.logger.log(this.id+":discontinuity detected"),ee&&d.logger.log(this.id+":switch detected"),this.frag=w,D)D.postMessage({cmd:"demux",data:R,decryptdata:G,initSegment:S,audioCodec:A,videoCodec:T,timeOffset:F,discontinuity:W,trackSwitch:ee,contiguous:z,duration:P,accurateTimeOffset:O,defaultInitPTS:k},R instanceof ArrayBuffer?[R]:[]);else{var U=this.demuxer;U&&U.push(R,G,S,A,T,F,W,ee,z,P,O,k)}},C.prototype.onWorkerMessage=function(R){var S=R.data,A=this.hls;switch(S.event){case"init":_.URL.revokeObjectURL(this.w.objectURL);break;case u.default.FRAG_PARSING_DATA:S.data.data1=new Uint8Array(S.data1),S.data2&&(S.data.data2=new Uint8Array(S.data2));default:S.data=S.data||{},S.data.frag=this.frag,S.data.id=this.id,A.trigger(S.event,S.data);break}},C}();t.default=x}).call(this,n("./src/polyfills/number.js").Number)},"./src/demux/exp-golomb.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/logger.js"),l=function(){function u(f){this.data=f,this.bytesAvailable=f.byteLength,this.word=0,this.bitsAvailable=0}return u.prototype.loadWord=function(){var f=this.data,d=this.bytesAvailable,h=f.byteLength-d,y=new Uint8Array(4),E=Math.min(4,d);if(E===0)throw new Error("no bytes available");y.set(f.subarray(h,h+E)),this.word=new DataView(y.buffer).getUint32(0),this.bitsAvailable=E*8,this.bytesAvailable-=E},u.prototype.skipBits=function(f){var d;this.bitsAvailable>f?(this.word<<=f,this.bitsAvailable-=f):(f-=this.bitsAvailable,d=f>>3,f-=d>>3,this.bytesAvailable-=d,this.loadWord(),this.word<<=f,this.bitsAvailable-=f)},u.prototype.readBits=function(f){var d=Math.min(this.bitsAvailable,f),h=this.word>>>32-d;return f>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=d,this.bitsAvailable>0?this.word<<=d:this.bytesAvailable>0&&this.loadWord(),d=f-d,d>0&&this.bitsAvailable?h<<d|this.readBits(d):h},u.prototype.skipLZ=function(){var f;for(f=0;f<this.bitsAvailable;++f)if(this.word&2147483648>>>f)return this.word<<=f,this.bitsAvailable-=f,f;return this.loadWord(),f+this.skipLZ()},u.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},u.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},u.prototype.readUEG=function(){var f=this.skipLZ();return this.readBits(f+1)-1},u.prototype.readEG=function(){var f=this.readUEG();return 1&f?1+f>>>1:-1*(f>>>1)},u.prototype.readBoolean=function(){return this.readBits(1)===1},u.prototype.readUByte=function(){return this.readBits(8)},u.prototype.readUShort=function(){return this.readBits(16)},u.prototype.readUInt=function(){return this.readBits(32)},u.prototype.skipScalingList=function(f){var d=8,h=8,y,E;for(y=0;y<f;y++)h!==0&&(E=this.readEG(),h=(d+E+256)%256),d=h===0?d:h},u.prototype.readSPS=function(){var f=0,d=0,h=0,y=0,E,p,_,g,x,C,R,S=this.readUByte.bind(this),A=this.readBits.bind(this),T=this.readUEG.bind(this),w=this.readBoolean.bind(this),P=this.skipBits.bind(this),O=this.skipEG.bind(this),k=this.skipUEG.bind(this),D=this.skipScalingList.bind(this);if(S(),E=S(),A(5),P(3),S(),k(),E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128){var F=T();if(F===3&&P(1),k(),k(),P(1),w())for(C=F!==3?8:12,R=0;R<C;R++)w()&&(R<6?D(16):D(64))}k();var G=T();if(G===0)T();else if(G===1)for(P(1),O(),O(),p=T(),R=0;R<p;R++)O();k(),P(1),_=T(),g=T(),x=A(1),x===0&&P(1),P(1),w()&&(f=T(),d=T(),h=T(),y=T());var V=[1,1];if(w()&&w()){var W=S();switch(W){case 1:V=[1,1];break;case 2:V=[12,11];break;case 3:V=[10,11];break;case 4:V=[16,11];break;case 5:V=[40,33];break;case 6:V=[24,11];break;case 7:V=[20,11];break;case 8:V=[32,11];break;case 9:V=[80,33];break;case 10:V=[18,11];break;case 11:V=[15,11];break;case 12:V=[64,33];break;case 13:V=[160,99];break;case 14:V=[4,3];break;case 15:V=[3,2];break;case 16:V=[2,1];break;case 255:{V=[S()<<8|S(),S()<<8|S()];break}}}return{width:Math.ceil((_+1)*16-f*2-d*2),height:(2-x)*(g+1)*16-(x?2:4)*(h+y),pixelRatio:V}},u.prototype.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},u}();t.default=l},"./src/demux/id3.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function u(){}return u.isHeader=function(f,d){return d+10<=f.length&&f[d]===73&&f[d+1]===68&&f[d+2]===51&&f[d+3]<255&&f[d+4]<255&&f[d+6]<128&&f[d+7]<128&&f[d+8]<128&&f[d+9]<128},u.isFooter=function(f,d){return d+10<=f.length&&f[d]===51&&f[d+1]===68&&f[d+2]===73&&f[d+3]<255&&f[d+4]<255&&f[d+6]<128&&f[d+7]<128&&f[d+8]<128&&f[d+9]<128},u.getID3Data=function(f,d){for(var h=d,y=0;u.isHeader(f,d);){y+=10;var E=u._readSize(f,d+6);y+=E,u.isFooter(f,d+10)&&(y+=10),d+=y}if(y>0)return f.subarray(h,h+y)},u._readSize=function(f,d){var h=0;return h=(f[d]&127)<<21,h|=(f[d+1]&127)<<14,h|=(f[d+2]&127)<<7,h|=f[d+3]&127,h},u.getTimeStamp=function(f){for(var d=u.getID3Frames(f),h=0;h<d.length;h++){var y=d[h];if(u.isTimeStampFrame(y))return u._readTimeStamp(y)}},u.isTimeStampFrame=function(f){return f&&f.key==="PRIV"&&f.info==="com.apple.streaming.transportStreamTimestamp"},u._getFrameData=function(f){var d=String.fromCharCode(f[0],f[1],f[2],f[3]),h=u._readSize(f,4),y=10;return{type:d,size:h,data:f.subarray(y,y+h)}},u.getID3Frames=function(f){for(var d=0,h=[];u.isHeader(f,d);){var y=u._readSize(f,d+6);d+=10;for(var E=d+y;d+8<E;){var p=u._getFrameData(f.subarray(d)),_=u._decodeFrame(p);_&&h.push(_),d+=p.size+10}u.isFooter(f,d)&&(d+=10)}return h},u._decodeFrame=function(f){if(f.type==="PRIV")return u._decodePrivFrame(f);if(f.type[0]==="T")return u._decodeTextFrame(f);if(f.type[0]==="W")return u._decodeURLFrame(f)},u._readTimeStamp=function(f){if(f.data.byteLength===8){var d=new Uint8Array(f.data),h=d[3]&1,y=(d[4]<<23)+(d[5]<<15)+(d[6]<<7)+d[7];return y/=45,h&&(y+=4772185884e-2),Math.round(y)}},u._decodePrivFrame=function(f){if(!(f.size<2)){var d=u._utf8ArrayToStr(f.data,!0),h=new Uint8Array(f.data.subarray(d.length+1));return{key:f.type,info:d,data:h.buffer}}},u._decodeTextFrame=function(f){if(!(f.size<2))if(f.type==="TXXX"){var d=1,h=u._utf8ArrayToStr(f.data.subarray(d));d+=h.length+1;var y=u._utf8ArrayToStr(f.data.subarray(d));return{key:f.type,info:h,data:y}}else{var E=u._utf8ArrayToStr(f.data.subarray(1));return{key:f.type,data:E}}},u._decodeURLFrame=function(f){if(f.type==="WXXX"){if(f.size<2)return;var d=1,h=u._utf8ArrayToStr(f.data.subarray(d));d+=h.length+1;var y=u._utf8ArrayToStr(f.data.subarray(d));return{key:f.type,info:h,data:y}}else{var E=u._utf8ArrayToStr(f.data);return{key:f.type,data:E}}},u._utf8ArrayToStr=function(f,d){d===void 0&&(d=!1);for(var h=f.length,y,E,p,_="",g=0;g<h;){if(y=f[g++],y===0&&d)return _;if(y===0||y===3)continue;switch(y>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:_+=String.fromCharCode(y);break;case 12:case 13:E=f[g++],_+=String.fromCharCode((y&31)<<6|E&63);break;case 14:E=f[g++],p=f[g++],_+=String.fromCharCode((y&15)<<12|(E&63)<<6|(p&63)<<0);break}}return _},u}(),l=a._utf8ArrayToStr;t.utf8ArrayToStr=l,t.default=a},"./src/demux/mp3demuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/demux/id3.js"),l=n("./src/utils/logger.js"),u=n("./src/demux/mpegaudio.js"),f=function(){function d(h,y,E){this.observer=h,this.config=E,this.remuxer=y}return d.prototype.resetInitSegment=function(h,y,E,p){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:y,duration:p,inputTimeScale:9e4}},d.prototype.resetTimeStamp=function(){},d.probe=function(h){var y,E,p=a.default.getID3Data(h,0);if(p&&a.default.getTimeStamp(p)!==void 0){for(y=p.length,E=Math.min(h.length-1,y+100);y<E;y++)if(u.default.probe(h,y))return l.logger.log("MPEG Audio sync word found !"),!0}return!1},d.prototype.append=function(h,y,E,p){for(var _=a.default.getID3Data(h,0),g=a.default.getTimeStamp(_),x=g?90*g:y*9e4,C=_.length,R=h.length,S=0,A=0,T=this._audioTrack,w=[{pts:x,dts:x,data:_}];C<R;)if(u.default.isHeader(h,C)){var P=u.default.appendFrame(T,h,C,x,S);if(P)C+=P.length,A=P.sample.pts,S++;else break}else a.default.isHeader(h,C)?(_=a.default.getID3Data(h,C),w.push({pts:A,dts:A,data:_}),C+=_.length):C++;this.remuxer.remux(T,{samples:[]},{samples:w,inputTimeScale:9e4},{samples:[]},y,E,p)},d.prototype.destroy=function(){},d}();t.default=f},"./src/demux/mp4demuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/logger.js"),l=n("./src/events.js"),u=Math.pow(2,32)-1,f=function(){function d(h,y){this.observer=h,this.remuxer=y}return d.prototype.resetTimeStamp=function(h){this.initPTS=h},d.prototype.resetInitSegment=function(h,y,E,p){if(h&&h.byteLength){var _=this.initData=d.parseInitSegment(h);y==null&&(y="mp4a.40.5"),E==null&&(E="avc1.42e01e");var g={};_.audio&&_.video?g.audiovideo={container:"video/mp4",codec:y+","+E,initSegment:p?h:null}:(_.audio&&(g.audio={container:"audio/mp4",codec:y,initSegment:p?h:null}),_.video&&(g.video={container:"video/mp4",codec:E,initSegment:p?h:null})),this.observer.trigger(l.default.FRAG_PARSING_INIT_SEGMENT,{tracks:g})}else y&&(this.audioCodec=y),E&&(this.videoCodec=E)},d.probe=function(h){return d.findBox({data:h,start:0,end:Math.min(h.length,16384)},["moof"]).length>0},d.bin2str=function(h){return String.fromCharCode.apply(null,h)},d.readUint16=function(h,y){h.data&&(y+=h.start,h=h.data);var E=h[y]<<8|h[y+1];return E<0?65536+E:E},d.readUint32=function(h,y){h.data&&(y+=h.start,h=h.data);var E=h[y]<<24|h[y+1]<<16|h[y+2]<<8|h[y+3];return E<0?4294967296+E:E},d.writeUint32=function(h,y,E){h.data&&(y+=h.start,h=h.data),h[y]=E>>24,h[y+1]=E>>16&255,h[y+2]=E>>8&255,h[y+3]=E&255},d.findBox=function(h,y){var E=[],p,_,g,x,C,R,S;if(h.data?(R=h.start,x=h.end,h=h.data):(R=0,x=h.byteLength),!y.length)return null;for(p=R;p<x;)_=d.readUint32(h,p),g=d.bin2str(h.subarray(p+4,p+8)),S=_>1?p+_:x,g===y[0]&&(y.length===1?E.push({data:h,start:p+8,end:S}):(C=d.findBox({data:h,start:p+8,end:S},y.slice(1)),C.length&&(E=E.concat(C)))),p=S;return E},d.parseSegmentIndex=function(h){var y=d.findBox(h,["moov"])[0],E=y?y.end:null,p=0,_=d.findBox(h,["sidx"]),g;if(!_||!_[0])return null;g=[],_=_[0];var x=_.data[0];p=x===0?8:16;var C=d.readUint32(_,p);p+=4;var R=0,S=0;x===0?p+=8:p+=16,p+=2;var A=_.end+S,T=d.readUint16(_,p);p+=2;for(var w=0;w<T;w++){var P=p,O=d.readUint32(_,P);P+=4;var k=O&2147483647,D=(O&2147483648)>>>31;if(D===1){console.warn("SIDX has hierarchical references (not supported)");return}var F=d.readUint32(_,P);P+=4,g.push({referenceSize:k,subsegmentDuration:F,info:{duration:F/C,start:A,end:A+k-1}}),A+=k,P+=4,p=P}return{earliestPresentationTime:R,timescale:C,version:x,referencesCount:T,references:g,moovEndOffset:E}},d.parseInitSegment=function(h){var y=[],E=d.findBox(h,["moov","trak"]);return E.forEach(function(p){var _=d.findBox(p,["tkhd"])[0];if(_){var g=_.data[_.start],x=g===0?12:20,C=d.readUint32(_,x),R=d.findBox(p,["mdia","mdhd"])[0];if(R){g=R.data[R.start],x=g===0?12:20;var S=d.readUint32(R,x),A=d.findBox(p,["mdia","hdlr"])[0];if(A){var T=d.bin2str(A.data.subarray(A.start+8,A.start+12)),w={soun:"audio",vide:"video"}[T];if(w){var P=d.findBox(p,["mdia","minf","stbl","stsd"]);if(P.length){P=P[0];var O=d.bin2str(P.data.subarray(P.start+12,P.start+16));a.logger.log("MP4Demuxer:"+w+":"+O+" found")}y[C]={timescale:S,type:w},y[w]={timescale:S,id:C}}}}}}),y},d.getStartDTS=function(h,y){var E,p,_;return E=d.findBox(y,["moof","traf"]),p=[].concat.apply([],E.map(function(g){return d.findBox(g,["tfhd"]).map(function(x){var C,R,S;return C=d.readUint32(x,4),R=h[C].timescale||9e4,S=d.findBox(g,["tfdt"]).map(function(A){var T,w;return T=A.data[A.start],w=d.readUint32(A,4),T===1&&(w*=Math.pow(2,32),w+=d.readUint32(A,8)),w})[0],S/R})})),_=Math.min.apply(null,p),isFinite(_)?_:0},d.offsetStartDTS=function(h,y,E){d.findBox(y,["moof","traf"]).map(function(p){return d.findBox(p,["tfhd"]).map(function(_){var g=d.readUint32(_,4),x=h[g].timescale||9e4;d.findBox(p,["tfdt"]).map(function(C){var R=C.data[C.start],S=d.readUint32(C,4);if(R===0)d.writeUint32(C,4,S-E*x);else{S*=Math.pow(2,32),S+=d.readUint32(C,8),S-=E*x,S=Math.max(S,0);var A=Math.floor(S/(u+1)),T=Math.floor(S%(u+1));d.writeUint32(C,4,A),d.writeUint32(C,8,T)}})})})},d.prototype.append=function(h,y,E,p){var _=this.initData;_||(this.resetInitSegment(h,this.audioCodec,this.videoCodec,!1),_=this.initData);var g,x=this.initPTS;if(x===void 0){var C=d.getStartDTS(_,h);this.initPTS=x=C-y,this.observer.trigger(l.default.INIT_PTS_FOUND,{initPTS:x})}d.offsetStartDTS(_,h,x),g=d.getStartDTS(_,h),this.remuxer.remux(_.audio,_.video,null,null,g,E,p,h)},d.prototype.destroy=function(){},d}();t.default=f},"./src/demux/mpegaudio.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={BitratesMap:[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients:[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot:[0,1,1,4],appendFrame:function(l,u,f,d,h){if(!(f+24>u.length)){var y=this.parseHeader(u,f);if(y&&f+y.frameLength<=u.length){var E=y.samplesPerFrame*9e4/y.sampleRate,p=d+h*E,_={unit:u.subarray(f,f+y.frameLength),pts:p,dts:p};return l.config=[],l.channelCount=y.channelCount,l.samplerate=y.sampleRate,l.samples.push(_),l.len+=y.frameLength,{sample:_,length:y.frameLength}}}},parseHeader:function(l,u){var f=l[u+1]>>3&3,d=l[u+1]>>1&3,h=l[u+2]>>4&15,y=l[u+2]>>2&3,E=l[u+2]>>1&1;if(f!==1&&h!==0&&h!==15&&y!==3){var p=f===3?3-d:d===3?3:4,_=a.BitratesMap[p*14+h-1]*1e3,g=f===3?0:f===2?1:2,x=a.SamplingRateMap[g*3+y],C=l[u+3]>>6===3?1:2,R=a.SamplesCoefficients[f][d],S=a.BytesInSlot[d],A=R*8*S,T=parseInt(R*_/x+E,10)*S;return{sampleRate:x,channelCount:C,frameLength:T,samplesPerFrame:A}}},isHeaderPattern:function(l,u){return l[u]===255&&(l[u+1]&224)===224&&(l[u+1]&6)!==0},isHeader:function(l,u){return!!(u+1<l.length&&this.isHeaderPattern(l,u))},probe:function(l,u){if(u+1<l.length&&this.isHeaderPattern(l,u)){var f=4,d=this.parseHeader(l,u),h=f;d&&d.frameLength&&(h=d.frameLength);var y=u+h;if(y===l.length||y+1<l.length&&this.isHeaderPattern(l,y))return!0}return!1}};t.default=a},"./src/demux/sample-aes.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/crypt/decrypter.js"),l=function(){function u(f,d,h,y){this.decryptdata=h,this.discardEPB=y,this.decrypter=new a.default(f,d,{removePKCS7Padding:!1})}return u.prototype.decryptBuffer=function(f,d){this.decrypter.decrypt(f,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,d)},u.prototype.decryptAacSample=function(f,d,h,y){var E=f[d].unit,p=E.subarray(16,E.length-E.length%16),_=p.buffer.slice(p.byteOffset,p.byteOffset+p.length),g=this;this.decryptBuffer(_,function(x){x=new Uint8Array(x),E.set(x,16),y||g.decryptAacSamples(f,d+1,h)})},u.prototype.decryptAacSamples=function(f,d,h){for(;;d++){if(d>=f.length){h();return}if(!(f[d].unit.length<32)){var y=this.decrypter.isSync();if(this.decryptAacSample(f,d,h,y),!y)return}}},u.prototype.getAvcEncryptedData=function(f){for(var d=Math.floor((f.length-48)/160)*16+16,h=new Int8Array(d),y=0,E=32;E<=f.length-16;E+=160,y+=16)h.set(f.subarray(E,E+16),y);return h},u.prototype.getAvcDecryptedUnit=function(f,d){d=new Uint8Array(d);for(var h=0,y=32;y<=f.length-16;y+=160,h+=16)f.set(d.subarray(h,h+16),y);return f},u.prototype.decryptAvcSample=function(f,d,h,y,E,p){var _=this.discardEPB(E.data),g=this.getAvcEncryptedData(_),x=this;this.decryptBuffer(g.buffer,function(C){E.data=x.getAvcDecryptedUnit(_,C),p||x.decryptAvcSamples(f,d,h+1,y)})},u.prototype.decryptAvcSamples=function(f,d,h,y){for(;;d++,h=0){if(d>=f.length){y();return}for(var E=f[d].units;!(h>=E.length);h++){var p=E[h];if(!(p.length<=48||p.type!==1&&p.type!==5)){var _=this.decrypter.isSync();if(this.decryptAvcSample(f,d,h,y,p,_),!_)return}}}},u}();t.default=l},"./src/demux/tsdemuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/demux/adts.js"),l=n("./src/demux/mpegaudio.js"),u=n("./src/events.js"),f=n("./src/demux/exp-golomb.js"),d=n("./src/demux/sample-aes.js"),h=n("./src/utils/logger.js"),y=n("./src/errors.js"),E={video:1,audio:2,id3:3,text:4},p=function(){function _(g,x,C,R){this.observer=g,this.config=C,this.typeSupported=R,this.remuxer=x,this.sampleAes=null}return _.prototype.setDecryptData=function(g){g!=null&&g.key!=null&&g.method==="SAMPLE-AES"?this.sampleAes=new d.default(this.observer,this.config,g,this.discardEPB):this.sampleAes=null},_.probe=function(g){var x=_._syncOffset(g);return x<0?!1:(x&&h.logger.warn("MPEG2-TS detected but first sync word found @ offset "+x+", junk ahead ?"),!0)},_._syncOffset=function(g){for(var x=Math.min(1e3,g.length-564),C=0;C<x;){if(g[C]===71&&g[C+188]===71&&g[C+2*188]===71)return C;C++}return-1},_.createTrack=function(g,x){return{container:g==="video"||g==="audio"?"video/mp2t":void 0,type:g,id:E[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0,dropped:g==="video"?0:void 0,isAAC:g==="audio"?!0:void 0,duration:g==="audio"?x:void 0}},_.prototype.resetInitSegment=function(g,x,C,R){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=_.createTrack("video",R),this._audioTrack=_.createTrack("audio",R),this._id3Track=_.createTrack("id3",R),this._txtTrack=_.createTrack("text",R),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=x,this.videoCodec=C,this._duration=R},_.prototype.resetTimeStamp=function(){},_.prototype.append=function(g,x,C,R){var S,A=g.length,T,w,P,O,k,D=!1;this.contiguous=C;var F=this.pmtParsed,G=this._avcTrack,V=this._audioTrack,W=this._id3Track,ee=G.pid,q=V.pid,z=W.pid,U=this._pmtId,$=G.pesData,I=V.pesData,B=W.pesData,X=this._parsePAT,Q=this._parsePMT,J=this._parsePES,ne=this._parseAVCPES.bind(this),ae=this._parseAACPES.bind(this),Z=this._parseMPEGPES.bind(this),se=this._parseID3PES.bind(this),oe=_._syncOffset(g);for(A-=(A+oe)%188,S=oe;S<A;S+=188)if(g[S]===71){if(T=!!(g[S+1]&64),w=((g[S+1]&31)<<8)+g[S+2],P=(g[S+3]&48)>>4,P>1){if(O=S+5+g[S+4],O===S+188)continue}else O=S+4;switch(w){case ee:T&&($&&(k=J($))&&k.pts!==void 0&&ne(k,!1),$={data:[],size:0}),$&&($.data.push(g.subarray(O,S+188)),$.size+=S+188-O);break;case q:T&&(I&&(k=J(I))&&k.pts!==void 0&&(V.isAAC?ae(k):Z(k)),I={data:[],size:0}),I&&(I.data.push(g.subarray(O,S+188)),I.size+=S+188-O);break;case z:T&&(B&&(k=J(B))&&k.pts!==void 0&&se(k),B={data:[],size:0}),B&&(B.data.push(g.subarray(O,S+188)),B.size+=S+188-O);break;case 0:T&&(O+=g[O]+1),U=this._pmtId=X(g,O);break;case U:T&&(O+=g[O]+1);var fe=Q(g,O,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,this.sampleAes!=null);ee=fe.avc,ee>0&&(G.pid=ee),q=fe.audio,q>0&&(V.pid=q,V.isAAC=fe.isAAC),z=fe.id3,z>0&&(W.pid=z),D&&!F&&(h.logger.log("reparse from beginning"),D=!1,S=oe-188),F=this.pmtParsed=!0;break;case 17:case 8191:break;default:D=!0;break}}else this.observer.trigger(u.default.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});$&&(k=J($))&&k.pts!==void 0?(ne(k,!0),G.pesData=null):G.pesData=$,I&&(k=J(I))&&k.pts!==void 0?(V.isAAC?ae(k):Z(k),V.pesData=null):(I&&I.size&&h.logger.log("last AAC PES packet truncated,might overlap between fragments"),V.pesData=I),B&&(k=J(B))&&k.pts!==void 0?(se(k),W.pesData=null):W.pesData=B,this.sampleAes==null?this.remuxer.remux(V,G,W,this._txtTrack,x,C,R):this.decryptAndRemux(V,G,W,this._txtTrack,x,C,R)},_.prototype.decryptAndRemux=function(g,x,C,R,S,A,T){if(g.samples&&g.isAAC){var w=this;this.sampleAes.decryptAacSamples(g.samples,0,function(){w.decryptAndRemuxAvc(g,x,C,R,S,A,T)})}else this.decryptAndRemuxAvc(g,x,C,R,S,A,T)},_.prototype.decryptAndRemuxAvc=function(g,x,C,R,S,A,T){if(x.samples){var w=this;this.sampleAes.decryptAvcSamples(x.samples,0,0,function(){w.remuxer.remux(g,x,C,R,S,A,T)})}else this.remuxer.remux(g,x,C,R,S,A,T)},_.prototype.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},_.prototype._parsePAT=function(g,x){return(g[x+10]&31)<<8|g[x+11]},_.prototype._parsePMT=function(g,x,C,R){var S,A,T,w,P={audio:-1,avc:-1,id3:-1,isAAC:!0};for(S=(g[x+1]&15)<<8|g[x+2],A=x+3+S-4,T=(g[x+10]&15)<<8|g[x+11],x+=12+T;x<A;){switch(w=(g[x+1]&31)<<8|g[x+2],g[x]){case 207:if(!R){h.logger.log("unkown stream type:"+g[x]);break}case 15:P.audio===-1&&(P.audio=w);break;case 21:P.id3===-1&&(P.id3=w);break;case 219:if(!R){h.logger.log("unkown stream type:"+g[x]);break}case 27:P.avc===-1&&(P.avc=w);break;case 3:case 4:C?P.audio===-1&&(P.audio=w,P.isAAC=!1):h.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:h.logger.warn("HEVC stream type found, not supported for now");break;default:h.logger.log("unkown stream type:"+g[x]);break}x+=((g[x+3]&15)<<8|g[x+4])+5}return P},_.prototype._parsePES=function(g){var x=0,C,R,S,A,T,w,P,O,k,D=g.data;if(!g||g.size===0)return null;for(;D[0].length<19&&D.length>1;){var F=new Uint8Array(D[0].length+D[1].length);F.set(D[0]),F.set(D[1],D[0].length),D[0]=F,D.splice(1,1)}if(C=D[0],S=(C[0]<<16)+(C[1]<<8)+C[2],S===1){if(A=(C[4]<<8)+C[5],A&&A>g.size-6)return null;R=C[7],R&192&&(P=(C[9]&14)*536870912+(C[10]&255)*4194304+(C[11]&254)*16384+(C[12]&255)*128+(C[13]&254)/2,P>4294967295&&(P-=8589934592),R&64?(O=(C[14]&14)*536870912+(C[15]&255)*4194304+(C[16]&254)*16384+(C[17]&255)*128+(C[18]&254)/2,O>4294967295&&(O-=8589934592),P-O>60*9e4&&(h.logger.warn(Math.round((P-O)/9e4)+"s delta between PTS and DTS, align them"),P=O)):O=P),T=C[8],k=T+9,g.size-=k,w=new Uint8Array(g.size);for(var G=0,V=D.length;G<V;G++){C=D[G];var W=C.byteLength;if(k)if(k>W){k-=W;continue}else C=C.subarray(k),W-=k,k=0;w.set(C,x),x+=W}return A&&(A-=T+3),{data:w,pts:P,dts:O,len:A}}else return null},_.prototype.pushAccesUnit=function(g,x){if(g.units.length&&g.frame){var C=x.samples,R=C.length;!this.config.forceKeyFrameOnDiscontinuity||g.key===!0||x.sps&&(R||this.contiguous)?(g.id=R,C.push(g)):x.dropped++}g.debug.length&&h.logger.log(g.pts+"/"+g.dts+":"+g.debug)},_.prototype._parseAVCPES=function(g,x){var C=this,R=this._avcTrack,S=this._parseAVCNALu(g.data),A,T=this.avcSample,w,P=!1,O,k=this.pushAccesUnit.bind(this),D=function(F,G,V,W){return{key:F,pts:G,dts:V,units:[],debug:W}};g.data=null,T&&S.length&&!R.audFound&&(k(T,R),T=this.avcSample=D(!1,g.pts,g.dts,"")),S.forEach(function(F){switch(F.type){case 1:w=!0,T||(T=C.avcSample=D(!0,g.pts,g.dts,"")),T.frame=!0;var G=F.data;if(P&&G.length>4){var V=new f.default(G).readSliceType();(V===2||V===4||V===7||V===9)&&(T.key=!0)}break;case 5:w=!0,T||(T=C.avcSample=D(!0,g.pts,g.dts,"")),T.key=!0,T.frame=!0;break;case 6:w=!0,A=new f.default(C.discardEPB(F.data)),A.readUByte();for(var W=0,ee=0,q=!1,z=0;!q&&A.bytesAvailable>1;){W=0;do z=A.readUByte(),W+=z;while(z===255);ee=0;do z=A.readUByte(),ee+=z;while(z===255);if(W===4&&A.bytesAvailable!==0){q=!0;var U=A.readUByte();if(U===181){var $=A.readUShort();if($===49){var I=A.readUInt();if(I===1195456820){var B=A.readUByte();if(B===3){var X=A.readUByte(),Q=A.readUByte(),J=31&X,ne=[X,Q];for(O=0;O<J;O++)ne.push(A.readUByte()),ne.push(A.readUByte()),ne.push(A.readUByte());C._insertSampleInOrder(C._txtTrack.samples,{type:3,pts:g.pts,bytes:ne})}}}}}else if(ee<A.bytesAvailable)for(O=0;O<ee;O++)A.readUByte()}break;case 7:if(w=!0,P=!0,!R.sps){A=new f.default(F.data);var ae=A.readSPS();R.width=ae.width,R.height=ae.height,R.pixelRatio=ae.pixelRatio,R.sps=[F.data],R.duration=C._duration;var Z=F.data.subarray(1,4),se="avc1.";for(O=0;O<3;O++){var oe=Z[O].toString(16);oe.length<2&&(oe="0"+oe),se+=oe}R.codec=se}break;case 8:w=!0,R.pps||(R.pps=[F.data]);break;case 9:w=!1,R.audFound=!0,T&&k(T,R),T=C.avcSample=D(!1,g.pts,g.dts,"");break;case 12:w=!1;break;default:w=!1,T&&(T.debug+="unknown NAL "+F.type+" ");break}if(T&&w){var fe=T.units;fe.push(F)}}),x&&T&&(k(T,R),this.avcSample=null)},_.prototype._insertSampleInOrder=function(g,x){var C=g.length;if(C>0){if(x.pts>=g[C-1].pts)g.push(x);else for(var R=C-1;R>=0;R--)if(x.pts<g[R].pts){g.splice(R,0,x);break}}else g.push(x)},_.prototype._getLastNalUnit=function(){var g=this.avcSample,x;if(!g||g.units.length===0){var C=this._avcTrack,R=C.samples;g=R[R.length-1]}if(g){var S=g.units;x=S[S.length-1]}return x},_.prototype._parseAVCNALu=function(g){var x=0,C=g.byteLength,R,S,A=this._avcTrack,T=A.naluState||0,w=T,P=[],O,k,D=-1,F;for(T===-1&&(D=0,F=g[0]&31,T=0,x=1);x<C;){if(R=g[x++],!T){T=R?0:1;continue}if(T===1){T=R?0:2;continue}if(!R)T=3;else if(R===1){if(D>=0)O={data:g.subarray(D,x-T-1),type:F},P.push(O);else{var G=this._getLastNalUnit();if(G&&(w&&x<=4-w&&G.state&&(G.data=G.data.subarray(0,G.data.byteLength-w)),S=x-T-1,S>0)){var V=new Uint8Array(G.data.byteLength+S);V.set(G.data,0),V.set(g.subarray(0,S),G.data.byteLength),G.data=V}}x<C?(k=g[x]&31,D=x,F=k,T=0):T=-1}else T=0}if(D>=0&&T>=0&&(O={data:g.subarray(D,C),type:F,state:T},P.push(O)),P.length===0){var G=this._getLastNalUnit();if(G){var V=new Uint8Array(G.data.byteLength+g.byteLength);V.set(G.data,0),V.set(g,G.data.byteLength),G.data=V}}return A.naluState=T,P},_.prototype.discardEPB=function(g){for(var x=g.byteLength,C=[],R=1,S,A;R<x-2;)g[R]===0&&g[R+1]===0&&g[R+2]===3?(C.push(R+2),R+=2):R++;if(C.length===0)return g;S=x-C.length,A=new Uint8Array(S);var T=0;for(R=0;R<S;T++,R++)T===C[0]&&(T++,C.shift()),A[R]=g[T];return A},_.prototype._parseAACPES=function(g){var x=this._audioTrack,C=g.data,R=g.pts,S=0,A=this.aacOverFlow,T=this.aacLastPTS,w,P,O,k,D;if(A){var F=new Uint8Array(A.byteLength+C.byteLength);F.set(A,0),F.set(C,A.byteLength),C=F}for(O=S,D=C.length;O<D-1&&!a.isHeader(C,O);O++);if(O){var G=void 0,V=void 0;if(O<D-1?(G="AAC PES did not start with ADTS header,offset:"+O,V=!1):(G="no ADTS header found in AAC PES",V=!0),h.logger.warn("parsing error:"+G),this.observer.trigger(u.default.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:V,reason:G}),V)return}if(a.initTrackConfig(x,this.observer,C,O,this.audioCodec),P=0,w=a.getFrameDuration(x.samplerate),A&&T){var W=T+w;Math.abs(W-R)>1&&(h.logger.log("AAC: align PTS for overlapping frames by "+Math.round((W-R)/90)),R=W)}for(;O<D;)if(a.isHeader(C,O)&&O+5<D){var ee=a.appendFrame(x,C,O,R,P);if(ee)O+=ee.length,k=ee.sample.pts,P++;else break}else O++;O<D?A=C.subarray(O,D):A=null,this.aacOverFlow=A,this.aacLastPTS=k},_.prototype._parseMPEGPES=function(g){for(var x=g.data,C=x.length,R=0,S=0,A=g.pts;S<C;)if(l.default.isHeader(x,S)){var T=l.default.appendFrame(this._audioTrack,x,S,A,R);if(T)S+=T.length,R++;else break}else S++},_.prototype._parseID3PES=function(g){this._id3Track.samples.push(g)},_}();t.default=p},"./src/errors.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",KEY_SYSTEM_ERROR:"keySystemError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},t.ErrorDetails={KEY_SYSTEM_NO_KEYS:"keySystemNoKeys",KEY_SYSTEM_NO_ACCESS:"keySystemNoAccess",KEY_SYSTEM_NO_SESSION:"keySystemNoSession",KEY_SYSTEM_LICENSE_REQUEST_FAILED:"keySystemLicenseRequestFailed",MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",AUDIO_TRACK_LOAD_ERROR:"audioTrackLoadError",AUDIO_TRACK_LOAD_TIMEOUT:"audioTrackLoadTimeOut",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",REMUX_ALLOC_ERROR:"remuxAllocError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_ADD_CODEC_ERROR:"bufferAddCodecError",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",BUFFER_NUDGE_ON_STALL:"bufferNudgeOnStall",INTERNAL_EXCEPTION:"internalException"}},"./src/event-handler.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/logger.js"),l=n("./src/errors.js"),u=n("./src/events.js"),f={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},d=function(){function h(y){for(var E=[],p=1;p<arguments.length;p++)E[p-1]=arguments[p];this.hls=y,this.onEvent=this.onEvent.bind(this),this.handledEvents=E,this.useGenericHandler=!0,this.registerListeners()}return h.prototype.destroy=function(){this.onHandlerDestroying(),this.unregisterListeners(),this.onHandlerDestroyed()},h.prototype.onHandlerDestroying=function(){},h.prototype.onHandlerDestroyed=function(){},h.prototype.isEventHandler=function(){return typeof this.handledEvents=="object"&&this.handledEvents.length&&typeof this.onEvent=="function"},h.prototype.registerListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(y){if(f[y])throw new Error("Forbidden event-name: "+y);this.hls.on(y,this.onEvent)},this)},h.prototype.unregisterListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(y){this.hls.off(y,this.onEvent)},this)},h.prototype.onEvent=function(y,E){this.onEventGeneric(y,E)},h.prototype.onEventGeneric=function(y,E){var p=function(_,g){var x="on"+_.replace("hls","");if(typeof this[x]!="function")throw new Error("Event "+_+" has no generic handler in this "+this.constructor.name+" class (tried "+x+")");return this[x].bind(this,g)};try{p.call(this,y,E).call()}catch(_){a.logger.error("An internal error happened while handling event "+y+'. Error message: "'+_.message+'". Here is a stacktrace:',_),this.hls.trigger(u.default.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:y,err:_})}},h}();t.default=d},"./src/events.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition"};t.default=a},"./src/hls.js":function(r,t,n){var a=this&&this.__extends||function(){var T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(w,P){w.__proto__=P}||function(w,P){for(var O in P)P.hasOwnProperty(O)&&(w[O]=P[O])};return function(w,P){T(w,P);function O(){this.constructor=w}w.prototype=P===null?Object.create(P):(O.prototype=P.prototype,new O)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/url-toolkit/src/url-toolkit.js"),u=n("./src/errors.js"),f=n("./src/loader/playlist-loader.js"),d=n("./src/loader/fragment-loader.js"),h=n("./src/loader/key-loader.js"),y=n("./src/controller/fragment-tracker.js"),E=n("./src/controller/stream-controller.js"),p=n("./src/controller/level-controller.js"),_=n("./src/controller/id3-track-controller.js"),g=n("./src/is-supported.js"),x=n("./src/utils/logger.js"),C=n("./src/config.js"),R=n("./src/events.js"),S=n("./src/observer.js"),A=function(T){a(w,T);function w(P){P===void 0&&(P={});var O=T.call(this)||this,k=w.DefaultConfig;if((P.liveSyncDurationCount||P.liveMaxLatencyDurationCount)&&(P.liveSyncDuration||P.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var D in k)D in P||(P[D]=k[D]);if(P.liveMaxLatencyDurationCount!==void 0&&P.liveMaxLatencyDurationCount<=P.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(P.liveMaxLatencyDuration!==void 0&&(P.liveMaxLatencyDuration<=P.liveSyncDuration||P.liveSyncDuration===void 0))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');x.enableLogs(P.debug),O.config=P,O._autoLevelCapping=-1;var F=O.abrController=new P.abrController(O),G=new P.bufferController(O),V=new P.capLevelController(O),W=new P.fpsController(O),ee=new f.default(O),q=new d.default(O),z=new h.default(O),U=new _.default(O),$=O.levelController=new p.default(O),I=new y.FragmentTracker(O),B=O.streamController=new E.default(O,I),X=[$,B],Q=P.audioStreamController;Q&&X.push(new Q(O,I)),O.networkControllers=X;var J=[ee,q,z,F,G,V,W,U,I];if(Q=P.audioTrackController,Q){var ne=new Q(O);O.audioTrackController=ne,J.push(ne)}if(Q=P.subtitleTrackController,Q){var ae=new Q(O);O.subtitleTrackController=ae,X.push(ae)}if(Q=P.emeController,Q){var Z=new Q(O);O.emeController=Z,J.push(Z)}return Q=P.subtitleStreamController,Q&&X.push(new Q(O,I)),Q=P.timelineController,Q&&J.push(new Q(O)),O.coreComponents=J,O}return Object.defineProperty(w,"version",{get:function(){return"0.12.4"},enumerable:!0,configurable:!0}),w.isSupported=function(){return g.isSupported()},Object.defineProperty(w,"Events",{get:function(){return R.default},enumerable:!0,configurable:!0}),Object.defineProperty(w,"ErrorTypes",{get:function(){return u.ErrorTypes},enumerable:!0,configurable:!0}),Object.defineProperty(w,"ErrorDetails",{get:function(){return u.ErrorDetails},enumerable:!0,configurable:!0}),Object.defineProperty(w,"DefaultConfig",{get:function(){return w.defaultConfig?w.defaultConfig:C.hlsDefaultConfig},set:function(P){w.defaultConfig=P},enumerable:!0,configurable:!0}),w.prototype.destroy=function(){x.logger.log("destroy"),this.trigger(R.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(P){P.destroy()}),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1},w.prototype.attachMedia=function(P){x.logger.log("attachMedia"),this.media=P,this.trigger(R.default.MEDIA_ATTACHING,{media:P})},w.prototype.detachMedia=function(){x.logger.log("detachMedia"),this.trigger(R.default.MEDIA_DETACHING),this.media=null},w.prototype.loadSource=function(P){P=l.buildAbsoluteURL(window.location.href,P,{alwaysNormalize:!0}),x.logger.log("loadSource:"+P),this.url=P,this.trigger(R.default.MANIFEST_LOADING,{url:P})},w.prototype.startLoad=function(P){P===void 0&&(P=-1),x.logger.log("startLoad("+P+")"),this.networkControllers.forEach(function(O){O.startLoad(P)})},w.prototype.stopLoad=function(){x.logger.log("stopLoad"),this.networkControllers.forEach(function(P){P.stopLoad()})},w.prototype.swapAudioCodec=function(){x.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},w.prototype.recoverMediaError=function(){x.logger.log("recoverMediaError");var P=this.media;this.detachMedia(),this.attachMedia(P)},Object.defineProperty(w.prototype,"levels",{get:function(){return this.levelController.levels},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"currentLevel",{get:function(){return this.streamController.currentLevel},set:function(P){x.logger.log("set currentLevel:"+P),this.loadLevel=P,this.streamController.immediateLevelSwitch()},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"nextLevel",{get:function(){return this.streamController.nextLevel},set:function(P){x.logger.log("set nextLevel:"+P),this.levelController.manualLevel=P,this.streamController.nextLevelSwitch()},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"loadLevel",{get:function(){return this.levelController.level},set:function(P){x.logger.log("set loadLevel:"+P),this.levelController.manualLevel=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"nextLoadLevel",{get:function(){return this.levelController.nextLoadLevel},set:function(P){this.levelController.nextLoadLevel=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"firstLevel",{get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(P){x.logger.log("set firstLevel:"+P),this.levelController.firstLevel=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"startLevel",{get:function(){return this.levelController.startLevel},set:function(P){x.logger.log("set startLevel:"+P);var O=this;P!==-1&&(P=Math.max(P,O.minAutoLevel)),O.levelController.startLevel=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"autoLevelCapping",{get:function(){return this._autoLevelCapping},set:function(P){x.logger.log("set autoLevelCapping:"+P),this._autoLevelCapping=P},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"autoLevelEnabled",{get:function(){return this.levelController.manualLevel===-1},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"manualLevel",{get:function(){return this.levelController.manualLevel},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"minAutoLevel",{get:function(){for(var P=this,O=P.levels,k=P.config.minAutoBitrate,D=O?O.length:0,F=0;F<D;F++){var G=O[F].realBitrate?Math.max(O[F].realBitrate,O[F].bitrate):O[F].bitrate;if(G>k)return F}return 0},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"maxAutoLevel",{get:function(){var P=this,O=P.levels,k=P.autoLevelCapping,D;return k===-1&&O&&O.length?D=O.length-1:D=k,D},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"nextAutoLevel",{get:function(){var P=this;return Math.min(Math.max(P.abrController.nextAutoLevel,P.minAutoLevel),P.maxAutoLevel)},set:function(P){var O=this;O.abrController.nextAutoLevel=Math.max(O.minAutoLevel,P)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"audioTracks",{get:function(){var P=this.audioTrackController;return P?P.audioTracks:[]},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"audioTrack",{get:function(){var P=this.audioTrackController;return P?P.audioTrack:-1},set:function(P){var O=this.audioTrackController;O&&(O.audioTrack=P)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"liveSyncPosition",{get:function(){return this.streamController.liveSyncPosition},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"subtitleTracks",{get:function(){var P=this.subtitleTrackController;return P?P.subtitleTracks:[]},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"subtitleTrack",{get:function(){var P=this.subtitleTrackController;return P?P.subtitleTrack:-1},set:function(P){var O=this.subtitleTrackController;O&&(O.subtitleTrack=P)},enumerable:!0,configurable:!0}),Object.defineProperty(w.prototype,"subtitleDisplay",{get:function(){var P=this.subtitleTrackController;return P?P.subtitleDisplay:!1},set:function(P){var O=this.subtitleTrackController;O&&(O.subtitleDisplay=P)},enumerable:!0,configurable:!0}),w}(S.Observer);t.default=A},"./src/is-supported.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/mediasource-helper.js");function l(){var u=a.getMediaSource(),f=window.SourceBuffer||window.WebKitSourceBuffer,d=u&&typeof u.isTypeSupported=="function"&&u.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),h=!f||f.prototype&&typeof f.prototype.appendBuffer=="function"&&typeof f.prototype.remove=="function";return!!d&&!!h}t.isSupported=l},"./src/loader/fragment-loader.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,_){p.__proto__=_}||function(p,_){for(var g in _)_.hasOwnProperty(g)&&(p[g]=_[g])};return function(p,_){E(p,_);function g(){this.constructor=p}p.prototype=_===null?Object.create(_):(g.prototype=_.prototype,new g)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/errors.js"),h=n("./src/utils/logger.js"),y=function(E){l(p,E);function p(_){var g=E.call(this,_,u.default.FRAG_LOADING)||this;return g.loaders={},g}return p.prototype.destroy=function(){var _=this.loaders;for(var g in _){var x=_[g];x&&x.destroy()}this.loaders={},E.prototype.destroy.call(this)},p.prototype.onFragLoading=function(_){var g=_.frag,x=g.type,C=this.loaders,R=this.hls.config,S=R.fLoader,A=R.loader;g.loaded=0;var T=C[x];T&&(h.logger.warn("abort previous fragment loader for type: "+x),T.abort()),T=C[x]=g.loader=R.fLoader?new S(R):new A(R);var w,P,O;w={url:g.url,frag:g,responseType:"arraybuffer",progressData:!1};var k=g.byteRangeStartOffset,D=g.byteRangeEndOffset;a.isFinite(k)&&a.isFinite(D)&&(w.rangeStart=k,w.rangeEnd=D),P={timeout:R.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:R.fragLoadingMaxRetryTimeout},O={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},T.load(w,P,O)},p.prototype.loadsuccess=function(_,g,x,C){C===void 0&&(C=null);var R=_.data,S=x.frag;S.loader=void 0,this.loaders[S.type]=void 0,this.hls.trigger(u.default.FRAG_LOADED,{payload:R,frag:S,stats:g,networkDetails:C})},p.prototype.loaderror=function(_,g,x){x===void 0&&(x=null);var C=g.frag,R=C.loader;R&&R.abort(),this.loaders[C.type]=void 0,this.hls.trigger(u.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:g.frag,response:_,networkDetails:x})},p.prototype.loadtimeout=function(_,g,x){x===void 0&&(x=null);var C=g.frag,R=C.loader;R&&R.abort(),this.loaders[C.type]=void 0,this.hls.trigger(u.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:g.frag,networkDetails:x})},p.prototype.loadprogress=function(_,g,x,C){C===void 0&&(C=null);var R=g.frag;R.loaded=_.loaded,this.hls.trigger(u.default.FRAG_LOAD_PROGRESS,{frag:R,stats:_,networkDetails:C})},p}(f.default);t.default=y}).call(this,n("./src/polyfills/number.js").Number)},"./src/loader/fragment.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/url-toolkit/src/url-toolkit.js"),u=n("./src/loader/level-key.js"),f=function(){function d(){var h;this._url=null,this._byteRange=null,this._decryptdata=null,this.tagList=[],this.programDateTime=null,this.rawProgramDateTime=null,this._elementaryStreams=(h={},h[d.ElementaryStreamTypes.AUDIO]=!1,h[d.ElementaryStreamTypes.VIDEO]=!1,h)}return Object.defineProperty(d,"ElementaryStreamTypes",{get:function(){return{AUDIO:"audio",VIDEO:"video"}},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"url",{get:function(){return!this._url&&this.relurl&&(this._url=l.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(h){this._url=h},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"byteRange",{get:function(){if(!this._byteRange&&!this.rawByteRange)return[];if(this._byteRange)return this._byteRange;var h=[];if(this.rawByteRange){var y=this.rawByteRange.split("@",2);if(y.length===1){var E=this.lastByteRangeEndOffset;h[0]=E||0}else h[0]=parseInt(y[1]);h[1]=parseInt(y[0])+h[0],this._byteRange=h}return h},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"byteRangeStartOffset",{get:function(){return this.byteRange[0]},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"byteRangeEndOffset",{get:function(){return this.byteRange[1]},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"decryptdata",{get:function(){return this._decryptdata||(this._decryptdata=this.fragmentDecryptdataFromLevelkey(this.levelkey,this.sn)),this._decryptdata},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"endProgramDateTime",{get:function(){if(!a.isFinite(this.programDateTime))return null;var h=a.isFinite(this.duration)?this.duration:0;return this.programDateTime+h*1e3},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"encrypted",{get:function(){return!!(this.decryptdata&&this.decryptdata.uri!==null&&this.decryptdata.key===null)},enumerable:!0,configurable:!0}),d.prototype.addElementaryStream=function(h){this._elementaryStreams[h]=!0},d.prototype.hasElementaryStream=function(h){return this._elementaryStreams[h]===!0},d.prototype.createInitializationVector=function(h){for(var y=new Uint8Array(16),E=12;E<16;E++)y[E]=h>>8*(15-E)&255;return y},d.prototype.fragmentDecryptdataFromLevelkey=function(h,y){var E=h;return h&&h.method&&h.uri&&!h.iv&&(E=new u.default,E.method=h.method,E.baseuri=h.baseuri,E.reluri=h.reluri,E.iv=this.createInitializationVector(y)),E},d}();t.default=f}).call(this,n("./src/polyfills/number.js").Number)},"./src/loader/key-loader.js":function(r,t,n){var a=this&&this.__extends||function(){var y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,p){E.__proto__=p}||function(E,p){for(var _ in p)p.hasOwnProperty(_)&&(E[_]=p[_])};return function(E,p){y(E,p);function _(){this.constructor=E}E.prototype=p===null?Object.create(p):(_.prototype=p.prototype,new _)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/events.js"),u=n("./src/event-handler.js"),f=n("./src/errors.js"),d=n("./src/utils/logger.js"),h=function(y){a(E,y);function E(p){var _=y.call(this,p,l.default.KEY_LOADING)||this;return _.loaders={},_.decryptkey=null,_.decrypturl=null,_}return E.prototype.destroy=function(){for(var p in this.loaders){var _=this.loaders[p];_&&_.destroy()}this.loaders={},u.default.prototype.destroy.call(this)},E.prototype.onKeyLoading=function(p){var _=p.frag,g=_.type,x=this.loaders[g],C=_.decryptdata,R=C.uri;if(R!==this.decrypturl||this.decryptkey===null){var S=this.hls.config;x&&(d.logger.warn("abort previous key loader for type:"+g),x.abort()),_.loader=this.loaders[g]=new S.loader(S),this.decrypturl=R,this.decryptkey=null;var A=void 0,T=void 0,w=void 0;A={url:R,frag:_,responseType:"arraybuffer"},T={timeout:S.fragLoadingTimeOut,maxRetry:0,retryDelay:S.fragLoadingRetryDelay,maxRetryDelay:S.fragLoadingMaxRetryTimeout},w={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},_.loader.load(A,T,w)}else this.decryptkey&&(C.key=this.decryptkey,this.hls.trigger(l.default.KEY_LOADED,{frag:_}))},E.prototype.loadsuccess=function(p,_,g){var x=g.frag;this.decryptkey=x.decryptdata.key=new Uint8Array(p.data),x.loader=void 0,this.loaders[x.type]=void 0,this.hls.trigger(l.default.KEY_LOADED,{frag:x})},E.prototype.loaderror=function(p,_){var g=_.frag,x=g.loader;x&&x.abort(),this.loaders[_.type]=void 0,this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:g,response:p})},E.prototype.loadtimeout=function(p,_){var g=_.frag,x=g.loader;x&&x.abort(),this.loaders[_.type]=void 0,this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:g})},E}(u.default);t.default=h},"./src/loader/level-key.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./node_modules/url-toolkit/src/url-toolkit.js"),l=function(){function u(){this.method=null,this.key=null,this.iv=null,this._uri=null}return Object.defineProperty(u.prototype,"uri",{get:function(){return!this._uri&&this.reluri&&(this._uri=a.buildAbsoluteURL(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri},enumerable:!0,configurable:!0}),u}();t.default=l},"./src/loader/level.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=function(){function u(f){this.endCC=0,this.endSN=0,this.fragments=[],this.initSegment=null,this.live=!0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=f,this.version=null}return Object.defineProperty(u.prototype,"hasProgramDateTime",{get:function(){return!!(this.fragments[0]&&a.isFinite(this.fragments[0].programDateTime))},enumerable:!0,configurable:!0}),u}();t.default=l}).call(this,n("./src/polyfills/number.js").Number)},"./src/loader/m3u8-parser.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/url-toolkit/src/url-toolkit.js"),u=n("./src/loader/fragment.js"),f=n("./src/loader/level.js"),d=n("./src/loader/level-key.js"),h=n("./src/utils/attr-list.js"),y=n("./src/utils/logger.js"),E=n("./src/utils/codecs.js"),p=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,_=/#EXT-X-MEDIA:(.*)/g,g=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),x=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,C=/\.(mp4|m4s|m4v|m4a)$/i,R=function(){function T(){}return T.findGroup=function(w,P){if(!w)return null;for(var O=null,k=0;k<w.length;k++){var D=w[k];D.id===P&&(O=D)}return O},T.convertAVC1ToAVCOTI=function(w){var P,O=w.split(".");return O.length>2?(P=O.shift()+".",P+=parseInt(O.shift()).toString(16),P+=("000"+parseInt(O.shift()).toString(16)).substr(-4)):P=w,P},T.resolve=function(w,P){return l.buildAbsoluteURL(P,w,{alwaysNormalize:!0})},T.parseMasterPlaylist=function(w,P){var O=[],k;p.lastIndex=0;function D(W,ee){["video","audio"].forEach(function(q){var z=W.filter(function($){return E.isCodecType($,q)});if(z.length){var U=z.filter(function($){return $.lastIndexOf("avc1",0)===0||$.lastIndexOf("mp4a",0)===0});ee[q+"Codec"]=U.length>0?U[0]:z[0],W=W.filter(function($){return z.indexOf($)===-1})}}),ee.unknownCodecs=W}for(;(k=p.exec(w))!=null;){var F={},G=F.attrs=new h.default(k[1]);F.url=T.resolve(k[2],P);var V=G.decimalResolution("RESOLUTION");V&&(F.width=V.width,F.height=V.height),F.bitrate=G.decimalInteger("AVERAGE-BANDWIDTH")||G.decimalInteger("BANDWIDTH"),F.name=G.NAME,D([].concat((G.CODECS||"").split(/[ ,]+/)),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=T.convertAVC1ToAVCOTI(F.videoCodec)),O.push(F)}return O},T.parseMasterPlaylistMedia=function(w,P,O,k){k===void 0&&(k=[]);var D,F=[],G=0;for(_.lastIndex=0;(D=_.exec(w))!==null;){var V={},W=new h.default(D[1]);if(W.TYPE===O){if(V.groupId=W["GROUP-ID"],V.name=W.NAME,V.type=O,V.default=W.DEFAULT==="YES",V.autoselect=W.AUTOSELECT==="YES",V.forced=W.FORCED==="YES",W.URI&&(V.url=T.resolve(W.URI,P)),V.lang=W.LANGUAGE,V.name||(V.name=V.lang),k.length){var ee=T.findGroup(k,V.groupId);V.audioCodec=ee?ee.codec:k[0].codec}V.id=G++,F.push(V)}}return F},T.parseLevelPlaylist=function(w,P,O,k,D){var F=0,G=0,V=new f.default(P),W=new d.default,ee=0,q=null,z=new u.default,U,$,I=null;for(g.lastIndex=0;(U=g.exec(w))!==null;){var B=U[1];if(B){z.duration=parseFloat(B);var X=(" "+U[2]).slice(1);z.title=X||null,z.tagList.push(X?["INF",B,X]:["INF",B])}else if(U[3]){if(a.isFinite(z.duration)){var Q=F++;z.type=k,z.start=G,z.levelkey=W,z.sn=Q,z.level=O,z.cc=ee,z.urlId=D,z.baseurl=P,z.relurl=(" "+U[3]).slice(1),A(z,q),V.fragments.push(z),q=z,G+=z.duration,z=new u.default}}else if(U[4]){if(z.rawByteRange=(" "+U[4]).slice(1),q){var J=q.byteRangeEndOffset;J&&(z.lastByteRangeEndOffset=J)}}else if(U[5])z.rawProgramDateTime=(" "+U[5]).slice(1),z.tagList.push(["PROGRAM-DATE-TIME",z.rawProgramDateTime]),I===null&&(I=V.fragments.length);else{for(U=U[0].match(x),$=1;$<U.length&&U[$]===void 0;$++);var ne=(" "+U[$+1]).slice(1),ae=(" "+U[$+2]).slice(1);switch(U[$]){case"#":z.tagList.push(ae?[ne,ae]:[ne]);break;case"PLAYLIST-TYPE":V.type=ne.toUpperCase();break;case"MEDIA-SEQUENCE":F=V.startSN=parseInt(ne);break;case"TARGETDURATION":V.targetduration=parseFloat(ne);break;case"VERSION":V.version=parseInt(ne);break;case"EXTM3U":break;case"ENDLIST":V.live=!1;break;case"DIS":ee++,z.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":ee=parseInt(ne);break;case"KEY":var Z=ne,se=new h.default(Z),oe=se.enumeratedString("METHOD"),fe=se.URI,de=se.hexadecimalInteger("IV");oe&&(W=new d.default,fe&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(oe)>=0&&(W.method=oe,W.baseuri=P,W.reluri=fe,W.key=null,W.iv=de));break;case"START":var ce=ne,Ee=new h.default(ce),De=Ee.decimalFloatingPoint("TIME-OFFSET");a.isFinite(De)&&(V.startTimeOffset=De);break;case"MAP":var we=new h.default(ne);z.relurl=we.URI,z.rawByteRange=we.BYTERANGE,z.baseurl=P,z.level=O,z.type=k,z.sn="initSegment",V.initSegment=z,z=new u.default,z.rawProgramDateTime=V.initSegment.rawProgramDateTime;break;default:y.logger.warn("line parsed but not handled: "+U);break}}}return z=q,z&&!z.relurl&&(V.fragments.pop(),G-=z.duration),V.totalduration=G,V.averagetargetduration=G/V.fragments.length,V.endSN=F-1,V.startCC=V.fragments[0]?V.fragments[0].cc:0,V.endCC=ee,!V.initSegment&&V.fragments.length&&V.fragments.every(function(He){return C.test(He.relurl)})&&(y.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),z=new u.default,z.relurl=V.fragments[0].relurl,z.baseurl=P,z.level=O,z.type=k,z.sn="initSegment",V.initSegment=z,V.needSidxRanges=!0),I&&S(V.fragments,I),V},T}();t.default=R;function S(T,w){for(var P=T[w],O=w-1;O>=0;O--){var k=T[O];k.programDateTime=P.programDateTime-k.duration*1e3,P=k}}function A(T,w){T.rawProgramDateTime?T.programDateTime=Date.parse(T.rawProgramDateTime):w&&w.programDateTime&&(T.programDateTime=w.endProgramDateTime),a.isFinite(T.programDateTime)||(T.programDateTime=null,T.rawProgramDateTime=null)}}).call(this,n("./src/polyfills/number.js").Number)},"./src/loader/playlist-loader.js":function(r,t,n){(function(a){var l=this&&this.__extends||function(){var C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,S){R.__proto__=S}||function(R,S){for(var A in S)S.hasOwnProperty(A)&&(R[A]=S[A])};return function(R,S){C(R,S);function A(){this.constructor=R}R.prototype=S===null?Object.create(S):(A.prototype=S.prototype,new A)}}();Object.defineProperty(t,"__esModule",{value:!0});var u=n("./src/events.js"),f=n("./src/event-handler.js"),d=n("./src/errors.js"),h=n("./src/utils/logger.js"),y=n("./src/demux/mp4demuxer.js"),E=n("./src/loader/m3u8-parser.js"),p=window.performance,_={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},g={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},x=function(C){l(R,C);function R(S){var A=C.call(this,S,u.default.MANIFEST_LOADING,u.default.LEVEL_LOADING,u.default.AUDIO_TRACK_LOADING,u.default.SUBTITLE_TRACK_LOADING)||this;return A.loaders={},A}return Object.defineProperty(R,"ContextType",{get:function(){return _},enumerable:!0,configurable:!0}),Object.defineProperty(R,"LevelType",{get:function(){return g},enumerable:!0,configurable:!0}),R.canHaveQualityLevels=function(S){return S!==_.AUDIO_TRACK&&S!==_.SUBTITLE_TRACK},R.mapContextToLevelType=function(S){var A=S.type;switch(A){case _.AUDIO_TRACK:return g.AUDIO;case _.SUBTITLE_TRACK:return g.SUBTITLE;default:return g.MAIN}},R.getResponseUrl=function(S,A){var T=S.url;return(T===void 0||T.indexOf("data:")===0)&&(T=A.url),T},R.prototype.createInternalLoader=function(S){var A=this.hls.config,T=A.pLoader,w=A.loader,P=T||w,O=new P(A);return S.loader=O,this.loaders[S.type]=O,O},R.prototype.getInternalLoader=function(S){return this.loaders[S.type]},R.prototype.resetInternalLoader=function(S){this.loaders[S]&&delete this.loaders[S]},R.prototype.destroyInternalLoaders=function(){for(var S in this.loaders){var A=this.loaders[S];A&&A.destroy(),this.resetInternalLoader(S)}},R.prototype.destroy=function(){this.destroyInternalLoaders(),C.prototype.destroy.call(this)},R.prototype.onManifestLoading=function(S){this.load(S.url,{type:_.MANIFEST,level:0,id:null})},R.prototype.onLevelLoading=function(S){this.load(S.url,{type:_.LEVEL,level:S.level,id:S.id})},R.prototype.onAudioTrackLoading=function(S){this.load(S.url,{type:_.AUDIO_TRACK,level:null,id:S.id})},R.prototype.onSubtitleTrackLoading=function(S){this.load(S.url,{type:_.SUBTITLE_TRACK,level:null,id:S.id})},R.prototype.load=function(S,A){var T=this.hls.config;h.logger.debug("Loading playlist of type "+A.type+", level: "+A.level+", id: "+A.id);var w=this.getInternalLoader(A);if(w){var P=w.context;if(P&&P.url===S)return h.logger.trace("playlist request ongoing"),!1;h.logger.warn("aborting previous loader for type: "+A.type),w.abort()}var O,k,D,F;switch(A.type){case _.MANIFEST:O=T.manifestLoadingMaxRetry,k=T.manifestLoadingTimeOut,D=T.manifestLoadingRetryDelay,F=T.manifestLoadingMaxRetryTimeout;break;case _.LEVEL:O=0,k=T.levelLoadingTimeOut;break;default:O=T.levelLoadingMaxRetry,k=T.levelLoadingTimeOut,D=T.levelLoadingRetryDelay,F=T.levelLoadingMaxRetryTimeout;break}w=this.createInternalLoader(A),A.url=S,A.responseType=A.responseType||"";var G={timeout:k,maxRetry:O,retryDelay:D,maxRetryDelay:F},V={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return h.logger.debug("Calling internal loader delegate for URL: "+S),w.load(A,G,V),!0},R.prototype.loadsuccess=function(S,A,T,w){if(w===void 0&&(w=null),T.isSidxRequest){this._handleSidxRequest(S,T),this._handlePlaylistLoaded(S,A,T,w);return}this.resetInternalLoader(T.type);var P=S.data;if(A.tload=p.now(),P.indexOf("#EXTM3U")!==0){this._handleManifestParsingError(S,T,"no EXTM3U delimiter",w);return}P.indexOf("#EXTINF:")>0||P.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(S,A,T,w):this._handleMasterPlaylist(S,A,T,w)},R.prototype.loaderror=function(S,A,T){T===void 0&&(T=null),this._handleNetworkError(A,T,!1,S)},R.prototype.loadtimeout=function(S,A,T){T===void 0&&(T=null),this._handleNetworkError(A,T,!0)},R.prototype._handleMasterPlaylist=function(S,A,T,w){var P=this.hls,O=S.data,k=R.getResponseUrl(S,T),D=E.default.parseMasterPlaylist(O,k);if(!D.length){this._handleManifestParsingError(S,T,"no level found in manifest",w);return}var F=D.map(function(ee){return{id:ee.attrs.AUDIO,codec:ee.audioCodec}}),G=E.default.parseMasterPlaylistMedia(O,k,"AUDIO",F),V=E.default.parseMasterPlaylistMedia(O,k,"SUBTITLES");if(G.length){var W=!1;G.forEach(function(ee){ee.url||(W=!0)}),W===!1&&D[0].audioCodec&&!D[0].attrs.AUDIO&&(h.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),G.unshift({type:"main",name:"main"}))}P.trigger(u.default.MANIFEST_LOADED,{levels:D,audioTracks:G,subtitles:V,url:k,stats:A,networkDetails:w})},R.prototype._handleTrackOrLevelPlaylist=function(S,A,T,w){var P=this.hls,O=T.id,k=T.level,D=T.type,F=R.getResponseUrl(S,T),G=a.isFinite(O)?O:0,V=a.isFinite(k)?k:G,W=R.mapContextToLevelType(T),ee=E.default.parseLevelPlaylist(S.data,F,V,W,G);if(ee.tload=A.tload,D===_.MANIFEST){var q={url:F,details:ee};P.trigger(u.default.MANIFEST_LOADED,{levels:[q],audioTracks:[],url:F,stats:A,networkDetails:w})}if(A.tparsed=p.now(),ee.needSidxRanges){var z=ee.initSegment.url;this.load(z,{isSidxRequest:!0,type:D,level:k,levelDetails:ee,id:O,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"});return}T.levelDetails=ee,this._handlePlaylistLoaded(S,A,T,w)},R.prototype._handleSidxRequest=function(S,A){var T=y.default.parseSegmentIndex(new Uint8Array(S.data));if(T){var w=T.references,P=A.levelDetails;w.forEach(function(O,k){var D=O.info,F=P.fragments[k];F.byteRange.length===0&&(F.rawByteRange=String(1+D.end-D.start)+"@"+String(D.start))}),P.initSegment.rawByteRange=String(T.moovEndOffset)+"@0"}},R.prototype._handleManifestParsingError=function(S,A,T,w){this.hls.trigger(u.default.ERROR,{type:d.ErrorTypes.NETWORK_ERROR,details:d.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:S.url,reason:T,networkDetails:w})},R.prototype._handleNetworkError=function(S,A,T,w){T===void 0&&(T=!1),w===void 0&&(w=null),h.logger.info("A network error occured while loading a "+S.type+"-type playlist");var P,O,k=this.getInternalLoader(S);switch(S.type){case _.MANIFEST:P=T?d.ErrorDetails.MANIFEST_LOAD_TIMEOUT:d.ErrorDetails.MANIFEST_LOAD_ERROR,O=!0;break;case _.LEVEL:P=T?d.ErrorDetails.LEVEL_LOAD_TIMEOUT:d.ErrorDetails.LEVEL_LOAD_ERROR,O=!1;break;case _.AUDIO_TRACK:P=T?d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,O=!1;break;default:O=!1}k&&(k.abort(),this.resetInternalLoader(S.type));var D={type:d.ErrorTypes.NETWORK_ERROR,details:P,fatal:O,url:k.url,loader:k,context:S,networkDetails:A};w&&(D.response=w),this.hls.trigger(u.default.ERROR,D)},R.prototype._handlePlaylistLoaded=function(S,A,T,w){var P=T.type,O=T.level,k=T.id,D=T.levelDetails;if(!D.targetduration){this._handleManifestParsingError(S,T,"invalid target duration",w);return}var F=R.canHaveQualityLevels(T.type);if(F)this.hls.trigger(u.default.LEVEL_LOADED,{details:D,level:O||0,id:k||0,stats:A,networkDetails:w});else switch(P){case _.AUDIO_TRACK:this.hls.trigger(u.default.AUDIO_TRACK_LOADED,{details:D,id:k,stats:A,networkDetails:w});break;case _.SUBTITLE_TRACK:this.hls.trigger(u.default.SUBTITLE_TRACK_LOADED,{details:D,id:k,stats:A,networkDetails:w});break}},R}(f.default);t.default=x}).call(this,n("./src/polyfills/number.js").Number)},"./src/observer.js":function(r,t,n){var a=this&&this.__extends||function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var y in h)h.hasOwnProperty(y)&&(d[y]=h[y])};return function(d,h){f(d,h);function y(){this.constructor=d}d.prototype=h===null?Object.create(h):(y.prototype=h.prototype,new y)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./node_modules/eventemitter3/index.js"),u=function(f){a(d,f);function d(){return f!==null&&f.apply(this,arguments)||this}return d.prototype.trigger=function(h){for(var y=[],E=1;E<arguments.length;E++)y[E-1]=arguments[E];this.emit.apply(this,[h,h].concat(y))},d}(l.EventEmitter);t.Observer=u},"./src/polyfills/number.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/get-self-scope.js"),l=a.getSelfScope(),u=l.Number;t.Number=u,u.isFinite=u.isFinite||function(f){return typeof f=="number"&&isFinite(f)}},"./src/remux/aac-helper.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(){}return l.getSilentFrame=function(u,f){switch(u){case"mp4a.40.2":if(f===1)return new Uint8Array([0,200,0,128,35,128]);if(f===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(f===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(f===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(f===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(f===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(f===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(f===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(f===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return null},l}();t.default=a},"./src/remux/mp4-generator.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=Math.pow(2,32)-1,l=function(){function u(){}return u.init=function(){u.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var f;for(f in u.types)u.types.hasOwnProperty(f)&&(u.types[f]=[f.charCodeAt(0),f.charCodeAt(1),f.charCodeAt(2),f.charCodeAt(3)]);var d=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),h=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);u.HDLR_TYPES={video:d,audio:h};var y=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),E=new Uint8Array([0,0,0,0,0,0,0,0]);u.STTS=u.STSC=u.STCO=E,u.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),u.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),u.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),u.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var p=new Uint8Array([105,115,111,109]),_=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);u.FTYP=u.box(u.types.ftyp,p,g,p,_),u.DINF=u.box(u.types.dinf,u.box(u.types.dref,y))},u.box=function(f){for(var d=Array.prototype.slice.call(arguments,1),h=8,y=d.length,E=y,p;y--;)h+=d[y].byteLength;for(p=new Uint8Array(h),p[0]=h>>24&255,p[1]=h>>16&255,p[2]=h>>8&255,p[3]=h&255,p.set(f,4),y=0,h=8;y<E;y++)p.set(d[y],h),h+=d[y].byteLength;return p},u.hdlr=function(f){return u.box(u.types.hdlr,u.HDLR_TYPES[f])},u.mdat=function(f){return u.box(u.types.mdat,f)},u.mdhd=function(f,d){d*=f;var h=Math.floor(d/(a+1)),y=Math.floor(d%(a+1));return u.box(u.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,f>>24&255,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&255,y>>24,y>>16&255,y>>8&255,y&255,85,196,0,0]))},u.mdia=function(f){return u.box(u.types.mdia,u.mdhd(f.timescale,f.duration),u.hdlr(f.type),u.minf(f))},u.mfhd=function(f){return u.box(u.types.mfhd,new Uint8Array([0,0,0,0,f>>24,f>>16&255,f>>8&255,f&255]))},u.minf=function(f){return f.type==="audio"?u.box(u.types.minf,u.box(u.types.smhd,u.SMHD),u.DINF,u.stbl(f)):u.box(u.types.minf,u.box(u.types.vmhd,u.VMHD),u.DINF,u.stbl(f))},u.moof=function(f,d,h){return u.box(u.types.moof,u.mfhd(f),u.traf(h,d))},u.moov=function(f){for(var d=f.length,h=[];d--;)h[d]=u.trak(f[d]);return u.box.apply(null,[u.types.moov,u.mvhd(f[0].timescale,f[0].duration)].concat(h).concat(u.mvex(f)))},u.mvex=function(f){for(var d=f.length,h=[];d--;)h[d]=u.trex(f[d]);return u.box.apply(null,[u.types.mvex].concat(h))},u.mvhd=function(f,d){d*=f;var h=Math.floor(d/(a+1)),y=Math.floor(d%(a+1)),E=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,f>>24&255,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&255,y>>24,y>>16&255,y>>8&255,y&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return u.box(u.types.mvhd,E)},u.sdtp=function(f){var d=f.samples||[],h=new Uint8Array(4+d.length),y,E;for(E=0;E<d.length;E++)y=d[E].flags,h[E+4]=y.dependsOn<<4|y.isDependedOn<<2|y.hasRedundancy;return u.box(u.types.sdtp,h)},u.stbl=function(f){return u.box(u.types.stbl,u.stsd(f),u.box(u.types.stts,u.STTS),u.box(u.types.stsc,u.STSC),u.box(u.types.stsz,u.STSZ),u.box(u.types.stco,u.STCO))},u.avc1=function(f){var d=[],h=[],y,E,p;for(y=0;y<f.sps.length;y++)E=f.sps[y],p=E.byteLength,d.push(p>>>8&255),d.push(p&255),d=d.concat(Array.prototype.slice.call(E));for(y=0;y<f.pps.length;y++)E=f.pps[y],p=E.byteLength,h.push(p>>>8&255),h.push(p&255),h=h.concat(Array.prototype.slice.call(E));var _=u.box(u.types.avcC,new Uint8Array([1,d[3],d[4],d[5],255,224|f.sps.length].concat(d).concat([f.pps.length]).concat(h))),g=f.width,x=f.height,C=f.pixelRatio[0],R=f.pixelRatio[1];return u.box(u.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,g>>8&255,g&255,x>>8&255,x&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),_,u.box(u.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),u.box(u.types.pasp,new Uint8Array([C>>24,C>>16&255,C>>8&255,C&255,R>>24,R>>16&255,R>>8&255,R&255])))},u.esds=function(f){var d=f.config.length;return new Uint8Array([0,0,0,0,3,23+d,0,1,0,4,15+d,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([d]).concat(f.config).concat([6,1,2]))},u.mp4a=function(f){var d=f.samplerate;return u.box(u.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,f.channelCount,0,16,0,0,0,0,d>>8&255,d&255,0,0]),u.box(u.types.esds,u.esds(f)))},u.mp3=function(f){var d=f.samplerate;return u.box(u.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,f.channelCount,0,16,0,0,0,0,d>>8&255,d&255,0,0]))},u.stsd=function(f){return f.type==="audio"?!f.isAAC&&f.codec==="mp3"?u.box(u.types.stsd,u.STSD,u.mp3(f)):u.box(u.types.stsd,u.STSD,u.mp4a(f)):u.box(u.types.stsd,u.STSD,u.avc1(f))},u.tkhd=function(f){var d=f.id,h=f.duration*f.timescale,y=f.width,E=f.height,p=Math.floor(h/(a+1)),_=Math.floor(h%(a+1));return u.box(u.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,d>>24&255,d>>16&255,d>>8&255,d&255,0,0,0,0,p>>24,p>>16&255,p>>8&255,p&255,_>>24,_>>16&255,_>>8&255,_&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,y>>8&255,y&255,0,0,E>>8&255,E&255,0,0]))},u.traf=function(f,d){var h=u.sdtp(f),y=f.id,E=Math.floor(d/(a+1)),p=Math.floor(d%(a+1));return u.box(u.types.traf,u.box(u.types.tfhd,new Uint8Array([0,0,0,0,y>>24,y>>16&255,y>>8&255,y&255])),u.box(u.types.tfdt,new Uint8Array([1,0,0,0,E>>24,E>>16&255,E>>8&255,E&255,p>>24,p>>16&255,p>>8&255,p&255])),u.trun(f,h.length+16+20+8+16+8+8),h)},u.trak=function(f){return f.duration=f.duration||4294967295,u.box(u.types.trak,u.tkhd(f),u.mdia(f))},u.trex=function(f){var d=f.id;return u.box(u.types.trex,new Uint8Array([0,0,0,0,d>>24,d>>16&255,d>>8&255,d&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},u.trun=function(f,d){var h=f.samples||[],y=h.length,E=12+16*y,p=new Uint8Array(E),_,g,x,C,R,S;for(d+=8+E,p.set([0,0,15,1,y>>>24&255,y>>>16&255,y>>>8&255,y&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255],0),_=0;_<y;_++)g=h[_],x=g.duration,C=g.size,R=g.flags,S=g.cts,p.set([x>>>24&255,x>>>16&255,x>>>8&255,x&255,C>>>24&255,C>>>16&255,C>>>8&255,C&255,R.isLeading<<2|R.dependsOn,R.isDependedOn<<6|R.hasRedundancy<<4|R.paddingValue<<1|R.isNonSync,R.degradPrio&61440,R.degradPrio&15,S>>>24&255,S>>>16&255,S>>>8&255,S&255],12+16*_);return u.box(u.types.trun,p)},u.initSegment=function(f){u.types||u.init();var d=u.moov(f),h;return h=new Uint8Array(u.FTYP.byteLength+d.byteLength),h.set(u.FTYP),h.set(d,u.FTYP.byteLength),h},u}();t.default=l},"./src/remux/mp4-remuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/remux/aac-helper.js"),l=n("./src/remux/mp4-generator.js"),u=n("./src/events.js"),f=n("./src/errors.js"),d=n("./src/utils/logger.js"),h=10*1e3,y=function(){function E(p,_,g,x){this.observer=p,this.config=_,this.typeSupported=g;var C=navigator.userAgent;this.isSafari=x&&x.indexOf("Apple")>-1&&C&&!C.match("CriOS"),this.ISGenerated=!1}return E.prototype.destroy=function(){},E.prototype.resetTimeStamp=function(p){this._initPTS=this._initDTS=p},E.prototype.resetInitSegment=function(){this.ISGenerated=!1},E.prototype.remux=function(p,_,g,x,C,R,S){if(this.ISGenerated||this.generateIS(p,_,C),this.ISGenerated){var A=p.samples.length,T=_.samples.length,w=C,P=C;if(A&&T){var O=(p.samples[0].pts-_.samples[0].pts)/_.inputTimeScale;w+=Math.max(0,O),P+=Math.max(0,-O)}if(A){p.timescale||(d.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(p,_,C));var k=this.remuxAudio(p,w,R,S);if(T){var D=void 0;k&&(D=k.endPTS-k.startPTS),_.timescale||(d.logger.warn("regenerate InitSegment as video detected"),this.generateIS(p,_,C)),this.remuxVideo(_,P,R,D,S)}}else if(T){var F=this.remuxVideo(_,P,R,0,S);F&&p.codec&&this.remuxEmptyAudio(p,w,R,F)}}g.samples.length&&this.remuxID3(g,C),x.samples.length&&this.remuxText(x,C),this.observer.trigger(u.default.FRAG_PARSED)},E.prototype.generateIS=function(p,_,g){var x=this.observer,C=p.samples,R=_.samples,S=this.typeSupported,A="audio/mp4",T={},w={tracks:T},P=this._initPTS===void 0,O,k;if(P&&(O=k=1/0),p.config&&C.length&&(p.timescale=p.samplerate,d.logger.log("audio sampling rate : "+p.samplerate),p.isAAC||(S.mpeg?(A="audio/mpeg",p.codec=""):S.mp3&&(p.codec="mp3")),T.audio={container:A,codec:p.codec,initSegment:!p.isAAC&&S.mpeg?new Uint8Array:l.default.initSegment([p]),metadata:{channelCount:p.channelCount}},P&&(O=k=C[0].pts-p.inputTimeScale*g)),_.sps&&_.pps&&R.length){var D=_.inputTimeScale;_.timescale=D,T.video={container:"video/mp4",codec:_.codec,initSegment:l.default.initSegment([_]),metadata:{width:_.width,height:_.height}},P&&(O=Math.min(O,R[0].pts-D*g),k=Math.min(k,R[0].dts-D*g),this.observer.trigger(u.default.INIT_PTS_FOUND,{initPTS:O}))}Object.keys(T).length?(x.trigger(u.default.FRAG_PARSING_INIT_SEGMENT,w),this.ISGenerated=!0,P&&(this._initPTS=O,this._initDTS=k)):x.trigger(u.default.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},E.prototype.remuxVideo=function(p,_,g,x,C){var R=8,S,A,T,w,P,O,k,D=p.timescale,F=p.samples,G=[],V=F.length,W=this._PTSNormalize,ee=this._initPTS,q=this.nextAvcDts,z=this.isSafari;if(V!==0){z&&(g|=F.length&&q&&(C&&Math.abs(_-q/D)<.1||Math.abs(F[0].pts-q-ee)<D/5)),g||(q=_*D),F.forEach(function(et){et.pts=W(et.pts-ee,q),et.dts=W(et.dts-ee,q)}),F.sort(function(et,nt){var qt=et.dts-nt.dts,We=et.pts-nt.pts;return qt||We||et.id-nt.id});var U=F.reduce(function(et,nt){return Math.max(Math.min(et,nt.pts-nt.dts),-18e3)},0);if(U<0){d.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(U/90)+" ms to overcome this issue");for(var $=0;$<F.length;$++)F[$].dts+=U}var I=F[0];P=Math.max(I.dts,0),w=Math.max(I.pts,0);var B=Math.round((P-q)/90);g&&B&&(B>1?d.logger.log("AVC:"+B+" ms hole between fragments detected,filling it"):B<-1&&d.logger.log("AVC:"+-B+" ms overlapping between fragments detected"),P=q,F[0].dts=P,w=Math.max(w-B,q),F[0].pts=w,d.logger.log("Video/PTS/DTS adjusted: "+Math.round(w/90)+"/"+Math.round(P/90)+",delta:"+B+" ms")),I=F[F.length-1],k=Math.max(I.dts,0),O=Math.max(I.pts,0,k),z&&(S=Math.round((k-P)/(F.length-1)));for(var X=0,Q=0,$=0;$<V;$++){for(var J=F[$],ne=J.units,ae=ne.length,Z=0,se=0;se<ae;se++)Z+=ne[se].data.length;Q+=Z,X+=ae,J.length=Z,z?J.dts=P+$*S:J.dts=Math.max(J.dts,P),J.pts=Math.max(J.pts,J.dts)}var oe=Q+4*X+8;try{A=new Uint8Array(oe)}catch{this.observer.trigger(u.default.ERROR,{type:f.ErrorTypes.MUX_ERROR,details:f.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:oe,reason:"fail allocating video mdat "+oe});return}var fe=new DataView(A.buffer);fe.setUint32(0,oe),A.set(l.default.types.mdat,4);for(var $=0;$<V;$++){for(var de=F[$],ce=de.units,Ee=0,De=void 0,se=0,ae=ce.length;se<ae;se++){var we=ce[se],He=we.data,Xe=we.data.byteLength;fe.setUint32(R,Xe),R+=4,A.set(He,R),R+=Xe,Ee+=4+Xe}if(z)De=Math.max(0,S*Math.round((de.pts-de.dts)/S));else{if($<V-1)S=F[$+1].dts-de.dts;else{var Qe=this.config,dt=de.dts-F[$>0?$-1:$].dts;if(Qe.stretchShortVideoTrack){var _t=Qe.maxBufferHole,ut=Math.floor(_t*D),ft=(x?w+x*D:this.nextAudioPts)-de.pts;ft>ut?(S=ft-dt,S<0&&(S=dt),d.logger.log("It is approximately "+ft/90+" ms to the next segment; using duration "+S/90+" ms for the last video frame.")):S=dt}else S=dt}De=Math.round(de.pts-de.dts)}G.push({size:Ee,duration:S,cts:De,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:de.key?2:1,isNonSync:de.key?0:1}})}this.nextAvcDts=k+S;var Xt=p.dropped;if(p.len=0,p.nbNalu=0,p.dropped=0,G.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var kt=G[0].flags;kt.dependsOn=2,kt.isNonSync=0}p.samples=G,T=l.default.moof(p.sequenceNumber++,P,p),p.samples=[];var Ue={data1:T,data2:A,startPTS:w/D,endPTS:(O+S)/D,startDTS:P/D,endDTS:this.nextAvcDts/D,type:"video",hasAudio:!1,hasVideo:!0,nb:G.length,dropped:Xt};return this.observer.trigger(u.default.FRAG_PARSING_DATA,Ue),Ue}},E.prototype.remuxAudio=function(p,_,g,x){var C=p.inputTimeScale,R=p.timescale,S=C/R,A=p.isAAC?1024:1152,T=A*S,w=this._PTSNormalize,P=this._initPTS,O=!p.isAAC&&this.typeSupported.mpeg,k,D,F,G,V,W,ee,q=p.samples,z=[],U=this.nextAudioPts;if(g|=q.length&&U&&(x&&Math.abs(_-U/C)<.1||Math.abs(q[0].pts-U-P)<20*T),q.forEach(function(ft){ft.pts=ft.dts=w(ft.pts-P,_*C)}),q=q.filter(function(ft){return ft.pts>=0}),q.length!==0){if(g||(x?U=_*C:U=q[0].pts),p.isAAC)for(var $=this.config.maxAudioFramesDrift,I=0,B=U;I<q.length;){var X=q[I],Q,J=X.pts;Q=J-B;var ne=Math.abs(1e3*Q/C);if(Q<=-$*T)d.logger.warn("Dropping 1 audio frame @ "+(B/C).toFixed(3)+"s due to "+Math.round(ne)+" ms overlap."),q.splice(I,1),p.len-=X.unit.length;else if(Q>=$*T&&ne<h&&B){var ae=Math.round(Q/T);d.logger.warn("Injecting "+ae+" audio frame @ "+(B/C).toFixed(3)+"s due to "+Math.round(1e3*Q/C)+" ms gap.");for(var Z=0;Z<ae;Z++){var se=Math.max(B,0);F=a.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount),F||(d.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),F=X.unit.subarray()),q.splice(I,0,{unit:F,pts:se,dts:se}),p.len+=F.length,B+=T,I++}X.pts=X.dts=B,B+=T,I++}else X.pts=X.dts=B,B+=T,I++}for(var Z=0,oe=q.length;Z<oe;Z++){var fe=q[Z],de=fe.unit,J=fe.pts;if(ee!==void 0)D.duration=Math.round((J-ee)/S);else{var ce=Math.round(1e3*(J-U)/C),Ee=0;if(g&&p.isAAC&&ce){if(ce>0&&ce<h)Ee=Math.round((J-U)/T),d.logger.log(ce+" ms hole between AAC samples detected,filling it"),Ee>0&&(F=a.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount),F||(F=de.subarray()),p.len+=Ee*F.length);else if(ce<-12){d.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(U/C).toFixed(3)+"s/"+(J/C).toFixed(3)+"s/"+-ce+"ms"),p.len-=de.byteLength;continue}J=U}if(W=J,p.len>0){var De=O?p.len:p.len+8;k=O?0:8;try{G=new Uint8Array(De)}catch{this.observer.trigger(u.default.ERROR,{type:f.ErrorTypes.MUX_ERROR,details:f.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:De,reason:"fail allocating audio mdat "+De});return}if(!O){var we=new DataView(G.buffer);we.setUint32(0,De),G.set(l.default.types.mdat,4)}}else return;for(var I=0;I<Ee;I++)F=a.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount),F||(d.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),F=de.subarray()),G.set(F,k),k+=F.byteLength,D={size:F.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},z.push(D)}G.set(de,k);var He=de.byteLength;k+=He,D={size:He,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},z.push(D),ee=J}var Xe=0,Qe=z.length;if(Qe>=2&&(Xe=z[Qe-2].duration,D.duration=Xe),Qe){this.nextAudioPts=U=ee+S*Xe,p.len=0,p.samples=z,O?V=new Uint8Array:V=l.default.moof(p.sequenceNumber++,W/S,p),p.samples=[];var dt=W/C,_t=U/C,ut={data1:V,data2:G,startPTS:dt,endPTS:_t,startDTS:dt,endDTS:_t,type:"audio",hasAudio:!0,hasVideo:!1,nb:Qe};return this.observer.trigger(u.default.FRAG_PARSING_DATA,ut),ut}return null}},E.prototype.remuxEmptyAudio=function(p,_,g,x){var C=p.inputTimeScale,R=p.samplerate?p.samplerate:C,S=C/R,A=this.nextAudioPts,T=(A!==void 0?A:x.startDTS*C)+this._initDTS,w=x.endDTS*C+this._initDTS,P=1024,O=S*P,k=Math.ceil((w-T)/O),D=a.default.getSilentFrame(p.manifestCodec||p.codec,p.channelCount);if(d.logger.warn("remux empty Audio"),!D){d.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");return}for(var F=[],G=0;G<k;G++){var V=T+G*O;F.push({unit:D,pts:V,dts:V}),p.len+=D.length}p.samples=F,this.remuxAudio(p,_,g)},E.prototype.remuxID3=function(p){var _=p.samples.length,g,x=p.inputTimeScale,C=this._initPTS,R=this._initDTS;if(_){for(var S=0;S<_;S++)g=p.samples[S],g.pts=(g.pts-C)/x,g.dts=(g.dts-R)/x;this.observer.trigger(u.default.FRAG_PARSING_METADATA,{samples:p.samples})}p.samples=[]},E.prototype.remuxText=function(p){p.samples.sort(function(S,A){return S.pts-A.pts});var _=p.samples.length,g,x=p.inputTimeScale,C=this._initPTS;if(_){for(var R=0;R<_;R++)g=p.samples[R],g.pts=(g.pts-C)/x;this.observer.trigger(u.default.FRAG_PARSING_USERDATA,{samples:p.samples})}p.samples=[]},E.prototype._PTSNormalize=function(p,_){var g;if(_===void 0)return p;for(_<p?g=-8589934592:g=8589934592;Math.abs(p-_)>4294967296;)p+=g;return p},E}();t.default=y},"./src/remux/passthrough-remuxer.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/events.js"),l=function(){function u(f){this.observer=f}return u.prototype.destroy=function(){},u.prototype.resetTimeStamp=function(){},u.prototype.resetInitSegment=function(){},u.prototype.remux=function(f,d,h,y,E,p,_,g){var x=this.observer,C="";f&&(C+="audio"),d&&(C+="video"),x.trigger(a.default.FRAG_PARSING_DATA,{data1:g,startPTS:E,startDTS:E,type:C,hasAudio:!!f,hasVideo:!!d,nb:1,dropped:0}),x.trigger(a.default.FRAG_PARSED)},u}();t.default=l},"./src/task-loop.js":function(r,t,n){var a=this&&this.__extends||function(){var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var y in h)h.hasOwnProperty(y)&&(d[y]=h[y])};return function(d,h){f(d,h);function y(){this.constructor=d}d.prototype=h===null?Object.create(h):(y.prototype=h.prototype,new y)}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/event-handler.js"),u=function(f){a(d,f);function d(h){for(var y=[],E=1;E<arguments.length;E++)y[E-1]=arguments[E];var p=f.apply(this,[h].concat(y))||this;return p._tickInterval=null,p._tickTimer=null,p._tickCallCount=0,p._boundTick=p.tick.bind(p),p}return d.prototype.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},d.prototype.hasInterval=function(){return!!this._tickInterval},d.prototype.hasNextTick=function(){return!!this._tickTimer},d.prototype.setInterval=function(h){return this._tickInterval?!1:(this._tickInterval=setInterval(this._boundTick,h),!0)},d.prototype.clearInterval=function(){return this._tickInterval?(clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},d.prototype.clearNextTick=function(){return this._tickTimer?(clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},d.prototype.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=setTimeout(this._boundTick,0)),this._tickCallCount=0)},d.prototype.doTick=function(){},d}(l.default);t.default=u},"./src/utils/attr-list.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=/^(\d+)x(\d+)$/,u=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,f=function(){function d(h){typeof h=="string"&&(h=d.parseAttrList(h));for(var y in h)h.hasOwnProperty(y)&&(this[y]=h[y])}return d.prototype.decimalInteger=function(h){var y=parseInt(this[h],10);return y>a.MAX_SAFE_INTEGER?1/0:y},d.prototype.hexadecimalInteger=function(h){if(this[h]){var y=(this[h]||"0x").slice(2);y=(y.length&1?"0":"")+y;for(var E=new Uint8Array(y.length/2),p=0;p<y.length/2;p++)E[p]=parseInt(y.slice(p*2,p*2+2),16);return E}else return null},d.prototype.hexadecimalIntegerAsNumber=function(h){var y=parseInt(this[h],16);return y>a.MAX_SAFE_INTEGER?1/0:y},d.prototype.decimalFloatingPoint=function(h){return parseFloat(this[h])},d.prototype.enumeratedString=function(h){return this[h]},d.prototype.decimalResolution=function(h){var y=l.exec(this[h]);if(y!==null)return{width:parseInt(y[1],10),height:parseInt(y[2],10)}},d.parseAttrList=function(h){var y,E={};for(u.lastIndex=0;(y=u.exec(h))!==null;){var p=y[2],_='"';p.indexOf(_)===0&&p.lastIndexOf(_)===p.length-1&&(p=p.slice(1,-1)),E[y[1]]=p}return E},d}();t.default=f}).call(this,n("./src/polyfills/number.js").Number)},"./src/utils/binary-search.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={search:function(l,u){for(var f=0,d=l.length-1,h=null,y=null;f<=d;){h=(f+d)/2|0,y=l[h];var E=u(y);if(E>0)f=h+1;else if(E<0)d=h-1;else return y}return null}};t.default=a},"./src/utils/buffer-helper.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(){}return l.isBuffered=function(u,f){try{if(u){for(var d=u.buffered,h=0;h<d.length;h++)if(f>=d.start(h)&&f<=d.end(h))return!0}}catch{}return!1},l.bufferInfo=function(u,f,d){try{if(u){var h=u.buffered,y=[],E=void 0;for(E=0;E<h.length;E++)y.push({start:h.start(E),end:h.end(E)});return this.bufferedInfo(y,f,d)}}catch{}return{len:0,start:f,end:f,nextStart:void 0}},l.bufferedInfo=function(u,f,d){var h=[],y,E,p,_,g;for(u.sort(function(A,T){var w=A.start-T.start;return w||T.end-A.end}),g=0;g<u.length;g++){var x=h.length;if(x){var C=h[x-1].end;u[g].start-C<d?u[g].end>C&&(h[x-1].end=u[g].end):h.push(u[g])}else h.push(u[g])}for(g=0,y=0,E=p=f;g<h.length;g++){var R=h[g].start,S=h[g].end;if(f+d>=R&&f<S)E=R,p=S,y=p-f;else if(f+d<R){_=R;break}}return{len:y,start:E,end:p,nextStart:_}},l}();t.BufferHelper=a},"./src/utils/cea-608-parser.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},l=function(w){var P=w;return a.hasOwnProperty(w)&&(P=a[w]),String.fromCharCode(P)},u=15,f=100,d={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},h={17:2,18:4,21:6,22:8,23:10,19:13,20:15},y={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},E={25:2,26:4,29:6,30:8,31:10,27:13,28:15},p=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],_={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(w){this.time=w},log:function(w,P){var O=this.verboseFilter[w];this.verboseLevel>=O}},g=function(w){for(var P=[],O=0;O<w.length;O++)P.push(w[O].toString(16));return P},x=function(){function w(P,O,k,D,F){this.foreground=P||"white",this.underline=O||!1,this.italics=k||!1,this.background=D||"black",this.flash=F||!1}return w.prototype.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},w.prototype.setStyles=function(P){for(var O=["foreground","underline","italics","background","flash"],k=0;k<O.length;k++){var D=O[k];P.hasOwnProperty(D)&&(this[D]=P[D])}},w.prototype.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},w.prototype.equals=function(P){return this.foreground===P.foreground&&this.underline===P.underline&&this.italics===P.italics&&this.background===P.background&&this.flash===P.flash},w.prototype.copy=function(P){this.foreground=P.foreground,this.underline=P.underline,this.italics=P.italics,this.background=P.background,this.flash=P.flash},w.prototype.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},w}(),C=function(){function w(P,O,k,D,F,G){this.uchar=P||" ",this.penState=new x(O,k,D,F,G)}return w.prototype.reset=function(){this.uchar=" ",this.penState.reset()},w.prototype.setChar=function(P,O){this.uchar=P,this.penState.copy(O)},w.prototype.setPenState=function(P){this.penState.copy(P)},w.prototype.equals=function(P){return this.uchar===P.uchar&&this.penState.equals(P.penState)},w.prototype.copy=function(P){this.uchar=P.uchar,this.penState.copy(P.penState)},w.prototype.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},w}(),R=function(){function w(){this.chars=[];for(var P=0;P<f;P++)this.chars.push(new C);this.pos=0,this.currPenState=new x}return w.prototype.equals=function(P){for(var O=!0,k=0;k<f;k++)if(!this.chars[k].equals(P.chars[k])){O=!1;break}return O},w.prototype.copy=function(P){for(var O=0;O<f;O++)this.chars[O].copy(P.chars[O])},w.prototype.isEmpty=function(){for(var P=!0,O=0;O<f;O++)if(!this.chars[O].isEmpty()){P=!1;break}return P},w.prototype.setCursor=function(P){this.pos!==P&&(this.pos=P),this.pos<0?(_.log("ERROR","Negative cursor position "+this.pos),this.pos=0):this.pos>f&&(_.log("ERROR","Too large cursor position "+this.pos),this.pos=f)},w.prototype.moveCursor=function(P){var O=this.pos+P;if(P>1)for(var k=this.pos+1;k<O+1;k++)this.chars[k].setPenState(this.currPenState);this.setCursor(O)},w.prototype.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},w.prototype.insertChar=function(P){P>=144&&this.backSpace();var O=l(P);if(this.pos>=f){_.log("ERROR","Cannot insert "+P.toString(16)+" ("+O+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(O,this.currPenState),this.moveCursor(1)},w.prototype.clearFromPos=function(P){var O;for(O=P;O<f;O++)this.chars[O].reset()},w.prototype.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},w.prototype.clearToEndOfRow=function(){this.clearFromPos(this.pos)},w.prototype.getTextString=function(){for(var P=[],O=!0,k=0;k<f;k++){var D=this.chars[k].uchar;D!==" "&&(O=!1),P.push(D)}return O?"":P.join("")},w.prototype.setPenStyles=function(P){this.currPenState.setStyles(P);var O=this.chars[this.pos];O.setPenState(this.currPenState)},w}(),S=function(){function w(){this.rows=[];for(var P=0;P<u;P++)this.rows.push(new R);this.currRow=u-1,this.nrRollUpRows=null,this.reset()}return w.prototype.reset=function(){for(var P=0;P<u;P++)this.rows[P].clear();this.currRow=u-1},w.prototype.equals=function(P){for(var O=!0,k=0;k<u;k++)if(!this.rows[k].equals(P.rows[k])){O=!1;break}return O},w.prototype.copy=function(P){for(var O=0;O<u;O++)this.rows[O].copy(P.rows[O])},w.prototype.isEmpty=function(){for(var P=!0,O=0;O<u;O++)if(!this.rows[O].isEmpty()){P=!1;break}return P},w.prototype.backSpace=function(){var P=this.rows[this.currRow];P.backSpace()},w.prototype.clearToEndOfRow=function(){var P=this.rows[this.currRow];P.clearToEndOfRow()},w.prototype.insertChar=function(P){var O=this.rows[this.currRow];O.insertChar(P)},w.prototype.setPen=function(P){var O=this.rows[this.currRow];O.setPenStyles(P)},w.prototype.moveCursor=function(P){var O=this.rows[this.currRow];O.moveCursor(P)},w.prototype.setCursor=function(P){_.log("INFO","setCursor: "+P);var O=this.rows[this.currRow];O.setCursor(P)},w.prototype.setPAC=function(P){_.log("INFO","pacData = "+JSON.stringify(P));var O=P.row-1;if(this.nrRollUpRows&&O<this.nrRollUpRows-1&&(O=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==O){for(var k=0;k<u;k++)this.rows[k].clear();var D=this.currRow+1-this.nrRollUpRows,F=this.lastOutputScreen;if(F){var G=F.rows[D].cueStartTime;if(G&&G<_.time)for(var k=0;k<this.nrRollUpRows;k++)this.rows[O-this.nrRollUpRows+k+1].copy(F.rows[D+k])}}this.currRow=O;var V=this.rows[this.currRow];if(P.indent!==null){var W=P.indent,ee=Math.max(W-1,0);V.setCursor(P.indent),P.color=V.chars[ee].penState.foreground}var q={foreground:P.color,underline:P.underline,italics:P.italics,background:"black",flash:!1};this.setPen(q)},w.prototype.setBkgData=function(P){_.log("INFO","bkgData = "+JSON.stringify(P)),this.backSpace(),this.setPen(P),this.insertChar(32)},w.prototype.setRollUpRows=function(P){this.nrRollUpRows=P},w.prototype.rollUp=function(){if(this.nrRollUpRows===null){_.log("DEBUG","roll_up but nrRollUpRows not set yet");return}_.log("TEXT",this.getDisplayText());var P=this.currRow+1-this.nrRollUpRows,O=this.rows.splice(P,1)[0];O.clear(),this.rows.splice(this.currRow,0,O),_.log("INFO","Rolling up")},w.prototype.getDisplayText=function(P){P=P||!1;for(var O=[],k="",D=-1,F=0;F<u;F++){var G=this.rows[F].getTextString();G&&(D=F+1,P?O.push("Row "+D+": '"+G+"'"):O.push(G.trim()))}return O.length>0&&(P?k="["+O.join(" | ")+"]":k=O.join(`
|
|
54
54
|
`)),k},w.prototype.getTextAndFormat=function(){return this.rows},w}(),A=function(){function w(P,O){this.chNr=P,this.outputFilter=O,this.mode=null,this.verbose=0,this.displayedMemory=new S,this.nonDisplayedMemory=new S,this.lastOutputScreen=new S,this.currRollUpRow=this.displayedMemory.rows[u-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return w.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[u-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null},w.prototype.getHandler=function(){return this.outputFilter},w.prototype.setHandler=function(P){this.outputFilter=P},w.prototype.setPAC=function(P){this.writeScreen.setPAC(P)},w.prototype.setBkgData=function(P){this.writeScreen.setBkgData(P)},w.prototype.setMode=function(P){P!==this.mode&&(this.mode=P,_.log("INFO","MODE="+P),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=P)},w.prototype.insertChars=function(P){for(var O=0;O<P.length;O++)this.writeScreen.insertChar(P[O]);var k=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";_.log("INFO",k+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(_.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},w.prototype.ccRCL=function(){_.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},w.prototype.ccBS=function(){_.log("INFO","BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},w.prototype.ccAOF=function(){},w.prototype.ccAON=function(){},w.prototype.ccDER=function(){_.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},w.prototype.ccRU=function(P){_.log("INFO","RU("+P+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(P)},w.prototype.ccFON=function(){_.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})},w.prototype.ccRDC=function(){_.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},w.prototype.ccTR=function(){_.log("INFO","TR"),this.setMode("MODE_TEXT")},w.prototype.ccRTD=function(){_.log("INFO","RTD"),this.setMode("MODE_TEXT")},w.prototype.ccEDM=function(){_.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},w.prototype.ccCR=function(){_.log("CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},w.prototype.ccENM=function(){_.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},w.prototype.ccEOC=function(){if(_.log("INFO","EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var P=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=P,this.writeScreen=this.nonDisplayedMemory,_.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},w.prototype.ccTO=function(P){_.log("INFO","TO("+P+") - Tab Offset"),this.writeScreen.moveCursor(P)},w.prototype.ccMIDROW=function(P){var O={flash:!1};if(O.underline=P%2===1,O.italics=P>=46,O.italics)O.foreground="white";else{var k=Math.floor(P/2)-16,D=["white","green","blue","cyan","red","yellow","magenta"];O.foreground=D[k]}_.log("INFO","MIDROW: "+JSON.stringify(O)),this.writeScreen.setPen(O)},w.prototype.outputDataUpdate=function(P){P===void 0&&(P=!1);var O=_.time;O!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=O:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&(this.outputFilter.newCue(this.cueStartTime,O,this.lastOutputScreen),P===!0&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue()),this.cueStartTime=this.displayedMemory.isEmpty()?null:O),this.lastOutputScreen.copy(this.displayedMemory))},w.prototype.cueSplitAtTime=function(P){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,P,this.displayedMemory),this.cueStartTime=P))},w}(),T=function(){function w(P,O,k){this.field=P||1,this.outputs=[O,k],this.channels=[new A(1,O),new A(2,k)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return w.prototype.getHandler=function(P){return this.channels[P].getHandler()},w.prototype.setHandler=function(P,O){this.channels[P].setHandler(O)},w.prototype.addData=function(P,O){var k,D,F,G=!1;this.lastTime=P,_.setTime(P);for(var V=0;V<O.length;V+=2){if(D=O[V]&127,F=O[V+1]&127,D===0&&F===0){this.dataCounters.padding+=2;continue}else _.log("DATA","["+g([O[V],O[V+1]])+"] -> ("+g([D,F])+")");if(k=this.parseCmd(D,F),k||(k=this.parseMidrow(D,F)),k||(k=this.parsePAC(D,F)),k||(k=this.parseBackgroundAttributes(D,F)),!k&&(G=this.parseChars(D,F),G))if(this.currChNr&&this.currChNr>=0){var W=this.channels[this.currChNr-1];W.insertChars(G)}else _.log("WARNING","No channel found yet. TEXT-MODE?");k?this.dataCounters.cmd+=2:G?this.dataCounters.char+=2:(this.dataCounters.other+=2,_.log("WARNING","Couldn't parse cleaned data "+g([D,F])+" orig: "+g([O[V],O[V+1]])))}},w.prototype.parseCmd=function(P,O){var k=null,D=(P===20||P===28)&&O>=32&&O<=47,F=(P===23||P===31)&&O>=33&&O<=35;if(!(D||F))return!1;if(P===this.lastCmdA&&O===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,_.log("DEBUG","Repeated command ("+g([P,O])+") is dropped"),!0;P===20||P===23?k=1:k=2;var G=this.channels[k-1];return P===20||P===28?O===32?G.ccRCL():O===33?G.ccBS():O===34?G.ccAOF():O===35?G.ccAON():O===36?G.ccDER():O===37?G.ccRU(2):O===38?G.ccRU(3):O===39?G.ccRU(4):O===40?G.ccFON():O===41?G.ccRDC():O===42?G.ccTR():O===43?G.ccRTD():O===44?G.ccEDM():O===45?G.ccCR():O===46?G.ccENM():O===47&&G.ccEOC():G.ccTO(O-32),this.lastCmdA=P,this.lastCmdB=O,this.currChNr=k,!0},w.prototype.parseMidrow=function(P,O){var k=null;if((P===17||P===25)&&O>=32&&O<=47){if(P===17?k=1:k=2,k!==this.currChNr)return _.log("ERROR","Mismatch channel in midrow parsing"),!1;var D=this.channels[k-1];return D.ccMIDROW(O),_.log("DEBUG","MIDROW ("+g([P,O])+")"),!0}return!1},w.prototype.parsePAC=function(P,O){var k=null,D=null,F=(P>=17&&P<=23||P>=25&&P<=31)&&O>=64&&O<=127,G=(P===16||P===24)&&O>=64&&O<=95;if(!(F||G))return!1;if(P===this.lastCmdA&&O===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;k=P<=23?1:2,O>=64&&O<=95?D=k===1?d[P]:y[P]:D=k===1?h[P]:E[P];var V=this.interpretPAC(D,O),W=this.channels[k-1];return W.setPAC(V),this.lastCmdA=P,this.lastCmdB=O,this.currChNr=k,!0},w.prototype.interpretPAC=function(P,O){var k=O,D={color:null,italics:!1,indent:null,underline:!1,row:P};return O>95?k=O-96:k=O-64,D.underline=(k&1)===1,k<=13?D.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(k/2)]:k<=15?(D.italics=!0,D.color="white"):D.indent=Math.floor((k-16)/2)*4,D},w.prototype.parseChars=function(P,O){var k=null,D=null,F=null;if(P>=25?(k=2,F=P-8):(k=1,F=P),F>=17&&F<=19){var G=O;F===17?G=O+80:F===18?G=O+112:G=O+144,_.log("INFO","Special char '"+l(G)+"' in channel "+k),D=[G]}else P>=32&&P<=127&&(D=O===0?[P]:[P,O]);if(D){var V=g(D);_.log("DEBUG","Char codes = "+V.join(",")),this.lastCmdA=null,this.lastCmdB=null}return D},w.prototype.parseBackgroundAttributes=function(P,O){var k,D,F,G,V=(P===16||P===24)&&O>=32&&O<=47,W=(P===23||P===31)&&O>=45&&O<=47;return V||W?(k={},P===16||P===24?(D=Math.floor((O-32)/2),k.background=p[D],O%2===1&&(k.background=k.background+"_semi")):O===45?k.background="transparent":(k.foreground="black",O===47&&(k.underline=!0)),F=P<24?1:2,G=this.channels[F-1],G.setBkgData(k),this.lastCmdA=null,this.lastCmdB=null,!0):!1},w.prototype.reset=function(){for(var P=0;P<this.channels.length;P++)this.channels[P]&&this.channels[P].reset();this.lastCmdA=null,this.lastCmdB=null},w.prototype.cueSplitAtTime=function(P){for(var O=0;O<this.channels.length;O++)this.channels[O]&&this.channels[O].cueSplitAtTime(P)},w}();t.default=T},"./src/utils/codecs.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}};function l(f,d){var h=a[d];return!!h&&h[f.slice(0,4)]===!0}t.isCodecType=l;function u(f,d){return window.MediaSource.isTypeSupported((d||"video")+'/mp4;codecs="'+f+'"')}t.isCodecSupportedInMp4=u},"./src/utils/cues.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/vttparser.js");function l(u,f,d,h){for(var y,E,p,_,g,x=window.VTTCue||window.TextTrackCue,C=0;C<h.rows.length;C++)if(y=h.rows[C],p=!0,_=0,g="",!y.isEmpty()){for(var R=0;R<y.chars.length;R++)y.chars[R].uchar.match(/\s/)&&p?_++:(g+=y.chars[R].uchar,p=!1);y.cueStartTime=f,f===d&&(d+=1e-4),E=new x(f,d,a.fixLineBreaks(g.trim())),_>=16?_--:_++,navigator.userAgent.match(/Firefox\//)?E.line=C+1:E.line=C>7?C-2:C+1,E.align="left",E.position=Math.max(0,Math.min(100,100*(_/32)+(navigator.userAgent.match(/Firefox\//)?50:0))),u.addCue(E)}}t.newCue=l},"./src/utils/discontinuities.js":function(r,t,n){(function(a){Object.defineProperty(t,"__esModule",{value:!0});var l=n("./src/utils/binary-search.js"),u=n("./src/utils/logger.js");function f(x,C){for(var R=null,S=0;S<x.length;S+=1){var A=x[S];if(A&&A.cc===C){R=A;break}}return R}t.findFirstFragWithCC=f;function d(x,C){return l.default.search(x,function(R){return R.cc<C?1:R.cc>C?-1:0})}t.findFragWithCC=d;function h(x,C,R){var S=!1;return C&&C.details&&R&&(R.endCC>R.startCC||x&&x.cc<R.startCC)&&(S=!0),S}t.shouldAlignOnDiscontinuities=h;function y(x,C){var R=x.fragments,S=C.fragments;if(!S.length||!R.length){u.logger.log("No fragments to align");return}var A=f(R,S[0].cc);if(!A||A&&!A.startPTS){u.logger.log("No frag in previous level to align on");return}return A}t.findDiscontinuousReferenceFrag=y;function E(x,C){C.fragments.forEach(function(R){if(R){var S=R.start+x;R.start=R.startPTS=S,R.endPTS=S+R.duration}}),C.PTSKnown=!0}t.adjustPts=E;function p(x,C,R){_(x,R,C),!R.PTSKnown&&C&&g(R,C.details)}t.alignStream=p;function _(x,C,R){if(h(x,R,C)){var S=y(R.details,C);S&&(u.logger.log("Adjusting PTS using last level due to CC increase within current level"),E(S.start,C))}}t.alignDiscontinuities=_;function g(x,C){if(C&&C.fragments.length){if(!x.hasProgramDateTime||!C.hasProgramDateTime)return;var R=C.fragments[0].programDateTime,S=x.fragments[0].programDateTime,A=(S-R)/1e3+C.fragments[0].start;a.isFinite(A)&&(u.logger.log("adjusting PTS using programDateTime delta, sliding:"+A.toFixed(3)),E(A,x))}}t.alignPDT=g}).call(this,n("./src/polyfills/number.js").Number)},"./src/utils/ewma-bandwidth-estimator.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/ewma.js"),l=function(){function u(f,d,h,y){this.hls=f,this.defaultEstimate_=y,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new a.default(d),this.fast_=new a.default(h)}return u.prototype.sample=function(f,d){f=Math.max(f,this.minDelayMs_);var h=8e3*d/f,y=f/1e3;this.fast_.sample(y,h),this.slow_.sample(y,h)},u.prototype.canEstimate=function(){var f=this.fast_;return f&&f.getTotalWeight()>=this.minWeight_},u.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},u.prototype.destroy=function(){},u}();t.default=l},"./src/utils/ewma.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(u){this.alpha_=u?Math.exp(Math.log(.5)/u):0,this.estimate_=0,this.totalWeight_=0}return l.prototype.sample=function(u,f){var d=Math.pow(this.alpha_,u);this.estimate_=f*(1-d)+d*this.estimate_,this.totalWeight_+=u},l.prototype.getTotalWeight=function(){return this.totalWeight_},l.prototype.getEstimate=function(){if(this.alpha_){var u=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/u}else return this.estimate_},l}();t.default=a},"./src/utils/get-self-scope.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});function a(){return typeof window>"u"?self:window}t.getSelfScope=a},"./src/utils/logger.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/get-self-scope.js");function l(){}var u={trace:l,debug:l,log:l,warn:l,info:l,error:l},f=u;function d(p,_){return _="["+p+"] > "+_,_}var h=a.getSelfScope();function y(p){var _=h.console[p];return _?function(){for(var g=[],x=0;x<arguments.length;x++)g[x]=arguments[x];g[0]&&(g[0]=d(p,g[0])),_.apply(h.console,g)}:l}function E(p){for(var _=[],g=1;g<arguments.length;g++)_[g-1]=arguments[g];_.forEach(function(x){f[x]=p[x]?p[x].bind(p):y(x)})}t.enableLogs=function(p){if(p===!0||typeof p=="object"){E(p,"debug","log","info","warn","error");try{f.log()}catch{f=u}}else f=u},t.logger=f},"./src/utils/mediakeys-helper.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){return typeof window<"u"&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null}();t.requestMediaKeySystemAccess=a},"./src/utils/mediasource-helper.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});function a(){if(typeof window<"u")return window.MediaSource||window.WebKitMediaSource}t.getMediaSource=a},"./src/utils/output-filter.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function l(u,f){this.timelineController=u,this.trackName=f,this.startTime=null,this.endTime=null,this.screen=null}return l.prototype.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen),this.startTime=null)},l.prototype.newCue=function(u,f,d){(this.startTime===null||this.startTime>u)&&(this.startTime=u),this.endTime=f,this.screen=d,this.timelineController.createCaptionsTrack(this.trackName)},l}();t.default=a},"./src/utils/texttrack-utils.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});function a(u,f){var d=null;try{d=new window.Event("addtrack")}catch{d=document.createEvent("Event"),d.initEvent("addtrack",!1,!1)}d.track=u,f.dispatchEvent(d)}t.sendAddTrackEvent=a;function l(u){if(u&&u.cues)for(;u.cues.length>0;)u.removeCue(u.cues[0])}t.clearCurrentCues=l},"./src/utils/time-ranges.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a={toString:function(l){for(var u="",f=l.length,d=0;d<f;d++)u+="["+l.start(d).toFixed(3)+","+l.end(d).toFixed(3)+"]";return u}};t.default=a},"./src/utils/vttcue.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(typeof window<"u"&&window.VTTCue)return window.VTTCue;var a="auto",l={"":!0,lr:!0,rl:!0},u={start:!0,middle:!0,end:!0,left:!0,right:!0};function f(E){if(typeof E!="string")return!1;var p=l[E.toLowerCase()];return p?E.toLowerCase():!1}function d(E){if(typeof E!="string")return!1;var p=u[E.toLowerCase()];return p?E.toLowerCase():!1}function h(E){for(var p=1;p<arguments.length;p++){var _=arguments[p];for(var g in _)E[g]=_[g]}return E}function y(E,p,_){var g=this,x=function(){if(!(typeof navigator>"u"))return/MSIE\s8\.0/.test(navigator.userAgent)}(),C={};x?g=document.createElement("custom"):C.enumerable=!0,g.hasBeenReset=!1;var R="",S=!1,A=E,T=p,w=_,P=null,O="",k=!0,D="auto",F="start",G=50,V="middle",W=50,ee="middle";if(Object.defineProperty(g,"id",h({},C,{get:function(){return R},set:function(q){R=""+q}})),Object.defineProperty(g,"pauseOnExit",h({},C,{get:function(){return S},set:function(q){S=!!q}})),Object.defineProperty(g,"startTime",h({},C,{get:function(){return A},set:function(q){if(typeof q!="number")throw new TypeError("Start time must be set to a number.");A=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",h({},C,{get:function(){return T},set:function(q){if(typeof q!="number")throw new TypeError("End time must be set to a number.");T=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",h({},C,{get:function(){return w},set:function(q){w=""+q,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",h({},C,{get:function(){return P},set:function(q){P=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",h({},C,{get:function(){return O},set:function(q){var z=f(q);if(z===!1)throw new SyntaxError("An invalid or illegal string was specified.");O=z,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",h({},C,{get:function(){return k},set:function(q){k=!!q,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",h({},C,{get:function(){return D},set:function(q){if(typeof q!="number"&&q!==a)throw new SyntaxError("An invalid number or illegal string was specified.");D=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",h({},C,{get:function(){return F},set:function(q){var z=d(q);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");F=z,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",h({},C,{get:function(){return G},set:function(q){if(q<0||q>100)throw new Error("Position must be between 0 and 100.");G=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",h({},C,{get:function(){return V},set:function(q){var z=d(q);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");V=z,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",h({},C,{get:function(){return W},set:function(q){if(q<0||q>100)throw new Error("Size must be between 0 and 100.");W=q,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",h({},C,{get:function(){return ee},set:function(q){var z=d(q);if(!z)throw new SyntaxError("An invalid or illegal string was specified.");ee=z,this.hasBeenReset=!0}})),g.displayState=void 0,x)return g}return y.prototype.getCueAsHTML=function(){var E=window.WebVTT;return E.convertCueToDOMTree(window,this.text)},y}()},"./src/utils/vttparser.js":function(r,t,n){Object.defineProperty(t,"__esModule",{value:!0});var a=n("./src/utils/vttcue.js"),l=function(){return{decode:function(x){if(!x)return"";if(typeof x!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(x))}}};function u(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new l,this.regionList=[]}function f(g){function x(R,S,A,T){return(R|0)*3600+(S|0)*60+(A|0)+(T|0)/1e3}var C=g.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return C?C[3]?x(C[1],C[2],C[3].replace(":",""),C[4]):C[1]>59?x(C[1],C[2],0,C[4]):x(0,C[1],C[2],C[4]):null}function d(){this.values=Object.create(null)}d.prototype={set:function(g,x){!this.get(g)&&x!==""&&(this.values[g]=x)},get:function(g,x,C){return C?this.has(g)?this.values[g]:x[C]:this.has(g)?this.values[g]:x},has:function(g){return g in this.values},alt:function(g,x,C){for(var R=0;R<C.length;++R)if(x===C[R]){this.set(g,x);break}},integer:function(g,x){/^-?\d+$/.test(x)&&this.set(g,parseInt(x,10))},percent:function(g,x){return x.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(x=parseFloat(x),x>=0&&x<=100)?(this.set(g,x),!0):!1}};function h(g,x,C,R){var S=R?g.split(R):[g];for(var A in S)if(typeof S[A]=="string"){var T=S[A].split(C);if(T.length===2){var w=T[0],P=T[1];x(w,P)}}}var y=new a.default(0,0,0),E=y.align==="middle"?"middle":"center";function p(g,x,C){var R=g;function S(){var w=f(g);if(w===null)throw new Error("Malformed timestamp: "+R);return g=g.replace(/^[^\sa-zA-Z-]+/,""),w}function A(w,P){var O=new d;h(w,function(F,G){switch(F){case"region":for(var V=C.length-1;V>=0;V--)if(C[V].id===G){O.set(F,C[V].region);break}break;case"vertical":O.alt(F,G,["rl","lr"]);break;case"line":var W=G.split(","),ee=W[0];O.integer(F,ee),O.percent(F,ee)&&O.set("snapToLines",!1),O.alt(F,ee,["auto"]),W.length===2&&O.alt("lineAlign",W[1],["start",E,"end"]);break;case"position":W=G.split(","),O.percent(F,W[0]),W.length===2&&O.alt("positionAlign",W[1],["start",E,"end","line-left","line-right","auto"]);break;case"size":O.percent(F,G);break;case"align":O.alt(F,G,["start",E,"end","left","right"]);break}},/:/,/\s/),P.region=O.get("region",null),P.vertical=O.get("vertical","");var k=O.get("line","auto");k==="auto"&&y.line===-1&&(k=-1),P.line=k,P.lineAlign=O.get("lineAlign","start"),P.snapToLines=O.get("snapToLines",!0),P.size=O.get("size",100),P.align=O.get("align",E);var D=O.get("position","auto");D==="auto"&&y.position===50&&(D=P.align==="start"||P.align==="left"?0:P.align==="end"||P.align==="right"?100:50),P.position=D}function T(){g=g.replace(/^\s+/,"")}if(T(),x.startTime=S(),T(),g.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+R);g=g.substr(3),T(),x.endTime=S(),T(),A(g,x)}function _(g){return g.replace(/<br(?: \/)?>/gi,`
|
|
55
55
|
`)}t.fixLineBreaks=_,u.prototype={parse:function(g){var x=this;g&&(x.buffer+=x.decoder.decode(g,{stream:!0}));function C(){var P=x.buffer,O=0;for(P=_(P);O<P.length&&P[O]!=="\r"&&P[O]!==`
|
|
@@ -13150,28 +13150,31 @@ function UrlComponent({
|
|
|
13150
13150
|
viewed: f,
|
|
13151
13151
|
documentType: d,
|
|
13152
13152
|
soundActions: h,
|
|
13153
|
-
keyboardControl: y
|
|
13153
|
+
keyboardControl: y,
|
|
13154
|
+
visible: E
|
|
13154
13155
|
}) {
|
|
13155
|
-
const
|
|
13156
|
+
const p = (A) => o({ type: "translate", payload: A }), _ = {
|
|
13156
13157
|
documentType: d,
|
|
13157
13158
|
name: r,
|
|
13158
13159
|
text: l,
|
|
13159
13160
|
link: n,
|
|
13160
13161
|
type: "url"
|
|
13161
|
-
}, [
|
|
13162
|
-
|
|
13163
|
-
}, [
|
|
13164
|
-
y(null, !f &&
|
|
13165
|
-
const
|
|
13166
|
-
return
|
|
13167
|
-
|
|
13162
|
+
}, [g] = h, x = () => {
|
|
13163
|
+
g("click-ui"), o({ type: "finishMedia", payload: _ });
|
|
13164
|
+
}, [C, T] = useState(!1);
|
|
13165
|
+
y(null, !f && C ? x : null, !f && C ? x : null);
|
|
13166
|
+
const S = t.indexOf("http") !== 0 ? `http://${t}` : t;
|
|
13167
|
+
return useEffect(() => {
|
|
13168
|
+
E || x();
|
|
13169
|
+
}), E && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "popup--layer", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "popup popup--link", children: [
|
|
13170
|
+
!f && C ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
13168
13171
|
"button",
|
|
13169
13172
|
{
|
|
13170
13173
|
className: "popup--close unset-button",
|
|
13171
13174
|
"data-testid": "close",
|
|
13172
13175
|
type: "button",
|
|
13173
|
-
"aria-label":
|
|
13174
|
-
onClick: () =>
|
|
13176
|
+
"aria-label": p("storylines.misc.closePiece"),
|
|
13177
|
+
onClick: () => x(),
|
|
13175
13178
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "icon-close" })
|
|
13176
13179
|
}
|
|
13177
13180
|
) : null,
|
|
@@ -13181,11 +13184,11 @@ function UrlComponent({
|
|
|
13181
13184
|
"a",
|
|
13182
13185
|
{
|
|
13183
13186
|
className: "popup--link__lineclamp popup--link__url",
|
|
13184
|
-
href:
|
|
13187
|
+
href: S,
|
|
13185
13188
|
target: "_blank",
|
|
13186
13189
|
rel: "noopener noreferrer",
|
|
13187
13190
|
onClick: () => {
|
|
13188
|
-
|
|
13191
|
+
g("click-ui"), T(!0);
|
|
13189
13192
|
},
|
|
13190
13193
|
children: u || t
|
|
13191
13194
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@gamelearn/arcade-components",
|
|
3
3
|
"author": "Gamelearn",
|
|
4
4
|
"license": "unlicense",
|
|
5
|
-
"version": "3.1.
|
|
5
|
+
"version": "3.1.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/preset-env": "^7.23.6",
|
|
35
35
|
"@babel/preset-react": "^7.23.3",
|
|
36
|
-
"@gamelearn/arcade-styles": "2.26.0",
|
|
37
36
|
"@gamelearn/arcade-three-core": "2.5.0",
|
|
38
37
|
"@gamelearn/version": "^1.3.1",
|
|
39
38
|
"@react-three/drei": "9.89.0",
|