/*! For license information please see 2~bba809326aa4acfe0e1b.js.LICENSE.txt */ (self.webpackChunkhybrid_client=self.webpackChunkhybrid_client||[]).push([[2],{"./node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js":(e,t,r)=>{"use strict";r.d(t,{A:()=>X});var n=function(){function e(e){var t=this;this._insertTag=function(e){var r;r=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,r),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t0?c(E,--y):0,g--,10===b&&(g=1,m--),b}function I(){return b=y2||A(b)>3?"":" "}function O(e,t){for(;--t&&I()&&!(b<48||b>102||b>57&&b<65||b>70&&b<97););return k(e,w()+(t<6&&32==_()&&32==I()))}function D(e,t){for(;I()&&e+b!==57&&(e+b!==84||47!==_()););return"/*"+k(t,y-1)+"*"+a(47===e?e:I())}function P(e){for(;!A(_());)I();return k(e,y)}function F(e,t){for(var r="",n=h(e),i=0;i0&&f(G)-y&&p(E>32?B(G+";",i,n,y-1):B(u(G," ","")+";",i,n,y-2),m);break;case 59:G+=";";default:if(p(U=W(G,r,n,g,v,o,h,x,F=[],N=[],y),s),123===L)if(0===v)e(G,r,U,U,F,s,y,h,N);else switch(99===b&&110===c(G,3)?100:b){case 100:case 109:case 115:e(t,U,U,i&&p(W(t,U,U,0,0,o,h,x,o,F=[],y),N),o,N,y,h,i?F:N);break;default:e(G,U,U,U,[""],N,0,h,N)}}g=v=E=0,T=A=1,x=G="",y=d;break;case 58:y=1+f(G),E=S;default:if(T<1)if(123==L)--T;else if(125==L&&0==T++&&125==R())continue;switch(G+=a(L),L*T){case 38:A=v>0?1:(G+="\f",-1);break;case 44:h[g++]=(f(G)-1)*A,A=1;break;case 64:45===_()&&(G+=C(I())),b=_(),v=y=f(x=G+=P(w())),L++;break;case 45:45===S&&2==f(G)&&(T=0)}}return s}("",null,null,null,[""],e=L(e),0,[0],e))}function W(e,t,r,n,a,o,l,c,f,p,m){for(var g=a-1,v=0===a?o:[""],y=h(v),b=0,E=0,T=0;b0?v[R]+" "+I:u(I,/&\f/g,v[R])))&&(f[T++]=_);return S(e,t,r,0===a?"rule":c,f,p,m)}function j(e,t,r){return S(e,t,r,"comm",a(b),d(e,2,-2),0)}function B(e,t,r,n){return S(e,t,r,"decl",d(e,0,n),d(e,n+1,-1),n)}var G=function(e,t,r){for(var n=0,i=0;n=i,i=_(),38===n&&12===i&&(t[r]=1),!A(i);)I();return k(e,y)},q=function(e,t){return x(function(e,t){var r=-1,n=44;do{switch(A(n)){case 0:38===n&&12===_()&&(t[r]=1),e[r]+=G(y-1,t,r);break;case 2:e[r]+=C(n);break;case 4:if(44===n){e[++r]=58===_()?"&\f":"",t[r]=e[r].length;break}default:e[r]+=a(n)}}while(n=I());return e}(L(e),t))},K=new WeakMap,H=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,r=e.parent,n=e.column===r.column&&e.line===r.line;"rule"!==r.type;)if(!(r=r.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||K.get(r))&&!n){K.set(e,!0);for(var i=[],a=q(t,i),o=r.props,s=0,u=0;s6)switch(c(e,t+1)){case 109:if(45!==c(e,t+4))break;case 102:return u(e,/(.+:)(.+)-([^]+)/,"$1-webkit-$2-$3$1-moz-"+(108==c(e,t+3)?"$3":"$2-$3"))+e;case 115:return~l(e,"stretch")?z(u(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==c(e,t+1))break;case 6444:switch(c(e,f(e)-3-(~l(e,"!important")&&10))){case 107:return u(e,":",":-webkit-")+e;case 101:return u(e,/(.+:)([^;!]+)(;|!.+)?/,"$1-webkit-"+(45===c(e,14)?"inline-":"")+"box$3$1-webkit-$2$3$1-ms-$2box$3")+e}break;case 5936:switch(c(e,t+11)){case 114:return"-webkit-"+e+"-ms-"+u(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return"-webkit-"+e+"-ms-"+u(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return"-webkit-"+e+"-ms-"+u(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return"-webkit-"+e+"-ms-"+e+e}return e}var Y=[function(e,t,r,n){if(e.length>-1&&!e.return)switch(e.type){case"decl":e.return=z(e.value,e.length);break;case"@keyframes":return F([T(e,{value:u(e.value,"@","@-webkit-")})],n);case"rule":if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=t.exec(e))?e[0]:e}(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return F([T(e,{props:[u(t,/:(read-\w+)/,":-moz-$1")]})],n);case"::placeholder":return F([T(e,{props:[u(t,/:(plac\w+)/,":-webkit-input-$1")]}),T(e,{props:[u(t,/:(plac\w+)/,":-moz-$1")]}),T(e,{props:[u(t,/:(plac\w+)/,"-ms-input-$1")]})],n)}return""}))}}];const X=function(e){var t=e.key;if("css"===t){var r=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(r,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var i=e.stylisPlugins||Y;var a,o,s={},u=[];a=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),r=1;r{"use strict";r.d(t,{A:()=>i});var n=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|default|defer|dir|disabled|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|itemProp|itemScope|itemType|itemID|itemRef|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;const i=function(e){var t={};return function(r){return void 0===t[r]&&(t[r]=e(r)),t[r]}}((function(e){return n.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}))},"./node_modules/@emotion/react/dist/emotion-element-6a883da9.browser.esm.js":(e,t,r)=>{"use strict";r.d(t,{C:()=>c,E:()=>g,c:()=>p,h:()=>u});var n=r("webpack/sharing/consume/default/react/react"),i=r("./node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js");var a=function(e,t,r){var n=e.key+"-"+t.name;!1===r&&void 0===e.registered[n]&&(e.registered[n]=t.styles)},o=r("./node_modules/@emotion/serialize/dist/emotion-serialize.browser.esm.js"),s=r("./node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js"),u={}.hasOwnProperty,l=(0,n.createContext)("undefined"!=typeof HTMLElement?(0,i.A)({key:"css"}):null);var c=l.Provider,d=function(e){return(0,n.forwardRef)((function(t,r){var i=(0,n.useContext)(l);return e(t,i,r)}))},f=(0,n.createContext)({});var h="__EMOTION_TYPE_PLEASE_DO_NOT_USE__",p=function(e,t){var r={};for(var n in t)u.call(t,n)&&(r[n]=t[n]);return r[h]=e,r},m=function(e){var t=e.cache,r=e.serialized,n=e.isStringTag;a(t,r,n);(0,s.s)((function(){return function(e,t,r){a(e,t,r);var n=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var i=t;do{e.insert(t===i?"."+n:"",i,e.sheet,!0);i=i.next}while(void 0!==i)}}(t,r,n)}));return null},g=d((function(e,t,r){var i=e.css;"string"==typeof i&&void 0!==t.registered[i]&&(i=t.registered[i]);var a=e[h],s=[i],l="";"string"==typeof e.className?l=function(e,t,r){var n="";return r.split(" ").forEach((function(r){void 0!==e[r]?t.push(e[r]+";"):n+=r+" "})),n}(t.registered,s,e.className):null!=e.className&&(l=e.className+" ");var c=(0,o.J)(s,void 0,(0,n.useContext)(f));l+=t.key+"-"+c.name;var d={};for(var p in e)u.call(e,p)&&"css"!==p&&p!==h&&(d[p]=e[p]);return d.ref=r,d.className=l,(0,n.createElement)(n.Fragment,null,(0,n.createElement)(m,{cache:t,serialized:c,isStringTag:"string"==typeof a}),(0,n.createElement)(a,d))}))},"./node_modules/@emotion/react/dist/emotion-react.browser.esm.js":(e,t,r)=>{"use strict";r.d(t,{AH:()=>s,Y:()=>o,i7:()=>u});var n=r("webpack/sharing/consume/default/react/react"),i=(r("./node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js"),r("./node_modules/@emotion/react/dist/emotion-element-6a883da9.browser.esm.js")),a=(r("./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js"),r("./node_modules/@emotion/serialize/dist/emotion-serialize.browser.esm.js")),o=(r("./node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js"),function(e,t){var r=arguments;if(null==t||!i.h.call(t,"css"))return n.createElement.apply(void 0,r);var a=r.length,o=new Array(a);o[0]=i.E,o[1]=(0,i.c)(e,t);for(var s=2;s{"use strict";r.d(t,{J:()=>p});const n=function(e){for(var t,r=0,n=0,i=e.length;i>=4;++n,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+(59797*(t>>>16)<<16),r=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&r)+(59797*(r>>>16)<<16);switch(i){case 3:r^=(255&e.charCodeAt(n+2))<<16;case 2:r^=(255&e.charCodeAt(n+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(n)))+(59797*(r>>>16)<<16)}return(((r=1540483477*(65535&(r^=r>>>13))+(59797*(r>>>16)<<16))^r>>>15)>>>0).toString(36)};const i={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1};var a=/[A-Z]|^ms/g,o=/_EMO_([^_]+?)_([^]*?)_EMO_/g,s=function(e){return 45===e.charCodeAt(1)},u=function(e){return null!=e&&"boolean"!=typeof e},l=function(e){var t=Object.create(null);return function(r){return void 0===t[r]&&(t[r]=e(r)),t[r]}}((function(e){return s(e)?e:e.replace(a,"-$&").toLowerCase()})),c=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(o,(function(e,t,r){return f={name:t,styles:r,next:f},t}))}return 1===i[e]||s(e)||"number"!=typeof t||0===t?t:t+"px"};function d(e,t,r){if(null==r)return"";if(void 0!==r.__emotion_styles)return r;switch(typeof r){case"boolean":return"";case"object":if(1===r.anim)return f={name:r.name,styles:r.styles,next:f},r.name;if(void 0!==r.styles){var n=r.next;if(void 0!==n)for(;void 0!==n;)f={name:n.name,styles:n.styles,next:f},n=n.next;return r.styles+";"}return function(e,t,r){var n="";if(Array.isArray(r))for(var i=0;i{"use strict";r.d(t,{A:()=>n});const n=function(e){function t(e,t,n){var i=t.trim().split(p);t=i;var a=i.length,o=e.length;switch(o){case 0:case 1:var s=0;for(e=0===o?"":e[0]+" ";sn&&(n=(t=t.trim()).charCodeAt(0)),n){case 38:return t.replace(m,"$1"+e.trim());case 58:return e.trim()+t.replace(m,"$1"+e.trim());default:if(0<1*r&&0u.charCodeAt(8))break;case 115:o=o.replace(u,"-webkit-"+u)+";"+o;break;case 207:case 102:o=o.replace(u,"-webkit-"+(102s.charCodeAt(0)&&(s=s.trim()),s=[s],0h)&&(W=(G=G.replace(" ",":")).length),0{"use strict";r.d(t,{s:()=>a});var n=r("webpack/sharing/consume/default/react/react"),i=!!n.useInsertionEffect&&n.useInsertionEffect,a=i||function(e){return e()}},"./node_modules/debug/src/browser.js":(e,t,r)=>{var n,i=r("./node_modules/process/browser.js");t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){var e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(n=!1,function(){n||(n=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||function(){},e.exports=r("./node_modules/debug/src/common.js")(t),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},"./node_modules/debug/src/common.js":(e,t,r)=>{function n(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r,n="object"===("undefined"==typeof Reflect?"undefined":t(Reflect))?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var a=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,a),n(r)}function a(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}g(e,t,a,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+t(e))}function l(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function c(e,t,r,n){var i,a,o,s;if(u(r),void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),o=a[t]),void 0===o)o=a[t]=r,++e._eventsCount;else if("function"==typeof o?o=a[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=l(e))>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,s=c,console&&console.warn&&console.warn(s)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=d.bind(n);return i.listener=r,n.wrapFn=i,i}function h(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var u=a[e];if(void 0===u)return!1;if("function"==typeof u)i(u,this,t);else{var l=u.length,c=m(u,l);for(r=0;r=0;a--)if(r[a]===t||r[a].listener===t){o=r[a].listener,i=a;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return h(this,e,!0)},o.prototype.rawListeners=function(e){return h(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},"./node_modules/h264-profile-level-id/index.js":(e,t,r)=>{function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},t=e["level-asymmetry-allowed"];return 1===t||"1"===t}t.parseProfileLevelId=function(e){if("string"!=typeof e||6!==e.length)return null;var t=parseInt(e,16);if(0===t)return null;var r,n=255&t,i=t>>8&255,a=t>>16&255;switch(n){case 11:r=0!=(16&i)?0:11;break;case 10:case 12:case 13:case 20:case 21:case 22:case 30:case 31:case 32:case 40:case 41:case 42:case 50:case 51:case 52:r=n;break;default:return l("parseProfileLevelId() | unrecognized level_idc [str:".concat(e,", level_idc:").concat(n,"]")),null}for(var o=0,s=h;o0&&void 0!==arguments[0]?arguments[0]:{},r=new c(1,31),n=e["profile-level-id"];return n?t.parseProfileLevelId(n):r},t.isSameProfile=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.parseSdpProfileLevelId(e),i=t.parseSdpProfileLevelId(r);return Boolean(n&&i&&n.profile===i.profile)},t.generateProfileLevelIdForAnswer=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e["profile-level-id"]&&!r["profile-level-id"])return l("generateProfileLevelIdForAnswer() | profile-level-id missing in local and remote params"),null;var n=t.parseSdpProfileLevelId(e),i=t.parseSdpProfileLevelId(r);if(!n)throw new TypeError("invalid local_profile_level_id");if(!i)throw new TypeError("invalid remote_profile_level_id");if(n.profile!==i.profile)throw new TypeError("H264 Profile mismatch");var a=g(e)&&g(r),o=n.level,s=i.level,d=m(o,s),f=a?o:d;return u("generateProfileLevelIdForAnswer() | result [profile:".concat(n.profile,", level:").concat(f,"]")),t.profileLevelIdToString(new c(n.profile,f))}},"./node_modules/icf-room-client-user/dist/index.js":(e,t,r)=>{var n=r("./node_modules/buffer/index.js").Buffer;function i(e,t,r,n){var i=a(S(1&n?e.prototype:e),t,r);return 2&n&&"function"==typeof i?function(e){return i.apply(r,e)}:i}function a(){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=o(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}}).apply(null,arguments)}function o(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=S(e)););return e}function s(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=c(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],u=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return d(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(u&&l){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),x(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:M(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&E(e,t)}function p(e){var t=b();return function(){var r,n=S(e);if(t){var i=S(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}function m(e,t){if(t&&("object"==w(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e){var t="function"==typeof Map?new Map:void 0;return(v=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return y(e,arguments,S(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),E(r,e)})(e)}function y(e,t,r){if(b())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&E(i,r.prototype),i}function b(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(b=function(){return!!e})()}function E(e,t){return(E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function R(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}function o(e,t){var r,n;return t((function(t,i){return r=t,n=i,e.on(t,i),e})),i.Disposable.create((function(){return e.off(r,n)}))}Object.defineProperty(t,"Emitter",{enumerable:!0,get:function(){return i.Emitter}}),t.delay=a,t.createTupleEmitter=function(e,t){var r,n=new i.Emitter({onFirstListenerAdd:function(){r=o(e,(function(e){return e(t,(function(){for(var e=arguments.length,t=new Array(e),r=0;r2?n-2:0),a=2;a1&&void 0!==arguments[1]?arguments[1]:[100,500,1e3,5e3];return n.__awaiter(this,void 0,void 0,f().mark((function r(){var n,i;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=null;case 1:if(!t.length){r.next=16;break}return r.prev=2,r.next=5,e();case 5:return r.abrupt("return",r.sent);case 8:return r.prev=8,r.t0=r.catch(2),n=r.t0,i=t.shift(),r.next=14,a(i);case 14:r.next=1;break;case 16:throw n;case 17:case"end":return r.stop()}}),r,null,[[2,8]])})))}},"../../../../src/room/shared/connections.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectionErrorCode=t.ConnectionError=void 0;var n=r("../../../../src/room/shared/naiad.ts"),i=function(e){h(r,e);var t=p(r);function r(e,n){var i;return T(this,r),(i=t.call(this,e)).code=n,i}return I(r)}(v(Error));t.ConnectionError=i,t.ConnectionErrorCode=Object.freeze({internal:n.ExtendedNaiadStatus.system,systemDb:n.ExtendedNaiadStatus.systemDb,configuration:n.ExtendedNaiadStatus.configuration,authentication:n.ExtendedNaiadStatus.authentication,userList:n.ExtendedNaiadStatus.userListFailure,exclusive:n.ExtendedNaiadStatus.exclusive,inGoldShow:n.ExtendedNaiadStatus.inGoldShow,busy:n.ExtendedNaiadStatus.busy,break:n.ExtendedNaiadStatus.onBreak,blocked:n.ExtendedNaiadStatus.blocked,shackled:n.ExtendedNaiadStatus.shackled,performer:n.ExtendedNaiadStatus.performer})},"../../../../src/room/shared/heartbeat.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MessageChannelHeartbeatRunner=void 0;var n=r("tslib"),i=r("../../../../src/room/shared/common.ts"),a=r("../../../../src/room/shared/rpc.ts"),o=function(){function e(t,r,o){var s=this;T(this,e),this.messageChannel=t,this.heartbeatFrequencyMs=r,this.heartbeatTimeoutMs=o,this.onErrorEmitter=new i.Emitter,this.onBeatEmitter=new i.Emitter,this.isDisposed=!1,this.currentTimeoutHandle=null,this.beatFunc=function(){return n.__awaiter(s,void 0,void 0,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,i.withTimeout(this.messageChannel.sendRequest(a.connectionMessageTypes.connectionHeartbeat),o,"heartbeat timeout");case 3:this.onBeatEmitter.fire(),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),this.onErrorEmitter.fire(e.t0);case 9:this.isDisposed||(this.currentTimeoutHandle=setTimeout(this.beatFunc,this.heartbeatFrequencyMs));case 10:case"end":return e.stop()}}),e,this,[[0,6]])})))}}return I(e,[{key:"onError",get:function(){return this.onErrorEmitter.event}},{key:"onBeat",get:function(){return this.onBeatEmitter.event}},{key:"start",value:function(){this.currentTimeoutHandle=setTimeout(this.beatFunc,this.heartbeatFrequencyMs)}},{key:"dispose",value:function(){this.isDisposed||(this.isDisposed=!0,this.onErrorEmitter.dispose(),this.onBeatEmitter.dispose(),this.currentTimeoutHandle&&(clearTimeout(this.currentTimeoutHandle),this.currentTimeoutHandle=null))}}]),e}();t.MessageChannelHeartbeatRunner=o},"../../../../src/room/shared/naiad.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.naiadCodeToDisconnectParams=t.ExtendedNaiadStatus=void 0,t.ExtendedNaiadStatus=Object.freeze({system:1,systemDb:2,configuration:8,authentication:9,performer:10,blocked:11,user:12,shackled:13,preauth:14,booted:15,exorcist:16,ghost:17,payoff:19,busy:20,exclusive:24,rejectExclusive:25,userDisconnect:27,blockSession:28,rejectBlockSession:29,redirect:31,upsold:32,newPerformer:34,onBreak:36,inGoldShow:37,lostConnection:38,timedOut:43,bootedByAdmin:54,encoderDisconnect:61,nginxAbnormal:62,roomIntegrityReconciliation:75,roomServerConnectionLost:77,temporaryUseCompleted:100,clientHidden:101,changedRoom:102,invalidRoomTopic:103,userListFailure:104}),t.naiadCodeToDisconnectParams=function(e,r){switch(e){case t.ExtendedNaiadStatus.userDisconnect:return{kind:"user",action:"clientClosed",details:r};case t.ExtendedNaiadStatus.clientHidden:return{kind:"user",action:"clientHidden",details:r};case t.ExtendedNaiadStatus.changedRoom:return{kind:"user",action:"changedRoom",details:r};case t.ExtendedNaiadStatus.redirect:return{kind:"user",action:"redirect",details:r};case t.ExtendedNaiadStatus.newPerformer:return{kind:"user",action:"newPerformer",details:r};case t.ExtendedNaiadStatus.temporaryUseCompleted:return{kind:"temporaryUseCompleted",details:r};case t.ExtendedNaiadStatus.lostConnection:return{kind:"fmsGatewayLostConnection",details:r};case t.ExtendedNaiadStatus.bootedByAdmin:return{kind:"server",action:"adminBooted"};case t.ExtendedNaiadStatus.blocked:return{kind:"server",action:"blocked"};case t.ExtendedNaiadStatus.booted:return{kind:"server",action:"booted"};case t.ExtendedNaiadStatus.exorcist:return{kind:"server",action:"exorcist"};case t.ExtendedNaiadStatus.ghost:return{kind:"server",action:"ghostSession"};case t.ExtendedNaiadStatus.onBreak:return{kind:"server",action:"onBreak",details:r};case t.ExtendedNaiadStatus.inGoldShow:return{kind:"server",action:"inGoldShow",details:r};case t.ExtendedNaiadStatus.authentication:return{kind:"server",action:"authentication",details:r};case t.ExtendedNaiadStatus.preauth:return{kind:"server",action:"preauthError",details:r};case t.ExtendedNaiadStatus.shackled:return{kind:"server",action:"shackled",details:r};case t.ExtendedNaiadStatus.system:return{kind:"server",action:"system",details:r};case t.ExtendedNaiadStatus.performer:return{kind:"server",action:"offlineRoom",details:r};case t.ExtendedNaiadStatus.payoff:return{kind:"server",action:"payoffFailed",details:r};case t.ExtendedNaiadStatus.busy:return{kind:"server",action:"busyRoom",details:r};case t.ExtendedNaiadStatus.upsold:return{kind:"server",action:"upsold",details:r};case t.ExtendedNaiadStatus.blockSession:return{kind:"server",action:"blockSession",details:r};case t.ExtendedNaiadStatus.rejectBlockSession:return{kind:"performer",action:"rejectBlockSession",details:r};case t.ExtendedNaiadStatus.exclusive:return{kind:"server",action:"performerInExclusive",details:r};case t.ExtendedNaiadStatus.rejectExclusive:return{kind:"performer",action:"rejectExclusive",details:r};case t.ExtendedNaiadStatus.roomServerConnectionLost:return{kind:"server",action:"roomServerConnectionLost",details:r};case t.ExtendedNaiadStatus.encoderDisconnect:return{kind:"server",action:"encoderDisconnect",details:r};case t.ExtendedNaiadStatus.nginxAbnormal:return{kind:"server",action:"encoderError",details:r};case t.ExtendedNaiadStatus.roomIntegrityReconciliation:return{kind:"server",action:"roomIntegrityReconciliation",details:r};case t.ExtendedNaiadStatus.timedOut:return{kind:"server",action:"timedOut",details:r};default:throw new Error("Unsupported or invalid naiad status code.")}}},"../../../../src/room/shared/protocol/shared/chat.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chatMessageProtocol=t.ISetChatParticipantIsMutedParams=t.ISendChatMessageParams=t.IOutboundChatMessage=t.IMessageHistory=t.IMessageHistoryRequestParams=t.SendChatMessageResult=t.Message=t.SystemMessage=t.IBlockSessionMinutesLeft=t.IGoldSentSystemMessage=t.IGoldShowPledgeSystemMessage=t.IUserBlockedSystemMessage=t.IGoldShowGoalReachedSystemMessage=t.IGoldShowCanceledSystemMessage=t.IUserLoggedOffSystemMessage=t.IUserLoggedOnSystemMessage=t.ISystemMessage=t.UserLoggedOffReason=t.SystemMessageKind=t.IChatMessage=t.ChatGroup=t.IMessage=t.MessageKind=t.IChatParticipant=t.ChatMessageContent=t.ChatParticipantType=t.ChatParticipantId=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts"),a=r("../../../../src/room/shared/protocol/shared/commonTypes.ts"),o=r("../../../../src/room/shared/validation.ts");t.ChatParticipantId=n.string,t.ChatParticipantType=n.union([n.literal("performer"),n.literal("user")]),t.ChatMessageContent=n.string.pipe(o.stringOfLength(1,255),"ChatMessageContent"),t.IChatParticipant=n.intersection([n.type({id:t.ChatParticipantId,nickname:a.Nickname,type:t.ChatParticipantType,isMuted:n.boolean,isAnonymous:n.boolean}),n.partial({nonBillable:n.boolean})],"IChatParticipant"),t.MessageKind=n.union([n.literal("chat"),n.literal("system")]),t.IMessage=n.type({kind:t.MessageKind,id:n.number,timestamp:n.number},"IMessage"),t.ChatGroup=n.union([n.literal("loggedout"),n.literal("loggedin"),n.literal("premium")]),t.IChatMessage=n.intersection([t.IMessage,n.intersection([n.type({kind:n.literal("chat"),content:t.ChatMessageContent,sender:t.IChatParticipant,hash:n.string}),n.partial({chatGroup:t.ChatGroup})])],"IChatMessage"),t.SystemMessageKind=n.union([n.literal("goldSent"),n.literal("goldShowCanceled"),n.literal("goldShowGoalReached"),n.literal("goldShowPledge"),n.literal("userBlocked"),n.literal("userLoggedOff"),n.literal("userLoggedOn"),n.literal("blockSessionMinutesLeft")]),t.UserLoggedOffReason=n.union([n.literal("blocked"),n.literal("booted"),n.literal("connection"),n.literal("exclusive"),n.literal("goldshow"),n.literal("manual"),n.literal("rejectBlockSession"),n.literal("rejectExclusive"),n.literal("support"),n.literal("unknown"),n.literal("user"),n.literal("adminBooted"),n.literal("ghost")]),t.ISystemMessage=n.intersection([t.IMessage,n.intersection([n.type({kind:n.literal("system"),systemMessageKind:t.SystemMessageKind,preformattedMessage:n.string}),n.partial({chatGroup:t.ChatGroup})])],"ISystemMessage"),t.IUserLoggedOnSystemMessage=n.intersection([t.ISystemMessage,n.type({systemMessageKind:n.literal("userLoggedOn"),participant:t.IChatParticipant})],"IUserLoggedOnSystemMessage"),t.IUserLoggedOffSystemMessage=n.intersection([t.ISystemMessage,n.type({systemMessageKind:n.literal("userLoggedOff"),participant:t.IChatParticipant,reason:t.UserLoggedOffReason})],"IUserLoggedOffSystemMessage"),t.IGoldShowCanceledSystemMessage=n.intersection([t.ISystemMessage,n.type({systemMessageKind:n.literal("goldShowCanceled")})],"IGoldShowCanceledSystemMessage"),t.IGoldShowGoalReachedSystemMessage=n.intersection([t.ISystemMessage,n.type({systemMessageKind:n.literal("goldShowGoalReached")})],"IGoldShowGoalReachedSystemMessage"),t.IUserBlockedSystemMessage=n.intersection([t.ISystemMessage,n.type({systemMessageKind:n.literal("userBlocked"),participant:t.IChatParticipant})],"IUserBlockedSystemMessage"),t.IGoldShowPledgeSystemMessage=n.intersection([t.ISystemMessage,n.type({systemMessageKind:n.literal("goldShowPledge"),participant:t.IChatParticipant,amount:n.number})],"IGoldPledgedSystemMessage"),t.IGoldSentSystemMessage=n.intersection([t.ISystemMessage,n.intersection([n.type({systemMessageKind:n.literal("goldSent"),participant:t.IChatParticipant,amount:n.number}),n.partial({goldItemKeyword:n.string})])],"IGaveGoldSystemMessage"),t.IBlockSessionMinutesLeft=n.intersection([t.ISystemMessage,n.type({systemMessageKind:n.literal("blockSessionMinutesLeft"),participant:t.IChatParticipant,durationMin:n.number,timeLeftMin:n.number})],"IBlockSessionMinutesLeft"),t.SystemMessage=n.union([t.IGoldSentSystemMessage,t.IGoldShowPledgeSystemMessage,t.IGoldShowCanceledSystemMessage,t.IGoldShowGoalReachedSystemMessage,t.IUserBlockedSystemMessage,t.IUserLoggedOffSystemMessage,t.IUserLoggedOnSystemMessage,t.IBlockSessionMinutesLeft]),t.Message=n.union([t.IChatMessage,t.SystemMessage]),t.SendChatMessageResult=i.createResultType(n.type({id:n.number,hash:n.string,timestamp:n.number},"ISendChatMessageSuccessInfo"),n.type({errorKind:n.string},"ISendChatMessageErrorInfo"),"SendChatMessageResult"),t.IMessageHistoryRequestParams=n.type({performerStreamId:n.number,messageCount:n.number},"IMessageHistoryRequestParams"),t.IMessageHistory=n.type({messages:n.readonly(n.array(t.IMessage))},"IMessageHistory");var s=n.type({messages:n.readonly(n.array(t.Message))},"IMessagesReceivedEventParams");t.IOutboundChatMessage=n.type({content:t.ChatMessageContent},"IOutboundChatMessage"),t.ISendChatMessageParams=n.type({message:t.IOutboundChatMessage},"ISendChatMessageParams"),t.ISetChatParticipantIsMutedParams=n.type({participantId:t.ChatParticipantId,isMuted:n.boolean},"ISetChatParticipantIsMutedParams"),t.chatMessageProtocol=[new i.RoomNotificationTypeWithParam("onMessagesReceived",s),new i.RoomRequestTypeWithParam("getMessageHistory",t.IMessageHistoryRequestParams,t.IMessageHistory),new i.RoomRequestTypeWithParam("setChatParticipantIsMuted",t.ISetChatParticipantIsMutedParams)]},"../../../../src/room/shared/protocol/shared/commonTypes.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Nickname=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/validation.ts");t.Nickname=i.withName(n.string.pipe(i.stringOfLength(1,32)),"Nickname")},"../../../../src/room/shared/protocol/shared/disconnection.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.disconnectionProtocol=t.PingResponse=t.PingParams=t.IOnDisconnectingEventParams=t.DisconnectionInfo=t.DisconnectParams=t.ServerDisconnectionInfo=t.IFmsGatewayLostConnectionDisconnectionInfo=t.ITemporaryUseCompletedDisconnectionInfo=t.ISystemFailureDisconnectionInfo=t.IPerformerDisconnectionInfo=t.IUserDisconnectionInfo=t.IDisconnectionDetails=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/naiad.ts"),a=r("../../../../src/room/shared/rpc.ts"),o=r("../../../../src/room/shared/validation.ts");t.IDisconnectionDetails=n.partial({details:n.string.pipe(o.stringOfLength(1,255))},"IDisconnectionDetails"),t.IUserDisconnectionInfo=n.intersection([t.IDisconnectionDetails,n.type({kind:n.literal("user"),action:n.union([n.literal("clientClosed"),n.literal("clientHidden"),n.literal("changedRoom"),n.literal("redirect"),n.literal("newPerformer")])})],"IUserDisconnectionInfo"),t.IPerformerDisconnectionInfo=n.intersection([t.IDisconnectionDetails,n.type({kind:n.literal("performer"),action:n.union([n.literal("rejectExclusive"),n.literal("rejectBlockSession")])})],"IPerformerDisconnectionInfo"),t.ISystemFailureDisconnectionInfo=n.intersection([t.IDisconnectionDetails,n.type({kind:n.literal("system"),failedFeature:n.literal("userList")})],"ISystemFailureDisconnectionInfo"),t.ITemporaryUseCompletedDisconnectionInfo=n.intersection([t.IDisconnectionDetails,n.type({kind:n.literal("temporaryUseCompleted")})],"ITemporaryUseCompletedDisconnectionInfo"),t.IFmsGatewayLostConnectionDisconnectionInfo=n.intersection([t.IDisconnectionDetails,n.type({kind:n.literal("fmsGatewayLostConnection")})],"IFmsGatewayLostConnectionDisconnectionInfo"),t.ServerDisconnectionInfo=n.intersection([t.IDisconnectionDetails,n.type({kind:n.literal("server"),action:n.union([n.literal("adminBooted"),n.literal("kicked"),n.literal("blocked"),n.literal("booted"),n.literal("exorcist"),n.literal("ghostSession"),n.literal("offlineRoom"),n.literal("busyRoom"),n.literal("onBreak"),n.literal("inGoldShow"),n.literal("authentication"),n.literal("preauthError"),n.literal("shackled"),n.literal("system"),n.literal("payoffFailed"),n.literal("upsold"),n.literal("blockSession"),n.literal("performerInExclusive"),n.literal("roomServerConnectionLost"),n.literal("encoderDisconnect"),n.literal("encoderError"),n.literal("roomIntegrityReconciliation"),n.literal("timedOut")])})],"ServerDisconnectionInfo"),t.DisconnectParams=n.union([t.IUserDisconnectionInfo,t.IPerformerDisconnectionInfo,t.ITemporaryUseCompletedDisconnectionInfo,t.IFmsGatewayLostConnectionDisconnectionInfo,t.ISystemFailureDisconnectionInfo,t.ServerDisconnectionInfo],"DisconnectionInfo"),t.DisconnectionInfo=t.DisconnectParams,t.IOnDisconnectingEventParams=n.intersection([n.type({info:t.DisconnectionInfo}),n.partial({naiadStatus:o.enumType(i.ExtendedNaiadStatus,"ExtendedNaiadStatus")})],"IOnDisconnectingEventParams"),t.PingParams=n.type({pingTimeMs:n.number},"PingParams"),t.PingResponse=a.createResultType(n.type({pingTimeMs:n.number,pongTimeMs:n.number},"PingSuccessResponse"),n.type({pingTimeMs:n.number,pongTimeMs:n.number,failureReason:n.literal("error")},"PingFailureResponse"),"PingResponse"),t.disconnectionProtocol=[new a.RoomRequestTypeWithParam("ping",t.PingParams,t.PingResponse),new a.RoomRequestTypeWithParam("disconnect",t.DisconnectParams),new a.RoomNotificationTypeWithParam("onDisconnecting",t.IOnDisconnectingEventParams)]},"../../../../src/room/shared/protocol/shared/gold.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.goldProtocol=t.GoldGiven=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts");t.GoldGiven=n.type({userName:n.string,isAnonymous:n.boolean,amount:n.number,isFromQuickTip:n.boolean,goldItemKeyword:n.string,spinGoldMenuName:n.string,spinGoldResultKeyword:n.string},"GoldGiven"),t.goldProtocol=[new i.RoomNotificationTypeWithParam("onGoldGiven",t.GoldGiven)]},"../../../../src/room/shared/protocol/shared/goldOnlyGoals.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.goldOnlyGoalsProtocol=t.IGoldOnlyGoals=t.IGoldOnlyGoalsStatus=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts"),a=r("../../../../src/room/shared/validation.ts");t.IGoldOnlyGoalsStatus=n.type({goal:n.string.pipe(a.stringOfLength(0,255)),cost:n.number,progress:n.number},"IGoldOnlyGoalsStatus"),t.IGoldOnlyGoals=n.type({status:n.union([t.IGoldOnlyGoalsStatus,n.null])},"IGoldOnlyGoals"),t.goldOnlyGoalsProtocol=[new i.RoomRequestType("getGoldOnlyGoals",t.IGoldOnlyGoals),new i.RoomNotificationTypeWithParam("onGoldOnlyGoalsChanged",t.IGoldOnlyGoals)]},"../../../../src/room/shared/protocol/shared/goldShow.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.goldShowProtocol=t.GoldShowPledged=t.GoldShowInfoCombined=t.GoldShowWithPledges=t.GoldShow=t.GoldShowBase=t.GoldShowTopContributorsUpdated=t.GoldShowTopContributor=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts");t.GoldShowTopContributor=n.intersection([n.type({userName:n.string,isAnonymous:n.boolean,isMyContribution:n.boolean,amount:n.number,lastGoldTimestamp:n.number}),n.partial({userId:n.number})],"GoldShowTopContributor"),t.GoldShowTopContributorsUpdated=n.type({users:n.array(t.GoldShowTopContributor)},"GoldShowTopContributorsUpdated"),t.GoldShowBase=n.type({goldShowId:n.number,performerId:n.number,showTopic:n.string,duration:n.number,maxWait:n.number,requestedAmount:n.number,minBuyin:n.number,isHighestBidder:n.boolean,isNonexplicit:n.boolean,isExternalSiteShow:n.boolean,timeToStart:n.number,timeToEnd:n.number,hasPledgesInfo:n.boolean},"GoldShowBase"),t.GoldShow=n.intersection([t.GoldShowBase,n.type({hasPledgesInfo:n.literal(!1)})],"GoldShow"),t.GoldShowWithPledges=n.intersection([t.GoldShowBase,n.type({totalPledgedAmount:n.number,myPledgedAmount:n.number,myAccess:n.boolean,hasPledgesInfo:n.literal(!0)}),n.partial({topContributors:n.array(t.GoldShowTopContributor)})],"GoldShowWithPledges"),t.GoldShowInfoCombined=n.union([t.GoldShow,t.GoldShowWithPledges],"GoldShowInfoCombined"),t.GoldShowPledged=n.type({goldShowId:n.number,userName:n.string,isAnonymous:n.boolean,amount:n.number,totalPledgedAmount:n.number},"GoldShowPledged"),t.goldShowProtocol=[new i.RoomNotificationTypeWithParam("onGoldShow",t.GoldShowInfoCombined),new i.RoomNotificationTypeWithParam("onGoldShowPledged",t.GoldShowPledged),new i.RoomNotificationTypeWithParam("onGoldShowTopContributorsUpdated",t.GoldShowTopContributorsUpdated)]},"../../../../src/room/shared/protocol/shared/index.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sharedProtocol=void 0;var n=r("../../../../src/room/shared/protocol/shared/disconnection.ts"),i=r("../../../../src/room/shared/protocol/shared/status.ts"),a=r("../../../../src/room/shared/protocol/shared/chat.ts"),o=r("../../../../src/room/shared/protocol/shared/goldOnlyGoals.ts"),s=r("../../../../src/room/shared/protocol/shared/goldShow.ts"),u=r("../../../../src/room/shared/protocol/shared/gold.ts");t.sharedProtocol=[].concat(l(n.disconnectionProtocol),l(i.statusChangedProtocol),l(a.chatMessageProtocol),l(o.goldOnlyGoalsProtocol),l(s.goldShowProtocol),l(u.goldProtocol))},"../../../../src/room/shared/protocol/shared/status.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.statusChangedProtocol=t.IRoomStatus=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts");t.IRoomStatus=n.intersection([n.type({status:n.string,timeInStatusMs:n.number,previousStatus:n.string,videoAuthRequired:n.boolean,isPremium:n.boolean}),n.partial({streamInfo:n.type({streamId:n.number}),showInfo:n.type({showType:n.string,showTopic:n.string}),goldShowInfo:n.type({goldShowId:n.number,showType:n.string})})],"IRoomStatus"),t.statusChangedProtocol=[new i.RoomNotificationTypeWithParam("onStatusChanged",t.IRoomStatus)]},"../../../../src/room/shared/protocol/shared/vibeStatus.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VibeStatus=void 0;var n=r("tslib").__importStar(r("io-ts"));t.VibeStatus=n.keyof({online:null,offline:null})},"../../../../src/room/shared/protocol/user/auth.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AuthInfo=void 0;var n=r("tslib").__importStar(r("io-ts"));t.AuthInfo=n.intersection([n.type({success:n.boolean,streamId:n.number,userType:n.number,nickname:n.string,owedAmount:n.number,owedMessage:n.union([n.string,n.number]),prebillRequired:n.boolean,maxGold:n.number,minGold:n.number,exchangeRate:n.number,currencySign:n.string}),n.partial({failureReason:n.string})],"AuthInfo")},"../../../../src/room/shared/protocol/user/chat.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.userSendMessageProtocol=t.IUserSendChatMessageParams=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts"),a=r("../../../../src/room/shared/protocol/shared/chat.ts");t.IUserSendChatMessageParams=n.intersection([a.ISendChatMessageParams,n.partial({anonymous:n.boolean})],"IUserSendChatMessageParams"),t.userSendMessageProtocol=[new i.RoomRequestTypeWithParam("sendChatMessage",t.IUserSendChatMessageParams,a.SendChatMessageResult)]},"../../../../src/room/shared/protocol/user/connectionInfo.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.userConnectionInfoProtocol=t.connectionInfoChanged=t.getConnectionInfoRequestType=t.IUserConnectionInfo=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts"),a=r("../../../../src/room/shared/protocol/shared/status.ts"),o=r("../../../../src/room/shared/protocol/shared/goldShow.ts"),s=r("../../../../src/room/shared/protocol/user/auth.ts");t.IUserConnectionInfo=n.intersection([n.type({videoManifestUrl:n.string,fmsGatewayUrl:n.string,features:n.array(n.string),additionalPerformersOnStream:n.array(n.number),connectionId:n.string,initialStatus:a.IRoomStatus}),n.partial({hubUrl:n.string,goldShow:o.GoldShowWithPledges,authInfo:s.AuthInfo})],"IUserConnectionInfo"),t.getConnectionInfoRequestType=new i.RoomRequestType("getConnectionInfo",t.IUserConnectionInfo),t.connectionInfoChanged=new i.RoomNotificationTypeWithParam("onConnectionInfoChanged",t.IUserConnectionInfo),t.userConnectionInfoProtocol=[t.getConnectionInfoRequestType,t.connectionInfoChanged]},"../../../../src/room/shared/protocol/user/gold.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.userGoldProtocol=t.UserGiveGoldResponse=t.UserGiveGoldRequest=t.GoldMenuOption=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts");t.GoldMenuOption=n.intersection([n.type({cost:n.number,description:n.string,goldmenuid:n.number,keyword:n.string}),n.partial({active:n.boolean,explicit:n.number})],"GoldMenuOption"),t.UserGiveGoldRequest=n.intersection([n.type({isAnonymous:n.boolean,amount:n.number,isFromQuickTip:n.boolean}),n.partial({spinGoldMenuName:n.string,goldMenuOption:t.GoldMenuOption})],"UserGiveGoldRequest"),t.UserGiveGoldResponse=i.createResultType(n.intersection([n.type({amount:n.number,maxGold:n.number,isPrebillRequired:n.boolean}),n.partial({spinGoldResultKeyword:n.string})],"UserGiveGoldSuccessResponse"),n.type({failureReason:n.union([n.literal("error"),n.literal("mingold"),n.literal("preauth"),n.literal("shackled")])},"UserGiveGoldFailureResponse"),"UserGiveGoldResponse"),t.userGoldProtocol=[new i.RoomRequestTypeWithParam("giveGold",t.UserGiveGoldRequest,t.UserGiveGoldResponse)]},"../../../../src/room/shared/protocol/user/goldShow.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.userGoldShowProtocol=t.UserPledgeGoldShowResponse=t.UserPledgeGoldShowRequest=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts");t.UserPledgeGoldShowRequest=n.type({isAnonymous:n.boolean,amount:n.number},"UserPledgeGoldShowRequest"),t.UserPledgeGoldShowResponse=i.createResultType(n.type({amount:n.number,maxGold:n.number,isPrebillRequired:n.boolean},"UserPledgeGoldShowSuccessResponse"),n.type({failureReason:n.union([n.literal("error"),n.literal("mingold"),n.literal("preauth"),n.literal("shackled")])},"UserPledgeGoldShowFailureResponse"),"UserPledgeGoldShowResponse"),t.userGoldShowProtocol=[new i.RoomRequestTypeWithParam("pledgeGoldShow",t.UserPledgeGoldShowRequest,t.UserPledgeGoldShowResponse)]},"../../../../src/room/shared/protocol/user/index.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.userProtocol=t.IUserConnectionInfo=t.getConnectionInfoRequestType=void 0;var n=r("../../../../src/room/shared/protocol/user/connectionInfo.ts"),i=r("../../../../src/room/shared/protocol/user/chat.ts"),a=r("../../../../src/room/shared/protocol/user/goldShow.ts"),o=r("../../../../src/room/shared/protocol/user/userlist.ts"),s=r("../../../../src/room/shared/protocol/user/streamfansExclusive.ts"),u=r("../../../../src/room/shared/protocol/user/gold.ts"),c=r("../../../../src/room/shared/protocol/user/paidShow.ts"),d=r("../../../../src/room/shared/protocol/user/payoff.ts"),f=r("../../../../src/room/shared/protocol/user/showProperty.ts"),h=r("../../../../src/room/shared/protocol/user/connectionInfo.ts");Object.defineProperty(t,"getConnectionInfoRequestType",{enumerable:!0,get:function(){return h.getConnectionInfoRequestType}}),Object.defineProperty(t,"IUserConnectionInfo",{enumerable:!0,get:function(){return h.IUserConnectionInfo}}),t.userProtocol=[].concat(l(n.userConnectionInfoProtocol),l(a.userGoldShowProtocol),l(i.userSendMessageProtocol),l(o.userListProtocol),l(s.streamfansExclusiveProtocol),l(u.userGoldProtocol),l(c.userPaidShowProtocol),l(d.userPayoffProtocol),l(f.showPropertyProtocol))},"../../../../src/room/shared/protocol/user/paidShow.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.userPaidShowProtocol=t.ClientAuthorizeInfo=t.UserBlockSessionRequest=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts");t.UserBlockSessionRequest=n.type({sessionType:n.union([n.literal("blockPrivate"),n.literal("blockExclusive")]),performerDiscountId:n.number,resumeBlockSessionStreamId:n.number,minimumDuration:n.number,remainingDuration:n.number},"UserBlockSessionRequest"),t.ClientAuthorizeInfo=n.type({userStreamId:n.number,maxGold:n.number},"ClientAuthorizeInfo"),t.userPaidShowProtocol=[new i.RoomRequestType("enterPrivate",t.ClientAuthorizeInfo),new i.RoomRequestType("requestExclusive",t.ClientAuthorizeInfo),new i.RoomRequestTypeWithParam("requestBlockSession",t.UserBlockSessionRequest,t.ClientAuthorizeInfo)]},"../../../../src/room/shared/protocol/user/payoff.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.userPayoffProtocol=void 0;var n=r("../../../../src/room/shared/rpc.ts");t.userPayoffProtocol=[new n.RoomRequestType("payoff")]},"../../../../src/room/shared/protocol/user/showProperty.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.showPropertyProtocol=t.propertyToHandler=t.EventPostfix=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts"),a=r("../../../../src/room/shared/protocol/shared/vibeStatus.ts");t.EventPostfix="Changed";t.propertyToHandler=function(e){return"".concat(e).concat(t.EventPostfix)};var o=function(e,r){return new i.RoomNotificationTypeWithParam("".concat(e).concat(t.EventPostfix),r)};t.showPropertyProtocol=[o("quickTipAllowed",n.boolean),o("vibeStatus",a.VibeStatus)]},"../../../../src/room/shared/protocol/user/streamfansExclusive.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.streamfansExclusiveProtocol=t.StreamfansExclusiveSessionStatusUpdate=t.StreamfansExclusiveSessionRequestResult=t.StreamfansExclusiveSessionRequest=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts");t.StreamfansExclusiveSessionRequest=n.type({priceItemId:n.number}),t.StreamfansExclusiveSessionRequestResult=i.createResultType(n.type({sessionId:n.string},"StreamfansExclusiveSessionRequestSuccessInfo"),n.type({errorInfo:n.string},"StreamfansExclusiveSessionRequestErrorInfo"),"StreamfansExclusiveSessionRequestResult"),t.StreamfansExclusiveSessionStatusUpdate=n.type({status:n.literal("started"),hasAccess:n.boolean},"StreamfansExclusiveSessionStatusUpdate"),t.streamfansExclusiveProtocol=[new i.RoomRequestTypeWithParam("requestStreamfansExclusiveSession",t.StreamfansExclusiveSessionRequest,t.StreamfansExclusiveSessionRequestResult),new i.RoomNotificationTypeWithParam("onStreamfansExclusiveSessionUpdated",t.StreamfansExclusiveSessionStatusUpdate)]},"../../../../src/room/shared/protocol/user/userlist.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.userListProtocol=t.IUserCountInfo=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("../../../../src/room/shared/rpc.ts");t.IUserCountInfo=n.type({totalUsers:n.number,isSolePrivateUser:n.boolean},"IUserCountInfo"),t.userListProtocol=[new i.RoomNotificationTypeWithParam("onUserCountUpdated",t.IUserCountInfo)]},"../../../../src/room/shared/publicResponseCodes.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PublicResponseCode=void 0;var n=r("../../../../src/room/shared/naiad.ts");t.PublicResponseCode=Object.freeze({invalidRoomTopic:n.ExtendedNaiadStatus.invalidRoomTopic})},"../../../../src/room/shared/rpc.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.connectionMessageTypes=t.IConnectionMetrics=t.createResultType=t.createClientProxy=t.IMessageChannel=t.RoomNotificationTypeWithParam=t.RoomNotificationType=t.RoomRequestTypeWithParam=t.RoomRequestType=void 0;var n=r("tslib"),i=r("./node_modules/vscode-jsonrpc/lib/main.js"),a=n.__importStar(r("io-ts")),o=r("../../../../src/room/shared/services/messaging.ts"),l=r("../../../../src/room/shared/validation.ts"),c=function(e){h(r,e);var t=p(r);function r(e,n){var i;return T(this,r),(i=t.call(this,"room/".concat(e))).name=e,i.returnSchema=n,i}return I(r)}(i.RequestType0);t.RoomRequestType=c;var d=function(e){h(r,e);var t=p(r);function r(e,n,i){var a;return T(this,r),(a=t.call(this,"room/".concat(e))).name=e,a.paramsSchema=n,a.returnSchema=i,a}return I(r)}(i.RequestType);t.RoomRequestTypeWithParam=d;var m=function(e){h(r,e);var t=p(r);function r(e){var n;return T(this,r),(n=t.call(this,"room/".concat(e))).name=e,n}return I(r)}(i.NotificationType0);t.RoomNotificationType=m;var g=function(e){h(r,e);var t=p(r);function r(e,n){var i;return T(this,r),(i=t.call(this,"room/".concat(e))).name=e,i.paramsSchema=n,i}return I(r)}(i.NotificationType);t.RoomNotificationTypeWithParam=g,t.IMessageChannel=Symbol("messageChannel"),t.createClientProxy=function(e,t,r,a){var c,h,p=new i.Emitter,v=new i.Emitter,y=new i.Emitter,b=new i.Emitter,E=new Map,S=[b,p,v];function T(){var e=function(){for(var e=0,t=S;e=4e3?new a.ConnectionError(t,e-4e3):e!==n.normalClosure&&e!==n.noStatusReceived&&e!==n.goingAway?new s(t,e):null}t.WebSocketError=s,t.errorFromSocketStatusCode=u;var l=function(){function e(t){var r=this;T(this,e),this.socket=t,this.onClosedEmitter=new i.Emitter,this.onErrorEmitter=new i.Emitter;var n=function(e,t){var n=u(e,t);null!==n&&r.onErrorEmitter.fire(n),r.onClosedEmitter.fire(),r.closeInternal()},a=function(e){r.onErrorEmitter.fire(e)};t.on?(t.on("close",(function e(t,i){r.socket.off("close",e),n(t,i)})),t.on("error",a)):t.addEventListener("close",(function e(t){var i=t.code,a=t.reason;r.socket.removeEventListener("close",e),n(i,a)})),this.stream=o(this.socket),this.stream.on("error",a)}return I(e,[{key:"readStream",get:function(){return this.stream}},{key:"writeStream",get:function(){return this.stream}},{key:"onClosed",get:function(){return this.onClosedEmitter.event}},{key:"onError",get:function(){return this.onErrorEmitter.event}},{key:"isOpen",get:function(){return this.socket.readyState===this.socket.OPEN}},{key:"closeInternal",value:function(){this.onErrorEmitter.dispose(),this.onClosedEmitter.dispose(),this.stream.destroy()}},{key:"close",value:function(e){this.isOpen?e?this.socket.close(e.code+4e3,e.message):this.socket.close(n.normalClosure,"session closed"):this.closeInternal()}}]),e}();t.WebSocketConnectionTransport=l},"../../../../src/room/shared/stopwatch.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Stopwatch=void 0;var n=function(){function e(){T(this,e),this._elapsed=0,this._currentStartTime=null}return I(e,[{key:"start",value:function(){this.stop(),this._currentStartTime=Date.now()}},{key:"stop",value:function(){null!=this._currentStartTime&&(this._elapsed+=Date.now()-this._currentStartTime,this._currentStartTime=null)}},{key:"reset",value:function(){this._elapsed=0,this._currentStartTime=null}},{key:"elapsed",get:function(){return null!==this._currentStartTime?this._elapsed+(Date.now()-this._currentStartTime):this._elapsed}}],[{key:"startNew",value:function(){var t=new e;return t.start(),t}}]),e}();t.Stopwatch=n},"../../../../src/room/shared/validation.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.withName=t.stringOfLength=t.enumType=t.decodeOrThrow=t.ValidationError=void 0;var n=r("tslib").__importStar(r("io-ts")),i=r("fp-ts/lib/Either"),a=r("io-ts-reporters"),o=function(e){h(r,e);var t=p(r);function r(e,n){var i;return T(this,r),(i=t.call(this,e.join(", "))).messages=e,i.internal=n,i}return I(r)}(v(Error));t.ValidationError=o,t.decodeOrThrow=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=e.decode(t);if(i.isLeft(n))throw new o(a.reporter(n),r);return n.right},t.enumType=function(e,t){var r=Object.values(e).map((function(e){return n.literal(e)}));return n.union(r,t)},t.stringOfLength=function(e,t){var r="string length must be >= ".concat(e," and <= ").concat(t);return new n.Type("length >= ".concat(e," and <= ").concat(t),n.string.is,(function(i,a){return i.length>=e&&i.length<=t?n.success(i):n.failure(i,a,r)}),n.string.encode)},t.withName=function(e,t){return new n.Type(t,e.is,e.validate,e.encode)}},"../../src/client.ts":function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.createClient=void 0;var i=r("tslib"),a=r("../../../../src/room/shared/rpc.ts"),o=r("../../../../src/room/shared/common.ts"),s=r("../../../../src/room/shared/heartbeat.ts"),u=r("../../../../src/room/shared/stopwatch.ts"),l={handshakeTimeoutMs:1e4,heartbeatFrequencyMs:15e3,heartbeatTimeoutMs:1e4},c=null!==(n="icf-room-client-user")?n:"dev",d=null!=="9.17.0"?"9.17.0":"0.0.0";t.createClient=function(e,t,r,n,h,p){var m=this;e.connectionParams.tracking&&(e.connectionParams.tracking=JSON.stringify(e.connectionParams.tracking));var g,v,y,b=Object.assign(Object.assign(Object.assign({},l),e),{connectionParams:Object.assign(Object.assign({},e.connectionParams),{clientName:c,clientVersion:d})}),E=p.child({performerName:b.connectionParams.performerName});return a.createClientProxy(h,(function(){return i.__awaiter(m,void 0,void 0,f().mark((function e(){var n,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y=u.Stopwatch.startNew(),E.info("opening connection"),n=u.Stopwatch.startNew(),e.next=5,t.createTransport(b.transportOptions,b.connectionParams,E);case 5:return i=e.sent,n.stop(),g=n.elapsed,a=u.Stopwatch.startNew(),e.next=11,r.create(i,E);case 11:return(o=e.sent).listen(),a.stop(),v=a.elapsed,e.abrupt("return",[o,i]);case 16:case"end":return e.stop()}}),e)})))}),(function(e,t){return i.__awaiter(m,void 0,void 0,f().mark((function r(){var i,l;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return e.onRequest(a.connectionMessageTypes.connectionHeartbeat,(function(){E.debug("responding to connection heartbeat")})),r.prev=1,i=u.Stopwatch.startNew(),r.next=5,o.withTimeout(new Promise((function(r,i){t.onError((function(e){return i(e)})),e.onError((function(e){return i(e)})),t.onClosed((function(){return i(new Error("Connection closed during handshake"))})),n(e).then(r,i)})),b.handshakeTimeoutMs,"connection handshake");case 5:return l=r.sent,i.stop(),E.info("client session established"),e.sendNotification(a.connectionMessageTypes.connectionMetrics,{initialConnectionInfoDuration:i.elapsed,messageChannelCreateDuration:v,totalDuration:y.elapsed,transportCreateDuration:g}),r.abrupt("return",[l,new s.MessageChannelHeartbeatRunner(e,b.heartbeatFrequencyMs,b.heartbeatTimeoutMs)]);case 12:throw r.prev=12,r.t0=r.catch(1),t.isOpen&&t.close(),e.dispose(),r.t0;case 17:case"end":return r.stop()}}),r,null,[[1,12]])})))}),e.xmentSelections)}},"../../src/commonExports.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PublicResponseCode=t.WebSocketStatusCode=t.WebSocketError=t.TimeoutError=t.naiadCodeToDisconnectParams=t.ExtendedNaiadStatus=t.ConnectionErrorCode=t.ConnectionError=t.ConsoleLogger=t.ILogger=void 0;var n=r("../../../../src/room/shared/naiad.ts");Object.defineProperty(t,"ExtendedNaiadStatus",{enumerable:!0,get:function(){return n.ExtendedNaiadStatus}}),Object.defineProperty(t,"naiadCodeToDisconnectParams",{enumerable:!0,get:function(){return n.naiadCodeToDisconnectParams}});var i=r("../../../../src/room/shared/services/logging.ts");Object.defineProperty(t,"ILogger",{enumerable:!0,get:function(){return i.ILogger}});var a=r("../../../../src/room/shared/services/websocket.ts");Object.defineProperty(t,"WebSocketError",{enumerable:!0,get:function(){return a.WebSocketError}}),Object.defineProperty(t,"WebSocketStatusCode",{enumerable:!0,get:function(){return a.WebSocketStatusCode}});var o=r("../../../../src/room/shared/common.ts");Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return o.TimeoutError}});var s=r("../../src/logging.ts");Object.defineProperty(t,"ConsoleLogger",{enumerable:!0,get:function(){return s.ConsoleLogger}});var u=r("../../../../src/room/shared/connections.ts");Object.defineProperty(t,"ConnectionError",{enumerable:!0,get:function(){return u.ConnectionError}}),Object.defineProperty(t,"ConnectionErrorCode",{enumerable:!0,get:function(){return u.ConnectionErrorCode}});var l=r("../../../../src/room/shared/publicResponseCodes.ts");Object.defineProperty(t,"PublicResponseCode",{enumerable:!0,get:function(){return l.PublicResponseCode}})},"../../src/logging.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsoleLogger=void 0;var n=["verbose","debug","info","warning","error","critical"],i=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};T(this,e),this.level=t,this.defaultLabels=r}return I(e,[{key:"applyLabels",value:function(e){return"string"==typeof e?{message:e,labels:this.defaultLabels}:Object.assign(Object.assign({},e),{labels:Object.assign(Object.assign({},this.defaultLabels),e.labels)})}},{key:"checkLevel",value:function(e){return n.indexOf(e)>=n.indexOf(this.level)}},{key:"critical",value:function(e){this.checkLevel("critical")&&console.error(this.applyLabels(e))}},{key:"error",value:function(e){this.checkLevel("error")&&console.error(this.applyLabels(e))}},{key:"warning",value:function(e){this.checkLevel("warning")&&console.warn(this.applyLabels(e))}},{key:"info",value:function(e){this.checkLevel("info")&&console.log(this.applyLabels(e))}},{key:"debug",value:function(e){this.checkLevel("debug")&&console.debug(this.applyLabels(e))}},{key:"verbose",value:function(e){this.checkLevel("verbose")&&console.debug(this.applyLabels(e))}},{key:"log",value:function(e,t){throw Error("Method not implemented")}},{key:"child",value:function(t){return new e(this.level,Object.assign(Object.assign({},this.defaultLabels),t))}}]),e}();t.ConsoleLogger=i},"../../src/utilities.ts":function(e,t,r){"use strict";function n(e){return e.replace(/\/$/,"").replace(/^\//,"")}Object.defineProperty(t,"__esModule",{value:!0}),t.formatUrl=void 0,t.formatUrl=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=0===Object.keys(r).length?"":"?".concat(Object.entries(r).filter((function(e){var t=u(e,2)[1];return!(null==t)})).map((function(e){var t=u(e,2),r=t[0],n=t[1];return"".concat(r,"=").concat("string"==typeof n?encodeURIComponent(n):n)})).join("&"));return"".concat(n(e),"/").concat(n(t)).concat(i)}},"../../src/websocket.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketTransportProvider=void 0;var n=r("tslib"),i=n.__importDefault(r("isomorphic-ws")),a=r("../../../../src/room/shared/services/websocket.ts"),o=r("../../src/utilities.ts"),s=r("../../../../src/room/shared/common.ts");function u(e,t,r,o){return n.__awaiter(this,void 0,void 0,f().mark((function n(){var u,l;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=new s.Deferred,(l="Server"in i.default?new i.default(e,r,o):new i.default(e,r)).binaryType="arraybuffer",l.onopen=function(){u.resolve(l)},l.onclose=function(e){var t=a.errorFromSocketStatusCode(e.code,e.reason);t&&u.reject(t)},l.onerror=function(e){e.error&&u.reject(e.error)},n.prev=6,n.next=9,s.withTimeout(u.promise,t,"WebSocket connection");case 9:return n.abrupt("return",n.sent);case 12:throw n.prev=12,n.t0=n.catch(6),l.readyState!==l.CLOSED&&l.close(),n.t0;case 16:case"end":return n.stop()}}),n,null,[[6,12]])})))}var l=function(){function e(){T(this,e)}return I(e,[{key:"createTransport",value:function(e,t,r){var i=e.webSocketUrl,s=e.connectionTimeoutMs,l=e.webSocketOptions;return n.__awaiter(this,void 0,void 0,f().mark((function e(){var n,c,d,h;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.saKey?["saKey_".concat(t.saKey)]:[],c=Object.assign(Object.assign({},t),{saKey:void 0}),d=o.formatUrl(i,"v1/room/socket",c),r.info("opening websocket connection: ".concat(d)),e.next=6,u(d,null!=s?s:1e4,n,l);case 6:return h=e.sent,e.abrupt("return",new a.WebSocketConnectionTransport(h));case 8:case"end":return e.stop()}}),e)})))}}]),e}();t.WebSocketTransportProvider=l},"./node_modules/vscode-jsonrpc/lib/cancellation.js":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r("./node_modules/vscode-jsonrpc/lib/events.js"),a=r("./node_modules/vscode-jsonrpc/lib/is.js");!function(e){e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:i.Event.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:i.Event.None}),e.is=function(t){var r=t;return r&&(r===e.None||r===e.Cancelled||a.boolean(r.isCancellationRequested)&&!!r.onCancellationRequested)}}(n=t.CancellationToken||(t.CancellationToken={}));var o=Object.freeze((function(e,t){var r=setTimeout(e.bind(t),0);return{dispose:function(){clearTimeout(r)}}})),s=function(){function e(){T(this,e),this._isCancelled=!1}return I(e,[{key:"cancel",value:function(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}},{key:"isCancellationRequested",get:function(){return this._isCancelled}},{key:"onCancellationRequested",get:function(){return this._isCancelled?o:(this._emitter||(this._emitter=new i.Emitter),this._emitter.event)}},{key:"dispose",value:function(){this._emitter&&(this._emitter.dispose(),this._emitter=void 0)}}]),e}(),u=function(){function e(){T(this,e)}return I(e,[{key:"token",get:function(){return this._token||(this._token=new s),this._token}},{key:"cancel",value:function(){this._token?this._token.cancel():this._token=n.Cancelled}},{key:"dispose",value:function(){this._token?this._token instanceof s&&this._token.dispose():this._token=n.None}}]),e}();t.CancellationTokenSource=u},"./node_modules/vscode-jsonrpc/lib/events.js":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.create=function(e){return{dispose:e}}}(t.Disposable||(t.Disposable={})),function(e){var t={dispose:function(){}};e.None=function(){return t}}(t.Event||(t.Event={}));var n=function(){function e(){T(this,e)}return I(e,[{key:"add",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2?arguments[2]:void 0;this._callbacks||(this._callbacks=[],this._contexts=[]),this._callbacks.push(e),this._contexts.push(r),Array.isArray(n)&&n.push({dispose:function(){return t.remove(e,r)}})}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this._callbacks){for(var r=!1,n=0,i=this._callbacks.length;n2&&void 0!==arguments[2]?arguments[2]:n.None,i=this._map.get(e);if(i)i.value=t,r!==n.None&&this.touch(i,r);else{switch(i={key:e,value:t,next:void 0,previous:void 0},r){case n.None:this.addItemLast(i);break;case n.First:this.addItemFirst(i);break;case n.Last:default:this.addItemLast(i)}this._map.set(e,i),this._size++}}},{key:"delete",value:function(e){var t=this._map.get(e);return!!t&&(this._map.delete(e),this.removeItem(t),this._size--,!0)}},{key:"shift",value:function(){if(this._head||this._tail){if(!this._head||!this._tail)throw new Error("Invalid list");var e=this._head;return this._map.delete(e.key),this.removeItem(e),this._size--,e.value}}},{key:"forEach",value:function(e,t){for(var r=this._head;r;)t?e.bind(t)(r.value,r.key,this):e(r.value,r.key,this),r=r.next}},{key:"forEachReverse",value:function(e,t){for(var r=this._tail;r;)t?e.bind(t)(r.value,r.key,this):e(r.value,r.key,this),r=r.previous}},{key:"values",value:function(){for(var e=[],t=this._head;t;)e.push(t.value),t=t.next;return e}},{key:"keys",value:function(){for(var e=[],t=this._head;t;)e.push(t.key),t=t.next;return e}},{key:"addItemFirst",value:function(e){if(this._head||this._tail){if(!this._head)throw new Error("Invalid list");e.next=this._head,this._head.previous=e}else this._tail=e;this._head=e}},{key:"addItemLast",value:function(e){if(this._head||this._tail){if(!this._tail)throw new Error("Invalid list");e.previous=this._tail,this._tail.next=e}else this._head=e;this._tail=e}},{key:"removeItem",value:function(e){if(e===this._head&&e===this._tail)this._head=void 0,this._tail=void 0;else if(e===this._head)this._head=e.next;else if(e===this._tail)this._tail=e.previous;else{var t=e.next,r=e.previous;if(!t||!r)throw new Error("Invalid list");t.previous=r,r.next=t}}},{key:"touch",value:function(e,t){if(!this._head||!this._tail)throw new Error("Invalid list");if(t===n.First||t===n.Last)if(t===n.First){if(e===this._head)return;var r=e.next,i=e.previous;e===this._tail?(i.next=void 0,this._tail=i):(r.previous=i,i.next=r),e.previous=void 0,e.next=this._head,this._head.previous=e,this._head=e}else if(t===n.Last){if(e===this._tail)return;var a=e.next,o=e.previous;e===this._head?(a.previous=void 0,this._head=a):(a.previous=o,o.next=a),e.next=void 0,e.previous=this._tail,this._tail.next=e,this._tail=e}}}]),e}();t.LinkedMap=i},"./node_modules/vscode-jsonrpc/lib/main.js":function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0});var i=r("./node_modules/vscode-jsonrpc/lib/is.js"),a=r("./node_modules/vscode-jsonrpc/lib/messages.js");t.RequestType=a.RequestType,t.RequestType0=a.RequestType0,t.RequestType1=a.RequestType1,t.RequestType2=a.RequestType2,t.RequestType3=a.RequestType3,t.RequestType4=a.RequestType4,t.RequestType5=a.RequestType5,t.RequestType6=a.RequestType6,t.RequestType7=a.RequestType7,t.RequestType8=a.RequestType8,t.RequestType9=a.RequestType9,t.ResponseError=a.ResponseError,t.ErrorCodes=a.ErrorCodes,t.NotificationType=a.NotificationType,t.NotificationType0=a.NotificationType0,t.NotificationType1=a.NotificationType1,t.NotificationType2=a.NotificationType2,t.NotificationType3=a.NotificationType3,t.NotificationType4=a.NotificationType4,t.NotificationType5=a.NotificationType5,t.NotificationType6=a.NotificationType6,t.NotificationType7=a.NotificationType7,t.NotificationType8=a.NotificationType8,t.NotificationType9=a.NotificationType9;var o=r("./node_modules/vscode-jsonrpc/lib/messageReader.js");t.MessageReader=o.MessageReader,t.StreamMessageReader=o.StreamMessageReader,t.IPCMessageReader=o.IPCMessageReader,t.SocketMessageReader=o.SocketMessageReader;var s=r("./node_modules/vscode-jsonrpc/lib/messageWriter.js");t.MessageWriter=s.MessageWriter,t.StreamMessageWriter=s.StreamMessageWriter,t.IPCMessageWriter=s.IPCMessageWriter,t.SocketMessageWriter=s.SocketMessageWriter;var u=r("./node_modules/vscode-jsonrpc/lib/events.js");t.Disposable=u.Disposable,t.Event=u.Event,t.Emitter=u.Emitter;var c=r("./node_modules/vscode-jsonrpc/lib/cancellation.js");t.CancellationTokenSource=c.CancellationTokenSource,t.CancellationToken=c.CancellationToken;var d,f,m=r("./node_modules/vscode-jsonrpc/lib/linkedMap.js");n(r("./src/noop.ts")),n(r("./src/noop.ts")),function(e){e.type=new a.NotificationType("$/cancelRequest")}(d||(d={})),function(e){e.type=new a.NotificationType("$/progress")}(f||(f={}));var y,b,E,S,R,_=I((function e(){T(this,e)}));t.ProgressType=_,t.NullLogger=Object.freeze({error:function(){},warn:function(){},info:function(){},log:function(){}}),function(e){e[e.Off=0]="Off",e[e.Messages=1]="Messages",e[e.Verbose=2]="Verbose"}(y=t.Trace||(t.Trace={})),function(e){e.fromString=function(t){if(!i.string(t))return e.Off;switch(t=t.toLowerCase()){case"off":return e.Off;case"messages":return e.Messages;case"verbose":return e.Verbose;default:return e.Off}},e.toString=function(t){switch(t){case e.Off:return"off";case e.Messages:return"messages";case e.Verbose:return"verbose";default:return"off"}}}(y=t.Trace||(t.Trace={})),function(e){e.Text="text",e.JSON="json"}(t.TraceFormat||(t.TraceFormat={})),function(e){e.fromString=function(t){return"json"===(t=t.toLowerCase())?e.JSON:e.Text}}(b=t.TraceFormat||(t.TraceFormat={})),function(e){e.type=new a.NotificationType("$/setTraceNotification")}(E=t.SetTraceNotification||(t.SetTraceNotification={})),function(e){e.type=new a.NotificationType("$/logTraceNotification")}(S=t.LogTraceNotification||(t.LogTraceNotification={})),function(e){e[e.Closed=1]="Closed",e[e.Disposed=2]="Disposed",e[e.AlreadyListening=3]="AlreadyListening"}(R=t.ConnectionErrors||(t.ConnectionErrors={}));var w,k,A,L,x,C=function(e){h(r,e);var t=p(r);function r(e,n){var i;return T(this,r),(i=t.call(this,n)).code=e,Object.setPrototypeOf(g(i),r.prototype),i}return I(r)}(v(Error));function M(e,t,r,n){var o,s,h=0,p=0,g=0,v=void 0,T=Object.create(null),I=void 0,_=Object.create(null),w=new Map,k=new m.LinkedMap,A=Object.create(null),M=Object.create(null),O=y.Off,D=b.Text,P=x.New,F=new u.Emitter,N=new u.Emitter,U=new u.Emitter,W=new u.Emitter,j=new u.Emitter,B=n&&n.cancellationStrategy?n.cancellationStrategy:L.Message;function G(e){return"req-"+e.toString()}function q(e,t){var r;a.isRequestMessage(t)?e.set(G(t.id),t):a.isResponseMessage(t)?e.set(null===(r=t.id)?"res-unknown-"+(++g).toString():"res-"+r.toString(),t):e.set("not-"+(++p).toString(),t)}function K(e){}function H(){return P===x.Listening}function V(){return P===x.Closed}function z(){return P===x.Disposed}function Y(){P!==x.New&&P!==x.Listening||(P=x.Closed,N.fire(void 0))}function X(){o||0===k.size||(o=setImmediate((function(){o=void 0,function(){if(0===k.size)return;var e=k.shift();try{a.isRequestMessage(e)?function(e){if(z())return;function r(r,n,i){var o={jsonrpc:"2.0",id:e.id};r instanceof a.ResponseError?o.error=r.toJson():o.result=void 0===r?null:r,Z(o,n,i),t.write(o)}function n(r,n,i){var a={jsonrpc:"2.0",id:e.id,error:r.toJson()};Z(a,n,i),t.write(a)}!function(e){if(O===y.Off||!s)return;if(D===b.Text){var t=void 0;O===y.Verbose&&e.params&&(t="Params: ".concat(JSON.stringify(e.params,null,4),"\n\n")),s.log("Received request '".concat(e.method," - (").concat(e.id,")'."),t)}else ee("receive-request",e)}(e);var o,u,c=T[e.method];c&&(o=c.type,u=c.handler);var d=Date.now();if(u||v){var f=String(e.id),h=B.receiver.createCancellationTokenSource(f);M[f]=h;try{var p,m=p=void 0===e.params||void 0!==o&&0===o.numberOfParams?u?u(h.token):v(e.method,h.token):i.array(e.params)&&(void 0===o||o.numberOfParams>1)?u?u.apply(void 0,l(e.params).concat([h.token])):v.apply(void 0,[e.method].concat(l(e.params),[h.token])):u?u(e.params,h.token):v(e.method,e.params,h.token);p?m.then?m.then((function(t){delete M[f],r(t,e.method,d)}),(function(t){delete M[f],t instanceof a.ResponseError?n(t,e.method,d):t&&i.string(t.message)?n(new a.ResponseError(a.ErrorCodes.InternalError,"Request ".concat(e.method," failed with message: ").concat(t.message)),e.method,d):n(new a.ResponseError(a.ErrorCodes.InternalError,"Request ".concat(e.method," failed unexpectedly without providing any details.")),e.method,d)})):(delete M[f],r(p,e.method,d)):(delete M[f],function(r,n,i){void 0===r&&(r=null);var a={jsonrpc:"2.0",id:e.id,result:r};Z(a,n,i),t.write(a)}(p,e.method,d))}catch(t){delete M[f],t instanceof a.ResponseError?r(t,e.method,d):t&&i.string(t.message)?n(new a.ResponseError(a.ErrorCodes.InternalError,"Request ".concat(e.method," failed with message: ").concat(t.message)),e.method,d):n(new a.ResponseError(a.ErrorCodes.InternalError,"Request ".concat(e.method," failed unexpectedly without providing any details.")),e.method,d)}}else n(new a.ResponseError(a.ErrorCodes.MethodNotFound,"Unhandled method ".concat(e.method)),e.method,d)}(e):a.isNotificationMessage(e)?function(e){if(z())return;var t,n=void 0;if(e.method===d.type.method)t=function(e){var t=e.id,r=M[String(t)];r&&r.cancel()};else{var a=_[e.method];a&&(t=a.handler,n=a.type)}if(t||I)try{!function(e){if(O===y.Off||!s||e.method===S.type.method)return;if(D===b.Text){var t=void 0;O===y.Verbose&&(t=e.params?"Params: ".concat(JSON.stringify(e.params,null,4),"\n\n"):"No parameters provided.\n\n"),s.log("Received notification '".concat(e.method,"'."),t)}else ee("receive-notification",e)}(e),void 0===e.params||void 0!==n&&0===n.numberOfParams?t?t():I(e.method):i.array(e.params)&&(void 0===n||n.numberOfParams>1)?t?t.apply(void 0,l(e.params)):I.apply(void 0,[e.method].concat(l(e.params))):t?t(e.params):I(e.method,e.params)}catch(t){t.message?r.error("Notification handler '".concat(e.method,"' failed with message: ").concat(t.message)):r.error("Notification handler '".concat(e.method,"' failed unexpectedly."))}else U.fire(e)}(e):a.isResponseMessage(e)?function(e){if(z())return;if(null===e.id)e.error?r.error("Received response message without id: Error is: \n".concat(JSON.stringify(e.error,void 0,4))):r.error("Received response message without id. No further error information provided.");else{var t=String(e.id),n=A[t];if(function(e,t){if(O===y.Off||!s)return;if(D===b.Text){var r=void 0;if(O===y.Verbose&&(e.error&&e.error.data?r="Error data: ".concat(JSON.stringify(e.error.data,null,4),"\n\n"):e.result?r="Result: ".concat(JSON.stringify(e.result,null,4),"\n\n"):void 0===e.error&&(r="No result returned.\n\n")),t){var n=e.error?" Request failed: ".concat(e.error.message," (").concat(e.error.code,")."):"";s.log("Received response '".concat(t.method," - (").concat(e.id,")' in ").concat(Date.now()-t.timerStart,"ms.").concat(n),r)}else s.log("Received response ".concat(e.id," without active response promise."),r)}else ee("receive-response",e)}(e,n),n){delete A[t];try{if(e.error){var i=e.error;n.reject(new a.ResponseError(i.code,i.message,i.data))}else{if(void 0===e.result)throw new Error("Should never happen.");n.resolve(e.result)}}catch(i){i.message?r.error("Response handler '".concat(n.method,"' failed with message: ").concat(i.message)):r.error("Response handler '".concat(n.method,"' failed unexpectedly."))}}}}(e):function(e){if(!e)return void r.error("Received empty message.");r.error("Received message which is neither a response nor a notification message:\n".concat(JSON.stringify(e,null,4)));var t=e;if(i.string(t.id)||i.number(t.id)){var n=String(t.id),a=A[n];a&&a.reject(new Error("The received response has neither a result nor an error property."))}}(e)}finally{X()}}()})))}e.onClose(Y),e.onError((function(e){F.fire([e,void 0,void 0])})),t.onClose(Y),t.onError((function(e){F.fire(e)}));var $=function(e){var r;try{if(a.isNotificationMessage(e)&&e.method===d.type.method){var i=G(e.params.id),o=k.get(i);if(a.isRequestMessage(o)){var s=null===(r=n)||void 0===r?void 0:r.connectionStrategy,u=s&&s.cancelUndispatched?s.cancelUndispatched(o,K):void 0;if(u&&(void 0!==u.error||void 0!==u.result))return k.delete(i),u.id=o.id,Z(u,e.method,Date.now()),void t.write(u)}}q(k,e)}finally{X()}};function J(e){if(O!==y.Off&&s)if(D===b.Text){var t=void 0;O===y.Verbose&&e.params&&(t="Params: ".concat(JSON.stringify(e.params,null,4),"\n\n")),s.log("Sending request '".concat(e.method," - (").concat(e.id,")'."),t)}else ee("send-request",e)}function Q(e){if(O!==y.Off&&s)if(D===b.Text){var t=void 0;O===y.Verbose&&(t=e.params?"Params: ".concat(JSON.stringify(e.params,null,4),"\n\n"):"No parameters provided.\n\n"),s.log("Sending notification '".concat(e.method,"'."),t)}else ee("send-notification",e)}function Z(e,t,r){if(O!==y.Off&&s)if(D===b.Text){var n=void 0;O===y.Verbose&&(e.error&&e.error.data?n="Error data: ".concat(JSON.stringify(e.error.data,null,4),"\n\n"):e.result?n="Result: ".concat(JSON.stringify(e.result,null,4),"\n\n"):void 0===e.error&&(n="No result returned.\n\n")),s.log("Sending response '".concat(t," - (").concat(e.id,")'. Processing request took ").concat(Date.now()-r,"ms"),n)}else ee("send-response",e)}function ee(e,t){if(s&&O!==y.Off){var r={isLSPMessage:!0,type:e,message:t,timestamp:Date.now()};s.log(r)}}function te(){if(V())throw new C(R.Closed,"Connection is closed.");if(z())throw new C(R.Disposed,"Connection is disposed.")}function re(){if(!H())throw new Error("Call listen() first.")}function ne(e){return void 0===e?null:e}function ie(e,t){var r,n=e.numberOfParams;switch(n){case 0:r=null;break;case 1:r=ne(t[0]);break;default:r=[];for(var i=0;i1?a-1:0),s=1;s1?s-1:0),l=1;l0&&void 0!==arguments[0]?arguments[0]:"utf8";T(this,e),this.encoding=t,this.index=0,this.buffer=n.allocUnsafe(8192)}return I(e,[{key:"append",value:function(e){var t=e;if("string"==typeof e){var r=e,i=n.byteLength(r,this.encoding);(t=n.allocUnsafe(i)).write(r,0,i,this.encoding)}if(this.buffer.length-this.index>=t.length)t.copy(this.buffer,this.index,0,t.length);else{var a=8192*(Math.ceil((this.index+t.length)/8192)+1);0===this.index?(this.buffer=n.allocUnsafe(a),t.copy(this.buffer,0,0,t.length)):this.buffer=n.concat([this.buffer.slice(0,this.index),t],a)}this.index+=t.length}},{key:"tryReadHeaders",value:function(){for(var e=void 0,t=0;t+3=this.index)return e;e=Object.create(null),this.buffer.toString("ascii",0,t).split("\r\n").forEach((function(t){var r=t.indexOf(":");if(-1===r)throw new Error("Message header must separate key and value using :");var n=t.substr(0,r),i=t.substr(r+1).trim();e[n]=i}));var r=t+4;return this.buffer=this.buffer.slice(r),this.index=this.index-r,e}},{key:"tryReadContent",value:function(e){if(this.index1&&void 0!==arguments[1]?arguments[1]:"utf8";return T(this,r),(n=t.call(this)).readable=e,n.buffer=new u(i),n._partialMessageTimeout=1e4,n}return I(r,[{key:"partialMessageTimeout",get:function(){return this._partialMessageTimeout},set:function(e){this._partialMessageTimeout=e}},{key:"listen",value:function(e){var t=this;this.nextMessageLength=-1,this.messageToken=0,this.partialMessageTimer=void 0,this.callback=e,this.readable.on("data",(function(e){t.onData(e)})),this.readable.on("error",(function(e){return t.fireError(e)})),this.readable.on("close",(function(){return t.fireClose()}))}},{key:"onData",value:function(e){for(this.buffer.append(e);;){if(-1===this.nextMessageLength){var t=this.buffer.tryReadHeaders();if(!t)return;var r=t["Content-Length"];if(!r)throw new Error("Header must provide a Content-Length property.");var n=parseInt(r);if(isNaN(n))throw new Error("Content-Length value must be a number.");this.nextMessageLength=n}var i=this.buffer.tryReadContent(this.nextMessageLength);if(null===i)return void this.setPartialMessageTimer();this.clearPartialMessageTimer(),this.nextMessageLength=-1,this.messageToken++;var a=JSON.parse(i);this.callback(a)}}},{key:"clearPartialMessageTimer",value:function(){this.partialMessageTimer&&(clearTimeout(this.partialMessageTimer),this.partialMessageTimer=void 0)}},{key:"setPartialMessageTimer",value:function(){var e=this;this.clearPartialMessageTimer(),this._partialMessageTimeout<=0||(this.partialMessageTimer=setTimeout((function(t,r){e.partialMessageTimer=void 0,t===e.messageToken&&(e.firePartialMessage({messageToken:t,waitingTime:r}),e.setPartialMessageTimer())}),this._partialMessageTimeout,this.messageToken,this._partialMessageTimeout))}}]),r}(l);t.StreamMessageReader=c;var d=function(e){h(r,e);var t=p(r);function r(e){var n;T(this,r),(n=t.call(this)).process=e;var i=n.process;return i.on("error",(function(e){return n.fireError(e)})),i.on("close",(function(){return n.fireClose()})),n}return I(r,[{key:"listen",value:function(e){this.process.on("message",e)}}]),r}(l);t.IPCMessageReader=d;var f=function(e){h(r,e);var t=p(r);function r(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf-8";return T(this,r),t.call(this,e,n)}return I(r)}(c);t.SocketMessageReader=f},"./node_modules/vscode-jsonrpc/lib/messageWriter.js":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=r("./node_modules/vscode-jsonrpc/lib/events.js"),o=r("./node_modules/vscode-jsonrpc/lib/is.js");!function(e){e.is=function(e){var t=e;return t&&o.func(t.dispose)&&o.func(t.onClose)&&o.func(t.onError)&&o.func(t.write)}}(t.MessageWriter||(t.MessageWriter={}));var s=function(){function e(){T(this,e),this.errorEmitter=new a.Emitter,this.closeEmitter=new a.Emitter}return I(e,[{key:"dispose",value:function(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}},{key:"onError",get:function(){return this.errorEmitter.event}},{key:"fireError",value:function(e,t,r){this.errorEmitter.fire([this.asError(e),t,r])}},{key:"onClose",get:function(){return this.closeEmitter.event}},{key:"fireClose",value:function(){this.closeEmitter.fire(void 0)}},{key:"asError",value:function(e){return e instanceof Error?e:new Error("Writer received error. Reason: ".concat(o.string(e.message)?e.message:"unknown"))}}]),e}();t.AbstractMessageWriter=s;var u=function(e){h(r,e);var t=p(r);function r(e){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";return T(this,r),(n=t.call(this)).writable=e,n.encoding=i,n.errorCount=0,n.writable.on("error",(function(e){return n.fireError(e)})),n.writable.on("close",(function(){return n.fireClose()})),n}return I(r,[{key:"write",value:function(e){var t=JSON.stringify(e),r=["Content-Length: ",n.byteLength(t,this.encoding).toString(),"\r\n","\r\n"];try{this.writable.write(r.join(""),"ascii"),this.writable.write(t,this.encoding),this.errorCount=0}catch(t){this.errorCount++,this.fireError(t,e,this.errorCount)}}}]),r}(s);t.StreamMessageWriter=u;var l=function(e){h(r,e);var t=p(r);function r(e){var n;T(this,r),(n=t.call(this)).process=e,n.errorCount=0,n.queue=[],n.sending=!1;var i=n.process;return i.on("error",(function(e){return n.fireError(e)})),i.on("close",(function(){return n.fireClose})),n}return I(r,[{key:"write",value:function(e){this.sending||0!==this.queue.length?this.queue.push(e):this.doWriteMessage(e)}},{key:"doWriteMessage",value:function(e){var t=this;try{this.process.send&&(this.sending=!0,this.process.send(e,void 0,void 0,(function(r){t.sending=!1,r?(t.errorCount++,t.fireError(r,e,t.errorCount)):t.errorCount=0,t.queue.length>0&&t.doWriteMessage(t.queue.shift())})))}catch(t){this.errorCount++,this.fireError(t,e,this.errorCount)}}}]),r}(s);t.IPCMessageWriter=l;var c=function(e){h(r,e);var t=p(r);function r(e){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";return T(this,r),(n=t.call(this)).socket=e,n.queue=[],n.sending=!1,n.encoding=i,n.errorCount=0,n.socket.on("error",(function(e){return n.fireError(e)})),n.socket.on("close",(function(){return n.fireClose()})),n}return I(r,[{key:"dispose",value:function(){i(r,"dispose",this,3)([]),this.socket.destroy()}},{key:"write",value:function(e){this.sending||0!==this.queue.length?this.queue.push(e):this.doWriteMessage(e)}},{key:"doWriteMessage",value:function(e){var t=this,r=JSON.stringify(e),i=["Content-Length: ",n.byteLength(r,this.encoding).toString(),"\r\n","\r\n"];try{this.sending=!0,this.socket.write(i.join(""),"ascii",(function(n){n&&t.handleError(n,e);try{t.socket.write(r,t.encoding,(function(r){t.sending=!1,r?t.handleError(r,e):t.errorCount=0,t.queue.length>0&&t.doWriteMessage(t.queue.shift())}))}catch(n){t.handleError(n,e)}}))}catch(t){this.handleError(t,e)}}},{key:"handleError",value:function(e,t){this.errorCount++,this.fireError(e,t,this.errorCount)}}]),r}(s);t.SocketMessageWriter=c},"./node_modules/vscode-jsonrpc/lib/messages.js":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r("./node_modules/vscode-jsonrpc/lib/is.js");!function(e){e.ParseError=-32700,e.InvalidRequest=-32600,e.MethodNotFound=-32601,e.InvalidParams=-32602,e.InternalError=-32603,e.serverErrorStart=-32099,e.serverErrorEnd=-32e3,e.ServerNotInitialized=-32002,e.UnknownErrorCode=-32001,e.RequestCancelled=-32800,e.ContentModified=-32801,e.MessageWriteError=1,e.MessageReadError=2}(n=t.ErrorCodes||(t.ErrorCodes={}));var a=function(e){h(r,e);var t=p(r);function r(e,a,o){var s;return T(this,r),(s=t.call(this,a)).code=i.number(e)?e:n.UnknownErrorCode,s.data=o,Object.setPrototypeOf(g(s),r.prototype),s}return I(r,[{key:"toJson",value:function(){return{code:this.code,message:this.message,data:this.data}}}]),r}(v(Error));t.ResponseError=a;var o=function(){function e(t,r){T(this,e),this._method=t,this._numberOfParams=r}return I(e,[{key:"method",get:function(){return this._method}},{key:"numberOfParams",get:function(){return this._numberOfParams}}]),e}();t.AbstractMessageType=o;var s=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,0)}return I(r)}(o);t.RequestType0=s;var u=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,1)}return I(r)}(o);t.RequestType=u;var l=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,1)}return I(r)}(o);t.RequestType1=l;var c=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,2)}return I(r)}(o);t.RequestType2=c;var d=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,3)}return I(r)}(o);t.RequestType3=d;var f=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,4)}return I(r)}(o);t.RequestType4=f;var m=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,5)}return I(r)}(o);t.RequestType5=m;var y=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,6)}return I(r)}(o);t.RequestType6=y;var b=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,7)}return I(r)}(o);t.RequestType7=b;var E=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,8)}return I(r)}(o);t.RequestType8=E;var S=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,9)}return I(r)}(o);t.RequestType9=S;var R=function(e){h(r,e);var t=p(r);function r(e){var n;return T(this,r),(n=t.call(this,e,1))._=void 0,n}return I(r)}(o);t.NotificationType=R;var _=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,0)}return I(r)}(o);t.NotificationType0=_;var w=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,1)}return I(r)}(o);t.NotificationType1=w;var k=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,2)}return I(r)}(o);t.NotificationType2=k;var A=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,3)}return I(r)}(o);t.NotificationType3=A;var L=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,4)}return I(r)}(o);t.NotificationType4=L;var x=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,5)}return I(r)}(o);t.NotificationType5=x;var C=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,6)}return I(r)}(o);t.NotificationType6=C;var M=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,7)}return I(r)}(o);t.NotificationType7=M;var O=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,8)}return I(r)}(o);t.NotificationType8=O;var D=function(e){h(r,e);var t=p(r);function r(e){return T(this,r),t.call(this,e,9)}return I(r)}(o);t.NotificationType9=D,t.isRequestMessage=function(e){var t=e;return t&&i.string(t.method)&&(i.string(t.id)||i.number(t.id))},t.isNotificationMessage=function(e){var t=e;return t&&i.string(t.method)&&void 0===e.id},t.isResponseMessage=function(e){var t=e;return t&&(void 0!==t.result||!!t.error)&&(i.string(t.id)||i.number(t.id)||null===t.id)}},"./src/index.ts":function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createUserRoomClient=void 0;var n=r("tslib");r("reflect-metadata");var i=r("../../src/websocket.ts"),a=r("../../../../src/room/shared/services/messaging.ts"),o=r("../../../../src/room/shared/protocol/shared/index.ts"),s=r("../../src/client.ts"),u=r("../../../../src/room/shared/protocol/user/index.ts"),l=r("../../src/logging.ts"),c=r("../../../../src/room/shared/protocol/user/connectionInfo.ts");n.__exportStar(r("../../src/commonExports.ts"),t),t.createUserRoomClient=function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new l.ConsoleLogger("info");return s.createClient(e,new i.WebSocketTransportProvider,new a.MessageChannelFactory,(function(e){return n.__awaiter(t,void 0,void 0,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new Promise((function(t){e.onNotification(c.connectionInfoChanged,t)}));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))}),[o.sharedProtocol,u.userProtocol],r)}},"./src/noop.ts":function(e,t,r){"use strict"},"fp-ts/lib/Either":function(e,t){e.exports=r("./node_modules/fp-ts/lib/Either.js")},inversify:function(e,t){e.exports=r("./node_modules/inversify/lib/inversify.js")},"io-ts":function(e,t){e.exports=r("./node_modules/io-ts/es6/index.js")},"io-ts-reporters":function(e,t){e.exports=r("./node_modules/io-ts-reporters/target/src/index.js")},"isomorphic-ws":function(e,t){e.exports=r("./node_modules/isomorphic-ws/browser.js")},"reflect-metadata":function(e,t){e.exports=r("./node_modules/reflect-metadata/Reflect.js")},tslib:function(e,t){e.exports=r("./node_modules/tslib/tslib.es6.mjs")},"vscode-jsonrpc/lib/messageReader":function(e,t){e.exports=r("./node_modules/vscode-jsonrpc/lib/messageReader.js")},"websocket-stream/stream":function(e,t){e.exports=r("./node_modules/websocket-stream/stream.js")}}))},"./node_modules/duplexify/index.js":(e,t,r)=>{var n=r("./node_modules/buffer/index.js").Buffer,i=r("./node_modules/process/browser.js"),a=r("./node_modules/readable-stream/readable-browser.js"),o=r("./node_modules/end-of-stream/index.js"),s=r("./node_modules/inherits/inherits_browser.js"),u=r("./node_modules/stream-shift/index.js"),l=n.from&&n.from!==Uint8Array.from?n.from([0]):new n([0]),c=function(e,t){e._corked?e.once("uncork",t):t()},d=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},f=function(e,t,r){if(!(this instanceof f))return new f(e,t,r);a.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(f,a.Duplex),f.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new f(e,t,r)},f.prototype.cork=function(){1==++this._corked&&this.emit("cork")},f.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},f.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=o(e,{writable:!0,readable:!1},d(this,this._forwardEnd)),n=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&i.nextTick(n),this._writable=e,this._writable.on("drain",n),this._unwrite=function(){t._writable.removeListener("drain",n),r()},this.uncork()}else this.end()},f.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t,r=this,n=o(e,{writable:!1,readable:!0},d(this)),i=function(){r._forward()},s=function(){r.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(t=e,new a.Readable({objectMode:!0,highWaterMark:16}).wrap(t)),this._readable2.on("readable",i),this._readable2.on("end",s),this._unread=function(){r._readable2.removeListener("readable",i),r._readable2.removeListener("end",s),n()},this._forward()}},f.prototype._read=function(){this._drained=!0,this._forward()},f.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=u(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},f.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;i.nextTick((function(){t._destroy(e)}))}},f.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},f.prototype._write=function(e,t,r){return this.destroyed?r():this._corked?c(this,this._write.bind(this,e,t,r)):e===l?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:r()):r()},f.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,(function(){var r,n;r=t._forwardEnd&&t._writable,n=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),c(t,e)},r?r._writableState&&r._writableState.finished?n():r._writableState?r.end(n):(r.end(),n()):n()}))},f.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(l),a.Writable.prototype.end.call(this,r))},e.exports=f},"./node_modules/end-of-stream/index.js":(e,t,r)=>{var n=r("./node_modules/process/browser.js"),i=r("./node_modules/once/once.js"),a=function(){},o=function(e,t,r){if("function"==typeof t)return o(e,null,t);t||(t={}),r=i(r||a);var s=e._writableState,u=e._readableState,l=t.readable||!1!==t.readable&&e.readable,c=t.writable||!1!==t.writable&&e.writable,d=!1,f=function(){e.writable||h()},h=function(){c=!1,l||r.call(e)},p=function(){l=!1,c||r.call(e)},m=function(t){r.call(e,t?new Error("exited with error code: "+t):null)},g=function(t){r.call(e,t)},v=function(){n.nextTick(y)},y=function(){if(!d)return(!l||u&&u.ended&&!u.destroyed)&&(!c||s&&s.ended&&!s.destroyed)?void 0:r.call(e,new Error("premature close"))},b=function(){e.req.on("finish",h)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?c&&!s&&(e.on("end",f),e.on("close",f)):(e.on("complete",h),e.on("abort",v),e.req?b():e.on("request",b)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",p),e.on("finish",h),!1!==t.error&&e.on("error",g),e.on("close",v),function(){d=!0,e.removeListener("complete",h),e.removeListener("abort",v),e.removeListener("request",b),e.req&&e.req.removeListener("finish",h),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",h),e.removeListener("exit",m),e.removeListener("end",p),e.removeListener("error",g),e.removeListener("close",v)}};e.exports=o},"./node_modules/error-stack-parser/error-stack-parser.js":function(e,t,r){var n,i,a;!function(o,s){"use strict";i=[r("./node_modules/stackframe/stackframe.js")],void 0===(a="function"==typeof(n=function(e){var t=/(^|@)\S+:\d+/,r=/^\s*at .*(\S+:\d+|\(native\))/m,n=/^(eval@)?(\[native code])?$/;return{parse:function(e){if(void 0!==e.stacktrace||void 0!==e["opera#sourceloc"])return this.parseOpera(e);if(e.stack&&e.stack.match(r))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];var t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(t){return t.stack.split("\n").filter((function(e){return!!e.match(r)}),this).map((function(t){t.indexOf("(eval ")>-1&&(t=t.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var r=t.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),n=r.match(/ (\(.+\)$)/);r=n?r.replace(n[0],""):r;var i=this.extractLocation(n?n[1]:r),a=n&&r||void 0,o=["eval",""].indexOf(i[0])>-1?void 0:i[0];return new e({functionName:a,fileName:o,lineNumber:i[1],columnNumber:i[2],source:t})}),this)},parseFFOrSafari:function(t){return t.stack.split("\n").filter((function(e){return!e.match(n)}),this).map((function(t){if(t.indexOf(" > eval")>-1&&(t=t.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===t.indexOf("@")&&-1===t.indexOf(":"))return new e({functionName:t});var r=/((.*".+"[^@]*)?[^@]*)(?:@)/,n=t.match(r),i=n&&n[1]?n[1]:void 0,a=this.extractLocation(t.replace(r,""));return new e({functionName:i,fileName:a[0],lineNumber:a[1],columnNumber:a[2],source:t})}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(t){for(var r=/Line (\d+).*script (?:in )?(\S+)/i,n=t.message.split("\n"),i=[],a=2,o=n.length;a/,"$2").replace(/\([^)]*\)/g,"")||void 0;a.match(/\(([^)]*)\)/)&&(r=a.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var s=void 0===r||"[arguments not available]"===r?void 0:r.split(",");return new e({functionName:o,args:s,fileName:i[0],lineNumber:i[1],columnNumber:i[2],source:t})}),this)}}})?n.apply(t,i):n)||(e.exports=a)}()},"./node_modules/fast-deep-equal/es6/index.js":e=>{"use strict";e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,i,a;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(i=n;0!=i--;)if(!e(t[i],r[i]))return!1;return!0}if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(i of t.entries())if(!r.has(i[0]))return!1;for(i of t.entries())if(!e(i[1],r.get(i[0])))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(i of t.entries())if(!r.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(r)){if((n=t.length)!=r.length)return!1;for(i=n;0!=i--;)if(t[i]!==r[i])return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(a=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(r,a[i]))return!1;for(i=n;0!=i--;){var o=a[i];if(!e(t[o],r[o]))return!1}return!0}return t!=t&&r!=r}},"./node_modules/fbemitter/index.js":(e,t,r)=>{var n={EventEmitter:r("./node_modules/fbemitter/lib/BaseEventEmitter.js"),EmitterSubscription:r("./node_modules/fbemitter/lib/EmitterSubscription.js")};e.exports=n},"./node_modules/fbemitter/lib/BaseEventEmitter.js":(e,t,r)=>{"use strict";var n=r("./node_modules/fbemitter/lib/EmitterSubscription.js"),i=r("./node_modules/fbemitter/lib/EventSubscriptionVendor.js"),a=r("./node_modules/fbjs/lib/invariant.js"),o=r("./node_modules/fbjs/lib/emptyFunction.js"),s=function(){function e(){this._subscriber=new i,this._currentSubscription=null}var t=e.prototype;return t.addListener=function(e,t,r){return this._subscriber.addSubscription(e,new n(this._subscriber,t,r))},t.once=function(e,t,r){var n=this;return this.addListener(e,(function(){n.removeCurrentListener(),t.apply(r,arguments)}))},t.removeAllListeners=function(e){this._subscriber.removeAllSubscriptions(e)},t.removeCurrentListener=function(){this._currentSubscription||a(!1),this._subscriber.removeSubscription(this._currentSubscription)},t.listeners=function(e){var t=this._subscriber.getSubscriptionsForType(e);return t?t.filter(o.thatReturnsTrue).map((function(e){return e.listener})):[]},t.emit=function(e){var t=this._subscriber.getSubscriptionsForType(e);if(t){for(var r=Object.keys(t),n=0;n{"use strict";var n=function(e){var t,r;function n(t,r,n){var i;return(i=e.call(this,t)||this).listener=r,i.context=n,i}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,n}(r("./node_modules/fbemitter/lib/EventSubscription.js"));e.exports=n},"./node_modules/fbemitter/lib/EventSubscription.js":e=>{"use strict";var t=function(){function e(e){this.subscriber=e}return e.prototype.remove=function(){this.subscriber&&(this.subscriber.removeSubscription(this),this.subscriber=null)},e}();e.exports=t},"./node_modules/fbemitter/lib/EventSubscriptionVendor.js":(e,t,r)=>{"use strict";var n=r("./node_modules/fbjs/lib/invariant.js"),i=function(){function e(){this._subscriptionsForType={},this._currentSubscription=null}var t=e.prototype;return t.addSubscription=function(e,t){t.subscriber!==this&&n(!1),this._subscriptionsForType[e]||(this._subscriptionsForType[e]=[]);var r=this._subscriptionsForType[e].length;return this._subscriptionsForType[e].push(t),t.eventType=e,t.key=r,t},t.removeAllSubscriptions=function(e){void 0===e?this._subscriptionsForType={}:delete this._subscriptionsForType[e]},t.removeSubscription=function(e){var t=e.eventType,r=e.key,n=this._subscriptionsForType[t];n&&delete n[r]},t.getSubscriptionsForType=function(e){return this._subscriptionsForType[e]},e}();e.exports=i},"./node_modules/fbjs/lib/emptyFunction.js":e=>{"use strict";function t(e){return function(){return e}}var r=function(){};r.thatReturns=t,r.thatReturnsFalse=t(!1),r.thatReturnsTrue=t(!0),r.thatReturnsNull=t(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},"./node_modules/fbjs/lib/invariant.js":e=>{"use strict";var t=function(e){};e.exports=function(e,r){for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a{"use strict";function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=r("./node_modules/fbjs/lib/invariant.js"),a=function(){function e(){n(this,"_callbacks",void 0),n(this,"_isDispatching",void 0),n(this,"_isHandled",void 0),n(this,"_isPending",void 0),n(this,"_lastID",void 0),n(this,"_pendingPayload",void 0),this._callbacks={},this._isDispatching=!1,this._isHandled={},this._isPending={},this._lastID=1}var t=e.prototype;return t.register=function(e){var t="ID_"+this._lastID++;return this._callbacks[t]=e,t},t.unregister=function(e){this._callbacks[e]||i(!1),delete this._callbacks[e]},t.waitFor=function(e){this._isDispatching||i(!1);for(var t=0;t{"use strict";function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=r("./node_modules/fbemitter/index.js").EventEmitter,a=r("./node_modules/fbjs/lib/invariant.js"),o=function(){function e(e){var t=this;n(this,"_dispatchToken",void 0),n(this,"__changed",void 0),n(this,"__changeEvent",void 0),n(this,"__className",void 0),n(this,"__dispatcher",void 0),n(this,"__emitter",void 0),this.__className=this.constructor.name,this.__changed=!1,this.__changeEvent="change",this.__dispatcher=e,this.__emitter=new i,this._dispatchToken=e.register((function(e){t.__invokeOnDispatch(e)}))}var t=e.prototype;return t.addListener=function(e){return this.__emitter.addListener(this.__changeEvent,e)},t.getDispatcher=function(){return this.__dispatcher},t.getDispatchToken=function(){return this._dispatchToken},t.hasChanged=function(){return this.__dispatcher.isDispatching()||a(!1),this.__changed},t.__emitChange=function(){this.__dispatcher.isDispatching()||a(!1),this.__changed=!0},t.__invokeOnDispatch=function(e){this.__changed=!1,this.__onDispatch(e),this.__changed&&this.__emitter.emit(this.__changeEvent)},t.__onDispatch=function(e){a(!1)},e}();e.exports=o},"./node_modules/fp-ts/es6/Either.js":(e,t,r)=>{"use strict";function n(e){return function(t,r){return e.chain(t,(function(t){return e.map(r(t),(function(){return t}))}))}}r.d(t,{OC:()=>S,kb:()=>d,pG:()=>f});var i=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i=e}:e;return function(){var e=Array.from(arguments);return r(arguments)?t.apply(this,e):function(r){return t.apply(void 0,i([r],e,!1))}}};function s(e){return function(t,r){return e.map(t,(function(){return r}))}}var u,l=function(e){return{_tag:"Left",left:e}},c=function(e){return{_tag:"Right",right:e}},d=(Object.prototype.hasOwnProperty,l),f=c,h=o(2,(function(e,t){return S(e)?e:t(e.right)})),p=function(e,t){return a(e,v(t))},m=function(e,t){return a(e,b(t))},g="Either",v=function(e){return function(t){return S(t)?t:f(e(t.right))}},y={URI:g,map:p},b=(o(2,s(y)),u=s(y),function(e){return function(t){return S(t)?t:S(e)?e:f(t.right(e.right))}}),E={URI:g,map:p,ap:m,chain:h},S=function(e){return"Left"===e._tag};n(E)},"./node_modules/fp-ts/lib/Applicative.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getApplicativeComposition=t.getApplicativeMonoid=void 0;var n=r("./node_modules/fp-ts/lib/Apply.js"),i=r("./node_modules/fp-ts/lib/function.js"),a=r("./node_modules/fp-ts/lib/Functor.js");t.getApplicativeMonoid=function(e){var t=(0,n.getApplySemigroup)(e);return function(r){return{concat:t(r).concat,empty:e.of(r.empty)}}},t.getApplicativeComposition=function(e,t){var r=(0,a.getFunctorComposition)(e,t).map,o=(0,n.ap)(e,t);return{map:r,of:function(r){return e.of(t.of(r))},ap:function(e,t){return(0,i.pipe)(e,o(t))}}}},"./node_modules/fp-ts/lib/Apply.js":function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.sequenceS=t.sequenceT=t.getApplySemigroup=t.apS=t.apSecond=t.apFirst=t.ap=void 0;var o=r("./node_modules/fp-ts/lib/function.js"),s=a(r("./node_modules/fp-ts/lib/internal.js"));function u(e,t,r){return function(n){for(var i=Array(r.length+1),a=0;a=0;a--)i[a]=t(r[a],i[a+1]);return i}};t.size=function(e){return e.length},t.isOutOfBound=f.isOutOfBound,t.lookup=h.lookup,t.head=h.head,t.last=h.last;t.tail=function(e){return(0,t.isNonEmpty)(e)?d.some(f.tail(e)):d.none};t.init=function(e){return(0,t.isNonEmpty)(e)?d.some(f.init(e)):d.none};t.takeLeft=function(e){return function(r){return(0,t.isOutOfBound)(e,r)?(0,t.copy)(r):r.slice(0,e)}};t.takeRight=function(e){return function(r){return(0,t.isOutOfBound)(e,r)?(0,t.copy)(r):0===e?[]:r.slice(-e)}},t.takeLeftWhile=function(e){return function(t){for(var r=[],n=0,i=t;n=r.length?[]:r.slice(e,r.length)}};t.dropRight=function(e){return function(r){return e<=0||(0,t.isEmpty)(r)?(0,t.copy)(r):e>=r.length?[]:r.slice(0,r.length-e)}},t.dropLeftWhile=function(e){return function(t){return t.slice(v(t,e))}},t.findIndex=h.findIndex,t.findFirst=function(e){return h.findFirst(e)},t.findFirstMap=h.findFirstMap,t.findLast=function(e){return h.findLast(e)},t.findLastMap=h.findLastMap,t.findLastIndex=h.findLastIndex;t.copy=function(e){return e.slice()};t.insertAt=function(e,r){return function(n){return e<0||e>n.length?d.none:d.some((0,t.unsafeInsertAt)(e,r,n))}};t.updateAt=function(e,r){return(0,t.modifyAt)(e,(function(){return r}))};t.deleteAt=function(e){return function(r){return(0,t.isOutOfBound)(e,r)?d.none:d.some((0,t.unsafeDeleteAt)(e,r))}};t.modifyAt=function(e,r){return function(n){return(0,t.isOutOfBound)(e,n)?d.none:d.some((0,t.unsafeUpdateAt)(e,r(n[e]),n))}};t.reverse=function(e){return(0,t.isEmpty)(e)?[]:e.slice().reverse()};t.rights=function(e){for(var t=[],r=0;r=1&&(0,t.isNonEmpty)(r)?f.splitAt(e)(r):(0,t.isEmpty)(r)?[(0,t.copy)(r),[]]:[[],(0,t.copy)(r)]}};t.chunksOf=function(e){var r=f.chunksOf(e);return function(e){return(0,t.isNonEmpty)(e)?r(e):[]}};t.fromOptionK=function(e){return function(){for(var r=[],n=0;n{"use strict";function r(e){return function(t,r){return e.chain(t,(function(t){return e.map(r(t),(function(){return t}))}))}}Object.defineProperty(t,"__esModule",{value:!0}),t.bind=t.tap=t.chainFirst=void 0,t.chainFirst=function(e){var t=r(e);return function(e){return function(r){return t(r,e)}}},t.tap=r,t.bind=function(e){return function(t,r){return function(n){return e.chain(n,(function(n){return e.map(r(n),(function(e){var r;return Object.assign({},n,((r={})[t]=e,r))}))}))}}}},"./node_modules/fp-ts/lib/ChainRec.js":(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tailRec=void 0;t.tailRec=function(e,t){for(var r=t(e);"Left"===r._tag;)r=t(r.left);return r.right}},"./node_modules/fp-ts/lib/Either.js":function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.match=t.foldW=t.matchW=t.isRight=t.isLeft=t.fromOption=t.fromPredicate=t.FromEither=t.MonadThrow=t.throwError=t.ChainRec=t.Extend=t.extend=t.Alt=t.alt=t.altW=t.Bifunctor=t.mapLeft=t.bimap=t.Traversable=t.sequence=t.traverse=t.Foldable=t.reduceRight=t.foldMap=t.reduce=t.Monad=t.Chain=t.Applicative=t.Apply=t.ap=t.apW=t.Pointed=t.of=t.asUnit=t.as=t.Functor=t.map=t.getAltValidation=t.getApplicativeValidation=t.getWitherable=t.getFilterable=t.getCompactable=t.getSemigroup=t.getEq=t.getShow=t.URI=t.flatMap=t.right=t.left=void 0,t.chainFirstW=t.chainFirst=t.chain=t.chainW=t.sequenceArray=t.traverseArray=t.traverseArrayWithIndex=t.traverseReadonlyArrayWithIndex=t.traverseReadonlyNonEmptyArrayWithIndex=t.ApT=t.apSW=t.apS=t.bindW=t.bind=t.let=t.bindTo=t.Do=t.exists=t.elem=t.toError=t.toUnion=t.chainNullableK=t.fromNullableK=t.tryCatchK=t.tryCatch=t.fromNullable=t.orElse=t.orElseW=t.swap=t.filterOrElseW=t.filterOrElse=t.flatMapOption=t.flatMapNullable=t.liftOption=t.liftNullable=t.chainOptionKW=t.chainOptionK=t.fromOptionK=t.duplicate=t.flatten=t.flattenW=t.tap=t.apSecondW=t.apSecond=t.apFirstW=t.apFirst=t.flap=t.getOrElse=t.getOrElseW=t.fold=void 0,t.getValidation=t.getValidationMonoid=t.getValidationSemigroup=t.getApplyMonoid=t.getApplySemigroup=t.either=t.stringifyJSON=t.parseJSON=void 0;var o=r("./node_modules/fp-ts/lib/Applicative.js"),s=r("./node_modules/fp-ts/lib/Apply.js"),u=a(r("./node_modules/fp-ts/lib/Chain.js")),l=r("./node_modules/fp-ts/lib/ChainRec.js"),c=r("./node_modules/fp-ts/lib/FromEither.js"),d=r("./node_modules/fp-ts/lib/function.js"),f=r("./node_modules/fp-ts/lib/Functor.js"),h=a(r("./node_modules/fp-ts/lib/internal.js")),p=r("./node_modules/fp-ts/lib/Separated.js"),m=r("./node_modules/fp-ts/lib/Witherable.js");t.left=h.left,t.right=h.right,t.flatMap=(0,d.dual)(2,(function(e,r){return(0,t.isLeft)(e)?e:r(e.right)}));var g=function(e,r){return(0,d.pipe)(e,(0,t.map)(r))},v=function(e,r){return(0,d.pipe)(e,(0,t.ap)(r))},y=function(e,r,n){return(0,d.pipe)(e,(0,t.reduce)(r,n))},b=function(e){return function(r,n){var i=(0,t.foldMap)(e);return(0,d.pipe)(r,i(n))}},E=function(e,r,n){return(0,d.pipe)(e,(0,t.reduceRight)(r,n))},S=function(e){var r=(0,t.traverse)(e);return function(e,t){return(0,d.pipe)(e,r(t))}},T=function(e,r,n){return(0,d.pipe)(e,(0,t.bimap)(r,n))},R=function(e,r){return(0,d.pipe)(e,(0,t.mapLeft)(r))},I=function(e,r){return(0,d.pipe)(e,(0,t.alt)(r))},_=function(e,r){return(0,d.pipe)(e,(0,t.extend)(r))},w=function(e,r){return(0,l.tailRec)(r(e),(function(e){return(0,t.isLeft)(e)?(0,t.right)((0,t.left)(e.left)):(0,t.isLeft)(e.right)?(0,t.left)(r(e.right.left)):(0,t.right)((0,t.right)(e.right.right))}))};t.URI="Either";t.getShow=function(e,r){return{show:function(n){return(0,t.isLeft)(n)?"left(".concat(e.show(n.left),")"):"right(".concat(r.show(n.right),")")}}};t.getEq=function(e,r){return{equals:function(n,i){return n===i||((0,t.isLeft)(n)?(0,t.isLeft)(i)&&e.equals(n.left,i.left):(0,t.isRight)(i)&&r.equals(n.right,i.right))}}};t.getSemigroup=function(e){return{concat:function(r,n){return(0,t.isLeft)(n)?r:(0,t.isLeft)(r)?n:(0,t.right)(e.concat(r.right,n.right))}}};t.getCompactable=function(e){var r=(0,t.left)(e.empty);return{URI:t.URI,_E:void 0,compact:function(e){return(0,t.isLeft)(e)?e:"None"===e.right._tag?r:(0,t.right)(e.right.value)},separate:function(e){return(0,t.isLeft)(e)?(0,p.separated)(e,e):(0,t.isLeft)(e.right)?(0,p.separated)((0,t.right)(e.right.left),r):(0,p.separated)(r,(0,t.right)(e.right.right))}}};t.getFilterable=function(e){var r=(0,t.left)(e.empty),n=(0,t.getCompactable)(e),i=n.compact,a=n.separate;return{URI:t.URI,_E:void 0,map:g,compact:i,separate:a,filter:function(e,n){return(0,t.isLeft)(e)||n(e.right)?e:r},filterMap:function(e,n){if((0,t.isLeft)(e))return e;var i=n(e.right);return"None"===i._tag?r:(0,t.right)(i.value)},partition:function(e,n){return(0,t.isLeft)(e)?(0,p.separated)(e,e):n(e.right)?(0,p.separated)(r,(0,t.right)(e.right)):(0,p.separated)((0,t.right)(e.right),r)},partitionMap:function(e,n){if((0,t.isLeft)(e))return(0,p.separated)(e,e);var i=n(e.right);return(0,t.isLeft)(i)?(0,p.separated)((0,t.right)(i.left),r):(0,p.separated)(r,(0,t.right)(i.right))}}};t.getWitherable=function(e){var r=(0,t.getFilterable)(e),n=(0,t.getCompactable)(e);return{URI:t.URI,_E:void 0,map:g,compact:r.compact,separate:r.separate,filter:r.filter,filterMap:r.filterMap,partition:r.partition,partitionMap:r.partitionMap,traverse:S,sequence:t.sequence,reduce:y,foldMap:b,reduceRight:E,wither:(0,m.witherDefault)(t.Traversable,n),wilt:(0,m.wiltDefault)(t.Traversable,n)}};t.getApplicativeValidation=function(e){return{URI:t.URI,_E:void 0,map:g,ap:function(r,n){return(0,t.isLeft)(r)?(0,t.isLeft)(n)?(0,t.left)(e.concat(r.left,n.left)):r:(0,t.isLeft)(n)?n:(0,t.right)(r.right(n.right))},of:t.of}};t.getAltValidation=function(e){return{URI:t.URI,_E:void 0,map:g,alt:function(r,n){if((0,t.isRight)(r))return r;var i=n();return(0,t.isLeft)(i)?(0,t.left)(e.concat(r.left,i.left)):i}}};t.map=function(e){return function(r){return(0,t.isLeft)(r)?r:(0,t.right)(e(r.right))}},t.Functor={URI:t.URI,map:g},t.as=(0,d.dual)(2,(0,f.as)(t.Functor)),t.asUnit=(0,f.asUnit)(t.Functor),t.of=t.right,t.Pointed={URI:t.URI,of:t.of};t.apW=function(e){return function(r){return(0,t.isLeft)(r)?r:(0,t.isLeft)(e)?e:(0,t.right)(r.right(e.right))}},t.ap=t.apW,t.Apply={URI:t.URI,map:g,ap:v},t.Applicative={URI:t.URI,map:g,ap:v,of:t.of},t.Chain={URI:t.URI,map:g,ap:v,chain:t.flatMap},t.Monad={URI:t.URI,map:g,ap:v,of:t.of,chain:t.flatMap};t.reduce=function(e,r){return function(n){return(0,t.isLeft)(n)?e:r(e,n.right)}};t.foldMap=function(e){return function(r){return function(n){return(0,t.isLeft)(n)?e.empty:r(n.right)}}};t.reduceRight=function(e,r){return function(n){return(0,t.isLeft)(n)?e:r(n.right,e)}},t.Foldable={URI:t.URI,reduce:y,foldMap:b,reduceRight:E};t.traverse=function(e){return function(r){return function(n){return(0,t.isLeft)(n)?e.of((0,t.left)(n.left)):e.map(r(n.right),t.right)}}};t.sequence=function(e){return function(r){return(0,t.isLeft)(r)?e.of((0,t.left)(r.left)):e.map(r.right,t.right)}},t.Traversable={URI:t.URI,map:g,reduce:y,foldMap:b,reduceRight:E,traverse:S,sequence:t.sequence};t.bimap=function(e,r){return function(n){return(0,t.isLeft)(n)?(0,t.left)(e(n.left)):(0,t.right)(r(n.right))}};t.mapLeft=function(e){return function(r){return(0,t.isLeft)(r)?(0,t.left)(e(r.left)):r}},t.Bifunctor={URI:t.URI,bimap:T,mapLeft:R};t.altW=function(e){return function(r){return(0,t.isLeft)(r)?e():r}},t.alt=t.altW,t.Alt={URI:t.URI,map:g,alt:I};t.extend=function(e){return function(r){return(0,t.isLeft)(r)?r:(0,t.right)(e(r))}},t.Extend={URI:t.URI,map:g,extend:_},t.ChainRec={URI:t.URI,map:g,ap:v,chain:t.flatMap,chainRec:w},t.throwError=t.left,t.MonadThrow={URI:t.URI,map:g,ap:v,of:t.of,chain:t.flatMap,throwError:t.throwError},t.FromEither={URI:t.URI,fromEither:d.identity},t.fromPredicate=(0,c.fromPredicate)(t.FromEither),t.fromOption=(0,c.fromOption)(t.FromEither),t.isLeft=h.isLeft,t.isRight=h.isRight;t.matchW=function(e,r){return function(n){return(0,t.isLeft)(n)?e(n.left):r(n.right)}},t.foldW=t.matchW,t.match=t.matchW,t.fold=t.match;t.getOrElseW=function(e){return function(r){return(0,t.isLeft)(r)?e(r.left):r.right}},t.getOrElse=t.getOrElseW,t.flap=(0,f.flap)(t.Functor),t.apFirst=(0,s.apFirst)(t.Apply),t.apFirstW=t.apFirst,t.apSecond=(0,s.apSecond)(t.Apply),t.apSecondW=t.apSecond,t.tap=(0,d.dual)(2,u.tap(t.Chain)),t.flattenW=(0,t.flatMap)(d.identity),t.flatten=t.flattenW,t.duplicate=(0,t.extend)(d.identity),t.fromOptionK=(0,c.fromOptionK)(t.FromEither),t.chainOptionK=(0,c.chainOptionK)(t.FromEither,t.Chain),t.chainOptionKW=t.chainOptionK;var k={fromEither:t.FromEither.fromEither};t.liftNullable=h.liftNullable(k),t.liftOption=h.liftOption(k);var A={flatMap:t.flatMap};t.flatMapNullable=h.flatMapNullable(k,A),t.flatMapOption=h.flatMapOption(k,A),t.filterOrElse=(0,c.filterOrElse)(t.FromEither,t.Chain),t.filterOrElseW=t.filterOrElse;t.swap=function(e){return(0,t.isLeft)(e)?(0,t.right)(e.left):(0,t.left)(e.right)};t.orElseW=function(e){return function(r){return(0,t.isLeft)(r)?e(r.left):r}},t.orElse=t.orElseW;t.fromNullable=function(e){return function(r){return null==r?(0,t.left)(e):(0,t.right)(r)}};t.tryCatch=function(e,r){try{return(0,t.right)(e())}catch(e){return(0,t.left)(r(e))}};t.tryCatchK=function(e,r){return function(){for(var n=[],i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eqDate=t.eqNumber=t.eqString=t.eqBoolean=t.eq=t.strictEqual=t.getStructEq=t.getTupleEq=t.Contravariant=t.getMonoid=t.getSemigroup=t.eqStrict=t.URI=t.contramap=t.tuple=t.struct=t.fromEquals=void 0;var n=r("./node_modules/fp-ts/lib/function.js");t.fromEquals=function(e){return{equals:function(t,r){return t===r||e(t,r)}}};t.struct=function(e){return(0,t.fromEquals)((function(t,r){for(var n in e)if(!e[n].equals(t[n],r[n]))return!1;return!0}))};t.tuple=function(){for(var e=[],r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.asUnit=t.as=t.getFunctorComposition=t.let=t.bindTo=t.flap=t.map=void 0;var n=r("./node_modules/fp-ts/lib/function.js");function i(e,t){return function(r){return function(n){return e.map(n,(function(e){return t.map(e,r)}))}}}function a(e){return function(t,r){return e.map(t,(function(){return r}))}}t.map=i,t.flap=function(e){return function(t){return function(r){return e.map(r,(function(e){return e(t)}))}}},t.bindTo=function(e){return function(t){return function(r){return e.map(r,(function(e){var r;return(r={})[t]=e,r}))}}},t.let=function(e){return function(t,r){return function(n){return e.map(n,(function(e){var n;return Object.assign({},e,((n={})[t]=r(e),n))}))}}},t.getFunctorComposition=function(e,t){var r=i(e,t);return{map:function(e,t){return(0,n.pipe)(e,r(t))}}},t.as=a,t.asUnit=function(e){var t=a(e);return function(e){return t(e,void 0)}}},"./node_modules/fp-ts/lib/Magma.js":(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.concatAll=t.endo=t.filterSecond=t.filterFirst=t.reverse=void 0;t.reverse=function(e){return{concat:function(t,r){return e.concat(r,t)}}};t.filterFirst=function(e){return function(t){return{concat:function(r,n){return e(r)?t.concat(r,n):n}}}};t.filterSecond=function(e){return function(t){return{concat:function(r,n){return e(n)?t.concat(r,n):r}}}};t.endo=function(e){return function(t){return{concat:function(r,n){return t.concat(e(r),e(n))}}}};t.concatAll=function(e){return function(t){return function(r){return r.reduce((function(t,r){return e.concat(t,r)}),t)}}}},"./node_modules/fp-ts/lib/NonEmptyArray.js":function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i0};t.isOutOfBound=function(e,t){return e<0||e>=t.length};t.prependW=function(e){return function(t){return o([e],t,!0)}},t.prepend=t.prependW;t.appendW=function(e){return function(t){return o(o([],t,!0),[e],!1)}},t.append=t.appendW;t.unsafeInsertAt=function(e,r,n){if((0,t.isNonEmpty)(n)){var i=(0,t.fromReadonlyNonEmptyArray)(n);return i.splice(e,0,r),i}return[r]};t.unsafeUpdateAt=function(e,r,n){var i=(0,t.fromReadonlyNonEmptyArray)(n);return i[e]=r,i};t.uniq=function(e){return function(r){if(1===r.length)return(0,t.copy)(r);for(var n=[(0,t.head)(r)],i=function(t){n.every((function(r){return!e.equals(r,t)}))&&n.push(t)},a=0,o=(0,t.tail)(r);an.length?d.none:d.some((0,t.unsafeInsertAt)(e,r,n))}};t.updateAt=function(e,r){return(0,t.modifyAt)(e,(function(){return r}))};t.modifyAt=function(e,r){return function(n){return(0,t.isOutOfBound)(e,n)?d.none:d.some((0,t.unsafeUpdateAt)(e,r(n[e]),n))}},t.copy=t.fromReadonlyNonEmptyArray;t.of=function(e){return[e]};t.zipWith=function(e,t,r){for(var n=[r(e[0],t[0])],i=Math.min(e.length,t.length),a=1;a=r.length?[(0,t.copy)(r),[]]:[(0,l.pipe)(r.slice(1,n),(0,t.prepend)((0,t.head)(r))),r.slice(n)]}};t.chunksOf=function(e){return(0,t.chop)((0,t.splitAt)(e))};var v=function(e,r){return(0,l.pipe)(e,(0,t.map)(r))},y=function(e,r){return(0,l.pipe)(e,(0,t.mapWithIndex)(r))},b=function(e,r){return(0,l.pipe)(e,(0,t.ap)(r))},E=function(e,r){return(0,l.pipe)(e,(0,t.extend)(r))},S=function(e,r,n){return(0,l.pipe)(e,(0,t.reduce)(r,n))},T=function(e){var r=(0,t.foldMap)(e);return function(e,t){return(0,l.pipe)(e,r(t))}},R=function(e,r,n){return(0,l.pipe)(e,(0,t.reduceRight)(r,n))},I=function(e){var r=(0,t.traverse)(e);return function(e,t){return(0,l.pipe)(e,r(t))}},_=function(e,r){return(0,l.pipe)(e,(0,t.alt)(r))},w=function(e,r,n){return(0,l.pipe)(e,(0,t.reduceWithIndex)(r,n))},k=function(e){var r=(0,t.foldMapWithIndex)(e);return function(e,t){return(0,l.pipe)(e,r(t))}},A=function(e,r,n){return(0,l.pipe)(e,(0,t.reduceRightWithIndex)(r,n))},L=function(e){var r=(0,t.traverseWithIndex)(e);return function(e,t){return(0,l.pipe)(e,r(t))}};t.altW=function(e){return function(t){return(0,l.pipe)(t,p(e()))}},t.alt=t.altW;t.ap=function(e){return(0,t.flatMap)((function(r){return(0,l.pipe)(e,(0,t.map)(r))}))},t.flatMap=(0,l.dual)(2,(function(e,r){return(0,l.pipe)(e,(0,t.chainWithIndex)((function(e,t){return r(t,e)})))}));t.extend=function(e){return function(r){for(var n=(0,t.tail)(r),i=[e(r)];(0,t.isNonEmpty)(n);)i.push(e(n)),n=(0,t.tail)(n);return i}},t.duplicate=(0,t.extend)(l.identity),t.flatten=(0,t.flatMap)(l.identity);t.map=function(e){return(0,t.mapWithIndex)((function(t,r){return e(r)}))};t.mapWithIndex=function(e){return function(r){for(var n=[e(0,(0,t.head)(r))],i=1;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ordDate=t.ordNumber=t.ordString=t.ordBoolean=t.ord=t.getDualOrd=t.getTupleOrd=t.between=t.clamp=t.max=t.min=t.geq=t.leq=t.gt=t.lt=t.equals=t.trivial=t.Contravariant=t.getMonoid=t.getSemigroup=t.URI=t.contramap=t.reverse=t.tuple=t.fromCompare=t.equalsDefault=void 0;var n=r("./node_modules/fp-ts/lib/Eq.js"),i=r("./node_modules/fp-ts/lib/function.js");t.equalsDefault=function(e){return function(t,r){return t===r||0===e(t,r)}};t.fromCompare=function(e){return{equals:(0,t.equalsDefault)(e),compare:function(t,r){return t===r?0:e(t,r)}}};t.tuple=function(){for(var e=[],r=0;r-1?t:r}};t.clamp=function(e){var r=(0,t.min)(e),n=(0,t.max)(e);return function(e,t){return function(i){return n(r(i,t),e)}}};t.between=function(e){var r=(0,t.lt)(e),n=(0,t.gt)(e);return function(e,t){return function(i){return!r(i,e)&&!n(i,t)}}},t.getTupleOrd=t.tuple,t.getDualOrd=t.reverse,t.ord=t.Contravariant;var a={equals:n.eqStrict.equals,compare:function(e,t){return et?1:0}};t.ordBoolean=a,t.ordString=a,t.ordNumber=a,t.ordDate=(0,i.pipe)(t.ordNumber,(0,t.contramap)((function(e){return e.valueOf()})))},"./node_modules/fp-ts/lib/Predicate.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.and=t.or=t.not=t.Contravariant=t.getMonoidAll=t.getSemigroupAll=t.getMonoidAny=t.getSemigroupAny=t.URI=t.contramap=void 0;var n=r("./node_modules/fp-ts/lib/function.js");t.contramap=function(e){return function(t){return(0,n.flow)(e,t)}},t.URI="Predicate";t.getSemigroupAny=function(){return{concat:function(e,r){return(0,n.pipe)(e,(0,t.or)(r))}}};t.getMonoidAny=function(){return{concat:(0,t.getSemigroupAny)().concat,empty:n.constFalse}};t.getSemigroupAll=function(){return{concat:function(e,r){return(0,n.pipe)(e,(0,t.and)(r))}}};t.getMonoidAll=function(){return{concat:(0,t.getSemigroupAll)().concat,empty:n.constTrue}},t.Contravariant={URI:t.URI,contramap:function(e,r){return(0,n.pipe)(e,(0,t.contramap)(r))}};t.not=function(e){return function(t){return!e(t)}};t.or=function(e){return function(t){return function(r){return t(r)||e(r)}}};t.and=function(e){return function(t){return function(r){return t(r)&&e(r)}}}},"./node_modules/fp-ts/lib/ReadonlyArray.js":function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i=0;a--)i[a]=t(r[a],i[a+1]);return i}};t.size=function(e){return e.length},t.isOutOfBound=g.isOutOfBound,t.lookup=function e(r,n){return void 0===n?function(t){return e(r,t)}:(0,t.isOutOfBound)(r,n)?h.none:h.some(n[r])};t.head=function(e){return(0,t.isNonEmpty)(e)?h.some(g.head(e)):h.none};t.last=function(e){return(0,t.isNonEmpty)(e)?h.some(g.last(e)):h.none};t.tail=function(e){return(0,t.isNonEmpty)(e)?h.some(g.tail(e)):h.none};t.init=function(e){return(0,t.isNonEmpty)(e)?h.some(g.init(e)):h.none};t.takeLeft=function(e){return function(r){return(0,t.isOutOfBound)(e,r)?r:0===e?t.empty:r.slice(0,e)}};t.takeRight=function(e){return function(r){return(0,t.isOutOfBound)(e,r)?r:0===e?t.empty:r.slice(-e)}},t.takeLeftWhile=function(e){return function(r){for(var n=[],i=0,a=r;i=r.length?t.empty:r.slice(e,r.length)}};t.dropRight=function(e){return function(r){return e<=0||(0,t.isEmpty)(r)?r:e>=r.length?t.empty:r.slice(0,r.length-e)}},t.dropLeftWhile=function(e){return function(r){var n=E(r,e);return 0===n?r:n===r.length?t.empty:r.slice(n)}};t.findIndex=function(e){return function(t){for(var r=0;r=0;r--)if(e(t[r]))return h.some(t[r]);return h.none}};t.findLastMap=function(e){return function(t){for(var r=t.length-1;r>=0;r--){var n=e(t[r]);if(h.isSome(n))return n}return h.none}};t.findLastIndex=function(e){return function(t){for(var r=t.length-1;r>=0;r--)if(e(t[r]))return h.some(r);return h.none}};t.insertAt=function(e,t){return function(r){return e<0||e>r.length?h.none:h.some(g.unsafeInsertAt(e,t,r))}};t.updateAt=function(e,r){return(0,t.modifyAt)(e,(function(){return r}))};t.deleteAt=function(e){return function(r){return(0,t.isOutOfBound)(e,r)?h.none:h.some((0,t.unsafeDeleteAt)(e,r))}};t.modifyAt=function(e,r){return function(n){return(0,t.isOutOfBound)(e,n)?h.none:h.some((0,t.unsafeUpdateAt)(e,r(n[e]),n))}};t.reverse=function(e){return e.length<=1?e:e.slice().reverse()};t.rights=function(e){for(var t=[],r=0;r=1&&(0,t.isNonEmpty)(r)?g.splitAt(e)(r):(0,t.isEmpty)(r)?[r,t.empty]:[t.empty,r]}};t.chunksOf=function(e){var r=g.chunksOf(e);return function(e){return(0,t.isNonEmpty)(e)?r(e):t.empty}};t.fromOptionK=function(e){return function(){for(var r=[],n=0;n0;){var i=r.shift();h.isLeft(i)?r.unshift.apply(r,e(i.left)):n.push(i.right)}return n}},t.ChainRecDepthFirst={URI:t.URI,map:_,ap:k,chain:t.flatMap,chainRec:t._chainRecDepthFirst};t.chainRecBreadthFirst=function(e){return function(t){var r=e(t),n=[],i=[];function a(t){h.isLeft(t)?e(t.left).forEach((function(e){return n.push(e)})):i.push(t.right)}for(var o=0,s=r;o0;)a(n.shift());return i}},t.ChainRecBreadthFirst={URI:t.URI,map:_,ap:k,chain:t.flatMap,chainRec:t._chainRecBreadthFirst};var V=(0,y.witherDefault)(t.Traversable,t.Compactable),z=(0,y.wiltDefault)(t.Traversable,t.Compactable);t.Witherable={URI:t.URI,map:_,compact:t.compact,separate:t.separate,filter:A,filterMap:L,partition:x,partitionMap:C,reduce:P,foldMap:F,reduceRight:N,traverse:K,sequence:t.sequence,wither:V,wilt:z},t.filterE=(0,y.filterE)(t.Witherable),t.FromEither={URI:t.URI,fromEither:t.fromEither},t.fromEitherK=(0,c.fromEitherK)(t.FromEither),t.unsafeInsertAt=g.unsafeInsertAt;t.unsafeUpdateAt=function(e,r,n){return(0,t.isNonEmpty)(n)?g.unsafeUpdateAt(e,r,n):n};t.unsafeDeleteAt=function(e,t){var r=t.slice();return r.splice(e,1),r};t.toArray=function(e){return e.slice()};t.fromArray=function(e){return(0,t.isEmpty)(e)?t.empty:e.slice()},t.empty=g.empty,t.every=function(e){return function(t){return t.every(e)}};t.some=function(e){return function(t){return t.some(e)}},t.exists=t.some;t.intercalate=function(e){var r=g.intercalate(e);return function(n){return(0,t.match)((function(){return e.empty}),r(n))}},t.Do=(0,t.of)(h.emptyRecord),t.bindTo=(0,f.bindTo)(t.Functor);var Y=(0,f.let)(t.Functor);t.let=Y,t.bind=(0,u.bind)(t.Chain),t.apS=(0,s.apS)(t.Apply),t.chain=t.flatMap,t.range=g.range,t.cons=g.cons,t.snoc=g.snoc,t.prependToAll=t.prependAll,t.readonlyArray={URI:t.URI,compact:t.compact,separate:t.separate,map:_,ap:k,of:t.of,chain:t.flatMap,filter:A,filterMap:L,partition:x,partitionMap:C,mapWithIndex:w,partitionMapWithIndex:O,partitionWithIndex:M,filterMapWithIndex:B,filterWithIndex:G,alt:D,zero:t.zero,unfold:t.unfold,reduce:P,foldMap:F,reduceRight:N,traverse:K,sequence:t.sequence,reduceWithIndex:U,foldMapWithIndex:W,reduceRightWithIndex:j,traverseWithIndex:H,extend:q,wither:V,wilt:z}},"./node_modules/fp-ts/lib/ReadonlyNonEmptyArray.js":function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i=t.length};t.prependW=function(e){return function(t){return o([e],t,!0)}},t.prepend=t.prependW;t.appendW=function(e){return function(t){return o(o([],t,!0),[e],!1)}},t.append=t.appendW;t.unsafeInsertAt=function(e,r,n){if((0,t.isNonEmpty)(n)){var i=f.fromReadonlyNonEmptyArray(n);return i.splice(e,0,r),i}return[r]};t.unsafeUpdateAt=function(e,t,r){if(r[e]===t)return r;var n=f.fromReadonlyNonEmptyArray(r);return n[e]=t,n};t.uniq=function(e){return function(r){if(1===r.length)return r;for(var n=[(0,t.head)(r)],i=function(t){n.every((function(r){return!e.equals(r,t)}))&&n.push(t)},a=0,o=(0,t.tail)(r);a=r.length?[r,t.empty]:[(0,c.pipe)(r.slice(1,n),(0,t.prepend)((0,t.head)(r))),r.slice(n)]}};t.chunksOf=function(e){return(0,t.chop)((0,t.splitAt)(e))};var y=function(e,r){return(0,c.pipe)(e,(0,t.map)(r))},b=function(e,r){return(0,c.pipe)(e,(0,t.mapWithIndex)(r))},E=function(e,r){return(0,c.pipe)(e,(0,t.ap)(r))},S=function(e,r){return(0,c.pipe)(e,(0,t.extend)(r))},T=function(e,r,n){return(0,c.pipe)(e,(0,t.reduce)(r,n))},R=function(e){var r=(0,t.foldMap)(e);return function(e,t){return(0,c.pipe)(e,r(t))}},I=function(e,r,n){return(0,c.pipe)(e,(0,t.reduceRight)(r,n))},_=function(e){var r=(0,t.traverse)(e);return function(e,t){return(0,c.pipe)(e,r(t))}},w=function(e,r){return(0,c.pipe)(e,(0,t.alt)(r))},k=function(e,r,n){return(0,c.pipe)(e,(0,t.reduceWithIndex)(r,n))},A=function(e){var r=(0,t.foldMapWithIndex)(e);return function(e,t){return(0,c.pipe)(e,r(t))}},L=function(e,r,n){return(0,c.pipe)(e,(0,t.reduceRightWithIndex)(r,n))},x=function(e){var r=(0,t.traverseWithIndex)(e);return function(e,t){return(0,c.pipe)(e,r(t))}};t.of=f.singleton;t.altW=function(e){return function(t){return(0,c.pipe)(t,m(e()))}},t.alt=t.altW;t.ap=function(e){return(0,t.flatMap)((function(r){return(0,c.pipe)(e,(0,t.map)(r))}))},t.flatMap=(0,c.dual)(2,(function(e,r){return(0,c.pipe)(e,(0,t.chainWithIndex)((function(e,t){return r(t,e)})))}));t.extend=function(e){return function(r){for(var n=(0,t.tail)(r),i=[e(r)];(0,t.isNonEmpty)(n);)i.push(e(n)),n=(0,t.tail)(n);return i}},t.duplicate=(0,t.extend)(c.identity),t.flatten=(0,t.flatMap)(c.identity);t.map=function(e){return(0,t.mapWithIndex)((function(t,r){return e(r)}))};t.mapWithIndex=function(e){return function(r){for(var n=[e(0,(0,t.head)(r))],i=1;in.length?f.none:f.some((0,t.unsafeInsertAt)(e,r,n))}},t.prependToAll=t.prependAll,t.fold=t.concatAll,t.readonlyNonEmptyArray={URI:t.URI,of:t.of,map:y,mapWithIndex:b,ap:E,chain:t.flatMap,extend:S,extract:t.extract,reduce:T,foldMap:R,reduceRight:I,traverse:_,sequence:t.sequence,reduceWithIndex:k,foldMapWithIndex:A,reduceRightWithIndex:L,traverseWithIndex:x,alt:w}},"./node_modules/fp-ts/lib/ReadonlyRecord.js":function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t._partition=t._filterMap=t._filter=t._reduceRight=t._foldMap=t._reduce=t._mapWithIndex=t._map=t.difference=t.intersection=t.union=t.elem=t.some=t.every=t.fromEntries=t.toEntries=t.fromFoldableMap=t.fromFoldable=t.filterWithIndex=t.filterMapWithIndex=t.partitionWithIndex=t.partitionMapWithIndex=t.wilt=t.wither=t.sequence=t.traverse=t.traverseWithIndex=t.singleton=t.reduceRightWithIndex=t.foldMapWithIndex=t.reduceWithIndex=t.map=t.mapWithIndex=t.empty=t.lookup=t.isSubrecord=t.pop=t.modifyAt=t.updateAt=t.deleteAt=t.has=t.upsertAt=t.toUnfoldable=t.toReadonlyArray=t.collect=t.keys=t.isEmpty=t.size=t.toRecord=t.fromRecord=void 0,t.readonlyRecord=t.hasOwnProperty=t.insertAt=t.Witherable=t.TraversableWithIndex=t.Traversable=t.FoldableWithIndex=t.Foldable=t.getDifferenceMagma=t.getIntersectionSemigroup=t.getUnionMonoid=t.getUnionSemigroup=t.getWitherable=t.getTraversableWithIndex=t.getTraversable=t.FilterableWithIndex=t.Filterable=t.Compactable=t.getFoldableWithIndex=t.getFoldable=t.FunctorWithIndex=t.flap=t.Functor=t.getMonoid=t.getEq=t.getShow=t.URI=t.separate=t.compact=t.reduceRight=t.foldMap=t.reduce=t.partitionMap=t.partition=t.filterMap=t.filter=t._sequence=t._traverse=t._filterWithIndex=t._filterMapWithIndex=t._partitionWithIndex=t._partitionMapWithIndex=t._reduceRightWithIndex=t._foldMapWithIndex=t._reduceWithIndex=t._partitionMap=void 0;var o=r("./node_modules/fp-ts/lib/Eq.js"),s=r("./node_modules/fp-ts/lib/function.js"),u=r("./node_modules/fp-ts/lib/Functor.js"),l=a(r("./node_modules/fp-ts/lib/internal.js")),c=r("./node_modules/fp-ts/lib/Separated.js"),d=a(r("./node_modules/fp-ts/lib/string.js")),f=r("./node_modules/fp-ts/lib/Witherable.js");t.fromRecord=function(e){return Object.assign({},e)};t.toRecord=function(e){return Object.assign({},e)};t.size=function(e){return Object.keys(e).length};t.isEmpty=function(e){for(var t in e)if(l.has.call(e,t))return!1;return!0};var h=function(e){return function(t){return Object.keys(t).sort(e.compare)}};function p(e){if("function"==typeof e)return p(d.Ord)(e);var t=h(e);return function(e){return function(r){for(var n=[],i=0,a=t(r);i=0;o--){var s=a[o];i=t(s,n[s],i)}return i}}}t.modifyAt=function(e,r){return function(n){if(!(0,t.has)(e,n))return l.none;var i=r(n[e]);if(i===n[e])return l.some(n);var a=Object.assign({},n);return a[e]=i,l.some(a)}},t.pop=function(e){var t=m(e);return function(r){var n=v(e,r);return l.isNone(n)?l.none:l.some([n.value,t(r)])}},t.isSubrecord=g,t.lookup=v,t.empty={},t.mapWithIndex=y,t.map=b,t.reduceWithIndex=E,t.foldMapWithIndex=S,t.reduceRightWithIndex=T;function R(e){var r=(0,t._traverse)(d.Ord)(e);return function(e){return function(t){return r(t,e)}}}function I(e){return(0,t._sequence)(d.Ord)(e)}t.singleton=function(e,t){var r;return(r={})[e]=t,r},t.traverseWithIndex=function(e){var t=x(d.Ord)(e);return function(e){return function(r){return t(r,e)}}},t.traverse=R,t.sequence=I;t.wither=function(e){var r=R(e);return function(n){return function(i){return e.map((0,s.pipe)(i,r(n)),t.compact)}}};function _(e){return function(t){var r={},n={};for(var i in t)if(l.has.call(t,i)){var a=e(i,t[i]);switch(a._tag){case"Left":r[i]=a.left;break;case"Right":n[i]=a.right}}return(0,c.separated)(r,n)}}function w(e){return function(t){var r={},n={};for(var i in t)if(l.has.call(t,i)){var a=t[i];e(i,a)?n[i]=a:r[i]=a}return(0,c.separated)(r,n)}}function k(e){return function(t){var r={};for(var n in t)if(l.has.call(t,n)){var i=e(n,t[n]);l.isSome(i)&&(r[n]=i.value)}return r}}function A(e){return function(t){var r={},n=!1;for(var i in t)if(l.has.call(t,i)){var a=t[i];e(i,a)?r[i]=a:n=!0}return n?r:t}}function L(e,t){return function(r,n){return t.reduce(r,{},(function(t,r){var i=n(r),a=i[0],o=i[1];return t[a]=l.has.call(t,a)?e.concat(t[a],o):o,t}))}}t.wilt=function(e){var r=R(e);return function(n){return function(i){return e.map((0,s.pipe)(i,r(n)),t.separate)}}},t.partitionMapWithIndex=_,t.partitionWithIndex=w,t.filterMapWithIndex=k,t.filterWithIndex=A,t.fromFoldable=function(e,t){var r=L(e,t);return function(e){return r(e,s.identity)}},t.fromFoldableMap=L,t.toEntries=t.toReadonlyArray;t.fromEntries=function(e){for(var t={},r=0,n=e;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.right=t.left=t.flap=t.Functor=t.Bifunctor=t.URI=t.bimap=t.mapLeft=t.map=t.separated=void 0;var n=r("./node_modules/fp-ts/lib/function.js"),i=r("./node_modules/fp-ts/lib/Functor.js");t.separated=function(e,t){return{left:e,right:t}};t.map=function(e){return function(r){return(0,t.separated)((0,t.left)(r),e((0,t.right)(r)))}};t.mapLeft=function(e){return function(r){return(0,t.separated)(e((0,t.left)(r)),(0,t.right)(r))}};t.bimap=function(e,r){return function(n){return(0,t.separated)(e((0,t.left)(n)),r((0,t.right)(n)))}},t.URI="Separated",t.Bifunctor={URI:t.URI,mapLeft:function(e,r){return(0,n.pipe)(e,(0,t.mapLeft)(r))},bimap:function(e,r,i){return(0,n.pipe)(e,(0,t.bimap)(r,i))}},t.Functor={URI:t.URI,map:function(e,r){return(0,n.pipe)(e,(0,t.map)(r))}},t.flap=(0,i.flap)(t.Functor);t.left=function(e){return e.left};t.right=function(e){return e.right}},"./node_modules/fp-ts/lib/Witherable.js":function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.filterE=t.witherDefault=t.wiltDefault=void 0;var o=a(r("./node_modules/fp-ts/lib/internal.js"));t.wiltDefault=function(e,t){return function(r){var n=e.traverse(r);return function(e,i){return r.map(n(e,i),t.separate)}}},t.witherDefault=function(e,t){return function(r){var n=e.traverse(r);return function(e,i){return r.map(n(e,i),t.compact)}}},t.filterE=function(e){return function(t){var r=e.wither(t);return function(e){return function(n){return r(n,(function(r){return t.map(e(r),(function(e){return e?o.some(r):o.none}))}))}}}}},"./node_modules/fp-ts/lib/Zero.js":(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.guard=void 0,t.guard=function(e,t){return function(r){return r?t.of(void 0):e.zero()}}},"./node_modules/fp-ts/lib/function.js":function(e,t){"use strict";var r=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i1?e(t[1],t[0]):function(r){return e(r)(t[0])}}},t.flow=a,t.tuple=function(){for(var e=[],t=0;t=e}:e;return function(){var e=Array.from(arguments);return n(arguments)?t.apply(this,e):function(n){return t.apply(void 0,r([n],e,!1))}}}},"./node_modules/fp-ts/lib/internal.js":function(e,t,r){"use strict";var n=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,a=t.length;i0};t.head=function(e){return e[0]};t.tail=function(e){return e.slice(1)},t.emptyReadonlyArray=[],t.emptyRecord={},t.has=Object.prototype.hasOwnProperty;t.fromReadonlyNonEmptyArray=function(e){return n([e[0]],e.slice(1),!0)};t.liftNullable=function(e){return function(r,n){return function(){for(var i=[],a=0;a{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Field=t.MonoidProduct=t.MonoidSum=t.SemigroupProduct=t.SemigroupSum=t.MagmaSub=t.Show=t.Bounded=t.Ord=t.Eq=t.isNumber=void 0;t.isNumber=function(e){return"number"==typeof e},t.Eq={equals:function(e,t){return e===t}},t.Ord={equals:t.Eq.equals,compare:function(e,t){return et?1:0}},t.Bounded={equals:t.Eq.equals,compare:t.Ord.compare,top:1/0,bottom:-1/0},t.Show={show:function(e){return JSON.stringify(e)}},t.MagmaSub={concat:function(e,t){return e-t}},t.SemigroupSum={concat:function(e,t){return e+t}},t.SemigroupProduct={concat:function(e,t){return e*t}},t.MonoidSum={concat:t.SemigroupSum.concat,empty:0},t.MonoidProduct={concat:t.SemigroupProduct.concat,empty:1},t.Field={add:t.SemigroupSum.concat,zero:0,mul:t.SemigroupProduct.concat,one:1,sub:t.MagmaSub.concat,degree:function(e){return 1},div:function(e,t){return e/t},mod:function(e,t){return e%t}}},"./node_modules/fp-ts/lib/pipeable.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pipe=t.pipeable=t.compose=t.promap=t.partitionMapWithIndex=t.partitionWithIndex=t.filterMapWithIndex=t.filterWithIndex=t.partitionMap=t.partition=t.filterMap=t.filter=t.alt=t.reduceRightWithIndex=t.foldMapWithIndex=t.reduceWithIndex=t.reduceRight=t.foldMap=t.reduce=t.extend=t.mapLeft=t.bimap=t.chain=t.ap=t.mapWithIndex=t.contramap=t.map=void 0;var n=r("./node_modules/fp-ts/lib/Apply.js"),i=r("./node_modules/fp-ts/lib/Chain.js"),a=r("./node_modules/fp-ts/lib/function.js");function o(e){return function(t){return function(r){return e.map(r,t)}}}function s(e){return function(t){return function(r){return e.contramap(r,t)}}}function u(e){return function(t){return function(r){return e.mapWithIndex(r,t)}}}function l(e){return function(t){return function(r){return e.ap(r,t)}}}function c(e){return function(t){return function(r){return e.chain(r,t)}}}function d(e){return function(t,r){return function(n){return e.bimap(n,t,r)}}}function f(e){return function(t){return function(r){return e.mapLeft(r,t)}}}function h(e){return function(t){return function(r){return e.extend(r,t)}}}function p(e){return function(t,r){return function(n){return e.reduce(n,t,r)}}}function m(e){return function(t){var r=e.foldMap(t);return function(e){return function(t){return r(t,e)}}}}function g(e){return function(t,r){return function(n){return e.reduceRight(n,t,r)}}}function v(e){return function(t,r){return function(n){return e.reduceWithIndex(n,t,r)}}}function y(e){return function(t){var r=e.foldMapWithIndex(t);return function(e){return function(t){return r(t,e)}}}}function b(e){return function(t,r){return function(n){return e.reduceRightWithIndex(n,t,r)}}}function E(e){return function(t){return function(r){return e.alt(r,t)}}}function S(e){return function(t){return function(r){return e.filter(r,t)}}}function T(e){return function(t){return function(r){return e.filterMap(r,t)}}}function R(e){return function(t){return function(r){return e.partition(r,t)}}}function I(e){return function(t){return function(r){return e.partitionMap(r,t)}}}function _(e){return function(t){return function(r){return e.filterWithIndex(r,t)}}}function w(e){return function(t){return function(r){return e.filterMapWithIndex(r,t)}}}function k(e){return function(t){return function(r){return e.partitionWithIndex(r,t)}}}function A(e){return function(t){return function(r){return e.partitionMapWithIndex(r,t)}}}function L(e){return function(t,r){return function(n){return e.promap(n,t,r)}}}function x(e){return function(t){return function(r){return e.compose(r,t)}}}t.map=o,t.contramap=s,t.mapWithIndex=u,t.ap=l,t.chain=c,t.bimap=d,t.mapLeft=f,t.extend=h,t.reduce=p,t.foldMap=m,t.reduceRight=g,t.reduceWithIndex=v,t.foldMapWithIndex=y,t.reduceRightWithIndex=b,t.alt=E,t.filter=S,t.filterMap=T,t.partition=R,t.partitionMap=I,t.filterWithIndex=_,t.filterMapWithIndex=w,t.partitionWithIndex=k,t.partitionMapWithIndex=A,t.promap=L,t.compose=x;t.pipeable=function(e){var t={};if(function(e){return"function"==typeof e.map}(e)&&(t.map=o(e)),function(e){return"function"==typeof e.contramap}(e)&&(t.contramap=s(e)),function(e){return"function"==typeof e.mapWithIndex}(e)&&(t.mapWithIndex=u(e)),function(e){return"function"==typeof e.ap}(e)&&(t.ap=l(e),t.apFirst=(0,n.apFirst)(e),t.apSecond=(0,n.apSecond)(e)),function(e){return"function"==typeof e.chain}(e)&&(t.chain=c(e),t.chainFirst=(0,i.chainFirst)(e),t.flatten=t.chain(a.identity)),function(e){return"function"==typeof e.bimap}(e)&&(t.bimap=d(e),t.mapLeft=f(e)),function(e){return"function"==typeof e.extend}(e)&&(t.extend=h(e),t.duplicate=t.extend(a.identity)),function(e){return"function"==typeof e.reduce}(e)&&(t.reduce=p(e),t.foldMap=m(e),t.reduceRight=g(e)),function(e){return"function"==typeof e.reduceWithIndex}(e)&&(t.reduceWithIndex=v(e),t.foldMapWithIndex=y(e),t.reduceRightWithIndex=b(e)),function(e){return"function"==typeof e.alt}(e)&&(t.alt=E(e)),function(e){return"function"==typeof e.compact}(e)&&(t.compact=e.compact,t.separate=e.separate),function(e){return"function"==typeof e.filter}(e)&&(t.filter=S(e),t.filterMap=T(e),t.partition=R(e),t.partitionMap=I(e)),function(e){return"function"==typeof e.filterWithIndex}(e)&&(t.filterWithIndex=_(e),t.filterMapWithIndex=w(e),t.partitionWithIndex=k(e),t.partitionMapWithIndex=A(e)),function(e){return"function"==typeof e.promap}(e)&&(t.promap=L(e)),function(e){return"function"==typeof e.compose}(e)&&(t.compose=x(e)),function(e){return"function"==typeof e.throwError}(e)){t.fromOption=function(t){return function(r){return"None"===r._tag?e.throwError(t()):e.of(r.value)}},t.fromEither=function(t){return"Left"===t._tag?e.throwError(t.left):e.of(t.right)},t.fromPredicate=function(t,r){return function(n){return t(n)?e.of(n):e.throwError(r(n))}},t.filterOrElse=function(t,r){return function(n){return e.chain(n,(function(n){return t(n)?e.of(n):e.throwError(r(n))}))}}}return t},t.pipe=a.pipe},"./node_modules/fp-ts/lib/string.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.endsWith=t.startsWith=t.includes=t.split=t.size=t.isEmpty=t.slice=t.trimRight=t.trimLeft=t.trim=t.replace=t.toLowerCase=t.toUpperCase=t.isString=t.Show=t.Ord=t.Monoid=t.empty=t.Semigroup=t.Eq=void 0;var n=r("./node_modules/fp-ts/lib/ReadonlyNonEmptyArray.js");t.Eq={equals:function(e,t){return e===t}},t.Semigroup={concat:function(e,t){return e+t}},t.empty="",t.Monoid={concat:t.Semigroup.concat,empty:t.empty},t.Ord={equals:t.Eq.equals,compare:function(e,t){return et?1:0}},t.Show={show:function(e){return JSON.stringify(e)}};t.isString=function(e){return"string"==typeof e};t.toUpperCase=function(e){return e.toUpperCase()};t.toLowerCase=function(e){return e.toLowerCase()};t.replace=function(e,t){return function(r){return r.replace(e,t)}};t.trim=function(e){return e.trim()};t.trimLeft=function(e){return e.trimLeft()};t.trimRight=function(e){return e.trimRight()};t.slice=function(e,t){return function(r){return r.slice(e,t)}};t.isEmpty=function(e){return 0===e.length};t.size=function(e){return e.length};t.split=function(e){return function(t){var r=t.split(e);return(0,n.isNonEmpty)(r)?r:[t]}};t.includes=function(e,t){return function(r){return r.includes(e,t)}};t.startsWith=function(e,t){return function(r){return r.startsWith(e,t)}};t.endsWith=function(e,t){return function(r){return r.endsWith(e,t)}}},"./node_modules/hls.js/dist/hls.js":e=>{!function t(r){e.exports=function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(t){for(var r=1;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function g(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var y={exports:{}};!function(e,t){var r,n,i,a,o;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var i=o.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=o.normalizePath(i.path),o.buildURLFromParts(i)}var a=o.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=o.normalizePath(a.path),o.buildURLFromParts(a)):t;var s=o.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var u=n.exec(s.path);s.netLoc=u[1],s.path=u[2]}s.netLoc&&!s.path&&(s.path="/");var l={scheme:s.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(l.netLoc=s.netLoc,"/"!==a.path[0]))if(a.path){var c=s.path,d=c.substring(0,c.lastIndexOf("/")+1)+a.path;l.path=o.normalizePath(d)}else l.path=s.path,a.params||(l.params=s.params,a.query||(l.query=s.query));return null===l.path&&(l.path=r.alwaysNormalize?o.normalizePath(a.path):a.path),o.buildURLFromParts(l)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=o}(y);var b=y.exports,E=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},S=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=T},T=Number.MAX_SAFE_INTEGER||9007199254740991,R=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e}({}),I=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),_=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({}),w=function(){},k={trace:w,debug:w,log:w,warn:w,info:w,error:w},A=k;function L(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):w}function x(e,t){if(self.console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;nNumber.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),n=0;nNumber.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=M.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(O.lastIndex=0;null!==(t=O.exec(e));){var n=t[2];0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),r[t[1].trim()]=n}return r},e}();function P(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}var F=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var n in r)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==r[n]){C.warn('DATERANGE tag attribute: "'+n+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=n;break}e=s(new D({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var i=new Date(this.attr["END-DATE"]);E(i.getTime())&&(this._endDate=i)}}return a(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(E(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&E(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),e}(),N=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},U="audio",W="video",j="audiovideo",B=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[U]=null,t[W]=null,t[j]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r=e.split("@",2),n=[];1===r.length?n[0]=t?t.byteRangeEndOffset:0:n[0]=parseInt(r[1]),n[1]=parseInt(r[0])+n[0],this._byteRange=n},a(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=b.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),G=function(e){function t(t,r){var n;return(n=e.call(this,r)||this)._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkeys=void 0,n.type=void 0,n.loader=null,n.keyLoader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new N,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.endList=void 0,n.gap=void 0,n.type=t,n}u(t,e);var r=t.prototype;return r.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},r.abortRequests=function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()},r.setElementaryStreamInfo=function(e,t,r,n,i,a){void 0===a&&(a=!1);var o=this.elementaryStreams,s=o[e];s?(s.startPTS=Math.min(s.startPTS,t),s.endPTS=Math.max(s.endPTS,r),s.startDTS=Math.min(s.startDTS,n),s.endDTS=Math.max(s.endDTS,i)):o[e]={startPTS:t,endPTS:r,startDTS:n,endDTS:i,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[U]=null,e[W]=null,e[j]=null},a(t,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!E(this.programDateTime))return null;var e=E(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}}]),t}(B),q=function(e){function t(t,r,n,i,a){var o;(o=e.call(this,n)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new N,o.duration=t.decimalFloatingPoint("DURATION"),o.gap=t.bool("GAP"),o.independent=t.bool("INDEPENDENT"),o.relurl=t.enumeratedString("URI"),o.fragment=r,o.index=i;var s=t.enumeratedString("BYTERANGE");return s&&o.setByteRange(s,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return u(t,e),a(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(B),K=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},a(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&E(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),e}();function H(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function V(e){var t,r,n=e.split(":"),i=null;if("data"===n[0]&&2===n.length){var a=n[1].split(";"),o=a[a.length-1].split(",");if(2===o.length){var s="base64"===o[0],u=o[1];s?(a.splice(-1,1),i=H(u)):(t=z(u).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),i=r)}}return i}function z(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}var Y={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},X="org.w3.clearkey",$="com.apple.streamingkeydelivery",J="com.microsoft.playready",Q="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Z(e){switch(e){case $:return Y.FAIRPLAY;case J:return Y.PLAYREADY;case Q:return Y.WIDEVINE;case X:return Y.CLEARKEY}}var ee="edef8ba979d64acea3c827dcd51d21ed";function te(e){switch(e){case Y.FAIRPLAY:return $;case Y.PLAYREADY:return J;case Y.WIDEVINE:return Q;case Y.CLEARKEY:return X}}function re(e){var t=e.drmSystems,r=e.widevineLicenseUrl,n=t?[Y.FAIRPLAY,Y.WIDEVINE,Y.PLAYREADY,Y.CLEARKEY].filter((function(e){return!!t[e]})):[];return!n[Y.WIDEVINE]&&r&&n.push(Y.WIDEVINE),n}var ne="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function ie(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}var ae,oe=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},se=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},ue=function(e,t){for(var r=t,n=0;oe(e,t);)n+=10,n+=le(e,t+6),se(e,t+10)&&(n+=10),t+=n;if(n>0)return e.subarray(r,r+n)},le=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},ce=function(e,t){return oe(e,t)&&le(e,t+6)+10<=e.length-t},de=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},fe=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=le(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},he=function(e){for(var t=0,r=[];oe(e,t);){for(var n=le(e,t+6),i=(t+=10)+n;t+8>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(a);break;case 12:case 13:o=e[c++],l+=String.fromCharCode((31&a)<<6|63&o);break;case 14:o=e[c++],s=e[c++],l+=String.fromCharCode((15&a)<<12|(63&o)<<6|(63&s)<<0)}}return l};function Ee(){if(!navigator.userAgent.includes("PlayStation 4"))return ae||void 0===self.TextDecoder||(ae=new self.TextDecoder("utf-8")),ae}var Se=function(e){for(var t="",r=0;r>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function xe(e,t){var r=[];if(!t.length)return r;for(var n=e.byteLength,i=0;i1?i+a:n;if(_e(e.subarray(i+4,i+8))===t[0])if(1===t.length)r.push(e.subarray(i+8,o));else{var s=xe(e.subarray(i+8,o),t.slice(1));s.length&&Re.apply(r,s)}i=o}return r}function Ce(e){var t=[],r=e[0],n=8,i=ke(e,n);n+=4,n+=0===r?8:16,n+=2;var a=e.length+0,o=we(e,n);n+=2;for(var s=0;s>>31)return C.warn("SIDX has hierarchical references (not supported)"),null;var d=ke(e,u);u+=4,t.push({referenceSize:c,subsegmentDuration:d,info:{duration:d/i,start:a,end:a+c-1}}),a+=c,n=u+=4}return{earliestPresentationTime:0,timescale:i,version:r,referencesCount:o,references:t}}function Me(e){for(var t=[],r=xe(e,["moov","trak"]),n=0;n>1&63;return 39===r||40===r}return 6==(31&t)}function Ue(e,t,r,n){var i=We(e),a=0;a+=t;for(var o=0,s=0,u=!1,l=0;a=i.length)break;o+=l=i[a++]}while(255===l);s=0;do{if(a>=i.length)break;s+=l=i[a++]}while(255===l);var c=i.length-a;if(!u&&4===o&&a16){for(var b=[],E=0;E<16;E++){var S=i[a++].toString(16);b.push(1==S.length?"0"+S:S),3!==E&&5!==E&&7!==E&&9!==E||b.push("-")}for(var T=s-16,R=new Uint8Array(T),I=0;Ic)break}}function We(e){for(var t=e.byteLength,r=[],n=1;n0?(a=new Uint8Array(4),t.length>0&&new DataView(a.buffer).setUint32(0,t.length,!1)):a=new Uint8Array;var u=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(u.buffer).setUint32(0,r.byteLength,!1),function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n>24&255,s[1]=a>>16&255,s[2]=a>>8&255,s[3]=255&a,s.set(e,4),o=0,a=8;o>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var n=V(this.uri);if(n)switch(this.keyFormat){case Q:this.pssh=n,n.length>=22&&(this.keyId=n.subarray(n.length-22,n.length-6));break;case J:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=je(i,null,n);var a=new Uint16Array(n.buffer,n.byteOffset,n.byteLength/2),o=String.fromCharCode.apply(null,Array.from(a)),s=o.substring(o.indexOf("<"),o.length),u=(new DOMParser).parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(u){var l=u.childNodes[0]?u.childNodes[0].nodeValue:u.getAttribute("VALUE");if(l){var c=H(l).subarray(0,16);!function(e){var t=function(e,t,r){var n=e[t];e[t]=e[r],e[r]=n};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(c),this.keyId=c}}break;default:var d=n.subarray(0,16);if(16!==d.length){var f=new Uint8Array(16);f.set(d,16-d.length),d=f}this.keyId=d}if(!this.keyId||16!==this.keyId.byteLength){var h=Be[this.uri];if(!h){var p=Object.keys(Be).length%Number.MAX_SAFE_INTEGER;h=new Uint8Array(16),new DataView(h.buffer,12,4).setUint32(0,p),Be[this.uri]=h}this.keyId=h}return this},e}(),qe=/\{\$([a-zA-Z0-9-_]+)\}/g;function Ke(e){return qe.test(e)}function He(e,t,r){if(null!==e.variableList||e.hasVariableRefs)for(var n=r.length;n--;){var i=r[n],a=t[i];a&&(t[i]=Ve(e,a))}}function Ve(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(qe,(function(t){var n=t.substring(2,t.length-1),i=null==r?void 0:r[n];return void 0===i?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+n+'"')),t):i}))}return t}function ze(e,t,r){var n,i,a=e.variableList;if(a||(e.variableList=a={}),"QUERYPARAM"in t){n=t.QUERYPARAM;try{var o=new self.URL(r).searchParams;if(!o.has(n))throw new Error('"'+n+'" does not match any query parameter in URI: "'+r+'"');i=o.get(n)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+t.message))}}else n=t.NAME,i=t.VALUE;n in a?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+n+'"')):a[n]=i||""}function Ye(e,t,r){var n=t.IMPORT;if(r&&n in r){var i=e.variableList;i||(e.variableList=i={}),i[n]=r[n]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+n+'"'))}function Xe(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}var $e={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,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,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!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},text:{stpp:!0,wvtt:!0}},Je=Xe();function Qe(e,t){var r;return null!=(r=null==Je?void 0:Je.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"'))&&r}var Ze=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,et=/#EXT-X-MEDIA:(.*)/g,tt=/^#EXT(?:INF|-X-TARGETDURATION):/m,rt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),nt=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),it=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4)}return e},e.resolve=function(e,t){return b.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.isMediaPlaylist=function(e){return tt.test(e)},e.parseMasterPlaylist=function(t,r){var n,i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Ke(t)},a=[];for(Ze.lastIndex=0;null!=(n=Ze.exec(t));)if(n[1]){var o,s=new D(n[1]);He(i,s,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var u=Ve(i,n[2]),l={attrs:s,bitrate:s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),name:s.NAME,url:e.resolve(u,r)},c=s.decimalResolution("RESOLUTION");c&&(l.width=c.width,l.height=c.height),st((s.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),l),l.videoCodec&&-1!==l.videoCodec.indexOf("avc1")&&(l.videoCodec=e.convertAVC1ToAVCOTI(l.videoCodec)),null!=(o=l.unknownCodecs)&&o.length||a.push(l),i.levels.push(l)}else if(n[3]){var d=n[3],f=n[4];switch(d){case"SESSION-DATA":var h=new D(f);He(i,h,["DATA-ID","LANGUAGE","VALUE","URI"]);var p=h["DATA-ID"];p&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[p]=h);break;case"SESSION-KEY":var m=at(f,r,i);m.encrypted&&m.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(m)):C.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+f+'"');break;case"DEFINE":var g=new D(f);He(i,g,["NAME","VALUE","QUERYPARAM"]),ze(i,g,r);break;case"CONTENT-STEERING":var v=new D(f);He(i,v,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:e.resolve(v["SERVER-URI"],r),pathwayId:v["PATHWAY-ID"]||"."};break;case"START":i.startTimeOffset=ot(f)}}var y=a.length>0&&a.length0&&H.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=H.optionalFloat("PART-HOLD-BACK",0),c.holdBack=H.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var V=new D(k);c.partTarget=V.decimalFloatingPoint("PART-TARGET");break;case"PART":var z=c.partList;z||(z=c.partList=[]);var Y=p>0?z[z.length-1]:void 0,X=p++,$=new D(k);He(c,$,["BYTERANGE","URI"]);var J=new q($,y,t,X,Y);z.push(J),y.duration+=J.duration;break;case"PRELOAD-HINT":var Q=new D(k);He(c,Q,["URI"]),c.preloadHint=Q;break;case"RENDITION-REPORT":var Z=new D(k);He(c,Z,["URI"]),c.renditionReports=c.renditionReports||[],c.renditionReports.push(Z);break;default:C.warn("line parsed but not handled: "+o)}}}v&&!v.relurl?(d.pop(),m-=v.duration,c.partList&&(c.fragmentHint=v)):c.partList&&(lt(y,v),y.cc=g,c.fragmentHint=y,l&&dt(y,l,c));var ee=d.length,te=d[0],re=d[ee-1];if((m+=c.skippedSegments*c.targetduration)>0&&ee&&re){c.averagetargetduration=m/ee;var ne=re.sn;c.endSN="initSegment"!==ne?ne:0,c.live||(re.endList=!0),te&&(c.startCC=te.cc)}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(m+=c.fragmentHint.duration),c.totalduration=m,c.endCC=g,b>0&&function(e,t){for(var r=e[t],n=t;n--;){var i=e[n];if(!i)return;i.programDateTime=r.programDateTime-1e3*i.duration,r=i}}(d,b),c},e}();function at(e,t,r){var n,i,a=new D(e);He(r,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var o=null!=(n=a.METHOD)?n:"",s=a.URI,u=a.hexadecimalInteger("IV"),l=a.KEYFORMATVERSIONS,c=null!=(i=a.KEYFORMAT)?i:"identity";s&&a.IV&&!u&&C.error("Invalid IV: "+a.IV);var d=s?it.resolve(s,t):"",f=(l||"1").split("/").map(Number).filter(Number.isFinite);return new Ge(o,d,c,f,u)}function ot(e){var t=new D(e).decimalFloatingPoint("TIME-OFFSET");return E(t)?t:null}function st(e,t){["video","audio","text"].forEach((function(r){var n=e.filter((function(e){return function(e,t){var r=$e[t];return!!r&&!0===r[e.slice(0,4)]}(e,r)}));if(n.length){var i=n.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=i.length>0?i[0]:n[0],e=e.filter((function(e){return-1===n.indexOf(e)}))}})),t.unknownCodecs=e}function ut(e,t,r){var n=t[r];n&&(e[r]=n)}function lt(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),E(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function ct(e,t,r,n){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",n&&(e.levelkeys=n),e.initSegment=null}function dt(e,t,r){e.levelkeys=t;var n=r.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||n.push(e)}var ft="manifest",ht="level",pt="audioTrack",mt="subtitleTrack",gt="main",vt="audio",yt="subtitle";function bt(e){switch(e.type){case pt:return vt;case mt:return yt;default:return gt}}function Et(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var St=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,n=t.loader,i=new(r||n)(t);return this.loaders[e.type]=i,i},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ft,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,n=t.level,i=t.url,a=t.deliveryDirectives;this.load({id:r,level:n,responseType:"text",type:ht,url:i,deliveryDirectives:a})},t.onAudioTrackLoading=function(e,t){var r=t.id,n=t.groupId,i=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:n,level:null,responseType:"text",type:pt,url:i,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,n=t.groupId,i=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:n,level:null,responseType:"text",type:mt,url:i,deliveryDirectives:a})},t.load=function(e){var t,r,n,i=this,a=this.hls.config,o=this.getInternalLoader(e);if(o){var u=o.context;if(u&&u.url===e.url)return void C.trace("[playlist-loader]: playlist request ongoing");C.log("[playlist-loader]: aborting previous loader for type: "+e.type),o.abort()}if(r=e.type===ft?a.manifestLoadPolicy.default:s({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),o=this.createInternalLoader(e),null!=(t=e.deliveryDirectives)&&t.part&&(e.type===ht&&null!==e.level?n=this.hls.levels[e.level].details:e.type===pt&&null!==e.id?n=this.hls.audioTracks[e.id].details:e.type===mt&&null!==e.id&&(n=this.hls.subtitleTracks[e.id].details),n)){var l=n.partTarget,c=n.targetduration;if(l&&c){var d=1e3*Math.max(3*l,.8*c);r=s({},r,{maxTimeToFirstByteMs:Math.min(d,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,r.maxTimeToFirstByteMs)})}}var f=r.errorRetry||r.timeoutRetry||{},h={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},p={onSuccess:function(e,t,r,n){var a=i.getInternalLoader(r);i.resetInternalLoader(r.type);var o=e.data;0===o.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),it.isMediaPlaylist(o)?i.handleTrackOrLevelPlaylist(e,t,r,n||null,a):i.handleMasterPlaylist(e,t,r,n)):i.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),n||null,t)},onError:function(e,t,r,n){i.handleNetworkError(t,r,!1,e,n)},onTimeout:function(e,t,r){i.handleNetworkError(t,r,!0,void 0,e)}};o.load(e,h,p)},t.handleMasterPlaylist=function(e,t,r,n){var i=this.hls,a=e.data,o=Et(e,r),s=it.parseMasterPlaylist(a,o);if(s.playlistParsingError)this.handleManifestParsingError(e,r,s.playlistParsingError,n,t);else{var u=s.contentSteering,l=s.levels,c=s.sessionData,d=s.sessionKeys,f=s.startTimeOffset,h=s.variableList;this.variableList=h;var p=it.parseMasterPlaylistMedia(a,o,s),m=p.AUDIO,g=void 0===m?[]:m,v=p.SUBTITLES,y=p["CLOSED-CAPTIONS"];g.length&&(g.some((function(e){return!e.url}))||!l[0].audioCodec||l[0].attrs.AUDIO||(C.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new D({}),bitrate:0,url:""}))),i.trigger(R.MANIFEST_LOADED,{levels:l,audioTracks:g,subtitles:v,captions:y,contentSteering:u,url:o,stats:t,networkDetails:n,sessionData:c,sessionKeys:d,startTimeOffset:f,variableList:h})}},t.handleTrackOrLevelPlaylist=function(e,t,r,n,i){var a=this.hls,o=r.id,s=r.level,u=r.type,l=Et(e,r),c=E(o)?o:0,d=E(s)?s:c,f=bt(r),h=it.parseLevelPlaylist(e.data,l,d,f,c,this.variableList);if(u===ft){var p={attrs:new D({}),bitrate:0,details:h,name:"",url:l};a.trigger(R.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:l,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=h,this.handlePlaylistLoaded(h,e,t,r,n,i)},t.handleManifestParsingError=function(e,t,r,n,i){this.hls.trigger(R.ERROR,{type:I.NETWORK_ERROR,details:_.MANIFEST_PARSING_ERROR,fatal:t.type===ft,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:n,stats:i})},t.handleNetworkError=function(e,t,r,i,a){void 0===r&&(r=!1);var o="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+e.type;e.type===ht?o+=": "+e.level+" id: "+e.id:e.type!==pt&&e.type!==mt||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var s=new Error(o);C.warn("[playlist-loader]: "+o);var u=_.UNKNOWN,l=!1,c=this.getInternalLoader(e);switch(e.type){case ft:u=r?_.MANIFEST_LOAD_TIMEOUT:_.MANIFEST_LOAD_ERROR,l=!0;break;case ht:u=r?_.LEVEL_LOAD_TIMEOUT:_.LEVEL_LOAD_ERROR,l=!1;break;case pt:u=r?_.AUDIO_TRACK_LOAD_TIMEOUT:_.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case mt:u=r?_.SUBTITLE_TRACK_LOAD_TIMEOUT:_.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);var d={type:I.NETWORK_ERROR,details:u,fatal:l,url:e.url,loader:c,context:e,error:s,networkDetails:t,stats:a};if(i){var f=(null==t?void 0:t.url)||e.url;d.response=n({url:f,data:void 0},i)}this.hls.trigger(R.ERROR,d)},t.handlePlaylistLoaded=function(e,t,r,n,i,a){var o=this.hls,s=n.type,u=n.level,l=n.id,c=n.groupId,d=n.deliveryDirectives,f=Et(t,n),h=bt(n),p="number"==typeof n.level&&h===gt?u:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var m=e.playlistParsingError;if(m)o.trigger(R.ERROR,{type:I.NETWORK_ERROR,details:_.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:m,reason:m.message,response:t,context:n,level:p,parent:h,networkDetails:i,stats:r});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),s){case ft:case ht:o.trigger(R.LEVEL_LOADED,{details:e,level:p||0,id:l||0,stats:r,networkDetails:i,deliveryDirectives:d});break;case pt:o.trigger(R.AUDIO_TRACK_LOADED,{details:e,id:l||0,groupId:c||"",stats:r,networkDetails:i,deliveryDirectives:d});break;case mt:o.trigger(R.SUBTITLE_TRACK_LOADED,{details:e,id:l||0,groupId:c||"",stats:r,networkDetails:i,deliveryDirectives:d})}}else{var g=new Error("No Segments found in Playlist");o.trigger(R.ERROR,{type:I.NETWORK_ERROR,details:_.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:n,level:p,parent:h,networkDetails:i,stats:r})}},e}();function Tt(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function Rt(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){C.debug("[texttrack-utils]: "+r);try{var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){C.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===r&&(e.mode=r)}function It(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function _t(e,t,r,n){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,r){var n=[],i=function(e,t){if(te[r].endTime)return-1;for(var n=0,i=r;n<=i;){var a=Math.floor((i+n)/2);if(te[a].startTime&&n-1)for(var a=i,o=e.length;a=t&&s.endTime<=r)n.push(s);else if(s.startTime>r)return n}return n}(e.cues,t,r),o=0;oCt&&(d=Ct),d-c<=0&&(d=c+.25);for(var f=0;ft.startDate&&e.push(n),e}),[]).sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()}))[0];p&&(c=Mt(p.startDate,f),u=!0)}for(var g,v,y=Object.keys(t.attr),b=0;b.05&&this.forwardBufferLength>1){var l=Math.min(2,Math.max(1,a)),c=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;e.playbackRate=Math.min(l,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},a(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,n=e.targetduration,i=this.config,a=i.liveSyncDuration,o=i.liveSyncDurationCount,s=i.lowLatencyMode,u=this.hls.userConfig,l=s&&r||t;(u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==a?a:o*n);var c=n;return l+Math.min(1*this.stallCount,c)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var n=r.edge,i=e-t-this.edgeStalled,a=n-r.totalduration,o=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,i),o)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),e}(),Pt=["NONE","TYPE-0","TYPE-1",null],Ft="",Nt="YES",Ut="v2",Wt=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href},e}(),jt=function(){function e(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return e})).join(",").replace(/\.[^.,]+/g,"")}return e.prototype.addFallback=function(e){this.url.push(e.url),this._attrs.push(e.attrs)},a(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(e){var t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroupIds)?void 0:e[this.urlId]}},{key:"textGroupId",get:function(){var e;return null==(e=this.textGroupIds)?void 0:e[this.urlId]}}]),e}();function Bt(e,t){var r=t.startPTS;if(E(r)){var n,i=0;t.sn>e.sn?(i=r-e.start,n=e):(i=e.start-r,n=t),n.duration!==i&&(n.duration=i)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function Gt(e,t,r,n,i,a){n-r<=0&&(C.warn("Fragment should have a positive duration",t),n=r+t.duration,a=i+t.duration);var o=r,s=n,u=t.startPTS,l=t.endPTS;if(E(u)){var c=Math.abs(u-r);E(t.deltaPTS)?t.deltaPTS=Math.max(c,t.deltaPTS):t.deltaPTS=c,o=Math.max(r,u),r=Math.min(r,u),i=Math.min(i,t.startDTS),s=Math.min(n,l),n=Math.max(n,l),a=Math.max(a,t.endDTS)}var d=r-t.start;0!==t.start&&(t.start=r),t.duration=n-t.start,t.startPTS=r,t.maxStartPTS=o,t.startDTS=i,t.endPTS=n,t.minEndPTS=s,t.endDTS=a;var f,h=t.sn;if(!e||he.endSN)return 0;var p=h-e.startSN,m=e.fragments;for(m[p]=t,f=p;f>0;f--)Bt(m[f],m[f-1]);for(f=p;f=0;i--){var a=n[i].initSegment;if(a){r=a;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var o,u,l,c,d,f=0;if(function(e,t,r){for(var n=t.skippedSegments,i=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(n?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,s=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i;l<=a;l++){var c=u[o+l],d=s[l];n&&!d&&l=n.length||Ht(t,n[r].start)}function Ht(e,t){if(t){for(var r=e.fragments,n=e.skippedSegments;n499)}(n)||!!r)}var Zt=function(e,t){for(var r=0,n=e.length-1,i=null,a=null;r<=n;){var o=t(a=e[i=(r+n)/2|0]);if(o>0)r=i+1;else{if(!(o<0))return a;n=i-1}}return null};function er(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=null;if(e?i=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(i=t[0]),i&&0===tr(r,n,i))return i;var a=Zt(t,tr.bind(null,r,n));return!a||a===e&&i?i:a}function tr(e,t,r){if(void 0===e&&(e=0),void 0===t&&(t=0),r.start<=e&&r.start+r.duration>e)return 0;var n=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-n<=e?1:r.start-n>e&&r.start?-1:0}function rr(e,t,r){var n=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-n>e}var nr,ir=0,ar=2,or=5,sr=0,ur=1,lr=2,cr=function(){function e(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=C.log.bind(C,"[info]:"),this.warn=C.warn.bind(C,"[warning]:"),this.error=C.error.bind(C,"[error]:"),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(R.ERROR,this.onError,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(R.ERROR,this.onError,this),e.off(R.ERROR,this.onErrorOut,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))},t.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},t.startLoad=function(e){this.playlistError=0},t.stopLoad=function(){},t.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===gt?e.level:this.hls.loadLevel},t.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},t.onLevelUpdated=function(){this.playlistError=0},t.onError=function(e,t){var r,n;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case _.FRAG_LOAD_ERROR:case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_ERROR:case _.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case _.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:ir,flags:sr});case _.FRAG_GAP:case _.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=ar);case _.LEVEL_EMPTY_ERROR:case _.LEVEL_PARSING_ERROR:var o,s,u=t.parent===gt?t.level:i.loadLevel;return void(t.details===_.LEVEL_EMPTY_ERROR&&null!=(o=t.context)&&null!=(s=o.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,u)));case _.LEVEL_LOAD_ERROR:case _.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case _.AUDIO_TRACK_LOAD_ERROR:case _.AUDIO_TRACK_LOAD_TIMEOUT:case _.SUBTITLE_LOAD_ERROR:case _.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var l=i.levels[i.loadLevel];if(l&&(a.type===pt&&a.groupId===l.audioGroupId||a.type===mt&&a.groupId===l.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=ar,void(t.errorAction.flags=ur)}return;case _.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var c=i.levels[i.loadLevel],d=null==c?void 0:c.attrs["HDCP-LEVEL"];return void(d&&(t.errorAction={action:ar,flags:lr,hdcpLevel:d}));case _.BUFFER_ADD_CODEC_ERROR:case _.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(n=t.level)?n:i.loadLevel));case _.INTERNAL_EXCEPTION:case _.BUFFER_APPENDING_ERROR:case _.BUFFER_APPEND_ERROR:case _.BUFFER_FULL_ERROR:case _.LEVEL_SWITCH_ERROR:case _.BUFFER_STALLED_ERROR:case _.BUFFER_SEEK_OVER_HOLE:case _.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:ir,flags:sr})}if(t.type===I.KEY_SYSTEM_ERROR){var f=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,f))}}},t.getPlaylistRetryOrSwitchAction=function(e,t){var r,n=Xt(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++,a=null==(r=e.response)?void 0:r.code;if(Qt(n,i,Yt(e),a))return{action:or,flags:sr,retryConfig:n,retryCount:i};var o=this.getLevelSwitchAction(e,t);return n&&(o.retryConfig=n,o.retryCount=i),o},t.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),n=t.levels[r],i=t.config,a=i.fragLoadPolicy,o=i.keyLoadPolicy,s=Xt(e.details.startsWith("key")?o:a,e),u=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(n){var l;e.details!==_.FRAG_GAP&&n.fragmentError++;var c=null==(l=e.response)?void 0:l.code;if(Qt(s,u,Yt(e),c))return{action:or,flags:sr,retryConfig:s,retryCount:u}}var d=this.getLevelSwitchAction(e,r);return s&&(d.retryConfig=s,d.retryCount=u),d},t.getLevelSwitchAction=function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var n=this.hls.levels[t];if(n&&(n.loadError++,r.autoLevelEnabled)){for(var i,a,o=-1,s=r.levels,u=r.loadLevel,l=r.minAutoLevel,c=r.maxAutoLevel,d=null==(i=e.frag)?void 0:i.type,f=null!=(a=e.context)?a:{},h=f.type,p=f.groupId,m=s.length;m--;){var g=(m+u)%s.length;if(g!==u&&g>=l&&g<=c&&0===s[g].loadError){var v=s[g];if(e.details===_.FRAG_GAP&&e.frag){var y=s[g].details;if(y){var b=er(e.frag,y.fragments,e.frag.start);if(null!=b&&b.gap)continue}}else{if(h===pt&&p===v.audioGroupId||h===mt&&p===v.textGroupId)continue;if(d===vt&&n.audioGroupId===v.audioGroupId||d===yt&&n.textGroupId===v.textGroupId)continue}o=g;break}}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:ar,flags:sr,nextAutoLevel:o}}return{action:ar,flags:ur}},t.onErrorOut=function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case ir:break;case ar:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===_.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()},t.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var n=r.flags,i=r.hdcpLevel,a=r.nextAutoLevel;switch(n){case sr:this.switchLevel(e,a);break;case ur:r.resolved||(r.resolved=this.redundantFailover(e));break;case lr:i&&(t.maxHdcpLevel=Pt[Pt.indexOf(i)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,a)}},t.switchLevel=function(e,t){void 0!==t&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},t.redundantFailover=function(e){var t=this,r=this.hls,n=this.penalizedRenditions,i=e.parent===gt?e.level:r.loadLevel,a=r.levels[i],o=a.url.length,s=e.frag?e.frag.urlId:a.urlId;a.urlId!==s||e.frag&&!a.details||this.penalizeRendition(a,e);for(var u=function(){var u=(s+l)%o,c=n[u];if(!c||function(e,t,r){if(performance.now()-e.lastErrorPerfMs>3e5)return!0;var n=e.details;if(t.details===_.FRAG_GAP&&n&&t.frag){var i=t.frag.start,a=er(null,n.fragments,i);if(a&&!a.gap)return!0}if(r&&e.errors.length3*n.targetduration)return!0}return!1}(c,e,n[s]))return t.warn("Switching to Redundant Stream "+(u+1)+"/"+o+': "'+a.url[u]+'" after '+e.details),t.playlistError=0,r.levels.forEach((function(e){e.urlId=u})),r.nextLoadLevel=i,{v:!0}},l=1;l=0&&c>t.partTarget&&(l+=1)}return new Wt(u,l>=0?l:void 0,Ft)}}},t.loadPlaylist=function(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},t.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},t.shouldReloadPlaylist=function(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)},t.playlistLoaded=function(e,t,r){var n=this,i=t.details,a=t.stats,o=self.performance.now(),s=a.loading.first?Math.max(0,o-a.loading.first):0;if(i.advancedDateTime=Date.now()-s,i.live||null!=r&&r.live){if(i.reloaded(r),r&&this.log("live playlist "+e+" "+(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),r&&i.fragments.length>0&&qt(r,i),!this.canLoad||!i.live)return;var u,l=void 0,c=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var d=this.hls.config.lowLatencyMode,f=i.lastPartSn,h=i.endSN,p=i.lastPartIndex,m=f===h;-1!==p?(l=m?h+1:f,c=m?d?0:p:p+1):l=h+1;var g=i.age,v=g+i.ageHeader,y=Math.min(v-i.partTarget,1.5*i.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+i.age),y=0;else{var b=Math.floor(y/i.targetduration);l+=b,void 0!==c&&(c+=Math.round(y%i.targetduration/i.partTarget)),this.log("CDN Tune-in age: "+i.ageHeader+"s last advanced "+g.toFixed(2)+"s goal: "+y+" skip sn "+b+" to part "+c)}i.tuneInGoal=y}if(u=this.getDeliveryDirectives(i,t.deliveryDirectives,l,c),d||!m)return void this.loadPlaylist(u)}else(i.canBlockReload||i.canSkipUntil)&&(u=this.getDeliveryDirectives(i,t.deliveryDirectives,l,c));var E=this.hls.mainForwardBufferInfo,S=E?E.end-E.len:0,T=function(e,t){void 0===t&&(t=1/0);var r=1e3*e.targetduration;if(e.updated){var n=e.fragments;if(n.length&&4*r>t){var i=1e3*n[n.length-1].duration;ithis.requestScheduled+T&&(this.requestScheduled=a.loading.start),void 0!==l&&i.canBlockReload?this.requestScheduled=a.loading.first+T-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+T=l.maxNumRetry)return!1;if(n&&null!=(d=e.context)&&d.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+l.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var f=$t(l,u);this.timer=self.setTimeout((function(){return t.loadPlaylist()}),f),this.warn("Retrying playlist loading "+(u+1)+"/"+l.maxNumRetry+' after "'+r+'" in '+f+"ms")}e.levelRetry=!0,i.resolved=!0}return c},e}(),fr=function(e){function t(t,r){var n;return(n=e.call(this,t,"[level-controller]")||this)._levels=[],n._firstLevel=-1,n._startLevel=void 0,n.currentLevel=null,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.steering=void 0,n.onParsedComplete=void 0,n.steering=r,n._registerListeners(),n}u(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this),e.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.ERROR,this.onError,this)},r._unregisterListeners=function(){var e=this.hls;e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this),e.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},r.startLoad=function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),e.prototype.startLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},r.onManifestLoading=function(e,t){this.resetLevels()},r.onManifestLoaded=function(e,t){var r,n=[],i={};t.levels.forEach((function(e){var t,a=e.attrs;-1!==(null==(t=e.audioCodec)?void 0:t.indexOf("mp4a.40.34"))&&(nr||(nr=/chrome|firefox/i.test(navigator.userAgent)),nr&&(e.audioCodec=void 0));var o=a.AUDIO,s=a.CODECS,u=a["FRAME-RATE"],l=a["PATHWAY-ID"],c=a.RESOLUTION,d=a.SUBTITLES,f=(l||".")+"-"+e.bitrate+"-"+c+"-"+u+"-"+s;(r=i[f])?r.addFallback(e):(r=new jt(e),i[f]=r,n.push(r)),hr(r,"audio",o),hr(r,"text",d)})),this.filterAndSortMediaOptions(n,t)},r.filterAndSortMediaOptions=function(e,t){var r=this,n=[],i=[],a=!1,o=!1,s=!1,u=e.filter((function(e){var t=e.audioCodec,r=e.videoCodec,n=e.width,i=e.height,u=e.unknownCodecs;return a||(a=!(!n||!i)),o||(o=!!r),s||(s=!!t),!(null!=u&&u.length)&&(!t||Qe(t,"audio"))&&(!r||Qe(r,"video"))}));if((a||o)&&s&&(u=u.filter((function(e){var t=e.videoCodec,r=e.width,n=e.height;return!!t||!(!r||!n)}))),0!==u.length){t.audioTracks&&pr(n=t.audioTracks.filter((function(e){return!e.audioCodec||Qe(e.audioCodec,"audio")}))),t.subtitles&&pr(i=t.subtitles);var l=u.slice(0);u.sort((function(e,t){return e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs["FRAME-RATE"]!==t.attrs["FRAME-RATE"]?e.attrs.decimalFloatingPoint("FRAME-RATE")-t.attrs.decimalFloatingPoint("FRAME-RATE"):e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):a&&e.height!==t.height?e.height-t.height:0}));var c=l[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==l.length)for(var d=0;d1&&void 0!==t?(i.url=i.url.filter(n),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(n)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(n)),i.urlId=0,!0):(r.steering&&r.steering.removeLevel(i),!1))}));this.hls.trigger(R.LEVELS_UPDATED,{levels:i})},r.onLevelsUpdated=function(e,t){var r=t.levels;r.forEach((function(e,t){var r=e.details;null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t}))})),this._levels=r},a(t,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var r=new Error("invalid level idx"),n=e<0;if(this.hls.trigger(R.ERROR,{type:I.OTHER_ERROR,details:_.LEVEL_SWITCH_ERROR,level:e,fatal:n,error:r,reason:r.message}),n)return;e=Math.min(e,t.length-1)}var i=this.currentLevelIndex,a=this.currentLevel,o=a?a.attrs["PATHWAY-ID"]:void 0,u=t[e],l=u.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=u,i!==e||!u.details||!a||o!==l){this.log("Switching to level "+e+(l?" with Pathway "+l:"")+" from level "+i+(o?" with Pathway "+o:""));var c=s({},u,{level:e,maxBitrate:u.maxBitrate,attrs:u.attrs,uri:u.uri,urlId:u.urlId});delete c._attrs,delete c._urlId,this.hls.trigger(R.LEVEL_SWITCHING,c);var d=u.details;if(!d||d.live){var f=this.switchParams(u.uri,null==a?void 0:a.details);this.loadPlaylist(f)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),t}(dr);function hr(e,t,r){r&&("audio"===t?(e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds[e.url.length-1]=r):"text"===t&&(e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds[e.url.length-1]=r))}function pr(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var mr="NOT_LOADED",gr="APPENDING",vr="PARTIAL",yr="OK",br=function(){function e(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(R.BUFFER_APPENDED,this.onBufferAppended,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(R.BUFFER_APPENDED,this.onBufferAppended,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var n=r.length;n--;){var i=r[n];if(!i)break;var a=i.end;if(i.start<=e&&null!==a&&e<=a)return i}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,n=Object.keys(r),i=n.length;i--;){var a=r[n[i]];if((null==a?void 0:a.body.type)===t&&a.buffered){var o=a.body;if(o.start<=e&&e<=o.end)return o}}return null},t.detectEvictedFragments=function(e,t,r,n){var i=this;this.timeRanges&&(this.timeRanges[e]=t);var a=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(n){var o=i.fragments[n];if(o&&!(a>=o.body.sn))if(o.buffered||o.loaded){var s=o.range[e];s&&s.time.some((function(e){var r=!i.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&i.removeFragment(o.body),r}))}else o.body.type===r&&i.removeFragment(o.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,n=e.frag,i=e.part;if(r&&"initSegment"!==n.sn){var a=Sr(n),o=this.fragments[a];if(!(!o||o.buffered&&n.gap)){var s=!n.relurl;Object.keys(r).forEach((function(e){var a=n.elementaryStreams[e];if(a){var u=r[e],l=s||!0===a.partial;o.range[e]=t.getBufferedTimes(n,i,l,u)}})),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,(o.body.endList=n.endList||o.body.endList)&&(this.endListFragments[o.body.type]=o),Er(o)||this.removeParts(n.sn-1,n.type)):this.removeFragment(o.body)}}},t.removeParts=function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter((function(t){return t.fragment.sn>=e})))},t.fragBuffered=function(e,t){var r=Sr(e),n=this.fragments[r];!n&&t&&(n=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)},t.getBufferedTimes=function(e,t,r,n){for(var i={time:[],partial:r},a=e.start,o=e.end,s=e.minEndPTS||o,u=e.maxStartPTS||a,l=0;l=c&&s<=d){i.time.push({startPTS:Math.max(a,n.start(l)),endPTS:Math.min(o,n.end(l))});break}if(ac)i.partial=!0,i.time.push({startPTS:Math.max(a,n.start(l)),endPTS:Math.min(o,n.end(l))});else if(o<=c)break}return i},t.getPartialFragment=function(e){var t,r,n,i=null,a=0,o=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach((function(u){var l=s[u];l&&Er(l)&&(r=l.body.start-o,n=l.body.end+o,e>=r&&e<=n&&(t=Math.min(e-r,n-e),a<=t&&(i=l.body,a=t)))})),i},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||Er(t))},t.getState=function(e){var t=Sr(e),r=this.fragments[t];return r?r.buffered?Er(r)?vr:yr:gr:mr},t.isTimeBuffered=function(e,t,r){for(var n,i,a=0;a=n&&t<=i)return!0;if(t<=n)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,n=t.part;if("initSegment"!==r.sn&&!r.bitrateTest){var i=n?null:t,a=Sr(r);this.fragments[a]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,n=t.frag,i=t.part,a=t.timeRanges;if("initSegment"!==n.sn){var o=n.type;if(i){var s=this.activePartLists[o];s||(this.activePartLists[o]=s=[]),s.push(i)}this.timeRanges=a,Object.keys(a).forEach((function(e){var t=a[e];r.detectEvictedFragments(e,t,o,i)}))}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=Sr(e);return!!this.fragments[t]},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.removeFragmentsInRange=function(e,t,r,n,i){var a=this;n&&!this.hasGaps||Object.keys(this.fragments).forEach((function(o){var s=a.fragments[o];if(s){var u=s.body;u.type!==r||n&&!u.gap||u.starte&&(s.buffered||i)&&a.removeFragment(u)}}))},t.removeFragment=function(e){var t=Sr(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var n=e.sn;this.activePartLists[e.type]=r.filter((function(e){return e.fragment.sn!==n}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},e}();function Er(e){var t,r,n;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(n=e.range.audiovideo)?void 0:n.partial))}function Sr(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}var Tr=Math.pow(2,17),Rr=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new wr({type:I.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,o=a.fLoader,s=a.loader;return new Promise((function(u,l){if(r.loader&&r.loader.destroy(),e.gap){if(e.tagList.some((function(e){return"GAP"===e[0]})))return void l(_r(e));e.gap=!1}var c=r.loader=e.loader=o?new o(a):new s(a),d=Ir(e),f=Jt(a.fragLoadPolicy.default),h={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Tr};e.stats=c.stats,c.load(d,h,{onSuccess:function(t,n,i,a){r.resetLoader(e,c);var o=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(o.slice(0,16)),o=o.slice(16)),u({frag:e,part:null,payload:o,networkDetails:a})},onError:function(t,a,o,s){r.resetLoader(e,c),l(new wr({type:I.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:n({url:i,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:o,stats:s}))},onAbort:function(t,n,i){r.resetLoader(e,c),l(new wr({type:I.NETWORK_ERROR,details:_.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:function(t,n,i){r.resetLoader(e,c),l(new wr({type:I.NETWORK_ERROR,details:_.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+h.timeout+"ms"),networkDetails:i,stats:t}))},onProgress:function(r,n,i,a){t&&t({frag:e,part:null,payload:i,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,o=a.fLoader,s=a.loader;return new Promise((function(u,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(_r(e,t));else{var c=i.loader=e.loader=o?new o(a):new s(a),d=Ir(e,t),f=Jt(a.fragLoadPolicy.default),h={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Tr};t.stats=c.stats,c.load(d,h,{onSuccess:function(n,a,o,s){i.resetLoader(e,c),i.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:n.data,networkDetails:s};r(l),u(l)},onError:function(r,a,o,s){i.resetLoader(e,c),l(new wr({type:I.NETWORK_ERROR,details:_.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:n({url:d.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:o,stats:s}))},onAbort:function(r,n,a){e.stats.aborted=t.stats.aborted,i.resetLoader(e,c),l(new wr({type:I.NETWORK_ERROR,details:_.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:r}))},onTimeout:function(r,n,a){i.resetLoader(e,c),l(new wr({type:I.NETWORK_ERROR,details:_.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+h.timeout+"ms"),networkDetails:a,stats:r}))}})}}))},t.updateStatsFromPart=function(e,t){var r=e.stats,n=t.stats,i=n.total;if(r.loaded+=n.loaded,i){var a=Math.round(e.duration/t.duration),o=Math.min(Math.round(r.loaded/i),a),s=(a-o)*Math.round(r.loaded/o);r.total=r.loaded+s}else r.total=Math.max(r.loaded,r.total);var u=r.loading,l=n.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function Ir(e,t){void 0===t&&(t=null);var r=t||e,n={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},i=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if(E(i)&&E(a)){var o,s=i,u=a;if("initSegment"===e.sn&&"AES-128"===(null==(o=e.decryptdata)?void 0:o.method)){var l=a-i;l%16&&(u=a+(16-l%16)),0!==i&&(n.resetIV=!0,s=i-16)}n.rangeStart=s,n.rangeEnd=u}return n}function _r(e,t){var r=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),n={type:I.MEDIA_ERROR,details:_.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(n.part=t),(t||e).stats.aborted=!0,new wr(n)}var wr=function(e){function t(t){var r;return(r=e.call(this,t.error.message)||this).data=void 0,r.data=t,r}return u(t,e),t}(h(Error)),kr=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,r,n,i){return void 0===t&&(t=_.KEY_LOAD_ERROR),new wr({type:I.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:i,error:r,networkDetails:n})},t.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var n=e.sn,i=e.cc,a=function(){var e=t[o];if(i<=e.cc&&("initSegment"===n||"initSegment"===e.sn||n1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}(),Lr={length:0,start:function(){return 0},end:function(){return 0}},xr=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var n=e.getBuffered(t),i=0;i=n.start(i)&&r<=n.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,n){try{if(t){var i,a=e.getBuffered(t),o=[];for(i=0;io&&(n[a-1].end=e[i].end):n.push(e[i])}else n.push(e[i])}else n=e;for(var s,u=0,l=t,c=t,d=0;d=f&&tr.startCC||e&&e.cc>>8^255&g^99,e[h]=g,t[g]=h;var v=f[h],y=f[v],b=f[y],E=257*f[g]^16843008*g;n[h]=E<<24|E>>>8,i[h]=E<<16|E>>>16,a[h]=E<<8|E>>>24,o[h]=E,E=16843009*b^65537*y^257*v^16843008*h,u[g]=E<<24|E>>>8,l[g]=E<<16|E>>>16,c[g]=E<<8|E>>>24,d[g]=E,h?(h=v^f[f[f[b^v]]],p^=f[f[p]]):h=p=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,n=0;no.end){var c=a>l;(a0&&a&&a.key&&a.iv&&"AES-128"===a.method){var o=self.performance.now();return r.decrypter.decrypt(new Uint8Array(i),a.key.buffer,a.iv.buffer).catch((function(t){throw n.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((function(r){var i=self.performance.now();return n.trigger(R.FRAG_DECRYPTED,{frag:e,payload:r,stats:{tstart:o,tdecrypt:i}}),t.payload=r,t}))}return t})).then((function(n){var i=r.fragCurrent,a=r.hls;if(!r.levels)throw new Error("init load aborted, missing levels");var o=e.stats;r.state=qr,t.fragmentError=0,e.data=new Uint8Array(n.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),n.frag===i&&a.trigger(R.FRAG_BUFFERED,{stats:o,frag:i,part:null,id:e.type}),r.tick()})).catch((function(t){r.state!==Gr&&r.state!==Jr&&(r.warn(t),r.resetFragmentLoading(e))}))},r.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId},r.fragBufferedComplete=function(e,t){var r,n,i,a,o=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+(this.playlistType===gt?"level":"track")+" "+e.level+" (frag:["+(null!=(r=e.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(n=e.endPTS)?n:NaN).toFixed(3)+"] > buffer:"+(o?Br(xr.getBuffered(o)):"(detached)")+")"),this.state=qr,o&&(!this.loadedmetadata&&e.type==gt&&o.buffered.length&&(null==(i=this.fragCurrent)?void 0:i.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},r.seekToStartPos=function(){},r._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,n=e.part,i=e.partsLoaded,a=!i||0===i.length||i.some((function(e){return!e})),o=new Cr(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!a);t.flush(o)}},r._handleFragmentLoadProgress=function(e){},r._doFragLoad=function(e,t,r,n){var i,a=this;void 0===r&&(r=null);var o=null==t?void 0:t.details;if(!this.levels||!o)throw new Error("frag load aborted, missing level"+(o?"":" detail")+"s");var s=null;if(!e.encrypted||null!=(i=e.decryptdata)&&i.key?!e.encrypted&&o.encryptedFragments.length&&this.keyLoader.loadClear(e,o.encryptedFragments):(this.log("Loading key for "+e.sn+" of ["+o.startSN+"-"+o.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=Kr,this.fragCurrent=e,s=this.keyLoader.load(e).then((function(e){if(!a.fragContextChanged(e.frag))return a.hls.trigger(R.KEY_LOADED,e),a.state===Kr&&(a.state=qr),e})),this.hls.trigger(R.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(s=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){var u=o.partList;if(u&&n){r>e.end&&o.fragmentHint&&(e=o.fragmentHint);var l=this.getNextPart(u,e,r);if(l>-1){var c,d=u[l];return this.log("Loading part sn: "+e.sn+" p: "+d.index+" cc: "+e.cc+" of playlist ["+o.startSN+"-"+o.endSN+"] parts [0-"+l+"-"+(u.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=d.start+d.duration,this.state=Hr,c=s?s.then((function(r){return!r||a.fragContextChanged(r.frag)?null:a.doFragPartsLoad(e,d,t,n)})).catch((function(e){return a.handleFragLoadError(e)})):this.doFragPartsLoad(e,d,t,n).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(R.FRAG_LOADING,{frag:e,part:d,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(o?"of ["+o.startSN+"-"+o.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),E(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Hr;var f,h=this.config.progressive;return f=h&&s?s.then((function(t){return!t||a.fragContextChanged(null==t?void 0:t.frag)?null:a.fragmentLoader.load(e,n)})).catch((function(e){return a.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,h?n:void 0),s]).then((function(e){var t=e[0];return!h&&t&&n&&n(t),t})).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(R.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f},r.doFragPartsLoad=function(e,t,r,n){var i=this;return new Promise((function(a,o){var s,u=[],l=null==(s=r.details)?void 0:s.partList;!function t(s){i.fragmentLoader.loadPart(e,s,n).then((function(n){u[s.index]=n;var o=n.part;i.hls.trigger(R.FRAG_LOADED,n);var c=Vt(r,e.sn,s.index+1)||zt(l,e.sn,s.index+1);if(!c)return a({frag:e,part:o,partsLoaded:u});t(c)})).catch(o)}(t)}))},r.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===_.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(R.ERROR,t)}else this.hls.trigger(R.ERROR,{type:I.OTHER_ERROR,details:_.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},r._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===Yr){var r=t.frag,n=t.part,i=t.level,a=self.performance.now();r.stats.parsing.end=a,n&&(n.stats.parsing.end=a),this.updateLevelTiming(r,n,i,e.partial)}else this.fragCurrent||this.state===Gr||this.state===Jr||(this.state=qr)},r.getCurrentContext=function(e){var t=this.levels,r=this.fragCurrent,n=e.level,i=e.sn,a=e.part;if(null==t||!t[n])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+n+". The current chunk will not be buffered."),null;var o=t[n],s=a>-1?Vt(o,i,a):null,u=s?s.fragment:function(e,t,r){if(null==e||!e.details)return null;var n=e.details,i=n.fragments[t-n.startSN];return i||((i=n.fragmentHint)&&i.sn===t?i:ta&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)},r.getFwdBufferInfo=function(e,t){var r=this.getLoadPosition();return E(r)?this.getFwdBufferInfoAtPos(e,r,t):null},r.getFwdBufferInfoAtPos=function(e,t,r){var n=this.config.maxBufferHole,i=xr.bufferInfo(e,t,n);if(0===i.len&&void 0!==i.nextStart){var a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&i.nextStart=r&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},r.getAppendedFrag=function(e,t){var r=this.fragmentTracker.getAppendedFrag(e,gt);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(e,t){var r=t.fragments,n=r.length;if(!n)return null;var i,a=this.config,o=r[0].start;if(t.live){var s=a.initialLiveManifestSize;if(nt},r.getNextFragmentLoopLoading=function(e,t,r,n,i){var a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(null===o)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,n);if(null!==s&&r.len+s.len>=i)return this.log('buffer full after gaps in "'+n+'" playlist starting at sn: '+e.sn),null}return e},r.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},r.getNextPart=function(e,t,r){for(var n=-1,i=!1,a=!0,o=0,s=e.length;o-1&&rr.start&&r.loaded},r.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,n=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),n=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!E(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n=e.startSN&&i<=e.endSN){var a=t[i-e.startSN];r.cc===a.cc&&(n=a,this.log("Live playlist, switching playlist, load frag with next SN: "+n.sn))}n||(n=function(e,t){return Zt(e,(function(e){return e.cct?-1:0}))}(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)}}else{var o=this.hls.liveSyncPosition;null!==o&&(n=this.getFragmentAtPosition(o,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n},r.getFragmentAtPosition=function(e,t,r){var n,i=this.config,a=this.fragPrevious,o=r.fragments,s=r.endSN,u=r.fragmentHint,l=i.maxFragLookUpTolerance,c=r.partList,d=!!(i.lowLatencyMode&&null!=c&&c.length&&u);if(d&&u&&!this.bitrateTest&&(o=o.concat(u),s=u.sn),n=et-l?0:l):o[o.length-1]){var f=n.sn-r.startSN,h=this.fragmentTracker.getState(n);if((h===yr||h===vr&&n.gap)&&(a=n),a&&n.sn===a.sn&&(!d||c[0].fragment.sn>n.sn)&&a&&n.level===a.level){var p=o[f+1];n=n.sn=a-t.maxFragLookUpTolerance&&i<=o;if(null!==n&&r.duration>n&&(i"+e.startSN+" prev-sn: "+(i?i.sn:"na")+" fragments: "+o),c}return s},r.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},r.setStartPosition=function(e,t){var r=this.startPosition;if(r "+(null==(i=this.fragCurrent)?void 0:i.url))}else{var a=t.details===_.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(n,!0);var o=t.errorAction,s=o||{},u=s.action,l=s.retryCount,c=void 0===l?0:l,d=s.retryConfig;if(o&&u===or&&d){var f;this.resetStartWhenNotLoaded(null!=(f=this.levelLastLoaded)?f:n.level);var h=$t(d,c);this.warn("Fragment "+n.sn+" of "+e+" "+n.level+" errored with "+t.details+", retrying loading "+(c+1)+"/"+d.maxNumRetry+" in "+h+"ms"),o.resolved=!0,this.retryDate=self.performance.now()+h,this.state=Vr}else d&&o?(this.resetFragmentErrors(e),c.5;n&&this.reduceMaxBufferLength(r.len);var i=!n;return i&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+t+" buffer"),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),i}return!1},r.resetFragmentErrors=function(e){e===vt&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Gr&&(this.state=qr)},r.afterBufferFlushed=function(e,t,r){if(e){var n=xr.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,r),this.state===$r&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=qr},r.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=this.levels?this.levels[e].details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(e){var t;this.warn("The loading context changed while buffering fragment "+e.sn+" of level "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(t=this.levelLastLoaded)?t:e.level),this.resetLoadingState()},r.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(e,t,r,n){var i,a=this,o=r.details;if(o){if(Object.keys(e.elementaryStreams).reduce((function(t,i){var s=e.elementaryStreams[i];if(s){var u=s.endPTS-s.startPTS;if(u<=0)return a.warn("Could not parse fragment "+e.sn+" "+i+" duration reliably ("+u+")"),t||!1;var l=n?0:Gt(o,e,s.startPTS,s.endPTS,s.startDTS,s.endDTS);return a.hls.trigger(R.LEVEL_PTS_UPDATED,{details:o,level:r,drift:l,type:i,frag:e,start:s.startPTS,end:s.endPTS}),!0}return t}),!1))r.fragmentError=0;else if(null===(null==(i=this.transmuxer)?void 0:i.error)){var s=new Error("Found no media in fragment "+e.sn+" of level "+e.level+" resetting transmuxer to fallback to playlist timing");if(0===r.fragmentError&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(s.message),this.hls.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,error:s,frag:e,reason:"Found no media in msn "+e.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Xr,this.hls.trigger(R.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(e){var t,r,n;"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(t=null!=(r=this.levelLastLoaded)?r:null==(n=this.fragCurrent)?void 0:n.level)?t:0),this.resetLoadingState())},a(t,[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}]),t}(Ar);function tn(){return self.SourceBuffer||self.WebKitSourceBuffer}function rn(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var nn=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=Pe(this.cachedData,e),this.cachedData=null);var r,n=ue(e,0),i=n?n.length:0,a=this._audioTrack,o=this._id3Track,s=n?function(e){for(var t=he(e),r=0;r0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:wt,duration:Number.POSITIVE_INFINITY});i>>5}function ln(e,t){return t+1=e.length)return!1;var n=un(e,t);if(n<=r)return!1;var i=t+n;return i===e.length||ln(e,i)}return!1}function dn(e,t,r,n,i){if(!e.samplerate){var a=function(e,t,r,n){var i,a,o,s,u=navigator.userAgent.toLowerCase(),l=n,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=1+((192&t[r+2])>>>6);var d=(60&t[r+2])>>>2;if(!(d>c.length-1))return o=(1&t[r+2])<<2,o|=(192&t[r+3])>>>6,C.log("manifest codec:"+n+", ADTS type:"+i+", samplingIndex:"+d),/firefox/i.test(u)?d>=6?(i=5,s=new Array(4),a=d-3):(i=2,s=new Array(2),a=d):-1!==u.indexOf("android")?(i=2,s=new Array(2),a=d):(i=5,s=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&d>=6?a=d-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(d>=6&&1===o||/vivaldi/i.test(u))||!n&&1===o)&&(i=2,s=new Array(2)),a=d)),s[0]=i<<3,s[0]|=(14&d)>>1,s[1]|=(1&d)<<7,s[1]|=o<<3,5===i&&(s[1]|=(14&a)>>1,s[2]=(1&a)<<7,s[2]|=8,s[3]=0),{config:s,samplerate:c[d],channelCount:o,codec:"mp4a.40."+i,manifestCodec:l};e.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}(t,r,n,i);if(!a)return;e.config=a.config,e.samplerate=a.samplerate,e.channelCount=a.channelCount,e.codec=a.codec,e.manifestCodec=a.manifestCodec,C.log("parsed codec:"+e.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function fn(e){return 9216e4/e}function hn(e,t,r,n,i){var a,o=n+i*fn(e.samplerate),s=function(e,t){var r=sn(e,t);if(t+r<=e.length){var n=un(e,t)-r;if(n>0)return{headerLength:r,frameLength:n}}}(t,r);if(s){var u=s.frameLength,l=s.headerLength,c=l+u,d=Math.max(0,r+c-t.length);d?(a=new Uint8Array(c-l)).set(t.subarray(r+l,t.length),0):a=t.subarray(r+l,r+c);var f={unit:a,pts:o};return d||e.samples.push(f),{sample:f,length:c,missing:d}}var h=t.length-r;return(a=new Uint8Array(h)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:o},length:h,missing:-1}}var pn=function(e){function t(t,r){var n;return(n=e.call(this)||this).observer=void 0,n.config=void 0,n.observer=t,n.config=r,n}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,n,i){e.prototype.resetInitSegment.call(this,t,r,n,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:i,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;for(var t=(ue(e,0)||[]).length,r=e.length;t16384?e.subarray(0,16384):e,["moof"]).length>0},t.demux=function(e,t){this.timeOffset=t;var r=e,n=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Pe(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=xe(e,["moof"]);if(!r)return t;if(r.length<2)return t.remainder=e,t;var n=r[r.length-1];return t.valid=ie(e,0,n.byteOffset-8),t.remainder=ie(e,n.byteOffset-8),t}(r);this.remainderData=a.remainder,n.samples=a.valid||new Uint8Array}else n.samples=r;var o=this.extractID3Track(n,t);return i.samples=Fe(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(t,this.timeOffset);return r.samples=Fe(e,t),{videoTrack:t,audioTrack:rn(),id3Track:n,textTrack:rn()}},t.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var n=xe(e.samples,["emsg"]);n&&n.forEach((function(e){var n=function(e){var t=e[0],r="",n="",i=0,a=0,o=0,s=0,u=0,l=0;if(0===t){for(;"\0"!==_e(e.subarray(l,l+1));)r+=_e(e.subarray(l,l+1)),l+=1;for(r+=_e(e.subarray(l,l+1)),l+=1;"\0"!==_e(e.subarray(l,l+1));)n+=_e(e.subarray(l,l+1)),l+=1;n+=_e(e.subarray(l,l+1)),l+=1,i=ke(e,12),a=ke(e,16),s=ke(e,20),u=ke(e,24),l=28}else if(1===t){i=ke(e,l+=4);var c=ke(e,l+=4),d=ke(e,l+=4);for(l+=4,o=Math.pow(2,32)*c+d,S(o)||(o=Number.MAX_SAFE_INTEGER,C.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),s=ke(e,l),u=ke(e,l+=4),l+=4;"\0"!==_e(e.subarray(l,l+1));)r+=_e(e.subarray(l,l+1)),l+=1;for(r+=_e(e.subarray(l,l+1)),l+=1;"\0"!==_e(e.subarray(l,l+1));)n+=_e(e.subarray(l,l+1)),l+=1;n+=_e(e.subarray(l,l+1)),l+=1}return{schemeIdUri:r,value:n,timeScale:i,presentationTime:o,presentationTimeDelta:a,eventDuration:s,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(mn.test(n.schemeIdUri)){var i=E(n.presentationTime)?n.presentationTime/n.timeScale:t+n.presentationTimeDelta/n.timeScale,a=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var o=n.payload;r.samples.push({data:o,len:o.byteLength,dts:i,pts:i,type:At,duration:a})}}))}return r},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}(),vn=null,yn=[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],bn=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],En=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Sn=[0,1,1,4];function Tn(e,t,r,n,i){if(!(r+24>t.length)){var a=Rn(t,r);if(a&&r+a.frameLength<=t.length){var o=n+i*(9e4*a.samplesPerFrame/a.sampleRate),s={unit:t.subarray(r,r+a.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(s),{sample:s,length:a.frameLength,missing:0}}}}function Rn(e,t){var r=e[t+1]>>3&3,n=e[t+1]>>1&3,i=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==r&&0!==i&&15!==i&&3!==a){var o=e[t+2]>>1&1,s=e[t+3]>>6,u=1e3*yn[14*(3===r?3-n:3===n?3:4)+i-1],l=bn[3*(3===r?0:2===r?1:2)+a],c=3===s?1:2,d=En[r][n],f=Sn[n],h=8*d*f,p=Math.floor(d*u/l+o)*f;if(null===vn){var m=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);vn=m?parseInt(m[1]):0}return!!vn&&vn<=87&&2===n&&u>=224e3&&0===s&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:c,frameLength:p,samplesPerFrame:h}}}function In(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function _n(e,t){return t+1e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&C.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,n=0;n=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),n=0,i=32;i=e.length)return void n();for(var i=e[t].units;!(r>=i.length);r++){var a=i[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,r,n,a),this.decrypter.isSync())))return}}},e}(),Ln=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}e.probe=function(t){var r=e.syncOffset(t);return r>0&&C.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=e.length,r=Math.min(940,e.length-188)+1,n=0;n1&&(0===a&&o>2||s+188>r))return a}n++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Ie[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,n,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",i),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=n,this._duration=i},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},t.demux=function(t,r,n,i){var a;void 0===n&&(n=!1),void 0===i&&(i=!1),n||(this.sampleAes=null);var o=this._avcTrack,s=this._audioTrack,u=this._id3Track,l=this._txtTrack,c=o.pid,d=o.pesData,f=s.pid,h=u.pid,p=s.pesData,m=u.pesData,g=null,v=this.pmtParsed,y=this._pmtId,b=t.length;if(this.remainderData&&(b=(t=Pe(this.remainderData,t)).length,this.remainderData=null),b<188&&!i)return this.remainderData=t,{audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};var E=Math.max(0,e.syncOffset(t));(b-=(b-E)%188)>4>1){if((A=T+5+t[T+4])===T+188)continue}else A=T+4;switch(k){case c:w&&(d&&(a=Dn(d))&&this.parseAVCPES(o,l,a,!1),d={data:[],size:0}),d&&(d.data.push(t.subarray(A,T+188)),d.size+=T+188-A);break;case f:if(w){if(p&&(a=Dn(p)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,a);break;case"mp3":this.parseMPEGPES(s,a)}p={data:[],size:0}}p&&(p.data.push(t.subarray(A,T+188)),p.size+=T+188-A);break;case h:w&&(m&&(a=Dn(m))&&this.parseID3PES(u,a),m={data:[],size:0}),m&&(m.data.push(t.subarray(A,T+188)),m.size+=T+188-A);break;case 0:w&&(A+=t[A]+1),y=this._pmtId=Mn(t,A);break;case y:w&&(A+=t[A]+1);var L=On(t,A,this.typeSupported,n);(c=L.avc)>0&&(o.pid=c),(f=L.audio)>0&&(s.pid=f,s.segmentCodec=L.segmentCodec),(h=L.id3)>0&&(u.pid=h),null===g||v||(C.warn("MPEG-TS PMT found at "+T+" after unknown PID '"+g+"'. Backtracking to sync byte @"+E+" to parse all TS packets."),g=null,T=E-188),v=this.pmtParsed=!0;break;case 17:case 8191:break;default:g=k}}else S++;if(S>0){var x=new Error("Found "+S+" TS packet/s that do not start with 0x47");this.observer.emit(R.ERROR,R.ERROR,{type:I.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,error:x,reason:x.message})}o.pesData=d,s.pesData=p,u.pesData=m;var M={audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};return i&&this.extractRemainingSamples(M),M},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,n=e.videoTrack,i=e.id3Track,a=e.textTrack,o=n.pesData,s=r.pesData,u=i.pesData;if(o&&(t=Dn(o))?(this.parseAVCPES(n,a,t,!0),n.pesData=null):n.pesData=o,s&&(t=Dn(s))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=s&&s.size&&C.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=s;u&&(t=Dn(u))?(this.parseID3PES(i,t),i.pesData=null):i.pesData=u},t.demuxSampleAes=function(e,t,r){var n=this.demux(e,r,!0,!this.config.progressive),i=this.sampleAes=new An(this.observer,this.config,t);return this.decrypt(n,i)},t.decrypt=function(e,t){return new Promise((function(r){var n=e.audioTrack,i=e.videoTrack;n.samples&&"aac"===n.segmentCodec?t.decryptAacSamples(n.samples,0,(function(){i.samples?t.decryptAvcSamples(i.samples,0,0,(function(){r(e)})):r(e)})):i.samples&&t.decryptAvcSamples(i.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._duration=0},t.parseAVCPES=function(e,t,r,n){var i,a=this,o=this.parseAVCNALu(e,r.data),s=this.avcSample,u=!1;r.data=null,s&&o.length&&!e.audFound&&(Pn(s,e),s=this.avcSample=xn(!1,r.pts,r.dts,"")),o.forEach((function(n){var o;switch(n.type){case 1:var l=!1;i=!0;var c,d=n.data;if(u&&d.length>4){var f=new kn(d).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(l=!0)}l&&null!=(c=s)&&c.frame&&!s.key&&(Pn(s,e),s=a.avcSample=null),s||(s=a.avcSample=xn(!0,r.pts,r.dts,"")),s.frame=!0,s.key=l;break;case 5:i=!0,null!=(o=s)&&o.frame&&!s.key&&(Pn(s,e),s=a.avcSample=null),s||(s=a.avcSample=xn(!0,r.pts,r.dts,"")),s.key=!0,s.frame=!0;break;case 6:i=!0,Ue(n.data,1,r.pts,t.samples);break;case 7:if(i=!0,u=!0,!e.sps){var h=n.data,p=new kn(h).readSPS();e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[h],e.duration=a._duration;for(var m=h.subarray(1,4),g="avc1.",v=0;v<3;v++){var y=m[v].toString(16);y.length<2&&(y="0"+y),g+=y}e.codec=g}break;case 8:i=!0,e.pps||(e.pps=[n.data]);break;case 9:i=!1,e.audFound=!0,s&&Pn(s,e),s=a.avcSample=xn(!1,r.pts,r.dts,"");break;case 12:i=!0;break;default:i=!1,s&&(s.debug+="unknown NAL "+n.type+" ")}s&&i&&s.units.push(n)})),n&&s&&(Pn(s,e),this.avcSample=null)},t.getLastNalUnit=function(e){var t,r,n=this.avcSample;if(n&&0!==n.units.length||(n=e[e.length-1]),null!=(t=n)&&t.units){var i=n.units;r=i[i.length-1]}return r},t.parseAVCNALu=function(e,t){var r,n,i=t.byteLength,a=e.naluState||0,o=a,s=[],u=0,l=-1,c=0;for(-1===a&&(l=0,c=31&t[0],a=0,u=1);u=0){var d={data:t.subarray(l,u-a-1),type:c};s.push(d)}else{var f=this.getLastNalUnit(e.samples);if(f&&(o&&u<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),(n=u-a-1)>0)){var h=new Uint8Array(f.data.byteLength+n);h.set(f.data,0),h.set(t.subarray(0,n),f.data.byteLength),f.data=h,f.state=0}}u=0&&a>=0){var p={data:t.subarray(l,i),type:c,state:a};s.push(p)}if(0===s.length){var m=this.getLastNalUnit(e.samples);if(m){var g=new Uint8Array(m.data.byteLength+t.byteLength);g.set(m.data,0),g.set(t,m.data.byteLength),m.data=g}}return e.naluState=a,s},t.parseAACPES=function(e,t){var r,n,i,a=0,o=this.aacOverFlow,s=t.data;if(o){this.aacOverFlow=null;var u=o.missing,l=o.sample.unit.byteLength;if(-1===u){var c=new Uint8Array(l+s.byteLength);c.set(o.sample.unit,0),c.set(s,l),s=c}else{var d=l-u;o.sample.unit.set(s.subarray(0,u),d),e.samples.push(o.sample),a=o.missing}}for(r=a,n=s.length;r1;){var u=new Uint8Array(s[0].length+s[1].length);u.set(s[0]),u.set(s[1],s[0].length),s[0]=u,s.splice(1,1)}if(1===((t=s[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var l=t[7];192&l&&(i=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?i-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(C.warn(Math.round((i-a)/9e4)+"s delta between PTS and DTS, align them"),i=a):a=i);var c=(n=t[8])+9;if(e.size<=c)return null;e.size-=c;for(var d=new Uint8Array(e.size),f=0,h=s.length;fp){c-=p;continue}t=t.subarray(c),p-=c,c=0}d.set(t,o),o+=p}return r&&(r-=n+3),{data:d,pts:i,dts:a,len:r}}return null}function Pn(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,n=r.length;if(!n)return void t.dropped++;var i=r[n-1];e.pts=i.pts,e.dts=i.dts}t.samples.push(e)}e.debug.length&&C.log(e.pts+"/"+e.dts+":"+e.debug)}var Fn=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,n,i){e.prototype.resetInitSegment.call(this,t,r,n,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:i,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;for(var t=(ue(e,0)||[]).length,r=e.length;t1?r-1:0),i=1;i>24&255,s[1]=t>>16&255,s[2]=t>>8&255,s[3]=255&t,s.set(e,4),a=0,t=8;a>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,r))},e.moov=function(t){for(var r=t.length,n=[];r--;)n[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(n).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,n=[];r--;)n[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(n))},e.mvhd=function(t,r){r*=t;var n=Math.floor(r/(Un+1)),i=Math.floor(r%(Un+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,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 e.box(e.types.mvhd,a)},e.sdtp=function(t){var r,n,i=t.samples||[],a=new Uint8Array(4+i.length);for(r=0;r>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(n));for(r=0;r>>8&255),o.push(255&i),o=o.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(o))),u=t.width,l=t.height,c=t.pixelRatio[0],d=t.pixelRatio[1];return e.box(e.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,u>>8&255,255&u,l>>8&255,255&l,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]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,n=t.duration*t.timescale,i=t.width,a=t.height,o=Math.floor(n/(Un+1)),s=Math.floor(n%(Un+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,i>>8&255,255&i,0,0,a>>8&255,255&a,0,0]))},e.traf=function(t,r){var n=e.sdtp(t),i=t.id,a=Math.floor(r/(Un+1)),o=Math.floor(r%(Un+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var n,i,a,o,s,u,l=t.samples||[],c=l.length,d=12+16*c,f=new Uint8Array(d);for(r+=8+d,f.set(["video"===t.type?1:0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),n=0;n>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*n);return e.box(e.types.trun,f)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t),n=new Uint8Array(e.FTYP.byteLength+r.byteLength);return n.set(e.FTYP),n.set(r,e.FTYP.byteLength),n},e}();function jn(e,t,r,n){void 0===r&&(r=1),void 0===n&&(n=!1);var i=e*t*r;return n?Math.round(i):i}function Bn(e,t){return void 0===t&&(t=!1),jn(e,1e3,1/9e4,t)}Wn.types=void 0,Wn.HDLR_TYPES=void 0,Wn.STTS=void 0,Wn.STSC=void 0,Wn.STCO=void 0,Wn.STSZ=void 0,Wn.VMHD=void 0,Wn.SMHD=void 0,Wn.STSD=void 0,Wn.FTYP=void 0,Wn.DINF=void 0;var Gn=null,qn=null,Kn=function(){function e(e,t,r,n){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===Gn){var i=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Gn=i?parseInt(i[1]):0}if(null===qn){var a=navigator.userAgent.match(/Safari\/(\d+)/i);qn=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){C.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){C.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){C.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var n=r.pts-e;return n<-4294967296?(t=!0,Hn(e,r.pts)):n>0?e:r.pts}),e[0].pts);return t&&C.debug("PTS rollover detected"),r},t.remux=function(e,t,r,n,i,a,o,s){var u,l,c,d,f,h,p=i,m=i,g=e.pid>-1,v=t.pid>-1,y=t.samples.length,b=e.samples.length>0,E=o&&y>0||y>1;if((!g||b)&&(!v||E)||this.ISGenerated||o){this.ISGenerated||(c=this.generateIS(e,t,i,a));var S,T=this.isVideoContiguous,R=-1;if(E&&(R=function(e){for(var t=0;t0){C.warn("[mp4-remuxer]: Dropped "+R+" out of "+y+" video samples due to a missing keyframe");var I=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(R),t.dropped+=R,S=m+=(t.samples[0].pts-I)/t.inputTimeScale}else-1===R&&(C.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),h=!1);if(this.ISGenerated){if(b&&E){var _=this.getVideoStartPts(t.samples),w=(Hn(e.samples[0].pts,_)-_)/t.inputTimeScale;p+=Math.max(0,w),m+=Math.max(0,-w)}if(b){if(e.samplerate||(C.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,i,a)),l=this.remuxAudio(e,p,this.isAudioContiguous,a,v||E||s===vt?m:void 0),E){var k=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(C.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,i,a)),u=this.remuxVideo(t,m,T,k)}}else E&&(u=this.remuxVideo(t,m,T,0));u&&(u.firstKeyFrame=R,u.independent=-1!==R,u.firstKeyFramePTS=S)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Vn(r,i,this._initPTS,this._initDTS)),n.samples.length&&(d=zn(n,i,this._initPTS))),{audio:l,video:u,initSegment:c,independent:h,text:d,id3:f}},t.generateIS=function(e,t,r,n){var i,a,o,s=e.samples,u=t.samples,l=this.typeSupported,c={},d=this._initPTS,f=!d||n,h="audio/mp4";if(f&&(i=a=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(h="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3")}c.audio={id:"audio",container:h,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):Wn.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(o=e.inputTimeScale,d&&o===d.timescale?f=!1:i=a=s[0].pts-Math.round(o*r))}if(t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Wn.initSegment([t]),metadata:{width:t.width,height:t.height}},f))if(o=t.inputTimeScale,d&&o===d.timescale)f=!1;else{var p=this.getVideoStartPts(u),m=Math.round(o*r);a=Math.min(a,Hn(u[0].dts,p)-m),i=Math.min(i,p-m)}if(Object.keys(c).length)return this.ISGenerated=!0,f?(this._initPTS={baseTime:i,timescale:o},this._initDTS={baseTime:a,timescale:o}):i=o=void 0,{tracks:c,initPTS:i,timescale:o}},t.remuxVideo=function(e,t,r,n){var i,a,o=e.inputTimeScale,u=e.samples,l=[],c=u.length,d=this._initPTS,f=this.nextAvcDts,h=8,p=this.videoSampleDuration,m=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;r&&null!==f||(f=t*o-(u[0].pts-Hn(u[0].dts,u[0].pts)));for(var y=d.baseTime*o/d.timescale,b=0;b0?b-1:b].dts&&(v=!0)}v&&u.sort((function(e,t){var r=e.dts-t.dts,n=e.pts-t.pts;return r||n})),i=u[0].dts;var S=(a=u[u.length-1].dts)-i,T=S?Math.round(S/(c-1)):p||e.inputTimeScale/30;if(r){var w=i-f,k=w>T,A=w<-1;if((k||A)&&(k?C.warn("AVC: "+Bn(w,!0)+" ms ("+w+"dts) hole between fragments detected, filling it"):C.warn("AVC: "+Bn(-w,!0)+" ms ("+w+"dts) overlapping between fragments detected"),!A||f>=u[0].pts)){i=f;var L=u[0].pts-w;u[0].dts=i,u[0].pts=L,C.log("Video: First PTS/DTS adjusted: "+Bn(L,!0)+"/"+Bn(i,!0)+", delta: "+Bn(w,!0)+" ms")}}i=Math.max(0,i);for(var x=0,M=0,O=0;O0?Y.dts-u[z-1].dts:T;if(re=z>0?Y.pts-u[z-1].pts:T,ne.stretchShortVideoTrack&&null!==this.nextAudioPts){var ae=Math.floor(ne.maxBufferHole*o),oe=(n?m+n*o:this.nextAudioPts)-Y.pts;oe>ae?((p=oe-ie)<0?p=ie:G=!0,C.log("[mp4-remuxer]: It is approximately "+oe/90+" ms to the next segment; using duration "+p/90+" ms for the last video frame.")):p=ie}else p=ie}var se=Math.round(Y.pts-Y.dts);q=Math.min(q,p),H=Math.max(H,p),K=Math.min(K,re),V=Math.max(V,re),l.push(new Xn(Y.key,p,$,se))}if(l.length)if(Gn){if(Gn<70){var ue=l[0].flags;ue.dependsOn=2,ue.isNonSync=0}}else if(qn&&V-K0&&(n&&Math.abs(v-g)<9e3||Math.abs(Hn(p[0].pts-y,v)-g)<20*l),p.forEach((function(e){e.pts=Hn(e.pts-y,v)})),!r||g<0){if(!(p=p.filter((function(e){return e.pts>=0}))).length)return;g=0===i?0:n&&!h?Math.max(0,v):p[0].pts}if("aac"===e.segmentCodec)for(var b=this.config.maxAudioFramesDrift,E=0,S=g;E=b*l&&A<1e4&&h){var L=Math.round(k/l);(S=w-L*l)<0&&(L--,S+=l),0===E&&(this.nextAudioPts=g=S),C.warn("[mp4-remuxer]: Injecting "+L+" audio frame @ "+(S/a).toFixed(3)+"s due to "+Math.round(1e3*k/a)+" ms gap.");for(var x=0;x0))return;N+=m;try{D=new Uint8Array(N)}catch(e){return void this.observer.emit(R.ERROR,R.ERROR,{type:I.MUX_ERROR,details:_.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:N,reason:"fail allocating audio mdat "+N})}d||(new DataView(D.buffer).setUint32(0,N),D.set(Wn.types.mdat,4))}D.set(G,m);var K=G.byteLength;m+=K,f.push(new Xn(!0,u,K,0)),F=q}var H=f.length;if(H){var V=f[f.length-1];this.nextAudioPts=g=F+o*V.duration;var z=d?new Uint8Array(0):Wn.moof(e.sequenceNumber++,P/o,s({},e,{samples:f}));e.samples=[];var Y=P/a,X=g/a,$={data1:z,data2:D,startPTS:Y,endPTS:X,startDTS:Y,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:H};return this.isAudioContiguous=!0,$}},t.remuxEmptyAudio=function(e,t,r,n){var i=e.inputTimeScale,a=i/(e.samplerate?e.samplerate:i),o=this.nextAudioPts,s=this._initDTS,u=9e4*s.baseTime/s.timescale,l=(null!==o?o:n.startDTS*i)+u,c=n.endDTS*i+u,d=1024*a,f=Math.ceil((c-l)/d),h=Nn.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(C.warn("[mp4-remuxer]: remux empty Audio"),h){for(var p=[],m=0;m4294967296;)e+=r;return e}function Vn(e,t,r,n){var i=e.samples.length;if(i){for(var a=e.inputTimeScale,o=0;o0;i||(n=xe(t,["encv"])),n.forEach((function(e){xe(i?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=Oe(e);if(t){var n=t.subarray(8,24);n.some((function(e){return 0!==e}))||(C.log("[eme] Patching keyId in 'enc"+(i?"a":"v")+">sinf>>tenc' box: "+Se(n)+" -> "+Se(r)),t.set(r,8))}}))}))})),e}(e,n)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var n=this.initData=Me(e);t||(t=Qn(n.audio,U)),r||(r=Qn(n.video,W));var i={};n.audio&&n.video?i.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:n.audio?i.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:n.video?i.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:C.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i},t.remux=function(e,t,r,n,i,a){var o,s,u=this.initPTS,l=this.lastEndTime,c={audio:void 0,video:void 0,text:n,id3:r,initSegment:void 0};E(l)||(l=this.lastEndTime=i||0);var d=t.samples;if(null==d||!d.length)return c;var f={initPTS:void 0,timescale:1},h=this.initData;if(null!=(o=h)&&o.length||(this.generateInitSegment(d),h=this.initData),null==(s=h)||!s.length)return C.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);var p=function(e,t){for(var r=0,n=0,i=0,a=xe(e,["moof","traf"]),o=0;oi}(u,g,i,p)||f.timescale!==u.timescale&&a)&&(f.initPTS=g-i,u&&1===u.timescale&&C.warn("Adjusting initPTS by "+(f.initPTS-u.baseTime)),this.initPTS=u={baseTime:f.initPTS,timescale:1});var v=e?g-u.baseTime/u.timescale:l,y=v+p;!function(e,t,r){xe(t,["moof","traf"]).forEach((function(t){xe(t,["tfhd"]).forEach((function(n){var i=ke(n,4),a=e[i];if(a){var o=a.timescale||9e4;xe(t,["tfdt"]).forEach((function(e){var t=e[0],n=ke(e,4);if(0===t)n-=r*o,Le(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=ke(e,8),n-=r*o,n=Math.max(n,0);var i=Math.floor(n/(Te+1)),a=Math.floor(n%(Te+1));Le(e,4,i),Le(e,8,a)}}))}}))}))}(h,d,u.baseTime/u.timescale),p>0?this.lastEndTime=y:(C.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var b=!!h.audio,S=!!h.video,T="";b&&(T+="audio"),S&&(T+="video");var R={data1:d,startPTS:v,startDTS:v,endPTS:y,endDTS:y,type:T,hasAudio:b,hasVideo:S,nb:1,dropped:0};return c.audio="audio"===R.type?R:void 0,c.video="audio"!==R.type?R:void 0,c.initSegment=f,c.id3=Vn(r,i,u,u),n.samples.length&&(c.text=zn(n,i,u)),c},e}();function Qn(e,t){var r=null==e?void 0:e.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||t===W?"avc1.42e01e":"mp4a.40.5"}try{Yn=self.performance.now.bind(self.performance)}catch(e){C.debug("Unable to use Performance API on this environment"),Yn="undefined"!=typeof self&&self.Date.now}var Zn=[{demux:gn,remux:Jn},{demux:Ln,remux:Kn},{demux:pn,remux:Kn},{demux:Fn,remux:Kn}],ei=function(){function e(e,t,r,n,i){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=n,this.id=i}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,n){var i=this,a=r.transmuxing;a.executeStart=Yn();var o=new Uint8Array(e),s=this.currentTransmuxState,u=this.transmuxConfig;n&&(this.currentTransmuxState=n);var l=n||s,c=l.contiguous,d=l.discontinuity,f=l.trackSwitch,h=l.accurateTimeOffset,p=l.timeOffset,m=l.initSegmentChange,g=u.audioCodec,v=u.videoCodec,y=u.defaultInitPts,b=u.duration,E=u.initSegmentData,S=function(e,t){var r=null;return e.byteLength>0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(r=t),r}(o,t);if(S&&"AES-128"===S.method){var T=this.getDecrypter();if(!T.isSync())return this.decryptionPromise=T.webCryptoDecrypt(o,S.key.buffer,S.iv.buffer).then((function(e){var t=i.push(e,null,r);return i.decryptionPromise=null,t})),this.decryptionPromise;var w=T.softwareDecrypt(o,S.key.buffer,S.iv.buffer);if(r.part>-1&&(w=T.flush()),!w)return a.executeEnd=Yn(),ti(r);o=new Uint8Array(w)}var k=this.needsProbing(d,f);if(k){var A=this.configureTransmuxer(o);if(A)return C.warn("[transmuxer] "+A.message),this.observer.emit(R.ERROR,R.ERROR,{type:I.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,fatal:!1,error:A,reason:A.message}),a.executeEnd=Yn(),ti(r)}(d||f||m||k)&&this.resetInitSegment(E,g,v,b,t),(d||m||k)&&this.resetInitialTimestamp(y),c||this.resetContiguity();var L=this.transmux(o,S,p,h,r),x=this.currentTransmuxState;return x.contiguous=!0,x.discontinuity=!1,x.trackSwitch=!1,a.executeEnd=Yn(),L},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=Yn();var n=this.decrypter,i=this.currentTransmuxState,a=this.decryptionPromise;if(a)return a.then((function(){return t.flush(e)}));var o=[],s=i.timeOffset;if(n){var u=n.flush();u&&o.push(this.push(u,null,e))}var l=this.demuxer,c=this.remuxer;if(!l||!c)return r.executeEnd=Yn(),[ti(e)];var d=l.flush(s);return ri(d)?d.then((function(r){return t.flushRemux(o,r,e),o})):(this.flushRemux(o,d,e),o)},t.flushRemux=function(e,t,r){var n=t.audioTrack,i=t.videoTrack,a=t.id3Track,o=t.textTrack,s=this.currentTransmuxState,u=s.accurateTimeOffset,l=s.timeOffset;C.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var c=this.remuxer.remux(n,i,a,o,l,u,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Yn()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,n,i){var a=this.demuxer,o=this.remuxer;a&&o&&(a.resetInitSegment(e,t,r,n),o.resetInitSegment(e,t,r,i))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,n,i){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,n,i):this.transmuxUnencrypted(e,r,n,i)},t.transmuxUnencrypted=function(e,t,r,n){var i=this.demuxer.demux(e,t,!1,!this.config.progressive),a=i.audioTrack,o=i.videoTrack,s=i.id3Track,u=i.textTrack;return{remuxResult:this.remuxer.remux(a,o,s,u,t,r,!1,this.id),chunkMeta:n}},t.transmuxSampleAes=function(e,t,r,n,i){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,n,!1,a.id),chunkMeta:i}}))},t.configureTransmuxer=function(e){for(var t,r=this.config,n=this.observer,i=this.typeSupported,a=this.vendor,o=0,s=Zn.length;o1&&u.id===(null==g?void 0:g.stats.chunkCount),T=!y&&(1===b||0===b&&(1===E||S&&E<=0)),R=self.performance.now();(y||b||0===i.stats.parsing.start)&&(i.stats.parsing.start=R),!a||!E&&T||(a.stats.parsing.start=R);var I=!(g&&(null==(c=i.initSegment)?void 0:c.url)===(null==(d=g.initSegment)?void 0:d.url)),_=new ii(v,T,s,y,p,I);if(!T||v||I){C.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+"\n discontinuity: "+v+"\n trackSwitch: "+y+"\n contiguous: "+T+"\n accurateTimeOffset: "+s+"\n timeOffset: "+p+"\n initSegmentChange: "+I);var w=new ni(r,n,t,o,l);this.configureTransmuxer(w)}if(this.frag=i,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:m,chunkMeta:u,state:_},e instanceof ArrayBuffer?[e]:[]);else if(h){var k=h.push(e,m,u,_);ri(k)?(h.async=!0,k.then((function(e){f.handleTransmuxComplete(e)})).catch((function(e){f.transmuxerError(e,u,"transmuxer-interface push error")}))):(h.async=!1,this.handleTransmuxComplete(k))}},r.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var n=r.flush(e);ri(n)||r.async?(ri(n)||(n=Promise.resolve(n)),n.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")}))):this.handleFlushResult(n,e)}},r.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))},r.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},r.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":var n,i=null==(n=this.workerContext)?void 0:n.objectURL;i&&self.URL.revokeObjectURL(i);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":C[t.data.logType]&&C[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},r.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}(),fi=function(){function e(e,t,r,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=n}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var r=this.config,n=this.media,i=this.stalled;if(null!==n){var a=n.currentTime,o=n.seeking,s=this.seeking&&!o,u=!this.seeking&&o;if(this.seeking=o,a===e){if(u||s)this.stalled=null;else if(!(n.paused&&!o||n.ended||0===n.playbackRate)&&xr.getBuffered(n).length){var l=xr.bufferInfo(n,a,0),c=l.len>0,d=l.nextStart||0;if(c||d){if(o){var f=l.len>2,h=!d||t&&t.start<=a||d-a>2&&!this.fragmentTracker.getPartialFragment(a);if(f||h)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var p,m=Math.max(d,l.start||0)-a,g=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,v=(null==g||null==(p=g.details)?void 0:p.live)?2*g.details.targetduration:2,y=this.fragmentTracker.getPartialFragment(a);if(m>0&&(m<=v||y))return void this._trySkipBufferHole(y)}var b=self.performance.now();if(null!==i){var E=b-i;if(o||!(E>=250)||(this._reportStall(l),this.media)){var S=xr.bufferInfo(n,a,r.maxBufferHole);this._tryFixBufferStall(S,E)}}else this.stalled=b}}}else if(this.moved=!0,null!==i){if(this.stallReported){var T=self.performance.now()-i;C.warn("playback not stuck anymore @"+a+", after "+Math.round(T)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},t._tryFixBufferStall=function(e,t){var r=this.config,n=this.fragmentTracker,i=this.media;if(null!==i){var a=i.currentTime,o=n.getPartialFragment(a);if(o&&(this._trySkipBufferHole(o)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a1e3*r.highBufferWatchdogPeriod&&(C.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var n=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");C.warn(n.message),t.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}},t._trySkipBufferHole=function(e){var t=this.config,r=this.hls,n=this.media;if(null===n)return 0;var i=n.currentTime,a=xr.bufferInfo(n,i,0),o=i0&&a.len<1&&n.readyState<3,l=o-i;if(l>0&&(s||u)){if(l>t.maxBufferHole){var c=this.fragmentTracker,d=!1;if(0===i){var f=c.getAppendedFrag(0,gt);f&&o1?(n=0,this.bitrateTest=!0):n=r.nextAutoLevel),this.level=r.nextLoadLevel=n,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=qr,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=Gr},r.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case Zr:var e,t=this.levels,r=this.level,n=null==t||null==(e=t[r])?void 0:e.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=qr;break}if(this.hls.nextLoadLevel!==this.level){this.state=qr;break}break;case Vr:var i,a=self.performance.now(),o=this.retryDate;(!o||a>=o||null!=(i=this.media)&&i.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=qr)}this.state===qr&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,n=this.media,i=e.config,a=e.nextLoadLevel;if(null!==t&&(n||!this.startFragRequested&&i.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&null!=r&&r[a]){var o=r[a],s=this.getMainFwdBufferInfo();if(null!==s){var u=this.getLevelDetails();if(u&&this._streamEnded(s,u)){var l={};return this.altAudio&&(l.type="video"),this.hls.trigger(R.BUFFER_EOS,l),void(this.state=$r)}e.loadLevel!==a&&-1===e.manualLevel&&this.log("Adapting to level "+a+" from level "+this.level),this.level=e.nextLoadLevel=a;var c=o.details;if(!c||this.state===Zr||c.live&&this.levelLastLoaded!==a)return this.level=a,void(this.state=Zr);var d=s.len,f=this.getMaxBufferLength(o.maxBitrate);if(!(d>=f)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var h=this.backtrackFragment?this.backtrackFragment.start:s.end,p=this.getNextFragment(h,c);if(this.couldBacktrack&&!this.fragPrevious&&p&&"initSegment"!==p.sn&&this.fragmentTracker.getState(p)!==yr){var m,g=(null!=(m=this.backtrackFragment)?m:p).sn-c.startSN,v=c.fragments[g-1];v&&p.cc===v.cc&&(p=v,this.fragmentTracker.removeFragment(v))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,h)){if(!p.gap){var y=this.audioOnly&&!this.altAudio?U:W,b=(y===W?this.videoBuffer:this.mediaBuffer)||this.media;b&&this.afterBufferFlushed(b,y,gt)}p=this.getNextFragmentLoopLoading(p,c,s,gt,f)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,o,h))}}}},r.loadFragment=function(t,r,n){var i=this.fragmentTracker.getState(t);this.fragCurrent=t,i===mr||i===vr?"initSegment"===t.sn?this._loadInitSegment(t,r):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,n)):this.clearTrackerIfNeeded(t)},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,gt)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var i=this.getLevelDetails();if(null!=i&&i.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*i.targetduration)return}if(!t.paused&&e){var o=e[this.hls.nextLoadLevel],s=this.fragLastKbps;r=s&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*s)+1:0}else r=0;var u=this.getBufferedFrag(t.currentTime+r);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var c=l.maxStartPTS?l.maxStartPTS:l.start,d=l.duration,f=Math.max(u.end,c+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,.5*d),.75*d));this.flushMainBuffer(f,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Kr:case Hr:case Vr:case Yr:case Xr:this.state=qr}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},r.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var n=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new fi(this.config,n,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var t=this.media;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),e.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;E(t)&&this.log("Media seeked to "+t.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},r.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},r.onManifestParsed=function(e,t){var r,n,i,a=!1,o=!1;t.levels.forEach((function(e){(r=e.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(a=!0),-1!==r.indexOf("mp4a.40.5")&&(o=!0))})),this.audioCodecSwitch=a&&o&&!("function"==typeof(null==(i=tn())||null==(n=i.prototype)?void 0:n.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},r.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===qr){var n=r[t.level];(!n.details||n.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(n.details))&&(this.state=Zr)}},r.onLevelLoaded=function(e,t){var r,n=this.levels,i=t.level,a=t.details,o=a.totalduration;if(n){this.log("Level "+i+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+", cc ["+a.startCC+", "+a.endCC+"] duration:"+o);var s=n[i],u=this.fragCurrent;!u||this.state!==Hr&&this.state!==Vr||u.level===t.level&&u.urlId===s.urlId||!u.loader||this.abortCurrentFrag();var l=0;if(a.live||null!=(r=s.details)&&r.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;l=this.alignPlaylists(a,s.details)}if(s.details=a,this.levelLastLoaded=i,this.hls.trigger(R.LEVEL_UPDATED,{details:a,level:i}),this.state===Zr){if(this.waitForCdnTuneIn(a))return;this.state=qr}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,l),this.tick()}else this.warn("Levels were reset while loading level "+i)},r._handleFragmentLoadProgress=function(e){var t,r=e.frag,n=e.part,i=e.payload,a=this.levels;if(a){var o=a[r.level],s=o.details;if(!s)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var u=o.videoCodec,l=s.PTSKnown||!s.live,c=null==(t=r.initSegment)?void 0:t.data,d=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new di(this.hls,gt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),h=n?n.index:-1,p=-1!==h,m=new Cr(r.level,r.sn,r.stats.chunkCount,i.byteLength,h,p),g=this.initPTS[r.cc];f.push(i,c,d,u,r,n,s.totalduration,l,m,g)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(e,t){var r=this.altAudio;if(!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var i=this.hls;r&&(i.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(R.AUDIO_TRACK_SWITCHED,t)}},r.onAudioTrackSwitched=function(e,t){var r=t.id,n=!!this.hls.audioTracks[r].url;if(n){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=n,this.tick()},r.onBufferCreated=function(e,t){var r,n,i=t.tracks,a=!1;for(var o in i){var s=i[o];if("main"===s.id){if(n=o,r=s,"video"===o){var u=i[o];u&&(this.videoBuffer=u.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+n+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(e,t){var r=t.frag,n=t.part;if(!r||r.type===gt){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(n?" p: "+n.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Xr&&(this.state=qr));var i=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}},r.onError=function(e,t){var r;if(t.fatal)this.state=Jr;else switch(t.details){case _.FRAG_GAP:case _.FRAG_PARSING_ERROR:case _.FRAG_DECRYPT_ERROR:case _.FRAG_LOAD_ERROR:case _.FRAG_LOAD_TIMEOUT:case _.KEY_LOAD_ERROR:case _.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(gt,t);break;case _.LEVEL_LOAD_ERROR:case _.LEVEL_LOAD_TIMEOUT:case _.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Zr||(null==(r=t.context)?void 0:r.type)!==ht||(this.state=qr);break;case _.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case _.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}},r.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!xr.getBuffered(e).length){var r=this.state!==qr?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=qr,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(e,t){var r=t.type;if(r!==U||this.audioOnly&&!this.altAudio){var n=(r===W?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,r,gt)}},r.onLevelsUpdated=function(e,t){this.levels=t.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t0&&(ib.cc;if(!1!==i.independent){var I=c.startPTS,_=c.endPTS,w=c.startDTS,k=c.endDTS;if(u)u.elementaryStreams[c.type]={startPTS:I,endPTS:_,startDTS:w,endDTS:k};else if(c.firstKeyFrame&&c.independent&&1===a.id&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){var A=this.getMainFwdBufferInfo(),L=(A?A.end:this.getLoadPosition())+this.config.maxBufferHole,x=c.firstKeyFramePTS?c.firstKeyFramePTS:I;if(!S&&L1&&!1===e.seeking){var r=e.currentTime;if(xr.isBuffered(e,r)?t=this.getAppendedFrag(r):xr.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var n=this.fragPlaying,i=t.level;n&&t.sn===n.sn&&n.level===i&&t.urlId===n.urlId||(this.fragPlaying=t,this.hls.trigger(R.FRAG_CHANGED,{frag:t}),n&&n.level===i||this.hls.trigger(R.LEVEL_SWITCHED,{level:i}))}}},a(t,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,r=this.currentFrag;if(r&&E(t)&&E(r.programDateTime)){var n=r.programDateTime+1e3*(t-r.start);return new Date(n)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(en),pi=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),mi=function(){function e(e,t,r,n){void 0===n&&(n=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new pi(e),this.fast_=new pi(t),this.defaultTTFB_=n,this.ttfb_=new pi(e)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,n=this.fast_,i=this.ttfb_;r.halfLife!==e&&(this.slow_=new pi(e,r.getEstimate(),r.getTotalWeight())),n.halfLife!==t&&(this.fast_=new pi(t,n.getEstimate(),n.getTotalWeight())),i.halfLife!==e&&(this.ttfb_=new pi(e,i.getEstimate(),i.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/r;this.fast_.sample(r,n),this.slow_.sample(r,n)},t.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},e}(),gi=function(){function e(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var t=e.config;this.bwEstimator=new mi(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(R.FRAG_LOADING,this.onFragLoading,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.FRAG_BUFFERED,this.onFragBuffered,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.LEVEL_LOADED,this.onLevelLoaded,this)},t.unregisterListeners=function(){var e=this.hls;e.off(R.FRAG_LOADING,this.onFragLoading,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.FRAG_BUFFERED,this.onFragBuffered,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.LEVEL_LOADED,this.onLevelLoaded,this)},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},t.onFragLoading=function(e,t){var r,n=t.frag;this.ignoreFragment(n)||(this.fragCurrent=n,this.partCurrent=null!=(r=t.part)?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},t.onLevelSwitching=function(e,t){this.clearTimer()},t.getTimeToLoadFrag=function(e,t,r,n){return e+r/t+(n?this.lastLevelLoadSec:0)},t.onLevelLoaded=function(e,t){var r=this.hls.config,n=t.stats,i=n.total,a=n.bwEstimate;E(i)&&E(a)&&(this.lastLevelLoadSec=8*i/a),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},t._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,n=r.autoLevelEnabled,i=r.media;if(e&&i){var a=performance.now(),o=t?t.stats:e.stats,s=t?t.duration:e.duration,u=a-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(n&&!i.paused&&i.playbackRate&&i.readyState){var l=r.mainForwardBufferInfo;if(null!==l){var c=this.bwEstimator.getEstimateTTFB(),d=Math.abs(i.playbackRate);if(!(u<=Math.max(c,s/(2*d)*1e3))){var f=l.len/d;if(!(f>=2*s/d)){var h=o.loading.first?o.loading.first-o.loading.start:-1,p=o.loaded&&h>-1,m=this.bwEstimator.getEstimate(),g=r.levels,v=r.minAutoLevel,y=g[e.level],b=o.total||Math.max(o.loaded,Math.round(s*y.maxBitrate/8)),S=u-h;S<1&&p&&(S=Math.min(u,8*o.loaded/m));var T=p?1e3*o.loaded/S:0,I=T?(b-o.loaded)/T:8*b/m+c/1e3;if(!(I<=f)){var _,w=T?8*T:m,k=Number.POSITIVE_INFINITY;for(_=e.level-1;_>v;_--){var A=g[_].maxBitrate;if((k=this.getTimeToLoadFrag(c/1e3,w,s*A,!g[_].details))=I||k>10*s||(r.nextLoadLevel=_,p?this.bwEstimator.sample(u-Math.min(c,h),o.loaded):this.bwEstimator.sampleTTFB(u),this.clearTimer(),C.warn("[abr] Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" is loading too slowly;\n Time to underbuffer: "+f.toFixed(3)+" s\n Estimated load time for current fragment: "+I.toFixed(3)+" s\n Estimated load time for down switch fragment: "+k.toFixed(3)+" s\n TTFB estimate: "+h+"\n Current BW estimate: "+(E(m)?(m/1024).toFixed(3):"Unknown")+" Kb/s\n New BW estimate: "+(this.bwEstimator.getEstimate()/1024).toFixed(3)+" Kb/s\n Aborting and switching to level "+_),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}}}}}}},t.onFragLoaded=function(e,t){var r=t.frag,n=t.part,i=n?n.stats:r.stats;if(r.type===gt&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var a=n?n.duration:r.duration,o=this.hls.levels[r.level],s=(o.loaded?o.loaded.bytes:0)+i.loaded,u=(o.loaded?o.loaded.duration:0)+a;o.loaded={bytes:s,duration:u},o.realBitrate=Math.round(8*s/u)}if(r.bitrateTest){var l={stats:i,frag:r,part:n,id:r.type};this.onFragBuffered(R.FRAG_BUFFERED,l),r.bitrateTest=!1}}},t.onFragBuffered=function(e,t){var r=t.frag,n=t.part,i=null!=n&&n.stats.loaded?n.stats:r.stats;if(!i.aborted&&!this.ignoreFragment(r)){var a=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},t.ignoreFragment=function(e){return e.type!==gt||"initSegment"===e.sn},t.clearTimer=function(){self.clearInterval(this.timer)},t.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,n=r.maxAutoLevel,i=r.config,a=r.minAutoLevel,o=r.media,s=t?t.duration:e?e.duration:0,u=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,l=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,c=r.mainForwardBufferInfo,d=(c?c.len:0)/u,f=this.findBestLevel(l,a,n,d,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(f>=0)return f;C.trace("[abr] "+(d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var h=s?Math.min(s,i.maxStarvationDelay):i.maxStarvationDelay,p=i.abrBandWidthFactor,m=i.abrBandWidthUpFactor;if(!d){var g=this.bitrateTestDelay;g&&(h=(s?Math.min(s,i.maxLoadingDelay):i.maxLoadingDelay)-g,C.trace("[abr] bitrate test took "+Math.round(1e3*g)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*h)+" ms"),p=m=1)}return f=this.findBestLevel(l,a,n,d+h,p,m),Math.max(f,0)},t.findBestLevel=function(e,t,r,n,i,a){for(var o,s=this.fragCurrent,u=this.partCurrent,l=this.lastLoadedFragLevel,c=this.hls.levels,d=c[l],f=!(null==d||null==(o=d.details)||!o.live),h=null==d?void 0:d.codecSet,p=u?u.duration:s?s.duration:0,m=this.bwEstimator.getEstimateTTFB()/1e3,g=t,v=-1,y=r;y>=t;y--){var b=c[y];if(!b||h&&b.codecSet!==h)b&&(g=Math.min(y,g),v=Math.max(y,v));else{-1!==v&&C.trace("[abr] Skipped level(s) "+g+"-"+v+' with CODECS:"'+c[v].attrs.CODECS+'"; not compatible with "'+d.attrs.CODECS+'"');var S=b.details,T=(u?null==S?void 0:S.partTarget:null==S?void 0:S.averagetargetduration)||p,R=void 0;R=y<=l?i*e:a*e;var I=c[y].maxBitrate,_=this.getTimeToLoadFrag(m,R,I*T,void 0===S);if(C.trace("[abr] level:"+y+" adjustedbw-bitrate:"+Math.round(R-I)+" avgDuration:"+T.toFixed(1)+" maxFetchDuration:"+n.toFixed(1)+" fetchDuration:"+_.toFixed(1)),R>I&&(0===_||!E(_)||f&&!this.bitrateTestDelay||_Math.max(e,r)&&n[e].loadError<=n[r].loadError)return e}return-1!==e&&(r=Math.min(e,r)),r},set:function(e){this._nextAutoLevel=e}}]),e}(),vi=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),n=0,i=0;i0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=qr):(this.loadedmetadata=!1,this.state=zr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},r.doTick=function(){switch(this.state){case qr:this.doTickIdle();break;case zr:var t,r=this.levels,n=this.trackId,i=null==r||null==(t=r[n])?void 0:t.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=Qr}break;case Vr:var a,o=performance.now(),s=this.retryDate;(!s||o>=s||null!=(a=this.media)&&a.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=qr);break;case Qr:var u=this.waitingData;if(u){var l=u.frag,c=u.part,d=u.cache,f=u.complete;if(void 0!==this.initPTS[l.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=Hr;var h={frag:l,part:c,payload:d.flush(),networkDetails:null};this._handleFragmentLoadProgress(h),f&&e.prototype._handleFragmentLoadComplete.call(this,h)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+l.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var p=this.getLoadPosition(),m=xr.bufferInfo(this.mediaBuffer,p,this.config.maxBufferHole);tr(m.end,this.config.maxFragLookUpTolerance,l)<0&&(this.log("Waiting fragment cc ("+l.cc+") @ "+l.start+" cancelled because another fragment at "+m.end+" is needed"),this.clearWaitingFragment())}}else this.state=qr}this.onTickEnd()},r.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=qr)},r.resetLoadingState=function(){this.clearWaitingFragment(),e.prototype.resetLoadingState.call(this)},r.onTickEnd=function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)},r.doTickIdle=function(){var e=this.hls,t=this.levels,r=this.media,n=this.trackId,i=e.config;if(null!=t&&t[n]&&(r||!this.startFragRequested&&i.startFragPrefetch)){var a=t[n],o=a.details;if(!o||o.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(o))this.state=zr;else{var s=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&s&&(this.bufferFlushed=!1,this.afterBufferFlushed(s,U,vt));var u=this.getFwdBufferInfo(s,vt);if(null!==u){var l=this.bufferedTrack,c=this.switchingTrack;if(!c&&this._streamEnded(u,o))return e.trigger(R.BUFFER_EOS,{type:"audio"}),void(this.state=$r);var d=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,gt),f=u.len,h=this.getMaxBufferLength(null==d?void 0:d.len);if(!(f>=h)||c){var p=o.fragments[0].start,m=u.end;if(c&&r){var g=this.getLoadPosition();l&&c.attrs!==l.attrs&&(m=g),o.PTSKnown&&gp||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=p+.05)}var v=this.getNextFragment(m,o),y=!1;if(v&&this.isLoopLoading(v,m)&&(y=!!v.gap,v=this.getNextFragmentLoopLoading(v,o,u,gt,h)),v){var b=d&&v.start>d.end+o.targetduration;if(b||(null==d||!d.len)&&u.len){var E=this.getAppendedFrag(v.start,gt);if(null===E)return;if(y||(y=!!E.gap||!!b&&0===d.len),b&&!y||y&&u.nextStart&&u.nextStart=t.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=this.currentTrack;t[this.trackId];var i=t[e],a=i.groupId,o=i.name;if(this.log("Switching to audio-track "+e+' "'+o+'" lang:'+i.lang+" group:"+a),this.trackId=e,this.currentTrack=i,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,n({},i)),!i.details||i.details.live){var s=this.switchParams(i.url,null==r?void 0:r.details);this.loadPlaylist(s)}}},r.selectInitialTrack=function(){var e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==t)this.setAudioTrack(t);else{var r=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+e.length);this.warn(r.message),this.hls.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}},r.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r=i[s].start&&o<=i[s].end){a=i[s];break}var u=r.start+r.duration;a?a.end=u:(a={start:o,end:u},i.push(a)),this.fragmentTracker.fragBuffered(r)}}},r.onBufferFlushing=function(e,t){var r=t.startOffset,n=t.endOffset;if(0===r&&n!==Number.POSITIVE_INFINITY){var i=n-1;if(i<=0)return;t.endOffsetSubtitles=Math.max(0,i),this.tracksBuffered.forEach((function(e){for(var t=0;t=o.length||i!==a)&&s){this.mediaBuffer=this.mediaBufferTimeRanges;var u=0;if(n.live||null!=(r=s.details)&&r.live){var l=this.mainDetails;if(n.deltaUpdateFailed||!l)return;var c=l.fragments[0];s.details?0===(u=this.alignPlaylists(n,s.details))&&c&&Ht(n,u=c.start):n.hasProgramDateTime&&l.hasProgramDateTime?(Fr(n,l),u=n.fragments[0].start):c&&Ht(n,u=c.start)}s.details=n,this.levelLastLoaded=i,this.startFragRequested||!this.mainDetails&&n.live||this.setStartPosition(s.details,u),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===qr&&(er(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0))}}},r._handleFragmentLoadComplete=function(e){var t=this,r=e.frag,n=e.payload,i=r.decryptdata,a=this.hls;if(!this.fragContextChanged(r)&&n&&n.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){var o=performance.now();this.decrypter.decrypt(new Uint8Array(n),i.key.buffer,i.iv.buffer).catch((function(e){throw a.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();a.trigger(R.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:o,tdecrypt:t}})})).catch((function(e){t.warn(e.name+": "+e.message),t.state=qr}))}},r.doTick=function(){if(this.media){if(this.state===qr){var e=this.currentTrackId,t=this.levels,r=t[e];if(!t.length||!r||!r.details)return;var n=this.config,i=this.getLoadPosition(),a=xr.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,n.maxBufferHole),o=a.end,s=a.len,u=this.getFwdBufferInfo(this.media,gt),l=r.details;if(s>this.getMaxBufferLength(null==u?void 0:u.len)+l.levelTargetDuration)return;var c=l.fragments,d=c.length,f=l.edge,h=null,p=this.fragPrevious;if(of-m?0:m;!(h=er(p,c,Math.max(c[0].start,o),g))&&p&&p.start>>=0)>n-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+n+")");return e[r][t]};this.buffered={get length(){return e.length},end:function(r){return t("end",r,e.length)},start:function(r){return t("start",r,e.length)}}},Ii=function(e){function t(t){var r;return(r=e.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}u(t,e);var r=t.prototype;return r.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,e.prototype.destroy.call(this)},r.registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.ERROR,this.onError,this)},r.onMediaAttached=function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},r.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},r.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),_i(this.media.textTracks).forEach((function(e){It(e)})),this.subtitleTrack=-1,this.media=null)},r.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},r.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},r.onSubtitleTrackLoaded=function(e,t){var r=t.id,n=t.details,i=this.trackId,a=this.tracksInGroup[i];if(a){var o=a.details;a.details=t.details,this.log("subtitle track "+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),r===this.trackId&&this.playlistLoaded(r,t,o)}else this.warn("Invalid subtitle track id "+r)},r.onLevelLoading=function(e,t){this.switchLevel(t.level)},r.onLevelSwitching=function(e,t){this.switchLevel(t.level)},r.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.textGroupIds){var r=t.textGroupIds[t.urlId],n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){var i=this.tracks.filter((function(e){return!r||e.groupId===r}));this.tracksInGroup=i;var a=this.findTrackId(null==n?void 0:n.name)||this.findTrackId();this.groupId=r||null;var o={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(R.SUBTITLE_TRACKS_UPDATED,o),-1!==a&&this.setSubtitleTrack(a,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}},r.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r=n.length)){this.clearTimer();var i=n[e];if(this.log("Switching to subtitle-track "+e+(i?' "'+i.name+'" lang:'+i.lang+" group:"+i.groupId:"")),this.trackId=e,i){var a=i.id,o=i.groupId,s=void 0===o?"":o,u=i.name,l=i.type,c=i.url;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:a,groupId:s,name:u,type:l,url:c});var d=this.switchParams(i.url,null==t?void 0:t.details);this.loadPlaylist(d)}else this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:e})}}else this.queuedDefaultTrack=e},r.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=_i(this.media.textTracks),r=0;r-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}}]),t}(dr);function _i(e){for(var t=[],r=0;r "+e.src+")")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},t.registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.BUFFER_RESET,this.onBufferReset,this),e.on(R.BUFFER_APPENDING,this.onBufferAppending,this),e.on(R.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.BUFFER_EOS,this.onBufferEos,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(R.FRAG_PARSED,this.onFragParsed,this),e.on(R.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.BUFFER_RESET,this.onBufferReset,this),e.off(R.BUFFER_APPENDING,this.onBufferAppending,this),e.off(R.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.BUFFER_EOS,this.onBufferEos,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(R.FRAG_PARSED,this.onFragParsed,this),e.off(R.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new wi(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},t.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},t.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,C.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&ki){var n=this.mediaSource=new ki;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(n),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(C.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){C.warn("[buffer-controller]: onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):C.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(R.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){var r=e.sourceBuffer[t];try{r&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(r),e.sourceBuffer[t]=void 0)}catch(e){C.warn("[buffer-controller]: Failed to reset the "+t+" buffer",e)}})),this._initSourceBuffer()},t.onBufferCodecs=function(e,t){var r=this,n=this.getSourceBufferTypes().length;Object.keys(t).forEach((function(e){if(n){var i=r.tracks[e];if(i&&"function"==typeof i.buffer.changeType){var a=t[e],o=a.id,s=a.codec,u=a.levelCodec,l=a.container,c=a.metadata,d=(i.levelCodec||i.codec).replace(Ai,"$1"),f=(u||s).replace(Ai,"$1");if(d!==f){var h=l+";codecs="+(u||s);r.appendChangeType(e,h),C.log("[buffer-controller]: switching codec "+d+" to "+f),r.tracks[e]={buffer:i.buffer,codec:s,container:l,levelCodec:u,metadata:c,id:o}}}}else r.pendingTracks[e]=t[e]})),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},t.appendChangeType=function(e,t){var r=this,n=this.operationQueue,i={execute:function(){var i=r.sourceBuffer[e];i&&(C.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),i.changeType(t)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){C.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",t)}};n.append(i,e)},t.onBufferAppending=function(e,t){var r=this,n=this.hls,i=this.operationQueue,a=this.tracks,o=t.data,s=t.type,u=t.frag,l=t.part,c=t.chunkMeta,d=c.buffering[s],f=self.performance.now();d.start=f;var h=u.stats.buffering,p=l?l.stats.buffering:null;0===h.start&&(h.start=f),p&&0===p.start&&(p.start=f);var m=a.audio,g=!1;"audio"===s&&"audio/mpeg"===(null==m?void 0:m.container)&&(g=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var v=u.start,y={execute:function(){if(d.executeStart=self.performance.now(),g){var e=r.sourceBuffer[s];if(e){var t=v-e.timestampOffset;Math.abs(t)>=.1&&(C.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+v+" (delta: "+t+") sn: "+u.sn+")"),e.timestampOffset=v)}}r.appendExecutor(o,s)},onStart:function(){},onComplete:function(){var e=self.performance.now();d.executeEnd=d.end=e,0===h.first&&(h.first=e),p&&0===p.first&&(p.first=e);var t=r.sourceBuffer,n={};for(var i in t)n[i]=xr.getBuffered(t[i]);r.appendError=0,r.hls.trigger(R.BUFFER_APPENDED,{type:s,frag:u,part:l,chunkMeta:c,parent:u.type,timeRanges:n})},onError:function(e){C.error("[buffer-controller]: Error encountered while trying to append to the "+s+" SourceBuffer",e);var t={type:I.MEDIA_ERROR,parent:u.type,details:_.BUFFER_APPEND_ERROR,frag:u,part:l,chunkMeta:c,error:e,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=_.BUFFER_FULL_ERROR:(r.appendError++,t.details=_.BUFFER_APPEND_ERROR,r.appendError>n.config.appendErrorMaxRetry&&(C.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0)),n.trigger(R.ERROR,t)}};i.append(y,s)},t.onBufferFlushing=function(e,t){var r=this,n=this.operationQueue,i=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(R.BUFFER_FLUSHED,{type:e})},onError:function(t){C.warn("[buffer-controller]: Failed to remove from "+e+" SourceBuffer",t)}}};t.type?n.append(i(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){n.append(i(e),e)}))},t.onFragParsed=function(e,t){var r=this,n=t.frag,i=t.part,a=[],o=i?i.elementaryStreams:n.elementaryStreams;o[j]?a.push("audiovideo"):(o[U]&&a.push("audio"),o[W]&&a.push("video")),0===a.length&&C.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers((function(){var e=self.performance.now();n.stats.buffering.end=e,i&&(i.stats.buffering.end=e);var t=i?i.stats:n.stats;r.hls.trigger(R.FRAG_BUFFERED,{frag:n,part:i,stats:t,id:n.type})}),a)},t.onFragChanged=function(e,t){this.flushBackBuffer()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,n){var i=r.sourceBuffer[n];return!i||t.type&&t.type!==n||(i.ending=!0,i.ended||(i.ended=!0,C.log("[buffer-controller]: "+n+" sourceBuffer now EOS"))),e&&!(i&&!i.ended)}),!0)&&(C.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(e){var t=r.sourceBuffer[e];t&&(t.ending=!1)}));var e=r.mediaSource;e&&"open"===e.readyState?(C.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&C.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)})))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,n=this.sourceBuffer;if(r&&null!==t){var i=this.getSourceBufferTypes();if(i.length){var a=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if(E(a)&&!(a<0)){var o=r.currentTime,s=t.levelTargetDuration,u=Math.max(a,s),l=Math.floor(o/s)*s-u;i.forEach((function(r){var i=n[r];if(i){var a=xr.getBuffered(i);if(a.length>0&&l>a.start(0)){if(e.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:l}),t.live)e.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:l});else if(i.ended&&a.end(a.length-1)-o<2*s)return void C.info("[buffer-controller]: Cannot flush "+r+" back buffer while SourceBuffer is in ended state");e.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:l,type:r})}}}))}}}},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,n=this.mediaSource,i=e.fragments[0].start+e.totalduration,a=r.duration,o=E(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(C.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(i>o&&i>a||!E(a))&&(C.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),n.duration=i)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var n=Math.max(0,r[0].start),i=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,i)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,n=Object.keys(r).length;if(n&&!e||2===n){this.createSourceBuffers(r),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),i.forEach((function(e){t.executeNext(e)}));else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},t.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var n in e)if(!t[n]){var i=e[n];if(!i)throw Error("source buffer exists for track "+n+", however track does not");var a=i.levelCodec||i.codec,o=i.container+";codecs="+a;C.log("[buffer-controller]: creating sourceBuffer("+o+")");try{var s=t[n]=r.addSourceBuffer(o),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.tracks[n]={buffer:s,codec:a,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id}}catch(e){C.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:o})}}},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},t._onSBUpdateError=function(e,t){var r=new Error(e+" SourceBuffer error");C.error("[buffer-controller]: "+r,t),this.hls.trigger(R.ERROR,{type:I.MEDIA_ERROR,details:_.BUFFER_APPENDING_ERROR,error:r,fatal:!1});var n=this.operationQueue.current(e);n&&n.onError(t)},t.removeExecutor=function(e,t,r){var n=this.media,i=this.mediaSource,a=this.operationQueue,o=this.sourceBuffer[e];if(!n||!i||!o)return C.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(e);var s=E(n.duration)?n.duration:1/0,u=E(i.duration)?i.duration:1/0,l=Math.max(0,t),c=Math.min(r,s,u);c>l&&!o.ending?(o.ended=!1,C.log("[buffer-controller]: Removing ["+l+","+c+"] from the "+e+" SourceBuffer"),o.remove(l,c)):a.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.operationQueue,n=this.sourceBuffer[t];if(!n)return C.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);n.ended=!1,n.appendBuffer(e)},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return C.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var n=this.operationQueue,i=t.map((function(e){return n.appendBlocker(e)}));Promise.all(i).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];null!=t&&t.updating||n.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var n=this.sourceBuffer[e];if(n){var i=r.bind(this,e);this.listeners[e].push({event:t,listener:i}),n.addEventListener(t,i)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},e}(),xi={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},Ci=function(e){var t=e;return xi.hasOwnProperty(e)&&(t=xi[e]),String.fromCharCode(t)},Mi={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Oi={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Di={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Pi={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Fi=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Ni=function(){function e(){this.time=null,this.verboseLevel=0}return e.prototype.log=function(e,t){if(this.verboseLevel>=e){var r="function"==typeof t?t():t;C.log(this.time+" ["+e+"] "+r)}},e}(),Ui=function(e){for(var t=[],r=0;r100&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=100)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r=144&&this.backSpace();var r=Ci(e);this.pos>=100?this.logger.log(0,(function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"})):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<100;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,r=0;r<100;r++){var n=this.chars[r].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},e}(),Gi=function(){function e(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<15;t++)this.rows.push(new Bi(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<15;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,r=0;r<15;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<15;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<15;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(2,(function(){return"pacData = "+JSON.stringify(e)}));var t=e.row-1;if(this.nrRollUpRows&&t0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},t.getTextAndFormat=function(){return this.rows},e}(),qi=function(){function e(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Gi(r),this.nonDisplayedMemory=new Gi(r),this.lastOutputScreen=new Gi(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(function(){return"MODE="+e})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=this,r=0;r=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}(),Ki=function(){function e(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new Ni;this.channels=[null,new qi(e,t,n),new qi(e+1,r,n)],this.cmdHistory={a:null,b:null},this.logger=n}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,n,i,a=!1;this.logger.time=e;for(var o=0;o ("+Ui([n,i])+")"),(r=this.parseCmd(n,i))||(r=this.parseMidrow(n,i)),r||(r=this.parsePAC(n,i)),r||(r=this.parseBackgroundAttributes(n,i)),!r&&(a=this.parseChars(n,i))){var s=this.currentChannel;s&&s>0?this.channels[s].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||a||this.logger.log(2,"Couldn't parse cleaned data "+Ui([n,i])+" orig: "+Ui([t[o],t[o+1]]))}},t.parseCmd=function(e,t){var r=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(Vi(e,t,r))return Hi(null,null,r),this.logger.log(3,"Repeated command ("+Ui([e,t])+") is dropped"),!0;var n=20===e||21===e||23===e?1:2,i=this.channels[n];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),Hi(e,t,r),this.currentChannel=n,!0},t.parseMidrow=function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var n=this.channels[r];return!!n&&(n.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Ui([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var r,n=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(Vi(e,t,n))return Hi(null,null,n),!0;var i=e<=23?1:2;r=t>=64&&t<=95?1===i?Mi[e]:Di[e]:1===i?Oi[e]:Pi[e];var a=this.channels[i];return!!a&&(a.setPAC(this.interpretPAC(r,t)),Hi(e,t,n),this.currentChannel=i,!0)},t.interpretPAC=function(e,t){var r,n={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,n.underline=1==(1&r),r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((r-16)/2),n},t.parseChars=function(e,t){var r,n,i=null,a=null;if(e>=25?(r=2,a=e-8):(r=1,a=e),a>=17&&a<=19?(n=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,"Special char '"+Ci(n)+"' in channel "+r),i=[n]):e>=32&&e<=127&&(i=0===t?[e]:[e,t]),i){var o=Ui(i);this.logger.log(3,"Char codes = "+o.join(",")),Hi(e,t,this.cmdHistory)}return i},t.parseBackgroundAttributes=function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(r=Math.floor((t-32)/2),n.background=Fi[r],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var i=e<=23?1:2;return this.channels[i].setBkgData(n),Hi(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;ee)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[],this.startTime=null},e}(),Yi=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var r=t.toLowerCase();return!!~e.indexOf(r)&&r}function n(e){return r(t,e)}function i(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",i({},u,{get:function(){return E},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",i({},u,{get:function(){return S},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");S=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",i({},u,{get:function(){return T},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");T=t,this.hasBeenReset=!0}})),s.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Xi=function(){function e(){}return e.prototype.decode=function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},e}();function $i(e){function t(e,t,r,n){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(n||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var Ji=function(){function e(){this.values=Object.create(null)}var t=e.prototype;return t.set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,r){for(var n=0;n=0&&r<=100)return this.set(e,r),!0}return!1},e}();function Qi(e,t,r,n){var i=n?e.split(n):[e];for(var a in i)if("string"==typeof i[a]){var o=i[a].split(r);2===o.length&&t(o[0],o[1])}}var Zi=new Yi(0,0,""),ea="middle"===Zi.align?"middle":"center";function ta(e,t,r){var n=e;function i(){var t=$i(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=i(),a(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=e.slice(3),a(),t.endTime=i(),a(),function(e,t){var n=new Ji;Qi(e,(function(e,t){var i;switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){n.set(e,r[a].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":i=t.split(","),n.integer(e,i[0]),n.percent(e,i[0])&&n.set("snapToLines",!1),n.alt(e,i[0],["auto"]),2===i.length&&n.alt("lineAlign",i[1],["start",ea,"end"]);break;case"position":i=t.split(","),n.percent(e,i[0]),2===i.length&&n.alt("positionAlign",i[1],["start",ea,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",ea,"end","left","right"])}}),/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var i=n.get("line","auto");"auto"===i&&-1===Zi.line&&(i=-1),t.line=i,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",ea);var a=n.get("position","auto");"auto"===a&&50===Zi.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function ra(e){return e.replace(//gi,"\n")}var na=function(){function e(){this.state="INITIAL",this.buffer="",this.decoder=new Xi,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var t=e.prototype;return t.parse=function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=ra(e);r>>0).toString()};function sa(e,t,r){return oa(e.toString())+oa(t.toString())+oa(r)}function ua(e,t,r,n,i,a,o){var s,u,l,c=new na,d=be(new Uint8Array(e)).trim().replace(ia,"\n").split("\n"),f=[],h=t?(s=t.baseTime,void 0===(u=t.timescale)&&(u=1),jn(s,9e4,1/u)):0,p="00:00.000",m=0,g=0,v=!0;c.oncue=function(e){var a=r[n],o=r.ccOffset,s=(m-h)/9e4;if(null!=a&&a.new&&(void 0!==g?o=r.ccOffset=a.start:function(e,t,r){var n=e[t],i=e[n.prevCC];if(!i||!i.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!=(a=i)&&a.new;){var a;e.ccOffset+=n.start-i.start,n.new=!1,i=e[(n=i).prevCC]}e.presentationOffset=r}(r,n,s)),s){if(!t)return void(l=new Error("Missing initPTS for VTT MPEGTS"));o=s-r.presentationOffset}var u=e.endTime-e.startTime,c=Hn(9e4*(e.startTime+o-g),9e4*i)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+u,0);var d=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(d)),e.id||(e.id=sa(e.startTime,e.endTime,d)),e.endTime>0&&f.push(e)},c.onparsingerror=function(e){l=e},c.onflush=function(){l?o(l):a(f)},d.forEach((function(e){if(v){if(aa(e,"X-TIMESTAMP-MAP=")){v=!1,e.slice(16).split(",").forEach((function(e){aa(e,"LOCAL:")?p=e.slice(6):aa(e,"MPEGTS:")&&(m=parseInt(e.slice(7)))}));try{g=function(e){var t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),i=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(E(t)&&E(r)&&E(n)&&E(i)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,t+=6e4*n,t+=36e5*i}(p)/1e3}catch(e){l=e}return}""===e&&(v=!1)}c.parse(e+"\n")})),c.flush()}var la=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ca=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,da={left:"start",center:"center",right:"end",start:"start",end:"end"};function fa(e,t,r,n){var i=xe(new Uint8Array(e),["mdat"]);if(0!==i.length){var a,o,u,l,c=i.map((function(e){return be(e)})),d=(a=t.baseTime,o=1,void 0===(u=t.timescale)&&(u=1),void 0===l&&(l=!1),jn(a,o,1/u,l));try{c.forEach((function(e){return r(function(e,t){var r=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},i=Object.keys(n).reduce((function(e,t){return e[t]=r.getAttribute("ttp:"+t)||n[t],e}),{}),a="preserve"!==r.getAttribute("xml:space"),o=pa(ha(r,"styling","style")),u=pa(ha(r,"layout","region")),l=ha(r,"body","[begin]");return[].map.call(l,(function(e){var r=function e(t,r){return[].slice.call(t.childNodes).reduce((function(t,n,i){var a;return"br"===n.nodeName&&i?t+"\n":null!=(a=n.childNodes)&&a.length?e(n,r):r?t+n.textContent.trim().replace(/\s+/g," "):t+n.textContent}),"")}(e,a);if(!r||!e.hasAttribute("begin"))return null;var n=va(e.getAttribute("begin"),i),l=va(e.getAttribute("dur"),i),c=va(e.getAttribute("end"),i);if(null===n)throw ga(e);if(null===c){if(null===l)throw ga(e);c=n+l}var d=new Yi(n-t,c-t,r);d.id=sa(d.startTime,d.endTime,d.text);var f=function(e,t,r){var n="http://www.w3.org/ns/ttml#styling",i=null,a=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return a&&r.hasOwnProperty(a)&&(i=r[a]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(r,a){var o=ma(t,n,a)||ma(e,n,a)||ma(i,n,a);return o&&(r[a]=o),r}),{})}(u[e.getAttribute("region")],o[e.getAttribute("style")],o),h=f.textAlign;if(h){var p=da[h];p&&(d.lineAlign=p),d.align=h}return s(d,f),d})).filter((function(e){return null!==e}))}(e,d))}))}catch(e){n(e)}}else n(new Error("Could not parse IMSC1 mdat"))}function ha(e,t,r){var n=e.getElementsByTagName(t)[0];return n?[].slice.call(n.querySelectorAll(r)):[]}function pa(e){return e.reduce((function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function ma(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function ga(e){return new Error("Could not parse ttml timestamp "+e)}function va(e,t){if(!e)return null;var r=$i(e);return null===r&&(la.test(e)?r=function(e,t){var r=la.exec(e),n=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+n/t.frameRate}(e,t):ca.test(e)&&(r=function(e,t){var r=ca.exec(e),n=Number(r[1]);switch(r[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}(e,t))),r}var ya=function(){function e(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new zi(this,"textTrack1"),r=new zi(this,"textTrack2"),n=new zi(this,"textTrack3"),i=new zi(this,"textTrack4");this.cea608Parser1=new Ki(1,t,r),this.cea608Parser2=new Ki(3,n,i)}e.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(R.FRAG_LOADING,this.onFragLoading,this),e.on(R.FRAG_LOADED,this.onFragLoaded,this),e.on(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(R.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=e.prototype;return t.destroy=function(){var e=this.hls;e.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(R.FRAG_LOADING,this.onFragLoading,this),e.off(R.FRAG_LOADED,this.onFragLoaded,this),e.off(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(R.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},t.addCues=function(e,t,r,n,i){for(var a,o,s,u,l=!1,c=i.length;c--;){var d=i[c],f=(a=d[0],o=d[1],s=t,u=r,Math.min(o,u)-Math.max(a,s));if(f>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],r),l=!0,f/(r-t)>.5))return}if(l||i.push([t,r]),this.config.renderTextTracksNatively){var h=this.captionsTracks[e];this.Cues.newCue(h,t,r,n)}else{var p=this.Cues.newCue(null,t,r,n);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:p,track:e})}},t.onInitPtsFound=function(e,t){var r=this,n=t.frag,i=t.id,a=t.initPTS,o=t.timescale,s=this.unparsedVttFrags;"main"===i&&(this.initPTS[n.cc]={baseTime:a,timescale:o}),s.length&&(this.unparsedVttFrags=[],s.forEach((function(e){r.onFragLoaded(R.FRAG_LOADED,e)})))},t.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;rn.cc||u.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:t})}))}else o.push(e)},t._fallbackToIMSC1=function(e,t){var r=this,n=this.tracks[e.level];n.textCodec||fa(t,this.initPTS[e.cc],(function(){n.textCodec="stpp.ttml.im1t",r._parseIMSC1(e,t)}),(function(){n.textCodec="wvtt"}))},t._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||"disabled"===n.mode)return;e.forEach((function(e){return Rt(n,e)}))}else{var i=this.tracks[t];if(!i)return;var a=i.default?"default":"subtitles"+t;r.trigger(R.CUES_PARSED,{type:"subtitles",cues:e,track:a})}},t.onFragDecrypted=function(e,t){t.frag.type===yt&&this.onFragLoaded(R.FRAG_LOADED,t)},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&r&&n){var i=t.frag,a=t.samples;if(i.type!==gt||"NONE"!==this.closedCaptionsForLevel(i))for(var o=0;o0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},t.getMaxLevel=function(t){var r=this,n=this.hls.levels;if(!n.length)return-1;var i=n.filter((function(e,n){return r.isLevelAllowed(e)&&n<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))},e.getMaxLevelByMediaSize=function(e,t,r){if(null==e||!e.length)return-1;for(var n,i,a=e.length-1,o=0;o=t||s.height>=r)&&(n=s,!(i=e[o+1])||n.width!==i.width||n.height!==i.height)){a=o;break}}return a},a(e,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}]),e}(),Sa=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var n=performance.now();if(t){if(this.lastTime){var i=n-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,s=1e3*a/i,u=this.hls;if(u.trigger(R.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),s>0&&a>u.config.fpsDroppedMonitoringThreshold*o){var l=u.currentLevel;C.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),Ta=function(){function e(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=e.CDMCleanupPromise?[e.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=C.debug.bind(C,"[eme]"),this.log=C.log.bind(C,"[eme]"),this.warn=C.warn.bind(C,"[eme]"),this.error=C.error.bind(C,"[eme]"),this.hls=t,this.config=t.config,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},t.registerListeners=function(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)},t.unregisterListeners=function(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this)},t.getLicenseServerUrl=function(e){var t=this.config,r=t.drmSystems,n=t.widevineLicenseUrl,i=r[e];if(i)return i.licenseUrl;if(e===Y.WIDEVINE&&n)return n;throw new Error('no license server URL configured for key-system "'+e+'"')},t.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},t.attemptKeySystemAccess=function(e){var t=this,r=this.hls.levels,n=function(e,t,r){return!!e&&r.indexOf(e)===t},i=r.map((function(e){return e.audioCodec})).filter(n),a=r.map((function(e){return e.videoCodec})).filter(n);return i.length+a.length===0&&a.push("avc1.42e01e"),new Promise((function(r,n){!function e(o){var s=o.shift();t.getMediaKeysPromise(s,i,a).then((function(e){return r({keySystem:s,mediaKeys:e})})).catch((function(t){o.length?e(o):n(t instanceof Ra?t:new Ra({type:I.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))}(e)}))},t.requestMediaKeySystemAccess=function(e,t){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var n="Configured requestMediaKeySystemAccess is not a function "+r;return null===ne&&"http:"===self.location.protocol&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(n))}return r(e,t)},t.getMediaKeysPromise=function(e,t,r){var n=this,i=function(e,t,r,n){var i;switch(e){case Y.FAIRPLAY:i=["cenc","sinf"];break;case Y.WIDEVINE:case Y.PLAYREADY:i=["cenc"];break;case Y.CLEARKEY:i=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+e)}return function(e,t,r,n){return[{initDataTypes:e,persistentState:n.persistentState||"not-allowed",distinctiveIdentifier:n.distinctiveIdentifier||"not-allowed",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:t.map((function(e){return{contentType:'audio/mp4; codecs="'+e+'"',robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null}})),videoCapabilities:r.map((function(e){return{contentType:'video/mp4; codecs="'+e+'"',robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}}))}]}(i,t,r,n)}(e,t,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e],o=null==a?void 0:a.keySystemAccess;if(!o){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(i)),o=this.requestMediaKeySystemAccess(e,i);var s=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch((function(t){n.log('Failed to obtain access to key-system "'+e+'": '+t)})),o.then((function(t){n.log('Access for key-system "'+t.keySystem+'" obtained');var r=n.fetchServerCertificate(e);return n.log('Create media-keys for "'+e+'"'),s.mediaKeys=t.createMediaKeys().then((function(t){return n.log('Media-keys created for "'+e+'"'),r.then((function(r){return r?n.setMediaKeysServerCertificate(t,e,r):t}))})),s.mediaKeys.catch((function(t){n.error('Failed to create media-keys for "'+e+'"}: '+t)})),s.mediaKeys}))}return o.then((function(){return a.mediaKeys}))},t.createMediaKeySessionContext=function(e){var t=e.decryptdata,r=e.keySystem,n=e.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+Se(t.keyId||[]));var i=n.createSession(),a={decryptdata:t,keySystem:r,mediaKeys:n,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a},t.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},t.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return Se(e.keyId)},t.updateKeySession=function(e,t){var r,n=e.mediaKeysSession;return this.log('Updating key-session "'+n.sessionId+'" for keyID '+Se((null==(r=e.decryptdata)?void 0:r.keyId)||[])+"\n } (data length: "+(t?t.byteLength:t)+")"),n.update(t)},t.selectKeySystemFormat=function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+e.sn+" "+e.type+": "+e.level+") key formats "+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise},t.getKeyFormatPromise=function(e){var t=this;return new Promise((function(r,n){var i=re(t.config),a=e.map(Z).filter((function(e){return!!e&&-1!==i.indexOf(e)}));return t.getKeySystemSelectionPromise(a).then((function(e){var t=e.keySystem,i=te(t);i?r(i):n(new Error('Unable to find format for key-system "'+t+'"'))})).catch(n)}))},t.loadKey=function(e){var t=this,r=e.keyInfo.decryptdata,n=this.getKeyIdString(r),i="(keyId: "+n+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+i);var a=this.keyIdToKeySessionPromise[n];return a||(a=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(r).then((function(n){var a=n.keySystem,o=n.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+i),t.attemptSetMediaKeys(a,o).then((function(){t.throwIfDestroyed();var e=t.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:r});return t.generateRequestWithPreferredKeySession(e,"cenc",r.pssh,"playlist-key")}))}))).catch((function(e){return t.handleError(e)})),a},t.throwIfDestroyed=function(e){if(!this.hls)throw new Error("invalid state")},t.handleError=function(e){this.hls&&(this.error(e.message),e instanceof Ra?this.hls.trigger(R.ERROR,e.data):this.hls.trigger(R.ERROR,{type:I.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},t.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){var n=Z(e.keyFormat),i=n?[n]:re(this.config);return this.attemptKeySystemAccess(i)}return r},t.getKeySystemSelectionPromise=function(e){if(e.length||(e=re(this.config)),0===e.length)throw new Ra({type:I.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},t._onMediaEncrypted=function(e){var t=this,r=e.initDataType,n=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+r+'"'),null!==n){var i,a;if("sinf"===r&&this.config.drmSystems[Y.FAIRPLAY]){var o=_e(new Uint8Array(n));try{var s=H(JSON.parse(o).sinf),u=Oe(new Uint8Array(s));if(!u)return;i=u.subarray(8,24),a=Y.FAIRPLAY}catch(e){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var l=function(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;var t={version:0,systemId:"",kids:null,data:null},r=new DataView(e),n=r.getUint32(0);if(e.byteLength!==n&&n>44)return null;if(1886614376!==r.getUint32(4))return null;if(t.version=r.getUint32(8)>>>24,t.version>1)return null;t.systemId=Se(new Uint8Array(e,12,16));var i=r.getUint32(28);if(0===t.version){if(n-32d||s.status>=400&&s.status<500)a(new Ra({type:I.KEY_SYSTEM_ERROR,details:_.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:s,response:{url:o,data:void 0,code:s.status,text:s.statusText}},"License Request XHR failed ("+o+"). Status: "+s.status+" ("+s.statusText+")"));else{var f=d-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+f+" attempts left"),r.requestLicense(e,t).then(i,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=s,r.setupLicenseXHR(s,o,e,t).then((function(e){var t=e.xhr,r=e.licenseChallenge;t.send(r)}))}))},t.onMediaAttached=function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},t.onMediaDetached=function(){var t=this,r=this.media,n=this.mediaKeySessions;r&&(r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Ge.clearKeyUriToKeyIdMap();var i=n.length;e.CDMCleanupPromise=Promise.all(n.map((function(e){return t.removeSession(e)})).concat(null==r?void 0:r.setMediaKeys(null).catch((function(e){t.log("Could not clear media keys: "+e+". media.src: "+(null==r?void 0:r.src))})))).then((function(){i&&(t.log("finished closing key sessions and clearing media keys"),n.length=0)})).catch((function(e){t.log("Could not close sessions and clear media keys: "+e+". media.src: "+(null==r?void 0:r.src))}))},t.onManifestLoading=function(){this.keyFormatPromise=null},t.onManifestLoaded=function(e,t){var r=t.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var n=r.reduce((function(e,t){return-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys "+n.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(n)}},t.removeSession=function(e){var t=this,r=e.mediaKeysSession,n=e.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var i=this.mediaKeySessions.indexOf(e);return i>-1&&this.mediaKeySessions.splice(i,1),r.remove().catch((function(e){t.log("Could not remove session: "+e)})).then((function(){return r.close()})).catch((function(e){t.log("Could not close session: "+e)}))}},e}();Ta.CDMCleanupPromise=void 0;var Ra=function(e){function t(t,r){var n;return(n=e.call(this,r)||this).data=void 0,t.error||(t.error=new Error(r)),n.data=t,t.err=t.error,n}return u(t,e),t}(h(Error)),Ia="m",_a="a",wa="v",ka="av",Aa="i",La="tt",xa=function(){function e(t){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(e){try{r.apply(e,{ot:Ia,su:!r.initialized})}catch(e){C.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var t=e.frag,n=r.hls.levels[t.level],i=r.getObjectType(t),a={d:1e3*t.duration,ot:i};i!==wa&&i!==_a&&i!=ka||(a.br=n.bitrate/1e3,a.tb=r.getTopBandwidth(i)/1e3,a.bl=r.getBufferLength(i)),r.apply(e,a)}catch(e){C.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var n=this.config=t.config,i=n.cmcd;null!=i&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.uuid(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.registerListeners())}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.MEDIA_DETACHED,this.onMediaDetached,this),e.on(R.BUFFER_CREATED,this.onBufferCreated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.MEDIA_DETACHED,this.onMediaDetached,this),e.off(R.BUFFER_CREATED,this.onBufferCreated,this)},t.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},t.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},t.onBufferCreated=function(e,t){var r,n;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(n=t.tracks.video)?void 0:n.buffer},t.createData=function(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},t.apply=function(t,r){void 0===r&&(r={}),s(r,this.createData());var n=r.ot===Aa||r.ot===wa||r.ot===ka;if(this.starved&&n&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering),this.useHeaders){var i=e.toHeaders(r);if(!Object.keys(i).length)return;t.headers||(t.headers={}),s(t.headers,i)}else{var a=e.toQuery(r);if(!a)return;t.url=e.appendQueryToUri(t.url,a)}},t.getObjectType=function(e){var t=e.type;return"subtitle"===t?La:"initSegment"===e.sn?Aa:"audio"===t?_a:"main"===t?this.hls.audioTracks.length?wa:ka:void 0},t.getTopBandwidth=function(e){var t,r=0,n=this.hls;if(e===_a)t=n.audioTracks;else{var i=n.maxAutoLevel,a=i>-1?i+1:n.levels.length;t=n.levels.slice(0,a)}for(var o,s=m(t);!(o=s()).done;){var u=o.value;u.bitrate>r&&(r=u.bitrate)}return r>0?r:NaN},t.getBufferLength=function(e){var t=this.hls.media,r=e===_a?this.audioBuffer:this.videoBuffer;return r&&t?1e3*xr.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},t.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var n=e.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(e,r,n){t(e),this.loader.load(e,r,n)},a(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},t.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var n=e.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(e,r,n){t(e),this.loader.load(e,r,n)},a(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},e.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},e.serialize=function(e){for(var t,r=[],n=function(e){return!Number.isNaN(e)&&null!=e&&""!==e&&!1!==e},i=function(e){return Math.round(e)},a=function(e){return 100*i(e/100)},o={br:i,d:i,bl:a,dl:a,mtp:a,nor:function(e){return encodeURIComponent(e)},rtp:a,tb:i},s=m(Object.keys(e||{}).sort());!(t=s()).done;){var u=t.value,l=e[u];if(n(l)&&!("v"===u&&1===l||"pr"==u&&1===l)){var c=o[u];c&&(l=c(l));var d=typeof l,f=void 0;f="ot"===u||"sf"===u||"st"===u?u+"="+l:"boolean"===d?u:"number"===d?u+"="+l:u+"="+JSON.stringify(l),r.push(f)}}return r.join(",")},e.toHeaders=function(t){for(var r={},n=["Object","Request","Session","Status"],i=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},o=0,s=Object.keys(t);o1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==i)}},t.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t):e},t.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))},t.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,n=performance.now();Object.keys(r).forEach((function(e){n-r[e]>3e5&&delete r[e]}));for(var i=0;i0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,this.hls.trigger(R.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[o];s&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==s.bitrate&&this.log("Unstable Pathways change from bitrate "+s.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=o);break}}}},t.clonePathways=function(e){var t=this,r=this.levels;if(r){var n={},i={};e.forEach((function(e){var a=e.ID,o=e["BASE-ID"],u=e["URI-REPLACEMENT"];if(!r.some((function(e){return e.pathwayId===a}))){var l=t.getLevelsForPathway(o).map((function(e){var t=s({},e);t.details=void 0,t.url=Oa(e.uri,e.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u);var r=new D(e.attrs);r["PATHWAY-ID"]=a;var o=r.AUDIO&&r.AUDIO+"_clone_"+a,l=r.SUBTITLES&&r.SUBTITLES+"_clone_"+a;o&&(n[r.AUDIO]=o,r.AUDIO=o),l&&(i[r.SUBTITLES]=l,r.SUBTITLES=l),t.attrs=r;var c=new jt(t);return hr(c,"audio",o),hr(c,"text",l),c}));r.push.apply(r,l),Ma(t.audioTracks,n,u,a),Ma(t.subtitleTracks,i,u,a)}}))}},t.loadSteeringManifest=function(e){var t,r=this,n=this.hls.config,i=n.loader;this.loader&&this.loader.destroy(),this.loader=new i(n);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||n.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var o={responseType:"json",url:t.href},s=n.steeringManifestLoadPolicy.default,u=s.errorRetry||s.timeoutRetry||{},l={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},c={onSuccess:function(e,n,i,a){r.log('Loaded steering manifest: "'+t+'"');var o=e.data;if(1===o.VERSION){r.updated=performance.now(),r.timeToLoad=o.TTL;var s=o["RELOAD-URI"],u=o["PATHWAY-CLONES"],l=o["PATHWAY-PRIORITY"];if(s)try{r.uri=new self.URL(s,t).href}catch(e){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+s)}r.scheduleRefresh(r.uri||i.url),u&&r.clonePathways(u),l&&r.updatePathwayPriority(l)}else r.log("Steering VERSION "+o.VERSION+" not supported!")},onError:function(e,t,n,i){if(r.log("Error loading steering manifest: "+e.code+" "+e.text+" ("+t.url+")"),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest "+t.url+" no longer available");var a=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,a);else{var o=r.loader;if("function"==typeof(null==o?void 0:o.getResponseHeader)){var s=o.getResponseHeader("Retry-After");s&&(a=1e3*parseFloat(s))}r.log("Steering manifest "+t.url+" rate limited")}},onTimeout:function(e,t,n){r.log("Timeout loading steering manifest ("+t.url+")"),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(o,l,c)},t.scheduleRefresh=function(e,t){var r=this;void 0===t&&(t=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((function(){r.loadSteeringManifest(e)}),t)},e}();function Ma(e,t,r,n){e&&Object.keys(t).forEach((function(i){var a=e.filter((function(e){return e.groupId===i})).map((function(e){var a=s({},e);return a.details=void 0,a.attrs=new D(a.attrs),a.url=a.attrs.URI=Oa(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),a.groupId=a.attrs["GROUP-ID"]=t[i],a.attrs["PATHWAY-ID"]=n,a}));e.push.apply(e,a)}))}function Oa(e,t,r,n){var i,a=n.HOST,o=n.PARAMS,s=n[r];t&&(i=null==s?void 0:s[t])&&(e=i);var u=new self.URL(e);return a&&!i&&(u.host=a),o&&Object.keys(o).sort().forEach((function(e){e&&u.searchParams.set(e,o[e])})),u.href}var Da=/^age:\s*[\d.]+\s*$/im,Pa=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new N,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t){var n=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then((function(){if(!e.stats.aborted)return a(n,r.url)})).catch((function(e){return n.open("GET",r.url,!0),a(n,r.url)})).then((function(){e.stats.aborted||e.openAndSendXhr(n,r,t)})).catch((function(t){e.callbacks.onError({code:n.status,text:t.message},r,n,i)})):this.openAndSendXhr(n,r,t)}},t.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var n=this.context.headers,i=r.loadPolicy,a=i.maxTimeToFirstByteMs,o=i.maxLoadTimeMs;if(n)for(var s in n)e.setRequestHeader(s,n[s]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=a&&E(a)?a:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var n=t.readyState,i=this.config;if(!r.aborted&&n>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===n)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var a=t.status,o="text"!==t.responseType;if(a>=200&&a<300&&(o&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var s=o?t.response:t.responseText,u="arraybuffer"===t.responseType?s.byteLength:s.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(r,e,s,t),!this.callbacks)return;var c={url:t.responseURL,data:s,code:a};this.callbacks.onSuccess(c,r,e,t)}else{var d=i.loadPolicy.errorRetry;Qt(d,r.retry,!1,a)?this.retry(d):(C.error(a+" while loading "+e.url),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}},t.loadtimeout=function(){var e,t=null==(e=this.config)?void 0:e.loadPolicy.timeoutRetry;if(Qt(t,this.stats.retry,!0))this.retry(t);else{C.warn("timeout while loading "+this.context.url);var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},t.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=$t(e,r.retry),r.retry++,C.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&Da.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}(),Fa=/(\d+)-(\d+)\/(\d+)/,Na=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Ua,this.controller=new self.AbortController,this.stats=new N}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},t.abortInternal=function(){var e=this.response;null!=e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var n=this,i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();var a=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(s({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),o=r.onProgress,u="arraybuffer"===e.responseType,l=u?"byteLength":"length",c=t.loadPolicy,d=c.maxTimeToFirstByteMs,f=c.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=d&&E(d)?d:f,this.requestTimeout=self.setTimeout((function(){n.abortInternal(),r.onTimeout(i,e,n.response)}),t.timeout),self.fetch(this.request).then((function(a){n.response=n.loader=a;var s=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(n.requestTimeout),t.timeout=f,n.requestTimeout=self.setTimeout((function(){n.abortInternal(),r.onTimeout(i,e,n.response)}),f-(s-i.loading.start)),!a.ok){var l=a.status,c=a.statusText;throw new Wa(c||"fetch, bad network response",l,a)}return i.loading.first=s,i.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=Fa.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(E(r))return r}var n=e.get("Content-Length");if(n)return parseInt(n)}(a.headers)||i.total,o&&E(t.highWaterMark)?n.loadProgressively(a,i,e,t.highWaterMark,o):u?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var s=n.response;self.clearTimeout(n.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);var u=a[l];u&&(i.loaded=i.total=u);var c={url:s.url,data:a,code:s.status};o&&!E(t.highWaterMark)&&o(i,e,a,s),r.onSuccess(c,i,e,s)})).catch((function(t){if(self.clearTimeout(n.requestTimeout),!i.aborted){var a=t&&t.code||0,o=t?t.message:null;r.onError({code:a,text:o},e,t?t.details:null,i)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,r,n,i){void 0===n&&(n=0);var a=new vi,o=e.body.getReader();return function s(){return o.read().then((function(o){if(o.done)return a.dataLength&&i(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));var u=o.value,l=u.length;return t.loaded+=l,l=n&&i(t,r,a.flush(),e)):i(t,r,u,e),s()})).catch((function(){return Promise.reject()}))}()},e}();function Ua(e,t){return new self.Request(e.url,t)}var Wa=function(e){function t(t,r,n){var i;return(i=e.call(this,t)||this).code=void 0,i.details=void 0,i.code=r,i.details=n,i}return u(t,e),t}(h(Error)),ja=/\s/,Ba={newCue:function(e,t,r,n){for(var i,a,o,s,u,l=[],c=self.VTTCue||self.TextTrackCue,d=0;d=16?s--:s++;var p=ra(u.trim()),m=sa(t,r,p);null!=e&&null!=(f=e.cues)&&f.getCueById(m)||((a=new c(t,r,p)).id=m,a.line=d+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*s/32)),l.push(a))}return e&&l.length&&(l.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),l.forEach((function(t){return Rt(e,t)}))),l}},Ga=n(n({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Pa,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:gi,bufferController:Li,capLevelController:Ea,errorController:cr,fpsController:Sa,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,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:ne,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:Ba,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:Ti,subtitleTrackController:Ii,timelineController:ya,audioStreamController:yi,audioTrackController:bi,emeController:Ta,cmcdController:xa,contentSteeringController:Ca});function qa(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(qa):Object.keys(e).reduce((function(t,r){return t[r]=qa(e[r]),t}),{}):e}function Ka(e){var t=e.loader;t!==Na&&t!==Pa?(C.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=Na,e.progressive=!0,e.enableSoftwareAES=!0,C.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Ha=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new oi,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,x(t.debug||!1,"Hls instance");var r=this.config=function(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=qa(e),i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(e){var n=("level"===e?"playlist":e)+"LoadPolicy",a=void 0===t[n],o=[];i.forEach((function(i){var s=e+"Loading"+i,u=t[s];if(void 0!==u&&a){o.push(s);var l=r[n].default;switch(t[n]={default:l},i){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}})),o.length&&C.warn('hls.js config: "'+o.join('", "')+'" setting(s) are deprecated, use "'+n+'": '+JSON.stringify(t[n]))})),n(n({},r),t)}(e.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,r.progressive&&Ka(r);var i=r.abrController,a=r.bufferController,o=r.capLevelController,s=r.errorController,u=r.fpsController,l=new s(this),c=this.abrController=new i(this),d=this.bufferController=new a(this),f=this.capLevelController=new o(this),h=new u(this),p=new St(this),m=new Ot(this),g=r.contentSteeringController,v=g?new g(this):null,y=this.levelController=new fr(this,v),b=new br(this),E=new kr(this.config),S=this.streamController=new hi(this,b,E);f.setStreamController(S),h.setStreamController(S);var T=[p,y,S];v&&T.splice(1,0,v),this.networkControllers=T;var I=[c,d,f,h,m,b];this.audioTrackController=this.createController(r.audioTrackController,T);var _=r.audioStreamController;_&&T.push(new _(this,b,E)),this.subtitleTrackController=this.createController(r.subtitleTrackController,T);var w=r.subtitleStreamController;w&&T.push(new w(this,b,E)),this.createController(r.timelineController,I),E.emeController=this.emeController=this.createController(r.emeController,I),this.cmcdController=this.createController(r.cmcdController,I),this.latencyController=this.createController(Dt,I),this.coreComponents=I,T.push(l);var k=l.onErrorOut;"function"==typeof k&&this.on(R.ERROR,k,l)}e.isSupported=function(){return function(){var e=Xe();if(!e)return!1;var t=tn(),r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),n=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!n}()};var t=e.prototype;return t.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},t.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},t.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,r,n){void 0===r&&(r=this),this._emitter.off(e,t,r,n)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,r){return this._emitter.emit(e,t,r)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){C.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(R.ERROR,{type:I.OTHER_ERROR,details:_.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){C.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){C.log("attachMedia"),this._media=e,this.trigger(R.MEDIA_ATTACHING,{media:e})},t.detachMedia=function(){C.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null},t.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,n=this.url=b.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});C.log("loadSource:"+n),t&&r&&(r!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(R.MANIFEST_LOADING,{url:e})},t.startLoad=function(e){void 0===e&&(e=-1),C.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},t.stopLoad=function(){C.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},t.swapAudioCodec=function(){C.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.recoverMediaError=function(){C.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},t.removeLevel=function(e,t){void 0===t&&(t=0),this.levelController.removeLevel(e,t)},a(e,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){C.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){C.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){C.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){C.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){C.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(C.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){Pt.indexOf(e)>-1&&(this._maxHdcpLevel=e)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,n=0;n=t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,n=this.maxHdcpLevel;if(e=-1===r&&t&&t.length?t.length-1:r,n)for(var i=e;i--;){var a=t[i].attrs["HDCP-LEVEL"];if(a&&a<=n)return i}return e}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.4.14"}},{key:"Events",get:function(){return R}},{key:"ErrorTypes",get:function(){return I}},{key:"ErrorDetails",get:function(){return _}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:Ga},set:function(t){e.defaultConfig=t}}]),e}();return Ha.defaultConfig=void 0,Ha}()}(!1)},"./node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js":(e,t,r)=>{"use strict";var n=r("./node_modules/react-is/index.js"),i={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},a={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},o={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function u(e){return n.isMemo(e)?o:s[e.$$typeof]||i}s[n.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[n.Memo]=o;var l=Object.defineProperty,c=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,f=Object.getOwnPropertyDescriptor,h=Object.getPrototypeOf,p=Object.prototype;e.exports=function e(t,r,n){if("string"!=typeof r){if(p){var i=h(r);i&&i!==p&&e(t,i,n)}var o=c(r);d&&(o=o.concat(d(r)));for(var s=u(t),m=u(r),g=0;g{"use strict";r.d(t,{A:()=>s});var n=/[A-Z]/g,i=/^ms-/,a={};function o(e){return"-"+e.toLowerCase()}const s=function(e){if(a.hasOwnProperty(e))return a[e];var t=e.replace(n,o);return a[e]=i.test(t)?"-"+t:t}},"./node_modules/deep-object-diff/cjs/added.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r("./node_modules/deep-object-diff/cjs/utils.js");const i=(e,t)=>e!==t&&(0,n.isObject)(e)&&(0,n.isObject)(t)?Object.keys(t).reduce((r,a)=>{if((0,n.hasOwnProperty)(e,a)){const o=i(e[a],t[a]);return(0,n.isObject)(o)&&(0,n.isEmpty)(o)||(r[a]=o),r}return r[a]=t[a],r},(0,n.makeObjectWithoutPrototype)()):{};var a=i;t.default=a},"./node_modules/deep-object-diff/cjs/deleted.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r("./node_modules/deep-object-diff/cjs/utils.js");const i=(e,t)=>e!==t&&(0,n.isObject)(e)&&(0,n.isObject)(t)?Object.keys(e).reduce((r,a)=>{if((0,n.hasOwnProperty)(t,a)){const o=i(e[a],t[a]);return(0,n.isObject)(o)&&(0,n.isEmpty)(o)||(r[a]=o),r}return r[a]=void 0,r},(0,n.makeObjectWithoutPrototype)()):{};var a=i;t.default=a},"./node_modules/deep-object-diff/cjs/detailed.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=o(r("./node_modules/deep-object-diff/cjs/added.js")),i=o(r("./node_modules/deep-object-diff/cjs/deleted.js")),a=o(r("./node_modules/deep-object-diff/cjs/updated.js"));function o(e){return e&&e.__esModule?e:{default:e}}var s=(e,t)=>({added:(0,n.default)(e,t),deleted:(0,i.default)(e,t),updated:(0,a.default)(e,t)});t.default=s},"./node_modules/deep-object-diff/cjs/diff.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r("./node_modules/deep-object-diff/cjs/utils.js");const i=(e,t)=>{if(e===t)return{};if(!(0,n.isObject)(e)||!(0,n.isObject)(t))return t;const r=Object.keys(e).reduce((e,r)=>((0,n.hasOwnProperty)(t,r)||(e[r]=void 0),e),(0,n.makeObjectWithoutPrototype)());return(0,n.isDate)(e)||(0,n.isDate)(t)?e.valueOf()==t.valueOf()?{}:t:Object.keys(t).reduce((r,a)=>{if(!(0,n.hasOwnProperty)(e,a))return r[a]=t[a],r;const o=i(e[a],t[a]);return!(0,n.isEmptyObject)(o)||(0,n.isDate)(o)||!(0,n.isEmptyObject)(e[a])&&(0,n.isEmptyObject)(t[a])?(r[a]=o,r):r},r)};var a=i;t.default=a},"./node_modules/deep-object-diff/cjs/index.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"addedDiff",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(t,"deletedDiff",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(t,"detailedDiff",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(t,"diff",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"updatedDiff",{enumerable:!0,get:function(){return o.default}});var n=u(r("./node_modules/deep-object-diff/cjs/diff.js")),i=u(r("./node_modules/deep-object-diff/cjs/added.js")),a=u(r("./node_modules/deep-object-diff/cjs/deleted.js")),o=u(r("./node_modules/deep-object-diff/cjs/updated.js")),s=u(r("./node_modules/deep-object-diff/cjs/detailed.js"));function u(e){return e&&e.__esModule?e:{default:e}}},"./node_modules/deep-object-diff/cjs/updated.js":(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r("./node_modules/deep-object-diff/cjs/utils.js");const i=(e,t)=>e===t?{}:(0,n.isObject)(e)&&(0,n.isObject)(t)?(0,n.isDate)(e)||(0,n.isDate)(t)?e.valueOf()==t.valueOf()?{}:t:Object.keys(t).reduce((r,a)=>{if((0,n.hasOwnProperty)(e,a)){const o=i(e[a],t[a]);return!(0,n.isEmptyObject)(o)||(0,n.isDate)(o)||!(0,n.isEmptyObject)(e[a])&&(0,n.isEmptyObject)(t[a])?(r[a]=o,r):r}return r},(0,n.makeObjectWithoutPrototype)()):t;var a=i;t.default=a},"./node_modules/deep-object-diff/cjs/utils.js":(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.makeObjectWithoutPrototype=t.isObject=t.isEmptyObject=t.isEmpty=t.isDate=t.hasOwnProperty=void 0;t.isDate=e=>e instanceof Date;const r=e=>0===Object.keys(e).length;t.isEmpty=r;const n=e=>null!=e&&"object"==typeof e;t.isObject=n;t.hasOwnProperty=(e,...t)=>Object.prototype.hasOwnProperty.call(e,...t);t.isEmptyObject=e=>n(e)&&r(e);t.makeObjectWithoutPrototype=()=>Object.create(null)},"./node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs":(e,t,r)=>{"use strict";r.d(t,{ll:()=>w});function n(e){return{...e,top:e.y,left:e.x,right:e.x+e.width,bottom:e.y+e.height}}Math.min,Math.max;const i=["top","right","bottom","left"];i.reduce((e,t)=>e.concat(t,t+"-start",t+"-end"),[]);function a(e){var t;return(null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function o(e){return a(e).getComputedStyle(e)}function s(e){return e instanceof a(e).Node}function u(e){return s(e)?(e.nodeName||"").toLowerCase():""}let l;function c(){if(l)return l;const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?(l=e.brands.map(e=>e.brand+"/"+e.version).join(" "),l):navigator.userAgent}function d(e){return e instanceof a(e).HTMLElement}function f(e){return e instanceof a(e).Element}function h(e){return"undefined"!=typeof ShadowRoot&&(e instanceof a(e).ShadowRoot||e instanceof ShadowRoot)}function p(e){const{overflow:t,overflowX:r,overflowY:n,display:i}=o(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!["inline","contents"].includes(i)}function m(){return/^((?!chrome|android).)*safari/i.test(c())}function g(e){return["html","body","#document"].includes(u(e))}Math.min,Math.max;const v=Math.round;function y(e){const t=o(e);let r=parseFloat(t.width),n=parseFloat(t.height);const i=d(e),a=i?e.offsetWidth:r,s=i?e.offsetHeight:n,u=v(r)!==a||v(n)!==s;return u&&(r=a,n=s),{width:r,height:n,fallback:u}}function b(e){return f(e)?e:e.contextElement}const E={x:1,y:1};function S(e){const t=b(e);if(!d(t))return E;const r=t.getBoundingClientRect(),{width:n,height:i,fallback:a}=y(t);let o=(a?v(r.width):r.width)/n,s=(a?v(r.height):r.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}function T(e,t,r,i){var o,s;void 0===t&&(t=!1),void 0===r&&(r=!1);const u=e.getBoundingClientRect(),l=b(e);let c=E;t&&(i?f(i)&&(c=S(i)):c=S(e));const d=l?a(l):window,h=m()&&r;let p=(u.left+(h&&(null==(o=d.visualViewport)?void 0:o.offsetLeft)||0))/c.x,g=(u.top+(h&&(null==(s=d.visualViewport)?void 0:s.offsetTop)||0))/c.y,v=u.width/c.x,y=u.height/c.y;if(l){const e=a(l),t=i&&f(i)?a(i):i;let r=e.frameElement;for(;r&&i&&t!==e;){const e=S(r),t=r.getBoundingClientRect(),n=getComputedStyle(r);t.x+=(r.clientLeft+parseFloat(n.paddingLeft))*e.x,t.y+=(r.clientTop+parseFloat(n.paddingTop))*e.y,p*=e.x,g*=e.y,v*=e.x,y*=e.y,p+=t.x,g+=t.y,r=a(r).frameElement}}return n({width:v,height:y,x:p,y:g})}function R(e){return((s(e)?e.ownerDocument:e.document)||window.document).documentElement}function I(e){if("html"===u(e))return e;const t=e.assignedSlot||e.parentNode||h(e)&&e.host||R(e);return h(t)?t.host:t}function _(e,t){var r;void 0===t&&(t=[]);const n=function e(t){const r=I(t);return g(r)?r.ownerDocument.body:d(r)&&p(r)?r:e(r)}(e),i=n===(null==(r=e.ownerDocument)?void 0:r.body),o=a(n);return i?t.concat(o,o.visualViewport||[],p(n)?n:[]):t.concat(n,_(n))}function w(e,t,r,n){void 0===n&&(n={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=!0,animationFrame:s=!1}=n,u=i||a?[...f(e)?_(e):e.contextElement?_(e.contextElement):[],..._(t)]:[];u.forEach(e=>{const t=!f(e)&&e.toString().includes("V");!i||s&&!t||e.addEventListener("scroll",r,{passive:!0}),a&&e.addEventListener("resize",r)});let l,c=null;o&&(c=new ResizeObserver(()=>{r()}),f(e)&&!s&&c.observe(e),f(e)||!e.contextElement||s||c.observe(e.contextElement),c.observe(t));let d=s?T(e):null;return s&&function t(){const n=T(e);!d||n.x===d.x&&n.y===d.y&&n.width===d.width&&n.height===d.height||r(),d=n,l=requestAnimationFrame(t)}(),r(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener("scroll",r),a&&e.removeEventListener("resize",r)}),null==(e=c)||e.disconnect(),c=null,s&&cancelAnimationFrame(l)}}}}]); //# sourceMappingURL=https://hybridclient.naiadsystems.com/dist/hybrid/27.5.9/2~bba809326aa4acfe0e1b.js.map