You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/p__Help__Index.6508d612.asy...

346 lines
688 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[164,8],{"2kAv":function(qe,Qe,fe){qe.exports={wrap:"wrap___CCio_",link:"link___PWIh8"}},"7O0G":function(qe,Qe,fe){(function(et,tt){qe.exports=tt()})(this,function(){"use strict";function et(ie,te){for(var re=0;re<te.length;re++){var K=te[re];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(ie,K.key,K)}}function tt(ie,te,re){return te&&et(ie.prototype,te),re&&et(ie,re),ie}function ze(ie,te){if(!ie)return;if(typeof ie=="string")return Ve(ie,te);var re=Object.prototype.toString.call(ie).slice(8,-1);if(re==="Object"&&ie.constructor&&(re=ie.constructor.name),re==="Map"||re==="Set")return Array.from(ie);if(re==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(re))return Ve(ie,te)}function Ve(ie,te){(te==null||te>ie.length)&&(te=ie.length);for(var re=0,K=new Array(te);re<te;re++)K[re]=ie[re];return K}function he(ie,te){var re;if(typeof Symbol=="undefined"||ie[Symbol.iterator]==null){if(Array.isArray(ie)||(re=ze(ie))||te&&ie&&typeof ie.length=="number"){re&&(ie=re);var K=0;return function(){return K>=ie.length?{done:!0}:{done:!1,value:ie[K++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}return re=ie[Symbol.iterator](),re.next.bind(re)}function V(ie,te){return te={exports:{}},ie(te,te.exports),te.exports}var w=V(function(ie){function te(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function re(K){ie.exports.defaults=K}ie.exports={defaults:te(),getDefaults:te,changeDefaults:re}}),W=w.defaults,P=w.getDefaults,N=w.changeDefaults,D=/[&<>"']/,G=/[&<>"']/g,I=/[<>"']|&(?!#?\w+;)/,R=/[<>"']|&(?!#?\w+;)/g,L={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},_=function(te){return L[te]};function T(ie,te){if(te){if(D.test(ie))return ie.replace(G,_)}else if(I.test(ie))return ie.replace(R,_);return ie}var g=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function x(ie){return ie.replace(g,function(te,re){return re=re.toLowerCase(),re==="colon"?":":re.charAt(0)==="#"?re.charAt(1)==="x"?String.fromCharCode(parseInt(re.substring(2),16)):String.fromCharCode(+re.substring(1)):""})}var b=/(^|[^\[])\^/g;function f(ie,te){ie=ie.source||ie,te=te||"";var re={replace:function(j,Z){return Z=Z.source||Z,Z=Z.replace(b,"$1"),ie=ie.replace(j,Z),re},getRegex:function(){return new RegExp(ie,te)}};return re}var u=/[^\w:]/g,h=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function o(ie,te,re){if(ie){var K;try{K=decodeURIComponent(x(re)).replace(u,"").toLowerCase()}catch(j){return null}if(K.indexOf("javascript:")===0||K.indexOf("vbscript:")===0||K.indexOf("data:")===0)return null}te&&!h.test(re)&&(re=v(te,re));try{re=encodeURI(re).replace(/%25/g,"%")}catch(j){return null}return re}var s={},l=/^[^:]+:\/*[^/]*$/,n=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function v(ie,te){s[" "+ie]||(l.test(ie)?s[" "+ie]=ie+"/":s[" "+ie]=a(ie,"/",!0)),ie=s[" "+ie];var re=ie.indexOf(":")===-1;return te.substring(0,2)==="//"?re?te:ie.replace(n,"$1")+te:te.charAt(0)==="/"?re?te:ie.replace(d,"$1")+te:ie+te}var p={exec:function(){}};function m(ie){for(var te=1,re,K;te<arguments.length;te++){re=arguments[te];for(K in re)Object.prototype.hasOwnProperty.call(re,K)&&(ie[K]=re[K])}return ie}function r(ie,te){var re=ie.replace(/\|/g,function(Z,q,se){for(var de=!1,ve=q;--ve>=0&&se[ve]==="\\";)de=!de;return de?"|":" |"}),K=re.split(/ \|/),j=0;if(K.length>te)K.splice(te);else for(;K.length<te;)K.push("");for(;j<K.length;j++)K[j]=K[j].trim().replace(/\\\|/g,"|");return K}function a(ie,te,re){var K=ie.length;if(K===0)return"";for(var j=0;j<K;){var Z=ie.charAt(K-j-1);if(Z===te&&!re)j++;else if(Z!==te&&re)j++;else break}return ie.substr(0,K-j)}function e(ie,te){if(ie.indexOf(te[1])===-1)return-1;for(var re=ie.length,K=0,j=0;j<re;j++)if(ie[j]==="\\")j++;else if(ie[j]===te[0])K++;else if(ie[j]===te[1]&&(K--,K<0))return j;return-1}function c(ie){ie&&ie.sanitize&&!ie.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}var E={escape:T,unescape:x,edit:f,cleanUrl:o,resolveUrl:v,noopTest:p,merge:m,splitCells:r,rtrim:a,findClosingBracket:e,checkSanitizeDeprecation:c},y=w.defaults,k=E.rtrim,M=E.splitCells,O=E.escape,U=E.findClosingBracket;function F(ie,te,re){var K=te.href,j=te.title?O(te.title):null,Z=ie[1].replace(/\\([\[\]])/g,"$1");return ie[0].charAt(0)!=="!"?{type:"link",raw:re,href:K,title:j,text:Z}:{type:"image",raw:re,href:K,title:j,text:O(Z)}}function H(ie,te){var re=ie.match(/^(\s+)(?:```)/);if(re===null)return te;var K=re[1];return te.split(`
`).map(function(j){var Z=j.match(/^\s+/);if(Z===null)return j;var q=Z[0];return q.length>=K.length?j.slice(K.length):j}).join(`
`)}var Y=function(){function ie(re){this.options=re||y}var te=ie.prototype;return te.space=function(K){var j=this.rules.block.newline.exec(K);if(j)return j[0].length>1?{type:"space",raw:j[0]}:{raw:`
`}},te.code=function(K,j){var Z=this.rules.block.code.exec(K);if(Z){var q=j[j.length-1];if(q&&q.type==="paragraph")return{raw:Z[0],text:Z[0].trimRight()};var se=Z[0].replace(/^ {4}/gm,"");return{type:"code",raw:Z[0],codeBlockStyle:"indented",text:this.options.pedantic?se:k(se,`
`)}}},te.fences=function(K){var j=this.rules.block.fences.exec(K);if(j){var Z=j[0],q=H(Z,j[3]||"");return{type:"code",raw:Z,lang:j[2]?j[2].trim():j[2],text:q}}},te.heading=function(K){var j=this.rules.block.heading.exec(K);if(j)return{type:"heading",raw:j[0],depth:j[1].length,text:j[2]}},te.nptable=function(K){var j=this.rules.block.nptable.exec(K);if(j){var Z={type:"table",header:M(j[1].replace(/^ *| *\| *$/g,"")),align:j[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:j[3]?j[3].replace(/\n$/,"").split(`
`):[],raw:j[0]};if(Z.header.length===Z.align.length){var q=Z.align.length,se;for(se=0;se<q;se++)/^ *-+: *$/.test(Z.align[se])?Z.align[se]="right":/^ *:-+: *$/.test(Z.align[se])?Z.align[se]="center":/^ *:-+ *$/.test(Z.align[se])?Z.align[se]="left":Z.align[se]=null;for(q=Z.cells.length,se=0;se<q;se++)Z.cells[se]=M(Z.cells[se],Z.header.length);return Z}}},te.hr=function(K){var j=this.rules.block.hr.exec(K);if(j)return{type:"hr",raw:j[0]}},te.blockquote=function(K){var j=this.rules.block.blockquote.exec(K);if(j){var Z=j[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:j[0],text:Z}}},te.list=function(K){var j=this.rules.block.list.exec(K);if(j){for(var Z=j[0],q=j[2],se=q.length>1,de=q[q.length-1]===")",ve={type:"list",raw:Z,ordered:se,start:se?+q.slice(0,-1):"",loose:!1,items:[]},Ue=j[0].match(this.rules.block.item),Ge=!1,We,it,$e,Ne,st,je,Je,ot=Ue.length,Ye=0;Ye<ot;Ye++)We=Ue[Ye],Z=We,it=We.length,We=We.replace(/^ *([*+-]|\d+[.)]) */,""),~We.indexOf(`
`)&&(it-=We.length,We=this.options.pedantic?We.replace(/^ {1,4}/gm,""):We.replace(new RegExp("^ {1,"+it+"}","gm"),"")),Ye!==ot-1&&($e=this.rules.block.bullet.exec(Ue[Ye+1])[0],(se?$e.length===1||!de&&$e[$e.length-1]===")":$e.length>1||this.options.smartLists&&$e!==q)&&(Ne=Ue.slice(Ye+1).join(`
`),ve.raw=ve.raw.substring(0,ve.raw.length-Ne.length),Ye=ot-1)),st=Ge||/\n\n(?!\s*$)/.test(We),Ye!==ot-1&&(Ge=We.charAt(We.length-1)===`
`,st||(st=Ge)),st&&(ve.loose=!0),je=/^\[[ xX]\] /.test(We),Je=void 0,je&&(Je=We[1]!==" ",We=We.replace(/^\[[ xX]\] +/,"")),ve.items.push({type:"list_item",raw:Z,task:je,checked:Je,loose:st,text:We});return ve}},te.html=function(K){var j=this.rules.block.html.exec(K);if(j)return{type:this.options.sanitize?"paragraph":"html",raw:j[0],pre:!this.options.sanitizer&&(j[1]==="pre"||j[1]==="script"||j[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(j[0]):O(j[0]):j[0]}},te.def=function(K){var j=this.rules.block.def.exec(K);if(j){j[3]&&(j[3]=j[3].substring(1,j[3].length-1));var Z=j[1].toLowerCase().replace(/\s+/g," ");return{tag:Z,raw:j[0],href:j[2],title:j[3]}}},te.table=function(K){var j=this.rules.block.table.exec(K);if(j){var Z={type:"table",header:M(j[1].replace(/^ *| *\| *$/g,"")),align:j[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:j[3]?j[3].replace(/\n$/,"").split(`
`):[]};if(Z.header.length===Z.align.length){Z.raw=j[0];var q=Z.align.length,se;for(se=0;se<q;se++)/^ *-+: *$/.test(Z.align[se])?Z.align[se]="right":/^ *:-+: *$/.test(Z.align[se])?Z.align[se]="center":/^ *:-+ *$/.test(Z.align[se])?Z.align[se]="left":Z.align[se]=null;for(q=Z.cells.length,se=0;se<q;se++)Z.cells[se]=M(Z.cells[se].replace(/^ *\| *| *\| *$/g,""),Z.header.length);return Z}}},te.lheading=function(K){var j=this.rules.block.lheading.exec(K);if(j)return{type:"heading",raw:j[0],depth:j[2].charAt(0)==="="?1:2,text:j[1]}},te.paragraph=function(K){var j=this.rules.block.paragraph.exec(K);if(j)return{type:"paragraph",raw:j[0],text:j[1].charAt(j[1].length-1)===`
`?j[1].slice(0,-1):j[1]}},te.text=function(K,j){var Z=this.rules.block.text.exec(K);if(Z){var q=j[j.length-1];return q&&q.type==="text"?{raw:Z[0],text:Z[0]}:{type:"text",raw:Z[0],text:Z[0]}}},te.escape=function(K){var j=this.rules.inline.escape.exec(K);if(j)return{type:"escape",raw:j[0],text:O(j[1])}},te.tag=function(K,j,Z){var q=this.rules.inline.tag.exec(K);if(q)return!j&&/^<a /i.test(q[0])?j=!0:j&&/^<\/a>/i.test(q[0])&&(j=!1),!Z&&/^<(pre|code|kbd|script)(\s|>)/i.test(q[0])?Z=!0:Z&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(q[0])&&(Z=!1),{type:this.options.sanitize?"text":"html",raw:q[0],inLink:j,inRawBlock:Z,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(q[0]):O(q[0]):q[0]}},te.link=function(K){var j=this.rules.inline.link.exec(K);if(j){var Z=U(j[2],"()");if(Z>-1){var q=j[0].indexOf("!")===0?5:4,se=q+j[1].length+Z;j[2]=j[2].substring(0,Z),j[0]=j[0].substring(0,se).trim(),j[3]=""}var de=j[2],ve="";if(this.options.pedantic){var Ue=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(de);Ue?(de=Ue[1],ve=Ue[3]):ve=""}else ve=j[3]?j[3].slice(1,-1):"";de=de.trim().replace(/^<([\s\S]*)>$/,"$1");var Ge=F(j,{href:de&&de.replace(this.rules.inline._escapes,"$1"),title:ve&&ve.replace(this.rules.inline._escapes,"$1")},j[0]);return Ge}},te.reflink=function(K,j){var Z;if((Z=this.rules.inline.reflink.exec(K))||(Z=this.rules.inline.nolink.exec(K))){var q=(Z[2]||Z[1]).replace(/\s+/g," ");if(q=j[q.toLowerCase()],!q||!q.href){var se=Z[0].charAt(0);return{type:"text",raw:se,text:se}}var de=F(Z,q,Z[0]);return de}},te.strong=function(K,j,Z){Z===void 0&&(Z="");var q=this.rules.inline.strong.start.exec(K);if(q&&(!q[1]||q[1]&&(Z===""||this.rules.inline.punctuation.exec(Z)))){j=j.slice(-1*K.length);var se=q[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;se.lastIndex=0;for(var de;(q=se.exec(j))!=null;)if(de=this.rules.inline.strong.middle.exec(j.slice(0,q.index+3)),de)return{type:"strong",raw:K.slice(0,de[0].length),text:K.slice(2,de[0].length-2)}}},te.em=function(K,j,Z){Z===void 0&&(Z="");var q=this.rules.inline.em.start.exec(K);if(q&&(!q[1]||q[1]&&(Z===""||this.rules.inline.punctuation.exec(Z)))){j=j.slice(-1*K.length);var se=q[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;se.lastIndex=0;for(var de;(q=se.exec(j))!=null;)if(de=this.rules.inline.em.middle.exec(j.slice(0,q.index+2)),de)return{type:"em",raw:K.slice(0,de[0].length),text:K.slice(1,de[0].length-1)}}},te.codespan=function(K){var j=this.rules.inline.code.exec(K);if(j){var Z=j[2].replace(/\n/g," "),q=/[^ ]/.test(Z),se=Z.startsWith(" ")&&Z.endsWith(" ");return q&&se&&(Z=Z.substring(1,Z.length-1)),Z=O(Z,!0),{type:"codespan",raw:j[0],text:Z}}},te.br=function(K){var j=this.rules.inline.br.exec(K);if(j)return{type:"br",raw:j[0]}},te.del=function(K){var j=this.rules.inline.del.exec(K);if(j)return{type:"del",raw:j[0],text:j[1]}},te.autolink=function(K,j){var Z=this.rules.inline.autolink.exec(K);if(Z){var q,se;return Z[2]==="@"?(q=O(this.options.mangle?j(Z[1]):Z[1]),se="mailto:"+q):(q=O(Z[1]),se=q),{type:"link",raw:Z[0],text:q,href:se,tokens:[{type:"text",raw:q,text:q}]}}},te.url=function(K,j){var Z;if(Z=this.rules.inline.url.exec(K)){var q,se;if(Z[2]==="@")q=O(this.options.mangle?j(Z[0]):Z[0]),se="mailto:"+q;else{var de;do de=Z[0],Z[0]=this.rules.inline._backpedal.exec(Z[0])[0];while(de!==Z[0]);q=O(Z[0]),Z[1]==="www."?se="http://"+q:se=q}return{type:"link",raw:Z[0],text:q,href:se,tokens:[{type:"text",raw:q,text:q}]}}},te.inlineText=function(K,j,Z){var q=this.rules.inline.text.exec(K);if(q){var se;return j?se=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(q[0]):O(q[0]):q[0]:se=O(this.options.smartypants?Z(q[0]):q[0]),{type:"text",raw:q[0],text:se}}},ie}(),Q=E.noopTest,z=E.edit,ee=E.merge,J={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|<![A-Z][\\s\\S]*?>\\n*|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:Q,table:Q,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};J._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,J._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,J.def=z(J.def).replace("label",J._label).replace("title",J._title).getRegex(),J.bullet=/(?:[*+-]|\d{1,9}[.)])/,J.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,J.item=z(J.item,"gm").replace(/bull/g,J.bullet).getRegex(),J.list=z(J.list).replace(/bull/g,J.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+J.def.source+")").getRegex(),J._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",J._comment=/<!--(?!-?>)[\s\S]*?-->/,J.html=z(J.html,"i").replace("comment",J._comment).replace("tag",J._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),J.paragraph=z(J._paragraph).replace("hr",J.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",J._tag).getRegex(),J.blockquote=z(J.blockquote).replace("paragraph",J.paragraph).getRegex(),J.normal=ee({},J),J.gfm=ee({},J.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n *([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n *\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),J.gfm.nptable=z(J.gfm.nptable).replace("hr",J.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",J._tag).getRegex(),J.gfm.table=z(J.gfm.table).replace("hr",J.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",J._tag).getRegex(),J.pedantic=ee({},J.normal,{html:z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",J._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:Q,paragraph:z(J.normal._paragraph).replace("hr",J.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",J.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var X={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Q,tag:"^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",strong:{start:/^(?:(\*\*(?=[*punctuation]))|\*\*)(?![\s])|__/,middle:/^\*\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*\*$|^__(?![\s])((?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?)__$/,endAst:/[^punctuation\s]\*\*(?!\*)|[punctuation]\*\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]__(?!_)(?:(?=[punctuation\s])|$)/},em:{start:/^(?:(\*(?=[punctuation]))|\*)(?![*\s])|_/,middle:/^\*(?:(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)|\*(?:(?!overlapSkip)(?:[^*]|\\\*)|overlapSkip)*?\*)+?\*$|^_(?![_\s])(?:(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)|_(?:(?!overlapSkip)(?:[^_]|\\_)|overlapSkip)*?_)+?_$/,endAst:/[^punctuation\s]\*(?!\*)|[punctuation]\*(?!\*)(?:(?=[punctuation\s]|$))/,endUnd:/[^\s]_(?!_)(?:(?=[punctuation\s])|$)/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Q,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};X._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",X.punctuation=z(X.punctuation).replace(/punctuation/g,X._punctuation).getRegex(),X._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",X._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",X.em.start=z(X.em.start).replace(/punctuation/g,X._punctuation).getRegex(),X.em.middle=z(X.em.middle).replace(/punctuation/g,X._punctuation).replace(/overlapSkip/g,X._overlapSkip).getRegex(),X.em.endAst=z(X.em.endAst,"g").replace(/punctuation/g,X._punctuation).getRegex(),X.em.endUnd=z(X.em.endUnd,"g").replace(/punctuation/g,X._punctuation).getRegex(),X.strong.start=z(X.strong.start).replace(/punctuation/g,X._punctuation).getRegex(),X.strong.middle=z(X.strong.middle).replace(/punctuation/g,X._punctuation).replace(/blockSkip/g,X._blockSkip).getRegex(),X.strong.endAst=z(X.strong.endAst,"g").replace(/punctuation/g,X._punctuation).getRegex(),X.strong.endUnd=z(X.strong.endUnd,"g").replace(/punctuation/g,X._punctuation).getRegex(),X.blockSkip=z(X._blockSkip,"g").getRegex(),X.overlapSkip=z(X._overlapSkip,"g").getRegex(),X._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,X._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,X._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,X.autolink=z(X.autolink).replace("scheme",X._scheme).replace("email",X._email).getRegex(),X._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,X.tag=z(X.tag).replace("comment",J._comment).replace("attribute",X._attribute).getRegex(),X._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,X._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,X._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,X.link=z(X.link).replace("label",X._label).replace("href",X._href).replace("title",X._title).getRegex(),X.reflink=z(X.reflink).replace("label",X._label).getRegex(),X.reflinkSearch=z(X.reflinkSearch,"g").replace("reflink",X.reflink).replace("nolink",X.nolink).getRegex(),X.normal=ee({},X),X.pedantic=ee({},X.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:z(/^!?\[(label)\]\((.*?)\)/).replace("label",X._label).getRegex(),reflink:z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",X._label).getRegex()}),X.gfm=ee({},X.normal,{escape:z(X.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/}),X.gfm.url=z(X.gfm.url,"i").replace("email",X.gfm._extended_email).getRegex(),X.breaks=ee({},X.gfm,{br:z(X.br).replace("{2,}","*").getRegex(),text:z(X.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var oe={block:J,inline:X},le=w.defaults,me=oe.block,Ae=oe.inline;function ge(ie){return ie.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function ae(ie){var te="",re,K,j=ie.length;for(re=0;re<j;re++)K=ie.charCodeAt(re),Math.random()>.5&&(K="x"+K.toString(16)),te+="&#"+K+";";return te}var ue=function(){function ie(re){this.tokens=[],this.tokens.links=Object.create(null),this.options=re||le,this.options.tokenizer=this.options.tokenizer||new Y,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var K={block:me.normal,inline:Ae.normal};this.options.pedantic?(K.block=me.pedantic,K.inline=Ae.pedantic):this.options.gfm&&(K.block=me.gfm,this.options.breaks?K.inline=Ae.breaks:K.inline=Ae.gfm),this.tokenizer.rules=K}ie.lex=function(K,j){var Z=new ie(j);return Z.lex(K)};var te=ie.prototype;return te.lex=function(K){return K=K.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(K,this.tokens,!0),this.inline(this.tokens),this.tokens},te.blockTokens=function(K,j,Z){j===void 0&&(j=[]),Z===void 0&&(Z=!0),K=K.replace(/^ +$/gm,"");for(var q,se,de,ve;K;){if(q=this.tokenizer.space(K)){K=K.substring(q.raw.length),q.type&&j.push(q);continue}if(q=this.tokenizer.code(K,j)){K=K.substring(q.raw.length),q.type?j.push(q):(ve=j[j.length-1],ve.raw+=`
`+q.raw,ve.text+=`
`+q.text);continue}if(q=this.tokenizer.fences(K)){K=K.substring(q.raw.length),j.push(q);continue}if(q=this.tokenizer.heading(K)){K=K.substring(q.raw.length),j.push(q);continue}if(q=this.tokenizer.nptable(K)){K=K.substring(q.raw.length),j.push(q);continue}if(q=this.tokenizer.hr(K)){K=K.substring(q.raw.length),j.push(q);continue}if(q=this.tokenizer.blockquote(K)){K=K.substring(q.raw.length),q.tokens=this.blockTokens(q.text,[],Z),j.push(q);continue}if(q=this.tokenizer.list(K)){for(K=K.substring(q.raw.length),de=q.items.length,se=0;se<de;se++)q.items[se].tokens=this.blockTokens(q.items[se].text,[],!1);j.push(q);continue}if(q=this.tokenizer.html(K)){K=K.substring(q.raw.length),j.push(q);continue}if(Z&&(q=this.tokenizer.def(K))){K=K.substring(q.raw.length),this.tokens.links[q.tag]||(this.tokens.links[q.tag]={href:q.href,title:q.title});continue}if(q=this.tokenizer.table(K)){K=K.substring(q.raw.length),j.push(q);continue}if(q=this.tokenizer.lheading(K)){K=K.substring(q.raw.length),j.push(q);continue}if(Z&&(q=this.tokenizer.paragraph(K))){K=K.substring(q.raw.length),j.push(q);continue}if(q=this.tokenizer.text(K,j)){K=K.substring(q.raw.length),q.type?j.push(q):(ve=j[j.length-1],ve.raw+=`
`+q.raw,ve.text+=`
`+q.text);continue}if(K){var Ue="Infinite loop on byte: "+K.charCodeAt(0);if(this.options.silent){console.error(Ue);break}else throw new Error(Ue)}}return j},te.inline=function(K){var j,Z,q,se,de,ve,Ue=K.length;for(j=0;j<Ue;j++){ve=K[j];switch(ve.type){case"paragraph":case"text":case"heading":{ve.tokens=[],this.inlineTokens(ve.text,ve.tokens);break}case"table":{for(ve.tokens={header:[],cells:[]},se=ve.header.length,Z=0;Z<se;Z++)ve.tokens.header[Z]=[],this.inlineTokens(ve.header[Z],ve.tokens.header[Z]);for(se=ve.cells.length,Z=0;Z<se;Z++)for(de=ve.cells[Z],ve.tokens.cells[Z]=[],q=0;q<de.length;q++)ve.tokens.cells[Z][q]=[],this.inlineTokens(de[q],ve.tokens.cells[Z][q]);break}case"blockquote":{this.inline(ve.tokens);break}case"list":{for(se=ve.items.length,Z=0;Z<se;Z++)this.inline(ve.items[Z].tokens);break}}}return K},te.inlineTokens=function(K,j,Z,q,se){j===void 0&&(j=[]),Z===void 0&&(Z=!1),q===void 0&&(q=!1),se===void 0&&(se="");var de,ve=K,Ue;if(this.tokens.links){var Ge=Object.keys(this.tokens.links);if(Ge.length>0)for(;(Ue=this.tokenizer.rules.inline.reflinkSearch.exec(ve))!=null;)Ge.includes(Ue[0].slice(Ue[0].lastIndexOf("[")+1,-1))&&(ve=ve.slice(0,Ue.index)+"["+"a".repeat(Ue[0].length-2)+"]"+ve.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(Ue=this.tokenizer.rules.inline.blockSkip.exec(ve))!=null;)ve=ve.slice(0,Ue.index)+"["+"a".repeat(Ue[0].length-2)+"]"+ve.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;K;){if(de=this.tokenizer.escape(K)){K=K.substring(de.raw.length),j.push(de);continue}if(de=this.tokenizer.tag(K,Z,q)){K=K.substring(de.raw.length),Z=de.inLink,q=de.inRawBlock,j.push(de);continue}if(de=this.tokenizer.link(K)){K=K.substring(de.raw.length),de.type==="link"&&(de.tokens=this.inlineTokens(de.text,[],!0,q)),j.push(de);continue}if(de=this.tokenizer.reflink(K,this.tokens.links)){K=K.substring(de.raw.length),de.type==="link"&&(de.tokens=this.inlineTokens(de.text,[],!0,q)),j.push(de);continue}if(de=this.tokenizer.strong(K,ve,se)){K=K.substring(de.raw.length),de.tokens=this.inlineTokens(de.text,[],Z,q),j.push(de);continue}if(de=this.tokenizer.em(K,ve,se)){K=K.substring(de.raw.length),de.tokens=this.inlineTokens(de.text,[],Z,q),j.push(de);continue}if(de=this.tokenizer.codespan(K)){K=K.substring(de.raw.length),j.push(de);continue}if(de=this.tokenizer.br(K)){K=K.substring(de.raw.length),j.push(de);continue}if(de=this.tokenizer.del(K)){K=K.substring(de.raw.length),de.tokens=this.inlineTokens(de.text,[],Z,q),j.push(de);continue}if(de=this.tokenizer.autolink(K,ae)){K=K.substring(de.raw.length),j.push(de);continue}if(!Z&&(de=this.tokenizer.url(K,ae))){K=K.substring(de.raw.length),j.push(de);continue}if(de=this.tokenizer.inlineText(K,q,ge)){K=K.substring(de.raw.length),se=de.raw.slice(-1),j.push(de);continue}if(K){var We="Infinite loop on byte: "+K.charCodeAt(0);if(this.options.silent){console.error(We);break}else throw new Error(We)}}return j},tt(ie,null,[{key:"rules",get:function(){return{block:me,inline:Ae}}}]),ie}(),ye=w.defaults,Ee=E.cleanUrl,_e=E.escape,Se=function(){function ie(re){this.options=re||ye}var te=ie.prototype;return te.code=function(K,j,Z){var q=(j||"").match(/\S*/)[0];if(this.options.highlight){var se=this.options.highlight(K,q);se!=null&&se!==K&&(Z=!0,K=se)}return q?'<pre><code class="'+this.options.langPrefix+_e(q,!0)+'">'+(Z?K:_e(K,!0))+`</code></pre>
`:"<pre><code>"+(Z?K:_e(K,!0))+`</code></pre>
`},te.blockquote=function(K){return`<blockquote>
`+K+`</blockquote>
`},te.html=function(K){return K},te.heading=function(K,j,Z,q){return this.options.headerIds?"<h"+j+' id="'+this.options.headerPrefix+q.slug(Z)+'">'+K+"</h"+j+`>
`:"<h"+j+">"+K+"</h"+j+`>
`},te.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},te.list=function(K,j,Z){var q=j?"ol":"ul",se=j&&Z!==1?' start="'+Z+'"':"";return"<"+q+se+`>
`+K+"</"+q+`>
`},te.listitem=function(K){return"<li>"+K+`</li>
`},te.checkbox=function(K){return"<input "+(K?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},te.paragraph=function(K){return"<p>"+K+`</p>
`},te.table=function(K,j){return j&&(j="<tbody>"+j+"</tbody>"),`<table>
<thead>
`+K+`</thead>
`+j+`</table>
`},te.tablerow=function(K){return`<tr>
`+K+`</tr>
`},te.tablecell=function(K,j){var Z=j.header?"th":"td",q=j.align?"<"+Z+' align="'+j.align+'">':"<"+Z+">";return q+K+"</"+Z+`>
`},te.strong=function(K){return"<strong>"+K+"</strong>"},te.em=function(K){return"<em>"+K+"</em>"},te.codespan=function(K){return"<code>"+K+"</code>"},te.br=function(){return this.options.xhtml?"<br/>":"<br>"},te.del=function(K){return"<del>"+K+"</del>"},te.link=function(K,j,Z){if(K=Ee(this.options.sanitize,this.options.baseUrl,K),K===null)return Z;var q='<a href="'+_e(K)+'"';return j&&(q+=' title="'+j+'"'),q+=">"+Z+"</a>",q},te.image=function(K,j,Z){if(K=Ee(this.options.sanitize,this.options.baseUrl,K),K===null)return Z;var q='<img src="'+K+'" alt="'+Z+'"';return j&&(q+=' title="'+j+'"'),q+=this.options.xhtml?"/>":">",q},te.text=function(K){return K},ie}(),Te=function(){function ie(){}var te=ie.prototype;return te.strong=function(K){return K},te.em=function(K){return K},te.codespan=function(K){return K},te.del=function(K){return K},te.html=function(K){return K},te.text=function(K){return K},te.link=function(K,j,Z){return""+Z},te.image=function(K,j,Z){return""+Z},te.br=function(){return""},ie}(),Pe=function(){function ie(){this.seen={}}var te=ie.prototype;return te.slug=function(K){var j=K.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(j)){var Z=j;do this.seen[Z]++,j=Z+"-"+this.seen[Z];while(this.seen.hasOwnProperty(j))}return this.seen[j]=0,j},ie}(),we=w.defaults,be=E.unescape,Re=function(){function ie(re){this.options=re||we,this.options.renderer=this.options.renderer||new Se,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Te,this.slugger=new Pe}ie.parse=function(K,j){var Z=new ie(j);return Z.parse(K)};var te=ie.prototype;return te.parse=function(K,j){j===void 0&&(j=!0);var Z="",q,se,de,ve,Ue,Ge,We,it,$e,Ne,st,je,Je,ot,Ye,ct,bt,mt,Tt=K.length;for(q=0;q<Tt;q++){Ne=K[q];switch(Ne.type){case"space":continue;case"hr":{Z+=this.renderer.hr();continue}case"heading":{Z+=this.renderer.heading(this.parseInline(Ne.tokens),Ne.depth,be(this.parseInline(Ne.tokens,this.textRenderer)),this.slugger);continue}case"code":{Z+=this.renderer.code(Ne.text,Ne.lang,Ne.escaped);continue}case"table":{for(it="",We="",ve=Ne.header.length,se=0;se<ve;se++)We+=this.renderer.tablecell(this.parseInline(Ne.tokens.header[se]),{header:!0,align:Ne.align[se]});for(it+=this.renderer.tablerow(We),$e="",ve=Ne.cells.length,se=0;se<ve;se++){for(Ge=Ne.tokens.cells[se],We="",Ue=Ge.length,de=0;de<Ue;de++)We+=this.renderer.tablecell(this.parseInline(Ge[de]),{header:!1,align:Ne.align[de]});$e+=this.renderer.tablerow(We)}Z+=this.renderer.table(it,$e);continue}case"blockquote":{$e=this.parse(Ne.tokens),Z+=this.renderer.blockquote($e);continue}case"list":{for(st=Ne.ordered,je=Ne.start,Je=Ne.loose,ve=Ne.items.length,$e="",se=0;se<ve;se++)Ye=Ne.items[se],ct=Ye.checked,bt=Ye.task,ot="",Ye.task&&(mt=this.renderer.checkbox(ct),Je?Ye.tokens.length>0&&Ye.tokens[0].type==="text"?(Ye.tokens[0].text=mt+" "+Ye.tokens[0].text,Ye.tokens[0].tokens&&Ye.tokens[0].tokens.length>0&&Ye.tokens[0].tokens[0].type==="text"&&(Ye.tokens[0].tokens[0].text=mt+" "+Ye.tokens[0].tokens[0].text)):Ye.tokens.unshift({type:"text",text:mt}):ot+=mt),ot+=this.parse(Ye.tokens,Je),$e+=this.renderer.listitem(ot,bt,ct);Z+=this.renderer.list($e,st,je);continue}case"html":{Z+=this.renderer.html(Ne.text);continue}case"paragraph":{Z+=this.renderer.paragraph(this.parseInline(Ne.tokens));continue}case"text":{for($e=Ne.tokens?this.parseInline(Ne.tokens):Ne.text;q+1<Tt&&K[q+1].type==="text";)Ne=K[++q],$e+=`
`+(Ne.tokens?this.parseInline(Ne.tokens):Ne.text);Z+=j?this.renderer.paragraph($e):$e;continue}default:{var He='Token with "'+Ne.type+'" type was not found.';if(this.options.silent){console.error(He);return}else throw new Error(He)}}}return Z},te.parseInline=function(K,j){j=j||this.renderer;var Z="",q,se,de=K.length;for(q=0;q<de;q++){se=K[q];switch(se.type){case"escape":{Z+=j.text(se.text);break}case"html":{Z+=j.html(se.text);break}case"link":{Z+=j.link(se.href,se.title,this.parseInline(se.tokens,j));break}case"image":{Z+=j.image(se.href,se.title,se.text);break}case"strong":{Z+=j.strong(this.parseInline(se.tokens,j));break}case"em":{Z+=j.em(this.parseInline(se.tokens,j));break}case"codespan":{Z+=j.codespan(se.text);break}case"br":{Z+=j.br();break}case"del":{Z+=j.del(this.parseInline(se.tokens,j));break}case"text":{Z+=j.text(se.text);break}default:{var ve='Token with "'+se.type+'" type was not found.';if(this.options.silent){console.error(ve);return}else throw new Error(ve)}}}return Z},ie}(),De=E.merge,ke=E.checkSanitizeDeprecation,Ie=E.escape,xe=w.getDefaults,Fe=w.changeDefaults,Me=w.defaults;function pe(ie,te,re){if(typeof ie=="undefined"||ie===null)throw new Error("marked(): input parameter is undefined or null");if(typeof ie!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(ie)+", string expected");if(typeof te=="function"&&(re=te,te=null),te=De({},pe.defaults,te||{}),ke(te),re){var K=te.highlight,j;try{j=ue.lex(ie,te)}catch(de){return re(de)}var Z=function(ve){var Ue;if(!ve)try{Ue=Re.parse(j,te)}catch(Ge){ve=Ge}return te.highlight=K,ve?re(ve):re(null,Ue)};if(!K||K.length<3)return Z();if(delete te.highlight,!j.length)return Z();var q=0;pe.walkTokens(j,function(de){de.type==="code"&&(q++,setTimeout(function(){K(de.text,de.lang,function(ve,Ue){if(ve)return Z(ve);Ue!=null&&Ue!==de.text&&(de.text=Ue,de.escaped=!0),q--,q===0&&Z()})},0))}),q===0&&Z();return}try{var se=ue.lex(ie,te);return te.walkTokens&&pe.walkTokens(se,te.walkTokens),Re.parse(se,te)}catch(de){if(de.message+=`
Please report this to https://github.com/markedjs/marked.`,te.silent)return"<p>An error occurred:</p><pre>"+Ie(de.message+"",!0)+"</pre>";throw de}}pe.options=pe.setOptions=function(ie){return De(pe.defaults,ie),Fe(pe.defaults),pe},pe.getDefaults=xe,pe.defaults=Me,pe.use=function(ie){var te=De({},ie);if(ie.renderer&&function(){var K=pe.defaults.renderer||new Se,j=function(se){var de=K[se];K[se]=function(){for(var ve=arguments.length,Ue=new Array(ve),Ge=0;Ge<ve;Ge++)Ue[Ge]=arguments[Ge];var We=ie.renderer[se].apply(K,Ue);return We===!1&&(We=de.apply(K,Ue)),We}};for(var Z in ie.renderer)j(Z);te.renderer=K}(),ie.tokenizer&&function(){var K=pe.defaults.tokenizer||new Y,j=function(se){var de=K[se];K[se]=function(){for(var ve=arguments.length,Ue=new Array(ve),Ge=0;Ge<ve;Ge++)Ue[Ge]=arguments[Ge];var We=ie.tokenizer[se].apply(K,Ue);return We===!1&&(We=de.apply(K,Ue)),We}};for(var Z in ie.tokenizer)j(Z);te.tokenizer=K}(),ie.walkTokens){var re=pe.defaults.walkTokens;te.walkTokens=function(K){ie.walkTokens(K),re&&re(K)}}pe.setOptions(te)},pe.walkTokens=function(ie,te){for(var re=he(ie),K;!(K=re()).done;){var j=K.value;te(j);switch(j.type){case"table":{for(var Z=he(j.tokens.header),q;!(q=Z()).done;){var se=q.value;pe.walkTokens(se,te)}for(var de=he(j.tokens.cells),ve;!(ve=de()).done;)for(var Ue=ve.value,Ge=he(Ue),We;!(We=Ge()).done;){var it=We.value;pe.walkTokens(it,te)}break}case"list":{pe.walkTokens(j.items,te);break}default:j.tokens&&pe.walkTokens(j.tokens,te)}}},pe.Parser=Re,pe.parser=Re.parse,pe.Renderer=Se,pe.TextRenderer=Te,pe.Lexer=ue,pe.lexer=ue.lex,pe.Tokenizer=Y,pe.Slugger=Pe,pe.parse=pe;var Le=pe;return Le})},"8hTe":function(qe,Qe,fe){qe.exports={button:"button___1wy9m"}},"9Bee":function(qe,Qe,fe){"use strict";var et=fe("CDKA"),tt=fe("d7ih"),ze=fe("dLI4"),Ve=fe("4d5L"),he=fe("YaWb"),V=fe("IYef"),w=fe("Hqw+"),W=fe("XXmO"),P=fe.n(W),N=fe("T/Jt"),D=fe.n(N),G=fe("vg9a"),I=fe("7O0G"),R=fe.n(I),L=fe("GcTH");function _(A,t){var i=A.match(/^(\s+)(?:```)/);if(i===null)return t;var S=i[1];return t.split(`
`).map(function(B){var C=B.match(/^\s+/);if(C===null)return B;var $=Object(w.a)(C,1),ne=$[0];return ne.length>=S.length?B.slice(S.length):B}).join(`
`)}var T=[],g=["<ul>"],x=new R.a.Renderer,b=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function f(){T.length=0,g=["<ul>"]}var u={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function h(A,t,i,S){if(t>=A.length||A[t].level<=i)return t;var B=A[t];S.push("<li><a href='#"+B.anchor+"'>"+B.text+"</a>"),t++;var C=[];return t=h(A,t,B.level,C),C.length>0&&(S.push("<ul>"),C.forEach(function($){S.push($)}),S.push("</ul>")),S.push("</li>"),t=h(A,t,i,S),t}function o(){return h(T,0,0,g),g.push("</ul>"),g.join("")}var s={heading:function(t){var i=b.exec(t);if(i)return{type:"heading",raw:i[0],depth:i[1].length,text:i[2]}},fences:function(t){var i=this.rules.block.fences.exec(t);if(i){var S=i[0],B=_(S,i[3]||""),C=i[2]?i[2].trim():i[2];if(["latex","katex","math"].indexOf(C)>=0){var $=d(),ne=B;B=$,v[$]={type:"block",expression:ne}}return{type:"code",raw:S,lang:C,text:B}}}},l=/(?:\${2})([^\n`]+?)(?:\${2})/gi,n=0,d=function(){return"__special_katext_id_".concat(n++,"__")},v={};function p(){return v}function m(){n=0,v={}}function r(A){return A=A.replace(l,function(t,i){var S=d();return v[S]={type:"inline",expression:i},S}),A}var a=x.listitem;x.listitem=function(A){return a(r(A))};var e=x.paragraph;x.paragraph=function(A){return e(r(A))};var c=x.tablecell;x.tablecell=function(A,t){return c(r(A),t)},x.code=function(A,t,i){var S=(t||"").match(/\S*/)[0];return S?["latex","katex","math"].indexOf(S)>=0?"<p class='editormd-tex'>".concat(A,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(t,'">').concat(i?A:Object(L.escape)(A,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(i?A:Object(L.escape)(A,!0))+"</code></pre>"},x.heading=function(A,t,i){var S=this.options.headerPrefix+i.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return T.push({anchor:S,level:t,text:A}),"<h"+t+' id="'+S+'">'+A+"</h"+t+">"},R.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),R.a.use({tokenizer:s,renderer:x});var E=R.a,y=fe("SJMd"),k=fe("ulZh"),M=fe.n(k),O=fe("m3rI"),U=fe("Oy/b"),F=fe("p5ED"),H=fe("ErOA");/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Y=function(A,t){return(Y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,S){i.__proto__=S}||function(i,S){for(var B in S)Object.prototype.hasOwnProperty.call(S,B)&&(i[B]=S[B])})(A,t)};function Q(A,t){function i(){this.constructor=A}Y(A,t),A.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}function z(A,t,i,S){return new(i||(i=Promise))(function(B,C){function $(Oe){try{Ce(S.next(Oe))}catch(ce){C(ce)}}function ne(Oe){try{Ce(S.throw(Oe))}catch(ce){C(ce)}}function Ce(Oe){var ce;Oe.done?B(Oe.value):(ce=Oe.value,ce instanceof i?ce:new i(function(Be){Be(ce)})).then($,ne)}Ce((S=S.apply(A,t||[])).next())})}function ee(A,t){var i,S,B,C,$={label:0,sent:function(){if(1&B[0])throw B[1];return B[1]},trys:[],ops:[]};return C={next:ne(0),throw:ne(1),return:ne(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function ne(Ce){return function(Oe){return function(ce){if(i)throw new TypeError("Generator is already executing.");for(;$;)try{if(i=1,S&&(B=2&ce[0]?S.return:ce[0]?S.throw||((B=S.return)&&B.call(S),0):S.next)&&!(B=B.call(S,ce[1])).done)return B;switch(S=0,B&&(ce=[2&ce[0],B.value]),ce[0]){case 0:case 1:B=ce;break;case 4:return $.label++,{value:ce[1],done:!1};case 5:$.label++,S=ce[1],ce=[0];continue;case 7:ce=$.ops.pop(),$.trys.pop();continue;default:if(!(B=$.trys,(B=B.length>0&&B[B.length-1])||ce[0]!==6&&ce[0]!==2)){$=0;continue}if(ce[0]===3&&(!B||ce[1]>B[0]&&ce[1]<B[3])){$.label=ce[1];break}if(ce[0]===6&&$.label<B[1]){$.label=B[1],B=ce;break}if(B&&$.label<B[2]){$.label=B[2],$.ops.push(ce);break}B[2]&&$.ops.pop(),$.trys.pop();continue}ce=t.call(A,$)}catch(Be){ce=[6,Be],S=0}finally{i=B=0}if(5&ce[0])throw ce[1];return{value:ce[0]?ce[1]:void 0,done:!0}}([Ce,Oe])}}}function J(){for(var A=0,t=0,i=arguments.length;t<i;t++)A+=arguments[t].length;var S=Array(A),B=0;for(t=0;t<i;t++)for(var C=arguments[t],$=0,ne=C.length;$<ne;$++,B++)S[B]=C[$];return S}var X=function(){function A(){}return A.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},A.setAttributes=function(t,i){for(var S=0,B=i;S<B.length;S++){var C=B[S],$=C[0],ne=C[1];t.setAttribute($,ne)}},A.createRect=function(t,i,S){var B=document.createElementNS("http://www.w3.org/2000/svg","rect");return B.setAttribute("width",t.toString()),B.setAttribute("height",i.toString()),S&&A.setAttributes(B,S),B},A.createLine=function(t,i,S,B,C){var $=document.createElementNS("http://www.w3.org/2000/svg","line");return $.setAttribute("x1",t.toString()),$.setAttribute("y1",i.toString()),$.setAttribute("x2",S.toString()),$.setAttribute("y2",B.toString()),C&&A.setAttributes($,C),$},A.createPolygon=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","polygon");return S.setAttribute("points",t),i&&A.setAttributes(S,i),S},A.createCircle=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","circle");return S.setAttribute("cx",(t/2).toString()),S.setAttribute("cy",(t/2).toString()),S.setAttribute("r",t.toString()),i&&A.setAttributes(S,i),S},A.createEllipse=function(t,i,S){var B=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return B.setAttribute("cx",(t/2).toString()),B.setAttribute("cy",(i/2).toString()),B.setAttribute("rx",(t/2).toString()),B.setAttribute("ry",(i/2).toString()),S&&A.setAttributes(B,S),B},A.createGroup=function(t){var i=document.createElementNS("http://www.w3.org/2000/svg","g");return t&&A.setAttributes(i,t),i},A.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},A.createMarker=function(t,i,S,B,C,$,ne){var Ce=document.createElementNS("http://www.w3.org/2000/svg","marker");return A.setAttributes(Ce,[["id",t],["orient",i],["markerWidth",S.toString()],["markerHeight",B.toString()],["refX",C.toString()],["refY",$.toString()]]),Ce.appendChild(ne),Ce},A.createText=function(t){var i=document.createElementNS("http://www.w3.org/2000/svg","text");return i.setAttribute("x","0"),i.setAttribute("y","0"),t&&A.setAttributes(i,t),i},A.createTSpan=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","tspan");return S.textContent=t,i&&A.setAttributes(S,i),S},A.createImage=function(t){var i=document.createElementNS("http://www.w3.org/2000/svg","image");return t&&A.setAttributes(i,t),i},A.createPoint=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return S.x=t,S.y=i,S},A.createPath=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","path");return S.setAttribute("d",t),i&&A.setAttributes(S,i),S},A}(),oe=function(){function A(){}return A.addKey=function(t){A.key=t},Object.defineProperty(A,"isLicensed",{get:function(){return!!A.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(A.key)},enumerable:!1,configurable:!0}),A}(),le=function(){function A(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return A.prototype.rasterize=function(t,i,S){var B=this;return new Promise(function(C){var $=S!==void 0?S:document.createElement("canvas");t===null&&(B.markersOnly=!0,B.naturalSize=!1);var ne=document.createElementNS("http://www.w3.org/2000/svg","svg");ne.setAttribute("xmlns","http://www.w3.org/2000/svg"),ne.setAttribute("width",i.width.baseVal.valueAsString),ne.setAttribute("height",i.height.baseVal.valueAsString),ne.setAttribute("viewBox","0 0 "+i.viewBox.baseVal.width.toString()+" "+i.viewBox.baseVal.height.toString()),ne.innerHTML=i.innerHTML,B.naturalSize===!0?(ne.width.baseVal.value=t.naturalWidth,ne.height.baseVal.value=t.naturalHeight):B.width!==void 0&&B.height!==void 0&&(ne.width.baseVal.value=B.width,ne.height.baseVal.value=B.height),$.width=ne.width.baseVal.value,$.height=ne.height.baseVal.value;var Ce=ne.outerHTML,Oe=$.getContext("2d");B.markersOnly!==!0&&Oe.drawImage(t,0,0,$.width,$.height);var ce=window.URL,Be=new Image($.width,$.height);Be.setAttribute("crossOrigin","anonymous");var Ke=new Blob([Ce],{type:"image/svg+xml"}),nt=ce.createObjectURL(Ke);Be.onload=function(){Oe.drawImage(Be,0,0),ce.revokeObjectURL(nt);var yt=$.toDataURL(B.imageType,B.imageQuality);C(yt)},Be.src=nt})},A}(),me=function(){},Ae=function(){function A(t){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+t+"_"}return Object.defineProperty(A.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),A.prototype.addClass=function(t){return this.styleSheet===void 0&&this.addStyleSheet(),t.name=""+this.classNamePrefix+t.localName,this.classes.push(t),this.styleSheet.sheet.insertRule("."+t.name+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length),t},A.prototype.addRule=function(t){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(t),this.styleSheet.sheet.insertRule(t.selector+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length)},A.prototype.addStyleSheet=function(){var t;this.styleSheet=document.createElement("style"),((t=this.styleSheetRoot)!==null&&t!==void 0?t:document.head).appendChild(this.styleSheet),this.addRule(new ge("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new ge("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new ge("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new ae("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new ae("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},A.prototype.removeStyleSheet=function(){var t;this.styleSheet&&(((t=this.styleSheetRoot)!==null&&t!==void 0?t:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},A}(),ge=function(A,t){this.selector=A,this.style=t},ae=function(A,t){this.localName=A,this.style=t},ue=function(){function A(t,i,S,B,C){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=t,this.displayMode=i,this.markerItems=S,this.uiStyleSettings=B,this.styles=C,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return A.prototype.show=function(t){var i=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=t,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var S=document.createElement("div");S.className=this.toolbarBlockStyleClass.name,S.style.whiteSpace="nowrap",this.uiContainer.appendChild(S),this.addActionButton(S,'<svg viewBox="0 0 24 24"><path d="M10.07 14.27a.997.997 0 011.33.48l2.3 4.99 1.8-.85-2.31-4.98c-.24-.5-.02-1.1.48-1.33l.28-.08 2.3-.45L8 5.12V15.9l1.82-1.47.25-.16m3.57 7.7a.99.99 0 01-1.33-.47l-2.18-4.74-2.51 2.02c-.17.14-.38.22-.62.22a1 1 0 01-1-1V3a1 1 0 011-1c.24 0 .47.09.64.23l.01-.01 11.49 9.64a1.001 1.001 0 01-.44 1.75l-3.16.62 2.2 4.73c.26.5.02 1.09-.48 1.32l-3.62 1.69z"/></svg>',"select","Select mode"),this.addActionButton(S,'<svg viewBox="0 0 24 24"><path d="M9 3v1H4v2h1v13a2 2 0 002 2h10a2 2 0 002-2V6h1V4h-5V3H9M7 6h10v13H7V6m2 2v9h2V8H9m4 0v9h2V8h-2z"/></svg>',"delete","Delete marker"),this.uiStyleSettings.clearButtonVisible&&this.addActionButton(S,'<svg viewBox="0 0 24 24"><path d="M19.36 2.72l1.42 1.42-5.72 5.71c1.07 1.54 1.22 3.39.32 4.59L9.06 8.12c1.2-.9 3.05-.75 4.59.32l5.71-5.72M5.93 17.57c-2.01-2.01-3.24-4.41-3.58-6.65l4.88-2.09 7.44 7.44-2.09 4.88c-2.24-.34-4.64-1.57-6.65-3.58z"/></svg>',"clear","Delete all markers"),this.uiStyleSettings.undoButtonVisible&&this.addActionButton(S,'<svg viewBox="0 0 24 24"><path d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',"undo","Undo"),this.uiStyleSettings.redoButtonVisible&&this.addActionButton(S,'<svg viewBox="0 0 24 24"><path d="M18.4 10.6C16.55 9 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 017.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',"redo","Redo"),this.uiStyleSettings.zoomButtonVisible&&this.addActionButton(S,'<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"zoom","Zoom in"),this.uiStyleSettings.zoomButtonVisible&&this.uiStyleSettings.zoomOutButtonVisible&&this.addActionButton(S,'<svg viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 009.5 3 6.5 6.5 0 003 9.5 6.5 6.5 0 009.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 5 1.5-1.5-5-5m-6 0C7 14 5 12 5 9.5S7 5 9.5 5 14 7 14 9.5 12 14 9.5 14M7 9h5v1H7V9z"/></svg>',"zoom-out","Zoom out"),this.uiStyleSettings.notesButtonVisible&&this.addActionButton(S,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes","Notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach(function(C){var $=document.createElement("div");$.className=""+i.toolbarButtonStyleClass.name,$.setAttribute("data-type-name",C.typeName),$.setAttribute("aria-label",C.title),$.setAttribute("title",C.title),$.innerHTML=C.icon,$.addEventListener("click",function(){i.markerToolbarButtonClicked($,C)}),i.buttons.push($),i.markerButtons.push($)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var B=document.createElement("div");B.className=this.toolbarBlockStyleClass.name,B.style.whiteSpace="nowrap",B.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(B),this.addActionButton(B,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render","Save and close"),this.addActionButton(B,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close","Close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},A.prototype.addButtonClickListener=function(t){this.buttonClickListeners.push(t)},A.prototype.removeButtonClickListener=function(t){this.buttonClickListeners.indexOf(t)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(t),1)},A.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},A.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var t=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var i=0;i<this.markerButtons.length;i++)i<t||i===t&&this.markerButtons.length-1===t?this.markerButtonBlock.appendChild(this.markerButtons[i]):(i===t&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[i]))}},A.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},A.prototype.resetButtonStyles=function(){var t=this;this.buttons.forEach(function(i){i.className=i.className.replace(t.uiStyleSettings.toolbarButtonStyleColorsClassName?t.uiStyleSettings.toolbarButtonStyleColorsClassName:t.toolbarButtonStyleColorsClass.name,"").trim(),i.className=i.className.replace(t.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?t.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:t.toolbarActiveButtonStyleColorsClass.name,"").trim(),i.className+=" "+(t.uiStyleSettings.toolbarButtonStyleColorsClassName?t.uiStyleSettings.toolbarButtonStyleColorsClassName:t.toolbarButtonStyleColorsClass.name)})},A.prototype.addActionButton=function(t,i,S,B){var C=this,$=document.createElement("div");switch($.className=""+this.toolbarButtonStyleClass.name,$.innerHTML=i,$.setAttribute("role","button"),$.setAttribute("data-action",S),$.title=B,$.setAttribute("aria-label",B),$.addEventListener("click",function(){C.actionToolbarButtonClicked($,S)}),S){case"select":$.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":$.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":$.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":$.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":$.style.fill=this.uiStyleSettings.closeButtonColor}t.appendChild($),this.buttons.push($)},A.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new ae("toolbar",`
width: 100%;
flex-shrink: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
height: `+this.uiStyleSettings.toolbarHeight+`px;
box-sizing: content-box;
`+(this.displayMode==="inline"?"border-top-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
`+(this.displayMode==="inline"?"border-top-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
overflow: hidden;
`)),this.toolbarStyleColorsClass=this.styles.addClass(new ae("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new ae("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new ae("toolbar-overflow-block",`
position: absolute;
top: `+this.uiStyleSettings.toolbarHeight+`px;
max-width: `+2*this.uiStyleSettings.toolbarHeight+`px;
z-index: 10;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleColorsClass=this.styles.addClass(new ae("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var t=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new ae("toolbar_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*t)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*t)+`px;
padding: `+t+`px;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new ae("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new ae("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new ge("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new ge("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},A.prototype.markerToolbarButtonClicked=function(t,i){this.setActiveButton(t),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(S){return S("marker",i)}),this.markerButtonOverflowBlock.style.display="none"},A.prototype.actionToolbarButtonClicked=function(t,i){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(S){return S("action",i)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},A.prototype.setActiveButton=function(t){this.resetButtonStyles(),t.className=t.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),t.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},A.prototype.setActiveMarkerButton=function(t){var i=this.markerButtons.find(function(S){return S.getAttribute("data-type-name")===t});i&&this.setActiveButton(i)},A.prototype.setCurrentMarker=function(t){var i=this;this.currentMarker=t,this.buttons.filter(function(S){return/delete|notes/.test(S.getAttribute("data-action"))}).forEach(function(S){i.currentMarker===void 0?(S.style.fillOpacity="0.4",S.style.pointerEvents="none"):(S.style.fillOpacity="1",S.style.pointerEvents="all")})},A}(),ye=function(){function A(t,i,S,B){this.panels=[],this.panelButtons=[],this.markerjsContainer=t,this.displayMode=i,this.uiStyleSettings=S,this.styles=B,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return A.prototype.addStyles=function(){var t;this.toolboxStyleClass=this.styles.addClass(new ae("toolbox",`
width: 100%;
flex-shrink: 0;
display: flex;
flex-direction: column;
font-family: sans-serif;
`+(this.displayMode==="popup"?"height:"+2.5*this.uiStyleSettings.toolbarHeight+"px;":"")+`
box-sizing: content-box;
`+(this.displayMode==="popup"?"background-color: "+this.uiStyleSettings.canvasBackgroundColor+";":"")+`
`+(this.displayMode==="inline"?"border-bottom-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
`+(this.displayMode==="inline"?"border-bottom-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
overflow: hidden;
`)),this.toolboxStyleColorsClass=this.styles.addClass(new ae("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var i=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new ae("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new ae("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new ae("toolbox-panel-row",`
display: flex;
`+(this.displayMode==="inline"?"position: absolute;":"")+`
`+(this.displayMode==="inline"?"bottom: "+this.uiStyleSettings.toolbarHeight+"px;":"")+`
cursor: default;
height: `+1.5*this.uiStyleSettings.toolbarHeight+`px;
`+(this.displayMode==="inline"?"width: 100%;":"")+`
box-sizing: content-box;
`)),this.toolboxPanelRowStyleColorsClass=this.styles.addClass(new ae("toolbox-panel-row_colors",`
background-color: `+((t=this.uiStyleSettings.toolboxBackgroundColor)!==null&&t!==void 0?t:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new ae("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*i)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*i)+`px;
padding: `+i+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new ae("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new ae("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new ge("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new ge("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new ge("."+this.toolboxPanelRowStyleClass.name+" > div",`
scrollbar-width: thin;
`)),this.styles.addRule(new ge("."+this.toolboxPanelRowStyleClass.name+" > div::-webkit-scrollbar",`
height: 10px;
width: 10px;
`)),this.styles.addRule(new ge("."+this.toolboxPanelRowStyleClass.name+" > div::-webkit-scrollbar-track",`
background-color: transparent;
`)),this.styles.addRule(new ge("."+this.toolboxPanelRowStyleClass.name+" > div::-webkit-scrollbar-thumb",`
background-color: #444;
border-radius: 20px;
border: 2px solid #aaa;
`))},A.prototype.show=function(t){var i;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=t,this.uiContainer.className=this.toolboxStyleClass.name+" "+((i=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&i!==void 0?i:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},A.prototype.setPanelButtons=function(t){var i,S,B=this;this.panels=t,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((i=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&i!==void 0?i:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((S=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&S!==void 0?S:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(C){var $;C.uiStyleSettings=B.uiStyleSettings;var ne=document.createElement("div");ne.className=B.toolboxButtonStyleClass.name+" "+(($=B.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&$!==void 0?$:B.toolboxButtonStyleColorsClass.name),ne.innerHTML=C.icon,ne.title=C.title,ne.setAttribute("role","button"),ne.setAttribute("aria-label",C.title),C.id&&ne.setAttribute("data-action",C.id),ne.addEventListener("click",function(){B.panelButtonClick(C)}),B.panelButtons.push(ne),B.buttonRow.appendChild(ne)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},A.prototype.panelButtonClick=function(t){var i=this,S=-1;if(t!==this.activePanel){S=this.panels.indexOf(t),this.panelRow.innerHTML="";var B=t.getUi();B.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(B),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=t}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){i.displayMode==="inline"?i.panelRow.style.display="none":i.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(C,$){var ne,Ce;C.className=i.toolboxButtonStyleClass.name+" "+($===S?""+((ne=i.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&ne!==void 0?ne:i.toolboxActiveButtonStyleColorsClass.name):""+((Ce=i.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Ce!==void 0?Ce:i.toolboxButtonStyleColorsClass.name))})},A}(),Ee=function(){function A(t,i,S){this.title=t,this.icon=i,this._id=S}return Object.defineProperty(A.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),A}(),_e=function(A){function t(i,S,B,C,$){var ne=A.call(this,i,C||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>',$||"color-picker-panel")||this;return ne.colors=[],ne.addTransparent=!1,ne.colorBoxes=[],ne.colors=S,ne.currentColor=B,ne.setCurrentColor=ne.setCurrentColor.bind(ne),ne.getColorBox=ne.getColorBox.bind(ne),ne}return Q(t,A),t.prototype.getUi=function(){var i=this,S=document.createElement("div");return S.style.overflow="hidden",S.style.overflowX="auto",S.style.whiteSpace="nowrap",this.colors.forEach(function(B){var C=i.getColorBox(B);S.appendChild(C),i.colorBoxes.push(C)}),S},t.prototype.getColorBox=function(i){var S=this,B=this.uiStyleSettings.toolbarHeight/4,C=this.uiStyleSettings.toolbarHeight-B,$=document.createElement("div");$.style.display="inline-block",$.style.boxSizing="content-box",$.style.width=C-2+"px",$.style.height=C-2+"px",$.style.padding="1px",$.style.marginRight="2px",$.style.marginBottom="2px",$.style.borderWidth="2px",$.style.borderStyle="solid",$.style.borderRadius=(C+2)/2+"px",$.style.borderColor=i===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",$.addEventListener("click",function(){S.setCurrentColor(i,$)});var ne=document.createElement("div");return ne.style.display="inline-block",ne.style.width=C-2+"px",ne.style.height=C-2+"px",ne.style.backgroundColor=i,ne.style.borderRadius=C/2+"px",i==="transparent"&&(ne.style.fill=this.uiStyleSettings.toolboxAccentColor,ne.innerHTML=`<svg viewBox="0 0 24 24">
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
</svg>`),$.appendChild(ne),$},t.prototype.setCurrentColor=function(i,S){var B=this;this.currentColor=i,this.colorBoxes.forEach(function(C){C.style.borderColor=C===S?B.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(i)},t}(Ee),Se=function(){function A(t,i,S){this._state="new",this._isSelected=!1,this._container=t,this._overlayContainer=i,this.globalSettings=S,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(A.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),A.prototype.ownsTarget=function(t){return!1},Object.defineProperty(A.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),A.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},A.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},A.prototype.pointerDown=function(t,i){},A.prototype.dblClick=function(t,i){},A.prototype.manipulate=function(t){},A.prototype.pointerUp=function(t){this.stateChanged()},A.prototype.dispose=function(){},A.prototype.addMarkerVisualToContainer=function(t){this.container.childNodes.length>0?this.container.insertBefore(t,this.container.childNodes[0]):this.container.appendChild(t)},A.prototype.getState=function(){return{typeName:A.typeName,state:this.state,notes:this.notes}},A.prototype.restoreState=function(t){this._state=t.state,this.notes=t.notes},A.prototype.scale=function(t,i){},A.prototype.colorChanged=function(t){this.onColorChanged&&this.onColorChanged(t),this.stateChanged()},A.prototype.fillColorChanged=function(t){this.onFillColorChanged&&this.onFillColorChanged(t),this.stateChanged()},A.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var t=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),t.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(t)&&this.onStateChanged(this)}},A.typeName="MarkerBase",A}(),Te=function(){function A(){this.findGripByVisual=this.findGripByVisual.bind(this)}return A.prototype.findGripByVisual=function(t){return this.topLeft.ownsTarget(t)?this.topLeft:this.topCenter.ownsTarget(t)?this.topCenter:this.topRight.ownsTarget(t)?this.topRight:this.centerLeft.ownsTarget(t)?this.centerLeft:this.centerRight.ownsTarget(t)?this.centerRight:this.bottomLeft.ownsTarget(t)?this.bottomLeft:this.bottomCenter.ownsTarget(t)?this.bottomCenter:this.bottomRight.ownsTarget(t)?this.bottomRight:void 0},A}(),Pe=function(){function A(){this.GRIP_SIZE=10,this.visual=X.createGroup(),this.visual.appendChild(X.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(X.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return A.prototype.ownsTarget=function(t){return t===this.visual||t===this.visual.childNodes[0]||t===this.visual.childNodes[1]},A}(),we=function(){function A(){}return A.toITransformMatrix=function(t){return{a:t.a,b:t.b,c:t.c,d:t.d,e:t.e,f:t.f}},A.toSVGMatrix=function(t,i){return t.a=i.a,t.b=i.b,t.c=i.c,t.d=i.d,t.e=i.e,t.f=i.f,t},A}(),be=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.left=0,C.top=0,C.width=0,C.height=0,C.defaultSize={x:50,y:20},C.offsetX=0,C.offsetY=0,C.rotationAngle=0,C.CB_DISTANCE=10,C._suppressMarkerCreateEvent=!1,C.container.transform.baseVal.appendItem(X.createTransform()),C.setupControlBox(),C}return Q(t,A),Object.defineProperty(t.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visual",{get:function(){return this._visual},set:function(i){this._visual=i;var S=X.createTransform();this._visual.transform.baseVal.appendItem(S)},enumerable:!1,configurable:!0}),t.prototype.ownsTarget=function(i){return!!A.prototype.ownsTarget.call(this,i)||!!(this.controlGrips.findGripByVisual(i)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(i))},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.state==="new"&&(this.left=i.x,this.top=i.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var B=this.unrotatePoint(i);if(this.manipulationStartX=B.x,this.manipulationStartY=B.y,this.offsetX=B.x-this.left,this.offsetY=B.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(S),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(S)){this.activeGrip=this.rotatorGrip;var C=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=C.x-this.width/2,this.top=C.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var $=this.container.transform.baseVal.getItem(0);$.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem($,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},t.prototype.pointerUp=function(i){var S=this.state;A.prototype.pointerUp.call(this,i),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(i),this._state="select",S==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},t.prototype.moveVisual=function(i){this.visual.style.transform="translate("+i.x+"px, "+i.y+"px)"},t.prototype.manipulate=function(i){var S=this.unrotatePoint(i);this.state==="creating"?this.resize(i):this.state==="move"?(this.left=this.manipulationStartLeft+(S.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(S.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(S):this.state==="rotate"&&this.rotate(i)},t.prototype.resize=function(i){var S=this.manipulationStartLeft,B=this.manipulationStartWidth,C=this.manipulationStartTop,$=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:S=this.manipulationStartLeft+i.x-this.manipulationStartX,B=this.manipulationStartWidth+this.manipulationStartLeft-S;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:B=this.manipulationStartWidth+i.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:C=this.manipulationStartTop+i.y-this.manipulationStartY,$=this.manipulationStartHeight+this.manipulationStartTop-C;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:$=this.manipulationStartHeight+i.y-this.manipulationStartY}B>=0?(this.left=S,this.width=B):(this.left=S+B,this.width=-B),$>=0?(this.top=C,this.height=$):(this.top=C+$,this.height=-$),this.setSize()},t.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},t.prototype.rotate=function(i){if(Math.abs(i.x-this.centerX)>.1){var S=Math.sign(i.x-this.centerX);this.rotationAngle=180*Math.atan((i.y-this.centerY)/(i.x-this.centerX))/Math.PI+90*S,this.applyRotation()}},t.prototype.applyRotation=function(){var i=this.container.transform.baseVal.getItem(0);i.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(i,0)},t.prototype.rotatePoint=function(i){if(this.rotationAngle===0)return i;var S=this.container.getCTM(),B=X.createPoint(i.x,i.y);return{x:(B=B.matrixTransform(S)).x,y:B.y}},t.prototype.unrotatePoint=function(i){if(this.rotationAngle===0)return i;var S=this.container.getCTM();S=S.inverse();var B=X.createPoint(i.x,i.y);return{x:(B=B.matrixTransform(S)).x,y:B.y}},t.prototype.select=function(){A.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},t.prototype.deselect=function(){A.prototype.deselect.call(this),this.controlBox.style.display="none"},t.prototype.setupControlBox=function(){this.controlBox=X.createGroup();var i=X.createTransform();i.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(i),this.container.appendChild(this.controlBox),this.controlRect=X.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=X.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new Te,this.addControlGrips(),this.controlBox.style.display="none"},t.prototype.adjustControlBox=function(){var i=this.controlBox.transform.baseVal.getItem(0);i.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(i,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},t.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},t.prototype.createGrip=function(){var i=new Pe;return i.visual.transform.baseVal.appendItem(X.createTransform()),this.controlBox.appendChild(i.visual),i},t.prototype.positionGrips=function(){var i=this.controlGrips.topLeft.GRIP_SIZE,S=-i/2,B=S,C=(this.width+this.CB_DISTANCE)/2-i/2,$=(this.height+this.CB_DISTANCE)/2-i/2,ne=this.height+this.CB_DISTANCE-i/2,Ce=this.width+this.CB_DISTANCE-i/2;this.positionGrip(this.controlGrips.topLeft.visual,S,B),this.positionGrip(this.controlGrips.topCenter.visual,C,B),this.positionGrip(this.controlGrips.topRight.visual,Ce,B),this.positionGrip(this.controlGrips.centerLeft.visual,S,$),this.positionGrip(this.controlGrips.centerRight.visual,Ce,$),this.positionGrip(this.controlGrips.bottomLeft.visual,S,ne),this.positionGrip(this.controlGrips.bottomCenter.visual,C,ne),this.positionGrip(this.controlGrips.bottomRight.visual,Ce,ne),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,C,B-3*this.CB_DISTANCE)},t.prototype.positionGrip=function(i,S,B){var C=i.transform.baseVal.getItem(0);C.setTranslate(S,B),i.transform.baseVal.replaceItem(C,0)},t.prototype.hideControlBox=function(){this.controlBox.style.display="none"},t.prototype.showControlBox=function(){this.controlBox.style.display=""},t.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:we.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:we.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},A.prototype.getState.call(this))},t.prototype.restoreState=function(i){A.prototype.restoreState.call(this,i);var S=i;this.left=S.left,this.top=S.top,this.width=S.width,this.height=S.height,this.rotationAngle=S.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(we.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,S.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(we.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,S.containerTransformMatrix))},t.prototype.scale=function(i,S){A.prototype.scale.call(this,i,S);var B=this.rotatePoint({x:this.left,y:this.top}),C=this.unrotatePoint({x:B.x*i,y:B.y*S});this.left=C.x,this.top=C.y,this.width=this.width*i,this.height=this.height*S,this.adjustControlBox()},t}(Se),Re=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.fillColor="transparent",C.strokeColor="transparent",C.strokeWidth=0,C.strokeDasharray="",C.opacity=1,C.setStrokeColor=C.setStrokeColor.bind(C),C.setFillColor=C.setFillColor.bind(C),C.setStrokeWidth=C.setStrokeWidth.bind(C),C.setStrokeDasharray=C.setStrokeDasharray.bind(C),C.createVisual=C.createVisual.bind(C),C}return Q(t,A),t.prototype.ownsTarget=function(i){return!(!A.prototype.ownsTarget.call(this,i)&&i!==this.visual)},t.prototype.createVisual=function(){this.visual=X.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.state==="new"&&(this.createVisual(),this.moveVisual(i),this._state="creating")},t.prototype.manipulate=function(i){A.prototype.manipulate.call(this,i)},t.prototype.resize=function(i){A.prototype.resize.call(this,i),this.setSize()},t.prototype.setSize=function(){A.prototype.setSize.call(this),X.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},t.prototype.pointerUp=function(i){A.prototype.pointerUp.call(this,i),this.setSize()},t.prototype.setStrokeColor=function(i){this.strokeColor=i,this.visual&&X.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(i),this.stateChanged()},t.prototype.setFillColor=function(i){this.fillColor=i,this.visual&&X.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},t.prototype.setStrokeWidth=function(i){this.strokeWidth=i,this.visual&&X.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},t.prototype.setStrokeDasharray=function(i){this.strokeDasharray=i,this.visual&&X.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},t.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},A.prototype.getState.call(this))},t.prototype.restoreState=function(i){var S=i;this.fillColor=S.fillColor,this.strokeColor=S.strokeColor,this.strokeWidth=S.strokeWidth,this.strokeDasharray=S.strokeDasharray,this.opacity=S.opacity,this.createVisual(),A.prototype.restoreState.call(this,i),this.setSize()},t.prototype.scale=function(i,S){A.prototype.scale.call(this,i,S),this.setSize()},t.title="Rectangle marker",t}(be),De=function(A){function t(i,S,B,C,$){var ne=A.call(this,i,C||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>',$||"line-width-panel")||this;return ne.widths=[],ne.widthBoxes=[],ne.widths=S,ne.currentWidth=B,ne.setCurrentWidth=ne.setCurrentWidth.bind(ne),ne}return Q(t,A),t.prototype.getUi=function(){var i=this,S=document.createElement("div");return S.style.display="flex",S.style.overflow="hidden",S.style.flexGrow="2",this.widths.forEach(function(B){var C=document.createElement("div");C.style.display="flex",C.style.flexGrow="2",C.style.alignItems="center",C.style.justifyContent="space-between",C.style.padding="5px",C.style.borderWidth="2px",C.style.borderStyle="solid",C.style.borderColor=B===i.currentWidth?i.uiStyleSettings.toolboxAccentColor:"transparent",C.addEventListener("click",function(){i.setCurrentWidth(B,C)}),S.appendChild(C);var $=document.createElement("div");$.innerText=B.toString(),$.style.marginRight="5px",C.appendChild($);var ne=document.createElement("div");ne.style.minHeight="20px",ne.style.flexGrow="2",ne.style.display="flex",ne.style.alignItems="center";var Ce=document.createElement("hr");Ce.style.minWidth="20px",Ce.style.border="0px",Ce.style.borderTop=B+"px solid "+i.uiStyleSettings.toolboxColor,Ce.style.flexGrow="2",ne.appendChild(Ce),C.appendChild(ne),i.widthBoxes.push(C)}),S},t.prototype.setCurrentWidth=function(i,S){var B=this;this.currentWidth=i,this.widthBoxes.forEach(function(C){C.style.borderColor=C===S?B.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},t}(Ee),ke=function(A){function t(i,S,B,C,$){var ne=A.call(this,i,C||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>',$||"line-style-panel")||this;return ne.styles=[],ne.styleBoxes=[],ne.styles=S,ne.currentStyle=B,ne.setCurrentStyle=ne.setCurrentStyle.bind(ne),ne}return Q(t,A),t.prototype.getUi=function(){var i=this,S=document.createElement("div");return S.style.display="flex",S.style.overflow="hidden",S.style.flexGrow="2",this.styles.forEach(function(B){var C=document.createElement("div");C.style.display="flex",C.style.alignItems="center",C.style.justifyContent="space-between",C.style.padding="5px",C.style.borderWidth="2px",C.style.borderStyle="solid",C.style.overflow="hidden",C.style.maxWidth=100/i.styles.length-5+"%",C.style.borderColor=B===i.currentStyle?i.uiStyleSettings.toolboxAccentColor:"transparent",C.addEventListener("click",function(){i.setCurrentStyle(B,C)}),S.appendChild(C);var $=document.createElement("div");$.style.minHeight="20px",$.style.flexGrow="2",$.style.overflow="hidden";var ne=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+i.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(B!==""?'stroke-dasharray="'+B+'"':"")+` />
</svg>`;$.innerHTML=ne,C.appendChild($),i.styleBoxes.push(C)}),S},t.prototype.setCurrentStyle=function(i,S){var B=this;this.currentStyle=i,this.styleBoxes.forEach(function(C){C.style.borderColor=C===S?B.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},t}(Ee),Ie=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.strokeColor=B.defaultColor,C.strokeWidth=B.defaultStrokeWidth,C.strokeDasharray=B.defaultStrokeDasharray,C.strokePanel=new _e("Line color",B.defaultColorSet,B.defaultColor),C.strokePanel.onColorChanged=C.setStrokeColor,C.strokeWidthPanel=new De("Line width",B.defaultStrokeWidths,B.defaultStrokeWidth),C.strokeWidthPanel.onWidthChanged=C.setStrokeWidth,C.strokeStylePanel=new ke("Line style",B.defaultStrokeDasharrays,B.defaultStrokeDasharray),C.strokeStylePanel.onStyleChanged=C.setStrokeDasharray,C}return Q(t,A),Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=A.prototype.getState.call(this);return i.typeName=t.typeName,i},t.typeName="FrameMarker",t.title="Frame marker",t.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',t}(Re),xe=function(){this.defaultColorSet=["#EF4444","#10B981","#2563EB","#FFFF00","#7C3AED","#F472B6","#000000","#FFFFFF"],this.defaultColor=this.defaultColorSet[0],this.defaultFillColor=this.defaultColorSet[0],this.defaultStrokeColor=this.defaultColorSet[7],this.defaultHighlightColor=this.defaultColorSet[3],this.defaultStrokeWidth=3,this.defaultStrokeDasharray="",this.defaultHighlightOpacity=.5,this.defaultFontFamily="Helvetica, Arial, sans-serif",this.defaultStrokeWidths=[1,2,3,5,10],this.defaultStrokeDasharrays=["","3","12 3","9 6 3 6"],this.defaultOpacitySteps=[.1,.25,.5,.75,1],this.displayMode="inline",this.defaultFontFamilies=['Times, "Times New Roman", serif',"Helvetica, Arial, sans-serif",'Courier, "Courier New", monospace',"cursive","fantasy"],this.popupMargin=30,this.newFreehandMarkerOnPointerUp=!1,this.defaultColorsFollowCurrentColors=!1,this.freehandPixelRatio=1,this.disableRotation=!1,this.defaultCaptionFontSize="1rem",this.defaultCaptionText="Text",this.wrapText=!1,this.defaultText="Your text here"},Fe=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.x1=0,C.y1=0,C.x2=0,C.y2=0,C.defaultLength=50,C.manipulationStartX=0,C.manipulationStartY=0,C.manipulationStartX1=0,C.manipulationStartY1=0,C.manipulationStartX2=0,C.manipulationStartY2=0,C.setupControlBox(),C}return Q(t,A),t.prototype.ownsTarget=function(i){return!!A.prototype.ownsTarget.call(this,i)||!(!this.grip1.ownsTarget(i)&&!this.grip2.ownsTarget(i))},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.manipulationStartX=i.x,this.manipulationStartY=i.y,this.state==="new"&&(this.x1=i.x,this.y1=i.y,this.x2=i.x,this.y2=i.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(S)?this.activeGrip=this.grip1:this.grip2.ownsTarget(S)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},t.prototype.pointerUp=function(i){var S=this.state;A.prototype.pointerUp.call(this,i),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(i),this._state="select",S==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},t.prototype.adjustVisual=function(){},t.prototype.manipulate=function(i){this.state==="creating"?this.resize(i):this.state==="move"?(this.x1=this.manipulationStartX1+i.x-this.manipulationStartX,this.y1=this.manipulationStartY1+i.y-this.manipulationStartY,this.x2=this.manipulationStartX2+i.x-this.manipulationStartX,this.y2=this.manipulationStartY2+i.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(i)},t.prototype.resize=function(i){switch(this.activeGrip){case this.grip1:this.x1=i.x,this.y1=i.y;break;case this.grip2:case void 0:this.x2=i.x,this.y2=i.y}this.adjustVisual(),this.adjustControlBox()},t.prototype.select=function(){A.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},t.prototype.deselect=function(){A.prototype.deselect.call(this),this.controlBox.style.display="none"},t.prototype.setupControlBox=function(){this.controlBox=X.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},t.prototype.adjustControlBox=function(){this.positionGrips()},t.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},t.prototype.createGrip=function(){var i=new Pe;return i.visual.transform.baseVal.appendItem(X.createTransform()),this.controlBox.appendChild(i.visual),i},t.prototype.positionGrips=function(){var i=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-i/2,this.y1-i/2),this.positionGrip(this.grip2.visual,this.x2-i/2,this.y2-i/2)},t.prototype.positionGrip=function(i,S,B){var C=i.transform.baseVal.getItem(0);C.setTranslate(S,B),i.transform.baseVal.replaceItem(C,0)},t.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},A.prototype.getState.call(this))},t.prototype.restoreState=function(i){A.prototype.restoreState.call(this,i);var S=i;this.x1=S.x1,this.y1=S.y1,this.x2=S.x2,this.y2=S.y2},t.prototype.scale=function(i,S){A.prototype.scale.call(this,i,S),this.x1=this.x1*i,this.y1=this.y1*S,this.x2=this.x2*i,this.y2=this.y2*S,this.adjustVisual(),this.adjustControlBox()},t}(Se),Me=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.strokeColor="transparent",C.strokeWidth=0,C.strokeDasharray="",C.setStrokeColor=C.setStrokeColor.bind(C),C.setStrokeWidth=C.setStrokeWidth.bind(C),C.setStrokeDasharray=C.setStrokeDasharray.bind(C),C.strokeColor=B.defaultColor,C.strokeWidth=B.defaultStrokeWidth,C.strokeDasharray=B.defaultStrokeDasharray,C.strokePanel=new _e("Line color",B.defaultColorSet,B.defaultColor),C.strokePanel.onColorChanged=C.setStrokeColor,C.strokeWidthPanel=new De("Line width",B.defaultStrokeWidths,B.defaultStrokeWidth),C.strokeWidthPanel.onWidthChanged=C.setStrokeWidth,C.strokeStylePanel=new ke("Line style",B.defaultStrokeDasharrays,B.defaultStrokeDasharray),C.strokeStylePanel.onStyleChanged=C.setStrokeDasharray,C}return Q(t,A),t.prototype.ownsTarget=function(i){return!(!A.prototype.ownsTarget.call(this,i)&&i!==this.visual&&i!==this.selectorLine&&i!==this.visibleLine)},t.prototype.createVisual=function(){this.visual=X.createGroup(),this.selectorLine=X.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=X.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},t.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),X.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),X.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),X.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},t.prototype.setStrokeColor=function(i){this.strokeColor=i,this.adjustVisual(),this.colorChanged(i)},t.prototype.setStrokeWidth=function(i){this.strokeWidth=i,this.adjustVisual()},t.prototype.setStrokeDasharray=function(i){this.strokeDasharray=i,this.adjustVisual(),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},A.prototype.getState.call(this));return i.typeName=t.typeName,i},t.prototype.restoreState=function(i){A.prototype.restoreState.call(this,i);var S=i;this.strokeColor=S.strokeColor,this.strokeWidth=S.strokeWidth,this.strokeDasharray=S.strokeDasharray,this.createVisual(),this.adjustVisual()},t.typeName="LineMarker",t.title="Line marker",t.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',t}(Fe),pe=function(A){function t(i,S,B,C,$){var ne=A.call(this,i,C||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>',$||"font-family-panel")||this;return ne.fonts=[],ne.fontBoxes=[],ne.fonts=S,ne.currentFont=B,ne.setCurrentFont=ne.setCurrentFont.bind(ne),ne}return Q(t,A),t.prototype.getUi=function(){var i=this,S=document.createElement("div");return S.style.overflow="hidden",S.style.flexGrow="2",this.fonts.forEach(function(B){var C=document.createElement("div");C.style.display="inline-block",C.style.alignItems="center",C.style.justifyContent="space-between",C.style.padding="5px",C.style.borderWidth="2px",C.style.borderStyle="solid",C.style.overflow="hidden",C.style.maxWidth=100/i.fonts.length-5+"%",C.style.borderColor=B===i.currentFont?i.uiStyleSettings.toolboxAccentColor:"transparent",C.addEventListener("click",function(){i.setCurrentFont(B,C)}),S.appendChild(C);var $=document.createElement("div");$.style.display="flex",$.style.minHeight="20px",$.style.flexGrow="2",$.style.fontFamily=B,$.style.overflow="hidden";var ne=document.createElement("div");ne.style.whiteSpace="nowrap",ne.style.overflow="hidden",ne.style.textOverflow="ellipsis",ne.innerHTML="The quick brown fox jumps over the lazy dog",$.appendChild(ne),C.appendChild($),i.fontBoxes.push(C)}),S},t.prototype.setCurrentFont=function(i,S){var B=this;this.currentFont=i,this.fontBoxes.forEach(function(C){C.style.borderColor=C===S?B.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},t}(Ee),Le=function(A){function t(i,S,B){var C,$=A.call(this,i,S,B)||this;return $.color="transparent",$.padding=5,$.DEFAULT_TEXT="your text here",$.isMoved=!1,$.color=B.defaultColor,$.fontFamily=B.defaultFontFamily,$.text=(C=B.defaultText)!==null&&C!==void 0?C:$.DEFAULT_TEXT,$.defaultSize={x:100,y:30},$.setColor=$.setColor.bind($),$.setFont=$.setFont.bind($),$.renderText=$.renderText.bind($),$.sizeText=$.sizeText.bind($),$.textEditDivClicked=$.textEditDivClicked.bind($),$.showTextEditor=$.showTextEditor.bind($),$.setSize=$.setSize.bind($),$.positionTextEditor=$.positionTextEditor.bind($),$.wrapText=$.wrapText.bind($),$.colorPanel=new _e("Color",B.defaultColorSet,B.defaultColor),$.colorPanel.onColorChanged=$.setColor,$.fontFamilyPanel=new pe("Font",B.defaultFontFamilies,B.defaultFontFamily),$.fontFamilyPanel.onFontChanged=$.setFont,$}return Q(t,A),t.prototype.ownsTarget=function(i){if(A.prototype.ownsTarget.call(this,i)||i===this.visual||i===this.textElement||i===this.bgRectangle)return!0;var S=!1;return this.textElement.childNodes.forEach(function(B){B===i&&(S=!0)}),S},t.prototype.createVisual=function(){this.visual=X.createGroup(),this.bgRectangle=X.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=X.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(X.createTransform()),this.textElement.transform.baseVal.appendItem(X.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.isMoved=!1,this.pointerDownPoint=i,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(i),this._state="creating")},t.prototype.wrapText=function(){function i(Oe){var ce=Oe[0].length;return Oe.forEach(function(Be){Be.length>ce&&(ce=Be.length)}),.35*ce/Oe.length}if(this.text!==""){for(var S=this.text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/),B=1*this.width/this.height,C=new(Array.bind.apply(Array,J([void 0],S))),$=i(C),ne=Number.MAX_VALUE,Ce=function(){var Oe=C[0];C.forEach(function(ce){ce.length>Oe.length&&(Oe=ce)}),(ne=Oe.lastIndexOf(" ",ne-1))>0?(C=[],S.forEach(function(ce){for(var Be=ce;Be.length>ne;){var Ke=Be.lastIndexOf(" ",ne);Ke<0&&(Ke=Be.indexOf(" ")),Ke>0?(C.push(Be.substring(0,Ke)),Be=Be.substring(Ke).trim()):(C.push(Be),Be="")}C.push(Be)}),$=i(C)):$=-1};$>B;)Ce();return C.join(`\r
`)}return this.text},t.prototype.renderText=function(){var i=this;if(this.textElement){for(;this.textElement.lastChild;)this.textElement.removeChild(this.textElement.lastChild);(this.globalSettings.wrapText?this.wrapText():this.text).split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).forEach(function(S){i.textElement.appendChild(X.createTSpan(S.trim()===""?" ":S.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},t.prototype.getTextScale=function(){var i=this.textElement.getBBox(),S=1;if(i.width>0&&i.height>0){var B=(1*this.width-this.width*this.padding*2/100)/i.width,C=(1*this.height-this.height*this.padding*2/100)/i.height;S=Math.min(B,C)}return S},t.prototype.getTextPosition=function(i){var S=window.getComputedStyle(this.textElement).direction==="rtl"?1:-1,B=this.textElement.getBBox(),C=0,$=0;return B.width>0&&B.height>0&&(C=(this.width+S*B.width*i)/2,$=this.height/2-B.height*i/2),{x:C,y:$}},t.prototype.sizeText=function(){var i=this.textElement.getBBox(),S=this.getTextScale(),B=this.getTextPosition(S);B.y-=i.y*S,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+B.x+"px, "+B.y+"px) scale("+S+", "+S+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(B.x,B.y),this.textElement.transform.baseVal.getItem(1).setScale(S,S))},t.prototype.manipulate=function(i){A.prototype.manipulate.call(this,i),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(i.x-this.pointerDownPoint.x)>5||Math.abs(i.y-this.pointerDownPoint.y)>5)},t.prototype.resize=function(i){A.prototype.resize.call(this,i),this.isMoved=!0,this.setSize(),this.globalSettings.wrapText?this.renderText():this.sizeText()},t.prototype.setSize=function(){A.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(X.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),X.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},t.prototype.pointerUp=function(i){var S=this.state;S==="creating"&&(this._suppressMarkerCreateEvent=!0),A.prototype.pointerUp.call(this,i),this.setSize(),(S==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},t.prototype.showTextEditor=function(){var i=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditor=document.createElement("div"),this.textEditor.style.position="absolute",this.textEditor.style.fontFamily=this.fontFamily,this.textEditor.style.lineHeight="1em",this.textEditor.innerText=this.text,this.textEditor.contentEditable="true",this.textEditor.style.color=this.color,this.textEditor.style.whiteSpace="pre",this.positionTextEditor(),this.textEditor.addEventListener("pointerup",function(S){S.stopPropagation()}),this.globalSettings.wrapText||this.textEditor.addEventListener("input",function(){for(var S=Number.parseFloat(i.textEditor.style.fontSize);i.textEditor.clientWidth>=Number.parseInt(i.textEditor.style.maxWidth)&&S>.9;)S-=.1,i.textEditor.style.fontSize=Math.max(S,.9)+"em"}),this.textEditor.addEventListener("keyup",function(S){S.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(S){if(S.clipboardData){var B=S.clipboardData.getData("text"),C=window.getSelection();if(!C.rangeCount)return!1;C.deleteFromDocument(),C.getRangeAt(0).insertNode(document.createTextNode(B)),S.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){i.textEditDivClicked(i.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},t.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else if(this.globalSettings.wrapText)this.textEditor.style.left=this.left+this.padding+"px",this.textEditor.style.top=this.top+this.padding+"px",this.textEditor.style.width=this.width-2*this.padding+"px",this.textEditor.style.height=this.height-2*this.padding+"px",this.textEditor.style.maxHeight=this.textEditor.style.height,this.textEditor.style.whiteSpace="wrap";else{this.textElement.style.display="";var i=this.getTextScale(),S=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),B=this.textElement.getBBox(),C={x:B.width*i,y:B.height*i};S.x-=C.x/2,S.y-=C.y/2,this.textEditor.style.top=S.y+"px",this.textEditor.style.left=S.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-S.x+"px",this.textEditor.style.fontSize=Math.max(16*i,12)+"px",this.textElement.style.display="none"}},t.prototype.textEditDivClicked=function(i){this.text=i.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},t.prototype.select=function(){A.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},t.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),A.prototype.deselect.call(this)},t.prototype.dblClick=function(i,S){A.prototype.dblClick.call(this,i,S),this.showTextEditor()},t.prototype.setColor=function(i){this.textElement&&X.setAttributes(this.textElement,[["fill",i]]),this.color=i,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(i)},t.prototype.setFont=function(i){this.textElement&&X.setAttributes(this.textElement,[["font-family",i]]),this.fontFamily=i,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},t.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},t.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text,wrapText:this.globalSettings.wrapText},A.prototype.getState.call(this));return i.typeName=t.typeName,i},t.prototype.restoreState=function(i){var S=i;this.color=S.color,this.fontFamily=S.fontFamily,this.padding=S.padding,this.text=S.text,this.createVisual(),A.prototype.restoreState.call(this,i),this.setSize(),this.globalSettings.wrapText&&this.renderText()},t.prototype.scale=function(i,S){A.prototype.scale.call(this,i,S),this.setSize(),this.sizeText(),this.positionTextEditor()},t.typeName="TextMarker",t.title="Text marker",t.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',t}(be),ie=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.color="transparent",C.lineWidth=3,C.drawing=!1,C.pixelRatio=1,C.color=B.defaultColor,C.lineWidth=B.defaultStrokeWidth,C.pixelRatio=B.freehandPixelRatio,C.setColor=C.setColor.bind(C),C.addCanvas=C.addCanvas.bind(C),C.finishCreation=C.finishCreation.bind(C),C.setLineWidth=C.setLineWidth.bind(C),C.colorPanel=new _e("Color",B.defaultColorSet,B.defaultColor),C.colorPanel.onColorChanged=C.setColor,C.lineWidthPanel=new De("Line width",B.defaultStrokeWidths,B.defaultStrokeWidth),C.lineWidthPanel.onWidthChanged=C.setLineWidth,C}return Q(t,A),t.prototype.ownsTarget=function(i){return!(!A.prototype.ownsTarget.call(this,i)&&i!==this.visual&&i!==this.drawingImage)},t.prototype.createVisual=function(){this.visual=X.createGroup(),this.drawingImage=X.createImage(),this.visual.appendChild(this.drawingImage);var i=X.createTransform();this.visual.transform.baseVal.appendItem(i),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(i,S){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(i.x,i.y),this.drawing=!0):A.prototype.pointerDown.call(this,i,S)},t.prototype.manipulate=function(i){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(i.x,i.y),this.canvasContext.stroke()):A.prototype.manipulate.call(this,i)},t.prototype.resize=function(i){A.prototype.resize.call(this,i),X.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),X.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},t.prototype.pointerUp=function(i){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):A.prototype.pointerUp.call(this,i)},t.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},t.prototype.select=function(){this.state==="creating"&&this.finishCreation(),A.prototype.select.call(this)},t.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),A.prototype.deselect.call(this)},t.prototype.finishCreation=function(){for(var i=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),S=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],B=S[0],C=S[1],$=S[2],ne=S[3],Ce=!1,Oe=0;Oe<this.canvasElement.height;Oe++)for(var ce=0;ce<this.canvasElement.width;ce++)i.data[Oe*this.canvasElement.width*4+4*ce+3]>0&&(Ce=!0,Oe<C&&(C=Oe),ce<B&&(B=ce),Oe>ne&&(ne=Oe),ce>$&&($=ce));if(Ce){this.left=B/this.pixelRatio,this.top=C/this.pixelRatio,this.width=($-B)/this.pixelRatio,this.height=(ne-C)/this.pixelRatio;var Be=document.createElement("canvas");Be.width=$-B,Be.height=ne-C,Be.getContext("2d").putImageData(this.canvasContext.getImageData(B,C,$-B,ne-C),0,0),this.drawingImgUrl=Be.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},t.prototype.setDrawingImage=function(){X.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),X.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},t.prototype.setColor=function(i){this.color=i,this.colorChanged(i)},t.prototype.setLineWidth=function(i){this.lineWidth=i},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=Object.assign({drawingImgUrl:this.drawingImgUrl},A.prototype.getState.call(this));return i.typeName=t.typeName,i},t.prototype.restoreState=function(i){this.createVisual(),A.prototype.restoreState.call(this,i),this.drawingImgUrl=i.drawingImgUrl,this.setDrawingImage()},t.prototype.scale=function(i,S){A.prototype.scale.call(this,i,S),this.setDrawingImage()},t.typeName="FreehandMarker",t.title="Freehand marker",t.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',t}(be),te=function(A){function t(i,S,B,C){var $=A.call(this,i,B||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>',C||"arrow-type-panel")||this;return $.typeBoxes=[],$.currentType=S,$.setCurrentType=$.setCurrentType.bind($),$}return Q(t,A),t.prototype.getUi=function(){var i=this,S=document.createElement("div");S.style.display="flex",S.style.overflow="hidden",S.style.flexGrow="2";for(var B=function(ne){var Ce="both";switch(ne){case 0:Ce="both";break;case 1:Ce="start";break;case 2:Ce="end";break;case 3:Ce="none"}var Oe=document.createElement("div");if(Oe.style.display="flex",Oe.style.flexGrow="2",Oe.style.alignItems="center",Oe.style.justifyContent="space-between",Oe.style.padding="5px",Oe.style.borderWidth="2px",Oe.style.borderStyle="solid",Oe.style.borderColor=Ce===C.currentType?C.uiStyleSettings.toolboxAccentColor:"transparent",Oe.addEventListener("click",function(){i.setCurrentType(Ce,Oe)}),S.appendChild(Oe),Ce==="both"||Ce==="start"){var ce=document.createElement("div");ce.style.display="flex",ce.style.alignItems="center",ce.style.minHeight="20px",ce.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,5 10,0 10,10" fill="`+(C.uiStyleSettings!==void 0?C.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,ce.style.marginLeft="5px",Oe.appendChild(ce)}var Be=document.createElement("div");Be.style.display="flex",Be.style.alignItems="center",Be.style.minHeight="20px",Be.style.flexGrow="2";var Ke=document.createElement("hr");if(Ke.style.minWidth="20px",Ke.style.border="0px",Ke.style.borderTop="3px solid "+(C.uiStyleSettings!==void 0?C.uiStyleSettings.toolboxColor:"#eeeeee"),Ke.style.flexGrow="2",Be.appendChild(Ke),Oe.appendChild(Be),Ce==="both"||Ce==="end"){var nt=document.createElement("div");nt.style.display="flex",nt.style.alignItems="center",nt.style.minHeight="20px",nt.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,0 10,5 0,10" fill="`+(C.uiStyleSettings!==void 0?C.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,nt.style.marginRight="5px",Oe.appendChild(nt)}C.typeBoxes.push(Oe)},C=this,$=0;$<4;$++)B($);return S},t.prototype.setCurrentType=function(i,S){var B=this;this.currentType=i,this.typeBoxes.forEach(function(C){C.style.borderColor=C===S?B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},t}(Ee),re=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.arrowType="end",C.arrowBaseHeight=10,C.arrowBaseWidth=10,C.getArrowPoints=C.getArrowPoints.bind(C),C.setArrowType=C.setArrowType.bind(C),C.arrowTypePanel=new te("Arrow type","end"),C.arrowTypePanel.onArrowTypeChanged=C.setArrowType,C}return Q(t,A),t.prototype.ownsTarget=function(i){return!(!A.prototype.ownsTarget.call(this,i)&&i!==this.arrow1&&i!==this.arrow2)},t.prototype.getArrowPoints=function(i,S){var B=this.arrowBaseWidth+2*this.strokeWidth,C=this.arrowBaseHeight+2*this.strokeWidth;return i-B/2+","+(S+C/2)+" "+i+","+(S-C/2)+" "+(i+B/2)+","+(S+C/2)},t.prototype.createTips=function(){this.arrow1=X.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(X.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=X.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(X.createTransform()),this.visual.appendChild(this.arrow2)},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.state==="creating"&&this.createTips()},t.prototype.adjustVisual=function(){if(A.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2){this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",X.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),X.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]);var i=0;Math.abs(this.x1-this.x2)>.1&&(i=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2));var S=this.arrow1.transform.baseVal.getItem(0);S.setRotate(i,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(S,0);var B=this.arrow2.transform.baseVal.getItem(0);B.setRotate(i+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(B,0)}},t.prototype.setArrowType=function(i){this.arrowType=i,this.adjustVisual(),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=Object.assign({arrowType:this.arrowType},A.prototype.getState.call(this));return i.typeName=t.typeName,i},t.prototype.restoreState=function(i){A.prototype.restoreState.call(this,i);var S=i;this.arrowType=S.arrowType,this.createTips(),this.adjustVisual()},t.typeName="ArrowMarker",t.title="Arrow marker",t.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',t}(Me),K=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.fillColor=B.defaultFillColor,C.strokeWidth=0,C.fillPanel=new _e("Color",B.defaultColorSet,B.defaultFillColor),C.fillPanel.onColorChanged=C.setFillColor,C}return Q(t,A),Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=A.prototype.getState.call(this);return i.typeName=t.typeName,i},t.typeName="CoverMarker",t.title="Cover marker",t.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',t}(Re),j=function(A){function t(i,S,B,C,$){var ne=A.call(this,i,C||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>',$||"opacity-panel")||this;return ne.opacities=[],ne.opacityBoxes=[],ne.opacities=S,ne.currentOpacity=B,ne.setCurrentOpacity=ne.setCurrentOpacity.bind(ne),ne}return Q(t,A),t.prototype.getUi=function(){var i=this,S=document.createElement("div");return S.style.display="flex",S.style.overflow="hidden",S.style.flexGrow="2",S.style.justifyContent="space-between",this.opacities.forEach(function(B){var C=document.createElement("div");C.style.display="flex",C.style.alignItems="center",C.style.justifyContent="center",C.style.padding="5px",C.style.borderWidth="2px",C.style.borderStyle="solid",C.style.borderColor=B===i.currentOpacity?i.uiStyleSettings.toolboxAccentColor:"transparent",C.addEventListener("click",function(){i.setCurrentOpacity(B,C)}),S.appendChild(C);var $=document.createElement("div");$.innerText=100*B+"%",C.appendChild($),i.opacityBoxes.push(C)}),S},t.prototype.setCurrentOpacity=function(i,S){var B=this;this.currentOpacity=i,this.opacityBoxes.forEach(function(C){C.style.borderColor=C===S?B.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},t}(Ee),Z=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.setOpacity=C.setOpacity.bind(C),C.fillColor=B.defaultHighlightColor,C.strokeWidth=0,C.opacity=B.defaultHighlightOpacity,C.fillPanel=new _e("Color",B.defaultColorSet,C.fillColor),C.fillPanel.onColorChanged=C.setFillColor,C.opacityPanel=new j("Opacity",B.defaultOpacitySteps,C.opacity),C.opacityPanel.onOpacityChanged=C.setOpacity,C}return Q(t,A),t.prototype.setOpacity=function(i){this.opacity=i,this.visual&&X.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=A.prototype.getState.call(this);return i.typeName=t.typeName,i},t.typeName="HighlightMarker",t.title="Highlight marker",t.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',t}(K),q='<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>',se='<svg viewBox="0 0 24 24"><path d="M19 11.5s-2 2.17-2 3.5a2 2 0 002 2 2 2 0 002-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21 14.79 10m1.77-1.06L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12z"/></svg>',de=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.bgColor="transparent",C.tipPosition={x:0,y:0},C.tipBase1Position={x:0,y:0},C.tipBase2Position={x:0,y:0},C.tipMoving=!1,C.color=B.defaultStrokeColor,C.bgColor=B.defaultFillColor,C.fontFamily=B.defaultFontFamily,C.defaultSize={x:100,y:30},C.setBgColor=C.setBgColor.bind(C),C.getTipPoints=C.getTipPoints.bind(C),C.positionTip=C.positionTip.bind(C),C.setTipPoints=C.setTipPoints.bind(C),C.colorPanel=new _e("Text color",B.defaultColorSet,C.color,q,"text-color-panel"),C.colorPanel.onColorChanged=C.setColor,C.bgColorPanel=new _e("Fill color",B.defaultColorSet,C.bgColor,se,"fill-color-panel"),C.bgColorPanel.onColorChanged=C.setBgColor,C.fontFamilyPanel=new pe("Font",B.defaultFontFamilies,B.defaultFontFamily),C.fontFamilyPanel.onFontChanged=C.setFont,C.tipGrip=new Pe,C.tipGrip.visual.transform.baseVal.appendItem(X.createTransform()),C.controlBox.appendChild(C.tipGrip.visual),C}return Q(t,A),t.prototype.ownsTarget=function(i){return A.prototype.ownsTarget.call(this,i)||this.tipGrip.ownsTarget(i)||this.tip===i},t.prototype.createTip=function(){X.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=X.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},t.prototype.pointerDown=function(i,S){this.state==="new"&&A.prototype.pointerDown.call(this,i,S),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(S)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):A.prototype.pointerDown.call(this,i,S)},t.prototype.pointerUp=function(i){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,A.prototype.pointerUp.call(this,i);else{var S=this.state==="creating";A.prototype.pointerUp.call(this,i),this.setTipPoints(S),this.positionTip()}},t.prototype.manipulate=function(i){if(this.tipMoving){var S=this.unrotatePoint(i);this.tipPosition={x:S.x-this.manipulationStartLeft,y:S.y-this.manipulationStartTop},this.positionTip()}else A.prototype.manipulate.call(this,i)},t.prototype.setBgColor=function(i){this.bgRectangle&&this.tip&&(X.setAttributes(this.bgRectangle,[["fill",i]]),X.setAttributes(this.tip,[["fill",i]])),this.bgColor=i,this.fillColorChanged(i)},t.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},t.prototype.setTipPoints=function(i){i===void 0&&(i=!1);var S=Math.min(this.height/2,15),B=this.height/5;i&&(this.tipPosition={x:S+B/2,y:this.height+20});var C=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?C<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(B=this.width/5,S=Math.min(this.width/2,15),this.tipBase1Position={x:S,y:0},this.tipBase2Position={x:S+B,y:0}):(this.tipBase1Position={x:0,y:S},this.tipBase2Position={x:0,y:S+B}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?C<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(B=this.width/5,S=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-S-B,y:0},this.tipBase2Position={x:this.width-S,y:0}):(this.tipBase1Position={x:this.width,y:S},this.tipBase2Position={x:this.width,y:S+B}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?C<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(B=this.width/5,S=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-S-B,y:this.height},this.tipBase2Position={x:this.width-S,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-S-B},this.tipBase2Position={x:this.width,y:this.height-S}):C<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(B=this.width/5,S=Math.min(this.width/2,15),this.tipBase1Position={x:S,y:this.height},this.tipBase2Position={x:S+B,y:this.height}):(this.tipBase1Position={x:0,y:this.height-S},this.tipBase2Position={x:0,y:this.height-S-B})},t.prototype.resize=function(i){A.prototype.resize.call(this,i),this.positionTip()},t.prototype.positionTip=function(){X.setAttributes(this.tip,[["points",this.getTipPoints()]]);var i=this.tipGrip.visual.transform.baseVal.getItem(0);i.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(i,0)},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),t.prototype.select=function(){this.positionTip(),A.prototype.select.call(this)},t.prototype.getState=function(){var i=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},A.prototype.getState.call(this));return i.typeName=t.typeName,i},t.prototype.restoreState=function(i){var S=i;this.bgColor=S.bgColor,this.tipPosition=S.tipPosition,A.prototype.restoreState.call(this,i),this.createTip(),this.setTipPoints()},t.prototype.scale=function(i,S){A.prototype.scale.call(this,i,S),this.tipPosition={x:this.tipPosition.x*i,y:this.tipPosition.y*S},this.positionTip()},t.typeName="CalloutMarker",t.title="Callout marker",t.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',t}(Le),ve=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.fillColor="transparent",C.strokeColor="transparent",C.strokeWidth=0,C.strokeDasharray="",C.opacity=1,C.strokeColor=B.defaultColor,C.strokeWidth=B.defaultStrokeWidth,C.strokeDasharray=B.defaultStrokeDasharray,C.fillColor=B.defaultFillColor,C.setStrokeColor=C.setStrokeColor.bind(C),C.setFillColor=C.setFillColor.bind(C),C.setStrokeWidth=C.setStrokeWidth.bind(C),C.setStrokeDasharray=C.setStrokeDasharray.bind(C),C.setOpacity=C.setOpacity.bind(C),C.createVisual=C.createVisual.bind(C),C.strokePanel=new _e("Line color",J(B.defaultColorSet,["transparent"]),B.defaultColor,void 0,"stroke-color-panel"),C.strokePanel.onColorChanged=C.setStrokeColor,C.fillPanel=new _e("Fill color",J(B.defaultColorSet,["transparent"]),C.fillColor,se,"fill-color-panel"),C.fillPanel.onColorChanged=C.setFillColor,C.strokeWidthPanel=new De("Line width",B.defaultStrokeWidths,B.defaultStrokeWidth),C.strokeWidthPanel.onWidthChanged=C.setStrokeWidth,C.strokeStylePanel=new ke("Line style",B.defaultStrokeDasharrays,B.defaultStrokeDasharray),C.strokeStylePanel.onStyleChanged=C.setStrokeDasharray,C.opacityPanel=new j("Opacity",B.defaultOpacitySteps,C.opacity),C.opacityPanel.onOpacityChanged=C.setOpacity,C}return Q(t,A),t.prototype.ownsTarget=function(i){return!(!A.prototype.ownsTarget.call(this,i)&&i!==this.visual)},t.prototype.createVisual=function(){this.visual=X.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.state==="new"&&(this.createVisual(),this.moveVisual(i),this._state="creating")},t.prototype.manipulate=function(i){A.prototype.manipulate.call(this,i)},t.prototype.resize=function(i){A.prototype.resize.call(this,i),this.setSize()},t.prototype.setSize=function(){A.prototype.setSize.call(this),X.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},t.prototype.pointerUp=function(i){A.prototype.pointerUp.call(this,i),this.setSize()},t.prototype.setStrokeColor=function(i){this.strokeColor=i,this.visual&&X.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(i),this.stateChanged()},t.prototype.setFillColor=function(i){this.fillColor=i,this.visual&&X.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(i),this.stateChanged()},t.prototype.setStrokeWidth=function(i){this.strokeWidth=i,this.visual&&X.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},t.prototype.setStrokeDasharray=function(i){this.strokeDasharray=i,this.visual&&X.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},t.prototype.setOpacity=function(i){this.opacity=i,this.visual&&X.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},A.prototype.getState.call(this));return i.typeName=t.typeName,i},t.prototype.restoreState=function(i){var S=i;this.fillColor=S.fillColor,this.strokeColor=S.strokeColor,this.strokeWidth=S.strokeWidth,this.strokeDasharray=S.strokeDasharray,this.opacity=S.opacity,this.createVisual(),A.prototype.restoreState.call(this,i),this.setSize()},t.prototype.scale=function(i,S){A.prototype.scale.call(this,i,S),this.setSize()},t.typeName="EllipseMarker",t.title="Ellipse marker",t.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',t}(be),Ue=function(A){function t(i,S,B){return A.call(this,i,S,B)||this}return Q(t,A),Object.defineProperty(t.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),t.prototype.ownsTarget=function(i){return!(!A.prototype.ownsTarget.call(this,i)&&i!==this.tip1&&i!==this.tip2)},t.prototype.createTips=function(){this.tip1=X.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem(X.createTransform()),this.visual.appendChild(this.tip1),this.tip2=X.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem(X.createTransform()),this.visual.appendChild(this.tip2)},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.state==="creating"&&this.createTips()},t.prototype.adjustVisual=function(){if(A.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(X.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),X.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var i=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),S=this.tip1.transform.baseVal.getItem(0);S.setRotate(i,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(S,0);var B=this.tip2.transform.baseVal.getItem(0);B.setRotate(i+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(B,0)}},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=A.prototype.getState.call(this);return i.typeName=t.typeName,i},t.prototype.restoreState=function(i){A.prototype.restoreState.call(this,i),this.createTips(),this.adjustVisual()},t.typeName="MeasurementMarker",t.title="Measurement marker",t.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',t}(Me),Ge=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.strokePanel.colors=B.defaultColorSet,C.fillColor="transparent",C}return Q(t,A),Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=A.prototype.getState.call(this);return i.typeName=t.typeName,i},t.typeName="EllipseFrameMarker",t.title="Ellipse frame marker",t.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',t}(ve),We=function(){function A(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(A.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),A.prototype.addUndoStep=function(t){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(t)||(this.undoStack.push(t),JSON.stringify(this.lastRedoStep)!==JSON.stringify(t)&&this.redoStack.splice(0,this.redoStack.length))},A.prototype.replaceLastUndoStep=function(t){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=t)},A.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},A.prototype.undo=function(){if(this.undoStack.length>1){var t=this.undoStack.pop();return t!==void 0&&this.redoStack.push(t),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},A.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},A}(),it=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.strokeColor="transparent",C.strokeWidth=0,C.strokeDasharray="",C.curveX=0,C.curveY=0,C.manipulationStartCurveX=0,C.manipulationStartCurveY=0,C.setStrokeColor=C.setStrokeColor.bind(C),C.setStrokeWidth=C.setStrokeWidth.bind(C),C.setStrokeDasharray=C.setStrokeDasharray.bind(C),C.positionGrips=C.positionGrips.bind(C),C.addControlGrips=C.addControlGrips.bind(C),C.adjustVisual=C.adjustVisual.bind(C),C.setupControlBox=C.setupControlBox.bind(C),C.resize=C.resize.bind(C),C.strokeColor=B.defaultColor,C.strokeWidth=B.defaultStrokeWidth,C.strokeDasharray=B.defaultStrokeDasharray,C.strokePanel=new _e("Line color",B.defaultColorSet,B.defaultColor),C.strokePanel.onColorChanged=C.setStrokeColor,C.strokeWidthPanel=new De("Line width",B.defaultStrokeWidths,B.defaultStrokeWidth),C.strokeWidthPanel.onWidthChanged=C.setStrokeWidth,C.strokeStylePanel=new ke("Line style",B.defaultStrokeDasharrays,B.defaultStrokeDasharray),C.strokeStylePanel.onStyleChanged=C.setStrokeDasharray,C}return Q(t,A),t.prototype.ownsTarget=function(i){return!(!A.prototype.ownsTarget.call(this,i)&&i!==this.visual&&i!==this.selectorCurve&&i!==this.visibleCurve&&!this.curveGrip.ownsTarget(i))},t.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},t.prototype.createVisual=function(){this.visual=X.createGroup(),this.selectorCurve=X.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=X.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=i.x,this.curveY=i.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(S)&&(this.activeGrip=this.curveGrip,this._state="resize")},t.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),X.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),X.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),X.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},t.prototype.setupControlBox=function(){A.prototype.setupControlBox.call(this),this.curveControlLine1=X.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=X.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},t.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,A.prototype.addControlGrips.call(this)},t.prototype.positionGrips=function(){A.prototype.positionGrips.call(this);var i=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-i/2,this.curveY-i/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},t.prototype.manipulate=function(i){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+i.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+i.y-this.manipulationStartY),A.prototype.manipulate.call(this,i)},t.prototype.resize=function(i){this.activeGrip===this.curveGrip&&(this.curveX=i.x,this.curveY=i.y),A.prototype.resize.call(this,i),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},t.prototype.setStrokeColor=function(i){this.strokeColor=i,this.adjustVisual(),this.colorChanged(i)},t.prototype.setStrokeWidth=function(i){this.strokeWidth=i,this.adjustVisual()},t.prototype.setStrokeDasharray=function(i){this.strokeDasharray=i,this.adjustVisual()},t.prototype.scale=function(i,S){this.curveX=this.curveX*i,this.curveY=this.curveY*S,A.prototype.scale.call(this,i,S)},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},A.prototype.getState.call(this));return i.typeName=t.typeName,i},t.prototype.restoreState=function(i){A.prototype.restoreState.call(this,i);var S=i;this.strokeColor=S.strokeColor,this.strokeWidth=S.strokeWidth,this.strokeDasharray=S.strokeDasharray,this.curveX=S.curveX,this.curveY=S.curveY,this.createVisual(),this.adjustVisual()},t.typeName="CurveMarker",t.title="Curve marker",t.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',t}(Fe),$e=function(A){function t(i,S,B){var C=A.call(this,i,S,B)||this;return C.fillColor="transparent",C.strokeColor="transparent",C.strokeWidth=0,C.strokeDasharray="",C.textColor="transparent",C.fontSize="1rem",C.isMoved=!1,C.captionText="Caption",C.PADDING=5,C.captionBoxWidth=0,C.captionBoxHeight=0,C.strokeColor=B.defaultColor,C.strokeWidth=B.defaultStrokeWidth,C.strokeDasharray=B.defaultStrokeDasharray,C.fillColor=B.defaultFillColor,C.textColor=B.defaultStrokeColor,C.fontFamily=B.defaultFontFamily,C.fontSize=B.defaultCaptionFontSize,C.captionText=B.defaultCaptionText,C.setStrokeColor=C.setStrokeColor.bind(C),C.setFillColor=C.setFillColor.bind(C),C.setStrokeWidth=C.setStrokeWidth.bind(C),C.setStrokeDasharray=C.setStrokeDasharray.bind(C),C.createVisual=C.createVisual.bind(C),C.sizeCaption=C.sizeCaption.bind(C),C.setCaptionText=C.setCaptionText.bind(C),C.showTextEditor=C.showTextEditor.bind(C),C.positionTextEditor=C.positionTextEditor.bind(C),C.finishTextEditing=C.finishTextEditing.bind(C),C.setFont=C.setFont.bind(C),C.setTextColor=C.setTextColor.bind(C),C.strokePanel=new _e("Line color",J(B.defaultColorSet,["transparent"]),C.strokeColor,void 0,"stroke-color-panel"),C.strokePanel.onColorChanged=C.setStrokeColor,C.fillPanel=new _e("Fill color",J(B.defaultColorSet,["transparent"]),C.fillColor,se,"fill-color-panel"),C.fillPanel.onColorChanged=C.setFillColor,C.strokeWidthPanel=new De("Line width",B.defaultStrokeWidths,B.defaultStrokeWidth),C.strokeWidthPanel.onWidthChanged=C.setStrokeWidth,C.strokeStylePanel=new ke("Line style",B.defaultStrokeDasharrays,B.defaultStrokeDasharray),C.strokeStylePanel.onStyleChanged=C.setStrokeDasharray,C.fontFamilyPanel=new pe("Font",B.defaultFontFamilies,B.defaultFontFamily),C.fontFamilyPanel.onFontChanged=C.setFont,C.textColorPanel=new _e("Text color",B.defaultColorSet,C.textColor,q,"text-color-panel"),C.textColorPanel.onColorChanged=C.setTextColor,C}return Q(t,A),t.prototype.ownsTarget=function(i){return!(!A.prototype.ownsTarget.call(this,i)&&i!==this.visual&&i!==this.frame&&i!==this.captionBg&&i!==this.captionElement)},t.prototype.createVisual=function(){this.visual=X.createGroup(),this.addMarkerVisualToContainer(this.visual),this.captionBg=X.createRect(1,1,[["fill",this.fillColor]]),this.visual.appendChild(this.captionBg),this.captionElement=X.createText([["fill",this.textColor],["font-family",this.fontFamily]]),this.captionElement.style.fontSize=this.fontSize,this.captionElement.style.textAnchor="start",this.captionElement.style.dominantBaseline="text-before-edge",this.captionElement.textContent=this.captionText,this.visual.appendChild(this.captionElement),this.frame=X.createRect(this.width,this.height,[["fill","transparent"],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray]]),this.visual.appendChild(this.frame),this.sizeCaption()},t.prototype.setCaptionText=function(i){this.captionText=i,this.captionElement.textContent=this.captionText,this.sizeCaption()},t.prototype.pointerDown=function(i,S){A.prototype.pointerDown.call(this,i,S),this.isMoved=!1,this.pointerDownPoint=i,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(i),this._state="creating")},t.prototype.manipulate=function(i){A.prototype.manipulate.call(this,i),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(i.x-this.pointerDownPoint.x)>5||Math.abs(i.y-this.pointerDownPoint.y)>5)},t.prototype.resize=function(i){A.prototype.resize.call(this,i),this.setSize()},t.prototype.sizeCaption=function(){var i=this.captionElement.getBBox();this.captionText.trim()!==""?(this.captionBoxWidth=i.width+2*this.PADDING,this.captionBoxHeight=i.height+2*this.PADDING):(this.captionBoxWidth=0,this.captionBoxHeight=0),X.setAttributes(this.captionBg,[["width",this.captionBoxWidth.toString()],["height",this.captionBoxHeight.toString()],["clip-path","path('M0,0 H"+this.width+" V"+this.height+" H"+-this.width+" Z')"]]),X.setAttributes(this.captionElement,[["x",this.PADDING.toString()],["y",this.PADDING.toString()],["clip-path","path('M0,0 H"+(this.width-this.PADDING)+" V"+this.height+" H"+(-this.width-this.PADDING)+" Z')"]])},t.prototype.showTextEditor=function(){var i=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditBox=document.createElement("input"),this.textEditBox.style.position="absolute",this.textEditBox.style.width=this.width+"px",this.captionBoxHeight>0&&(this.textEditBox.style.height=this.captionBoxHeight+"px"),this.textEditBox.style.fontSize=this.fontSize,this.textEditBox.style.fontFamily=this.fontFamily,this.textEditBox.style.backgroundColor=this.fillColor,this.textEditBox.style.color=this.textColor,this.textEditBox.style.borderWidth="0",this.textEditBox.setAttribute("value",this.captionText),this.textEditBox.select(),this.textEditDiv.appendChild(this.textEditBox),this.overlayContainer.appendChild(this.textEditDiv),this.textEditBox.addEventListener("pointerup",function(S){S.stopPropagation()}),this.textEditBox.addEventListener("keypress",function(S){S.key==="Enter"&&i.finishTextEditing(i.textEditBox.value)}),this.textEditBox.addEventListener("keyup",function(S){S.cancelBubble=!0}),this.textEditBox.addEventListener("blur",function(){i.finishTextEditing(i.textEditBox.value)}),this.textEditDiv.addEventListener("pointerup",function(){i.finishTextEditing(i.textEditBox.value)}),this.positionTextEditor(),this.textEditBox.focus()},t.prototype.positionTextEditor=function(){this.state==="edit"&&(this.textEditBox===void 0?this.showTextEditor():(this.textEditBox.style.left=this.left+"px",this.textEditBox.style.top=this.top+"px",this.textEditBox.style.transform="rotate("+this.rotationAngle+"deg)",this.textEditBox.style.transformOrigin=this.width/2+"px "+this.height/2+"px"))},t.prototype.finishTextEditing=function(i){this.setCaptionText(i.trim()),this.overlayContainer.innerHTML="",this.stateChanged()},t.prototype.setFont=function(i){this.captionElement&&X.setAttributes(this.captionElement,[["font-family",i]]),this.fontFamily=i,this.textEditBox&&(this.textEditBox.style.fontFamily=this.fontFamily),this.sizeCaption(),this.stateChanged()},t.prototype.setTextColor=function(i){this.captionElement&&X.setAttributes(this.captionElement,[["fill",i]]),this.textColor=i,this.textEditBox&&(this.textEditBox.style.color=this.textColor),this.stateChanged()},t.prototype.setSize=function(){A.prototype.setSize.call(this),X.setAttributes(this.frame,[["width",this.width.toString()],["height",this.height.toString()]]),this.sizeCaption()},t.prototype.pointerUp=function(i){A.prototype.pointerUp.call(this,i),this.setSize(),!this.isMoved&&Date.now()-this.pointerDownTimestamp>500&&this.showTextEditor(),this.pointerDownPoint=void 0},t.prototype.dblClick=function(i,S){A.prototype.dblClick.call(this,i,S),this.showTextEditor()},t.prototype.setStrokeColor=function(i){this.strokeColor=i,this.frame&&X.setAttributes(this.frame,[["stroke",this.strokeColor]]),this.colorChanged(i),this.stateChanged()},t.prototype.setFillColor=function(i){this.fillColor=i,this.captionBg&&X.setAttributes(this.captionBg,[["fill",this.fillColor]]),this.fillColorChanged(i),this.stateChanged()},t.prototype.setStrokeWidth=function(i){this.strokeWidth=i,this.frame&&X.setAttributes(this.frame,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},t.prototype.setStrokeDasharray=function(i){this.strokeDasharray=i,this.frame&&X.setAttributes(this.frame,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},Object.defineProperty(t.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.fontFamilyPanel,this.textColorPanel]},enumerable:!1,configurable:!0}),t.prototype.getState=function(){var i=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:1,textColor:this.textColor,fontFamily:this.fontFamily,fontSize:this.fontSize,captionText:this.captionText},A.prototype.getState.call(this));return i.typeName=this.typeName,i},t.prototype.restoreState=function(i){var S=i;this.fillColor=S.fillColor,this.strokeColor=S.strokeColor,this.strokeWidth=S.strokeWidth,this.strokeDasharray=S.strokeDasharray,this.textColor=S.textColor,this.fontFamily=S.fontFamily,this.captionText=S.captionText,this.fontSize=S.fontSize,this.createVisual(),A.prototype.restoreState.call(this,i),this.setSize()},t.prototype.scale=function(i,S){A.prototype.scale.call(this,i,S),this.setSize()},t.typeName="CaptionFrameMarker",t.title="Caption frame marker",t.icon='<svg viewBox="0 0 24 24"><path d="M5 3c-1.11 0-2 .89-2 2v14c0 1.11.89 2 2 2h14c1.11 0 2-.89 2-2V5c0-1.11-.89-2-2-2H5m0 2h14v14H5V5m2 2v2h10V7H7z"/></svg>',t}(be),Ne=function(){function A(t,i){i===void 0&&(i=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=t,this.cancelable=i}return Object.defineProperty(A.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),A.prototype.preventDefault=function(){this._defaultPrevented=!0},A}(),st=function(A){function t(i,S,B){var C=A.call(this,i,!1)||this;return C.dataUrl=S,C.state=B,C}return Q(t,A),t}(Ne),je=function(A){function t(i,S,B){B===void 0&&(B=!1);var C=A.call(this,i,B)||this;return C.marker=S,C}return Q(t,A),t}(Ne),Je=function(){function A(){this.render=[],this.beforeclose=[],this.close=[],this.show=[],this.restorestate=[],this.statechange=[],this.markerselect=[],this.markerdeselect=[],this.markercreating=[],this.markercreate=[],this.markerbeforedelete=[],this.markerdelete=[],this.markerchange=[],this.focus=[],this.blur=[]}return A.prototype.addEventListener=function(t,i){this[t].push(i)},A.prototype.removeEventListener=function(t,i){var S=this[t].indexOf(i);S>-1&&this[t].splice(S,1)},A}(),ot=function(){function A(t){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new xe,this._isOpen=!1,this.undoRedoManager=new We,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.renderMarkersOnly=!1,this.zoomSteps=[1,1.5,2,4],this._zoomLevel=1,this._isResizing=!1,this.prevPanPoint={x:0,y:0},this.eventListeners=new Je,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=A.instanceCounter++,this.styles=new Ae(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=t,this.targetRoot=document.body,this.width=t.clientWidth,this.height=t.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this),this.addMarkerEvents=this.addMarkerEvents.bind(this)}return Object.defineProperty(A.prototype,"ALL_MARKER_TYPES",{get:function(){return[Ie,ie,re,Le,Ge,ve,Z,de,Ue,K,Me,it,$e]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[Ie,ie,re,Le,ve,Z,de]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"BASIC_MARKER_TYPES",{get:function(){return[Ie,ie,re,Le,Z]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(t){var i=this;this._availableMarkerTypes.splice(0),t.forEach(function(S){if(typeof S=="string"){var B=i.ALL_MARKER_TYPES.find(function(C){return C.typeName===S});B!==void 0&&i._availableMarkerTypes.push(B)}else i._availableMarkerTypes.push(S)})},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(t){this._zoomLevel=t,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),A.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),oe.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},A.prototype.show=function(){var t=this;this.styles.styleSheetRoot===void 0&&me.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=me.styleSheetRoot),this.markers.splice(0),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(i){return i(new Ne(t))})},A.prototype.render=function(){return z(this,void 0,void 0,function(){var t;return ee(this,function(i){switch(i.label){case 0:return this.setCurrentMarker(),(t=new le).naturalSize=this.renderAtNaturalSize,t.imageType=this.renderImageType,t.imageQuality=this.renderImageQuality,t.markersOnly=this.renderMarkersOnly,t.width=this.renderWidth,t.height=this.renderHeight,[4,t.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return i.sent(),[4,t.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,i.sent()]}})})},A.prototype.close=function(t){var i=this;if(t===void 0&&(t=!1),this.isOpen){var S=!1;t||this.eventListeners.beforeclose.forEach(function(B){var C=new Ne(i,!0);B(C),C.defaultPrevented&&(S=!0)}),S||(this.coverDiv&&this.closeUI(),this.targetObserver&&(this.targetObserver.unobserve(this.target),this.targetObserver.unobserve(this.editorCanvas)),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(B){return B(new Ne(i))}),this.detachEvents(),this._isOpen=!1)}},A.prototype.addMarkersToToolbar=function(){for(var t,i=[],S=0;S<arguments.length;S++)i[S]=arguments[S];(t=this._availableMarkerTypes).push.apply(t,i)},A.prototype.addRenderEventListener=function(t){this.addEventListener("render",function(i){t(i.dataUrl,i.state)})},A.prototype.removeRenderEventListener=function(t){},A.prototype.addCloseEventListener=function(t){this.addEventListener("close",function(){t()})},A.prototype.removeCloseEventListener=function(t){},A.prototype.setupResizeObserver=function(){var t=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){t.resize(t.target.clientWidth,t.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return t.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},A.prototype.onPopupTargetResize=function(){var t=1*this.target.clientWidth/this.target.clientHeight,i=this.editorCanvas.clientWidth/t>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*t:this.editorCanvas.clientWidth,S=i<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/t;this.resize(i,S)},A.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},A.prototype.resize=function(t,i){this._isResizing=!0;var S=t/this.imageWidth,B=i/this.imageHeight;this.imageWidth=Math.round(t),this.imageHeight=Math.round(i),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(S,B),this._isResizing=!1},A.prototype.scaleMarkers=function(t,i){var S,B=this;this._currentMarker&&this._currentMarker instanceof Le?this._currentMarker.scale(t,i):(S=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(C){C!==B._currentMarker&&C.scale(t,i)}),S!==void 0&&this.setCurrentMarker(S)},A.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},A.prototype.setTopLeft=function(){var t=this.editingTarget.getBoundingClientRect(),i=this.editorCanvas.getBoundingClientRect();this.left=t.left-i.left,this.top=t.top-i.top},A.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},A.prototype.addDefs=function(){for(var t,i=[],S=0;S<arguments.length;S++)i[S]=arguments[S];this.defs=X.createDefs(),this.addDefsToImage(),(t=this.defs).append.apply(t,i)},A.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},A.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},A.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},A.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("touchmove",function(t){return t.preventDefault()}),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},A.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},A.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},A.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},A.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var t=document.createElement("a");t.href="https://markerjs.com/",t.target="_blank",t.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',t.title="Powered by marker.js",t.style.display="grid",t.style.alignItems="center",t.style.justifyItems="center",t.style.padding="3px",t.style.width="20px",t.style.height="20px",this.logoUI.appendChild(t),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},A.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},A.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},A.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},A.prototype.showUI=function(){var t;switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var i=this.settings.uiOffsetTop!==void 0?this.target.offsetTop+this.settings.uiOffsetTop:this.target.offsetTop>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0,S=this.target.offsetLeft+((t=this.settings.uiOffsetLeft)!==null&&t!==void 0?t:0);this.coverDiv.style.top=i+"px",this.coverDiv.style.left=S+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="fixed",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.settings.displayMode==="popup"&&(this.uiDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px"),this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new ue(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.settings.displayMode==="inline"&&this.settings.uiOffsetTop===void 0&&this.target.offsetTop<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new ye(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},A.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv),this.coverDiv.remove(),this.coverDiv=null},A.prototype.removeMarker=function(t){this.markerImage.removeChild(t.container),this.markers.indexOf(t)>-1&&this.markers.splice(this.markers.indexOf(t),1),t.dispose()},A.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},A.prototype.toolbarButtonClicked=function(t,i){if(t==="marker"&&i!==void 0)this.createNewMarker(i);else if(t==="action")switch(i){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},A.prototype.deleteSelectedMarker=function(){var t=this;if(this._currentMarker!==void 0&&this._currentMarker.state==="select"){var i=!1;if(this.eventListeners.markerbeforedelete.forEach(function(B){var C=new je(t,t._currentMarker,!0);B(C),C.defaultPrevented&&(i=!0)}),!i){var S=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach(function(B){return B(new je(t,S))})}}},A.prototype.clear=function(){var t=this,i=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function($){var ne=new je(t,void 0,!0);$(ne),ne.defaultPrevented&&(i=!0)}),!i)){this.setCurrentMarker();for(var S=function($){var ne=B.markers[$];B.setCurrentMarker(B.markers[$]),B._currentMarker.dispose(),B.markerImage.removeChild(B._currentMarker.container),B.markers.splice(B.markers.indexOf(B._currentMarker),1),B.eventListeners.markerdelete.forEach(function(Ce){return Ce(new je(t,ne))})},B=this,C=this.markers.length-1;C>=0;C--)S(C);this.addUndoStep()}},Object.defineProperty(A.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),A.prototype.showNotesEditor=function(){var t;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(t=this._currentMarker.notes)!==null&&t!==void 0?t:"",this.overlayContainer.appendChild(this.notesArea))},A.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},A.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},A.prototype.addUndoStep=function(){var t=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var i=this.getState(),S=this.undoRedoManager.getLastUndoStep();if(!S||S.width===i.width&&S.height===i.height){var B=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(i),B<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(C){return C(new Ne(t))})}else this.undoRedoManager.replaceLastUndoStep(i)}},A.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},A.prototype.undoStep=function(){var t=this,i=this.undoRedoManager.undo();i!==void 0&&(this.restoreState(i),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(S){return S(new Ne(t))}))},A.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},A.prototype.redoStep=function(){var t=this,i=this.undoRedoManager.redo();i!==void 0&&(this.restoreState(i),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(S){return S(new Ne(t))}))},A.prototype.stepZoom=function(){var t=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=t<this.zoomSteps.length-1?this.zoomSteps[t+1]:this.zoomSteps[0]},A.prototype.panTo=function(t){this.contentDiv.scrollBy({left:this.prevPanPoint.x-t.x,top:this.prevPanPoint.y-t.y}),this.prevPanPoint=t},A.prototype.startRenderAndClose=function(){return z(this,void 0,void 0,function(){var t,i,S=this;return ee(this,function(B){switch(B.label){case 0:return[4,this.render()];case 1:return t=B.sent(),i=this.getState(),this.eventListeners.render.forEach(function(C){return C(new st(S,t,i))}),this.close(!0),[2]}})})},A.prototype.getState=function(t){t===!0&&this.setCurrentMarker();var i={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(S){return i.markers.push(S.getState())}),i},A.prototype.restoreState=function(t){var i=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);t.markers.forEach(function(S){var B=i._availableMarkerTypes.find(function($){return $.typeName===S.typeName});if(B!==void 0){var C=i.addNewMarker(B);C.restoreState(S),i.addMarkerEvents(C),i.markers.push(C)}}),t.width&&t.height&&(t.width!==this.imageWidth||t.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/t.width,this.imageHeight/t.height),this.eventListeners.restorestate.forEach(function(S){return S(new Ne(i))})},A.prototype.addNewMarker=function(t){var i=X.createGroup();return this.markerImage.appendChild(i),new t(i,this.overlayContainer,this.settings)},A.prototype.createNewMarker=function(t){var i,S=this;(i=typeof t=="string"?this._availableMarkerTypes.find(function(B){return B.typeName===t}):t)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(i),this.addMarkerEvents(this._currentMarker),this.markerImage.style.cursor="crosshair",this.toolbar.setActiveMarkerButton(i.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(B){return B(new je(S,S._currentMarker))}))},A.prototype.addMarkerEvents=function(t){t.onMarkerCreated=this.markerCreated,t.onColorChanged=this.colorChanged,t.onFillColorChanged=this.fillColorChanged,t.onStateChanged=this.markerStateChanged},A.prototype.markerCreated=function(t){var i=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(t),this.setCurrentMarker(t),t instanceof ie&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(ie):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(S){return S(new je(i,t))})},A.prototype.colorChanged=function(t){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=t,this.settings.defaultStrokeColor=t)},A.prototype.fillColorChanged=function(t){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=t)},A.prototype.markerStateChanged=function(t){var i=this;this.eventListeners.markerchange.forEach(function(S){return S(new je(i,t))})},A.prototype.setCurrentMarker=function(t){var i=this;this._currentMarker!==t&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(S){return S(new je(i,i._currentMarker))})),this._currentMarker=t,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(S){return S(new je(i,i._currentMarker))}))},A.prototype.onPointerDown=function(t){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||t.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var i=this.markers.find(function(S){return S.ownsTarget(t.target)});i!==void 0?(this.setCurrentMarker(i),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(t.clientX,t.clientY),t.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:t.clientX,y:t.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(t.clientX,t.clientY))},A.prototype.onDblClick=function(t){if(this._isFocused||this.focus(),this.mode==="select"){var i=this.markers.find(function(S){return S.ownsTarget(t.target)});i!==void 0&&i!==this._currentMarker&&this.setCurrentMarker(i),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(t.clientX,t.clientY),t.target):this.setCurrentMarker()}},A.prototype.onPointerMove=function(t){this.touchPoints!==1&&t.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||t.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(t.clientX,t.clientY)):this.zoomLevel>1&&this.panTo({x:t.clientX,y:t.clientY}))},A.prototype.onPointerUp=function(t){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(t.clientX,t.clientY)),this.isDragging=!1,this.addUndoStep()},A.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},A.prototype.onKeyUp=function(t){this._currentMarker===void 0||this.notesArea!==void 0||t.key!=="Delete"&&t.key!=="Backspace"||this.deleteSelectedMarker()},A.prototype.clientToLocalCoordinates=function(t,i){var S=this.markerImage.getBoundingClientRect(),B=S.width/this.imageWidth/this.zoomLevel,C=S.height/this.imageHeight/this.zoomLevel;return{x:(t-S.left)/this.zoomLevel/B,y:(i-S.top)/this.zoomLevel/C}},A.prototype.onWindowResize=function(){this.positionUI()},A.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var t=this.target.getClientRects(),i=t.length>0&&t.item(0)&&t.item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=i+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},A.prototype.addLicenseKey=function(t){oe.addKey(t)},A.prototype.addEventListener=function(t,i){this.eventListeners.addEventListener(t,i)},A.prototype.removeEventListener=function(t,i){this.eventListeners.removeEventListener(t,i)},A.prototype.renderState=function(t){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(t),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(A.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),A.prototype.focus=function(){var t=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(i){return i(new Ne(t))}))},A.prototype.blur=function(){var t=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(i){return i(new Ne(t))}))},A.instanceCounter=0,A}();/* **********************************
cropro version 1.6.0
@license SEE LICENSE IN LICENSE
copyright Alan Mendelevich
see README and LICENSE for details
********************************** *//*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Ye=function(A,t){return(Ye=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,S){i.__proto__=S}||function(i,S){for(var B in S)Object.prototype.hasOwnProperty.call(S,B)&&(i[B]=S[B])})(A,t)};function ct(A,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=A}Ye(A,t),A.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}function bt(A,t,i,S){return new(i||(i=Promise))(function(B,C){function $(Oe){try{Ce(S.next(Oe))}catch(ce){C(ce)}}function ne(Oe){try{Ce(S.throw(Oe))}catch(ce){C(ce)}}function Ce(Oe){var ce;Oe.done?B(Oe.value):(ce=Oe.value,ce instanceof i?ce:new i(function(Be){Be(ce)})).then($,ne)}Ce((S=S.apply(A,t||[])).next())})}function mt(A,t){var i,S,B,C,$={label:0,sent:function(){if(1&B[0])throw B[1];return B[1]},trys:[],ops:[]};return C={next:ne(0),throw:ne(1),return:ne(2)},typeof Symbol=="function"&&(C[Symbol.iterator]=function(){return this}),C;function ne(Ce){return function(Oe){return function(ce){if(i)throw new TypeError("Generator is already executing.");for(;$;)try{if(i=1,S&&(B=2&ce[0]?S.return:ce[0]?S.throw||((B=S.return)&&B.call(S),0):S.next)&&!(B=B.call(S,ce[1])).done)return B;switch(S=0,B&&(ce=[2&ce[0],B.value]),ce[0]){case 0:case 1:B=ce;break;case 4:return $.label++,{value:ce[1],done:!1};case 5:$.label++,S=ce[1],ce=[0];continue;case 7:ce=$.ops.pop(),$.trys.pop();continue;default:if(!(B=$.trys,(B=B.length>0&&B[B.length-1])||ce[0]!==6&&ce[0]!==2)){$=0;continue}if(ce[0]===3&&(!B||ce[1]>B[0]&&ce[1]<B[3])){$.label=ce[1];break}if(ce[0]===6&&$.label<B[1]){$.label=B[1],B=ce;break}if(B&&$.label<B[2]){$.label=B[2],$.ops.push(ce);break}B[2]&&$.ops.pop(),$.trys.pop();continue}ce=t.call(A,$)}catch(Be){ce=[6,Be],S=0}finally{i=B=0}if(5&ce[0])throw ce[1];return{value:ce[0]?ce[1]:void 0,done:!0}}([Ce,Oe])}}}var Tt=function(){function A(){}return A.addKey=function(t){A.key=t},Object.defineProperty(A,"isLicensed",{get:function(){return!!A.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(A.key)},enumerable:!1,configurable:!0}),A}(),He=function(){function A(){}return A.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},A.setAttributes=function(t,i){for(var S=0,B=i;S<B.length;S++){var C=B[S],$=C[0],ne=C[1];t.setAttribute($,ne)}},A.createRect=function(t,i,S){var B=document.createElementNS("http://www.w3.org/2000/svg","rect");return B.setAttribute("width",t.toString()),B.setAttribute("height",i.toString()),S&&A.setAttributes(B,S),B},A.createLine=function(t,i,S,B,C){var $=document.createElementNS("http://www.w3.org/2000/svg","line");return $.setAttribute("x1",t.toString()),$.setAttribute("y1",i.toString()),$.setAttribute("x2",S.toString()),$.setAttribute("y2",B.toString()),C&&A.setAttributes($,C),$},A.createPolygon=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","polygon");return S.setAttribute("points",t),i&&A.setAttributes(S,i),S},A.createCircle=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","circle");return S.setAttribute("cx",(t/2).toString()),S.setAttribute("cy",(t/2).toString()),S.setAttribute("r",t.toString()),i&&A.setAttributes(S,i),S},A.createEllipse=function(t,i,S){var B=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return B.setAttribute("cx",(t/2).toString()),B.setAttribute("cy",(i/2).toString()),B.setAttribute("rx",(t/2).toString()),B.setAttribute("ry",(i/2).toString()),S&&A.setAttributes(B,S),B},A.createGroup=function(t){var i=document.createElementNS("http://www.w3.org/2000/svg","g");return t&&A.setAttributes(i,t),i},A.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},A.createMarker=function(t,i,S,B,C,$,ne){var Ce=document.createElementNS("http://www.w3.org/2000/svg","marker");return A.setAttributes(Ce,[["id",t],["orient",i],["markerWidth",S.toString()],["markerHeight",B.toString()],["refX",C.toString()],["refY",$.toString()]]),Ce.appendChild(ne),Ce},A.createText=function(t){var i=document.createElementNS("http://www.w3.org/2000/svg","text");return i.setAttribute("x","0"),i.setAttribute("y","0"),t&&A.setAttributes(i,t),i},A.createTSpan=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","tspan");return S.textContent=t,i&&A.setAttributes(S,i),S},A.createImage=function(t){var i=document.createElementNS("http://www.w3.org/2000/svg","image");return t&&A.setAttributes(i,t),i},A.createPoint=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return S.x=t,S.y=i,S},A.createPath=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg","path");return S.setAttribute("d",t),i&&A.setAttributes(S,i),S},A.createElement=function(t,i){var S=document.createElementNS("http://www.w3.org/2000/svg",t);return i&&A.setAttributes(S,i),S},A.getHollowRectanglePath=function(t,i,S,B,C,$,ne,Ce){return"M"+t+","+i+"V"+(i+B)+"H"+(t+S)+"V"+i+"H"+C+"V"+$+"H"+(C+ne)+"V"+($+Ce)+"H"+C+"V"+i+"Z"},A}(),_t=function(){function A(t){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+t+"_"}return Object.defineProperty(A.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#333333",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarBackgroundActiveColor:"#282828",toolbarColor:"#eeeeee",cropShadeColor:"#ffffff",cropFrameColor:"#ffffff",gripColor:"#333333",gripFillColor:"#cccccc",toolbarHeight:40}},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),A.prototype.addClass=function(t){return this.styleSheet===void 0&&this.addStyleSheet(),t.name=""+this.classNamePrefix+t.localName,this.classes.push(t),this.styleSheet.sheet.insertRule("."+t.name+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length),t},A.prototype.addRule=function(t){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(t),this.styleSheet.sheet.insertRule(t.selector+" {"+t.style+"}",this.styleSheet.sheet.cssRules.length)},A.prototype.addStyleSheet=function(){var t;this.styleSheet=document.createElement("style"),((t=this.styleSheetRoot)!==null&&t!==void 0?t:document.head).appendChild(this.styleSheet),this.addRule(new vt("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new vt("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new vt("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new lt("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new lt("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},A.prototype.removeStyleSheet=function(){var t;this.styleSheet&&(((t=this.styleSheetRoot)!==null&&t!==void 0?t:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},A}(),vt=function(A,t){this.selector=A,this.style=t},lt=function(A,t){this.localName=A,this.style=t},Ct=function(){function A(){this.blocks=[],this.display=""}return A.prototype.addButtonBlock=function(t){t.className=this.blockClassName,t.buttonClassName=this.buttonClassName,t.buttonColorsClassName=this.buttonColorsClassName,t.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(t)},A.prototype.addElementBlock=function(t){t.className===void 0&&(t.className=this.blockClassName),this.blocks.push(t)},A.prototype.getUI=function(){var t=document.createElement("div");return t.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,t.style.display=this.display,this.blocks.forEach(function(i){return t.appendChild(i.getUI())}),t},A}(),Ot=function(){function A(){}return A.prototype.getUI=function(){var t=document.createElement("div");if(t.className=this.className,this.minWidth!==void 0&&(t.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":t.style.justifyContent="flex-start";break;case"center":t.style.justifyContent="center";break;case"end":t.style.justifyContent="flex-end"}return t.style.whiteSpace="nowrap",t},A}(),wt=function(A){function t(){var i=A!==null&&A.apply(this,arguments)||this;return i.buttons=[],i}return ct(t,A),t.prototype.addButton=function(i){i.className=this.buttonClassName,i.colorsClassName=this.buttonColorsClassName,i.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(i)},t.prototype.getUI=function(){var i=A.prototype.getUI.call(this);return this.buttons.forEach(function(S){return i.appendChild(S.getUI())}),i},t}(Ot),gt=function(){function A(t,i){this._isActive=!1,this._isHidden=!1,this._icon=t,this.title=i,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(A.prototype,"icon",{get:function(){return this._icon},set:function(t){this._icon=t,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isActive",{get:function(){return this._isActive},set:function(t){this._isActive=t,this.adjustClassName()},enumerable:!1,configurable:!0}),A.prototype.getUI=function(){var t=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.setAttribute("role","button"),this.buttonContainer.setAttribute("aria-label",this.title),this.buttonContainer.setAttribute("data-action",this.title),this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return t.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},A.prototype.adjustClassName=function(){this.activeColorsClassName&&(this._isActive&&this.buttonContainer.className.indexOf(this.activeColorsClassName)<0?this.buttonContainer.className+=" "+this.activeColorsClassName:this._isActive||(this.buttonContainer.className=this.buttonContainer.className.replace(this.activeColorsClassName,"")))},A.prototype.hide=function(){this._isHidden=!0},A}(),Mt=function(A){function t(){var i=A!==null&&A.apply(this,arguments)||this;return i.elements=[],i}return ct(t,A),t.prototype.addElement=function(i){this.elements.push(i)},t.prototype.getUI=function(){var i=A.prototype.getUI.call(this);return this.elements.forEach(function(S){return i.appendChild(S)}),i},t}(Ot),Bt=function(){function A(t,i){this.horizontal=t,this.vertical=i}return Object.defineProperty(A.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),A.prototype.getVerticalLength=function(t){return t/this.ratio},A.prototype.getHorizontalLength=function(t){return t*this.ratio},A}(),Dt=function(){function A(){}return A.getIcon=function(t,i){if(t>0&&i>0){var S=new Bt(t,i),B=S.ratio>=1?20:S.getHorizontalLength(20),C=S.ratio<1?20:S.getVerticalLength(20),$=document.createElementNS("http://www.w3.org/2000/svg","svg");$.setAttribute("xmlns","http://www.w3.org/2000/svg"),$.setAttribute("viewBox","0 0 24 24"),document.body.appendChild($);var ne=He.createDefs();$.appendChild(ne);var Ce=He.createElement("clipPath",[["id","text-bg-clip"]]);ne.appendChild(Ce);var Oe=He.createPath(He.getHollowRectanglePath((24-B)/2,(24-C)/2,B,C,(24-B)/2+2,(24-C)/2+2,B-4,C-4));$.appendChild(Oe);var ce=He.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);ce.appendChild(He.createTSpan(t+":"+i)),$.appendChild(ce);var Be=ce.getBBox();He.setAttributes(ce,[["x",((24-Be.width)/2).toString()],["y",((24-Be.height)/2-Be.y).toString()]]);var Ke=He.createPath(He.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(Be.width))/2,(24-Math.ceil(Be.height))/2,Math.ceil(Be.width),Math.ceil(Be.height)));return Ce.appendChild(Ke),He.setAttributes(Oe,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild($),$.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},A}(),Ht=function(A){function t(i,S,B){var C=A.call(this,i,S)||this;return C.isDropdownOpen=!1,C.onClick=C.dropdownButtonClicked,C.dropdownButtons=B,C}return ct(t,A),t.prototype.setupDropdown=function(){var i=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(S){S.className=i.className,S.colorsClassName=i.colorsClassName,i.dropdownBlock.appendChild(S.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},t.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},t.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},t.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},t.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},t.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},t}(gt),At=function(){function A(t,i){this.GRIP_SIZE=10,this.color=t,this.fillColor=i,this.visual=He.createGroup(),this.visual.appendChild(He.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(He.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return A.prototype.ownsTarget=function(t){return t===this.visual||t===this.visual.childNodes[0]||t===this.visual.childNodes[1]},A.prototype.setCenter=function(t,i){this.visual.childNodes.forEach(function(S){return He.setAttributes(S,[["cx",t.toString()],["cy",i.toString()]])})},A}(),Gt=function(){function A(t,i,S,B){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this._zoomToCropEnabled=!1,this.cropRectChanged=!1,this.canvasWidth=t,this.canvasHeight=i,this.margin=S,this.container=B,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(A.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(t){this._aspectRatio=t,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(t){this._isGridVisible=t,this.gridContainer&&He.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(t){this._zoomFactor=t,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"zoomToCropEnabled",{set:function(t){this._zoomToCropEnabled=t},enumerable:!1,configurable:!0}),A.prototype.open=function(){var t=this;this.cropShadeElement=He.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=He.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var i=0;i<this.numberOfGridLines;i++)this.horizontalGridLines.push(He.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(He.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(S){return t.gridContainer.appendChild(S)}),this.verticalGridLines.forEach(function(S){return t.gridContainer.appendChild(S)}),this.cropRectElement=He.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new At(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new At(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new At(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new At(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},A.prototype.setCropRectangle=function(t){this.cropRect=t;var i=Object.assign({},this.cropRect);this._zoomToCropEnabled&&(i.width=this.cropRect.width*this.zoomFactor,i.height=this.cropRect.height*this.zoomFactor,i.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-i.width/2,i.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-i.height/2),He.setAttributes(this.cropRectElement,[["x",i.x.toString()],["y",i.y.toString()],["width",i.width.toString()],["height",i.height.toString()]]);var S=i.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(C,$){var ne=i.y+S*($+1);He.setAttributes(C,[["x1",""+i.x],["y1",""+ne],["x2",""+(i.x+i.width)],["y2",""+ne]])});var B=i.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(C,$){var ne=i.x+B*($+1);He.setAttributes(C,[["x1",""+ne],["y1",""+i.y],["x2",""+ne],["y2",""+(i.y+i.height)]])}),He.setAttributes(this.cropShadeElement,[["d",He.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,i.x,i.y,i.width,i.height)]]),this.topLeftGrip.setCenter(i.x,i.y),this.topRightGrip.setCenter(i.x+i.width,i.y),this.bottomLeftGrip.setCenter(i.x,i.y+i.height),this.bottomRightGrip.setCenter(i.x+i.width,i.y+i.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},A.prototype.attachEvents=function(){this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp)},A.prototype.clientToLocalCoordinates=function(t,i){var S=this.container.getBoundingClientRect();return{x:t-S.left+this.margin,y:i-S.top+this.margin}},A.prototype.onPointerDown=function(t){this.container.setPointerCapture(t.pointerId),this.previousPoint=this.clientToLocalCoordinates(t.clientX,t.clientY),this.cropRectElement===t.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(t.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(t.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(t.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(t.target)&&(this.activeGrip=this.bottomRightGrip)},A.prototype.onPointerMove=function(t){if(this.isMoving)this.move(this.clientToLocalCoordinates(t.clientX,t.clientY));else if(this.activeGrip){var i=this.clientToLocalCoordinates(t.clientX,t.clientY);this.resize(i)}t.preventDefault()},A.prototype.onPointerUp=function(t){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(t.pointerId)},A.prototype.move=function(t){var i=t.x-this.previousPoint.x,S=t.y-this.previousPoint.y;this.zoomFactor!==1&&(i=-i/this.zoomFactor,S=-S/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+i),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+S),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=t},A.prototype.resize=function(t){var i=Object.assign({},this.cropRect),S=t.x-this.previousPoint.x,B=t.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:i.x+S<this.margin&&(S=this.margin-i.x),i.x+=S,i.width=this.cropRect.x+this.cropRect.width-i.x;break;case this.bottomRightGrip:case this.topRightGrip:i.width+S>this.canvasWidth*this.zoomFactor&&(S=this.canvasWidth*this.zoomFactor-i.width),i.width+=S}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(i.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(S),i.height=this.aspectRatio.getVerticalLength(i.width)):(i.y+=B,i.height=this.cropRect.y+this.cropRect.height-i.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?i.height=this.aspectRatio.getVerticalLength(i.width):i.height+=B}i.width<10&&(i.x=this.cropRect.x,i.width=10),i.height<10&&(i.y=this.cropRect.y,i.height=10),this.previousPoint=t,i.x>=this.margin&&i.y>=this.margin&&Math.floor(i.x-this.margin+i.width)<=Math.ceil(this.canvasWidth)&&Math.floor(i.y-this.margin+i.height)<=Math.ceil(this.canvasHeight)&&(this.cropRect=i,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},A.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var t=this.cropRect.x+this.cropRect.width/2,i=this.cropRect.y+this.cropRect.height/2,S=this.aspectRatio.getHorizontalLength(this.cropRect.height),B=this.aspectRatio.getVerticalLength(this.cropRect.width);S/this.canvasWidth<B/this.canvasHeight?this.cropRect.width=S:this.cropRect.height=B,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=t-this.cropRect.width/2,this.cropRect.y=i-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},A.prototype.getRescaledRect=function(t,i,S,B,C,$){var ne=S/t,Ce=B/i;return{x:(C.x-$)*ne+$,y:(C.y-$)*Ce+$,width:C.width*ne,height:C.height*Ce}},A.prototype.scaleCanvas=function(t,i){var S=this.getRescaledRect(this.canvasWidth,this.canvasHeight,t,i,this.cropRect,this.margin);this.canvasWidth=t,this.canvasHeight=i,this.onCropChange&&this.onCropChange(S),this.setCropRectangle(S)},A}(),Kt=function(){function A(t){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=t,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(A.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),A.prototype.getUI=function(){return this.controlContainer=document.createElement("div"),this.controlContainer.title=this.title,this.controlContainer.setAttribute("role","button"),this.controlContainer.setAttribute("aria-label",this.title),this.controlContainer.setAttribute("data-action",this.title),this.controlContainer.className=this.className+" "+this.colorsClassName,this.controlContainer.appendChild(this.getVisual()),this.controlContainer.addEventListener("pointerdown",this.onPointerDown),this.controlContainer.addEventListener("pointermove",this.onPointerMove),this.controlContainer.addEventListener("pointerup",this.onPointerUp),this.uiContainer.appendChild(this.controlContainer),this.uiContainer.style.display="inline-block",this.uiContainer.style.touchAction="none",this.setAngleLabel(),this.positionScaleShape(),this.uiContainer},A.prototype.onPointerDown=function(t){this.controlContainer.setPointerCapture(t.pointerId),this.isDragging=!0,this.previousPoint={x:t.clientX,y:t.clientY}},A.prototype.onPointerMove=function(t){this.isDragging&&(this.onAngleChange&&this.onAngleChange((t.clientX-this.previousPoint.x)/5),this.previousPoint.x=t.clientX)},A.prototype.onPointerUp=function(t){this.isDragging&&this.onAngleChange&&this.onAngleChange((t.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(t.pointerId)},A.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var t=this.angleLabelText.getBBox();He.setAttributes(this.angleLabelElement,[["x",((this.width-t.width)/2).toString()],["y",(this.height/2).toString()]])}},A.prototype.positionScaleShape=function(){if(this.scaleShape){var t=this.scaleShape.transform.baseVal.getItem(0);t.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(t,0)}},A.prototype.getVisual=function(){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("width",this.width+"px"),t.setAttribute("height",this.height+"px"),t.setAttribute("viewBox","0 0 "+this.width+" "+this.height),t.style.flexShrink="0",document.body.appendChild(t);for(var i="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,S=1;S<=this.width/5+10;S++){var B=S%5==0?this.height/3:this.height/6;i+="h4v"+-B+"h1v"+B}i+="v1H0Z",this.scaleShape=He.createPath(i);var C=He.createTransform();this.scaleShape.transform.baseVal.appendItem(C),t.appendChild(this.scaleShape),this.angleLabelElement=He.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=He.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var $=He.createTSpan("");return $.innerHTML="&deg;",this.angleLabelElement.appendChild($),t.appendChild(this.angleLabelElement),document.body.removeChild(t),t},A}(),jt=function(){function A(){this.naturalSize=!1,this.imageType="image/png",this.rasterize=this.rasterize.bind(this)}return A.prototype.rasterize=function(t,i,S,B,C,$,ne){var Ce=this;return new Promise(function(Oe){var ce=document.createElement("canvas");ce.width=t.width.baseVal.value-2*B,ce.height=t.height.baseVal.value-2*B;var Be=1,Ke=1;if(Ce.naturalSize===!0?(Be=Math.abs(i.naturalWidth/(t.width.baseVal.value-2*B)/$),Ke=Math.abs(i.naturalHeight/(t.height.baseVal.value-2*B)/ne),ce.width=Math.abs(i.naturalWidth/$),ce.height=Math.abs(i.naturalHeight/ne)):Ce.width!==void 0&&Ce.height!==void 0&&(Be=Ce.width/S.width,Ke=Ce.height/S.height,ce.width*=Be,ce.height*=Ke),Ce.maxSize!==void 0&&ce.width*ce.height>=Ce.maxSize){var nt=ce.width*ce.height,yt=Math.sqrt(Ce.maxSize/nt);Be*=yt,Ke*=yt,ce.width*=yt,ce.height*=yt}var dt=ce.getContext("2d");dt.translate(ce.width/2,ce.height/2),dt.rotate(C*Math.PI/180),dt.scale($,ne),dt.translate(-ce.width/2,-ce.height/2),dt.drawImage(i,0,0,ce.width,ce.height);var at=document.createElement("canvas");at.width=S.width*Be,at.height=S.height*Ke,at.getContext("2d").putImageData(dt.getImageData((S.x-B)*Be,(S.y-B)*Ke,S.width*Be,S.height*Ke),0,0),Oe(at.toDataURL(Ce.imageType,Ce.imageQuality))})},A}(),zt=function(){function A(t){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this.stateChangeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this.previousState="",this._instanceNo=A.instanceCounter++,this.styles=new _t(this.instanceNo),this.target=t,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this),this.renderState=this.renderState.bind(this),this.addStateChangeEventListener=this.addStateChangeEventListener.bind(this),this.removeStateChangeEventListener=this.removeStateChangeEventListener.bind(this),this.onStateChanged=this.onStateChanged.bind(this)}return Object.defineProperty(A.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(t){this._zoomToCropEnabled=t,this.cropLayer!==void 0&&(this.cropLayer.zoomToCropEnabled=this._zoomToCropEnabled),t?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(t){this._isGridVisible=t,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"gridLines",{get:function(){return this._gridLines},set:function(t){this._gridLines=t,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(t){this._rotationAngle=t,this.straightener&&(this.straightener.angle=this._rotationAngle),this.onStateChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"aspectRatio",{get:function(){var t;return(t=this._aspectRatio)!==null&&t!==void 0?t:this.aspectRatios[0]},set:function(t){this._aspectRatio=t},enumerable:!1,configurable:!0}),A.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},A.prototype.show=function(){this.showUI(),this.open()},A.prototype.close=function(t){t===void 0&&(t=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),t||this.closeEventListeners.forEach(function(i){return i()}),this._isOpen=!1)},A.prototype.addRenderEventListener=function(t){this.renderEventListeners.push(t)},A.prototype.removeRenderEventListener=function(t){this.renderEventListeners.indexOf(t)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(t),1)},A.prototype.addCloseEventListener=function(t){this.closeEventListeners.push(t)},A.prototype.removeCloseEventListener=function(t){this.closeEventListeners.indexOf(t)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(t),1)},A.prototype.addStateChangeEventListener=function(t){this.stateChangeEventListeners.push(t)},A.prototype.removeStateChangeEventListener=function(t){this.stateChangeEventListeners.indexOf(t)>-1&&this.stateChangeEventListeners.splice(this.stateChangeEventListeners.indexOf(t),1)},A.prototype.setupResizeObserver=function(){var t=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){t.resize(t.target.clientWidth,t.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},A.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var t=1*this.target.clientWidth/this.target.clientHeight,i=this.contentDiv.clientWidth/t>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*t:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,S=i+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/t;this.resize(i,S)}},A.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},A.prototype.setEditingTargetSize=function(){this.editorCanvas.style.width=this.imageWidth+2*this.CANVAS_MARGIN+"px",this.editorCanvas.style.height=this.imageHeight+2*this.CANVAS_MARGIN+"px",He.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},A.prototype.resize=function(t,i){this.imageWidth=Math.round(t),this.imageHeight=Math.round(i),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation(),this.onStateChanged()},A.prototype.setEditingTarget=function(){He.setAttributes(this.editingTarget,[["href",this.target.src]]),this.setEditingTargetSize()},A.prototype.setTopLeft=function(){var t=this.target.getBoundingClientRect(),i=this.editorCanvas.getBoundingClientRect();this.left=t.left-i.left-this.CANVAS_MARGIN,this.top=t.top-i.top-this.CANVAS_MARGIN},A.prototype.initCropCanvas=function(){this.cropImageHolder=document.createElement("div"),this.cropImageHolder.style.setProperty("touch-action","none"),this.cropImageHolder.style.setProperty("-ms-touch-action","none"),this.cropImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.cropImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImage.style.pointerEvents="auto",this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.cropImageHolder.style.transformOrigin="top left",this.positionCropImage(),this.defs=He.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=He.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=He.createGroup(),this.editingTargetRotationScaleContainer=He.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var t=He.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(t);var i=He.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(i),this.editingTargetContainer=He.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},A.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},A.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=He.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new Gt(this.imageWidth,this.imageHeight,this.CANVAS_MARGIN,this.cropLayerContainer),this.cropLayer.onCropChange=this.cropRectChanged,this.cropLayer.numberOfGridLines=this.gridLines,this.cropLayer.isGridVisible=this.isGridVisible,this.cropLayer.cropShadeColor=this.styles.settings.cropShadeColor,this.cropLayer.cropFrameColor=this.styles.settings.cropFrameColor,this.cropLayer.gripColor=this.styles.settings.gripColor,this.cropLayer.gripFillColor=this.styles.settings.gripFillColor,this.cropLayer.zoomToCropEnabled=this.zoomToCropEnabled,this.cropLayer.open(),this.cropLayer.setCropRectangle(this.cropRect),this.zoomToCropEnabled&&this.zoomToCrop()},A.prototype.zoomToCrop=function(){if(this.cropRect){var t=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,i=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=t+"px "+i+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-t+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-i+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},A.prototype.unzoomFromCrop=function(){this.zoomFactor=1,this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin="center",this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px) scale(1)",this.cropLayer.zoomFactor=this.zoomFactor)},A.prototype.cropRectChanged=function(t){this.cropRect=t,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1,this.onStateChanged()},A.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},A.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},A.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},A.prototype.showUI=function(){var t,i;switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var S=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,B=this.target.offsetTop>S+this.CANVAS_MARGIN?this.target.offsetTop-(S+this.CANVAS_MARGIN):0;B+=(t=this.uiOffsetTop)!==null&&t!==void 0?t:0;var C=this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0;C+=(i=this.uiOffsetLeft)!==null&&i!==void 0?i:0,this.coverDiv.style.top=B+"px",this.coverDiv.style.left=C+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.processingUi=document.createElement("div"),this.processingUi.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; background: none; display: block; shape-rendering: auto;" width="50px" height="50px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
<rect x="19" y="19" width="20" height="20" fill="#eeeeee">
<animate attributeName="fill" values="#888888;#eeeeee;#eeeeee" keyTimes="0;0.125;1" dur="1s" repeatCount="indefinite" begin="0s" calcMode="discrete"></animate>
</rect><rect x="40" y="19" width="20" height="20" fill="#eeeeee">
<animate attributeName="fill" values="#888888;#eeeeee;#eeeeee" keyTimes="0;0.125;1" dur="1s" repeatCount="indefinite" begin="0.125s" calcMode="discrete"></animate>
</rect><rect x="61" y="19" width="20" height="20" fill="#eeeeee">
<animate attributeName="fill" values="#888888;#eeeeee;#eeeeee" keyTimes="0;0.125;1" dur="1s" repeatCount="indefinite" begin="0.25s" calcMode="discrete"></animate>
</rect><rect x="19" y="40" width="20" height="20" fill="#eeeeee">
<animate attributeName="fill" values="#888888;#eeeeee;#eeeeee" keyTimes="0;0.125;1" dur="1s" repeatCount="indefinite" begin="0.875s" calcMode="discrete"></animate>
</rect><rect x="61" y="40" width="20" height="20" fill="#eeeeee">
<animate attributeName="fill" values="#888888;#eeeeee;#eeeeee" keyTimes="0;0.125;1" dur="1s" repeatCount="indefinite" begin="0.375s" calcMode="discrete"></animate>
</rect><rect x="19" y="61" width="20" height="20" fill="#eeeeee">
<animate attributeName="fill" values="#888888;#eeeeee;#eeeeee" keyTimes="0;0.125;1" dur="1s" repeatCount="indefinite" begin="0.75s" calcMode="discrete"></animate>
</rect><rect x="40" y="61" width="20" height="20" fill="#eeeeee">
<animate attributeName="fill" values="#888888;#eeeeee;#eeeeee" keyTimes="0;0.125;1" dur="1s" repeatCount="indefinite" begin="0.625s" calcMode="discrete"></animate>
</rect><rect x="61" y="61" width="20" height="20" fill="#eeeeee">
<animate attributeName="fill" values="#888888;#eeeeee;#eeeeee" keyTimes="0;0.125;1" dur="1s" repeatCount="indefinite" begin="0.5s" calcMode="discrete"></animate>
</rect>
</svg>`,this.processingUi.style.position="absolute",this.processingUi.style.width="100%",this.processingUi.style.height="100%",this.processingUi.style.backgroundColor="rgba(0,0,0,0.3)",this.processingUi.style.alignItems="center",this.processingUi.style.justifyContent="center",this.processingUi.style.display="none",this.editorCanvas.appendChild(this.processingUi),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},A.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},A.prototype.addTopToolbar=function(){var t=this;this.topToolbar=new Ct,this.topToolbar.display=this.styles.settings.hideTopToolbar?"none":"",this.topToolbar.className=this.toolbarStyleClass.name,this.topToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.topToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.topToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.topToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.topToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.topToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var i=new wt;i.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(i);var S=[];this.aspectRatios.forEach(function(Ke){var nt=new gt(Dt.getIcon(Ke.horizontal,Ke.vertical),Ke.horizontal===0&&Ke.vertical===0?"FREE":Ke.horizontal+":"+Ke.vertical);nt.onClick=function(){return t.ratioButtonClicked(Ke)},S.push(nt)}),this.aspectRatioButton=new Ht(Dt.getIcon(0,0),"Aspect ratio",S),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,i.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var B=new gt('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");B.isActive=this.isGridVisible,B.onClick=function(){t.isGridVisible=!t.isGridVisible,B.isActive=t.isGridVisible},i.addButton(B);var C=new gt('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(C.isActive=this.zoomToCropEnabled,C.onClick=function(){t.zoomToCropEnabled=!t.zoomToCropEnabled,C.isActive=t.zoomToCropEnabled},i.addButton(C),!Tt.isLicensed){var $=new Mt;this.topToolbar.addElementBlock($);var ne=document.createElement("div");ne.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Ce=document.createElement("a");Ce.style.color="currentColor",Ce.href="https://markerjs.com/products/cropro",Ce.target="_blank",Ce.innerHTML='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><path d="M16.326 14.895c0 1.126-.558 1.688-1.673 1.688H9.931c-1.116 0-1.674-.562-1.674-1.688V3.733c0-1.126.558-1.688 1.674-1.688h4.722c1.115 0 1.673.562 1.673 1.688v2.899h-1.957V3.793h-4.124v11.042h4.124v-3.242h1.957v3.302z" fill="currentColor"/><path d="M15.94 7.364a.783.783 0 00-1.065-.304l-11.01 6.126a.783.783 0 00-.303 1.065l4.498 8.085a.783.783 0 001.065.304l11.01-6.126a.783.783 0 00.303-1.065L15.94 7.364zM5.311 14.173l3.737 6.718 9.641-5.364-3.737-6.718-9.641 5.364z" fill="#eef762"/></svg>',ne.appendChild(Ce),$.addElement(ne)}var Oe=new wt;Oe.minWidth=3*this.toolbarHeight+"px",Oe.contentAlign="end",this.topToolbar.addButtonBlock(Oe);var ce=new gt('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");ce.onClick=function(){t.processingUi.style.display="flex",setTimeout(t.startRenderAndClose,100)},Oe.addButton(ce),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(ce.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var Be=new gt('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");Be.onClick=this.close,Oe.addButton(Be),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(Be.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},A.prototype.addBottomToolbar=function(){var t=this;this.bottomToolbar=new Ct,this.bottomToolbar.display=this.styles.settings.hideBottomToolbar?"none":"",this.bottomToolbar.className=this.toolbarStyleClass.name,this.bottomToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.bottomToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.bottomToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.bottomToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.bottomToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.bottomToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var i=new wt;i.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(i);var S=new gt('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");S.onClick=this.rotateLeftButtonClicked,i.addButton(S);var B=new gt('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");B.onClick=this.rotateRightButtonClicked,i.addButton(B);var C=new Mt;C.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(C),this.straightener=new Kt("Straighten"),this.straightener.className=this.toolbarStraightenerStyleClass.name,this.straightener.colorsClassName=this.styles.settings.toolbarStraightenerColorsClassName?this.styles.settings.toolbarStraightenerColorsClassName:this.toolbarStraightenerStyleColorsClass.name,this.straightener.onAngleChange=function(Oe){t.rotateBy(Oe),t.straightener.angle=t.rotationAngle},C.addElement(this.straightener.getUI());var $=new wt;$.minWidth=2*this.toolbarHeight+"px",$.contentAlign="end",this.bottomToolbar.addButtonBlock($);var ne=new gt('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");ne.onClick=this.flipHorizontallyButtonClicked,$.addButton(ne);var Ce=new gt('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");Ce.onClick=this.flipVerticallyButtonClicked,$.addButton(Ce)},A.prototype.ratioButtonClicked=function(t){this.aspectRatio=t,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},A.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=Dt.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},A.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new Bt(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0,this.onStateChanged())},A.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},A.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},A.prototype.restoreState=function(t){if(t){var i=this.cropLayer.getRescaledRect(t.width,t.height,this.imageWidth,this.imageHeight,t.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(i),this.cropRectChanged(i),this.flippedHorizontally=t.flippedHorizontally,this.flippedVertically=t.flippedVertically,this.applyFlip(),this.rotationAngle=t.rotationAngle,this.applyRotation(),this.onStateChanged()}},A.prototype.renderState=function(t){this.displayMode="inline",this.isOpen||this.show(),this.restoreState(t),this.startRenderAndClose()},A.prototype.clientToLocalCoordinates=function(t,i){var S=this.cropImage.getBoundingClientRect();return{x:t-S.left,y:i-S.top}},A.prototype.onWindowResize=function(){this.positionUI()},A.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var t=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=t+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},A.prototype.rotateLeftButtonClicked=function(){var t=this.rotationAngle-90;this.rotationAngle%90!=0&&(t+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(t)},A.prototype.rotateRightButtonClicked=function(){var t=this.rotationAngle+90;this.rotationAngle%90!=0&&(t-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(t)},A.prototype.rotateTo=function(t){t=(t=t>180?t-360:t)<=-180?t+360:t,this.rotationAngle=t,this.applyRotation()},A.prototype.rotateBy=function(t){this.rotateTo((this.rotationAngle+t)%360)},A.prototype.applyRotation=function(){var t=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var i=this.editingTargetRotationContainer.transform.baseVal.getItem(0);i.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(i,0);var S=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/S.width,this.imageHeight/S.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=t},A.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},A.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},A.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")",this.onStateChanged()},A.prototype.startRenderAndClose=function(){return bt(this,void 0,void 0,function(){var t,i;return mt(this,function(S){switch(S.label){case 0:return[4,this.render()];case 1:return t=S.sent(),i=this.getState(),this.renderEventListeners.forEach(function(B){return B(t,i)}),this.close(!0),[2]}})})},A.prototype.render=function(){return bt(this,void 0,void 0,function(){var t,i;return mt(this,function(S){switch(S.label){case 0:return(t=new jt).naturalSize=this.renderAtNaturalSize,t.imageType=this.renderImageType,t.imageQuality=this.renderImageQuality,t.width=this.renderWidth,t.height=this.renderHeight,t.maxSize=this.renderMaxSize,this.unzoomFromCrop(),He.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,t.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return S.sent(),[4,t.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return i=S.sent(),this.processingUi.style.display="none",[2,i]}})})},A.prototype.onStateChanged=function(){var t=this.getState(),i=JSON.stringify(t);this.previousState!==i&&(this.stateChangeEventListeners.forEach(function(S){return S(t)}),this.previousState=i)},A.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new lt("toolbar",`
width: `+(this.displayMode==="inline"?"100%":"calc(100vw - "+2*this.popupMargin+"px)")+`;
flex-shrink: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
height: `+this.toolbarHeight+`px;
box-sizing: content-box;
overflow: hidden;
line-height: 0px;
`)),this.toolbarStyleColorsClass=this.styles.addClass(new lt("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new lt("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var t=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new lt("toolbar_button",`
display: inline-block;
width: `+(this.toolbarHeight-2*t)+`px;
height: `+(this.toolbarHeight-2*t)+`px;
padding: `+t+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new lt("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new lt("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new vt("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new vt("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new lt("toolbar_dropdown",`
position: absolute;
max-width: `+4*this.toolbarHeight+`px;
z-index: 20;
white-space: normal;
box-sizing: content-box;
box-shadow: 3px 3px rgba(33, 33, 33, 0.1);
margin: `+(this.displayMode==="inline"?"0":this.popupMargin)+`px;
line-height: 0px;
`)),this.toolbarDropdownStyleColorsClass=this.styles.addClass(new lt("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new lt("toolbar_straightener_block",`
display: flex;
overflow: hidden;
justify-content: center;
-webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
`)),this.toolbarStraightenerStyleClass=this.styles.addClass(new lt("toolbar_straightener",`
display: flex;
overflow: hidden;
justify-content: center;
height: `+(this.toolbarHeight-2*t)+`px;
padding: `+t+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new lt("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},A.instanceCounter=0,A}(),Vt=fe("8hTe"),Ft=fe.n(Vt),Yt=/<pre[^>]*>/g;function Xt(A){var t=document.createElement("div");return t.innerHTML=A,t.childNodes.length===0?"":t.childNodes[0].nodeValue}var nr=Qe.a=function(A){var t=A.value,i=t===void 0?"":t,S=A.edit,B=S===void 0?!1:S,C=A.className,$=A.showTextOnly,ne=A.showLines,Ce=A.replaces,Oe=A.zoomImg,ce=A.hasMask,Be=A.style,Ke=Be===void 0?{}:Be,nt=A.stylesPrev,yt=nt===void 0?{}:nt,dt=String(i),at=Object(N.useRef)(),Et=Object(N.useRef)(),$t=Object(N.useState)(""),Ut=Object(w.a)($t,2),Lt=Ut[0],St=Ut[1],Zt=Object(N.useState)("office"),Nt=Object(w.a)(Zt,2),Qt=Nt[0],kt=Nt[1],Jt=function(){var Ze=new zt(Et.current);Ze.displayMode="popup",Ze.addRenderEventListener(function(){var ft=Object(V.a)(P.a.mark(function Xe(pt){var rt;return P.a.wrap(function(ut){for(;;)switch(ut.prev=ut.next){case 0:return at.current.style.display="none",ut.next=3,Object(H.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:pt}});case 3:rt=ut.sent,rt!=null&&rt.id&&Ce(Et.current.getAttribute("src").replace(O.a.API_SERVER,""),"/api/attachments/".concat(rt==null?void 0:rt.id,"?type=").concat(rt.content_type));case 5:case"end":return ut.stop()}},Xe)}));return function(Xe){return ft.apply(this,arguments)}}()),Ze.show()},qt=function(){var Ze=new ot(Et.current);Ze.settings.displayMode="popup",Ze.addEventListener("render",function(){var ft=Object(V.a)(P.a.mark(function Xe(pt){var rt;return P.a.wrap(function(ut){for(;;)switch(ut.prev=ut.next){case 0:if(at.current.style.display="none",!Et.current){ut.next=6;break}return ut.next=4,Object(H.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:pt.dataUrl}});case 4:rt=ut.sent,rt!=null&&rt.id&&Ce(Et.current.getAttribute("src").replace(O.a.API_SERVER,""),"/api/attachments/".concat(rt==null?void 0:rt.id,"?type=").concat(rt.content_type));case 6:case"end":return ut.stop()}},Xe)}));return function(Xe){return ft.apply(this,arguments)}}()),Ze.show(),window.markerArea=Ze},Rt=Object(N.useMemo)(function(){at.current&&(at.current.style.zIndex=-1);try{var ht=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Ze=/\"\/api\/attachments\/|\"\/attachments\/download\//g,ft=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;dt=dt.replace(ht,"("+O.a.API_SERVER+"/api/attachments/").replace(Ze,'"'+O.a.API_SERVER+"/api/attachments/").replace(ft,'"'+O.a.API_SERVER+"/files/uploads/").replaceAll("http://video.educoder","https://video.educoder").replaceAll("http://www.educoder.net/api","https://data.educoder.net/api").replaceAll("https://www.educoder.net/api","https://data.educoder.net/api").replace(/\r\n/g,`
`)}catch(It){}var Xe=E(dt),pt=p();if(dt.match(/\[TOC\]/)&&(Xe=Xe.replace("<p>[TOC]</p>",o()),f()),Xe=Xe.replace(/(__special_katext_id_\d+__)/g,function(It,ut){var Wt=pt[ut],rr=Wt.type,ir=Wt.expression;return Object(U.renderToString)(Xt(ir)||"",{displayMode:rr==="block",throwOnError:!1,output:"html"})}),Xe=Xe.replace(/▁/g,"\u2581\u2581\u2581"),m(),$){var rt=document.createElement("div");return rt.innerHTML=Xe,rt.innerText}return setTimeout(function(){return er()},500),Xe},[dt]),xt=Object(N.useRef)();u.WebkitLineClamp=ne,ne&&(Ke=Object(he.a)(Object(he.a)({},Ke),u));function Pt(ht){var Ze=ht.target;if(Ze.tagName.toUpperCase()==="IMG"){if(Oe){var ft=Ze.getAttribute("src");St(ft),kt("image")}}else if(Ze.tagName.toUpperCase()==="A"){var Xe=Ze.getAttribute("href");if(Xe.indexOf("office")>-1)ht.preventDefault(),St(Xe),kt("office");else if(Xe.indexOf("application/pdf")>-1)ht.preventDefault(),St(Xe),kt("pdf");else if(Xe.indexOf("text/html")>-1)ht.preventDefault(),St(Xe),kt("html");else if(Xe.startsWith("#")){ht.preventDefault();var pt=document.getElementById(Xe.replace("#",""));pt&&pt.scrollIntoView(!0)}}}var er=function(){var Ze,ft=(Ze=xt.current)===null||Ze===void 0?void 0:Ze.querySelectorAll("video");ft==null||ft.forEach(function(Xe){if(Xe.oncontextmenu=function(){return!1},Xe.src.indexOf(".m3u8")>-1&&!Xe.canPlayType("application/vnd.apple.mpegurl")){if(M.a.isSupported()){var pt=new M.a;pt.loadSource(Xe.src),pt.attachMedia(Xe)}}})};Object(N.useEffect)(function(){if(xt.current&&Rt&&(Rt.match(Yt)&&window.PR.prettyPrint()),xt.current)return xt.current.addEventListener("click",Pt),function(){xt.current.removeEventListener("click",Pt),m(),f()}},[Rt,xt.current,Pt]);var tr=function(Ze){if(!B)return;Ze.target.nodeName==="IMG"?(at.current.style.zIndex=1,at.current.style.display="flex",at.current.style.width=Ze.target.clientWidth+"px",at.current.style.height=Ze.target.clientHeight+"px",at.current.style.top=Ze.target.offsetTop+"px",at.current.style.left=Ze.target.offsetLeft+"px",Et.current.src=Ze.target.getAttribute("src")):at.current.style.display="none"};return D.a.createElement("div",{style:{position:"relative"}},D.a.createElement("div",{ref:xt,style:Object(he.a)({},Ke),className:"".concat(C||""," markdown-body ").concat(Ft.a.mdBody),onMouseOver:tr,dangerouslySetInnerHTML:{__html:Rt}}),D.a.createElement("div",{ref:at,className:Ft.a.button},D.a.createElement(tt.b,null,D.a.createElement(Ve.a,{onClick:function(){return Jt()}},"\u88C1\u526A"),D.a.createElement(Ve.a,{onClick:function(){return qt()}},"\u7F16\u8F91"))),D.a.createElement("img",{ref:Et,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),D.a.createElement(F.a,{close:!0,data:Lt,type:Lt!=null&&Lt.length?Qt:"",style:Object(he.a)({},yt),onClose:function(){return St("")}}))}},GNbK:function(qe,Qe,fe){"use strict";fe.d(Qe,"a",function(){return T});var et=fe("3ptp"),tt=fe("M6Bk"),ze=fe("T/Jt"),Ve=fe.n(ze),he=fe("AFTV"),V=fe("yuO0"),w=fe("ZIz+"),W=fe("r0bv"),P=function(s){Object(tt.a)(l,s);function l(){for(var d,v=arguments.length,p=new Array(v),m=0;m<v;m++)p[m]=arguments[m];return d=s.call.apply(s,[this].concat(p))||this,d.history=Object(he.a)(d.props),d}var n=l.prototype;return n.render=function(){return Ve.a.createElement(et.c,{history:this.history,children:this.props.children})},l}(Ve.a.Component),N=function(s){Object(tt.a)(l,s);function l(){for(var d,v=arguments.length,p=new Array(v),m=0;m<v;m++)p[m]=arguments[m];return d=s.call.apply(s,[this].concat(p))||this,d.history=Object(he.b)(d.props),d}var n=l.prototype;return n.render=function(){return Ve.a.createElement(et.c,{history:this.history,children:this.props.children})},l}(Ve.a.Component),D=function(l,n){return typeof l=="function"?l(n):l},G=function(l,n){return typeof l=="string"?Object(he.c)(l,null,null,n):l},I=function(l){return l},R=Ve.a.forwardRef;typeof R=="undefined"&&(R=I);function L(s){return!!(s.metaKey||s.altKey||s.ctrlKey||s.shiftKey)}var _=R(function(s,l){var n=s.innerRef,d=s.navigate,v=s.onClick,p=Object(w.a)(s,["innerRef","navigate","onClick"]),m=p.target,r=Object(V.a)({},p,{onClick:function(e){try{v&&v(e)}catch(c){throw e.preventDefault(),c}!e.defaultPrevented&&e.button===0&&(!m||m==="_self")&&!L(e)&&(e.preventDefault(),d())}});return I!==R?r.ref=l||n:r.ref=n,Ve.a.createElement("a",r)}),T=R(function(s,l){var n=s.component,d=n===void 0?_:n,v=s.replace,p=s.to,m=s.innerRef,r=Object(w.a)(s,["component","replace","to","innerRef"]);return Ve.a.createElement(et.e.Consumer,null,function(a){a||Object(W.a)(!1);var e=a.history,c=G(D(p,a.location),a.location),E=c?e.createHref(c):"",y=Object(V.a)({},r,{href:E,navigate:function(){var M=D(p,a.location),O=v?e.replace:e.push;O(M)}});return I!==R?y.ref=l||m:y.innerRef=m,Ve.a.createElement(d,y)})});if(!1)var g,x;var b=function(l){return l},f=Ve.a.forwardRef;typeof f=="undefined"&&(f=b);function u(){for(var s=arguments.length,l=new Array(s),n=0;n<s;n++)l[n]=arguments[n];return l.filter(function(d){return d}).join(" ")}var h=f(function(s,l){var n=s["aria-current"],d=n===void 0?"page":n,v=s.activeClassName,p=v===void 0?"active":v,m=s.activeStyle,r=s.className,a=s.exact,e=s.isActive,c=s.location,E=s.sensitive,y=s.strict,k=s.style,M=s.to,O=s.innerRef,U=Object(w.a)(s,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return Ve.a.createElement(et.e.Consumer,null,function(F){F||Object(W.a)(!1);var H=c||F.location,Y=G(D(M,H),H),Q=Y.pathname,z=Q&&Q.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),ee=z?Object(et.f)(H.pathname,{path:z,exact:a,sensitive:E,strict:y}):null,J=!!(e?e(ee,H):ee),X=J?u(r,p):r,oe=J?Object(V.a)({},k,{},m):k,le=Object(V.a)({"aria-current":J&&d||null,className:X,style:oe,to:Y},U);return b!==f?le.ref=l||O:le.innerRef=O,Ve.a.createElement(T,le)})});if(!1)var o},GcTH:function(qe,Qe){const fe=/[&<>"']/,et=/[&<>"']/g,tt=/[<>"']|&(?!#?\w+;)/,ze=/[<>"']|&(?!#?\w+;)/g,Ve={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},he=s=>Ve[s];function V(s,l){if(l){if(fe.test(s))return s.replace(et,he)}else if(tt.test(s))return s.replace(ze,he);return s}const w=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function W(s){return s.replace(w,(l,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const P=/(^|[^\[])\^/g;function N(s,l){s=s.source||s,l=l||"";const n={replace:(d,v)=>(v=v.source||v,v=v.replace(P,"$1"),s=s.replace(d,v),n),getRegex:()=>new RegExp(s,l)};return n}const D=/[^\w:]/g,G=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function I(s,l,n){if(s){let d;try{d=decodeURIComponent(W(n)).replace(D,"").toLowerCase()}catch(v){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}l&&!G.test(n)&&(n=g(l,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(d){return null}return n}const R={},L=/^[^:]+:\/*[^/]*$/,_=/^([^:]+:)[\s\S]*$/,T=/^([^:]+:\/*[^/]*)[\s\S]*$/;function g(s,l){R[" "+s]||(L.test(s)?R[" "+s]=s+"/":R[" "+s]=u(s,"/",!0)),s=R[" "+s];const n=s.indexOf(":")===-1;return l.substring(0,2)==="//"?n?l:s.replace(_,"$1")+l:l.charAt(0)==="/"?n?l:s.replace(T,"$1")+l:s+l}const x={exec:function(){}};function b(s){let l=1,n,d;for(;l<arguments.length;l++){n=arguments[l];for(d in n)Object.prototype.hasOwnProperty.call(n,d)&&(s[d]=n[d])}return s}function f(s,l){const n=s.replace(/\|/g,(p,m,r)=>{let a=!1,e=m;for(;--e>=0&&r[e]==="\\";)a=!a;return a?"|":" |"}),d=n.split(/ \|/);let v=0;if(d.length>l)d.splice(l);else for(;d.length<l;)d.push("");for(;v<d.length;v++)d[v]=d[v].trim().replace(/\\\|/g,"|");return d}function u(s,l,n){const d=s.length;if(d===0)return"";let v=0;for(;v<d;){const p=s.charAt(d-v-1);if(p===l&&!n)v++;else if(p!==l&&n)v++;else break}return s.substr(0,d-v)}function h(s,l){if(s.indexOf(l[1])===-1)return-1;const n=s.length;let d=0,v=0;for(;v<n;v++)if(s[v]==="\\")v++;else if(s[v]===l[0])d++;else if(s[v]===l[1]&&(d--,d<0))return v;return-1}function o(s){s&&s.sanitize&&!s.silent&&console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options")}qe.exports={escape:V,unescape:W,edit:N,cleanUrl:I,resolveUrl:g,noopTest:x,merge:b,splitCells:f,rtrim:u,findClosingBracket:h,checkSanitizeDeprecation:o}},NLgs:function(qe,Qe,fe){"use strict";fe.d(Qe,"e",function(){return L}),fe.d(Qe,"f",function(){return _}),fe.d(Qe,"d",function(){return g}),fe.d(Qe,"c",function(){return x}),fe.d(Qe,"a",function(){return b}),fe.d(Qe,"b",function(){return f});var et=fe("IYef"),tt=fe("c3Iv"),ze=fe("rBQ5"),Ve=fe("XXmO"),he=fe.n(Ve),V=fe("T/Jt"),w=fe.n(V),W=fe("9kvl"),P=fe("xKgJ"),N=fe("1vsH"),D=fe("RCxd"),G=fe("yTi+"),I=fe.n(G),R=fe("m3rI"),L=function(h){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return!!(_(h)&&T(o))},_=function(h){return Object(P.p)()?!0:(h({type:"user/showPopLogin",payload:{showPopLogin:!0,showClosable:!0}}),!1)},T=function(){var h,o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,s=Object(W.c)()._store.getState(),l=s.user;return(h=l.userInfo)!==null&&h!==void 0&&h.profile_completed?!0:(ze.a.confirm({title:"\u63D0\u793A",width:530,centered:!0,content:o?"\u6309\u7167\u6709\u5173\u653F\u7B56\u89C4\u5B9A\uFF0C\u7279\u6B8A\u5B9E\u9A8C\u9700\u8981\u5148\u7ED1\u5B9A\u624B\u673A\u53F7\u624D\u80FD\u4F7F\u7528\uFF0C\u8BF7\u5148\u7ED1\u5B9A\u624B\u673A\u53F7\u7801":"\u60A8\u9700\u8981\u53BB\u5B8C\u5584\u60A8\u7684\u4E2A\u4EBA\u8D44\u6599\uFF0C\u624D\u80FD\u4F7F\u7528\u6B64\u529F\u80FD",okText:"\u7ACB\u5373\u5B8C\u5584",cancelText:"\u7A0D\u540E\u5B8C\u5584",onOk:function(){W.d.push("/account/profile/edit")}}),!1)},g=function(){var h,o=Object(W.c)()._store.getState(),s=o.user;return(h=s.userInfo)!==null&&h!==void 0&&h.professional_certification?!0:(ze.a.confirm({title:"\u63D0\u793A",centered:!0,content:w.a.createElement("div",{className:"tc"},"\u60A8\u9700\u8981\u53BB\u5B8C\u6210\u60A8\u7684\u804C\u4E1A\u8BA4\u8BC1\uFF0C\u624D\u80FD\u4F7F\u7528\u6B64\u529F\u80FD"),okText:"\u7ACB\u5373\u5B8C\u5584",cancelText:"\u7A0D\u540E\u5B8C\u5584",onOk:function(){Object(N.T)("/account/certification")}}),!1)},x=function(){var h;if(Object(P.a)())return!0;var o=Object(W.c)()._store.getState(),s=o.user,l=o.globalSetting;return ze.a.warning({centered:!0,width:530,title:"\u63D0\u793A",content:w.a.createElement("div",{className:"tc",style:{marginLeft:-38}},w.a.createElement("p",null,"\u626B\u7801\u6DFB\u52A0\uFF0C\u7533\u8BF7\u64CD\u4F5C\u6743\u9650"),w.a.createElement("img",{src:R.a.IMG_SERVER+(l==null||((h=l.setting)===null||h===void 0)?void 0:h.authority_qrcode_url),width:200})),okText:"\u6211\u77E5\u9053\u4E86",maskClosable:!0}),!1},b=function(h,o){var s;if(h)return!0;var l=Object(W.c)()._store.getState(),n=l.user,d=l.globalSetting;return ze.a.confirm({centered:!0,zIndex:1e4,width:530,title:"\u63D0\u793A",content:w.a.createElement("div",null,w.a.createElement("p",null,o||"\u8BE5\u5B9E\u8DF5\u8D44\u6E90\u9700\u6388\u6743\u540E\u624D\u53EF\u4F7F\u7528\u3002 \u60A8\u53EF\u4EE5\u5728QQ\u670D\u52A1\u7FA4\u5411\u7BA1\u7406\u5458\u7533\u8BF7\uFF0C\u83B7\u5F97\u7EE7\u7EED\u64CD\u4F5C\u7684\u6743\u9650\u3002"),w.a.createElement("div",{style:{marginLeft:"110px"}},w.a.createElement("img",{src:R.a.IMG_SERVER+(d==null||((s=d.setting)===null||s===void 0)?void 0:s.authority_qrcode_url),width:200}),w.a.createElement("div",{style:{marginLeft:"35px"}},"\u7FA4\u53F7\uFF1A","714336072"))),okText:"\u7ACB\u5373\u8054\u7CFB",cancelText:"\u53D6\u6D88",onOk:function(){Object(N.T)("https://qm.qq.com/cgi-bin/qm/qr?k=tIyDPXUtE0yEk-MOJxhH55lTUJS-nYAM&jump_from=webapi")}}),!1},f=function(h){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",s=Object(W.c)()._store.getState(),l=s.shixunsDetail.detail;return(l==null?void 0:l.public)===2||(l==null?void 0:l.public)===1||(l==null?void 0:l.shixun_status)===3?(ze.a.info({centered:!0,icon:w.a.createElement(D.a,{style:{color:"#faad14"}}),width:460,title:"\u63D0\u793A",content:w.a.createElement("div",{className:"tc",style:{marginLeft:-38}},w.a.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:38,margin:"12px 0"}},w.a.createElement("span",null,"\u8BE5\u5B9E\u9A8C\u9879\u76EE\u7684\u72B6\u6001\u4E3A",(l==null?void 0:l.public)===2?"\u5DF2\u516C\u5F00":(l==null?void 0:l.public)===1?"\u5F85\u5BA1\u6838":"\u5DF2\u5173\u95ED","\uFF0C",o,"\u3002"),w.a.createElement("p",null,"\u5982\u6709\u9700\u8981\uFF0C\u8BF7\u8054\u7CFB\u5E73\u53F0\u7BA1\u7406\u5458\u8FDB\u884C\u6280\u672F\u652F\u6301\u3002")),w.a.createElement("img",{style:{border:"4px solid #0152d9",borderRadius:"4px"},src:I.a,alt:"\u4E8C\u7EF4\u7801",width:160})),okText:"\u6211\u77E5\u9053\u4E86"}),!0):(l==null?void 0:l.shixun_status)===2?(ze.a.confirm({centered:!0,icon:w.a.createElement(D.a,null),title:"\u63D0\u793A",content:w.a.createElement("div",null,w.a.createElement("span",null,"\u8BE5\u5B9E\u9A8C\u9879\u76EE\u5DF2\u53D1\u5E03\uFF0C",o,"\u3002"),w.a.createElement("br",null),w.a.createElement("span",null,"\u5982\u6709\u9700\u8981\uFF0C\u60A8\u53EF\u4EE5\u64A4\u9500\u53D1\u5E03\u540E\uFF0C\u518D\u8FDB\u884C\u64CD\u4F5C\u3002")),okText:"\u64A4\u9500\u53D1\u5E03",cancelText:"\u53D6\u6D88",onOk:function(){ze.a.confirm({width:440,centered:!0,icon:w.a.createElement(D.a,{style:{color:"#faad14"}}),title:"\u63D0\u793A",content:"\u64A4\u9500\u53D1\u5E03\u540E\uFF0C\u5B66\u5458\u5C06\u65E0\u6CD5\u8FDB\u884C\u7EC3\u4E60\u3002\u662F\u5426\u786E\u8BA4\u64A4\u9500\u53D1\u5E03\uFF1F",okText:"\u786E\u5B9A\u64A4\u9500\u53D1\u5E03",cancelText:"\u53D6\u6D88",onOk:function(){var d=Object(et.a)(he.a.mark(function p(){var m;return he.a.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,h({type:"shixunsDetail/cancelRelease",payload:{id:l==null?void 0:l.identifier}});case 2:m=a.sent,m.status!==401&&(h({type:"shixunsDetail/getShixunsDetail",payload:{id:l==null?void 0:l.identifier}}),h({type:"practiceSetting/getCommonData",payload:{id:l==null?void 0:l.identifier}}));case 4:case"end":return a.stop()}},p)}));function v(){return d.apply(this,arguments)}return v}()})}}),!0):!1}},SJMd:function(qe,Qe){/**
* @license
* Copyright (C) 2006 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var fe,et,tt,ze=!1,Ve,he;window.PR_SHOULD_USE_CONTINUATION=!0;var V,w;(function(){var W=window,P=["break,continue,do,else,for,if,return,while"],N=[P,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],D=[N,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],G=[D,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],I=[D,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],R=[D,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],L="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",_=[D,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],T="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",g=[P,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],x=[P,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],b=[P,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],f=[G,R,I,_,T,g,x,b],u=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,h="str",o="kwd",s="com",l="typ",n="lit",d="pun",v="pln",p="tag",m="dec",r="src",a="atn",e="atv",c="nocode",E="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function y(ae){for(var ue=0,ye=!1,Ee=!1,_e=0,Se=ae.length;_e<Se;++_e){var Te=ae[_e];if(Te.ignoreCase)Ee=!0;else if(/[a-z]/i.test(Te.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){ye=!0,Ee=!1;break}}var Pe={b:8,t:9,n:10,v:11,f:12,r:13};function we(Ie){var xe=Ie.charCodeAt(0);if(xe!==92)return xe;var Fe=Ie.charAt(1);return xe=Pe[Fe],xe||("0"<=Fe&&Fe<="7"?parseInt(Ie.substring(1),8):Fe==="u"||Fe==="x"?parseInt(Ie.substring(2),16):Ie.charCodeAt(1))}function be(Ie){if(Ie<32)return(Ie<16?"\\x0":"\\x")+Ie.toString(16);var xe=String.fromCharCode(Ie);return xe==="\\"||xe==="-"||xe==="]"||xe==="^"?"\\"+xe:xe}function Re(Ie){var xe=Ie.substring(1,Ie.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g")),Fe=[],Me=xe[0]==="^",pe=["["];Me&&pe.push("^");for(var Le=Me?1:0,ie=xe.length;Le<ie;++Le){var te=xe[Le];if(/\\[bdsw]/i.test(te))pe.push(te);else{var re=we(te),K;Le+2<ie&&xe[Le+1]==="-"?(K=we(xe[Le+2]),Le+=2):K=re,Fe.push([re,K]),K<65||re>122||(K<65||re>90||Fe.push([Math.max(65,re)|32,Math.min(K,90)|32]),K<97||re>122||Fe.push([Math.max(97,re)&~32,Math.min(K,122)&~32]))}}Fe.sort(function(se,de){return se[0]-de[0]||de[1]-se[1]});for(var j=[],Z=[],Le=0;Le<Fe.length;++Le){var q=Fe[Le];q[0]<=Z[1]+1?Z[1]=Math.max(Z[1],q[1]):j.push(Z=q)}for(var Le=0;Le<j.length;++Le){var q=j[Le];pe.push(be(q[0])),q[1]>q[0]&&(q[1]+1>q[0]&&pe.push("-"),pe.push(be(q[1])))}return pe.push("]"),pe.join("")}function De(Ie){for(var xe=Ie.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),Fe=xe.length,Me=[],pe=0,Le=0;pe<Fe;++pe){var ie=xe[pe];if(ie==="(")++Le;else if(ie.charAt(0)==="\\"){var te=+ie.substring(1);te&&(te<=Le?Me[te]=-1:xe[pe]=be(te))}}for(var pe=1;pe<Me.length;++pe)Me[pe]===-1&&(Me[pe]=++ue);for(var pe=0,Le=0;pe<Fe;++pe){var ie=xe[pe];if(ie==="(")++Le,Me[Le]||(xe[pe]="(?:");else if(ie.charAt(0)==="\\"){var te=+ie.substring(1);te&&te<=Le&&(xe[pe]="\\"+Me[te])}}for(var pe=0;pe<Fe;++pe)xe[pe]==="^"&&xe[pe+1]!=="^"&&(xe[pe]="");if(Ie.ignoreCase&&ye)for(var pe=0;pe<Fe;++pe){var ie=xe[pe],re=ie.charAt(0);ie.length>=2&&re==="["?xe[pe]=Re(ie):re!=="\\"&&(xe[pe]=ie.replace(/[a-zA-Z]/g,function(Z){var q=Z.charCodeAt(0);return"["+String.fromCharCode(q&~32,q|32)+"]"}))}return xe.join("")}for(var ke=[],_e=0,Se=ae.length;_e<Se;++_e){var Te=ae[_e];if(Te.global||Te.multiline)throw new Error(""+Te);ke.push("(?:"+De(Te)+")")}return new RegExp(ke.join("|"),Ee?"gi":"g")}function k(ae,ue){var ye=/(?:^|\s)nocode(?:\s|$)/,Ee=[],_e=0,Se=[],Te=0;function Pe(we){var be=we.nodeType;if(be==1){if(ye.test(we.className))return;for(var Re=we.firstChild;Re;Re=Re.nextSibling)Pe(Re);var De=we.nodeName.toLowerCase();(De==="br"||De==="li")&&(Ee[Te]=`
`,Se[Te<<1]=_e++,Se[Te++<<1|1]=we)}else if(be==3||be==4){var ke=we.nodeValue;ke.length&&(ue?ke=ke.replace(/\r\n?/g,`
`):ke=ke.replace(/[ \t\r\n]+/g," "),Ee[Te]=ke,Se[Te<<1]=_e,_e+=ke.length,Se[Te++<<1|1]=we)}}return Pe(ae),{sourceCode:Ee.join("").replace(/\n$/,""),spans:Se}}function M(ae,ue,ye,Ee,_e){if(!ye)return;var Se={sourceNode:ae,pre:1,langExtension:null,numberLines:null,sourceCode:ye,spans:null,basePos:ue,decorations:null};Ee(Se),_e.push.apply(_e,Se.decorations)}var O=/\S/;function U(ae){for(var ue=void 0,ye=ae.firstChild;ye;ye=ye.nextSibling){var Ee=ye.nodeType;ue=Ee===1?ue?ae:ye:Ee===3&&O.test(ye.nodeValue)?ae:ue}return ue===ae?void 0:ue}function F(ae,ue){var ye={},Ee;(function(){for(var Te=ae.concat(ue),Pe=[],we={},be=0,Re=Te.length;be<Re;++be){var De=Te[be],ke=De[3];if(ke)for(var Ie=ke.length;--Ie>=0;)ye[ke.charAt(Ie)]=De;var xe=De[1],Fe=""+xe;we.hasOwnProperty(Fe)||(Pe.push(xe),we[Fe]=null)}Pe.push(/[\0-\uffff]/),Ee=y(Pe)})();var _e=ue.length,Se=function(Te){for(var Pe=Te.sourceCode,we=Te.basePos,be=Te.sourceNode,Re=[we,v],De=0,ke=Pe.match(Ee)||[],Ie={},xe=0,Fe=ke.length;xe<Fe;++xe){var Me=ke[xe],pe=Ie[Me],Le=void 0,ie;if(typeof pe=="string")ie=!1;else{var te=ye[Me.charAt(0)];if(te)Le=Me.match(te[1]),pe=te[0];else{for(var re=0;re<_e;++re)if(te=ue[re],Le=Me.match(te[1]),Le){pe=te[0];break}Le||(pe=v)}ie=pe.length>=5&&pe.substring(0,5)==="lang-",ie&&!(Le&&typeof Le[1]=="string")&&(ie=!1,pe=r),ie||(Ie[Me]=pe)}var K=De;if(De+=Me.length,!ie)Re.push(we+K,pe);else{var j=Le[1],Z=Me.indexOf(j),q=Z+j.length;Le[2]&&(q=Me.length-Le[2].length,Z=q-j.length);var se=pe.substring(5);M(be,we+K,Me.substring(0,Z),Se,Re),M(be,we+K+Z,j,X(se,j),Re),M(be,we+K+q,Me.substring(q),Se,Re)}}Te.decorations=Re};return Se}function H(ae){var ue=[],ye=[];ae.tripleQuotedStrings?ue.push([h,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):ae.multiLineStrings?ue.push([h,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):ue.push([h,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),ae.verbatimStrings&&ye.push([h,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ee=ae.hashComments;Ee&&(ae.cStyleComments?(Ee>1?ue.push([s,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):ue.push([s,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),ye.push([h,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):ue.push([s,/^#[^\r\n]*/,null,"#"])),ae.cStyleComments&&(ye.push([s,/^\/\/[^\r\n]*/,null]),ye.push([s,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var _e=ae.regexLiterals;if(_e){var Se=_e>1?"":`
\r`,Te=Se?".":"[\\S\\s]",Pe="/(?=[^/*"+Se+"])(?:[^/\\x5B\\x5C"+Se+"]|\\x5C"+Te+"|\\x5B(?:[^\\x5C\\x5D"+Se+"]|\\x5C"+Te+")*(?:\\x5D|$))+/";ye.push(["lang-regex",RegExp("^"+E+"("+Pe+")")])}var we=ae.types;we&&ye.push([l,we]);var be=(""+ae.keywords).replace(/^ | $/g,"");be.length&&ye.push([o,new RegExp("^(?:"+be.replace(/[\s,]+/g,"|")+")\\b"),null]),ue.push([v,/^\s+/,null,` \r
\xA0`]);var Re="^.[^\\s\\w.$@'\"`/\\\\]*";return ae.regexLiterals&&(Re+="(?!s*/)"),ye.push([n,/^@[a-z_$][a-z_$@0-9]*/i,null],[l,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[v,/^[a-z_$][a-z_$@0-9]*/i,null],[n,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[v,/^\\[\s\S]?/,null],[d,new RegExp(Re),null]),F(ue,ye)}var Y=H({keywords:f,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Q(ae,ue,ye){for(var Ee=/(?:^|\s)nocode(?:\s|$)/,_e=/\r\n?|\n/,Se=ae.ownerDocument,Te=Se.createElement("li");ae.firstChild;)Te.appendChild(ae.firstChild);var Pe=[Te];function we(xe){var Fe=xe.nodeType;if(Fe==1&&!Ee.test(xe.className))if(xe.nodeName==="br")be(xe),xe.parentNode&&xe.parentNode.removeChild(xe);else for(var Me=xe.firstChild;Me;Me=Me.nextSibling)we(Me);else if((Fe==3||Fe==4)&&ye){var pe=xe.nodeValue,Le=pe.match(_e);if(Le){var ie=pe.substring(0,Le.index);xe.nodeValue=ie;var te=pe.substring(Le.index+Le[0].length);if(te){var re=xe.parentNode;re.insertBefore(Se.createTextNode(te),xe.nextSibling)}be(xe),ie||xe.parentNode.removeChild(xe)}}}function be(xe){for(;!xe.nextSibling;)if(xe=xe.parentNode,!xe)return;function Fe(Le,ie){var te=ie?Le.cloneNode(!1):Le,re=Le.parentNode;if(re){var K=Fe(re,1),j=Le.nextSibling;K.appendChild(te);for(var Z=j;Z;Z=j)j=Z.nextSibling,K.appendChild(Z)}return te}for(var Me=Fe(xe.nextSibling,0),pe;(pe=Me.parentNode)&&pe.nodeType===1;)Me=pe;Pe.push(Me)}for(var Re=0;Re<Pe.length;++Re)we(Pe[Re]);ue===(ue|0)&&Pe[0].setAttribute("value",ue);var De=Se.createElement("ol");De.className="linenums";for(var ke=Math.max(0,ue-1|0)||0,Re=0,Ie=Pe.length;Re<Ie;++Re)Te=Pe[Re],Te.className="L"+(Re+ke)%10,Te.firstChild||Te.appendChild(Se.createTextNode("\xA0")),De.appendChild(Te);ae.appendChild(De)}function z(ae){var ue=/\bMSIE\s(\d+)/.exec(navigator.userAgent);ue=ue&&+ue[1]<=8;var ye=/\n/g,Ee=ae.sourceCode,_e=Ee.length,Se=0,Te=ae.spans,Pe=Te.length,we=0,be=ae.decorations,Re=be.length,De=0;be[Re]=_e;var ke,Ie;for(Ie=ke=0;Ie<Re;)be[Ie]!==be[Ie+2]?(be[ke++]=be[Ie++],be[ke++]=be[Ie++]):Ie+=2;for(Re=ke,Ie=ke=0;Ie<Re;){for(var xe=be[Ie],Fe=be[Ie+1],Me=Ie+2;Me+2<=Re&&be[Me+1]===Fe;)Me+=2;be[ke++]=xe,be[ke++]=Fe,Ie=Me}Re=be.length=ke;var pe=ae.sourceNode,Le="";pe&&(Le=pe.style.display,pe.style.display="none");try{for(var ie=null;we<Pe;){var te=Te[we],re=Te[we+2]||_e,K=be[De+2]||_e,Me=Math.min(re,K),j=Te[we+1],Z;if(j.nodeType!==1&&(Z=Ee.substring(Se,Me))){ue&&(Z=Z.replace(ye,"\r")),j.nodeValue=Z;var q=j.ownerDocument,se=q.createElement("span");se.className=be[De+1];var de=j.parentNode;de.replaceChild(se,j),se.appendChild(j),Se<re&&(Te[we+1]=j=q.createTextNode(Ee.substring(Me,re)),de.insertBefore(j,se.nextSibling))}Se=Me,Se>=re&&(we+=2),Se>=K&&(De+=2)}}finally{pe&&(pe.style.display=Le)}}var ee={};function J(ae,ue){for(var ye=ue.length;--ye>=0;){var Ee=ue[ye];ee.hasOwnProperty(Ee)?W.console&&console.warn("cannot override language handler %s",Ee):ee[Ee]=ae}}function X(ae,ue){return ae&&ee.hasOwnProperty(ae)||(ae=/^\s*</.test(ue)?"default-markup":"default-code"),ee[ae]}J(Y,["default-code"]),J(F([],[[v,/^[^<?]+/],[m,/^<!\w[^>]*(?:>|$)/],[s,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[d,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]),J(F([[v,/^[\s]+/,null,` \r
`],[e,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[p,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[a,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[d,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]),J(F([],[[e,/^[\s\S]+/]]),["uq.val"]),J(H({keywords:G,hashComments:!0,cStyleComments:!0,types:u}),["c","cc","cpp","cxx","cyc","m"]),J(H({keywords:"null,true,false"}),["json"]),J(H({keywords:R,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:u}),["cs"]),J(H({keywords:I,cStyleComments:!0}),["java"]),J(H({keywords:b,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),J(H({keywords:g,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),J(H({keywords:T,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),J(H({keywords:x,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),J(H({keywords:_,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),J(H({keywords:L,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),J(F([],[[h,/^[\s\S]+/]]),["regex"]);function oe(ae){var ue=ae.langExtension;try{var ye=k(ae.sourceNode,ae.pre),Ee=ye.sourceCode;ae.sourceCode=Ee,ae.spans=ye.spans,ae.basePos=0,X(ue,Ee)(ae),z(ae)}catch(_e){W.console&&console.log(_e&&_e.stack||_e)}}function le(ae,ue,ye){var Ee=ye||!1,_e=ue||null,Se=document.createElement("div");Se.innerHTML="<pre>"+ae+"</pre>",Se=Se.firstChild,Ee&&Q(Se,Ee,!0);var Te={langExtension:_e,numberLines:Ee,sourceNode:Se,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return oe(Te),Se.innerHTML}function me(ae,ue){var ye=ue||document.body,Ee=ye.ownerDocument||document;function _e(te){return ye.getElementsByTagName(te)}for(var Se=[_e("pre"),_e("code"),_e("xmp")],Te=[],Pe=0;Pe<Se.length;++Pe)for(var we=0,be=Se[Pe].length;we<be;++we)Te.push(Se[Pe][we]);Se=null;var Re=Date;Re.now||(Re={now:function(){return+new Date}});var De=0,ke=/\blang(?:uage)?-([\w.]+)(?!\S)/,Ie=/\bprettyprint\b/,xe=/\bprettyprinted\b/,Fe=/pre|xmp/i,Me=/^code$/i,pe=/^(?:pre|code|xmp)$/i,Le={};function ie(){for(var te=W.PR_SHOULD_USE_CONTINUATION?Re.now()+250:Infinity;De<Te.length&&Re.now()<te;De++){for(var re=Te[De],K=Le,j=re;j=j.previousSibling;){var Z=j.nodeType,q=(Z===7||Z===8)&&j.nodeValue;if(q?!/^\??prettify\b/.test(q):Z!==3||/\S/.test(j.nodeValue))break;if(q){K={},q.replace(/\b(\w+)=([\w:.%+-]+)/g,function(ot,Ye,ct){K[Ye]=ct});break}}var se=re.className;if((K!==Le||Ie.test(se))&&!xe.test(se)){for(var de=!1,ve=re.parentNode;ve;ve=ve.parentNode){var Ue=ve.tagName;if(pe.test(Ue)&&ve.className&&Ie.test(ve.className)){de=!0;break}}if(!de){re.className+=" prettyprinted";var Ge=K.lang;if(!Ge){Ge=se.match(ke);var We;!Ge&&(We=U(re))&&Me.test(We.tagName)&&(Ge=We.className.match(ke)),Ge&&(Ge=Ge[1])}var it;if(Fe.test(re.tagName))it=1;else{var $e=re.currentStyle,Ne=Ee.defaultView,st=$e?$e.whiteSpace:Ne&&Ne.getComputedStyle?Ne.getComputedStyle(re,null).getPropertyValue("white-space"):0;it=st&&st.substring(0,3)==="pre"}var je=K.linenums;(je=je==="true"||+je)||(je=se.match(/\blinenums\b(?::(\d+))?/),je=je?je[1]&&je[1].length?+je[1]:!0:!1),je&&Q(re,je,it);var Je={langExtension:Ge,sourceNode:re,numberLines:je,pre:it,sourceCode:null,basePos:null,spans:null,decorations:null};oe(Je)}}}De<Te.length?W.setTimeout(ie,250):typeof ae=="function"&&ae()}ie()}var Ae=W.PR={createSimpleLexer:F,registerLangHandler:J,sourceDecorator:H,PR_ATTRIB_NAME:a,PR_ATTRIB_VALUE:e,PR_COMMENT:s,PR_DECLARATION:m,PR_KEYWORD:o,PR_LITERAL:n,PR_NOCODE:c,PR_PLAIN:v,PR_PUNCTUATION:d,PR_SOURCE:r,PR_STRING:h,PR_TAG:p,PR_TYPE:l,prettyPrintOne:ze?W.prettyPrintOne=le:V=le,prettyPrint:w=ze?W.prettyPrint=me:w=me},ge=W.define;typeof ge=="function"&&ge.amd&&ge("google-code-prettify",[],function(){return Ae})})()},TNY5:function(qe,Qe,fe){"use strict";fe.r(Qe);var et=fe("kmrB"),tt=fe("Jv1h"),ze=fe("6NPb"),Ve=fe("o3AU"),he=fe("EOh4"),V=fe("V/dS"),w=fe("dX86"),W=fe("GwPp"),P=fe("IYef"),N=fe("y6Ii"),D=fe("Wuip"),G=fe("Hqw+"),I=fe("ftSv"),R=fe("XXmO"),L=fe.n(R),_=fe("T/Jt"),T=fe.n(_),g=fe("GNbK"),x=fe("9kvl"),b=fe("ErOA"),f=fe("9Bee"),u=fe("m3rI"),h=fe("zvqp"),o=fe.n(h),s=fe("dLI4"),l=fe("4d5L"),n=fe("2yBE"),d=fe("5LYH"),v=fe("YaWb"),p=fe("47JS"),m=fe("TOZL"),r=fe("NLgs"),a=fe("2kAv"),e=fe.n(a),c=fe("1vsH"),E=m.a.TextArea,y=function(F){var H=F.user,Y=F.globalSetting,Q=F.loading,z=F.dispatch,ee=Object(I.a)(F,["user","globalSetting","loading","dispatch"]),J=D.a.useForm(),X=Object(G.a)(J,1),oe=X[0];Object(_.useEffect)(function(){var me;Object(c.Q)((me=H.userInfo)===null||me===void 0?void 0:me.login)||Object(r.f)(z)},[H.userInfo.login]);var le=function(){var me=Object(P.a)(L.a.mark(function Ae(ge){var ae,ue;return L.a.wrap(function(Ee){for(;;)switch(Ee.prev=Ee.next){case 0:return Ee.next=2,Object(b.a)("/api/helps/feedback.json",{method:"post",body:Object(v.a)({},ge)});case 2:ae=Ee.sent,(ae==null?void 0:ae.status)===0&&x.d.push("/messages/".concat((ue=H.userInfo)===null||ue===void 0?void 0:ue.login,"/message_detail?target_ids=1"));case 4:case"end":return Ee.stop()}},Ae)}));return function(ge){return me.apply(this,arguments)}}();return T.a.createElement("section",{className:"".concat(e.a.wrap," bg-white pl30 pr30 pt30")},T.a.createElement("div",{className:"c-grey-999 line26"},"\u60F3\u5BF9\u6211\u4EEC\u7684\u5E73\u53F0\u63D0\u4F9B\u529F\u80FD\u5EFA\u8BAE\uFF1F",T.a.createElement("br",null),"\u53D1\u73B0\u7F51\u9875\u4E2D\u7684\u95EE\u9898\u6216bug\u60F3\u544A\u8BC9\u6211\u4EEC\uFF1F",T.a.createElement("br",null),"\u671F\u671B\u4E0E\u6211\u4EEC\u5C55\u5F00\u5408\u4F5C\uFF1F",T.a.createElement("br",null),"\u5728\u8FD9\u91CC\u628A\u4F60\u60F3\u8BF4\u7684\u4E00\u5207\u544A\u8BC9\u6211\u4EEC\u5427\uFF1F"),T.a.createElement("div",{className:"c-red-ee4 mt20 mb20"},"*"," ",T.a.createElement(g.a,{to:"/help/help_center",className:"".concat(e.a.link," c-red-ee4")},"\u770B\u770B\u5E2E\u52A9\u4E2D\u5FC3\u662F\u5426\u6709\u4F60\u60F3\u8981\u7684\u7B54\u6848")),T.a.createElement(D.a,{layout:"vertical",form:oe,onFinish:le,initialValues:{question_kind:"\u767B\u5F55\u6CE8\u518C"}},T.a.createElement(D.a.Item,{label:"\u95EE\u9898\u5206\u7C7B\uFF1A",name:"question_kind",rules:[{required:!0,message:"\u4E0D\u80FD\u4E3A\u7A7A"}]},T.a.createElement(d.a.Group,null,T.a.createElement(d.a,{value:"\u767B\u5F55\u6CE8\u518C"},"\u767B\u5F55\u6CE8\u518C"),T.a.createElement(d.a,{value:"\u4FE1\u606F\u8BA4\u8BC1"},"\u4FE1\u606F\u8BA4\u8BC1"),T.a.createElement(d.a,{value:"\u5B9E\u8BAD\u7F16\u7A0B"},"\u5B9E\u8BAD\u7F16\u7A0B"),T.a.createElement(d.a,{value:"\u5B9E\u8BAD\u8BFE\u7A0B"},"\u5B9E\u8BAD\u8BFE\u7A0B"),T.a.createElement(d.a,{value:"\u8BFE\u5802"},"\u8BFE\u5802"),T.a.createElement(d.a,{value:"\u5176\u5B83"},"\u5176\u5B83"))),T.a.createElement(D.a.Item,{label:"\u95EE\u9898\u9875\u9762\u7F51\u5740\uFF1A",name:"url",rules:[{required:!0,message:"\u4E0D\u80FD\u4E3A\u7A7A"}]},T.a.createElement(m.a,{placeholder:"\u53CD\u9988\u5E73\u53F0\u95EE\u9898\uFF0C\u8BF7\u540C\u65F6\u586B\u5199\u5BF9\u5E94\u7684\u95EE\u9898\u9875\u9762\u94FE\u63A5\uFF0C\u4EE5\u4FBF\u5E73\u53F0\u80FD\u591F\u53CA\u65F6\u8DDF\u8E2A\u89E3\u51B3\uFF0C\u8C22\u8C22"})),T.a.createElement(D.a.Item,{label:"\u95EE\u9898\u63CF\u8FF0\uFF1A",name:"description",rules:[{required:!0,message:"\u4E0D\u80FD\u4E3A\u7A7A"}]},T.a.createElement(E,{rows:4,placeholder:"\u53CD\u9988\u5E73\u53F0\u95EE\u9898\uFF0C\u8BF7\u540C\u65F6\u586B\u5199\u5BF9\u5E94\u7684\u95EE\u9898\u9875\u9762\u94FE\u63A5\uFF0C\u4EE5\u4FBF\u5E73\u53F0\u80FD\u591F\u53CA\u65F6\u8DDF\u8E2A\u89E3\u51B3\uFF0C\u8C22\u8C22"})),T.a.createElement(D.a.Item,null,T.a.createElement(l.a,{type:"primary",htmlType:"submit"},"\u63D0\u4EA4"))))},k=Object(x.a)(function(U){var F=U.user,H=U.loading,Y=U.globalSetting;return{user:F,globalSetting:Y,loading:H.models.index}})(y),M=function(F){var H,Y,Q,z,ee=F.user,J=F.globalSetting,X=F.loading,oe=F.dispatch,le=Object(I.a)(F,["user","globalSetting","loading","dispatch"]),me=Object(_.useState)({content:"",message:"",status:0,contacts:[],address:"",data:[]}),Ae=Object(G.a)(me,2),ge=Ae[0],ae=Ae[1],ue=Object(_.useState)(!0),ye=Object(G.a)(ue,2),Ee=ye[0],_e=ye[1],Se=D.a.useForm(),Te=Object(G.a)(Se,1),Pe=Te[0],we=[{name:"\u5173\u4E8E\u6211\u4EEC",key:"about_us",id:"about"},{name:"\u52A0\u5165\u6211\u4EEC",key:"join_us",id:"join_us"},{name:"\u8054\u7CFB\u6211\u4EEC",key:"contact_us",id:"contact"},{name:"\u5408\u4F5C\u4F19\u4F34",key:"cooperatives",id:"cooperatives"},{name:"\u670D\u52A1\u534F\u8BAE",key:"agreement",id:"agreement"},{name:"\u5E2E\u52A9\u4E2D\u5FC3",key:"help_center",id:"help_center"},{name:"\u610F\u89C1\u53CD\u9988",key:"feedback",id:"feedback"}].filter(function(De){var ke;return J!=null&&(ke=J.setting)!==null&&ke!==void 0&&ke.is_local?De.name!=="\u5173\u4E8E\u6211\u4EEC":!0}),be=le.match.params,Re=function(){var De=Object(P.a)(L.a.mark(function ke(){var Ie,xe,Fe,Me;return L.a.wrap(function(Le){for(;;)switch(Le.prev=Le.next){case 0:return Le.t0=ae,Le.next=3,Object(b.a)("/api/helps/".concat((Ie=we.filter(function(ie){return ie.key===be.id}))===null||Ie===void 0||((xe=Ie[0])===null||xe===void 0)?void 0:xe.id,".json"),{method:"get"});case 3:Le.t1=Le.sent,(0,Le.t0)(Le.t1),_e(!1),Object(c.Z)((Fe=we.filter(function(ie){return ie.key===be.id}))===null||Fe===void 0||((Me=Fe[0])===null||Me===void 0)?void 0:Me.name);case 7:case"end":return Le.stop()}},ke)}));return function(){return De.apply(this,arguments)}}();return Object(_.useEffect)(function(){_e(!0),Re()},[be.id]),T.a.createElement("section",null,T.a.createElement("aside",{className:"edu-container mt30"},T.a.createElement(Ve.a,{gutter:[20,20]},T.a.createElement(V.a,null,T.a.createElement(W.a,{className:o.a.menu,style:{width:174},defaultSelectedKeys:[(H=we.filter(function(De){return De.key===be.id}))===null||H===void 0?void 0:H[0].key],mode:"inline"},we.map(function(De,ke){return T.a.createElement(W.a.Item,{key:De.key},T.a.createElement(g.a,{to:"/help/".concat(De.key)},De.name))}))),T.a.createElement(V.a,{flex:"1"},T.a.createElement("h1",{className:o.a.title},(Y=we.filter(function(De){return De.key===be.id}))===null||Y===void 0?void 0:Y[0].name),T.a.createElement("div",{className:"minH500"},be.id==="feedback"?T.a.createElement(k,null):T.a.createElement(tt.a,{loading:Ee},T.a.createElement("div",{className:[o.a.content,"bg-white pl30 pr30 pt30"].join(" ")},T.a.createElement(f.a,{value:ge.content||""}),(Q=ge.contacts)===null||Q===void 0?void 0:Q.map(function(De,ke){return T.a.createElement("ul",{key:ke,className:o.a.contcats},T.a.createElement("h1",null,De.type),T.a.createElement("li",null,De.name),T.a.createElement("li",null,T.a.createElement("span",null,"QQ:"),De.qq),T.a.createElement("li",null,T.a.createElement("span",null,"Email:"),De.mail))}),ge.address&&T.a.createElement("ul",{className:o.a.contcats},T.a.createElement("h1",null,"\u516C\u53F8\u5730\u5740"),T.a.createElement("li",null,ge.address)),(z=ge.data)===null||z===void 0?void 0:z.map(function(De,ke){var Ie;return T.a.createElement("div",{className:o.a.cooperatives},T.a.createElement("h1",null,De.name),T.a.createElement(Ve.a,{gutter:[10,20]},(Ie=De.values)===null||Ie===void 0?void 0:Ie.map(function(xe,Fe){return T.a.createElement(V.a,{span:6},T.a.createElement("div",{className:o.a.imgWrp},T.a.createElement("img",{src:u.a.IMG_SERVER+xe.img})))})))}))))))))},O=Qe.default=Object(x.a)(function(U){var F=U.user,H=U.loading,Y=U.globalSetting;return{user:F,globalSetting:Y,loading:H.models.index}})(M)},p5ED:function(qe,Qe,fe){"use strict";var et=fe("dLI4"),tt=fe("4d5L"),ze=fe("YfA7"),Ve=fe("e4Gi"),he=fe("YaWb"),V=fe("IYef"),w=fe("Hqw+"),W=fe("XXmO"),P=fe.n(W),N=fe("T/Jt"),D=fe.n(N),G=fe("vHTk"),I=fe.n(G),R=fe("yEEn"),L=fe("ZW9T"),_=fe("1vsH"),T=fe("V0Rq"),g=fe("m3rI");Qe.a=function(x){var b,f,u,h,o,s,l,n=x.editOffice,d=n===void 0?"view":n,v=x.data,p=x.theme,m=x.type,r=x.filename,a=x.monacoEditor,e=x.className,c=x.style,E=x.close,y=x.onClose,k=x.hasMask,M=x.disabledDownload,O=Object(N.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),U=Object(w.a)(O,2),F=U[0],H=U[1],Y=Object(N.useState)(""),Q=Object(w.a)(Y,2),z=Q[0],ee=Q[1],J=Object(N.useState)(),X=Object(w.a)(J,2),oe=X[0],le=X[1],me=window.ENV==="build"?"/react/build":"",Ae=g.a.PROXY_SERVER||location.origin,ge,ae=1024*1024,ue=10*ae,ye=Object(N.useRef)();(b=v)!==null&&b!==void 0&&b.startsWith("/api")&&m!=="txt"&&(v=g.a.API_SERVER+v),m==="office"&&(ge=Object(_.U)(v).filesize,ge>ue&&(m="other")),r&&a&&(a.filename=r),Object(N.useEffect)(function(){var Te,Pe,we=(Te=document.cookie)===null||Te===void 0||((Pe=Te.replace(/\s/g,""))===null||Pe===void 0)?void 0:Pe.split(";");we==null||we.map(function(be){var Re=be.split("=");Re[0]==="_educoder_session"&&ee(Re[1])})},[]),Object(N.useEffect)(function(){m==="office"&&Ee()},[m,v]);var Ee=function(){var Te=Object(V.a)(P.a.mark(function Pe(){var we,be,Re;return P.a.wrap(function(ke){for(;;)switch(ke.prev=ke.next){case 0:return console.log("data:",v),we=v,v.startsWith("http")||(we=location.origin+we),be=new URL(we).pathname.split("/").pop(),ke.next=6,Object(T.V)({attachment_id:be});case 6:Re=ke.sent,le(Re);case 8:case"end":return ke.stop()}},Pe)}));return function(){return Te.apply(this,arguments)}}(),_e=function(){if(v.startsWith("http")||v.startsWith("blob:")){Se();return}Object(_.z)(r||"educoder",v,r)},Se=function(){Object(_.x)(r||"educoder",decodeURIComponent(v))};return D.a.createElement("div",{style:Object(he.a)({},c||{}),className:"".concat(k&&I.a.bgBlack," ").concat(m?I.a.wrp:"hide")},E&&D.a.createElement("div",{className:I.a.close,ref:ye},!M&&D.a.createElement(Ve.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return ye.current}},D.a.createElement("span",{onClick:Se},D.a.createElement("i",{className:"icon-quxiaozhiding"}))),D.a.createElement(Ve.a,{title:"\u5173\u95ED",getPopupContainer:function(){return ye.current}},D.a.createElement("span",{className:"",onClick:y},D.a.createElement("i",{className:"icon-guanbi1"})))),D.a.createElement("div",{className:"".concat(I.a[e]," ").concat(e," ").concat(I.a.monaco," ").concat(m==="txt"?"show":"hide")},m==="txt"&&D.a.createElement(L.b,a)),m==="audio"&&D.a.createElement("audio",{src:"".concat(((f=v)===null||f===void 0?void 0:f.indexOf("http://"))>-1||((u=v)===null||u===void 0?void 0:u.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(v),autoPlay:!0}),m==="video"&&D.a.createElement(D.a.Fragment,null,((h=v)===null||h===void 0?void 0:h.indexOf("http"))>-1?D.a.createElement("video",{controls:!0,src:"".concat(v),autoPlay:!0}):D.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(v),autoPlay:!0})),m==="office"&&oe&&D.a.createElement("iframe",{src:"".concat(me,"/office.html?key=").concat(oe.key,"&url=").concat(Ae+oe.url,"&callbackUrl=").concat(Ae+oe.callbackUrl,"&fileType=").concat(oe.fileType,"&title=").concat(oe.title,"&model=").concat(d,"&officeServer=").concat(g.a.OFFICE_SERVER,"&disabledDownload=").concat(!!M)}),m==="html"&&D.a.createElement("iframe",{src:v+"&disposition=inline"}),m==="pdf"&&D.a.createElement("iframe",{src:"".concat(me,"/js/pdfview/index.html?url=").concat(v,"&disabledDownload=").concat(!!M)}),m==="image"&&D.a.createElement("img",{src:"".concat(((o=v)===null||o===void 0?void 0:o.indexOf("http://"))>-1||((s=v)===null||s===void 0?void 0:s.indexOf("https://"))>-1||(l=v)!==null&&l!==void 0&&l.startsWith("/api")?"":"data:image/png;base64,").concat(v)}),m==="other"&&D.a.createElement("div",null,D.a.createElement(tt.a,{type:"primary",size:"large",onClick:_e},D.a.createElement(R.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),m==="download"&&D.a.createElement(tt.a,{type:"primary",size:"large",onClick:_e},D.a.createElement(R.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},ulZh:function(qe,Qe,fe){typeof window!="undefined"&&function(tt,ze){qe.exports=ze()}(this,()=>(()=>{var et={"./src/config.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{enableStreamingMode:()=>a,hlsDefaultConfig:()=>p,mergeConfig:()=>r});var W=w("./src/controller/abr-controller.ts"),P=w("./src/controller/audio-stream-controller.ts"),N=w("./src/controller/audio-track-controller.ts"),D=w("./src/controller/subtitle-stream-controller.ts"),G=w("./src/controller/subtitle-track-controller.ts"),I=w("./src/controller/buffer-controller.ts"),R=w("./src/controller/timeline-controller.ts"),L=w("./src/controller/cap-level-controller.ts"),_=w("./src/controller/fps-controller.ts"),T=w("./src/controller/eme-controller.ts"),g=w("./src/controller/cmcd-controller.ts"),x=w("./src/utils/xhr-loader.ts"),b=w("./src/utils/fetch-loader.ts"),f=w("./src/utils/cues.ts"),u=w("./src/utils/mediakeys-helper.ts"),h=w("./src/utils/logger.ts");function o(){return o=Object.assign?Object.assign.bind():function(e){for(var c=1;c<arguments.length;c++){var E=arguments[c];for(var y in E)Object.prototype.hasOwnProperty.call(E,y)&&(e[y]=E[y])}return e},o.apply(this,arguments)}function s(e,c){var E=Object.keys(e);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(e);c&&(y=y.filter(function(k){return Object.getOwnPropertyDescriptor(e,k).enumerable})),E.push.apply(E,y)}return E}function l(e){for(var c=1;c<arguments.length;c++){var E=arguments[c]!=null?arguments[c]:{};c%2?s(Object(E),!0).forEach(function(y){n(e,y,E[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(E)):s(Object(E)).forEach(function(y){Object.defineProperty(e,y,Object.getOwnPropertyDescriptor(E,y))})}return e}function n(e,c,E){return c=d(c),c in e?Object.defineProperty(e,c,{value:E,enumerable:!0,configurable:!0,writable:!0}):e[c]=E,e}function d(e){var c=v(e,"string");return typeof c=="symbol"?c:String(c)}function v(e,c){if(typeof e!="object"||e===null)return e;var E=e[Symbol.toPrimitive];if(E!==void 0){var y=E.call(e,c||"default");if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(e)}var p=l(l({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:x.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:W.default,bufferController:I.default,capLevelController:L.default,fpsController:_.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:u.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},m()),{},{subtitleStreamController:D.SubtitleStreamController,subtitleTrackController:G.default,timelineController:R.TimelineController,audioStreamController:P.default,audioTrackController:N.default,emeController:T.default,cmcdController:g.default});function m(){return{cueHandler:f.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function r(e,c){if((c.liveSyncDurationCount||c.liveMaxLatencyDurationCount)&&(c.liveSyncDuration||c.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(c.liveMaxLatencyDurationCount!==void 0&&(c.liveSyncDurationCount===void 0||c.liveMaxLatencyDurationCount<=c.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(c.liveMaxLatencyDuration!==void 0&&(c.liveSyncDuration===void 0||c.liveMaxLatencyDuration<=c.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return o({},e,c)}function a(e){var c=e.loader;if(c!==b.default&&c!==x.default)h.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{var E=(0,b.fetchSupported)();E&&(e.loader=b.default,e.progressive=!0,e.enableSoftwareAES=!0,h.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>x});var W=w("./src/polyfills/number.ts"),P=w("./src/utils/ewma-bandwidth-estimator.ts"),N=w("./src/events.ts"),D=w("./src/errors.ts"),G=w("./src/types/loader.ts"),I=w("./src/utils/logger.ts");function R(b,f){for(var u=0;u<f.length;u++){var h=f[u];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(b,_(h.key),h)}}function L(b,f,u){return f&&R(b.prototype,f),u&&R(b,u),Object.defineProperty(b,"prototype",{writable:!1}),b}function _(b){var f=T(b,"string");return typeof f=="symbol"?f:String(f)}function T(b,f){if(typeof b!="object"||b===null)return b;var u=b[Symbol.toPrimitive];if(u!==void 0){var h=u.call(b,f||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(b)}var g=function(){function b(u){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=u;var h=u.config;this.bwEstimator=new P.default(h.abrEwmaSlowVoD,h.abrEwmaFastVoD,h.abrEwmaDefaultEstimate),this.registerListeners()}var f=b.prototype;return f.registerListeners=function(){var h=this.hls;h.on(N.Events.FRAG_LOADING,this.onFragLoading,this),h.on(N.Events.FRAG_LOADED,this.onFragLoaded,this),h.on(N.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(N.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var h=this.hls;h.off(N.Events.FRAG_LOADING,this.onFragLoading,this),h.off(N.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(N.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(N.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},f.onFragLoading=function(h,o){var s=o.frag;if(s.type===G.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=s,this.partCurrent=(l=o.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},f.onLevelLoaded=function(h,o){var s=this.hls.config;o.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},f._abandonRulesCheck=function(){var h=this.fragCurrent,o=this.partCurrent,s=this.hls,l=s.autoLevelEnabled,n=s.media;if(!h||!n)return;var d=o?o.stats:h.stats,v=o?o.duration:h.duration;if(d.aborted||d.loaded&&d.loaded===d.total||h.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!l||n.paused||!n.playbackRate||!n.readyState)return;var p=s.mainForwardBufferInfo;if(p===null)return;var m=performance.now()-d.loading.start,r=Math.abs(n.playbackRate);if(m<=500*v/r)return;var a=d.loaded&&d.loading.first,e=this.bwEstimator.getEstimate(),c=s.levels,E=s.minAutoLevel,y=c[h.level],k=d.total||Math.max(d.loaded,Math.round(v*y.maxBitrate/8)),M=a?d.loaded*1e3/m:0,O=M?(k-d.loaded)/M:k*8/e,U=p.len/r;if(O<=U)return;var F=Number.POSITIVE_INFINITY,H;for(H=h.level-1;H>E;H--){var Y=c[H].maxBitrate;if(F=M?v*Y/(8*.8*M):v*Y/e,F<U)break}if(F>=O)return;I.logger.warn("Fragment "+h.sn+(o?" part "+o.index:"")+" of level "+h.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+H+`
Current BW estimate: `+((0,W.isFiniteNumber)(e)?(e/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+O.toFixed(3)+` s
Estimated load time for the next fragment: `+F.toFixed(3)+` s
Time to underbuffer: `+U.toFixed(3)+" s"),s.nextLoadLevel=H,a&&this.bwEstimator.sample(m,d.loaded),this.clearTimer(),(h.loader||h.keyLoader)&&(this.fragCurrent=this.partCurrent=null,h.abortRequests()),s.trigger(N.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:h,part:o,stats:d})},f.onFragLoaded=function(h,o){var s=o.frag,l=o.part;if(s.type===G.PlaylistLevelType.MAIN&&(0,W.isFiniteNumber)(s.sn)){var n=l?l.stats:s.stats,d=l?l.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var v=this.hls.levels[s.level],p=(v.loaded?v.loaded.bytes:0)+n.loaded,m=(v.loaded?v.loaded.duration:0)+d;v.loaded={bytes:p,duration:m},v.realBitrate=Math.round(8*p/m)}if(s.bitrateTest){var r={stats:n,frag:s,part:l,id:s.type};this.onFragBuffered(N.Events.FRAG_BUFFERED,r)}}},f.onFragBuffered=function(h,o){var s=o.frag,l=o.part,n=l?l.stats:s.stats;if(n.aborted)return;if(s.type!==G.PlaylistLevelType.MAIN||s.sn==="initSegment")return;var d=n.parsing.end-n.loading.start;this.bwEstimator.sample(d,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=d/1e3:this.bitrateTestDelay=0},f.onError=function(h,o){var s;if(((s=o.frag)===null||s===void 0?void 0:s.type)===G.PlaylistLevelType.MAIN){if(o.type===D.ErrorTypes.KEY_SYSTEM_ERROR){this.clearTimer();return}switch(o.details){case D.ErrorDetails.FRAG_LOAD_ERROR:case D.ErrorDetails.FRAG_LOAD_TIMEOUT:case D.ErrorDetails.KEY_LOAD_ERROR:case D.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer();break;default:break}}},f.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},f.getNextABRAutoLevel=function(){var h=this.fragCurrent,o=this.partCurrent,s=this.hls,l=s.maxAutoLevel,n=s.config,d=s.minAutoLevel,v=s.media,p=o?o.duration:h?h.duration:0,m=v&&v.playbackRate!==0?Math.abs(v.playbackRate):1,r=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,a=s.mainForwardBufferInfo,e=(a?a.len:0)/m,c=this.findBestLevel(r,d,l,e,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(c>=0)return c;I.logger.trace((e?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var E=p?Math.min(p,n.maxStarvationDelay):n.maxStarvationDelay,y=n.abrBandWidthFactor,k=n.abrBandWidthUpFactor;if(!e){var M=this.bitrateTestDelay;if(M){var O=p?Math.min(p,n.maxLoadingDelay):n.maxLoadingDelay;E=O-M,I.logger.trace("bitrate test took "+Math.round(1e3*M)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*E)+" ms"),y=k=1}}return c=this.findBestLevel(r,d,l,e+E,y,k),Math.max(c,0)},f.findBestLevel=function(h,o,s,l,n,d){for(var v,p=this.fragCurrent,m=this.partCurrent,r=this.lastLoadedFragLevel,a=this.hls.levels,e=a[r],c=!!(e!=null&&(v=e.details)!==null&&v!==void 0&&v.live),E=e==null?void 0:e.codecSet,y=m?m.duration:p?p.duration:0,k=s;k>=o;k--){var M=a[k];if(!M||E&&M.codecSet!==E)continue;var O=M.details,U=(m?O==null?void 0:O.partTarget:O==null?void 0:O.averagetargetduration)||y,F=void 0;k<=r?F=n*h:F=d*h;var H=a[k].maxBitrate,Y=H*U/F;if(I.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+k+"/"+Math.round(F)+"/"+H+"/"+U+"/"+l+"/"+Y),F>H&&(Y===0||!(0,W.isFiniteNumber)(Y)||c&&!this.bitrateTestDelay||Y<l))return k}return-1},L(b,[{key:"nextAutoLevel",get:function(){var h=this._nextAutoLevel,o=this.bwEstimator;if(h!==-1&&!o.canEstimate())return h;var s=this.getNextABRAutoLevel();return h!==-1&&this.hls.levels[s].loadError?h:(h!==-1&&(s=Math.min(h,s)),s)},set:function(h){this._nextAutoLevel=h}}]),b}();const x=g},"./src/controller/audio-stream-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>n});var W=w("./src/polyfills/number.ts"),P=w("./src/controller/base-stream-controller.ts"),N=w("./src/events.ts"),D=w("./src/utils/buffer-helper.ts"),G=w("./src/controller/fragment-tracker.ts"),I=w("./src/types/level.ts"),R=w("./src/types/loader.ts"),L=w("./src/loader/fragment.ts"),_=w("./src/demux/chunk-cache.ts"),T=w("./src/demux/transmuxer-interface.ts"),g=w("./src/types/transmuxer.ts"),x=w("./src/controller/fragment-finders.ts"),b=w("./src/utils/discontinuities.ts"),f=w("./src/errors.ts");function u(){return u=Object.assign?Object.assign.bind():function(d){for(var v=1;v<arguments.length;v++){var p=arguments[v];for(var m in p)Object.prototype.hasOwnProperty.call(p,m)&&(d[m]=p[m])}return d},u.apply(this,arguments)}function h(d,v){d.prototype=Object.create(v.prototype),d.prototype.constructor=d,o(d,v)}function o(d,v){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,r){return m.__proto__=r,m},o(d,v)}var s=100,l=function(d){h(v,d);function v(m,r,a){var e;return e=d.call(this,m,r,a,"[audio-stream-controller]")||this,e.videoBuffer=null,e.videoTrackCC=-1,e.waitingVideoCC=-1,e.audioSwitch=!1,e.trackId=-1,e.waitingData=null,e.mainDetails=null,e.bufferFlushed=!1,e.cachedTrackLoadedData=null,e._registerListeners(),e}var p=v.prototype;return p.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},p._registerListeners=function(){var r=this.hls;r.on(N.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(N.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),r.on(N.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(N.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(N.Events.ERROR,this.onError,this),r.on(N.Events.BUFFER_RESET,this.onBufferReset,this),r.on(N.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(N.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),r.on(N.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var r=this.hls;r.off(N.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(N.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(N.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(N.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(N.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),r.off(N.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(N.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(N.Events.ERROR,this.onError,this),r.off(N.Events.BUFFER_RESET,this.onBufferReset,this),r.off(N.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(N.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(N.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),r.off(N.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.onInitPtsFound=function(r,a){var e=a.frag,c=a.id,E=a.initPTS;if(c==="main"){var y=e.cc;this.initPTS[e.cc]=E,this.log("InitPTS for cc: "+y+" found from main: "+E),this.videoTrackCC=y,this.state===P.State.WAITING_INIT_PTS&&this.tick()}},p.startLoad=function(r){if(!this.levels){this.startPosition=r,this.state=P.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(s),this.fragLoadError=0,a>0&&r===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),r=a,this.state=P.State.IDLE):(this.loadedmetadata=!1,this.state=P.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},p.doTick=function(){switch(this.state){case P.State.IDLE:this.doTickIdle();break;case P.State.WAITING_TRACK:{var r,a=this.levels,e=this.trackId,c=a==null||((r=a[e])===null||r===void 0)?void 0:r.details;if(c){if(this.waitForCdnTuneIn(c))break;this.state=P.State.WAITING_INIT_PTS}break}case P.State.FRAG_LOADING_WAITING_RETRY:{var E,y=performance.now(),k=this.retryDate;(!k||y>=k||(E=this.media)!==null&&E!==void 0&&E.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=P.State.IDLE);break}case P.State.WAITING_INIT_PTS:{var M=this.waitingData;if(M){var O=M.frag,U=M.part,F=M.cache,H=M.complete;if(this.initPTS[O.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=P.State.FRAG_LOADING;var Y=F.flush(),Q={frag:O,part:U,payload:Y,networkDetails:null};this._handleFragmentLoadProgress(Q),H&&d.prototype._handleFragmentLoadComplete.call(this,Q)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+O.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var z=this.getLoadPosition(),ee=D.BufferHelper.bufferInfo(this.mediaBuffer,z,this.config.maxBufferHole),J=(0,x.fragmentWithinToleranceTest)(ee.end,this.config.maxFragLookUpTolerance,O);J<0&&(this.log("Waiting fragment cc ("+O.cc+") @ "+O.start+" cancelled because another fragment at "+ee.end+" is needed"),this.clearWaitingFragment())}}else this.state=P.State.IDLE}}this.onTickEnd()},p.clearWaitingFragment=function(){var r=this.waitingData;r&&(this.fragmentTracker.removeFragment(r.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=P.State.IDLE)},p.resetLoadingState=function(){this.clearWaitingFragment(),d.prototype.resetLoadingState.call(this)},p.onTickEnd=function(){var r=this.media;if(!r||!r.readyState)return;this.lastCurrentTime=r.currentTime},p.doTickIdle=function(){var r=this.hls,a=this.levels,e=this.media,c=this.trackId,E=r.config;if(!a||!a[c])return;if(!e&&(this.startFragRequested||!E.startFragPrefetch))return;var y=a[c],k=y.details;if(!k||k.live&&this.levelLastLoaded!==c||this.waitForCdnTuneIn(k)){this.state=P.State.WAITING_TRACK;return}var M=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&M&&(this.bufferFlushed=!1,this.afterBufferFlushed(M,L.ElementaryStreamTypes.AUDIO,R.PlaylistLevelType.AUDIO));var O=this.getFwdBufferInfo(M,R.PlaylistLevelType.AUDIO);if(O===null)return;var U=this.audioSwitch;if(!U&&this._streamEnded(O,k)){r.trigger(N.Events.BUFFER_EOS,{type:"audio"}),this.state=P.State.ENDED;return}var F=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,R.PlaylistLevelType.MAIN),H=O.len,Y=this.getMaxBufferLength(F==null?void 0:F.len);if(H>=Y&&!U)return;var Q=k.fragments,z=Q[0].start,ee=O.end;if(U&&e){var J=this.getLoadPosition();ee=J,k.PTSKnown&&J<z&&((O.end>z||O.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),e.currentTime=z+.05))}if(F&&ee>F.end+k.targetduration)return;if((!F||!F.len)&&O.len)return;var X=this.getNextFragment(ee,k);if(!X){this.bufferFlushed=!0;return}this.loadFragment(X,k,ee)},p.getMaxBufferLength=function(r){var a=d.prototype.getMaxBufferLength.call(this);return r?Math.max(a,r):a},p.onMediaDetaching=function(){this.videoBuffer=null,d.prototype.onMediaDetaching.call(this)},p.onAudioTracksUpdated=function(r,a){var e=a.audioTracks;this.resetTransmuxer(),this.levels=e.map(function(c){return new I.Level(c)})},p.onAudioTrackSwitching=function(r,a){var e=!!a.url;this.trackId=a.id;var c=this.fragCurrent;c&&c.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),e?this.setInterval(s):this.resetTransmuxer(),e?(this.audioSwitch=!0,this.state=P.State.IDLE):this.state=P.State.STOPPED,this.tick()},p.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},p.onLevelLoaded=function(r,a){this.mainDetails=a.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(N.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},p.onAudioTrackLoaded=function(r,a){var e;if(this.mainDetails==null){this.cachedTrackLoadedData=a;return}var c=this.levels,E=a.details,y=a.id;if(!c){this.warn("Audio tracks were reset while loading level "+y);return}this.log("Track "+y+" loaded ["+E.startSN+","+E.endSN+"],duration:"+E.totalduration);var k=c[y],M=0;if(E.live||(e=k.details)!==null&&e!==void 0&&e.live){var O=this.mainDetails;if(E.fragments[0]||(E.deltaUpdateFailed=!0),E.deltaUpdateFailed||!O)return;!k.details&&E.hasProgramDateTime&&O.hasProgramDateTime?((0,b.alignMediaPlaylistByPDT)(E,O),M=E.fragments[0].start):M=this.alignPlaylists(E,k.details)}k.details=E,this.levelLastLoaded=y,!this.startFragRequested&&(this.mainDetails||!E.live)&&this.setStartPosition(k.details,M),this.state===P.State.WAITING_TRACK&&!this.waitForCdnTuneIn(E)&&(this.state=P.State.IDLE),this.tick()},p._handleFragmentLoadProgress=function(r){var a,e=r.frag,c=r.part,E=r.payload,y=this.config,k=this.trackId,M=this.levels;if(!M){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+e.sn+" of level "+e.level+" will not be buffered");return}var O=M[k];console.assert(O,"Audio track is defined on fragment load progress");var U=O.details;console.assert(U,"Audio track details are defined on fragment load progress");var F=y.defaultAudioCodec||O.audioCodec||"mp4a.40.2",H=this.transmuxer;H||(H=this.transmuxer=new T.default(this.hls,R.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var Y=this.initPTS[e.cc],Q=(a=e.initSegment)===null||a===void 0?void 0:a.data;if(Y!==void 0){var z=!1,ee=c?c.index:-1,J=ee!==-1,X=new g.ChunkMetadata(e.level,e.sn,e.stats.chunkCount,E.byteLength,ee,J);H.push(E,Q,F,"",e,c,U.totalduration,z,X,Y)}else{this.log("Unknown video PTS for cc "+e.cc+", waiting for video PTS before demuxing audio frag "+e.sn+" of ["+U.startSN+" ,"+U.endSN+"],track "+k);var oe=this.waitingData=this.waitingData||{frag:e,part:c,cache:new _.default,complete:!1},le=oe.cache;le.push(new Uint8Array(E)),this.waitingVideoCC=this.videoTrackCC,this.state=P.State.WAITING_INIT_PTS}},p._handleFragmentLoadComplete=function(r){if(this.waitingData){this.waitingData.complete=!0;return}d.prototype._handleFragmentLoadComplete.call(this,r)},p.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},p.onBufferCreated=function(r,a){var e=a.tracks.audio;e&&(this.mediaBuffer=e.buffer||null),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer||null)},p.onFragBuffered=function(r,a){var e=a.frag,c=a.part;if(e.type!==R.PlaylistLevelType.AUDIO){if(!this.loadedmetadata&&e.type===R.PlaylistLevelType.MAIN){var E;(E=this.videoBuffer||this.media)!==null&&E!==void 0&&E.buffered.length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(e)){this.warn("Fragment "+e.sn+(c?" p: "+c.index:"")+" of level "+e.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}e.sn!=="initSegment"&&(this.fragPrevious=e,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(N.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(e,c)},p.onError=function(r,a){if(a.type===f.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(R.PlaylistLevelType.AUDIO,a);return}switch(a.details){case f.ErrorDetails.FRAG_LOAD_ERROR:case f.ErrorDetails.FRAG_LOAD_TIMEOUT:case f.ErrorDetails.FRAG_PARSING_ERROR:case f.ErrorDetails.KEY_LOAD_ERROR:case f.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(R.PlaylistLevelType.AUDIO,a);break;case f.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case f.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==P.State.ERROR&&this.state!==P.State.STOPPED&&(this.state=a.fatal?P.State.ERROR:P.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case f.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===P.State.PARSING||this.state===P.State.PARSED)){var e=!0,c=this.getFwdBufferInfo(this.mediaBuffer,R.PlaylistLevelType.AUDIO);c&&c.len>.5&&(e=!this.reduceMaxBufferLength(c.len)),e&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},p.onBufferFlushed=function(r,a){var e=a.type;e===L.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===P.State.ENDED&&(this.state=P.State.IDLE))},p._handleTransmuxComplete=function(r){var a,e="audio",c=this.hls,E=r.remuxResult,y=r.chunkMeta,k=this.getCurrentContext(y);if(!k){this.warn("The loading context changed while buffering fragment "+y.sn+" of level "+y.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(y.level);return}var M=k.frag,O=k.part,U=k.level.details,F=E.audio,H=E.text,Y=E.id3,Q=E.initSegment;if(this.fragContextChanged(M)||!U)return;if(this.state=P.State.PARSING,this.audioSwitch&&F&&this.completeAudioSwitch(),Q!=null&&Q.tracks&&(this._bufferInitSegment(Q.tracks,M,y),c.trigger(N.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:e,tracks:Q.tracks})),F){var z=F.startPTS,ee=F.endPTS,J=F.startDTS,X=F.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:z,endPTS:ee,startDTS:J,endDTS:X}),M.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,z,ee,J,X),this.bufferFragmentData(F,M,O,y)}if(Y!=null&&(a=Y.samples)!==null&&a!==void 0&&a.length){var oe=u({id:e,frag:M,details:U},Y);c.trigger(N.Events.FRAG_PARSING_METADATA,oe)}if(H){var le=u({id:e,frag:M,details:U},H);c.trigger(N.Events.FRAG_PARSING_USERDATA,le)}},p._bufferInitSegment=function(r,a,e){if(this.state!==P.State.PARSING)return;r.video&&delete r.video;var c=r.audio;if(!c)return;c.levelCodec=c.codec,c.id="audio",this.log("Init audio buffer, container:"+c.container+", codecs[parsed]=["+c.codec+"]"),this.hls.trigger(N.Events.BUFFER_CODECS,r);var E=c.initSegment;if(E!=null&&E.byteLength){var y={type:"audio",frag:a,part:null,chunkMeta:e,parent:a.type,data:E};this.hls.trigger(N.Events.BUFFER_APPENDING,y)}this.tick()},p.loadFragment=function(r,a,e){var c=this.fragmentTracker.getState(r);this.fragCurrent=r,(this.audioSwitch||c===G.FragmentState.NOT_LOADED||c===G.FragmentState.PARTIAL)&&(r.sn==="initSegment"?this._loadInitSegment(r,a):a.live&&!(0,W.isFiniteNumber)(this.initPTS[r.cc])?(this.log("Waiting for video PTS in continuity counter "+r.cc+" of live stream before loading audio fragment "+r.sn+" of level "+this.trackId),this.state=P.State.WAITING_INIT_PTS):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,a,e)))},p.completeAudioSwitch=function(){var r=this.hls,a=this.media,e=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,r.trigger(N.Events.AUDIO_TRACK_SWITCHED,{id:e})},v}(P.default);const n=l},"./src/controller/audio-track-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>x});var W=w("./src/events.ts"),P=w("./src/errors.ts"),N=w("./src/controller/base-playlist-controller.ts"),D=w("./src/types/loader.ts");function G(b,f){for(var u=0;u<f.length;u++){var h=f[u];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(b,R(h.key),h)}}function I(b,f,u){return f&&G(b.prototype,f),u&&G(b,u),Object.defineProperty(b,"prototype",{writable:!1}),b}function R(b){var f=L(b,"string");return typeof f=="symbol"?f:String(f)}function L(b,f){if(typeof b!="object"||b===null)return b;var u=b[Symbol.toPrimitive];if(u!==void 0){var h=u.call(b,f||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(b)}function _(b,f){b.prototype=Object.create(f.prototype),b.prototype.constructor=b,T(b,f)}function T(b,f){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,o){return h.__proto__=o,h},T(b,f)}var g=function(b){_(f,b);function f(h){var o;return o=b.call(this,h,"[audio-track-controller]")||this,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.trackName="",o.selectDefaultTrack=!0,o.registerListeners(),o}var u=f.prototype;return u.registerListeners=function(){var o=this.hls;o.on(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(W.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(W.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on(W.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),o.on(W.Events.ERROR,this.onError,this)},u.unregisterListeners=function(){var o=this.hls;o.off(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(W.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(W.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off(W.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),o.off(W.Events.ERROR,this.onError,this)},u.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,b.prototype.destroy.call(this)},u.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},u.onManifestParsed=function(o,s){this.tracks=s.audioTracks||[]},u.onAudioTrackLoaded=function(o,s){var l=s.id,n=s.details,d=this.tracksInGroup[l];if(!d){this.warn("Invalid audio track id "+l);return}var v=d.details;d.details=s.details,this.log("audioTrack "+l+" loaded ["+n.startSN+"-"+n.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,v))},u.onLevelLoading=function(o,s){this.switchLevel(s.level)},u.onLevelSwitching=function(o,s){this.switchLevel(s.level)},u.switchLevel=function(o){var s=this.hls.levels[o];if(!(s!=null&&s.audioGroupIds))return;var l=s.audioGroupIds[s.urlId];if(this.groupId!==l){this.groupId=l;var n=this.tracks.filter(function(v){return!l||v.groupId===l});this.selectDefaultTrack&&!n.some(function(v){return v.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;var d={audioTracks:n};this.log("Updating audio tracks, "+n.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(W.Events.AUDIO_TRACKS_UPDATED,d),this.selectInitialTrack()}},u.onError=function(o,s){if(b.prototype.onError.call(this,o,s),s.fatal||!s.context)return;s.context.type===D.PlaylistContextType.AUDIO_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},u.setAudioTrack=function(o){var s=this.tracksInGroup;if(o<0||o>=s.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=s[this.trackId];this.log("Now switching to audio-track index "+o);var n=s[o],d=n.id,v=n.groupId,p=v===void 0?"":v,m=n.name,r=n.type,a=n.url;if(this.trackId=o,this.trackName=m,this.selectDefaultTrack=!1,this.hls.trigger(W.Events.AUDIO_TRACK_SWITCHING,{id:d,groupId:p,name:m,type:r,url:a}),n.details&&!n.details.live)return;var e=this.switchParams(n.url,l==null?void 0:l.details);this.loadPlaylist(e)},u.selectInitialTrack=function(){var o=this.tracksInGroup;console.assert(o.length,"Initial audio track should be selected when tracks are known");var s=this.trackName,l=this.findTrackId(s)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(W.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},u.findTrackId=function(o){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var n=s[l];if((!this.selectDefaultTrack||n.default)&&(!o||o===n.name))return n.id}return-1},u.loadPlaylist=function(o){b.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,n=s.groupId,d=s.url;if(o)try{d=o.addDirectives(d)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(W.Events.AUDIO_TRACK_LOADING,{url:d,id:l,groupId:n,deliveryDirectives:o||null})}},I(f,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1,this.setAudioTrack(o)}}]),f}(N.default);const x=g},"./src/controller/base-playlist-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>G});var W=w("./src/types/level.ts"),P=w("./src/controller/level-helper.ts"),N=w("./src/utils/logger.ts"),D=w("./src/errors.ts"),G=function(){function I(L,_){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=N.logger.log.bind(N.logger,_+":"),this.warn=N.logger.warn.bind(N.logger,_+":"),this.hls=L}var R=I.prototype;return R.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},R.onError=function(_,T){T.fatal&&(T.type===D.ErrorTypes.NETWORK_ERROR||T.type===D.ErrorTypes.KEY_SYSTEM_ERROR)&&this.stopLoad()},R.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},R.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},R.stopLoad=function(){this.canLoad=!1,this.clearTimer()},R.switchParams=function(_,T){var g=T==null?void 0:T.renditionReports;if(g)for(var x=0;x<g.length;x++){var b=g[x],f=void 0;try{f=new self.URL(b.URI,T.url).href}catch(s){N.logger.warn("Could not construct new URL for Rendition Report: "+s),f=b.URI||""}if(f===_.slice(-f.length)){var u=parseInt(b["LAST-MSN"])||(T==null?void 0:T.lastPartSn),h=parseInt(b["LAST-PART"])||(T==null?void 0:T.lastPartIndex);if(this.hls.config.lowLatencyMode){var o=Math.min(T.age-T.partTarget,T.targetduration);h>=0&&o>T.partTarget&&(h+=1)}return new W.HlsUrlParameters(u,h>=0?h:void 0,W.HlsSkip.No)}}},R.loadPlaylist=function(_){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},R.shouldLoadTrack=function(_){return this.canLoad&&_&&!!_.url&&(!_.details||_.details.live)},R.playlistLoaded=function(_,T,g){var x=this,b=T.details,f=T.stats,u=self.performance.now(),h=f.loading.first?Math.max(0,u-f.loading.first):0;if(b.advancedDateTime=Date.now()-h,b.live||g!=null&&g.live){if(b.reloaded(g),g&&this.log("live playlist "+_+" "+(b.advanced?"REFRESHED "+b.lastPartSn+"-"+b.lastPartIndex:"MISSED")),g&&b.fragments.length>0&&(0,P.mergeDetails)(g,b),!this.canLoad||!b.live)return;var o,s=void 0,l=void 0;if(b.canBlockReload&&b.endSN&&b.advanced){var n=this.hls.config.lowLatencyMode,d=b.lastPartSn,v=b.endSN,p=b.lastPartIndex,m=p!==-1,r=d===v,a=n?0:p;m?(s=r?v+1:d,l=r?a:p+1):s=v+1;var e=b.age,c=e+b.ageHeader,E=Math.min(c-b.partTarget,b.targetduration*1.5);if(E>0){if(g&&E>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+E+" with playlist age: "+b.age),E=0;else{var y=Math.floor(E/b.targetduration);if(s+=y,l!==void 0){var k=Math.round(E%b.targetduration/b.partTarget);l+=k}this.log("CDN Tune-in age: "+b.ageHeader+"s last advanced "+e.toFixed(2)+"s goal: "+E+" skip sn "+y+" to part "+l)}b.tuneInGoal=E}if(o=this.getDeliveryDirectives(b,T.deliveryDirectives,s,l),n||!r){this.loadPlaylist(o);return}}else o=this.getDeliveryDirectives(b,T.deliveryDirectives,s,l);var M=this.hls.mainForwardBufferInfo,O=M?M.end-M.len:0,U=(b.edge-O)*1e3,F=(0,P.computeReloadInterval)(b,U);b.updated?u>this.requestScheduled+F&&(this.requestScheduled=f.loading.start):this.requestScheduled=-1,s!==void 0&&b.canBlockReload?this.requestScheduled=f.loading.first+F-(b.partTarget*1e3||1e3):this.requestScheduled=(this.requestScheduled===-1?u:this.requestScheduled)+F;var H=this.requestScheduled-u;H=Math.max(0,H),this.log("reload live playlist "+_+" in "+Math.round(H)+" ms"),this.timer=self.setTimeout(function(){return x.loadPlaylist(o)},H)}else this.clearTimer()},R.getDeliveryDirectives=function(_,T,g,x){var b=(0,W.getSkipValue)(_,g);return T!=null&&T.skip&&_.deltaUpdateFailed&&(g=T.msn,x=T.part,b=W.HlsSkip.No),new W.HlsUrlParameters(g,x,b)},R.retryLoadingOrFail=function(_){var T=this,g=this.hls.config,x=this.retryCount<g.levelLoadingMaxRetry;if(x){var b;if(this.requestScheduled=-1,this.retryCount++,_.details.indexOf("LoadTimeOut")>-1&&(b=_.context)!==null&&b!==void 0&&b.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+_.details+'"'),this.loadPlaylist();else{var f=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return T.loadPlaylist()},f),this.warn("retry playlist loading #"+this.retryCount+" in "+f+' ms after "'+_.details+'"')}}else this.warn('cannot recover from error "'+_.details+'"'),this.clearTimer(),_.fatal=!0;return x},I}()},"./src/controller/base-stream-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{State:()=>m,default:()=>r});var W=w("./src/polyfills/number.ts"),P=w("./src/task-loop.ts"),N=w("./src/controller/fragment-tracker.ts"),D=w("./src/utils/buffer-helper.ts"),G=w("./src/utils/logger.ts"),I=w("./src/events.ts"),R=w("./src/errors.ts"),L=w("./src/types/transmuxer.ts"),_=w("./src/utils/mp4-tools.ts"),T=w("./src/utils/discontinuities.ts"),g=w("./src/controller/fragment-finders.ts"),x=w("./src/controller/level-helper.ts"),b=w("./src/loader/fragment-loader.ts"),f=w("./src/crypt/decrypter.ts"),u=w("./src/utils/time-ranges.ts"),h=w("./src/types/loader.ts");function o(a,e){for(var c=0;c<e.length;c++){var E=e[c];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(a,l(E.key),E)}}function s(a,e,c){return e&&o(a.prototype,e),c&&o(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function l(a){var e=n(a,"string");return typeof e=="symbol"?e:String(e)}function n(a,e){if(typeof a!="object"||a===null)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var E=c.call(a,e||"default");if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function d(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function v(a,e){a.prototype=Object.create(e.prototype),a.prototype.constructor=a,p(a,e)}function p(a,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,y){return E.__proto__=y,E},p(a,e)}var m={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},r=function(a){v(e,a);function e(E,y,k,M){var O;return O=a.call(this)||this,O.hls=void 0,O.fragPrevious=null,O.fragCurrent=null,O.fragmentTracker=void 0,O.transmuxer=null,O._state=m.STOPPED,O.media=null,O.mediaBuffer=null,O.config=void 0,O.bitrateTest=!1,O.lastCurrentTime=0,O.nextLoadPosition=0,O.startPosition=0,O.loadedmetadata=!1,O.fragLoadError=0,O.retryDate=0,O.levels=null,O.fragmentLoader=void 0,O.keyLoader=void 0,O.levelLastLoaded=null,O.startFragRequested=!1,O.decrypter=void 0,O.initPTS=[],O.onvseeking=null,O.onvended=null,O.logPrefix="",O.log=void 0,O.warn=void 0,O.logPrefix=M,O.log=G.logger.log.bind(G.logger,M+":"),O.warn=G.logger.warn.bind(G.logger,M+":"),O.hls=E,O.fragmentLoader=new b.default(E.config),O.keyLoader=k,O.fragmentTracker=y,O.config=E.config,O.decrypter=new f.default(E.config),E.on(I.Events.LEVEL_SWITCHING,O.onLevelSwitching,d(O)),O}var c=e.prototype;return c.doTick=function(){this.onTickEnd()},c.onTickEnd=function(){},c.startLoad=function(y){},c.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var y=this.fragCurrent;y&&(y.abortRequests(),this.fragmentTracker.removeFragment(y)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=m.STOPPED},c._streamEnded=function(y,k){if(k.live||y.nextStart||!y.end||!this.media)return!1;var M=k.partList;if(M!=null&&M.length){var O=M[M.length-1],U=D.BufferHelper.isBuffered(this.media,O.start+O.duration/2);return U}var F=k.fragments[k.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(F)},c.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var y;return(y=this.levels[this.levelLastLoaded])===null||y===void 0?void 0:y.details}},c.onMediaAttached=function(y,k){var M=this.media=this.mediaBuffer=k.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),M.addEventListener("seeking",this.onvseeking),M.addEventListener("ended",this.onvended);var O=this.config;this.levels&&O.autoStartLoad&&this.state===m.STOPPED&&this.startLoad(O.startPosition)},c.onMediaDetaching=function(){var y=this.media;y!=null&&y.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),y&&this.onvseeking&&this.onvended&&(y.removeEventListener("seeking",this.onvseeking),y.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},c.onMediaSeeking=function(){var y=this.config,k=this.fragCurrent,M=this.media,O=this.mediaBuffer,U=this.state,F=M?M.currentTime:0,H=D.BufferHelper.bufferInfo(O||M,F,y.maxBufferHole);if(this.log("media seeking to "+((0,W.isFiniteNumber)(F)?F.toFixed(3):F)+", state: "+U),this.state===m.ENDED)this.resetLoadingState();else if(k){var Y=y.maxFragLookUpTolerance,Q=k.start-Y,z=k.start+k.duration+Y;if(!H.len||z<H.start||Q>H.end){var ee=F>z;(F<Q||ee)&&(ee&&k.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),k.abortRequests()),this.resetLoadingState())}}M&&(this.lastCurrentTime=F),!this.loadedmetadata&&!H.len&&(this.nextLoadPosition=this.startPosition=F),this.tickImmediate()},c.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},c.onLevelSwitching=function(y,k){this.fragLoadError=0},c.onHandlerDestroying=function(){this.stopLoad(),a.prototype.onHandlerDestroying.call(this)},c.onHandlerDestroyed=function(){this.state=m.STOPPED,this.hls.off(I.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,a.prototype.onHandlerDestroyed.call(this)},c.loadFragment=function(y,k,M){this._loadFragForPlayback(y,k,M)},c._loadFragForPlayback=function(y,k,M){var O=this,U=function(H){if(O.fragContextChanged(y)){O.warn("Fragment "+y.sn+(H.part?" p: "+H.part.index:"")+" of level "+y.level+" was dropped during download."),O.fragmentTracker.removeFragment(y);return}y.stats.chunkCount++,O._handleFragmentLoadProgress(H)};this._doFragLoad(y,k,M,U).then(function(F){if(!F)return;O.fragLoadError=0;var H=O.state;if(O.fragContextChanged(y)){(H===m.FRAG_LOADING||!O.fragCurrent&&H===m.PARSING)&&(O.fragmentTracker.removeFragment(y),O.state=m.IDLE);return}"payload"in F&&(O.log("Loaded fragment "+y.sn+" of level "+y.level),O.hls.trigger(I.Events.FRAG_LOADED,F)),O._handleFragmentLoadComplete(F)}).catch(function(F){if(O.state===m.STOPPED||O.state===m.ERROR)return;O.warn(F),O.resetFragmentLoading(y)})},c.flushMainBuffer=function(y,k,M){if(M===void 0&&(M=null),!(y-k))return;var O={startOffset:y,endOffset:k,type:M};this.fragLoadError=0,this.hls.trigger(I.Events.BUFFER_FLUSHING,O)},c._loadInitSegment=function(y,k){var M=this;this._doFragLoad(y,k).then(function(O){if(!O||M.fragContextChanged(y)||!M.levels)throw new Error("init load aborted");return O}).then(function(O){var U=M.hls,F=O.payload,H=y.decryptdata;if(F&&F.byteLength>0&&H&&H.key&&H.iv&&H.method==="AES-128"){var Y=self.performance.now();return M.decrypter.decrypt(new Uint8Array(F),H.key.buffer,H.iv.buffer).then(function(Q){var z=self.performance.now();return U.trigger(I.Events.FRAG_DECRYPTED,{frag:y,payload:Q,stats:{tstart:Y,tdecrypt:z}}),O.payload=Q,O})}return O}).then(function(O){var U=M.fragCurrent,F=M.hls,H=M.levels;if(!H)throw new Error("init load aborted, missing levels");var Y=H[y.level].details;console.assert(Y,"Level details are defined when init segment is loaded");var Q=y.stats;M.state=m.IDLE,M.fragLoadError=0,y.data=new Uint8Array(O.payload),Q.parsing.start=Q.buffering.start=self.performance.now(),Q.parsing.end=Q.buffering.end=self.performance.now(),O.frag===U&&F.trigger(I.Events.FRAG_BUFFERED,{stats:Q,frag:U,part:null,id:y.type}),M.tick()}).catch(function(O){if(M.state===m.STOPPED||M.state===m.ERROR)return;M.warn(O),M.resetFragmentLoading(y)})},c.fragContextChanged=function(y){var k=this.fragCurrent;return!y||!k||y.level!==k.level||y.sn!==k.sn||y.urlId!==k.urlId},c.fragBufferedComplete=function(y,k){var M,O,U,F,H=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+y.type+" sn: "+y.sn+(k?" part: "+k.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level+" (frag:["+((M=y.startPTS)!=null?M:NaN).toFixed(3)+"-"+((O=y.endPTS)!=null?O:NaN).toFixed(3)+"] > buffer:"+(H?u.default.toString(D.BufferHelper.getBuffered(H)):"(detached)")+")"),this.state=m.IDLE,!H)return;!this.loadedmetadata&&y.type==h.PlaylistLevelType.MAIN&&H.buffered.length&&((U=this.fragCurrent)===null||U===void 0?void 0:U.sn)===((F=this.fragPrevious)===null||F===void 0?void 0:F.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick()},c.seekToStartPos=function(){},c._handleFragmentLoadComplete=function(y){var k=this.transmuxer;if(!k)return;var M=y.frag,O=y.part,U=y.partsLoaded,F=!U||U.length===0||U.some(function(Y){return!Y}),H=new L.ChunkMetadata(M.level,M.sn,M.stats.chunkCount+1,0,O?O.index:-1,!F);k.flush(H)},c._handleFragmentLoadProgress=function(y){},c._doFragLoad=function(y,k,M,O){var U,F=this;if(M===void 0&&(M=null),!this.levels)throw new Error("frag load aborted, missing levels");var H=null;if(y.encrypted&&!((U=y.decryptdata)!==null&&U!==void 0&&U.key)?(this.log("Loading key for "+y.sn+" of ["+k.startSN+"-"+k.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level),this.state=m.KEY_LOADING,this.fragCurrent=y,H=this.keyLoader.load(y).then(function(J){if(!F.fragContextChanged(J.frag))return F.hls.trigger(I.Events.KEY_LOADED,J),F.state===m.KEY_LOADING&&(F.state=m.IDLE),J}),this.hls.trigger(I.Events.KEY_LOADING,{frag:y}),this.throwIfFragContextChanged("KEY_LOADING")):!y.encrypted&&k.encryptedFragments.length&&this.keyLoader.loadClear(y,k.encryptedFragments),M=Math.max(y.start,M||0),this.config.lowLatencyMode&&k){var Y=k.partList;if(Y&&O){M>y.end&&k.fragmentHint&&(y=k.fragmentHint);var Q=this.getNextPart(Y,y,M);if(Q>-1){var z=Y[Q];return this.log("Loading part sn: "+y.sn+" p: "+z.index+" cc: "+y.cc+" of playlist ["+k.startSN+"-"+k.endSN+"] parts [0-"+Q+"-"+(Y.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(M.toFixed(3))),this.nextLoadPosition=z.start+z.duration,this.state=m.FRAG_LOADING,this.hls.trigger(I.Events.FRAG_LOADING,{frag:y,part:Y[Q],targetBufferTime:M}),this.throwIfFragContextChanged("FRAG_LOADING parts"),H?H.then(function(J){return!J||F.fragContextChanged(J.frag)?null:F.doFragPartsLoad(y,Y,Q,O)}).catch(function(J){return F.handleFragLoadError(J)}):this.doFragPartsLoad(y,Y,Q,O).catch(function(J){return F.handleFragLoadError(J)})}else if(!y.url||this.loadedEndOfParts(Y,M))return Promise.resolve(null)}}this.log("Loading fragment "+y.sn+" cc: "+y.cc+" "+(k?"of ["+k.startSN+"-"+k.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(M.toFixed(3))),(0,W.isFiniteNumber)(y.sn)&&!this.bitrateTest&&(this.nextLoadPosition=y.start+y.duration),this.state=m.FRAG_LOADING,this.hls.trigger(I.Events.FRAG_LOADING,{frag:y,targetBufferTime:M}),this.throwIfFragContextChanged("FRAG_LOADING");var ee=this.config.progressive;return ee&&H?H.then(function(J){return!J||F.fragContextChanged(J==null?void 0:J.frag)?null:F.fragmentLoader.load(y,O)}).catch(function(J){return F.handleFragLoadError(J)}):Promise.all([this.fragmentLoader.load(y,ee?O:void 0),H]).then(function(J){var X=J[0];return!ee&&X&&O&&O(X),X}).catch(function(J){return F.handleFragLoadError(J)})},c.throwIfFragContextChanged=function(y){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+y)},c.doFragPartsLoad=function(y,k,M,O){var U=this;return new Promise(function(F,H){var Y=[],Q=function z(ee){var J=k[ee];U.fragmentLoader.loadPart(y,J,O).then(function(X){Y[J.index]=X;var oe=X.part;U.hls.trigger(I.Events.FRAG_LOADED,X);var le=k[ee+1];if(le&&le.fragment===y)z(ee+1);else return F({frag:y,part:oe,partsLoaded:Y})}).catch(H)};Q(M)})},c.handleFragLoadError=function(y){if("data"in y){var k=y.data;y.data&&k.details===R.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(k.frag,k.part):this.hls.trigger(I.Events.ERROR,k)}else this.hls.trigger(I.Events.ERROR,{type:R.ErrorTypes.OTHER_ERROR,details:R.ErrorDetails.INTERNAL_EXCEPTION,err:y,fatal:!0});return null},c._handleTransmuxerFlush=function(y){var k=this.getCurrentContext(y);if(!k||this.state!==m.PARSING){!this.fragCurrent&&this.state!==m.STOPPED&&this.state!==m.ERROR&&(this.state=m.IDLE);return}var M=k.frag,O=k.part,U=k.level,F=self.performance.now();M.stats.parsing.end=F,O&&(O.stats.parsing.end=F),this.updateLevelTiming(M,O,U,y.partial)},c.getCurrentContext=function(y){var k=this.levels,M=y.level,O=y.sn,U=y.part;if(!k||!k[M])return this.warn("Levels object was unset while buffering fragment "+O+" of level "+M+". The current chunk will not be buffered."),null;var F=k[M],H=U>-1?(0,x.getPartWith)(F,O,U):null,Y=H?H.fragment:(0,x.getFragmentWithSN)(F,O,this.fragCurrent);return Y?{frag:Y,part:H,level:F}:null},c.bufferFragmentData=function(y,k,M,O){if(!y||this.state!==m.PARSING)return;var U=y.data1,F=y.data2,H=U;if(U&&F&&(H=(0,_.appendUint8Array)(U,F)),!H||!H.length)return;var Y={type:y.type,frag:k,part:M,chunkMeta:O,parent:k.type,data:H};this.hls.trigger(I.Events.BUFFER_APPENDING,Y),y.dropped&&y.independent&&!M&&this.flushBufferGap(k)},c.flushBufferGap=function(y){var k=this.media;if(!k)return;if(!D.BufferHelper.isBuffered(k,k.currentTime)){this.flushMainBuffer(0,y.start);return}var M=k.currentTime,O=D.BufferHelper.bufferInfo(k,M,0),U=y.duration,F=Math.min(this.config.maxFragLookUpTolerance*2,U*.25),H=Math.max(Math.min(y.start-F,O.end-F),M+F);y.start-H>F&&this.flushMainBuffer(H,y.start)},c.getFwdBufferInfo=function(y,k){var M=this.config,O=this.getLoadPosition();if(!(0,W.isFiniteNumber)(O))return null;var U=D.BufferHelper.bufferInfo(y,O,M.maxBufferHole);if(U.len===0&&U.nextStart!==void 0){var F=this.fragmentTracker.getBufferedFrag(O,k);if(F&&U.nextStart<F.end)return D.BufferHelper.bufferInfo(y,O,Math.max(U.nextStart,M.maxBufferHole))}return U},c.getMaxBufferLength=function(y){var k=this.config,M;return y?M=Math.max(8*k.maxBufferSize/y,k.maxBufferLength):M=k.maxBufferLength,Math.min(M,k.maxMaxBufferLength)},c.reduceMaxBufferLength=function(y){var k=this.config,M=y||k.maxBufferLength;return k.maxMaxBufferLength>=M?(k.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+k.maxMaxBufferLength+"s"),!0):!1},c.getNextFragment=function(y,k){var M=k.fragments,O=M.length;if(!O)return null;var U=this.config,F=M[0].start,H;if(k.live){var Y=U.initialLiveManifestSize;if(O<Y)return this.warn("Not enough fragments to start playback (have: "+O+", need: "+Y+")"),null;!k.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(H=this.getInitialLiveFragment(k,M),this.startPosition=H?this.hls.liveSyncPosition||H.start:y)}else y<=F&&(H=M[0]);if(!H){var Q=U.lowLatencyMode?k.partEnd:k.fragmentEnd;H=this.getFragmentAtPosition(y,Q,k)}return this.mapToInitFragWhenRequired(H)},c.mapToInitFragWhenRequired=function(y){return y!=null&&y.initSegment&&!(y!=null&&y.initSegment.data)&&!this.bitrateTest?y.initSegment:y},c.getNextPart=function(y,k,M){for(var O=-1,U=!1,F=!0,H=0,Y=y.length;H<Y;H++){var Q=y[H];if(F=F&&!Q.independent,O>-1&&M<Q.start)break;var z=Q.loaded;z?O=-1:(U||Q.independent||F)&&Q.fragment===k&&(O=H),U=z}return O},c.loadedEndOfParts=function(y,k){var M=y[y.length-1];return M&&k>M.start&&M.loaded},c.getInitialLiveFragment=function(y,k){var M=this.fragPrevious,O=null;if(M){if(y.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+M.programDateTime),O=(0,g.findFragmentByPDT)(k,M.endProgramDateTime,this.config.maxFragLookUpTolerance)),!O){var U=M.sn+1;if(U>=y.startSN&&U<=y.endSN){var F=k[U-y.startSN];M.cc===F.cc&&(O=F,this.log("Live playlist, switching playlist, load frag with next SN: "+O.sn))}O||(O=(0,g.findFragWithCC)(k,M.cc),O&&this.log("Live playlist, switching playlist, load frag with same CC: "+O.sn))}}else{var H=this.hls.liveSyncPosition;H!==null&&(O=this.getFragmentAtPosition(H,this.bitrateTest?y.fragmentEnd:y.edge,y))}return O},c.getFragmentAtPosition=function(y,k,M){var O=this.config,U=this.fragPrevious,F=M.fragments,H=M.endSN,Y=M.fragmentHint,Q=O.maxFragLookUpTolerance,z=!!(O.lowLatencyMode&&M.partList&&Y);z&&Y&&!this.bitrateTest&&(F=F.concat(Y),H=Y.sn);var ee;if(y<k){var J=y>k-Q?0:Q;ee=(0,g.findFragmentByPTS)(U,F,y,J)}else ee=F[F.length-1];if(ee){var X=ee.sn-M.startSN;if(this.fragmentTracker.getState(ee)===N.FragmentState.OK&&(U=ee),U&&ee.sn===U.sn&&!z){var oe=U&&ee.level===U.level;if(oe){var le=F[X+1];ee.sn<H&&this.fragmentTracker.getState(le)!==N.FragmentState.OK?(this.log("SN "+ee.sn+" just loaded, load next one: "+le.sn),ee=le):ee=null}}}return ee},c.synchronizeToLiveEdge=function(y){var k=this.config,M=this.media;if(!M)return;var O=this.hls.liveSyncPosition,U=M.currentTime,F=y.fragments[0].start,H=y.edge,Y=U>=F-k.maxFragLookUpTolerance&&U<=H;if(O!==null&&M.duration>O&&(U<O||!Y)){var Q=k.liveMaxLatencyDuration!==void 0?k.liveMaxLatencyDuration:k.liveMaxLatencyDurationCount*y.targetduration;(!Y&&M.readyState<4||U<H-Q)&&(this.loadedmetadata||(this.nextLoadPosition=O),M.readyState&&(this.warn("Playback: "+U.toFixed(3)+" is located too far from the end of live sliding playlist: "+H+", reset currentTime to : "+O.toFixed(3)),M.currentTime=O))}},c.alignPlaylists=function(y,k){var M=this.levels,O=this.levelLastLoaded,U=this.fragPrevious,F=O!==null?M[O]:null,H=y.fragments.length;if(!H)return this.warn("No fragments in live playlist"),0;var Y=y.fragments[0].start,Q=!k,z=y.alignedSliding&&(0,W.isFiniteNumber)(Y);if(Q||!z&&!Y){(0,T.alignStream)(U,F,y);var ee=y.fragments[0].start;return this.log("Live playlist sliding: "+ee.toFixed(2)+" start-sn: "+(k?k.startSN:"na")+"->"+y.startSN+" prev-sn: "+(U?U.sn:"na")+" fragments: "+H),ee}return Y},c.waitForCdnTuneIn=function(y){var k=3;return y.live&&y.canBlockReload&&y.partTarget&&y.tuneInGoal>Math.max(y.partHoldBack,y.partTarget*k)},c.setStartPosition=function(y,k){var M=this.startPosition;if(M<k&&(M=-1),M===-1||this.lastCurrentTime===-1){var O=y.startTimeOffset;(0,W.isFiniteNumber)(O)?(M=k+O,O<0&&(M+=y.totalduration),M=Math.min(Math.max(k,M),k+y.totalduration),this.log("Start time offset "+O+" found in playlist, adjust startPosition to "+M),this.startPosition=M):y.live?M=this.hls.liveSyncPosition||k:this.startPosition=M=0,this.lastCurrentTime=M}this.nextLoadPosition=M},c.getLoadPosition=function(){var y=this.media,k=0;return this.loadedmetadata&&y?k=y.currentTime:this.nextLoadPosition&&(k=this.nextLoadPosition),k},c.handleFragLoadAborted=function(y,k){this.transmuxer&&y.sn!=="initSegment"&&y.stats.aborted&&(this.warn("Fragment "+y.sn+(k?" part"+k.index:"")+" of level "+y.level+" was aborted"),this.resetFragmentLoading(y))},c.resetFragmentLoading=function(y){(!this.fragCurrent||!this.fragContextChanged(y)&&this.state!==m.FRAG_LOADING_WAITING_RETRY)&&(this.state=m.IDLE)},c.onFragmentOrKeyLoadError=function(y,k){if(k.fatal){this.stopLoad(),this.state=m.ERROR;return}var M=this.config;if(k.chunkMeta){var O=this.getCurrentContext(k.chunkMeta);O&&(k.frag=O.frag,k.levelRetry=!0,this.fragLoadError=M.fragLoadingMaxRetry)}var U=k.frag;if(!U||U.type!==y)return;var F=this.fragCurrent;if(console.assert(F&&U.sn===F.sn&&U.level===F.level&&U.urlId===F.urlId,"Frag load error must match current frag to retry"),this.fragLoadError+1<=M.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var H=Math.min(Math.pow(2,this.fragLoadError)*M.fragLoadingRetryDelay,M.fragLoadingMaxRetryTimeout);this.warn("Fragment "+U.sn+" of "+y+" "+U.level+" failed to load, retrying in "+H+"ms"),this.retryDate=self.performance.now()+H,this.fragLoadError++,this.state=m.FRAG_LOADING_WAITING_RETRY}else k.levelRetry?(y===h.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=m.IDLE):(G.logger.error(k.details+" reaches max retry, redispatch as fatal ..."),k.fatal=!0,this.hls.stopLoad(),this.state=m.ERROR)},c.afterBufferFlushed=function(y,k,M){if(!y)return;var O=D.BufferHelper.getBuffered(y);this.fragmentTracker.detectEvictedFragments(k,O,M),this.state===m.ENDED&&this.resetLoadingState()},c.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=m.IDLE},c.resetStartWhenNotLoaded=function(y){if(!this.loadedmetadata){this.startFragRequested=!1;var k=this.levels?this.levels[y].details:null;k!=null&&k.live?(this.startPosition=-1,this.setStartPosition(k,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},c.updateLevelTiming=function(y,k,M,O){var U=this,F=M.details;console.assert(!!F,"level.details must be defined");var H=Object.keys(y.elementaryStreams).reduce(function(Y,Q){var z=y.elementaryStreams[Q];if(z){var ee=z.endPTS-z.startPTS;if(ee<=0)return U.warn("Could not parse fragment "+y.sn+" "+Q+" duration reliably ("+ee+")"),Y||!1;var J=O?0:(0,x.updateFragPTSDTS)(F,y,z.startPTS,z.endPTS,z.startDTS,z.endDTS);return U.hls.trigger(I.Events.LEVEL_PTS_UPDATED,{details:F,level:M,drift:J,type:Q,frag:y,start:z.startPTS,end:z.endPTS}),!0}return Y},!1);H||(this.warn("Found no media in fragment "+y.sn+" of level "+M.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=m.PARSED,this.hls.trigger(I.Events.FRAG_PARSED,{frag:y,part:k})},c.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},s(e,[{key:"state",get:function(){return this._state},set:function(y){var k=this._state;k!==y&&(this._state=y,this.log(k+"->"+y))}}]),e}(P.default)},"./src/controller/buffer-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>g});var W=w("./src/polyfills/number.ts"),P=w("./src/events.ts"),N=w("./src/utils/logger.ts"),D=w("./src/errors.ts"),G=w("./src/utils/buffer-helper.ts"),I=w("./src/utils/mediasource-helper.ts"),R=w("./src/loader/fragment.ts"),L=w("./src/controller/buffer-operation-queue.ts"),_=(0,I.getMediaSource)(),T=/([ha]vc.)(?:\.[^.,]+)+/,g=function(){function x(f){var u=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var h=u.media,o=u.mediaSource;N.logger.log("[buffer-controller]: Media source opened"),h&&(h.removeEventListener("emptied",u._onMediaEmptied),u.updateMediaElementDuration(),u.hls.trigger(P.Events.MEDIA_ATTACHED,{media:h})),o&&o.removeEventListener("sourceopen",u._onMediaSourceOpen),u.checkPendingTracks()},this._onMediaSourceClose=function(){N.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){N.logger.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var h=u.media,o=u._objectUrl;h&&h.src!==o&&N.logger.error("Media element src was set while attaching MediaSource ("+o+" > "+h.src+")")},this.hls=f,this._initSourceBuffer(),this.registerListeners()}var b=x.prototype;return b.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},b.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},b.registerListeners=function(){var u=this.hls;u.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),u.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(P.Events.BUFFER_RESET,this.onBufferReset,this),u.on(P.Events.BUFFER_APPENDING,this.onBufferAppending,this),u.on(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),u.on(P.Events.BUFFER_EOS,this.onBufferEos,this),u.on(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),u.on(P.Events.LEVEL_UPDATED,this.onLevelUpdated,this),u.on(P.Events.FRAG_PARSED,this.onFragParsed,this),u.on(P.Events.FRAG_CHANGED,this.onFragChanged,this)},b.unregisterListeners=function(){var u=this.hls;u.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),u.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(P.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(P.Events.BUFFER_RESET,this.onBufferReset,this),u.off(P.Events.BUFFER_APPENDING,this.onBufferAppending,this),u.off(P.Events.BUFFER_CODECS,this.onBufferCodecs,this),u.off(P.Events.BUFFER_EOS,this.onBufferEos,this),u.off(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),u.off(P.Events.LEVEL_UPDATED,this.onLevelUpdated,this),u.off(P.Events.FRAG_PARSED,this.onFragParsed,this),u.off(P.Events.FRAG_CHANGED,this.onFragChanged,this)},b._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new L.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},b.onManifestParsed=function(u,h){var o=2;(h.audio&&!h.video||!h.altAudio)&&(o=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=o,this.details=null,N.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},b.onMediaAttaching=function(u,h){var o=this.media=h.media;if(o&&_){var s=this.mediaSource=new _;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),o.src=self.URL.createObjectURL(s),this._objectUrl=o.src,o.addEventListener("emptied",this._onMediaEmptied)}},b.onMediaDetaching=function(){var u=this.media,h=this.mediaSource,o=this._objectUrl;if(h){if(N.logger.log("[buffer-controller]: media source detaching"),h.readyState==="open")try{h.endOfStream()}catch(s){N.logger.warn("[buffer-controller]: onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),h.removeEventListener("sourceopen",this._onMediaSourceOpen),h.removeEventListener("sourceended",this._onMediaSourceEnded),h.removeEventListener("sourceclose",this._onMediaSourceClose),u&&(u.removeEventListener("emptied",this._onMediaEmptied),o&&self.URL.revokeObjectURL(o),u.src===o?(u.removeAttribute("src"),u.load()):N.logger.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(P.Events.MEDIA_DETACHED,void 0)},b.onBufferReset=function(){var u=this;this.getSourceBufferTypes().forEach(function(h){var o=u.sourceBuffer[h];try{o&&(u.removeBufferListeners(h),u.mediaSource&&u.mediaSource.removeSourceBuffer(o),u.sourceBuffer[h]=void 0)}catch(s){N.logger.warn("[buffer-controller]: Failed to reset the "+h+" buffer",s)}}),this._initSourceBuffer()},b.onBufferCodecs=function(u,h){var o=this,s=this.getSourceBufferTypes().length;if(Object.keys(h).forEach(function(l){if(s){var n=o.tracks[l];if(n&&typeof n.buffer.changeType=="function"){var d=h[l],v=d.id,p=d.codec,m=d.levelCodec,r=d.container,a=d.metadata,e=(n.levelCodec||n.codec).replace(T,"$1"),c=(m||p).replace(T,"$1");if(e!==c){var E=r+";codecs="+(m||p);o.appendChangeType(l,E),N.logger.log("[buffer-controller]: switching codec "+e+" to "+c),o.tracks[l]={buffer:n.buffer,codec:p,container:r,levelCodec:m,metadata:a,id:v}}}}else o.pendingTracks[l]=h[l]}),s)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},b.appendChangeType=function(u,h){var o=this,s=this.operationQueue,l={execute:function(){var d=o.sourceBuffer[u];d&&(N.logger.log("[buffer-controller]: changing "+u+" sourceBuffer type to "+h),d.changeType(h)),s.shiftAndExecuteNext(u)},onStart:function(){},onComplete:function(){},onError:function(d){N.logger.warn("[buffer-controller]: Failed to change "+u+" SourceBuffer type",d)}};s.append(l,u)},b.onBufferAppending=function(u,h){var o=this,s=this.hls,l=this.operationQueue,n=this.tracks,d=h.data,v=h.type,p=h.frag,m=h.part,r=h.chunkMeta,a=r.buffering[v],e=self.performance.now();a.start=e;var c=p.stats.buffering,E=m?m.stats.buffering:null;c.start===0&&(c.start=e),E&&E.start===0&&(E.start=e);var y=n.audio,k=!1;v==="audio"&&(y==null?void 0:y.container)==="audio/mpeg"&&(k=!this.lastMpegAudioChunk||r.id===1||this.lastMpegAudioChunk.sn!==r.sn,this.lastMpegAudioChunk=r);var M=p.start,O={execute:function(){if(a.executeStart=self.performance.now(),k){var F=o.sourceBuffer[v];if(F){var H=M-F.timestampOffset;Math.abs(H)>=.1&&(N.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+M+" (delta: "+H+") sn: "+p.sn+")"),F.timestampOffset=M)}}o.appendExecutor(d,v)},onStart:function(){},onComplete:function(){var F=self.performance.now();a.executeEnd=a.end=F,c.first===0&&(c.first=F),E&&E.first===0&&(E.first=F);var H=o.sourceBuffer,Y={};for(var Q in H)Y[Q]=G.BufferHelper.getBuffered(H[Q]);o.appendError=0,o.hls.trigger(P.Events.BUFFER_APPENDED,{type:v,frag:p,part:m,chunkMeta:r,parent:p.type,timeRanges:Y})},onError:function(F){N.logger.error("[buffer-controller]: Error encountered while trying to append to the "+v+" SourceBuffer",F);var H={type:D.ErrorTypes.MEDIA_ERROR,parent:p.type,details:D.ErrorDetails.BUFFER_APPEND_ERROR,err:F,fatal:!1};F.code===DOMException.QUOTA_EXCEEDED_ERR?H.details=D.ErrorDetails.BUFFER_FULL_ERROR:(o.appendError++,H.details=D.ErrorDetails.BUFFER_APPEND_ERROR,o.appendError>s.config.appendErrorMaxRetry&&(N.logger.error("[buffer-controller]: Failed "+s.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),H.fatal=!0,s.stopLoad())),s.trigger(P.Events.ERROR,H)}};l.append(O,v)},b.onBufferFlushing=function(u,h){var o=this,s=this.operationQueue,l=function(d){return{execute:o.removeExecutor.bind(o,d,h.startOffset,h.endOffset),onStart:function(){},onComplete:function(){o.hls.trigger(P.Events.BUFFER_FLUSHED,{type:d})},onError:function(p){N.logger.warn("[buffer-controller]: Failed to remove from "+d+" SourceBuffer",p)}}};h.type?s.append(l(h.type),h.type):this.getSourceBufferTypes().forEach(function(n){s.append(l(n),n)})},b.onFragParsed=function(u,h){var o=this,s=h.frag,l=h.part,n=[],d=l?l.elementaryStreams:s.elementaryStreams;d[R.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(d[R.ElementaryStreamTypes.AUDIO]&&n.push("audio"),d[R.ElementaryStreamTypes.VIDEO]&&n.push("video"));var v=function(){var m=self.performance.now();s.stats.buffering.end=m,l&&(l.stats.buffering.end=m);var r=l?l.stats:s.stats;o.hls.trigger(P.Events.FRAG_BUFFERED,{frag:s,part:l,stats:r,id:s.type})};n.length===0&&N.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(v,n)},b.onFragChanged=function(u,h){this.flushBackBuffer()},b.onBufferEos=function(u,h){var o=this,s=this.getSourceBufferTypes().reduce(function(l,n){var d=o.sourceBuffer[n];return d&&(!h.type||h.type===n)&&(d.ending=!0,d.ended||(d.ended=!0,N.logger.log("[buffer-controller]: "+n+" sourceBuffer now EOS"))),l&&!!(!d||d.ended)},!0);s&&(N.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){o.getSourceBufferTypes().forEach(function(n){var d=o.sourceBuffer[n];d&&(d.ending=!1)});var l=o.mediaSource;if(!l||l.readyState!=="open"){l&&N.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+l.readyState);return}N.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),l.endOfStream()}))},b.onLevelUpdated=function(u,h){var o=h.details;if(!o.fragments.length)return;this.details=o,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},b.flushBackBuffer=function(){var u=this.hls,h=this.details,o=this.media,s=this.sourceBuffer;if(!o||h===null)return;var l=this.getSourceBufferTypes();if(!l.length)return;var n=h.live&&u.config.liveBackBufferLength!==null?u.config.liveBackBufferLength:u.config.backBufferLength;if(!(0,W.isFiniteNumber)(n)||n<0)return;var d=o.currentTime,v=h.levelTargetDuration,p=Math.max(n,v),m=Math.floor(d/v)*v-p;l.forEach(function(r){var a=s[r];if(a){var e=G.BufferHelper.getBuffered(a);if(e.length>0&&m>e.start(0)){if(u.trigger(P.Events.BACK_BUFFER_REACHED,{bufferEnd:m}),h.live)u.trigger(P.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:m});else if(a.ended&&e.end(e.length-1)-d<v*2){N.logger.info("[buffer-controller]: Cannot flush "+r+" back buffer while SourceBuffer is in ended state");return}u.trigger(P.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:m,type:r})}}})},b.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var u=this.details,h=this.hls,o=this.media,s=this.mediaSource,l=u.fragments[0].start+u.totalduration,n=o.duration,d=(0,W.isFiniteNumber)(s.duration)?s.duration:0;u.live&&h.config.liveDurationInfinity?(N.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=Infinity,this.updateSeekableRange(u)):(l>d&&l>n||!(0,W.isFiniteNumber)(n))&&(N.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),s.duration=l)},b.updateSeekableRange=function(u){var h=this.mediaSource,o=u.fragments,s=o.length;if(s&&u.live&&h!==null&&h!==void 0&&h.setLiveSeekableRange){var l=Math.max(0,o[0].start),n=Math.max(l,l+u.totalduration);h.setLiveSeekableRange(l,n)}},b.checkPendingTracks=function(){var u=this.bufferCodecEventsExpected,h=this.operationQueue,o=this.pendingTracks,s=Object.keys(o).length;if(s&&!u||s===2){this.createSourceBuffers(o),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0){this.hls.trigger(P.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}l.forEach(function(n){h.executeNext(n)})}},b.createSourceBuffers=function(u){var h=this.sourceBuffer,o=this.mediaSource;if(!o)throw Error("createSourceBuffers called when mediaSource was null");var s=0;for(var l in u)if(!h[l]){var n=u[l];if(!n)throw Error("source buffer exists for track "+l+", however track does not");var d=n.levelCodec||n.codec,v=n.container+";codecs="+d;N.logger.log("[buffer-controller]: creating sourceBuffer("+v+")");try{var p=h[l]=o.addSourceBuffer(v),m=l;this.addBufferListener(m,"updatestart",this._onSBUpdateStart),this.addBufferListener(m,"updateend",this._onSBUpdateEnd),this.addBufferListener(m,"error",this._onSBUpdateError),this.tracks[l]={buffer:p,codec:d,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id},s++}catch(r){N.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+r.message),this.hls.trigger(P.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:r,mimeType:v})}}s&&this.hls.trigger(P.Events.BUFFER_CREATED,{tracks:this.tracks})},b._onSBUpdateStart=function(u){var h=this.operationQueue,o=h.current(u);o.onStart()},b._onSBUpdateEnd=function(u){var h=this.operationQueue,o=h.current(u);o.onComplete(),h.shiftAndExecuteNext(u)},b._onSBUpdateError=function(u,h){N.logger.error("[buffer-controller]: "+u+" SourceBuffer error",h),this.hls.trigger(P.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var o=this.operationQueue.current(u);o&&o.onError(h)},b.removeExecutor=function(u,h,o){var s=this.media,l=this.mediaSource,n=this.operationQueue,d=this.sourceBuffer,v=d[u];if(!s||!l||!v){N.logger.warn("[buffer-controller]: Attempting to remove from the "+u+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(u);return}var p=(0,W.isFiniteNumber)(s.duration)?s.duration:Infinity,m=(0,W.isFiniteNumber)(l.duration)?l.duration:Infinity,r=Math.max(0,h),a=Math.min(o,p,m);a>r&&!v.ending?(v.ended=!1,N.logger.log("[buffer-controller]: Removing ["+r+","+a+"] from the "+u+" SourceBuffer"),console.assert(!v.updating,u+" sourceBuffer must not be updating"),v.remove(r,a)):n.shiftAndExecuteNext(u)},b.appendExecutor=function(u,h){var o=this.operationQueue,s=this.sourceBuffer,l=s[h];if(!l){N.logger.warn("[buffer-controller]: Attempting to append to the "+h+" SourceBuffer, but it does not exist"),o.shiftAndExecuteNext(h);return}l.ended=!1,console.assert(!l.updating,h+" sourceBuffer must not be updating"),l.appendBuffer(u)},b.blockBuffers=function(u,h){var o=this;if(h===void 0&&(h=this.getSourceBufferTypes()),!h.length){N.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(u);return}var s=this.operationQueue,l=h.map(function(n){return s.appendBlocker(n)});Promise.all(l).then(function(){u(),h.forEach(function(n){var d=o.sourceBuffer[n];(!d||!d.updating)&&s.shiftAndExecuteNext(n)})})},b.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},b.addBufferListener=function(u,h,o){var s=this.sourceBuffer[u];if(!s)return;var l=o.bind(this,u);this.listeners[u].push({event:h,listener:l}),s.addEventListener(h,l)},b.removeBufferListeners=function(u){var h=this.sourceBuffer[u];if(!h)return;this.listeners[u].forEach(function(o){h.removeEventListener(o.event,o.listener)})},x}()},"./src/controller/buffer-operation-queue.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>P});var W=w("./src/utils/logger.ts"),P=function(){function N(G){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=G}var D=N.prototype;return D.append=function(I,R){var L=this.queues[R];L.push(I),L.length===1&&this.buffers[R]&&this.executeNext(R)},D.insertAbort=function(I,R){var L=this.queues[R];L.unshift(I),this.executeNext(R)},D.appendBlocker=function(I){var R,L=new Promise(function(T){R=T}),_={execute:R,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(_,I),L},D.executeNext=function(I){var R=this.buffers,L=this.queues,_=R[I],T=L[I];if(T.length){var g=T[0];try{g.execute()}catch(x){W.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),g.onError(x),(!_||!_.updating)&&(T.shift(),this.executeNext(I))}}},D.shiftAndExecuteNext=function(I){this.queues[I].shift(),this.executeNext(I)},D.current=function(I){return this.queues[I][0]},N}()},"./src/controller/cap-level-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>R});var W=w("./src/events.ts");function P(L,_){for(var T=0;T<_.length;T++){var g=_[T];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(L,D(g.key),g)}}function N(L,_,T){return _&&P(L.prototype,_),T&&P(L,T),Object.defineProperty(L,"prototype",{writable:!1}),L}function D(L){var _=G(L,"string");return typeof _=="symbol"?_:String(_)}function G(L,_){if(typeof L!="object"||L===null)return L;var T=L[Symbol.toPrimitive];if(T!==void 0){var g=T.call(L,_||"default");if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(L)}var I=function(){function L(T){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=T,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var _=L.prototype;return _.setStreamController=function(g){this.streamController=g},_.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},_.registerListeners=function(){var g=this.hls;g.on(W.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.on(W.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(W.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.on(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},_.unregisterListener=function(){var g=this.hls;g.off(W.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.off(W.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(W.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.off(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},_.onFpsDropLevelCapping=function(g,x){L.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},_.onMediaAttaching=function(g,x){this.media=x.media instanceof HTMLVideoElement?x.media:null,this.clientRect=null},_.onManifestParsed=function(g,x){var b=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,b.config.capLevelToPlayerSize&&x.video&&this.startCapping()},_.onBufferCodecs=function(g,x){var b=this.hls;b.config.capLevelToPlayerSize&&x.video&&this.startCapping()},_.onMediaDetaching=function(){this.stopCapping()},_.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(g.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},_.getMaxLevel=function(g){var x=this,b=this.hls.levels;if(!b.length)return-1;var f=b.filter(function(u,h){return L.isLevelAllowed(h,x.restrictedLevels)&&h<=g});return this.clientRect=null,L.getMaxLevelByMediaSize(f,this.mediaWidth,this.mediaHeight)},_.startCapping=function(){if(this.timer)return;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()},_.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},_.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,x={width:0,height:0};if(g){var b=g.getBoundingClientRect();x.width=b.width,x.height=b.height,!x.width&&!x.height&&(x.width=b.right-b.left||g.width||0,x.height=b.bottom-b.top||g.height||0)}return this.clientRect=x,x},L.isLevelAllowed=function(g,x){return x===void 0&&(x=[]),x.indexOf(g)===-1},L.getMaxLevelByMediaSize=function(g,x,b){if(!g||!g.length)return-1;for(var f=function(l,n){return n?l.width!==n.width||l.height!==n.height:!0},u=g.length-1,h=0;h<g.length;h+=1){var o=g[h];if((o.width>=x||o.height>=b)&&f(o,g[h+1])){u=h;break}}return u},N(L,[{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 g=1;if(!this.hls.config.ignoreDevicePixelRatio)try{g=self.devicePixelRatio}catch(x){}return g}}]),L}();const R=I},"./src/controller/cmcd-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>b});var W=w("./src/events.ts"),P=w("./src/types/cmcd.ts"),N=w("./src/utils/buffer-helper.ts"),D=w("./src/utils/logger.ts");function G(f,u){for(var h=0;h<u.length;h++){var o=u[h];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(f,R(o.key),o)}}function I(f,u,h){return u&&G(f.prototype,u),h&&G(f,h),Object.defineProperty(f,"prototype",{writable:!1}),f}function R(f){var u=L(f,"string");return typeof u=="symbol"?u:String(u)}function L(f,u){if(typeof f!="object"||f===null)return f;var h=f[Symbol.toPrimitive];if(h!==void 0){var o=h.call(f,u||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(f)}function _(f,u){var h=typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(h)return(h=h.call(f)).next.bind(h);if(Array.isArray(f)||(h=T(f))||u&&f&&typeof f.length=="number"){h&&(f=h);var o=0;return function(){return o>=f.length?{done:!0}:{done:!1,value:f[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function T(f,u){if(!f)return;if(typeof f=="string")return g(f,u);var h=Object.prototype.toString.call(f).slice(8,-1);if(h==="Object"&&f.constructor&&(h=f.constructor.name),h==="Map"||h==="Set")return Array.from(f);if(h==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(h))return g(f,u)}function g(f,u){(u==null||u>f.length)&&(u=f.length);for(var h=0,o=new Array(u);h<u;h++)o[h]=f[h];return o}function x(){return x=Object.assign?Object.assign.bind():function(f){for(var u=1;u<arguments.length;u++){var h=arguments[u];for(var o in h)Object.prototype.hasOwnProperty.call(h,o)&&(f[o]=h[o])}return f},x.apply(this,arguments)}var b=function(){function f(h){var o=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(){o.initialized&&(o.starved=!0),o.buffering=!0},this.onPlaying=function(){o.initialized||(o.initialized=!0),o.buffering=!1},this.applyPlaylistData=function(n){try{o.apply(n,{ot:P.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(d){D.logger.warn("Could not generate manifest CMCD data.",d)}},this.applyFragmentData=function(n){try{var d=n.frag,v=o.hls.levels[d.level],p=o.getObjectType(d),m={d:d.duration*1e3,ot:p};(p===P.CMCDObjectType.VIDEO||p===P.CMCDObjectType.AUDIO||p==P.CMCDObjectType.MUXED)&&(m.br=v.bitrate/1e3,m.tb=o.getTopBandwidth(p)/1e3,m.bl=o.getBufferLength(p)),o.apply(n,m)}catch(r){D.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=h;var s=this.config=h.config,l=s.cmcd;l!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=l.sessionId||f.uuid(),this.cid=l.contentId,this.useHeaders=l.useHeaders===!0,this.registerListeners())}var u=f.prototype;return u.registerListeners=function(){var o=this.hls;o.on(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(W.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on(W.Events.BUFFER_CREATED,this.onBufferCreated,this)},u.unregisterListeners=function(){var o=this.hls;o.off(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(W.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off(W.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},u.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},u.onMediaAttached=function(o,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},u.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},u.onBufferCreated=function(o,s){var l,n;this.audioBuffer=(l=s.tracks.audio)===null||l===void 0?void 0:l.buffer,this.videoBuffer=(n=s.tracks.video)===null||n===void 0?void 0:n.buffer},u.createData=function(){var o;return{v:P.CMCDVersion,sf:P.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(o=this.media)===null||o===void 0?void 0:o.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},u.apply=function(o,s){s===void 0&&(s={}),x(s,this.createData());var l=s.ot===P.CMCDObjectType.INIT||s.ot===P.CMCDObjectType.VIDEO||s.ot===P.CMCDObjectType.MUXED;if(this.starved&&l&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var n=f.toHeaders(s);if(!Object.keys(n).length)return;o.headers||(o.headers={}),x(o.headers,n)}else{var d=f.toQuery(s);if(!d)return;o.url=f.appendQueryToUri(o.url,d)}},u.getObjectType=function(o){var s=o.type;return s==="subtitle"?P.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?P.CMCDObjectType.INIT:s==="audio"?P.CMCDObjectType.AUDIO:s==="main"?this.hls.audioTracks.length?P.CMCDObjectType.VIDEO:P.CMCDObjectType.MUXED:void 0},u.getTopBandwidth=function(o){var s=0,l,n=this.hls;if(o===P.CMCDObjectType.AUDIO)l=n.audioTracks;else{var d=n.maxAutoLevel,v=d>-1?d+1:n.levels.length;l=n.levels.slice(0,v)}for(var p=_(l),m;!(m=p()).done;){var r=m.value;r.bitrate>s&&(s=r.bitrate)}return s>0?s:NaN},u.getBufferLength=function(o){var s=this.hls.media,l=o===P.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!l||!s)return NaN;var n=N.BufferHelper.bufferInfo(l,s.currentTime,this.config.maxBufferHole);return n.len*1e3},u.createPlaylistLoader=function(){var o=this.config.pLoader,s=this.applyPlaylistData,l=o||this.config.loader;return function(){function n(v){this.loader=void 0,this.loader=new l(v)}var d=n.prototype;return d.destroy=function(){this.loader.destroy()},d.abort=function(){this.loader.abort()},d.load=function(p,m,r){s(p),this.loader.load(p,m,r)},I(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},u.createFragmentLoader=function(){var o=this.config.fLoader,s=this.applyFragmentData,l=o||this.config.loader;return function(){function n(v){this.loader=void 0,this.loader=new l(v)}var d=n.prototype;return d.destroy=function(){this.loader.destroy()},d.abort=function(){this.loader.abort()},d.load=function(p,m,r){s(p),this.loader.load(p,m,r)},I(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},f.uuid=function(){var o=URL.createObjectURL(new Blob),s=o.toString();return URL.revokeObjectURL(o),s.slice(s.lastIndexOf("/")+1)},f.serialize=function(o){for(var s=[],l=function(O){return!Number.isNaN(O)&&O!=null&&O!==""&&O!==!1},n=function(O){return Math.round(O)},d=function(O){return n(O/100)*100},v=function(O){return encodeURIComponent(O)},p={br:n,d:n,bl:d,dl:d,mtp:d,nor:v,rtp:d,tb:n},m=Object.keys(o||{}).sort(),r=_(m),a;!(a=r()).done;){var e=a.value,c=o[e];if(!l(c))continue;if(e==="v"&&c===1)continue;if(e=="pr"&&c===1)continue;var E=p[e];E&&(c=E(c));var y=typeof c,k=void 0;e==="ot"||e==="sf"||e==="st"?k=e+"="+c:y==="boolean"?k=e:y==="number"?k=e+"="+c:k=e+"="+JSON.stringify(c),s.push(k)}return s.join(",")},f.toHeaders=function(o){for(var s=Object.keys(o),l={},n=["Object","Request","Session","Status"],d=[{},{},{},{}],v={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},p=0,m=s;p<m.length;p++){var r=m[p],a=v[r]!=null?v[r]:1;d[a][r]=o[r]}for(var e=0;e<d.length;e++){var c=f.serialize(d[e]);c&&(l["CMCD-"+n[e]]=c)}return l},f.toQuery=function(o){return"CMCD="+encodeURIComponent(f.serialize(o))},f.appendQueryToUri=function(o,s){if(!s)return o;var l=o.includes("?")?"&":"?";return""+o+l+s},f}()},"./src/controller/eme-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>p});var W=w("./src/events.ts"),P=w("./src/errors.ts"),N=w("./src/utils/logger.ts"),D=w("./src/utils/mediakeys-helper.ts"),G=w("./src/utils/keysystem-util.ts"),I=w("./src/utils/numeric-encoding-utils.ts"),R=w("./src/loader/level-key.ts"),L=w("./src/utils/hex.ts"),_=w("./src/utils/mp4-tools.ts"),T=w("./node_modules/eventemitter3/index.js"),g=w.n(T);function x(m,r){m.prototype=Object.create(r.prototype),m.prototype.constructor=m,o(m,r)}function b(m){var r=typeof Map=="function"?new Map:void 0;return b=function(e){if(e===null||!h(e))return e;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(typeof r!="undefined"){if(r.has(e))return r.get(e);r.set(e,c)}function c(){return f(e,arguments,s(this).constructor)}return c.prototype=Object.create(e.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),o(c,e)},b(m)}function f(m,r,a){return u()?f=Reflect.construct.bind():f=function(c,E,y){var k=[null];k.push.apply(k,E);var M=Function.bind.apply(c,k),O=new M;return y&&o(O,y.prototype),O},f.apply(null,arguments)}function u(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(m){return!1}}function h(m){return Function.toString.call(m).indexOf("[native code]")!==-1}function o(m,r){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,c){return e.__proto__=c,e},o(m,r)}function s(m){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},s(m)}var l=3,n="[eme]",d=function(){function m(a){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=m.CDMCleanupPromise?[m.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=N.logger.debug.bind(N.logger,n),this.log=N.logger.log.bind(N.logger,n),this.warn=N.logger.warn.bind(N.logger,n),this.error=N.logger.error.bind(N.logger,n),this.hls=a,this.config=a.config,this.registerListeners()}var r=m.prototype;return r.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},r.registerListeners=function(){this.hls.on(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(W.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(W.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},r.unregisterListeners=function(){this.hls.off(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(W.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(W.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},r.getLicenseServerUrl=function(e){var c=this.config,E=c.drmSystems,y=c.widevineLicenseUrl,k=E[e];if(k)return k.licenseUrl;if(e===D.KeySystems.WIDEVINE&&y)return y;throw new Error('no license server URL configured for key-system "'+e+'"')},r.getServerCertificateUrl=function(e){var c=this.config.drmSystems,E=c[e];if(E)return E.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},r.attemptKeySystemAccess=function(e){var c=this,E=this.hls.levels,y=function(U,F,H){return!!U&&H.indexOf(U)===F},k=E.map(function(O){return O.audioCodec}).filter(y),M=E.map(function(O){return O.videoCodec}).filter(y);return k.length+M.length===0&&M.push("avc1.42e01e"),new Promise(function(O,U){var F=function H(Y){var Q=Y.shift();c.getMediaKeysPromise(Q,k,M).then(function(z){return O({keySystem:Q,mediaKeys:z})}).catch(function(z){Y.length?H(Y):z instanceof v?U(z):U(new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:z,fatal:!0},z.message))})};F(e)})},r.requestMediaKeySystemAccess=function(e,c){var E=this.config.requestMediaKeySystemAccessFunc;if(!(typeof E=="function")){var y="Configured requestMediaKeySystemAccess is not a function "+E;return D.requestMediaKeySystemAccess===null&&self.location.protocol==="http:"&&(y="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(y))}return E(e,c)},r.getMediaKeysPromise=function(e,c,E){var y=this,k=(0,D.getSupportedMediaKeySystemConfigurations)(e,c,E,this.config.drmSystemOptions),M=this.keySystemAccessPromises[e],O=M==null?void 0:M.keySystemAccess;if(!O){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(k)),O=this.requestMediaKeySystemAccess(e,k);var U=this.keySystemAccessPromises[e]={keySystemAccess:O};return O.catch(function(F){y.log('Failed to obtain access to key-system "'+e+'": '+F)}),O.then(function(F){y.log('Access for key-system "'+F.keySystem+'" obtained');var H=y.fetchServerCertificate(e);return y.log('Create media-keys for "'+e+'"'),U.mediaKeys=F.createMediaKeys().then(function(Y){return y.log('Media-keys created for "'+e+'"'),H.then(function(Q){return Q?y.setMediaKeysServerCertificate(Y,e,Q):Y})}),U.mediaKeys.catch(function(Y){y.error('Failed to create media-keys for "'+e+'"}: '+Y)}),U.mediaKeys})}return O.then(function(){return M.mediaKeys})},r.createMediaKeySessionContext=function(e){var c=e.decryptdata,E=e.keySystem,y=e.mediaKeys;console.assert(!!y,"mediaKeys is defined"),this.log('Creating key-system session "'+E+'" keyId: '+L.default.hexDump(c.keyId||[]));var k=y.createSession(),M={decryptdata:c,keySystem:E,mediaKeys:y,mediaKeysSession:k,keyStatus:"status-pending"};return this.mediaKeySessions.push(M),M},r.renewKeySession=function(e){var c=e.decryptdata;if(c.pssh){var E=this.createMediaKeySessionContext(e),y=this.getKeyIdString(c),k="cenc";this.keyIdToKeySessionPromise[y]=this.generateRequestWithPreferredKeySession(E,k,c.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},r.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return L.default.hexDump(e.keyId)},r.updateKeySession=function(e,c){var E,y=e.mediaKeysSession;return this.log('Updating key-session "'+y.sessionId+'" for keyID '+L.default.hexDump(((E=e.decryptdata)===null||E===void 0?void 0:E.keyId)||[])+`
} (data length: `+(c&&c.byteLength)+")"),y.update(c)},r.selectKeySystemFormat=function(e){var c=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+e.sn+" "+e.type+": "+e.level+") key formats "+c.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(c)),this.keyFormatPromise},r.getKeyFormatPromise=function(e){var c=this;return new Promise(function(E,y){var k=(0,D.getKeySystemsForConfig)(c.config),M=e.map(D.keySystemFormatToKeySystemDomain).filter(function(O){return!!O&&k.indexOf(O)!==-1});return c.getKeySystemSelectionPromise(M).then(function(O){var U=O.keySystem,F=(0,D.keySystemDomainToKeySystemFormat)(U);F?E(F):y(new Error('Unable to find format for key-system "'+U+'"'))}).catch(y)})},r.loadKey=function(e){var c=this,E=e.keyInfo.decryptdata,y=this.getKeyIdString(E),k="(keyId: "+y+' format: "'+E.keyFormat+'" method: '+E.method+" uri: "+E.uri+")";this.log("Starting session for key "+k);var M=this.keyIdToKeySessionPromise[y];return M||(M=this.keyIdToKeySessionPromise[y]=this.getKeySystemForKeyPromise(E).then(function(O){var U=O.keySystem,F=O.mediaKeys;return c.throwIfDestroyed(),c.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+k),c.attemptSetMediaKeys(U,F).then(function(){c.throwIfDestroyed();var H=c.createMediaKeySessionContext({keySystem:U,mediaKeys:F,decryptdata:E}),Y="cenc";return c.generateRequestWithPreferredKeySession(H,Y,E.pssh,"playlist-key")})}),M.catch(function(O){return c.handleError(O)})),M},r.throwIfDestroyed=function(e){if(e===void 0&&(e="Invalid state"),!this.hls)throw new Error("invalid state")},r.handleError=function(e){if(!this.hls)return;this.error(e.message),e instanceof v?this.hls.trigger(W.Events.ERROR,e.data):this.hls.trigger(W.Events.ERROR,{type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})},r.getKeySystemForKeyPromise=function(e){var c=this.getKeyIdString(e),E=this.keyIdToKeySessionPromise[c];if(!E){var y=(0,D.keySystemFormatToKeySystemDomain)(e.keyFormat),k=y?[y]:(0,D.getKeySystemsForConfig)(this.config);return this.attemptKeySystemAccess(k)}return E},r.getKeySystemSelectionPromise=function(e){if(e.length||(e=(0,D.getKeySystemsForConfig)(this.config)),e.length===0)throw new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},r._onMediaEncrypted=function(e){var c=this,E=e.initDataType,y=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+E+'"'),y===null)return;var k,M;if(E==="sinf"&&this.config.drmSystems[D.KeySystems.FAIRPLAY]){var O=(0,_.bin2str)(new Uint8Array(y));try{var U=(0,I.base64Decode)(JSON.parse(O).sinf),F=(0,_.parseSinf)(new Uint8Array(U));if(!F)return;k=F.subarray(8,24),M=D.KeySystems.FAIRPLAY}catch(le){this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var H=(0,_.parsePssh)(y);if(H===null)return;H.version===0&&H.systemId===D.KeySystemIds.WIDEVINE&&H.data&&(k=H.data.subarray(8,24)),M=(0,D.keySystemIdToKeySystemDomain)(H.systemId)}if(!M||!k)return;for(var Y=L.default.hexDump(k),Q=this.keyIdToKeySessionPromise,z=this.mediaKeySessions,ee=Q[Y],J=function(me){var Ae=z[me],ge=Ae.decryptdata;if(ge.pssh||!ge.keyId)return"continue";var ae=L.default.hexDump(ge.keyId);if(Y===ae||ge.uri.replace(/-/g,"").indexOf(Y)!==-1)return ee=Q[ae],delete Q[ae],ge.pssh=new Uint8Array(y),ge.keyId=k,ee=Q[Y]=ee.then(function(){return c.generateRequestWithPreferredKeySession(Ae,E,y,"encrypted-event-key-match")}),"break"},X=0;X<z.length;X++){var oe=J(X);if(oe==="continue")continue;if(oe==="break")break}ee||(ee=Q[Y]=this.getKeySystemSelectionPromise([M]).then(function(le){var me,Ae=le.keySystem,ge=le.mediaKeys;c.throwIfDestroyed();var ae=new R.LevelKey("ISO-23001-7",Y,(me=(0,D.keySystemDomainToKeySystemFormat)(Ae))!=null?me:"");return ae.pssh=new Uint8Array(y),ae.keyId=k,c.attemptSetMediaKeys(Ae,ge).then(function(){c.throwIfDestroyed();var ue=c.createMediaKeySessionContext({decryptdata:ae,keySystem:Ae,mediaKeys:ge});return c.generateRequestWithPreferredKeySession(ue,E,y,"encrypted-event-no-match")})})),ee.catch(function(le){return c.handleError(le)})},r._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},r.attemptSetMediaKeys=function(e,c){var E=this,y=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var k=Promise.all(y).then(function(){if(!E.media)throw new Error("Attempted to set mediaKeys without media element attached");return E.media.setMediaKeys(c)});return this.setMediaKeysQueue.push(k),k.then(function(){E.log('Media-keys set for "'+e+'"'),y.push(k),E.setMediaKeysQueue=E.setMediaKeysQueue.filter(function(M){return y.indexOf(M)===-1})})},r.generateRequestWithPreferredKeySession=function(e,c,E,y){var k,M,O=this,U=(k=this.config.drmSystems)===null||k===void 0||((M=k[e.keySystem])===null||M===void 0)?void 0:M.generateRequest;if(U)try{var F=U.call(this.hls,c,E,e);if(!F)throw new Error("Invalid response from configured generateRequest filter");c=F.initDataType,E=e.decryptdata.pssh=F.initData?new Uint8Array(F.initData):null}catch(ee){var H;if(this.warn(ee.message),(H=this.hls)!==null&&H!==void 0&&H.config.debug)throw ee}if(E===null)return this.log('Skipping key-session request for "'+y+'" (no initData)'),Promise.resolve(e);var Y=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+y+'": '+Y+" (init data type: "+c+" length: "+(E?E.byteLength:null)+")");var Q=new(g());e.mediaKeysSession.onmessage=function(ee){var J=e.mediaKeysSession;if(!J){Q.emit("error",new Error("invalid state"));return}var X=ee.messageType,oe=ee.message;O.log('"'+X+'" message event for session "'+J.sessionId+'" message size: '+oe.byteLength),X==="license-request"||X==="license-renewal"?O.renewLicense(e,oe).catch(function(le){O.handleError(le),Q.emit("error",le)}):X==="license-release"?e.keySystem===D.KeySystems.FAIRPLAY&&(O.updateKeySession(e,(0,G.strToUtf8array)("acknowledged")),O.removeSession(e)):O.warn('unhandled media key message type "'+X+'"')},e.mediaKeysSession.onkeystatuseschange=function(ee){var J=e.mediaKeysSession;if(!J){Q.emit("error",new Error("invalid state"));return}O.onKeyStatusChange(e);var X=e.keyStatus;Q.emit("keyStatus",X),X==="expired"&&(O.warn(e.keySystem+" expired for key "+Y),O.renewKeySession(e))};var z=new Promise(function(ee,J){Q.on("error",J),Q.on("keyStatus",function(X){X.startsWith("usable")?ee():X==="output-restricted"?J(new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):X==="internal-error"?J(new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+X+'"')):X==="expired"?J(new Error("key expired while generating request")):O.warn('unhandled key status change "'+X+'"')})});return e.mediaKeysSession.generateRequest(c,E).then(function(){var ee;O.log('Request generated for key-session "'+((ee=e.mediaKeysSession)===null||ee===void 0?void 0:ee.sessionId)+'" keyId: '+Y)}).catch(function(ee){throw new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:ee,fatal:!1},"Error generating key-session request: "+ee)}).then(function(){return z}).catch(function(ee){throw Q.removeAllListeners(),O.removeSession(e),ee}).then(function(){return Q.removeAllListeners(),e})},r.onKeyStatusChange=function(e){var c=this;e.mediaKeysSession.keyStatuses.forEach(function(E,y){c.log('key status change "'+E+'" for keyStatuses keyId: '+L.default.hexDump("buffer"in y?new Uint8Array(y.buffer,y.byteOffset,y.byteLength):new Uint8Array(y))+" session keyId: "+L.default.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=E})},r.fetchServerCertificate=function(e){var c=this;return new Promise(function(E,y){var k=c.getServerCertificateUrl(e);if(!k)return E();c.log('Fetching serverCertificate for "'+e+'"');var M=new XMLHttpRequest;M.open("GET",k,!0),M.responseType="arraybuffer",M.onreadystatechange=function(){M.readyState===XMLHttpRequest.DONE&&(M.status===200?E(M.response):y(new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:M},'"'+e+'" certificate request XHR failed ('+k+"). Status: "+M.status+" ("+M.statusText+")")))},M.send()})},r.setMediaKeysServerCertificate=function(e,c,E){var y=this;return new Promise(function(k,M){e.setServerCertificate(E).then(function(O){y.log("setServerCertificate "+(O?"success":"not supported by CDM")+" ("+(E==null?void 0:E.byteLength)+') on "'+c+'"'),k(e)}).catch(function(O){M(new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:O,fatal:!0},O.message))})})},r.renewLicense=function(e,c){var E=this;return this.requestLicense(e,new Uint8Array(c)).then(function(y){return E.updateKeySession(e,new Uint8Array(y)).catch(function(k){throw new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:k,fatal:!0},k.message)})})},r.setupLicenseXHR=function(e,c,E,y){var k=this,M=this.config.licenseXhrSetup;return M?Promise.resolve().then(function(){if(!E.decryptdata)throw new Error("Key removed");return M.call(k.hls,e,c,E,y)}).catch(function(O){if(!E.decryptdata)throw O;return e.open("POST",c,!0),M.call(k.hls,e,c,E,y)}).then(function(O){e.readyState||e.open("POST",c,!0);var U=O||y;return{xhr:e,licenseChallenge:U}}):(e.open("POST",c,!0),Promise.resolve({xhr:e,licenseChallenge:y}))},r.requestLicense=function(e,c){var E=this;return new Promise(function(y,k){var M=E.getLicenseServerUrl(e.keySystem);E.log("Sending license request to URL: "+M);var O=new XMLHttpRequest;O.responseType="arraybuffer",O.onreadystatechange=function(){if(!E.hls||!e.mediaKeysSession)return k(new Error("invalid state"));if(O.readyState===4)if(O.status===200){E._requestLicenseFailureCount=0;var U=O.response;E.log("License received "+(U instanceof ArrayBuffer?U.byteLength:U));var F=E.config.licenseResponseCallback;if(F)try{U=F.call(E.hls,O,M,e)}catch(Y){E.error(Y)}y(U)}else if(E._requestLicenseFailureCount++,E._requestLicenseFailureCount>l||O.status>=400&&O.status<500)k(new v({type:P.ErrorTypes.KEY_SYSTEM_ERROR,details:P.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:O},"License Request XHR failed ("+M+"). Status: "+O.status+" ("+O.statusText+")"));else{var H=l-E._requestLicenseFailureCount+1;E.warn("Retrying license request, "+H+" attempts left"),E.requestLicense(e,c).then(y,k)}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=O,E.setupLicenseXHR(O,M,e,c).then(function(U){var F=U.xhr,H=U.licenseChallenge;F.send(H)})})},r.onMediaAttached=function(e,c){if(!this.config.emeEnabled)return;var E=c.media;this.media=E,E.addEventListener("encrypted",this.onMediaEncrypted),E.addEventListener("waitingforkey",this.onWaitingForKey)},r.onMediaDetached=function(){var e=this,c=this.media,E=this.mediaKeySessions;c&&(c.removeEventListener("encrypted",this.onMediaEncrypted),c.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},R.LevelKey.clearKeyUriToKeyIdMap();var y=E.length;m.CDMCleanupPromise=Promise.all(E.map(function(k){return e.removeSession(k)}).concat(c==null?void 0:c.setMediaKeys(null).catch(function(k){e.log("Could not clear media keys: "+k+". media.src: "+(c==null?void 0:c.src))}))).then(function(){y&&(e.log("finished closing key sessions and clearing media keys"),E.length=0)}).catch(function(k){e.log("Could not close sessions and clear media keys: "+k+". media.src: "+(c==null?void 0:c.src))})},r.onManifestLoaded=function(e,c){var E=c.sessionKeys;if(!E||!this.config.emeEnabled)return;if(!this.keyFormatPromise){var y=E.reduce(function(k,M){return k.indexOf(M.keyFormat)===-1&&k.push(M.keyFormat),k},[]);this.log("Selecting key-system from session-keys "+y.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(y)}},r.removeSession=function(e){var c=this,E=e.mediaKeysSession,y=e.licenseXhr;if(E){this.log("Remove licenses and keys and close session "+E.sessionId),E.onmessage=null,E.onkeystatuseschange=null,y&&y.readyState!==XMLHttpRequest.DONE&&y.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var k=this.mediaKeySessions.indexOf(e);return k>-1&&this.mediaKeySessions.splice(k,1),E.remove().catch(function(M){c.log("Could not remove session: "+M)}).then(function(){return E.close()}).catch(function(M){c.log("Could not close session: "+M)})}},m}();d.CDMCleanupPromise=void 0;var v=function(m){x(r,m);function r(a,e){var c;return c=m.call(this,e)||this,c.data=void 0,c.data=a,a.err=a.error,c}return r}(b(Error));const p=d},"./src/controller/fps-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>D});var W=w("./src/events.ts"),P=w("./src/utils/logger.ts"),N=function(){function G(R){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=R,this.registerListeners()}var I=G.prototype;return I.setStreamController=function(L){this.streamController=L},I.registerListeners=function(){this.hls.on(W.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.unregisterListeners=function(){this.hls.off(W.Events.MEDIA_ATTACHING,this.onMediaAttaching)},I.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},I.onMediaAttaching=function(L,_){var T=this.hls.config;if(T.capLevelOnFPSDrop){var g=_.media instanceof self.HTMLVideoElement?_.media:null;this.media=g,g&&typeof g.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),T.fpsDroppedMonitoringPeriod)}},I.checkFPS=function(L,_,T){var g=performance.now();if(_){if(this.lastTime){var x=g-this.lastTime,b=T-this.lastDroppedFrames,f=_-this.lastDecodedFrames,u=1e3*b/x,h=this.hls;if(h.trigger(W.Events.FPS_DROP,{currentDropped:b,currentDecoded:f,totalDroppedFrames:T}),u>0&&b>h.config.fpsDroppedMonitoringThreshold*f){var o=h.currentLevel;P.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(h.autoLevelCapping===-1||h.autoLevelCapping>=o)&&(o=o-1,h.trigger(W.Events.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:h.currentLevel}),h.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=g,this.lastDroppedFrames=T,this.lastDecodedFrames=_}},I.checkFPSInterval=function(){var L=this.media;if(L)if(this.isVideoPlaybackQualityAvailable){var _=L.getVideoPlaybackQuality();this.checkFPS(L,_.totalVideoFrames,_.droppedVideoFrames)}else this.checkFPS(L,L.webkitDecodedFrameCount,L.webkitDroppedFrameCount)},G}();const D=N},"./src/controller/fragment-finders.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{findFragWithCC:()=>R,findFragmentByPDT:()=>N,findFragmentByPTS:()=>D,fragmentWithinToleranceTest:()=>G,pdtWithinToleranceTest:()=>I});var W=w("./src/polyfills/number.ts"),P=w("./src/utils/binary-search.ts");function N(L,_,T){if(_===null||!Array.isArray(L)||!L.length||!(0,W.isFiniteNumber)(_))return null;var g=L[0].programDateTime;if(_<(g||0))return null;var x=L[L.length-1].endProgramDateTime;if(_>=(x||0))return null;T=T||0;for(var b=0;b<L.length;++b){var f=L[b];if(I(_,T,f))return f}return null}function D(L,_,T,g){T===void 0&&(T=0),g===void 0&&(g=0);var x=null;if(L?x=_[L.sn-_[0].sn+1]||null:T===0&&_[0].start===0&&(x=_[0]),x&&G(T,g,x)===0)return x;var b=P.default.search(_,G.bind(null,T,g));return b&&(b!==L||!x)?b:x}function G(L,_,T){if(L===void 0&&(L=0),_===void 0&&(_=0),T.start<=L&&T.start+T.duration>L)return 0;var g=Math.min(_,T.duration+(T.deltaPTS?T.deltaPTS:0));return T.start+T.duration-g<=L?1:T.start-g>L&&T.start?-1:0}function I(L,_,T){var g=Math.min(_,T.duration+(T.deltaPTS?T.deltaPTS:0))*1e3,x=T.endProgramDateTime||0;return x-g>L}function R(L,_){return P.default.search(L,function(T){return T.cc<_?1:T.cc>_?-1:0})}},"./src/controller/fragment-tracker.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{FragmentState:()=>N,FragmentTracker:()=>D});var W=w("./src/events.ts"),P=w("./src/types/loader.ts"),N;(function(R){R.NOT_LOADED="NOT_LOADED",R.APPENDING="APPENDING",R.PARTIAL="PARTIAL",R.OK="OK"})(N||(N={}));var D=function(){function R(_){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=_,this._registerListeners()}var L=R.prototype;return L._registerListeners=function(){var T=this.hls;T.on(W.Events.BUFFER_APPENDED,this.onBufferAppended,this),T.on(W.Events.FRAG_BUFFERED,this.onFragBuffered,this),T.on(W.Events.FRAG_LOADED,this.onFragLoaded,this)},L._unregisterListeners=function(){var T=this.hls;T.off(W.Events.BUFFER_APPENDED,this.onBufferAppended,this),T.off(W.Events.FRAG_BUFFERED,this.onFragBuffered,this),T.off(W.Events.FRAG_LOADED,this.onFragLoaded,this)},L.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},L.getAppendedFrag=function(T,g){if(g===P.PlaylistLevelType.MAIN){var x=this.activeFragment,b=this.activeParts;if(!x)return null;if(b)for(var f=b.length;f--;){var u=b[f],h=u?u.end:x.appendedPTS;if(u.start<=T&&h!==void 0&&T<=h)return f>9&&(this.activeParts=b.slice(f-9)),u}else if(x.start<=T&&x.appendedPTS!==void 0&&T<=x.appendedPTS)return x}return this.getBufferedFrag(T,g)},L.getBufferedFrag=function(T,g){for(var x=this.fragments,b=Object.keys(x),f=b.length;f--;){var u=x[b[f]];if((u==null?void 0:u.body.type)===g&&u.buffered){var h=u.body;if(h.start<=T&&T<=h.end)return h}}return null},L.detectEvictedFragments=function(T,g,x){var b=this;this.timeRanges&&(this.timeRanges[T]=g),Object.keys(this.fragments).forEach(function(f){var u=b.fragments[f];if(!u)return;if(!u.buffered&&!u.loaded){u.body.type===x&&b.removeFragment(u.body);return}var h=u.range[T];if(!h)return;h.time.some(function(o){var s=!b.isTimeBuffered(o.startPTS,o.endPTS,g);return s&&b.removeFragment(u.body),s})})},L.detectPartialFragments=function(T){var g=this,x=this.timeRanges,b=T.frag,f=T.part;if(!x||b.sn==="initSegment")return;var u=I(b),h=this.fragments[u];if(!h)return;Object.keys(x).forEach(function(o){var s=b.elementaryStreams[o];if(!s)return;var l=x[o],n=f!==null||s.partial===!0;h.range[o]=g.getBufferedTimes(b,f,n,l)}),h.loaded=null,Object.keys(h.range).length?(h.buffered=!0,h.body.endList&&(this.endListFragments[h.body.type]=h)):this.removeFragment(h.body)},L.fragBuffered=function(T){var g=I(T),x=this.fragments[g];x&&(x.loaded=null,x.buffered=!0)},L.getBufferedTimes=function(T,g,x,b){for(var f={time:[],partial:x},u=g?g.start:T.start,h=g?g.end:T.end,o=T.minEndPTS||h,s=T.maxStartPTS||u,l=0;l<b.length;l++){var n=b.start(l)-this.bufferPadding,d=b.end(l)+this.bufferPadding;if(s>=n&&o<=d){f.time.push({startPTS:Math.max(u,b.start(l)),endPTS:Math.min(h,b.end(l))});break}else if(u<d&&h>n)f.partial=!0,f.time.push({startPTS:Math.max(u,b.start(l)),endPTS:Math.min(h,b.end(l))});else if(h<=n)break}return f},L.getPartialFragment=function(T){var g=null,x,b,f,u=0,h=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach(function(s){var l=o[s];if(!l)return;G(l)&&(b=l.body.start-h,f=l.body.end+h,T>=b&&T<=f&&(x=Math.min(T-b,f-T),u<=x&&(g=l.body,u=x)))}),g},L.isEndListAppended=function(T){var g=this.endListFragments[T];return g!==void 0&&(g.buffered||G(g))},L.getState=function(T){var g=I(T),x=this.fragments[g];return x?x.buffered?G(x)?N.PARTIAL:N.OK:N.APPENDING:N.NOT_LOADED},L.isTimeBuffered=function(T,g,x){for(var b,f,u=0;u<x.length;u++){if(b=x.start(u)-this.bufferPadding,f=x.end(u)+this.bufferPadding,T>=b&&g<=f)return!0;if(g<=b)return!1}return!1},L.onFragLoaded=function(T,g){var x=g.frag,b=g.part;if(x.sn==="initSegment"||x.bitrateTest||b)return;var f=I(x);this.fragments[f]={body:x,loaded:g,buffered:!1,range:Object.create(null)}},L.onBufferAppended=function(T,g){var x=this,b=g.frag,f=g.part,u=g.timeRanges;if(b.type===P.PlaylistLevelType.MAIN)if(this.activeFragment!==b&&(this.activeFragment=b,b.appendedPTS=void 0),f){var h=this.activeParts;h||(this.activeParts=h=[]),h.push(f)}else this.activeParts=null;this.timeRanges=u,Object.keys(u).forEach(function(o){var s=u[o];if(x.detectEvictedFragments(o,s),!f&&b.type===P.PlaylistLevelType.MAIN){var l=b.elementaryStreams[o];if(!l)return;for(var n=0;n<s.length;n++){var d=s.end(n);d<=l.endPTS&&d>l.startPTS?b.appendedPTS=Math.max(d,b.appendedPTS||0):b.appendedPTS=l.endPTS}}})},L.onFragBuffered=function(T,g){this.detectPartialFragments(g)},L.hasFragment=function(T){var g=I(T);return!!this.fragments[g]},L.removeFragmentsInRange=function(T,g,x){var b=this;Object.keys(this.fragments).forEach(function(f){var u=b.fragments[f];if(!u)return;if(u.buffered){var h=u.body;h.type===x&&h.start<g&&h.end>T&&b.removeFragment(h)}})},L.removeFragment=function(T){var g=I(T);T.stats.loaded=0,T.clearElementaryStreamInfo(),T.appendedPTS=void 0,delete this.fragments[g],T.endList&&delete this.endListFragments[T.type]},L.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},R}();function G(R){var L,_;return R.buffered&&(((L=R.range.video)===null||L===void 0?void 0:L.partial)||((_=R.range.audio)===null||_===void 0?void 0:_.partial))}function I(R){return R.type+"_"+R.level+"_"+R.urlId+"_"+R.sn}},"./src/controller/gap-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{MAX_START_GAP_JUMP:()=>I,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>R,SKIP_BUFFER_RANGE_START:()=>L,STALL_MINIMUM_DURATION_MS:()=>G,default:()=>_});var W=w("./src/utils/buffer-helper.ts"),P=w("./src/errors.ts"),N=w("./src/events.ts"),D=w("./src/utils/logger.ts"),G=250,I=2,R=.1,L=.05,_=function(){function T(x,b,f,u){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=x,this.media=b,this.fragmentTracker=f,this.hls=u}var g=T.prototype;return g.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},g.poll=function(b,f){var u=this.config,h=this.media,o=this.stalled;if(h===null)return;var s=h.currentTime,l=h.seeking,n=this.seeking&&!l,d=!this.seeking&&l;if(this.seeking=l,s!==b){if(this.moved=!0,o!==null){if(this.stallReported){var v=self.performance.now()-o;D.logger.warn("playback not stuck anymore @"+s+", after "+Math.round(v)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((d||n)&&(this.stalled=null),h.paused&&!l||h.ended||h.playbackRate===0||!W.BufferHelper.getBuffered(h).length)return;var p=W.BufferHelper.bufferInfo(h,s,0),m=p.len>0,r=p.nextStart||0;if(!m&&!r)return;if(l){var a=p.len>I,e=!r||f&&f.start<=s||r-s>I&&!this.fragmentTracker.getPartialFragment(s);if(a||e)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var c,E=Math.max(r,p.start||0)-s,y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,k=y==null||((c=y.details)===null||c===void 0)?void 0:c.live,M=k?y.details.targetduration*2:I;if(E>0&&E<=M){this._trySkipBufferHole(null);return}}var O=self.performance.now();if(o===null){this.stalled=O;return}var U=O-o;if(!l&&U>=G&&(this._reportStall(p),!this.media))return;var F=W.BufferHelper.bufferInfo(h,s,u.maxBufferHole);this._tryFixBufferStall(F,U)},g._tryFixBufferStall=function(b,f){var u=this.config,h=this.fragmentTracker,o=this.media;if(o===null)return;var s=o.currentTime,l=h.getPartialFragment(s);if(l){var n=this._trySkipBufferHole(l);if(n||!this.media)return}b.len>u.maxBufferHole&&f>u.highBufferWatchdogPeriod*1e3&&(D.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},g._reportStall=function(b){var f=this.hls,u=this.media,h=this.stallReported;!h&&u&&(this.stallReported=!0,D.logger.warn("Playback stalling at @"+u.currentTime+" due to low buffer ("+JSON.stringify(b)+")"),f.trigger(N.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:b.len}))},g._trySkipBufferHole=function(b){var f=this.config,u=this.hls,h=this.media;if(h===null)return 0;for(var o=h.currentTime,s=0,l=W.BufferHelper.getBuffered(h),n=0;n<l.length;n++){var d=l.start(n);if(o+f.maxBufferHole>=s&&o<d){var v=Math.max(d+L,h.currentTime+R);return D.logger.warn("skipping hole, adjusting currentTime from "+o+" to "+v),this.moved=!0,this.stalled=null,h.currentTime=v,b&&u.trigger(N.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+o+" to "+v,frag:b}),v}s=l.end(n)}return 0},g._tryNudgeBuffer=function(){var b=this.config,f=this.hls,u=this.media,h=this.nudgeRetry;if(u===null)return;var o=u.currentTime;if(this.nudgeRetry++,h<b.nudgeMaxRetry){var s=o+(h+1)*b.nudgeOffset;D.logger.warn("Nudging 'currentTime' from "+o+" to "+s),u.currentTime=s,f.trigger(N.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else D.logger.error("Playhead still not moving while enough data buffered @"+o+" after "+b.nudgeMaxRetry+" nudges"),f.trigger(N.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},T}()},"./src/controller/id3-track-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>b});var W=w("./src/polyfills/number.ts"),P=w("./src/events.ts"),N=w("./src/utils/texttrack-utils.ts"),D=w("./src/demux/id3.ts"),G=w("./src/loader/date-range.ts"),I=w("./src/types/demuxer.ts"),R=.25;function L(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var _=function(){var f=L();try{new f(0,Number.POSITIVE_INFINITY,"")}catch(u){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function T(f,u){return f.getTime()/1e3-u}function g(f){return Uint8Array.from(f.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var x=function(){function f(h){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=h,this._registerListeners()}var u=f.prototype;return u.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},u._registerListeners=function(){var o=this.hls;o.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(P.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),o.on(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(P.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},u._unregisterListeners=function(){var o=this.hls;o.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(P.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),o.off(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(P.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},u.onMediaAttached=function(o,s){this.media=s.media},u.onMediaDetaching=function(){if(!this.id3Track)return;(0,N.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={}},u.onManifestLoading=function(){this.dateRangeCuesAppended={}},u.createTrack=function(o){var s=this.getID3Track(o.textTracks);return s.mode="hidden",s},u.getID3Track=function(o){if(!this.media)return;for(var s=0;s<o.length;s++){var l=o[s];if(l.kind==="metadata"&&l.label==="id3")return(0,N.sendAddTrackEvent)(l,this.media),l}return this.media.addTextTrack("metadata","id3")},u.onFragParsingMetadata=function(o,s){if(!this.media)return;var l=this.hls.config,n=l.enableEmsgMetadataCues,d=l.enableID3MetadataCues;if(!n&&!d)return;var v=s.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var p=L(),m=0;m<v.length;m++){var r=v[m].type;if(r===I.MetadataSchema.emsg&&!n||!d)continue;var a=D.getID3Frames(v[m].data);if(a){var e=v[m].pts,c=e+v[m].duration;c>_&&(c=_);var E=c-e;E<=0&&(c=e+R);for(var y=0;y<a.length;y++){var k=a[y];if(!D.isTimeStampFrame(k)){this.updateId3CueEnds(e);var M=new p(e,c,"");M.value=k,r&&(M.type=r),this.id3Track.addCue(M)}}}}},u.updateId3CueEnds=function(o){var s,l=(s=this.id3Track)===null||s===void 0?void 0:s.cues;if(l)for(var n=l.length;n--;){var d=l[n];d.startTime<o&&d.endTime===_&&(d.endTime=o)}},u.onBufferFlushing=function(o,s){var l=s.startOffset,n=s.endOffset,d=s.type,v=this.id3Track,p=this.hls;if(!p)return;var m=p.config,r=m.enableEmsgMetadataCues,a=m.enableID3MetadataCues;if(v&&(r||a)){var e;d==="audio"?e=function(E){return E.type===I.MetadataSchema.audioId3&&a}:d==="video"?e=function(E){return E.type===I.MetadataSchema.emsg&&r}:e=function(E){return E.type===I.MetadataSchema.audioId3&&a||E.type===I.MetadataSchema.emsg&&r},(0,N.removeCuesInRange)(v,l,n,e)}},u.onLevelUpdated=function(o,s){var l=this,n=s.details;if(!this.media||!n.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;var d=this.dateRangeCuesAppended,v=this.id3Track,p=n.dateRanges,m=Object.keys(p);if(v)for(var r=Object.keys(d).filter(function(O){return!m.includes(O)}),a=function(U){var F=r[U];Object.keys(d[F].cues).forEach(function(H){v.removeCue(d[F].cues[H])}),delete d[F]},e=r.length;e--;)a(e);var c=n.fragments[n.fragments.length-1];if(m.length===0||!(0,W.isFiniteNumber)(c==null?void 0:c.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var E=c.programDateTime/1e3-c.start,y=L(),k=function(U){var F=m[U],H=p[F],Y=d[F],Q=(Y==null?void 0:Y.cues)||{},z=(Y==null?void 0:Y.durationKnown)||!1,ee=T(H.startDate,E),J=_,X=H.endDate;if(X)J=T(X,E),z=!0;else if(H.endOnNext&&!z){var oe=m.reduce(function(ue,ye){var Ee=p[ye];return Ee.class===H.class&&Ee.id!==ye&&Ee.startDate>H.startDate&&ue.push(Ee),ue},[]).sort(function(ue,ye){return ue.startDate.getTime()-ye.startDate.getTime()})[0];oe&&(J=T(oe.startDate,E),z=!0)}for(var le=Object.keys(H.attr),me=0;me<le.length;me++){var Ae=le[me];if(Ae===G.DateRangeAttribute.ID||Ae===G.DateRangeAttribute.CLASS||Ae===G.DateRangeAttribute.START_DATE||Ae===G.DateRangeAttribute.DURATION||Ae===G.DateRangeAttribute.END_DATE||Ae===G.DateRangeAttribute.END_ON_NEXT)continue;var ge=Q[Ae];if(ge)z&&!Y.durationKnown&&(ge.endTime=J);else{var ae=H.attr[Ae];ge=new y(ee,J,""),(Ae===G.DateRangeAttribute.SCTE35_OUT||Ae===G.DateRangeAttribute.SCTE35_IN)&&(ae=g(ae)),ge.value={key:Ae,data:ae},ge.type=I.MetadataSchema.dateRange,l.id3Track.addCue(ge),Q[Ae]=ge}}d[F]={cues:Q,dateRange:H,durationKnown:z}},M=0;M<m.length;M++)k(M)},f}();const b=x},"./src/controller/latency-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>L});var W=w("./src/errors.ts"),P=w("./src/events.ts"),N=w("./src/utils/logger.ts");function D(_,T){for(var g=0;g<T.length;g++){var x=T[g];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(_,I(x.key),x)}}function G(_,T,g){return T&&D(_.prototype,T),g&&D(_,g),Object.defineProperty(_,"prototype",{writable:!1}),_}function I(_){var T=R(_,"string");return typeof T=="symbol"?T:String(T)}function R(_,T){if(typeof _!="object"||_===null)return _;var g=_[Symbol.toPrimitive];if(g!==void 0){var x=g.call(_,T||"default");if(typeof x!="object")return x;throw new TypeError("@@toPrimitive must return a primitive value.")}return(T==="string"?String:Number)(_)}var L=function(){function _(g){var x=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return x.timeupdate()},this.hls=g,this.config=g.config,this.registerListeners()}var T=_.prototype;return T.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},T.registerListeners=function(){this.hls.on(P.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(P.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(P.Events.ERROR,this.onError,this)},T.unregisterListeners=function(){this.hls.off(P.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(P.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(P.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(P.Events.ERROR,this.onError)},T.onMediaAttached=function(x,b){this.media=b.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},T.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},T.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},T.onLevelUpdated=function(x,b){var f=b.details;this.levelDetails=f,f.advanced&&this.timeupdate(),!f.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},T.onError=function(x,b){if(b.details!==W.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,N.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},T.timeupdate=function(){var x=this.media,b=this.levelDetails;if(!x||!b)return;this.currentTime=x.currentTime;var f=this.computeLatency();if(f===null)return;this._latency=f;var u=this.config,h=u.lowLatencyMode,o=u.maxLiveSyncPlaybackRate;if(!h||o===1)return;var s=this.targetLatency;if(s===null)return;var l=f-s,n=Math.min(this.maxLatency,s+b.targetduration),d=l<n;if(b.live&&d&&l>.05&&this.forwardBufferLength>1){var v=Math.min(2,Math.max(1,o)),p=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;x.playbackRate=Math.min(v,Math.max(1,p))}else x.playbackRate!==1&&x.playbackRate!==0&&(x.playbackRate=1)},T.estimateLiveEdge=function(){var x=this.levelDetails;return x===null?null:x.edge+x.age},T.computeLatency=function(){var x=this.estimateLiveEdge();return x===null?null:x-this.currentTime},G(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var x=this.config,b=this.levelDetails;return x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:b?x.liveMaxLatencyDurationCount*b.targetduration:0}},{key:"targetLatency",get:function(){var x=this.levelDetails;if(x===null)return null;var b=x.holdBack,f=x.partHoldBack,u=x.targetduration,h=this.config,o=h.liveSyncDuration,s=h.liveSyncDurationCount,l=h.lowLatencyMode,n=this.hls.userConfig,d=l&&f||b;(n.liveSyncDuration||n.liveSyncDurationCount||d===0)&&(d=o!==void 0?o:s*u);var v=u,p=1;return d+Math.min(this.stallCount*p,v)}},{key:"liveSyncPosition",get:function(){var x=this.estimateLiveEdge(),b=this.targetLatency,f=this.levelDetails;if(x===null||b===null||f===null)return null;var u=f.edge,h=x-b-this.edgeStalled,o=u-f.totalduration,s=u-(this.config.lowLatencyMode&&f.partTarget||f.targetduration);return Math.min(Math.max(o,h),s)}},{key:"drift",get:function(){var x=this.levelDetails;return x===null?1:x.drift}},{key:"edgeStalled",get:function(){var x=this.levelDetails;if(x===null)return 0;var b=(this.config.lowLatencyMode&&x.partTarget||x.targetduration)*3;return Math.max(x.age-b,0)}},{key:"forwardBufferLength",get:function(){var x=this.media,b=this.levelDetails;if(!x||!b)return 0;var f=x.buffered.length;return(f?x.buffered.end(f-1):b.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>h});var W=w("./src/types/level.ts"),P=w("./src/events.ts"),N=w("./src/errors.ts"),D=w("./src/utils/codecs.ts"),G=w("./src/controller/level-helper.ts"),I=w("./src/controller/base-playlist-controller.ts"),R=w("./src/types/loader.ts");function L(){return L=Object.assign?Object.assign.bind():function(o){for(var s=1;s<arguments.length;s++){var l=arguments[s];for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(o[n]=l[n])}return o},L.apply(this,arguments)}function _(o,s){for(var l=0;l<s.length;l++){var n=s[l];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(o,g(n.key),n)}}function T(o,s,l){return s&&_(o.prototype,s),l&&_(o,l),Object.defineProperty(o,"prototype",{writable:!1}),o}function g(o){var s=x(o,"string");return typeof s=="symbol"?s:String(s)}function x(o,s){if(typeof o!="object"||o===null)return o;var l=o[Symbol.toPrimitive];if(l!==void 0){var n=l.call(o,s||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(o)}function b(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,f(o,s)}function f(o,s){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,d){return n.__proto__=d,n},f(o,s)}var u=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),h=function(o){b(s,o);function s(n){var d;return d=o.call(this,n,"[level-controller]")||this,d._levels=[],d._firstLevel=-1,d._startLevel=void 0,d.currentLevelIndex=-1,d.manualLevelIndex=-1,d.onParsedComplete=void 0,d._registerListeners(),d}var l=s.prototype;return l._registerListeners=function(){var d=this.hls;d.on(P.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(P.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.on(P.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(P.Events.ERROR,this.onError,this)},l._unregisterListeners=function(){var d=this.hls;d.off(P.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(P.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),d.off(P.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(P.Events.ERROR,this.onError,this)},l.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},l.startLoad=function(){var d=this._levels;d.forEach(function(v){v.loadError=0}),o.prototype.startLoad.call(this)},l.onManifestLoaded=function(d,v){var p=[],m=[],r=[],a,e={},c,E=!1,y=!1,k=!1;if(v.levels.forEach(function(F){var H=F.attrs;E=E||!!(F.width&&F.height),y=y||!!F.videoCodec,k=k||!!F.audioCodec,u&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var Y=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;c=e[Y],c?c.url.push(F.url):(c=new W.Level(F),e[Y]=c,p.push(c)),H&&(H.AUDIO&&(0,G.addGroupId)(c,"audio",H.AUDIO),H.SUBTITLES&&(0,G.addGroupId)(c,"text",H.SUBTITLES))}),(E||y)&&k&&(p=p.filter(function(F){var H=F.videoCodec,Y=F.width,Q=F.height;return!!H||!!(Y&&Q)})),p=p.filter(function(F){var H=F.audioCodec,Y=F.videoCodec;return(!H||(0,D.isCodecSupportedInMp4)(H,"audio"))&&(!Y||(0,D.isCodecSupportedInMp4)(Y,"video"))}),v.audioTracks&&(m=v.audioTracks.filter(function(F){return!F.audioCodec||(0,D.isCodecSupportedInMp4)(F.audioCodec,"audio")}),(0,G.assignTrackIdsByGroup)(m)),v.subtitles&&(r=v.subtitles,(0,G.assignTrackIdsByGroup)(r)),p.length>0){a=p[0].bitrate,p.sort(function(F,H){return F.attrs["HDCP-LEVEL"]!==H.attrs["HDCP-LEVEL"]?(F.attrs["HDCP-LEVEL"]||"")>(H.attrs["HDCP-LEVEL"]||"")?1:-1:F.bitrate!==H.bitrate?F.bitrate-H.bitrate:F.attrs.SCORE!==H.attrs.SCORE?F.attrs.decimalFloatingPoint("SCORE")-H.attrs.decimalFloatingPoint("SCORE"):E&&F.height!==H.height?F.height-H.height:0}),this._levels=p;for(var M=0;M<p.length;M++)if(p[M].bitrate===a){this._firstLevel=M,this.log("manifest loaded, "+p.length+" level(s) found, first bitrate: "+a);break}var O=k&&!y,U={levels:p,audioTracks:m,subtitleTracks:r,sessionData:v.sessionData,sessionKeys:v.sessionKeys,firstLevel:this._firstLevel,stats:v.stats,audio:k,video:y,altAudio:!O&&m.some(function(F){return!!F.url})};this.hls.trigger(P.Events.MANIFEST_PARSED,U),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(P.Events.ERROR,{type:N.ErrorTypes.MEDIA_ERROR,details:N.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:v.url,reason:"no level with compatible codecs found in manifest"})},l.onError=function(d,v){var p,m;if(o.prototype.onError.call(this,d,v),v.fatal)return;var r=v.context,a=this._levels[this.currentLevelIndex];if(r&&(r.type===R.PlaylistContextType.AUDIO_TRACK&&a.audioGroupIds&&r.groupId===a.audioGroupIds[a.urlId]||r.type===R.PlaylistContextType.SUBTITLE_TRACK&&a.textGroupIds&&r.groupId===a.textGroupIds[a.urlId])){this.redundantFailover(this.currentLevelIndex);return}var e=!1,c=!0,E;switch(v.details){case N.ErrorDetails.FRAG_LOAD_ERROR:case N.ErrorDetails.FRAG_LOAD_TIMEOUT:case N.ErrorDetails.KEY_LOAD_ERROR:case N.ErrorDetails.KEY_LOAD_TIMEOUT:if(v.frag){var y=v.frag.type===R.PlaylistLevelType.MAIN?v.frag.level:this.currentLevelIndex,k=this._levels[y];k?(k.fragmentError++,k.fragmentError>this.hls.config.fragLoadingMaxRetry&&(E=y)):E=y}break;case N.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var M=a.attrs["HDCP-LEVEL"];M&&(this.hls.maxHdcpLevel=W.HdcpLevels[W.HdcpLevels.indexOf(M)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'))}case N.ErrorDetails.FRAG_PARSING_ERROR:case N.ErrorDetails.KEY_SYSTEM_NO_SESSION:E=((p=v.frag)===null||p===void 0?void 0:p.type)===R.PlaylistLevelType.MAIN?v.frag.level:this.currentLevelIndex,v.levelRetry=!1;break;case N.ErrorDetails.LEVEL_LOAD_ERROR:case N.ErrorDetails.LEVEL_LOAD_TIMEOUT:r&&(r.deliveryDirectives&&(c=!1),E=r.level),e=!0;break;case N.ErrorDetails.REMUX_ALLOC_ERROR:E=(m=v.level)!=null?m:this.currentLevelIndex,e=!0;break}E!==void 0&&this.recoverLevel(v,E,e,c)},l.recoverLevel=function(d,v,p,m){var r=d.details,a=this._levels[v];if(a.loadError++,p){var e=this.retryLoadingOrFail(d);if(e)d.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(m){var c=a.url.length;if(c>1&&a.loadError<c)d.levelRetry=!0,this.redundantFailover(v);else if(this.manualLevelIndex===-1){for(var E=-1,y=this._levels,k=y.length;k--;){var M=(k+this.currentLevelIndex)%y.length;if(M!==this.currentLevelIndex&&y[M].loadError===0){E=M;break}}E>-1&&this.currentLevelIndex!==E?(this.warn(r+": switch to "+E),d.levelRetry=!0,this.hls.nextAutoLevel=E):d.levelRetry===!1&&(d.fatal=!0)}}},l.redundantFailover=function(d){var v=this._levels[d],p=v.url.length;if(p>1){var m=(v.urlId+1)%p;this.warn("Switching to redundant URL-id "+m),this._levels.forEach(function(r){r.urlId=m}),this.level=d}},l.onFragLoaded=function(d,v){var p=v.frag;if(p!==void 0&&p.type===R.PlaylistLevelType.MAIN){var m=this._levels[p.level];m!==void 0&&(m.fragmentError=0,m.loadError=0)}},l.onLevelLoaded=function(d,v){var p,m=v.level,r=v.details,a=this._levels[m];if(!a){var e;this.warn("Invalid level index "+m),(e=v.deliveryDirectives)!==null&&e!==void 0&&e.skip&&(r.deltaUpdateFailed=!0);return}m===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(m,v,a.details)):(p=v.deliveryDirectives)!==null&&p!==void 0&&p.skip&&(r.deltaUpdateFailed=!0)},l.onAudioTrackSwitched=function(d,v){var p=this.hls.levels[this.currentLevelIndex];if(!p)return;if(p.audioGroupIds){for(var m=-1,r=this.hls.audioTracks[v.id].groupId,a=0;a<p.audioGroupIds.length;a++)if(p.audioGroupIds[a]===r){m=a;break}m!==p.urlId&&(p.urlId=m,this.startLoad())}},l.loadPlaylist=function(d){o.prototype.loadPlaylist.call(this);var v=this.currentLevelIndex,p=this._levels[v];if(this.canLoad&&p&&p.url.length>0){var m=p.urlId,r=p.url[m];if(d)try{r=d.addDirectives(r)}catch(a){this.warn("Could not construct new URL with HLS Delivery Directives: "+a)}this.log("Attempt loading level index "+v+((d==null?void 0:d.msn)!==void 0?" at sn "+d.msn+" part "+d.part:"")+" with URL-id "+m+" "+r),this.clearTimer(),this.hls.trigger(P.Events.LEVEL_LOADING,{url:r,level:v,id:m,deliveryDirectives:d||null})}},l.removeLevel=function(d,v){var p=function(a,e){return e!==v},m=this._levels.filter(function(r,a){return a!==d?!0:r.url.length>1&&v!==void 0?(r.url=r.url.filter(p),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(p)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(p)),r.urlId=0,!0):!1}).map(function(r,a){var e=r.details;return e!=null&&e.fragments&&e.fragments.forEach(function(c){c.level=a}),r});this._levels=m,this.hls.trigger(P.Events.LEVELS_UPDATED,{levels:m})},T(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(d){var v,p=this._levels;if(p.length===0)return;if(this.currentLevelIndex===d&&(v=p[d])!==null&&v!==void 0&&v.details)return;if(d<0||d>=p.length){var m=d<0;if(this.hls.trigger(P.Events.ERROR,{type:N.ErrorTypes.OTHER_ERROR,details:N.ErrorDetails.LEVEL_SWITCH_ERROR,level:d,fatal:m,reason:"invalid level idx"}),m)return;d=Math.min(d,p.length-1)}this.clearTimer();var r=this.currentLevelIndex,a=p[r],e=p[d];this.log("switching to level "+d+" from "+r),this.currentLevelIndex=d;var c=L({},e,{level:d,maxBitrate:e.maxBitrate,uri:e.uri,urlId:e.urlId});delete c._urlId,this.hls.trigger(P.Events.LEVEL_SWITCHING,c);var E=e.details;if(!E||E.live){var y=this.switchParams(e.uri,a==null?void 0:a.details);this.loadPlaylist(y)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(d){this.manualLevelIndex=d,this._startLevel===void 0&&(this._startLevel=d),d!==-1&&(this.level=d)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(d){this._firstLevel=d}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var d=this.hls.config.startLevel;return d!==void 0?d:this._firstLevel}else return this._startLevel},set:function(d){this._startLevel=d}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(d){this.level=d,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=d)}}]),s}(I.default)},"./src/controller/level-helper.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{addGroupId:()=>G,addSliding:()=>u,adjustSliding:()=>f,assignTrackIdsByGroup:()=>I,computeReloadInterval:()=>h,getFragmentWithSN:()=>o,getPartWith:()=>s,mapFragmentIntersection:()=>b,mapPartIntersection:()=>x,mergeDetails:()=>T,updateFragPTSDTS:()=>_,updatePTS:()=>R});var W=w("./src/polyfills/number.ts"),P=w("./src/utils/logger.ts"),N=w("./src/loader/date-range.ts");function D(){return D=Object.assign?Object.assign.bind():function(l){for(var n=1;n<arguments.length;n++){var d=arguments[n];for(var v in d)Object.prototype.hasOwnProperty.call(d,v)&&(l[v]=d[v])}return l},D.apply(this,arguments)}function G(l,n,d){switch(n){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(d);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(d);break}}function I(l){var n={};l.forEach(function(d){var v=d.groupId||"";d.id=n[v]=n[v]||0,n[v]++})}function R(l,n,d){var v=l[n],p=l[d];L(v,p)}function L(l,n){var d=n.startPTS;if((0,W.isFiniteNumber)(d)){var v=0,p;n.sn>l.sn?(v=d-l.start,p=l):(v=l.start-d,p=n),p.duration!==v&&(p.duration=v)}else if(n.sn>l.sn){var m=l.cc===n.cc;m&&l.minEndPTS?n.start=l.start+(l.minEndPTS-l.start):n.start=l.start+l.duration}else n.start=Math.max(l.start-n.duration,0)}function _(l,n,d,v,p,m){var r=v-d;r<=0&&(P.logger.warn("Fragment should have a positive duration",n),v=d+n.duration,m=p+n.duration);var a=d,e=v,c=n.startPTS,E=n.endPTS;if((0,W.isFiniteNumber)(c)){var y=Math.abs(c-d);(0,W.isFiniteNumber)(n.deltaPTS)?n.deltaPTS=Math.max(y,n.deltaPTS):n.deltaPTS=y,a=Math.max(d,c),d=Math.min(d,c),p=Math.min(p,n.startDTS),e=Math.min(v,E),v=Math.max(v,E),m=Math.max(m,n.endDTS)}n.duration=v-d;var k=d-n.start;n.start=n.startPTS=d,n.maxStartPTS=a,n.startDTS=p,n.endPTS=v,n.minEndPTS=e,n.endDTS=m;var M=n.sn;if(!l||M<l.startSN||M>l.endSN)return 0;var O,U=M-l.startSN,F=l.fragments;for(F[U]=n,O=U;O>0;O--)L(F[O],F[O-1]);for(O=U;O<F.length-1;O++)L(F[O],F[O+1]);return l.fragmentHint&&L(F[F.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,k}function T(l,n){for(var d=null,v=l.fragments,p=v.length-1;p>=0;p--){var m=v[p].initSegment;if(m){d=m;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var r=0,a;if(b(l,n,function(O,U){O.relurl&&(r=O.cc-U.cc),(0,W.isFiniteNumber)(O.startPTS)&&(0,W.isFiniteNumber)(O.endPTS)&&(U.start=U.startPTS=O.startPTS,U.startDTS=O.startDTS,U.appendedPTS=O.appendedPTS,U.maxStartPTS=O.maxStartPTS,U.endPTS=O.endPTS,U.endDTS=O.endDTS,U.minEndPTS=O.minEndPTS,U.duration=O.endPTS-O.startPTS,U.duration&&(a=U),n.PTSKnown=n.alignedSliding=!0),U.elementaryStreams=O.elementaryStreams,U.loader=O.loader,U.stats=O.stats,U.urlId=O.urlId,O.initSegment&&(U.initSegment=O.initSegment,d=O.initSegment)}),d){var e=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;e.forEach(function(O){var U;(!O.initSegment||O.initSegment.relurl===((U=d)===null||U===void 0?void 0:U.relurl))&&(O.initSegment=d)})}if(n.skippedSegments)if(n.deltaUpdateFailed=n.fragments.some(function(O){return!O}),n.deltaUpdateFailed){P.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var c=n.skippedSegments;c--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}else n.canSkipDateRanges&&(n.dateRanges=g(l.dateRanges,n.dateRanges,n.recentlyRemovedDateranges));var E=n.fragments;if(r){P.logger.warn("discontinuity sliding from playlist, take drift into account");for(var y=0;y<E.length;y++)E[y].cc+=r}n.skippedSegments&&(n.startCC=n.fragments[0].cc),x(l.partList,n.partList,function(O,U){U.elementaryStreams=O.elementaryStreams,U.stats=O.stats}),a?_(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):f(l,n),E.length&&(n.totalduration=n.edge-E[0].start),n.driftStartTime=l.driftStartTime,n.driftStart=l.driftStart;var k=n.advancedDateTime;if(n.advanced&&k){var M=n.edge;n.driftStart||(n.driftStartTime=k,n.driftStart=M),n.driftEndTime=k,n.driftEnd=M}else n.driftEndTime=l.driftEndTime,n.driftEnd=l.driftEnd,n.advancedDateTime=l.advancedDateTime}function g(l,n,d){var v=D({},l);return d&&d.forEach(function(p){delete v[p]}),Object.keys(n).forEach(function(p){var m=new N.DateRange(n[p].attr,v[p]);m.isValid?v[p]=m:P.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(n[p].attr)+'"')}),v}function x(l,n,d){if(l&&n)for(var v=0,p=0,m=l.length;p<=m;p++){var r=l[p],a=n[p+v];r&&a&&r.index===a.index&&r.fragment.sn===a.fragment.sn?d(r,a):v--}}function b(l,n,d){for(var v=n.skippedSegments,p=Math.max(l.startSN,n.startSN)-n.startSN,m=(l.fragmentHint?1:0)+(v?n.endSN:Math.min(l.endSN,n.endSN))-n.startSN,r=n.startSN-l.startSN,a=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,e=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,c=p;c<=m;c++){var E=e[r+c],y=a[c];v&&!y&&c<v&&(y=n.fragments[c]=E),E&&y&&d(E,y)}}function f(l,n){var d=n.startSN+n.skippedSegments-l.startSN,v=l.fragments;if(d<0||d>=v.length)return;u(n,v[d].start)}function u(l,n){if(n){for(var d=l.fragments,v=l.skippedSegments;v<d.length;v++)d[v].start+=n;l.fragmentHint&&(l.fragmentHint.start+=n)}}function h(l,n){n===void 0&&(n=Infinity);var d=1e3*l.targetduration;if(l.updated){var v=l.fragments,p=4;if(v.length&&d*p>n){var m=v[v.length-1].duration*1e3;m<d&&(d=m)}}else d/=2;return Math.round(d)}function o(l,n,d){if(!l||!l.details)return null;var v=l.details,p=v.fragments[n-v.startSN];return p||(p=v.fragmentHint,p&&p.sn===n?p:n<v.startSN&&d&&d.sn===n?d:null)}function s(l,n,d){if(!l||!l.details)return null;var v=l.details.partList;if(v)for(var p=v.length;p--;){var m=v[p];if(m.index===d&&m.fragment.sn===n)return m}return null}},"./src/controller/stream-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>n});var W=w("./src/polyfills/number.ts"),P=w("./src/controller/base-stream-controller.ts"),N=w("./src/is-supported.ts"),D=w("./src/events.ts"),G=w("./src/utils/buffer-helper.ts"),I=w("./src/controller/fragment-tracker.ts"),R=w("./src/types/loader.ts"),L=w("./src/loader/fragment.ts"),_=w("./src/demux/transmuxer-interface.ts"),T=w("./src/types/transmuxer.ts"),g=w("./src/controller/gap-controller.ts"),x=w("./src/errors.ts");function b(d,v){for(var p=0;p<v.length;p++){var m=v[p];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(d,u(m.key),m)}}function f(d,v,p){return v&&b(d.prototype,v),p&&b(d,p),Object.defineProperty(d,"prototype",{writable:!1}),d}function u(d){var v=h(d,"string");return typeof v=="symbol"?v:String(v)}function h(d,v){if(typeof d!="object"||d===null)return d;var p=d[Symbol.toPrimitive];if(p!==void 0){var m=p.call(d,v||"default");if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(v==="string"?String:Number)(d)}function o(d,v){d.prototype=Object.create(v.prototype),d.prototype.constructor=d,s(d,v)}function s(d,v){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,r){return m.__proto__=r,m},s(d,v)}var l=100,n=function(d){o(v,d);function v(m,r,a){var e;return e=d.call(this,m,r,a,"[stream-controller]")||this,e.audioCodecSwap=!1,e.gapController=null,e.level=-1,e._forceStartLoad=!1,e.altAudio=!1,e.audioOnly=!1,e.fragPlaying=null,e.onvplaying=null,e.onvseeked=null,e.fragLastKbps=0,e.couldBacktrack=!1,e.backtrackFragment=null,e.audioCodecSwitch=!1,e.videoBuffer=null,e._registerListeners(),e}var p=v.prototype;return p._registerListeners=function(){var r=this.hls;r.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(D.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(D.Events.ERROR,this.onError,this),r.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(D.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var r=this.hls;r.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(D.Events.ERROR,this.onError,this),r.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(D.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},p.startLoad=function(r){if(this.levels){var a=this.lastCurrentTime,e=this.hls;if(this.stopLoad(),this.setInterval(l),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var c=e.startLevel;c===-1&&(e.config.testBandwidth&&this.levels.length>1?(c=0,this.bitrateTest=!0):c=e.nextAutoLevel),this.level=e.nextLoadLevel=c,this.loadedmetadata=!1}a>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),r=a),this.state=P.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=P.State.STOPPED},p.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},p.doTick=function(){switch(this.state){case P.State.IDLE:this.doTickIdle();break;case P.State.WAITING_LEVEL:{var r,a=this.levels,e=this.level,c=a==null||((r=a[e])===null||r===void 0)?void 0:r.details;if(c&&(!c.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(c))break;this.state=P.State.IDLE;break}break}case P.State.FRAG_LOADING_WAITING_RETRY:{var E,y=self.performance.now(),k=this.retryDate;(!k||y>=k||(E=this.media)!==null&&E!==void 0&&E.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=P.State.IDLE)}break;default:break}this.onTickEnd()},p.onTickEnd=function(){d.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},p.doTickIdle=function(){var r=this.hls,a=this.levelLastLoaded,e=this.levels,c=this.media,E=r.config,y=r.nextLoadLevel;if(a===null||!c&&(this.startFragRequested||!E.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!e||!e[y])return;var k=e[y],M=this.getMainFwdBufferInfo();if(M===null)return;var O=this.getLevelDetails();if(O&&this._streamEnded(M,O)){var U={};this.altAudio&&(U.type="video"),this.hls.trigger(D.Events.BUFFER_EOS,U),this.state=P.State.ENDED;return}this.level=r.nextLoadLevel=y;var F=k.details;if(!F||this.state===P.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==y){this.level=y,this.state=P.State.WAITING_LEVEL;return}var H=M.len,Y=this.getMaxBufferLength(k.maxBitrate);if(H>=Y)return;this.backtrackFragment&&this.backtrackFragment.start>M.end&&(this.backtrackFragment=null);var Q=this.backtrackFragment?this.backtrackFragment.start:M.end,z=this.getNextFragment(Q,F);if(this.couldBacktrack&&!this.fragPrevious&&z&&z.sn!=="initSegment"&&this.fragmentTracker.getState(z)!==I.FragmentState.OK){var ee,J=((ee=this.backtrackFragment)!=null?ee:z).sn,X=J-F.startSN,oe=F.fragments[X-1];oe&&z.cc===oe.cc&&(z=oe,this.fragmentTracker.removeFragment(oe))}else this.backtrackFragment&&M.len&&(this.backtrackFragment=null);if(z&&this.fragmentTracker.getState(z)===I.FragmentState.OK&&this.nextLoadPosition>Q){var le=this.audioOnly&&!this.altAudio?L.ElementaryStreamTypes.AUDIO:L.ElementaryStreamTypes.VIDEO,me=(le===L.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;me&&this.afterBufferFlushed(me,le,R.PlaylistLevelType.MAIN),z=this.getNextFragment(this.nextLoadPosition,F)}if(!z)return;z.initSegment&&!z.initSegment.data&&!this.bitrateTest&&(z=z.initSegment),this.loadFragment(z,F,Q)},p.loadFragment=function(r,a,e){var c,E=this.fragmentTracker.getState(r);this.fragCurrent=r,E===I.FragmentState.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r,a):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r,a)):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,a,e)):E===I.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((c=this.media)===null||c===void 0?void 0:c.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},p.getAppendedFrag=function(r){var a=this.fragmentTracker.getAppendedFrag(r,R.PlaylistLevelType.MAIN);return a&&"fragment"in a?a.fragment:a},p.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,R.PlaylistLevelType.MAIN)},p.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},p.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},p.nextLevelSwitch=function(){var r=this.levels,a=this.media;if(a!=null&&a.readyState){var e,c=this.getAppendedFrag(a.currentTime);if(c&&c.start>1&&this.flushMainBuffer(0,c.start-1),!a.paused&&r){var E=this.hls.nextLoadLevel,y=r[E],k=this.fragLastKbps;k&&this.fragCurrent?e=this.fragCurrent.duration*y.maxBitrate/(1e3*k)+1:e=0}else e=0;var M=this.getBufferedFrag(a.currentTime+e);if(M){var O=this.followingBufferedFrag(M);if(O){this.abortCurrentFrag();var U=O.maxStartPTS?O.maxStartPTS:O.start,F=O.duration,H=Math.max(M.end,U+Math.min(Math.max(F-this.config.maxFragLookUpTolerance,F*.5),F*.75));this.flushMainBuffer(H,Number.POSITIVE_INFINITY)}}}},p.abortCurrentFrag=function(){var r=this.fragCurrent;this.fragCurrent=null,this.backtrackFragment=null,r&&r.abortRequests();switch(this.state){case P.State.KEY_LOADING:case P.State.FRAG_LOADING:case P.State.FRAG_LOADING_WAITING_RETRY:case P.State.PARSING:case P.State.PARSED:this.state=P.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},p.flushMainBuffer=function(r,a){d.prototype.flushMainBuffer.call(this,r,a,this.altAudio?"video":null)},p.onMediaAttached=function(r,a){d.prototype.onMediaAttached.call(this,r,a);var e=a.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),e.addEventListener("playing",this.onvplaying),e.addEventListener("seeked",this.onvseeked),this.gapController=new g.default(this.config,e,this.fragmentTracker,this.hls)},p.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),d.prototype.onMediaDetaching.call(this)},p.onMediaPlaying=function(){this.tick()},p.onMediaSeeked=function(){var r=this.media,a=r?r.currentTime:null;(0,W.isFiniteNumber)(a)&&this.log("Media seeked to "+a.toFixed(3)),this.tick()},p.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(D.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},p.onManifestParsed=function(r,a){var e=!1,c=!1,E;a.levels.forEach(function(y){E=y.audioCodec,E&&(E.indexOf("mp4a.40.2")!==-1&&(e=!0),E.indexOf("mp4a.40.5")!==-1&&(c=!0))}),this.audioCodecSwitch=e&&c&&!(0,N.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=a.levels,this.startFragRequested=!1},p.onLevelLoading=function(r,a){var e=this.levels;if(!e||this.state!==P.State.IDLE)return;var c=e[a.level];(!c.details||c.details.live&&this.levelLastLoaded!==a.level||this.waitForCdnTuneIn(c.details))&&(this.state=P.State.WAITING_LEVEL)},p.onLevelLoaded=function(r,a){var e,c=this.levels,E=a.level,y=a.details,k=y.totalduration;if(!c){this.warn("Levels were reset while loading level "+E);return}this.log("Level "+E+" loaded ["+y.startSN+","+y.endSN+"], cc ["+y.startCC+", "+y.endCC+"] duration:"+k);var M=this.fragCurrent;M&&(this.state===P.State.FRAG_LOADING||this.state===P.State.FRAG_LOADING_WAITING_RETRY)&&(M.level!==a.level&&M.loader&&(this.state=P.State.IDLE,this.backtrackFragment=null,M.abortRequests()));var O=c[E],U=0;if(y.live||(e=O.details)!==null&&e!==void 0&&e.live){if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed)return;U=this.alignPlaylists(y,O.details)}if(O.details=y,this.levelLastLoaded=E,this.hls.trigger(D.Events.LEVEL_UPDATED,{details:y,level:E}),this.state===P.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(y))return;this.state=P.State.IDLE}this.startFragRequested?y.live&&this.synchronizeToLiveEdge(y):this.setStartPosition(y,U),this.tick()},p._handleFragmentLoadProgress=function(r){var a,e=r.frag,c=r.part,E=r.payload,y=this.levels;if(!y){this.warn("Levels were reset while fragment load was in progress. Fragment "+e.sn+" of level "+e.level+" will not be buffered");return}var k=y[e.level],M=k.details;if(!M){this.warn("Dropping fragment "+e.sn+" of level "+e.level+" after level details were reset");return}var O=k.videoCodec,U=M.PTSKnown||!M.live,F=(a=e.initSegment)===null||a===void 0?void 0:a.data,H=this._getAudioCodec(k),Y=this.transmuxer=this.transmuxer||new _.default(this.hls,R.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),Q=c?c.index:-1,z=Q!==-1,ee=new T.ChunkMetadata(e.level,e.sn,e.stats.chunkCount,E.byteLength,Q,z),J=this.initPTS[e.cc];Y.push(E,F,H,O,e,c,M.totalduration,U,ee,J)},p.onAudioTrackSwitching=function(r,a){var e=this.altAudio,c=!!a.url,E=a.id;if(!c){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var y=this.fragCurrent;y&&(this.log("Switching to main audio track, cancel main fragment load"),y.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var k=this.hls;e&&k.trigger(D.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),k.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:E})}},p.onAudioTrackSwitched=function(r,a){var e=a.id,c=!!this.hls.audioTracks[e].url;if(c){var E=this.videoBuffer;E&&this.mediaBuffer!==E&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=E)}this.altAudio=c,this.tick()},p.onBufferCreated=function(r,a){var e=a.tracks,c,E,y=!1;for(var k in e){var M=e[k];if(M.id==="main"){if(E=k,c=M,k==="video"){var O=e[k];O&&(this.videoBuffer=O.buffer)}}else y=!0}y&&c?(this.log("Alternate track found, use "+E+".buffered to schedule main fragment loading"),this.mediaBuffer=c.buffer):this.mediaBuffer=this.media},p.onFragBuffered=function(r,a){var e=a.frag,c=a.part;if(e&&e.type!==R.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(e)){this.warn("Fragment "+e.sn+(c?" p: "+c.index:"")+" of level "+e.level+" finished buffering, but was aborted. state: "+this.state),this.state===P.State.PARSED&&(this.state=P.State.IDLE);return}var E=c?c.stats:e.stats;this.fragLastKbps=Math.round(8*E.total/(E.buffering.end-E.loading.first)),e.sn!=="initSegment"&&(this.fragPrevious=e),this.fragBufferedComplete(e,c)},p.onError=function(r,a){if(a.type===x.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(R.PlaylistLevelType.MAIN,a);return}switch(a.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.FRAG_PARSING_ERROR:case x.ErrorDetails.KEY_LOAD_ERROR:case x.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(R.PlaylistLevelType.MAIN,a);break;case x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==P.State.ERROR&&(a.fatal?(this.warn(""+a.details),this.state=P.State.ERROR):!a.levelRetry&&this.state===P.State.WAITING_LEVEL&&(this.state=P.State.IDLE));break;case x.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="main"&&(this.state===P.State.PARSING||this.state===P.State.PARSED)){var e=!0,c=this.getFwdBufferInfo(this.media,R.PlaylistLevelType.MAIN);c&&c.len>.5&&(e=!this.reduceMaxBufferLength(c.len)),e&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},p.checkBuffer=function(){var r=this.media,a=this.gapController;if(!r||!a||!r.readyState)return;if(this.loadedmetadata||!G.BufferHelper.getBuffered(r).length){var e=this.state!==P.State.IDLE?this.fragCurrent:null;a.poll(this.lastCurrentTime,e)}this.lastCurrentTime=r.currentTime},p.onFragLoadEmergencyAborted=function(){this.state=P.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},p.onBufferFlushed=function(r,a){var e=a.type;if(e!==L.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var c=(e===L.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(c,e,R.PlaylistLevelType.MAIN)}},p.onLevelsUpdated=function(r,a){this.levels=a.levels},p.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},p.seekToStartPos=function(){var r=this.media;if(!r)return;var a=r.currentTime,e=this.startPosition;if(e>=0&&a<e){if(r.seeking){this.log("could not seek to "+e+", already seeking at "+a);return}var c=G.BufferHelper.getBuffered(r),E=c.length?c.start(0):0,y=E-e;y>0&&(y<this.config.maxBufferHole||y<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+y+" to match buffer start"),e+=y,this.startPosition=e),this.log("seek to target start position "+e+" from current time "+a),r.currentTime=e}},p._getAudioCodec=function(r){var a=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&a&&(this.log("Swapping audio codec"),a.indexOf("mp4a.40.5")!==-1?a="mp4a.40.2":a="mp4a.40.5"),a},p._loadBitrateTestFrag=function(r,a){var e=this;r.bitrateTest=!0,this._doFragLoad(r,a).then(function(c){var E=e.hls;if(!c||e.fragContextChanged(r))return;e.fragLoadError=0,e.state=P.State.IDLE,e.startFragRequested=!1,e.bitrateTest=!1;var y=r.stats;y.parsing.start=y.parsing.end=y.buffering.start=y.buffering.end=self.performance.now(),E.trigger(D.Events.FRAG_LOADED,c),r.bitrateTest=!1})},p._handleTransmuxComplete=function(r){var a,e="main",c=this.hls,E=r.remuxResult,y=r.chunkMeta,k=this.getCurrentContext(y);if(!k){this.warn("The loading context changed while buffering fragment "+y.sn+" of level "+y.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(y.level);return}var M=k.frag,O=k.part,U=k.level,F=E.video,H=E.text,Y=E.id3,Q=E.initSegment,z=U.details,ee=this.altAudio?void 0:E.audio;if(this.fragContextChanged(M))return;if(this.state=P.State.PARSING,Q){Q.tracks&&(this._bufferInitSegment(U,Q.tracks,M,y),c.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:e,tracks:Q.tracks}));var J=Q.initPTS,X=Q.timescale;(0,W.isFiniteNumber)(J)&&(this.initPTS[M.cc]=J,c.trigger(D.Events.INIT_PTS_FOUND,{frag:M,id:e,initPTS:J,timescale:X}))}if(F&&E.independent!==!1){if(z){var oe=F.startPTS,le=F.endPTS,me=F.startDTS,Ae=F.endDTS;if(O)O.elementaryStreams[F.type]={startPTS:oe,endPTS:le,startDTS:me,endDTS:Ae};else if(F.firstKeyFrame&&F.independent&&y.id===1&&(this.couldBacktrack=!0),F.dropped&&F.independent){var ge=this.getMainFwdBufferInfo(),ae=(ge?ge.end:this.getLoadPosition())+this.config.maxBufferHole,ue=F.firstKeyFramePTS?F.firstKeyFramePTS:oe;if(ae<ue-this.config.maxBufferHole){this.backtrack(M);return}M.setElementaryStreamInfo(F.type,M.start,le,M.start,Ae,!0)}M.setElementaryStreamInfo(F.type,oe,le,me,Ae),this.backtrackFragment&&(this.backtrackFragment=M),this.bufferFragmentData(F,M,O,y)}}else if(E.independent===!1){this.backtrack(M);return}if(ee){var ye=ee.startPTS,Ee=ee.endPTS,_e=ee.startDTS,Se=ee.endDTS;O&&(O.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:ye,endPTS:Ee,startDTS:_e,endDTS:Se}),M.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,ye,Ee,_e,Se),this.bufferFragmentData(ee,M,O,y)}if(z&&Y!==null&&Y!==void 0&&(a=Y.samples)!==null&&a!==void 0&&a.length){var Te={id:e,frag:M,details:z,samples:Y.samples};c.trigger(D.Events.FRAG_PARSING_METADATA,Te)}if(z&&H){var Pe={id:e,frag:M,details:z,samples:H.samples};c.trigger(D.Events.FRAG_PARSING_USERDATA,Pe)}},p._bufferInitSegment=function(r,a,e,c){var E=this;if(this.state!==P.State.PARSING)return;this.audioOnly=!!a.audio&&!a.video,this.altAudio&&!this.audioOnly&&delete a.audio;var y=a.audio,k=a.video,M=a.audiovideo;if(y){var O=r.audioCodec,U=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(O&&(O.indexOf("mp4a.40.5")!==-1?O="mp4a.40.2":O="mp4a.40.5"),y.metadata.channelCount!==1&&U.indexOf("firefox")===-1&&(O="mp4a.40.5")),U.indexOf("android")!==-1&&y.container!=="audio/mpeg"&&(O="mp4a.40.2",this.log("Android: force audio codec to "+O)),r.audioCodec&&r.audioCodec!==O&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+O+'"'),y.levelCodec=O,y.id="main",this.log("Init audio buffer, container:"+y.container+", codecs[selected/level/parsed]=["+(O||"")+"/"+(r.audioCodec||"")+"/"+y.codec+"]")}k&&(k.levelCodec=r.videoCodec,k.id="main",this.log("Init video buffer, container:"+k.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+k.codec+"]")),M&&this.log("Init audiovideo buffer, container:"+M.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+M.codec+"]"),this.hls.trigger(D.Events.BUFFER_CODECS,a),Object.keys(a).forEach(function(F){var H=a[F],Y=H.initSegment;Y!=null&&Y.byteLength&&E.hls.trigger(D.Events.BUFFER_APPENDING,{type:F,data:Y,frag:e,part:null,chunkMeta:c,parent:e.type})}),this.tick()},p.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,R.PlaylistLevelType.MAIN)},p.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=P.State.IDLE},p.checkFragmentChanged=function(){var r=this.media,a=null;if(r&&r.readyState>1&&r.seeking===!1){var e=r.currentTime;if(G.BufferHelper.isBuffered(r,e)?a=this.getAppendedFrag(e):G.BufferHelper.isBuffered(r,e+.1)&&(a=this.getAppendedFrag(e+.1)),a){this.backtrackFragment=null;var c=this.fragPlaying,E=a.level;(!c||a.sn!==c.sn||c.level!==E||a.urlId!==c.urlId)&&(this.fragPlaying=a,this.hls.trigger(D.Events.FRAG_CHANGED,{frag:a}),(!c||c.level!==E)&&this.hls.trigger(D.Events.LEVEL_SWITCHED,{level:E}))}}},f(v,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var a=r.currentTime,e=this.currentFrag;if(e&&(0,W.isFiniteNumber)(a)&&(0,W.isFiniteNumber)(e.programDateTime)){var c=e.programDateTime+(a-e.start)*1e3;return new Date(c)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),v}(P.default)},"./src/controller/subtitle-stream-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{SubtitleStreamController:()=>o});var W=w("./src/events.ts"),P=w("./src/utils/buffer-helper.ts"),N=w("./src/controller/fragment-finders.ts"),D=w("./src/utils/discontinuities.ts"),G=w("./src/controller/level-helper.ts"),I=w("./src/controller/fragment-tracker.ts"),R=w("./src/controller/base-stream-controller.ts"),L=w("./src/types/loader.ts"),_=w("./src/types/level.ts");function T(l,n){for(var d=0;d<n.length;d++){var v=n[d];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(l,x(v.key),v)}}function g(l,n,d){return n&&T(l.prototype,n),d&&T(l,d),Object.defineProperty(l,"prototype",{writable:!1}),l}function x(l){var n=b(l,"string");return typeof n=="symbol"?n:String(n)}function b(l,n){if(typeof l!="object"||l===null)return l;var d=l[Symbol.toPrimitive];if(d!==void 0){var v=d.call(l,n||"default");if(typeof v!="object")return v;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(l)}function f(l,n){l.prototype=Object.create(n.prototype),l.prototype.constructor=l,u(l,n)}function u(l,n){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,p){return v.__proto__=p,v},u(l,n)}var h=500,o=function(l){f(n,l);function n(v,p,m){var r;return r=l.call(this,v,p,m,"[subtitle-stream-controller]")||this,r.levels=[],r.currentTrackId=-1,r.tracksBuffered=[],r.mainDetails=null,r._registerListeners(),r}var d=n.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var p=this.hls;p.on(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.on(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.on(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.on(W.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.on(W.Events.ERROR,this.onError,this),p.on(W.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.on(W.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.on(W.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.on(W.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.on(W.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),p.on(W.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var p=this.hls;p.off(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),p.off(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),p.off(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),p.off(W.Events.LEVEL_LOADED,this.onLevelLoaded,this),p.off(W.Events.ERROR,this.onError,this),p.off(W.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),p.off(W.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),p.off(W.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),p.off(W.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),p.off(W.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),p.off(W.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.startLoad=function(p){this.stopLoad(),this.state=R.State.IDLE,this.setInterval(h),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=p,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},d.onLevelLoaded=function(p,m){this.mainDetails=m.details},d.onSubtitleFragProcessed=function(p,m){var r=m.frag,a=m.success;if(this.fragPrevious=r,this.state=R.State.IDLE,!a)return;var e=this.tracksBuffered[this.currentTrackId];if(!e)return;for(var c,E=r.start,y=0;y<e.length;y++)if(E>=e[y].start&&E<=e[y].end){c=e[y];break}var k=r.start+r.duration;c?c.end=k:(c={start:E,end:k},e.push(c)),this.fragmentTracker.fragBuffered(r)},d.onBufferFlushing=function(p,m){var r=m.startOffset,a=m.endOffset;if(r===0&&a!==Number.POSITIVE_INFINITY){var e=this.currentTrackId,c=this.levels;if(!c.length||!c[e]||!c[e].details)return;var E=c[e].details,y=E.targetduration,k=a-y;if(k<=0)return;m.endOffsetSubtitles=Math.max(0,k),this.tracksBuffered.forEach(function(M){for(var O=0;O<M.length;){if(M[O].end<=k){M.shift();continue}else if(M[O].start<k)M[O].start=k;else break;O++}}),this.fragmentTracker.removeFragmentsInRange(r,k,L.PlaylistLevelType.SUBTITLE)}},d.onFragBuffered=function(p,m){if(!this.loadedmetadata&&m.frag.type===L.PlaylistLevelType.MAIN){var r;(r=this.media)!==null&&r!==void 0&&r.buffered.length&&(this.loadedmetadata=!0)}},d.onError=function(p,m){var r=m.frag;if(!r||r.type!==L.PlaylistLevelType.SUBTITLE)return;this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=R.State.IDLE},d.onSubtitleTracksUpdated=function(p,m){var r=this,a=m.subtitleTracks;this.tracksBuffered=[],this.levels=a.map(function(e){return new _.Level(e)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(e){r.tracksBuffered[e.id]=[]}),this.mediaBuffer=null},d.onSubtitleTrackSwitch=function(p,m){if(this.currentTrackId=m.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(h)},d.onSubtitleTrackLoaded=function(p,m){var r,a=m.details,e=m.id,c=this.currentTrackId,E=this.levels;if(!E.length)return;var y=E[c];if(e>=E.length||e!==c||!y)return;this.mediaBuffer=this.mediaBufferTimeRanges;var k=0;if(a.live||(r=y.details)!==null&&r!==void 0&&r.live){var M=this.mainDetails;if(a.deltaUpdateFailed||!M)return;var O=M.fragments[0];y.details?(k=this.alignPlaylists(a,y.details),k===0&&O&&(k=O.start,(0,G.addSliding)(a,k))):a.hasProgramDateTime&&M.hasProgramDateTime?((0,D.alignMediaPlaylistByPDT)(a,M),k=a.fragments[0].start):O&&(k=O.start,(0,G.addSliding)(a,k))}if(y.details=a,this.levelLastLoaded=e,!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(y.details,k),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===R.State.IDLE){var U=(0,N.findFragmentByPTS)(null,a.fragments,this.media.currentTime,0);U||(this.warn("Subtitle playlist not aligned with playback"),y.details=void 0)}},d._handleFragmentLoadComplete=function(p){var m=this,r=p.frag,a=p.payload,e=r.decryptdata,c=this.hls;if(this.fragContextChanged(r))return;if(a&&a.byteLength>0&&e&&e.key&&e.iv&&e.method==="AES-128"){var E=performance.now();this.decrypter.decrypt(new Uint8Array(a),e.key.buffer,e.iv.buffer).then(function(y){var k=performance.now();c.trigger(W.Events.FRAG_DECRYPTED,{frag:r,payload:y,stats:{tstart:E,tdecrypt:k}})}).catch(function(y){m.warn(y.name+": "+y.message),m.state=R.State.IDLE})}},d.doTick=function(){if(!this.media){this.state=R.State.IDLE;return}if(this.state===R.State.IDLE){var p=this.currentTrackId,m=this.levels;if(!m.length||!m[p]||!m[p].details)return;var r=m[p].details,a=r.targetduration,e=this.config,c=this.getLoadPosition(),E=P.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],c-a,e.maxBufferHole),y=E.end,k=E.len,M=this.getFwdBufferInfo(this.media,L.PlaylistLevelType.MAIN),O=this.getMaxBufferLength(M==null?void 0:M.len)+a;if(k>O)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var U=r.fragments,F=U.length,H=r.edge,Y=null,Q=this.fragPrevious;if(y<H){var z=e.maxFragLookUpTolerance;Y=(0,N.findFragmentByPTS)(Q,U,Math.max(U[0].start,y),z),!Y&&Q&&Q.start<U[0].start&&(Y=U[0])}else Y=U[F-1];if(!Y)return;Y=this.mapToInitFragWhenRequired(Y),this.fragmentTracker.getState(Y)===I.FragmentState.NOT_LOADED&&this.loadFragment(Y,r,y)}},d.getMaxBufferLength=function(p){var m=l.prototype.getMaxBufferLength.call(this);return p?Math.max(m,p):m},d.loadFragment=function(p,m,r){this.fragCurrent=p,p.sn==="initSegment"?this._loadInitSegment(p,m):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,p,m,r))},g(n,[{key:"mediaBufferTimeRanges",get:function(){return new s(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(R.default),s=function(n){this.buffered=void 0;var d=function(p,m,r){if(m=m>>>0,m>r-1)throw new DOMException("Failed to execute '"+p+"' on 'TimeRanges': The index provided ("+m+") is greater than the maximum bound ("+r+")");return n[m][p]};this.buffered={get length(){return n.length},end:function(p){return d("end",p,n.length)},start:function(p){return d("start",p,n.length)}}}},"./src/controller/subtitle-track-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>b});var W=w("./src/events.ts"),P=w("./src/utils/texttrack-utils.ts"),N=w("./src/controller/base-playlist-controller.ts"),D=w("./src/types/loader.ts");function G(f,u){for(var h=0;h<u.length;h++){var o=u[h];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(f,R(o.key),o)}}function I(f,u,h){return u&&G(f.prototype,u),h&&G(f,h),Object.defineProperty(f,"prototype",{writable:!1}),f}function R(f){var u=L(f,"string");return typeof u=="symbol"?u:String(u)}function L(f,u){if(typeof f!="object"||f===null)return f;var h=f[Symbol.toPrimitive];if(h!==void 0){var o=h.call(f,u||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(u==="string"?String:Number)(f)}function _(f,u){f.prototype=Object.create(u.prototype),f.prototype.constructor=f,T(f,u)}function T(f,u){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,s){return o.__proto__=s,o},T(f,u)}var g=function(f){_(u,f);function u(o){var s;return s=f.call(this,o,"[subtitle-track-controller]")||this,s.media=null,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.selectDefaultTrack=!0,s.queuedDefaultTrack=-1,s.trackChangeListener=function(){return s.onTextTracksChanged()},s.asyncPollTrackChange=function(){return s.pollTrackChange(0)},s.useTextTrackPolling=!1,s.subtitlePollingInterval=-1,s._subtitleDisplay=!0,s.registerListeners(),s}var h=u.prototype;return h.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,f.prototype.destroy.call(this)},h.registerListeners=function(){var s=this.hls;s.on(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.on(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.on(W.Events.LEVEL_LOADING,this.onLevelLoading,this),s.on(W.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.on(W.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),s.on(W.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var s=this.hls;s.off(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),s.off(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.off(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.off(W.Events.LEVEL_LOADING,this.onLevelLoading,this),s.off(W.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.off(W.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),s.off(W.Events.ERROR,this.onError,this)},h.onMediaAttached=function(s,l){if(this.media=l.media,!this.media)return;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)},h.pollTrackChange=function(s){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,s)},h.onMediaDetaching=function(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var s=x(this.media.textTracks);s.forEach(function(l){(0,P.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null},h.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},h.onManifestParsed=function(s,l){this.tracks=l.subtitleTracks},h.onSubtitleTrackLoaded=function(s,l){var n=l.id,d=l.details,v=this.trackId,p=this.tracksInGroup[v];if(!p){this.warn("Invalid subtitle track id "+n);return}var m=p.details;p.details=l.details,this.log("subtitle track "+n+" loaded ["+d.startSN+"-"+d.endSN+"]"),n===this.trackId&&(this.retryCount=0,this.playlistLoaded(n,l,m))},h.onLevelLoading=function(s,l){this.switchLevel(l.level)},h.onLevelSwitching=function(s,l){this.switchLevel(l.level)},h.switchLevel=function(s){var l=this.hls.levels[s];if(!(l!=null&&l.textGroupIds))return;var n=l.textGroupIds[l.urlId];if(this.groupId!==n){var d=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,v=this.tracks.filter(function(r){return!n||r.groupId===n});this.tracksInGroup=v;var p=this.findTrackId(d==null?void 0:d.name)||this.findTrackId();this.groupId=n;var m={subtitleTracks:v};this.log("Updating subtitle tracks, "+v.length+' track(s) found in "'+n+'" group-id'),this.hls.trigger(W.Events.SUBTITLE_TRACKS_UPDATED,m),p!==-1&&this.setSubtitleTrack(p,d)}},h.findTrackId=function(s){for(var l=this.tracksInGroup,n=0;n<l.length;n++){var d=l[n];if((!this.selectDefaultTrack||d.default)&&(!s||s===d.name))return d.id}return-1},h.onError=function(s,l){if(f.prototype.onError.call(this,s,l),l.fatal||!l.context)return;l.context.type===D.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},h.loadPlaylist=function(s){f.prototype.loadPlaylist.call(this);var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var n=l.id,d=l.groupId,v=l.url;if(s)try{v=s.addDirectives(v)}catch(p){this.warn("Could not construct new URL with HLS Delivery Directives: "+p)}this.log("Loading subtitle playlist for id "+n),this.hls.trigger(W.Events.SUBTITLE_TRACK_LOADING,{url:v,id:n,groupId:d,deliveryDirectives:s||null})}},h.toggleTrackModes=function(s){var l=this,n=this.media,d=this.trackId;if(!n)return;var v=x(n.textTracks),p=v.filter(function(a){return a.groupId===l.groupId});if(s===-1)[].slice.call(v).forEach(function(a){a.mode="disabled"});else{var m=p[d];m&&(m.mode="disabled")}var r=p[s];r&&(r.mode=this.subtitleDisplay?"showing":"hidden")},h.setSubtitleTrack=function(s,l){var n,d=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=s;return}if(this.trackId!==s&&this.toggleTrackModes(s),this.trackId===s&&(s===-1||(n=d[s])!==null&&n!==void 0&&n.details)||s<-1||s>=d.length)return;this.clearTimer();var v=d[s];if(this.log("Switching to subtitle track "+s),this.trackId=s,v){var p=v.id,m=v.groupId,r=m===void 0?"":m,a=v.name,e=v.type,c=v.url;this.hls.trigger(W.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:r,name:a,type:e,url:c});var E=this.switchParams(v.url,l==null?void 0:l.details);this.loadPlaylist(E)}else this.hls.trigger(W.Events.SUBTITLE_TRACK_SWITCH,{id:s})},h.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var s=-1,l=x(this.media.textTracks),n=0;n<l.length;n++)if(l[n].mode==="hidden")s=n;else if(l[n].mode==="showing"){s=n;break}this.subtitleTrack!==s&&(this.subtitleTrack=s)},I(u,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(s){this._subtitleDisplay=s,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(s){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(s,l)}}]),u}(N.default);function x(f){for(var u=[],h=0;h<f.length;h++){var o=f[h];(o.kind==="subtitles"||o.kind==="captions")&&o.label&&u.push(f[h])}return u}const b=g},"./src/controller/timeline-controller.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{TimelineController:()=>g});var W=w("./src/polyfills/number.ts"),P=w("./src/events.ts"),N=w("./src/utils/cea-608-parser.ts"),D=w("./src/utils/output-filter.ts"),G=w("./src/utils/webvtt-parser.ts"),I=w("./src/utils/texttrack-utils.ts"),R=w("./src/utils/imsc1-ttml-parser.ts"),L=w("./src/utils/mp4-tools.ts"),_=w("./src/types/loader.ts"),T=w("./src/utils/logger.ts"),g=function(){function u(o){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.timescale=[],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=f(),this.captionsProperties=void 0,this.hls=o,this.config=o.config,this.Cues=o.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 s=new D.default(this,"textTrack1"),l=new D.default(this,"textTrack2"),n=new D.default(this,"textTrack3"),d=new D.default(this,"textTrack4");this.cea608Parser1=new N.default(1,s,l),this.cea608Parser2=new N.default(3,n,d)}o.on(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(P.Events.MANIFEST_LOADED,this.onManifestLoaded,this),o.on(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),o.on(P.Events.FRAG_LOADING,this.onFragLoading,this),o.on(P.Events.FRAG_LOADED,this.onFragLoaded,this),o.on(P.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),o.on(P.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),o.on(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),o.on(P.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),o.on(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var h=u.prototype;return h.destroy=function(){var s=this.hls;s.off(P.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.off(P.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(P.Events.MANIFEST_LOADED,this.onManifestLoaded,this),s.off(P.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),s.off(P.Events.FRAG_LOADING,this.onFragLoading,this),s.off(P.Events.FRAG_LOADED,this.onFragLoaded,this),s.off(P.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),s.off(P.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),s.off(P.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.off(P.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),s.off(P.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},h.addCues=function(s,l,n,d,v){for(var p=!1,m=v.length;m--;){var r=v[m],a=b(r[0],r[1],l,n);if(a>=0&&(r[0]=Math.min(r[0],l),r[1]=Math.max(r[1],n),p=!0,a/(n-l)>.5))return}if(p||v.push([l,n]),this.config.renderTextTracksNatively){var e=this.captionsTracks[s];this.Cues.newCue(e,l,n,d)}else{var c=this.Cues.newCue(null,l,n,d);this.hls.trigger(P.Events.CUES_PARSED,{type:"captions",cues:c,track:s})}},h.onInitPtsFound=function(s,l){var n=this,d=l.frag,v=l.id,p=l.initPTS,m=l.timescale,r=this.unparsedVttFrags;v==="main"&&(this.initPTS[d.cc]=p,this.timescale[d.cc]=m),r.length&&(this.unparsedVttFrags=[],r.forEach(function(a){n.onFragLoaded(P.Events.FRAG_LOADED,a)}))},h.getExistingTrack=function(s){var l=this.media;if(l)for(var n=0;n<l.textTracks.length;n++){var d=l.textTracks[n];if(d[s])return d}return null},h.createCaptionsTrack=function(s){this.config.renderTextTracksNatively?this.createNativeTrack(s):this.createNonNativeTrack(s)},h.createNativeTrack=function(s){if(this.captionsTracks[s])return;var l=this.captionsProperties,n=this.captionsTracks,d=this.media,v=l[s],p=v.label,m=v.languageCode,r=this.getExistingTrack(s);if(r)n[s]=r,(0,I.clearCurrentCues)(n[s]),(0,I.sendAddTrackEvent)(n[s],d);else{var a=this.createTextTrack("captions",p,m);a&&(a[s]=!0,n[s]=a)}},h.createNonNativeTrack=function(s){if(this.nonNativeCaptionsTracks[s])return;var l=this.captionsProperties[s];if(!l)return;var n=l.label,d={_id:s,label:n,kind:"captions",default:l.media?!!l.media.default:!1,closedCaptions:l.media};this.nonNativeCaptionsTracks[s]=d,this.hls.trigger(P.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[d]})},h.createTextTrack=function(s,l,n){var d=this.media;return d?d.addTextTrack(s,l,n):void 0},h.onMediaAttaching=function(s,l){this.media=l.media,this._cleanTracks()},h.onMediaDetaching=function(){var s=this.captionsTracks;Object.keys(s).forEach(function(l){(0,I.clearCurrentCues)(s[l]),delete s[l]}),this.nonNativeCaptionsTracks={}},h.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=f(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},h._cleanTracks=function(){var s=this.media;if(!s)return;var l=s.textTracks;if(l)for(var n=0;n<l.length;n++)(0,I.clearCurrentCues)(l[n])},h.onSubtitleTracksUpdated=function(s,l){var n=this;this.textTracks=[];var d=l.subtitleTracks||[],v=d.some(function(a){return a.textCodec===R.IMSC1_CODEC});if(this.config.enableWebVTT||v&&this.config.enableIMSC1){var p=this.tracks&&d&&this.tracks.length===d.length;if(this.tracks=d||[],this.config.renderTextTracksNatively){var m=this.media?this.media.textTracks:[];this.tracks.forEach(function(a,e){var c;if(e<m.length){for(var E=null,y=0;y<m.length;y++)if(x(m[y],a)){E=m[y];break}E&&(c=E)}if(c)(0,I.clearCurrentCues)(c);else{var k=n._captionsOrSubtitlesFromCharacteristics(a);c=n.createTextTrack(k,a.name,a.lang),c&&(c.mode="disabled")}c&&(c.groupId=a.groupId,n.textTracks.push(c))})}else if(!p&&this.tracks&&this.tracks.length){var r=this.tracks.map(function(a){return{label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}});this.hls.trigger(P.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:r})}}},h._captionsOrSubtitlesFromCharacteristics=function(s){var l;if((l=s.attrs)!==null&&l!==void 0&&l.CHARACTERISTICS){var n=/transcribes-spoken-dialog/gi.test(s.attrs.CHARACTERISTICS),d=/describes-music-and-sound/gi.test(s.attrs.CHARACTERISTICS);if(n&&d)return"captions"}return"subtitles"},h.onManifestLoaded=function(s,l){var n=this;this.config.enableCEA708Captions&&l.captions&&l.captions.forEach(function(d){var v=/(?:CC|SERVICE)([1-4])/.exec(d.instreamId);if(!v)return;var p="textTrack"+v[1],m=n.captionsProperties[p];if(!m)return;m.label=d.name,d.lang&&(m.languageCode=d.lang),m.media=d})},h.closedCaptionsForLevel=function(s){var l=this.hls.levels[s.level];return l==null?void 0:l.attrs["CLOSED-CAPTIONS"]},h.onFragLoading=function(s,l){var n=this.cea608Parser1,d=this.cea608Parser2,v=this.lastSn,p=this.lastPartIndex;if(!this.enabled||!(n&&d))return;if(l.frag.type===_.PlaylistLevelType.MAIN){var m,r,a=l.frag.sn,e=(m=l==null||((r=l.part)===null||r===void 0)?void 0:r.index)!=null?m:-1;a===v+1||a===v&&e===p+1||(n.reset(),d.reset()),this.lastSn=a,this.lastPartIndex=e}},h.onFragLoaded=function(s,l){var n=l.frag,d=l.payload,v=this.initPTS,p=this.unparsedVttFrags;if(n.type===_.PlaylistLevelType.SUBTITLE)if(d.byteLength){if(!(0,W.isFiniteNumber)(v[n.cc])){p.push(l),v.length&&this.hls.trigger(P.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Missing initial subtitle PTS")});return}var m=n.decryptdata,r="stats"in l;if(m==null||!m.encrypted||r){var a=this.tracks[n.level],e=this.vttCCs;e[n.cc]||(e[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc),a&&a.textCodec===R.IMSC1_CODEC?this._parseIMSC1(n,d):this._parseVTTs(n,d,e)}}else this.hls.trigger(P.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Empty subtitle payload")})},h._parseIMSC1=function(s,l){var n=this,d=this.hls;(0,R.parseIMSC1)(l,this.initPTS[s.cc],this.timescale[s.cc],function(v){n._appendCues(v,s.level),d.trigger(P.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},function(v){T.logger.log("Failed to parse IMSC1: "+v),d.trigger(P.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:v})})},h._parseVTTs=function(s,l,n){var d,v=this,p=this.hls,m=(d=s.initSegment)!==null&&d!==void 0&&d.data?(0,L.appendUint8Array)(s.initSegment.data,new Uint8Array(l)):l;(0,G.parseWebVTT)(m,this.initPTS[s.cc],this.timescale[s.cc],n,s.cc,s.start,function(r){v._appendCues(r,s.level),p.trigger(P.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},function(r){v._fallbackToIMSC1(s,l),T.logger.log("Failed to parse VTT cue: "+r),p.trigger(P.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:r})})},h._fallbackToIMSC1=function(s,l){var n=this,d=this.tracks[s.level];d.textCodec||(0,R.parseIMSC1)(l,this.initPTS[s.cc],this.timescale[s.cc],function(){d.textCodec=R.IMSC1_CODEC,n._parseIMSC1(s,l)},function(){d.textCodec="wvtt"})},h._appendCues=function(s,l){var n=this.hls;if(this.config.renderTextTracksNatively){var d=this.textTracks[l];if(!d||d.mode==="disabled")return;s.forEach(function(m){return(0,I.addCueToTrack)(d,m)})}else{var v=this.tracks[l];if(!v)return;var p=v.default?"default":"subtitles"+l;n.trigger(P.Events.CUES_PARSED,{type:"subtitles",cues:s,track:p})}},h.onFragDecrypted=function(s,l){var n=l.frag;if(n.type===_.PlaylistLevelType.SUBTITLE){if(!(0,W.isFiniteNumber)(this.initPTS[n.cc])){this.unparsedVttFrags.push(l);return}this.onFragLoaded(P.Events.FRAG_LOADED,l)}},h.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},h.onFragParsingUserdata=function(s,l){var n=this.cea608Parser1,d=this.cea608Parser2;if(!this.enabled||!(n&&d))return;var v=l.frag,p=l.samples;if(v.type===_.PlaylistLevelType.MAIN&&this.closedCaptionsForLevel(v)==="NONE")return;for(var m=0;m<p.length;m++){var r=p[m].bytes;if(r){var a=this.extractCea608Data(r);n.addData(p[m].pts,a[0]),d.addData(p[m].pts,a[1])}}},h.onBufferFlushing=function(s,l){var n=l.startOffset,d=l.endOffset,v=l.endOffsetSubtitles,p=l.type,m=this.media;if(!m||m.currentTime<d)return;if(!p||p==="video"){var r=this.captionsTracks;Object.keys(r).forEach(function(e){return(0,I.removeCuesInRange)(r[e],n,d)})}if(this.config.renderTextTracksNatively&&(n===0&&v!==void 0)){var a=this.textTracks;Object.keys(a).forEach(function(e){return(0,I.removeCuesInRange)(a[e],n,v)})}},h.extractCea608Data=function(s){for(var l=[[],[]],n=s[0]&31,d=2,v=0;v<n;v++){var p=s[d++],m=127&s[d++],r=127&s[d++];if(m===0&&r===0)continue;var a=(4&p)!==0;if(a){var e=3&p;(e===0||e===1)&&(l[e].push(m),l[e].push(r))}}return l},u}();function x(u,h){return u&&u.label===h.name&&!(u.textTrack1||u.textTrack2)}function b(u,h,o,s){return Math.min(h,s)-Math.max(u,o)}function f(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>W});var W=function(){function P(D,G){this.subtle=void 0,this.aesIV=void 0,this.subtle=D,this.aesIV=G}var N=P.prototype;return N.decrypt=function(G,I){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},I,G)},P}()},"./src/crypt/aes-decryptor.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>N,removePadding:()=>P});var W=w("./src/utils/typed-array.ts");function P(D){var G=D.byteLength,I=G&&new DataView(D.buffer).getUint8(G-1);return I?(0,W.sliceUint8)(D,0,G-I):D}var N=function(){function D(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var G=D.prototype;return G.uint8ArrayToUint32Array_=function(R){for(var L=new DataView(R),_=new Uint32Array(4),T=0;T<4;T++)_[T]=L.getUint32(T*4);return _},G.initTable=function(){var R=this.sBox,L=this.invSBox,_=this.subMix,T=_[0],g=_[1],x=_[2],b=_[3],f=this.invSubMix,u=f[0],h=f[1],o=f[2],s=f[3],l=new Uint32Array(256),n=0,d=0,v=0;for(v=0;v<256;v++)v<128?l[v]=v<<1:l[v]=v<<1^283;for(v=0;v<256;v++){var p=d^d<<1^d<<2^d<<3^d<<4;p=p>>>8^p&255^99,R[n]=p,L[p]=n;var m=l[n],r=l[m],a=l[r],e=l[p]*257^p*16843008;T[n]=e<<24|e>>>8,g[n]=e<<16|e>>>16,x[n]=e<<8|e>>>24,b[n]=e,e=a*16843009^r*65537^m*257^n*16843008,u[p]=e<<24|e>>>8,h[p]=e<<16|e>>>16,o[p]=e<<8|e>>>24,s[p]=e,n?(n=m^l[l[l[a^m]]],d^=l[l[d]]):n=d=1}},G.expandKey=function(R){for(var L=this.uint8ArrayToUint32Array_(R),_=!0,T=0;T<L.length&&_;)_=L[T]===this.key[T],T++;if(_)return;this.key=L;var g=this.keySize=L.length;if(g!==4&&g!==6&&g!==8)throw new Error("Invalid aes key size="+g);var x=this.ksRows=(g+6+1)*4,b,f,u=this.keySchedule=new Uint32Array(x),h=this.invKeySchedule=new Uint32Array(x),o=this.sBox,s=this.rcon,l=this.invSubMix,n=l[0],d=l[1],v=l[2],p=l[3],m,r;for(b=0;b<x;b++){if(b<g){m=u[b]=L[b];continue}r=m,b%g===0?(r=r<<8|r>>>24,r=o[r>>>24]<<24|o[r>>>16&255]<<16|o[r>>>8&255]<<8|o[r&255],r^=s[b/g|0]<<24):g>6&&b%g===4&&(r=o[r>>>24]<<24|o[r>>>16&255]<<16|o[r>>>8&255]<<8|o[r&255]),u[b]=m=(u[b-g]^r)>>>0}for(f=0;f<x;f++)b=x-f,f&3?r=u[b]:r=u[b-4],f<4||b<=4?h[f]=r:h[f]=n[o[r>>>24]]^d[o[r>>>16&255]]^v[o[r>>>8&255]]^p[o[r&255]],h[f]=h[f]>>>0},G.networkToHostOrderSwap=function(R){return R<<24|(R&65280)<<8|(R&16711680)>>8|R>>>24},G.decrypt=function(R,L,_){for(var T=this.keySize+6,g=this.invKeySchedule,x=this.invSBox,b=this.invSubMix,f=b[0],u=b[1],h=b[2],o=b[3],s=this.uint8ArrayToUint32Array_(_),l=s[0],n=s[1],d=s[2],v=s[3],p=new Int32Array(R),m=new Int32Array(p.length),r,a,e,c,E,y,k,M,O,U,F,H,Y,Q,z=this.networkToHostOrderSwap;L<p.length;){for(O=z(p[L]),U=z(p[L+1]),F=z(p[L+2]),H=z(p[L+3]),E=O^g[0],y=H^g[1],k=F^g[2],M=U^g[3],Y=4,Q=1;Q<T;Q++)r=f[E>>>24]^u[y>>16&255]^h[k>>8&255]^o[M&255]^g[Y],a=f[y>>>24]^u[k>>16&255]^h[M>>8&255]^o[E&255]^g[Y+1],e=f[k>>>24]^u[M>>16&255]^h[E>>8&255]^o[y&255]^g[Y+2],c=f[M>>>24]^u[E>>16&255]^h[y>>8&255]^o[k&255]^g[Y+3],E=r,y=a,k=e,M=c,Y=Y+4;r=x[E>>>24]<<24^x[y>>16&255]<<16^x[k>>8&255]<<8^x[M&255]^g[Y],a=x[y>>>24]<<24^x[k>>16&255]<<16^x[M>>8&255]<<8^x[E&255]^g[Y+1],e=x[k>>>24]<<24^x[M>>16&255]<<16^x[E>>8&255]<<8^x[y&255]^g[Y+2],c=x[M>>>24]<<24^x[E>>16&255]<<16^x[y>>8&255]<<8^x[k&255]^g[Y+3],m[L]=z(r^l),m[L+1]=z(c^n),m[L+2]=z(e^d),m[L+3]=z(a^v),l=O,n=U,d=F,v=H,L=L+4}return m.buffer},D}()},"./src/crypt/decrypter.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>L});var W=w("./src/crypt/aes-crypto.ts"),P=w("./src/crypt/fast-aes-key.ts"),N=w("./src/crypt/aes-decryptor.ts"),D=w("./src/utils/logger.ts"),G=w("./src/utils/mp4-tools.ts"),I=w("./src/utils/typed-array.ts"),R=16,L=function(){function _(g,x){var b=x===void 0?{}:x,f=b.removePKCS7Padding,u=f===void 0?!0:f;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=g.enableSoftwareAES,this.removePKCS7Padding=u,u)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(o){}this.subtle===null&&(this.useSoftware=!0)}var T=_.prototype;return T.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},T.isSync=function(){return this.useSoftware},T.flush=function(){var x=this.currentResult,b=this.remainderData;if(!x||b)return this.reset(),null;var f=new Uint8Array(x);return this.reset(),this.removePKCS7Padding?(0,N.removePadding)(f):f},T.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},T.decrypt=function(x,b,f){var u=this;return this.useSoftware?new Promise(function(h,o){u.softwareDecrypt(new Uint8Array(x),b,f);var s=u.flush();s?h(s.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(x),b,f)},T.softwareDecrypt=function(x,b,f){var u=this.currentIV,h=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(x=(0,G.appendUint8Array)(o,x),this.remainderData=null);var s=this.getValidChunk(x);if(!s.length)return null;u&&(f=u);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new N.default),l.expandKey(b);var n=h;return this.currentResult=l.decrypt(s.buffer,0,f),this.currentIV=(0,I.sliceUint8)(s,-16).buffer,n||null},T.webCryptoDecrypt=function(x,b,f){var u=this,h=this.subtle;return(this.key!==b||!this.fastAesKey)&&(this.key=b,this.fastAesKey=new P.default(h,b)),this.fastAesKey.expandKey().then(function(o){if(!h)return Promise.reject(new Error("web crypto not initialized"));u.logOnce("WebCrypto AES decrypt");var s=new W.default(h,new Uint8Array(f));return s.decrypt(x.buffer,o)}).catch(function(o){return D.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+o.name+": "+o.message),u.onWebCryptoError(x,b,f)})},T.onWebCryptoError=function(x,b,f){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(x,b,f);var u=this.flush();if(u)return u.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},T.getValidChunk=function(x){var b=x,f=x.length-x.length%R;return f!==x.length&&(b=(0,I.sliceUint8)(x,0,f),this.remainderData=(0,I.sliceUint8)(x,f)),b},T.logOnce=function(x){if(!this.logEnabled)return;D.logger.log("[decrypter]: "+x),this.logEnabled=!1},_}()},"./src/crypt/fast-aes-key.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>W});var W=function(){function P(D,G){this.subtle=void 0,this.key=void 0,this.subtle=D,this.key=G}var N=P.prototype;return N.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},P}()},"./src/demux/aacdemuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>L});var W=w("./src/demux/base-audio-demuxer.ts"),P=w("./src/demux/adts.ts"),N=w("./src/utils/logger.ts"),D=w("./src/demux/id3.ts");function G(_,T){_.prototype=Object.create(T.prototype),_.prototype.constructor=_,I(_,T)}function I(_,T){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(x,b){return x.__proto__=b,x},I(_,T)}var R=function(_){G(T,_);function T(x,b){var f;return f=_.call(this)||this,f.observer=void 0,f.config=void 0,f.observer=x,f.config=b,f}var g=T.prototype;return g.resetInitSegment=function(b,f,u,h){_.prototype.resetInitSegment.call(this,b,f,u,h),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:f,duration:h,inputTimeScale:9e4,dropped:0}},T.probe=function(b){if(!b)return!1;for(var f=D.getID3Data(b,0)||[],u=f.length,h=b.length;u<h;u++)if(P.probe(b,u))return N.logger.log("ADTS sync word found !"),!0;return!1},g.canParse=function(b,f){return P.canParse(b,f)},g.appendFrame=function(b,f,u){P.initTrackConfig(b,this.observer,f,u,b.manifestCodec);var h=P.appendFrame(b,f,u,this.basePTS,this.frameIndex);if(h&&h.missing===0)return h},T}(W.default);const L=R},"./src/demux/adts.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{appendFrame:()=>u,canGetFrameLength:()=>L,canParse:()=>T,getAudioConfig:()=>D,getFrameDuration:()=>b,getFullFrameLength:()=>R,getHeaderLength:()=>I,initTrackConfig:()=>x,isHeader:()=>_,isHeaderPattern:()=>G,parseFrameHeader:()=>f,probe:()=>g});var W=w("./src/utils/logger.ts"),P=w("./src/errors.ts"),N=w("./src/events.ts");function D(h,o,s,l){var n,d,v,p,m=navigator.userAgent.toLowerCase(),r=l,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((o[s+2]&192)>>>6)+1;var e=(o[s+2]&60)>>>2;if(e>a.length-1){h.trigger(N.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+e});return}return v=(o[s+2]&1)<<2,v|=(o[s+3]&192)>>>6,W.logger.log("manifest codec:"+l+", ADTS type:"+n+", samplingIndex:"+e),/firefox/i.test(m)?e>=6?(n=5,p=new Array(4),d=e-3):(n=2,p=new Array(2),d=e):m.indexOf("android")!==-1?(n=2,p=new Array(2),d=e):(n=5,p=new Array(4),l&&(l.indexOf("mp4a.40.29")!==-1||l.indexOf("mp4a.40.5")!==-1)||!l&&e>=6?d=e-3:((l&&l.indexOf("mp4a.40.2")!==-1&&(e>=6&&v===1||/vivaldi/i.test(m))||!l&&v===1)&&(n=2,p=new Array(2)),d=e)),p[0]=n<<3,p[0]|=(e&14)>>1,p[1]|=(e&1)<<7,p[1]|=v<<3,n===5&&(p[1]|=(d&14)>>1,p[2]=(d&1)<<7,p[2]|=2<<2,p[3]=0),{config:p,samplerate:a[e],channelCount:v,codec:"mp4a.40."+n,manifestCodec:r}}function G(h,o){return h[o]===255&&(h[o+1]&246)===240}function I(h,o){return h[o+1]&1?7:9}function R(h,o){return(h[o+3]&3)<<11|h[o+4]<<3|(h[o+5]&224)>>>5}function L(h,o){return o+5<h.length}function _(h,o){return o+1<h.length&&G(h,o)}function T(h,o){return L(h,o)&&G(h,o)&&R(h,o)<=h.length-o}function g(h,o){if(_(h,o)){var s=I(h,o);if(o+s>=h.length)return!1;var l=R(h,o);if(l<=s)return!1;var n=o+l;return n===h.length||_(h,n)}return!1}function x(h,o,s,l,n){if(!h.samplerate){var d=D(o,s,l,n);if(!d)return;h.config=d.config,h.samplerate=d.samplerate,h.channelCount=d.channelCount,h.codec=d.codec,h.manifestCodec=d.manifestCodec,W.logger.log("parsed codec:"+h.codec+", rate:"+d.samplerate+", channels:"+d.channelCount)}}function b(h){return 1024*9e4/h}function f(h,o){var s=I(h,o);if(o+s<=h.length){var l=R(h,o)-s;if(l>0)return{headerLength:s,frameLength:l}}}function u(h,o,s,l,n){var d=b(h.samplerate),v=l+n*d,p=f(o,s),m;if(p){var r=p.frameLength,a=p.headerLength,e=a+r,c=Math.max(0,s+e-o.length);c?(m=new Uint8Array(e-a),m.set(o.subarray(s+a,o.length),0)):m=o.subarray(s+a,s+e);var E={unit:m,pts:v};return c||h.samples.push(E),{sample:E,length:e,missing:c}}var y=o.length-s;m=new Uint8Array(y),m.set(o.subarray(s,o.length),0);var k={unit:m,pts:v};return{sample:k,length:y,missing:-1}}},"./src/demux/base-audio-demuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>_,initPTSFn:()=>L});var W=w("./src/polyfills/number.ts"),P=w("./src/demux/id3.ts"),N=w("./src/types/demuxer.ts"),D=w("./src/demux/dummy-demuxed-track.ts"),G=w("./src/utils/mp4-tools.ts"),I=w("./src/utils/typed-array.ts"),R=function(){function T(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var g=T.prototype;return g.resetInitSegment=function(b,f,u,h){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},g.resetTimeStamp=function(b){this.initPTS=b,this.resetContiguity()},g.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},g.canParse=function(b,f){return!1},g.appendFrame=function(b,f,u){},g.demux=function(b,f){this.cachedData&&(b=(0,G.appendUint8Array)(this.cachedData,b),this.cachedData=null);var u=P.getID3Data(b,0),h=u?u.length:0,o,s=this._audioTrack,l=this._id3Track,n=u?P.getTimeStamp(u):void 0,d=b.length;for((this.basePTS===null||this.frameIndex===0&&(0,W.isFiniteNumber)(n))&&(this.basePTS=L(n,f,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),u&&u.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:N.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});h<d;){if(this.canParse(b,h)){var v=this.appendFrame(s,b,h);v?(this.frameIndex++,this.lastPTS=v.sample.pts,h+=v.length,o=h):h=d}else P.canParse(b,h)?(u=P.getID3Data(b,h),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:N.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),h+=u.length,o=h):h++;if(h===d&&o!==d){var p=(0,I.sliceUint8)(b,o);this.cachedData?this.cachedData=(0,G.appendUint8Array)(this.cachedData,p):this.cachedData=p}}return{audioTrack:s,videoTrack:(0,D.dummyTrack)(),id3Track:l,textTrack:(0,D.dummyTrack)()}},g.demuxSampleAes=function(b,f,u){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},g.flush=function(b){var f=this.cachedData;return f&&(this.cachedData=null,this.demux(f,0)),{audioTrack:this._audioTrack,videoTrack:(0,D.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,D.dummyTrack)()}},g.destroy=function(){},T}(),L=function(g,x,b){return(0,W.isFiniteNumber)(g)?g*90:x*9e4+(b||0)};const _=R},"./src/demux/chunk-cache.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>W});var W=function(){function N(){this.chunks=[],this.dataLength=0}var D=N.prototype;return D.push=function(I){this.chunks.push(I),this.dataLength+=I.length},D.flush=function(){var I=this.chunks,R=this.dataLength,L;if(I.length)I.length===1?L=I[0]:L=P(I,R);else return new Uint8Array(0);return this.reset(),L},D.reset=function(){this.chunks.length=0,this.dataLength=0},N}();function P(N,D){for(var G=new Uint8Array(D),I=0,R=0;R<N.length;R++){var L=N[R];G.set(L,I),I+=L.length}return G}},"./src/demux/dummy-demuxed-track.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{dummyTrack:()=>W});function W(P,N){return P===void 0&&(P=""),N===void 0&&(N=9e4),{type:P,id:-1,pid:-1,inputTimeScale:N,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>N});var W=w("./src/utils/logger.ts"),P=function(){function D(I){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=I,this.bytesAvailable=I.byteLength,this.word=0,this.bitsAvailable=0}var G=D.prototype;return G.loadWord=function(){var R=this.data,L=this.bytesAvailable,_=R.byteLength-L,T=new Uint8Array(4),g=Math.min(4,L);if(g===0)throw new Error("no bytes available");T.set(R.subarray(_,_+g)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=g*8,this.bytesAvailable-=g},G.skipBits=function(R){var L;R=Math.min(R,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>R?(this.word<<=R,this.bitsAvailable-=R):(R-=this.bitsAvailable,L=R>>3,R-=L<<3,this.bytesAvailable-=L,this.loadWord(),this.word<<=R,this.bitsAvailable-=R)},G.readBits=function(R){var L=Math.min(this.bitsAvailable,R),_=this.word>>>32-L;if(R>32&&W.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=L,this.bitsAvailable>0)this.word<<=L;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return L=R-L,L>0&&this.bitsAvailable?_<<L|this.readBits(L):_},G.skipLZ=function(){var R;for(R=0;R<this.bitsAvailable;++R)if((this.word&2147483648>>>R)!==0)return this.word<<=R,this.bitsAvailable-=R,R;return this.loadWord(),R+this.skipLZ()},G.skipUEG=function(){this.skipBits(1+this.skipLZ())},G.skipEG=function(){this.skipBits(1+this.skipLZ())},G.readUEG=function(){var R=this.skipLZ();return this.readBits(R+1)-1},G.readEG=function(){var R=this.readUEG();return 1&R?1+R>>>1:-1*(R>>>1)},G.readBoolean=function(){return this.readBits(1)===1},G.readUByte=function(){return this.readBits(8)},G.readUShort=function(){return this.readBits(16)},G.readUInt=function(){return this.readBits(32)},G.skipScalingList=function(R){for(var L=8,_=8,T,g=0;g<R;g++)_!==0&&(T=this.readEG(),_=(L+T+256)%256),L=_===0?L:_},G.readSPS=function(){var R=0,L=0,_=0,T=0,g,x,b,f=this.readUByte.bind(this),u=this.readBits.bind(this),h=this.readUEG.bind(this),o=this.readBoolean.bind(this),s=this.skipBits.bind(this),l=this.skipEG.bind(this),n=this.skipUEG.bind(this),d=this.skipScalingList.bind(this);f();var v=f();if(u(5),s(3),f(),n(),v===100||v===110||v===122||v===244||v===44||v===83||v===86||v===118||v===128){var p=h();if(p===3&&s(1),n(),n(),s(1),o())for(x=p!==3?8:12,b=0;b<x;b++)o()&&(b<6?d(16):d(64))}n();var m=h();if(m===0)h();else if(m===1)for(s(1),l(),l(),g=h(),b=0;b<g;b++)l();n(),s(1);var r=h(),a=h(),e=u(1);e===0&&s(1),s(1),o()&&(R=h(),L=h(),_=h(),T=h());var c=[1,1];if(o()&&o()){var E=f();switch(E){case 1:c=[1,1];break;case 2:c=[12,11];break;case 3:c=[10,11];break;case 4:c=[16,11];break;case 5:c=[40,33];break;case 6:c=[24,11];break;case 7:c=[20,11];break;case 8:c=[32,11];break;case 9:c=[80,33];break;case 10:c=[18,11];break;case 11:c=[15,11];break;case 12:c=[64,33];break;case 13:c=[160,99];break;case 14:c=[4,3];break;case 15:c=[3,2];break;case 16:c=[2,1];break;case 255:{c=[f()<<8|f(),f()<<8|f()];break}}}return{width:Math.ceil((r+1)*16-R*2-L*2),height:(2-e)*(a+1)*16-(e?2:4)*(_+T),pixelRatio:c}},G.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},D}();const N=P},"./src/demux/id3.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{canParse:()=>G,decodeFrame:()=>T,getID3Data:()=>N,getID3Frames:()=>_,getTimeStamp:()=>I,isFooter:()=>P,isHeader:()=>W,isTimeStampFrame:()=>R,testables:()=>h,utf8ArrayToStr:()=>u});var W=function(n,d){return d+10<=n.length&&(n[d]===73&&n[d+1]===68&&n[d+2]===51&&(n[d+3]<255&&n[d+4]<255&&(n[d+6]<128&&n[d+7]<128&&n[d+8]<128&&n[d+9]<128)))},P=function(n,d){return d+10<=n.length&&(n[d]===51&&n[d+1]===68&&n[d+2]===73&&(n[d+3]<255&&n[d+4]<255&&(n[d+6]<128&&n[d+7]<128&&n[d+8]<128&&n[d+9]<128)))},N=function(n,d){for(var v=d,p=0;W(n,d);){p+=10;var m=D(n,d+6);p+=m,P(n,d+10)&&(p+=10),d+=p}return p>0?n.subarray(v,v+p):void 0},D=function(n,d){var v=0;return v=(n[d]&127)<<21,v|=(n[d+1]&127)<<14,v|=(n[d+2]&127)<<7,v|=n[d+3]&127,v},G=function(n,d){return W(n,d)&&D(n,d+6)+10<=n.length-d},I=function(n){for(var d=_(n),v=0;v<d.length;v++){var p=d[v];if(R(p))return f(p)}return},R=function(n){return n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp"},L=function(n){var d=String.fromCharCode(n[0],n[1],n[2],n[3]),v=D(n,4),p=10;return{type:d,size:v,data:n.subarray(p,p+v)}},_=function(n){for(var d=0,v=[];W(n,d);){var p=D(n,d+6);d+=10;for(var m=d+p;d+8<m;){var r=L(n.subarray(d)),a=T(r);a&&v.push(a),d+=r.size+10}P(n,d)&&(d+=10)}return v},T=function(n){return n.type==="PRIV"?g(n):n.type[0]==="W"?b(n):x(n)},g=function(n){if(n.size<2)return;var d=u(n.data,!0),v=new Uint8Array(n.data.subarray(d.length+1));return{key:n.type,info:d,data:v.buffer}},x=function(n){if(n.size<2)return;if(n.type==="TXXX"){var d=1,v=u(n.data.subarray(d),!0);d+=v.length+1;var p=u(n.data.subarray(d));return{key:n.type,info:v,data:p}}var m=u(n.data.subarray(1));return{key:n.type,data:m}},b=function(n){if(n.type==="WXXX"){if(n.size<2)return;var d=1,v=u(n.data.subarray(d),!0);d+=v.length+1;var p=u(n.data.subarray(d));return{key:n.type,info:v,data:p}}var m=u(n.data);return{key:n.type,data:m}},f=function(n){if(n.data.byteLength===8){var d=new Uint8Array(n.data),v=d[3]&1,p=(d[4]<<23)+(d[5]<<15)+(d[6]<<7)+d[7];return p/=45,v&&(p+=4772185884e-2),Math.round(p)}return},u=function(n,d){d===void 0&&(d=!1);var v=s();if(v){var p=v.decode(n);if(d){var m=p.indexOf("\0");return m!==-1?p.substring(0,m):p}return p.replace(/\0/g,"")}for(var r=n.length,a,e,c,E="",y=0;y<r;){if(a=n[y++],a===0&&d)return E;if(a===0||a===3)continue;switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:E+=String.fromCharCode(a);break;case 12:case 13:e=n[y++],E+=String.fromCharCode((a&31)<<6|e&63);break;case 14:e=n[y++],c=n[y++],E+=String.fromCharCode((a&15)<<12|(e&63)<<6|(c&63)<<0);break;default:}}return E},h={decodeTextFrame:x},o;function s(){return!o&&typeof self.TextDecoder!="undefined"&&(o=new self.TextDecoder("utf-8")),o}},"./src/demux/mp3demuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>L});var W=w("./src/demux/base-audio-demuxer.ts"),P=w("./src/demux/id3.ts"),N=w("./src/utils/logger.ts"),D=w("./src/demux/mpegaudio.ts");function G(_,T){_.prototype=Object.create(T.prototype),_.prototype.constructor=_,I(_,T)}function I(_,T){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(x,b){return x.__proto__=b,x},I(_,T)}var R=function(_){G(T,_);function T(){return _.apply(this,arguments)||this}var g=T.prototype;return g.resetInitSegment=function(b,f,u,h){_.prototype.resetInitSegment.call(this,b,f,u,h),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:f,duration:h,inputTimeScale:9e4,dropped:0}},T.probe=function(b){if(!b)return!1;for(var f=P.getID3Data(b,0)||[],u=f.length,h=b.length;u<h;u++)if(D.probe(b,u))return N.logger.log("MPEG Audio sync word found !"),!0;return!1},g.canParse=function(b,f){return D.canParse(b,f)},g.appendFrame=function(b,f,u){return this.basePTS===null?void 0:D.appendFrame(b,f,u,this.basePTS,this.frameIndex)},T}(W.default);const L=R},"./src/demux/mp4demuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>R});var W=w("./src/polyfills/number.ts"),P=w("./src/types/demuxer.ts"),N=w("./src/utils/mp4-tools.ts"),D=w("./src/demux/dummy-demuxed-track.ts"),G=/\/emsg[-/]ID3/i,I=function(){function L(T,g){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=g}var _=L.prototype;return _.resetTimeStamp=function(){},_.resetInitSegment=function(g,x,b,f){var u=this.videoTrack=(0,D.dummyTrack)("video",1),h=this.audioTrack=(0,D.dummyTrack)("audio",1),o=this.txtTrack=(0,D.dummyTrack)("text",1);if(this.id3Track=(0,D.dummyTrack)("id3",1),this.timeOffset=0,!g||!g.byteLength)return;var s=(0,N.parseInitSegment)(g);if(s.video){var l=s.video,n=l.id,d=l.timescale,v=l.codec;u.id=n,u.timescale=o.timescale=d,u.codec=v}if(s.audio){var p=s.audio,m=p.id,r=p.timescale,a=p.codec;h.id=m,h.timescale=r,h.codec=a}o.id=N.RemuxerTrackIdConfig.text,u.sampleDuration=0,u.duration=h.duration=f},_.resetContiguity=function(){},L.probe=function(g){return g=g.length>16384?g.subarray(0,16384):g,(0,N.findBox)(g,["moof"]).length>0},_.demux=function(g,x){this.timeOffset=x;var b=g,f=this.videoTrack,u=this.txtTrack;if(this.config.progressive){this.remainderData&&(b=(0,N.appendUint8Array)(this.remainderData,g));var h=(0,N.segmentValidRange)(b);this.remainderData=h.remainder,f.samples=h.valid||new Uint8Array}else f.samples=b;var o=this.extractID3Track(f,x);return u.samples=(0,N.parseSamples)(x,f),{videoTrack:f,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},_.flush=function(){var g=this.timeOffset,x=this.videoTrack,b=this.txtTrack;x.samples=this.remainderData||new Uint8Array,this.remainderData=null;var f=this.extractID3Track(x,this.timeOffset);return b.samples=(0,N.parseSamples)(g,x),{videoTrack:x,audioTrack:(0,D.dummyTrack)(),id3Track:f,textTrack:(0,D.dummyTrack)()}},_.extractID3Track=function(g,x){var b=this.id3Track;if(g.samples.length){var f=(0,N.findBox)(g.samples,["emsg"]);f&&f.forEach(function(u){var h=(0,N.parseEmsg)(u);if(G.test(h.schemeIdUri)){var o=(0,W.isFiniteNumber)(h.presentationTime)?h.presentationTime/h.timeScale:x+h.presentationTimeDelta/h.timeScale,s=h.eventDuration===4294967295?Number.POSITIVE_INFINITY:h.eventDuration/h.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);var l=h.payload;b.samples.push({data:l,len:l.byteLength,dts:o,pts:o,type:P.MetadataSchema.emsg,duration:s})}})}return b},_.demuxSampleAes=function(g,x,b){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},_.destroy=function(){},L}();const R=I},"./src/demux/mpegaudio.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{appendFrame:()=>I,canParse:()=>T,isHeader:()=>_,isHeaderPattern:()=>L,parseHeader:()=>R,probe:()=>g});var W=null,P=[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],N=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],D=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],G=[0,1,1,4];function I(x,b,f,u,h){if(f+24>b.length)return;var o=R(b,f);if(o&&f+o.frameLength<=b.length){var s=o.samplesPerFrame*9e4/o.sampleRate,l=u+h*s,n={unit:b.subarray(f,f+o.frameLength),pts:l,dts:l};return x.config=[],x.channelCount=o.channelCount,x.samplerate=o.sampleRate,x.samples.push(n),{sample:n,length:o.frameLength,missing:0}}}function R(x,b){var f=x[b+1]>>3&3,u=x[b+1]>>1&3,h=x[b+2]>>4&15,o=x[b+2]>>2&3;if(f!==1&&h!==0&&h!==15&&o!==3){var s=x[b+2]>>1&1,l=x[b+3]>>6,n=f===3?3-u:u===3?3:4,d=P[n*14+h-1]*1e3,v=f===3?0:f===2?1:2,p=N[v*3+o],m=l===3?1:2,r=D[f][u],a=G[u],e=r*8*a,c=Math.floor(r*d/p+s)*a;if(W===null){var E=navigator.userAgent||"",y=E.match(/Chrome\/(\d+)/i);W=y?parseInt(y[1]):0}var k=!!W&&W<=87;return k&&u===2&&d>=224e3&&l===0&&(x[b+3]=x[b+3]|128),{sampleRate:p,channelCount:m,frameLength:c,samplesPerFrame:e}}}function L(x,b){return x[b]===255&&(x[b+1]&224)===224&&(x[b+1]&6)!==0}function _(x,b){return b+1<x.length&&L(x,b)}function T(x,b){var f=4;return L(x,b)&&f<=x.length-b}function g(x,b){if(b+1<x.length&&L(x,b)){var f=4,u=R(x,b),h=f;u!=null&&u.frameLength&&(h=u.frameLength);var o=b+h;return o===x.length||_(x,o)}return!1}},"./src/demux/sample-aes.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>D});var W=w("./src/crypt/decrypter.ts"),P=w("./src/utils/mp4-tools.ts"),N=function(){function G(R,L,_){this.keyData=void 0,this.decrypter=void 0,this.keyData=_,this.decrypter=new W.default(L,{removePKCS7Padding:!1})}var I=G.prototype;return I.decryptBuffer=function(L){return this.decrypter.decrypt(L,this.keyData.key.buffer,this.keyData.iv.buffer)},I.decryptAacSample=function(L,_,T){var g=this,x=L[_].unit;if(x.length<=16)return;var b=x.subarray(16,x.length-x.length%16),f=b.buffer.slice(b.byteOffset,b.byteOffset+b.length);this.decryptBuffer(f).then(function(u){var h=new Uint8Array(u);x.set(h,16),g.decrypter.isSync()||g.decryptAacSamples(L,_+1,T)})},I.decryptAacSamples=function(L,_,T){for(;;_++){if(_>=L.length){T();return}if(L[_].unit.length<32)continue;if(this.decryptAacSample(L,_,T),!this.decrypter.isSync())return}},I.getAvcEncryptedData=function(L){for(var _=Math.floor((L.length-48)/160)*16+16,T=new Int8Array(_),g=0,x=32;x<L.length-16;x+=160,g+=16)T.set(L.subarray(x,x+16),g);return T},I.getAvcDecryptedUnit=function(L,_){for(var T=new Uint8Array(_),g=0,x=32;x<L.length-16;x+=160,g+=16)L.set(T.subarray(g,g+16),x);return L},I.decryptAvcSample=function(L,_,T,g,x){var b=this,f=(0,P.discardEPB)(x.data),u=this.getAvcEncryptedData(f);this.decryptBuffer(u.buffer).then(function(h){x.data=b.getAvcDecryptedUnit(f,h),b.decrypter.isSync()||b.decryptAvcSamples(L,_,T+1,g)})},I.decryptAvcSamples=function(L,_,T,g){if(L instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;_++,T=0){if(_>=L.length){g();return}for(var x=L[_].units;!(T>=x.length);T++){var b=x[T];if(b.data.length<=48||b.type!==1&&b.type!==5)continue;if(this.decryptAvcSample(L,_,T,g,b),!this.decrypter.isSync())return}}},G}();const D=N},"./src/demux/transmuxer-interface.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>T});var W=w("./src/demux/webworkify-webpack.js"),P=w("./src/events.ts"),N=w("./src/demux/transmuxer.ts"),D=w("./src/utils/logger.ts"),G=w("./src/errors.ts"),I=w("./src/utils/mediasource-helper.ts"),R=w("./node_modules/eventemitter3/index.js"),L=w.n(R),_=(0,I.getMediaSource)()||{isTypeSupported:function(){return!1}},T=function(){function g(b,f,u,h){var o=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var s=b.config;this.hls=b,this.id=f,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=u,this.onFlush=h;var l=function(m,r){r=r||{},r.frag=o.frag,r.id=o.id,o.hls.trigger(m,r)};this.observer=new R.EventEmitter,this.observer.on(P.Events.FRAG_DECRYPTED,l),this.observer.on(P.Events.ERROR,l);var n={mp4:_.isTypeSupported("video/mp4"),mpeg:_.isTypeSupported("audio/mpeg"),mp3:_.isTypeSupported('audio/mp4; codecs="mp3"')},d=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){D.logger.log("demuxing in webworker");var v;try{v=this.worker=(0,W.default)("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),v.addEventListener("message",this.onwmsg),v.onerror=function(p){o.useWorker=!1,D.logger.warn("Exception in webworker, fallback to inline"),o.hls.trigger(P.Events.ERROR,{type:G.ErrorTypes.OTHER_ERROR,details:G.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(p.message+" ("+p.filename+":"+p.lineno+")")})},v.postMessage({cmd:"init",typeSupported:n,vendor:d,id:f,config:JSON.stringify(s)})}catch(p){D.logger.warn("Error in worker:",p),D.logger.error("Error while initializing DemuxerWorker, fallback to inline"),v&&self.URL.revokeObjectURL(v.objectURL),this.transmuxer=new N.default(this.observer,n,s,d,f),this.worker=null}}else this.transmuxer=new N.default(this.observer,n,s,d,f)}var x=g.prototype;return x.destroy=function(){var f=this.worker;if(f)f.removeEventListener("message",this.onwmsg),f.terminate(),this.worker=null,this.onwmsg=void 0;else{var u=this.transmuxer;u&&(u.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},x.push=function(f,u,h,o,s,l,n,d,v,p){var m,r,a=this;v.transmuxing.start=self.performance.now();var e=this.transmuxer,c=this.worker,E=l?l.start:s.start,y=s.decryptdata,k=this.frag,M=!(k&&s.cc===k.cc),O=!(k&&v.level===k.level),U=k?v.sn-k.sn:-1,F=this.part?v.part-this.part.index:-1,H=U===0&&v.id>1&&v.id===(k==null?void 0:k.stats.chunkCount),Y=!O&&(U===1||U===0&&(F===1||H&&F<=0)),Q=self.performance.now();(O||U||s.stats.parsing.start===0)&&(s.stats.parsing.start=Q),l&&(F||!Y)&&(l.stats.parsing.start=Q);var z=!(k&&((m=s.initSegment)===null||m===void 0?void 0:m.url)===((r=k.initSegment)===null||r===void 0?void 0:r.url)),ee=new N.TransmuxState(M,Y,d,O,E,z);if(!Y||M||z){D.logger.log("[transmuxer-interface, "+s.type+"]: Starting new transmux session for sn: "+v.sn+" p: "+v.part+" level: "+v.level+" id: "+v.id+`
discontinuity: `+M+`
trackSwitch: `+O+`
contiguous: `+Y+`
accurateTimeOffset: `+d+`
timeOffset: `+E+`
initSegmentChange: `+z);var J=new N.TransmuxConfig(h,o,u,n,p);this.configureTransmuxer(J)}if(this.frag=s,this.part=l,c)c.postMessage({cmd:"demux",data:f,decryptdata:y,chunkMeta:v,state:ee},f instanceof ArrayBuffer?[f]:[]);else if(e){var X=e.push(f,y,v,ee);(0,N.isPromise)(X)?(e.async=!0,X.then(function(oe){a.handleTransmuxComplete(oe)}).catch(function(oe){a.transmuxerError(oe,v,"transmuxer-interface push error")})):(e.async=!1,this.handleTransmuxComplete(X))}},x.flush=function(f){var u=this;f.transmuxing.start=self.performance.now();var h=this.transmuxer,o=this.worker;if(o)o.postMessage({cmd:"flush",chunkMeta:f});else if(h){var s=h.flush(f),l=(0,N.isPromise)(s);l||h.async?((0,N.isPromise)(s)||(s=Promise.resolve(s)),s.then(function(n){u.handleFlushResult(n,f)}).catch(function(n){u.transmuxerError(n,f,"transmuxer-interface flush error")})):this.handleFlushResult(s,f)}},x.transmuxerError=function(f,u,h){if(!this.hls)return;this.hls.trigger(P.Events.ERROR,{type:G.ErrorTypes.MEDIA_ERROR,details:G.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:u,fatal:!1,error:f,err:f,reason:h})},x.handleFlushResult=function(f,u){var h=this;f.forEach(function(o){h.handleTransmuxComplete(o)}),this.onFlush(u)},x.onWorkerMessage=function(f){var u=f.data,h=this.hls;switch(u.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(u.data);break}case"flush":{this.onFlush(u.data);break}case"workerLog":D.logger[u.data.logType]&&D.logger[u.data.logType](u.data.message);break;default:{u.data=u.data||{},u.data.frag=this.frag,u.data.id=this.id,h.trigger(u.event,u.data);break}}},x.configureTransmuxer=function(f){var u=this.worker,h=this.transmuxer;u?u.postMessage({cmd:"configure",config:f}):h&&h.configure(f)},x.handleTransmuxComplete=function(f){f.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(f)},g}()},"./src/demux/transmuxer-worker.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>R});var W=w("./src/demux/transmuxer.ts"),P=w("./src/events.ts"),N=w("./src/utils/logger.ts"),D=w("./node_modules/eventemitter3/index.js"),G=w.n(D),I=w("./src/errors.ts");function R(x){var b=new D.EventEmitter,f=function(o,s){x.postMessage({event:o,data:s})};b.on(P.Events.FRAG_DECRYPTED,f),b.on(P.Events.ERROR,f);var u=function(){var o=function(n){var d=function(p){f("workerLog",{logType:n,message:p})};N.logger[n]=d};for(var s in N.logger)o(s)};x.addEventListener("message",function(h){var o=h.data;switch(o.cmd){case"init":{var s=JSON.parse(o.config);x.transmuxer=new W.default(b,o.typeSupported,s,o.vendor,o.id),(0,N.enableLogs)(s.debug,o.id),u(),f("init",null);break}case"configure":{x.transmuxer.configure(o.config);break}case"demux":{var l=x.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);(0,W.isPromise)(l)?(x.transmuxer.async=!0,l.then(function(p){L(x,p)}).catch(function(p){f(P.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:o.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker push error"})})):(x.transmuxer.async=!1,L(x,l));break}case"flush":{var n=o.chunkMeta,d=x.transmuxer.flush(n),v=(0,W.isPromise)(d);v||x.transmuxer.async?((0,W.isPromise)(d)||(d=Promise.resolve(d)),d.then(function(p){T(x,p,n)}).catch(function(p){f(P.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:o.chunkMeta,fatal:!1,error:p,err:p,reason:"transmuxer-worker flush error"})})):T(x,d,n);break}default:break}})}function L(x,b){if(g(b.remuxResult))return!1;var f=[],u=b.remuxResult,h=u.audio,o=u.video;return h&&_(f,h),o&&_(f,o),x.postMessage({event:"transmuxComplete",data:b},f),!0}function _(x,b){b.data1&&x.push(b.data1.buffer),b.data2&&x.push(b.data2.buffer)}function T(x,b,f){var u=b.reduce(function(h,o){return L(x,o)||h},!1);u||x.postMessage({event:"transmuxComplete",data:b[0]}),x.postMessage({event:"flush",data:f})}function g(x){return!x.audio&&!x.video&&!x.text&&!x.id3&&!x.initSegment}},"./src/demux/transmuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{TransmuxConfig:()=>o,TransmuxState:()=>s,default:()=>b,isPromise:()=>h});var W=w("./src/events.ts"),P=w("./src/errors.ts"),N=w("./src/crypt/decrypter.ts"),D=w("./src/demux/aacdemuxer.ts"),G=w("./src/demux/mp4demuxer.ts"),I=w("./src/demux/tsdemuxer.ts"),R=w("./src/demux/mp3demuxer.ts"),L=w("./src/remux/mp4-remuxer.ts"),_=w("./src/remux/passthrough-remuxer.ts"),T=w("./src/utils/logger.ts"),g;try{g=self.performance.now.bind(self.performance)}catch(l){T.logger.debug("Unable to use Performance API on this environment"),g=self.Date.now}var x=[{demux:G.default,remux:_.default},{demux:I.default,remux:L.default},{demux:D.default,remux:L.default},{demux:R.default,remux:L.default}],b=function(){function l(d,v,p,m,r){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=d,this.typeSupported=v,this.config=p,this.vendor=m,this.id=r}var n=l.prototype;return n.configure=function(v){this.transmuxConfig=v,this.decrypter&&this.decrypter.reset()},n.push=function(v,p,m,r){var a=this,e=m.transmuxing;e.executeStart=g();var c=new Uint8Array(v),E=this.currentTransmuxState,y=this.transmuxConfig;r&&(this.currentTransmuxState=r);var k=r||E,M=k.contiguous,O=k.discontinuity,U=k.trackSwitch,F=k.accurateTimeOffset,H=k.timeOffset,Y=k.initSegmentChange,Q=y.audioCodec,z=y.videoCodec,ee=y.defaultInitPts,J=y.duration,X=y.initSegmentData,oe=f(c,p);if(oe&&oe.method==="AES-128"){var le=this.getDecrypter();if(le.isSync()){var me=le.softwareDecrypt(c,oe.key.buffer,oe.iv.buffer),Ae=m.part>-1;if(Ae&&(me=le.flush()),!me)return e.executeEnd=g(),u(m);c=new Uint8Array(me)}else return this.decryptionPromise=le.webCryptoDecrypt(c,oe.key.buffer,oe.iv.buffer).then(function(ye){var Ee=a.push(ye,null,m);return a.decryptionPromise=null,Ee}),this.decryptionPromise}var ge=this.needsProbing(O,U);ge&&this.configureTransmuxer(c),(O||U||Y||ge)&&this.resetInitSegment(X,Q,z,J,p),(O||Y||ge)&&this.resetInitialTimestamp(ee),M||this.resetContiguity();var ae=this.transmux(c,oe,H,F,m),ue=this.currentTransmuxState;return ue.contiguous=!0,ue.discontinuity=!1,ue.trackSwitch=!1,e.executeEnd=g(),ae},n.flush=function(v){var p=this,m=v.transmuxing;m.executeStart=g();var r=this.decrypter,a=this.currentTransmuxState,e=this.decryptionPromise;if(e)return e.then(function(){return p.flush(v)});var c=[],E=a.timeOffset;if(r){var y=r.flush();y&&c.push(this.push(y,null,v))}var k=this.demuxer,M=this.remuxer;if(!k||!M)return this.observer.emit(W.Events.ERROR,W.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),m.executeEnd=g(),[u(v)];var O=k.flush(E);return h(O)?O.then(function(U){return p.flushRemux(c,U,v),c}):(this.flushRemux(c,O,v),c)},n.flushRemux=function(v,p,m){var r=p.audioTrack,a=p.videoTrack,e=p.id3Track,c=p.textTrack,E=this.currentTransmuxState,y=E.accurateTimeOffset,k=E.timeOffset;T.logger.log("[transmuxer.ts]: Flushed fragment "+m.sn+(m.part>-1?" p: "+m.part:"")+" of level "+m.level);var M=this.remuxer.remux(r,a,e,c,k,y,!0,this.id);v.push({remuxResult:M,chunkMeta:m}),m.transmuxing.executeEnd=g()},n.resetInitialTimestamp=function(v){var p=this.demuxer,m=this.remuxer;if(!p||!m)return;p.resetTimeStamp(v),m.resetTimeStamp(v)},n.resetContiguity=function(){var v=this.demuxer,p=this.remuxer;if(!v||!p)return;v.resetContiguity(),p.resetNextTimestamp()},n.resetInitSegment=function(v,p,m,r,a){var e=this.demuxer,c=this.remuxer;if(!e||!c)return;e.resetInitSegment(v,p,m,r),c.resetInitSegment(v,p,m,a)},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(v,p,m,r,a){var e;return p&&p.method==="SAMPLE-AES"?e=this.transmuxSampleAes(v,p,m,r,a):e=this.transmuxUnencrypted(v,m,r,a),e},n.transmuxUnencrypted=function(v,p,m,r){var a=this.demuxer.demux(v,p,!1,!this.config.progressive),e=a.audioTrack,c=a.videoTrack,E=a.id3Track,y=a.textTrack,k=this.remuxer.remux(e,c,E,y,p,m,!1,this.id);return{remuxResult:k,chunkMeta:r}},n.transmuxSampleAes=function(v,p,m,r,a){var e=this;return this.demuxer.demuxSampleAes(v,p,m).then(function(c){var E=e.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,m,r,!1,e.id);return{remuxResult:E,chunkMeta:a}})},n.configureTransmuxer=function(v){for(var p=this.config,m=this.observer,r=this.typeSupported,a=this.vendor,e,c=0,E=x.length;c<E;c++)if(x[c].demux.probe(v)){e=x[c];break}e||(T.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),e={demux:G.default,remux:_.default});var y=this.demuxer,k=this.remuxer,M=e.remux,O=e.demux;(!k||!(k instanceof M))&&(this.remuxer=new M(m,p,r,a)),(!y||!(y instanceof O))&&(this.demuxer=new O(m,p,r),this.probe=O.probe)},n.needsProbing=function(v,p){return!this.demuxer||!this.remuxer||v||p},n.getDecrypter=function(){var v=this.decrypter;return v||(v=this.decrypter=new N.default(this.config)),v},l}();function f(l,n){var d=null;return l.byteLength>0&&n!=null&&n.key!=null&&n.iv!==null&&n.method!=null&&(d=n),d}var u=function(n){return{remuxResult:{},chunkMeta:n}};function h(l){return"then"in l&&l.then instanceof Function}var o=function(n,d,v,p,m){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=n,this.videoCodec=d,this.initSegmentData=v,this.duration=p,this.defaultInitPts=m},s=function(n,d,v,p,m,r){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=n,this.contiguous=d,this.accurateTimeOffset=v,this.trackSwitch=p,this.timeOffset=m,this.initSegmentChange=r}},"./src/demux/tsdemuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>l});var W=w("./src/demux/adts.ts"),P=w("./src/demux/mpegaudio.ts"),N=w("./src/demux/exp-golomb.ts"),D=w("./src/demux/sample-aes.ts"),G=w("./src/events.ts"),I=w("./src/utils/mp4-tools.ts"),R=w("./src/utils/logger.ts"),L=w("./src/errors.ts"),_=w("./src/types/demuxer.ts");function T(){return T=Object.assign?Object.assign.bind():function(n){for(var d=1;d<arguments.length;d++){var v=arguments[d];for(var p in v)Object.prototype.hasOwnProperty.call(v,p)&&(n[p]=v[p])}return n},T.apply(this,arguments)}var g=188,x=function(){function n(v,p,m){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=v,this.config=p,this.typeSupported=m}n.probe=function(p){var m=n.syncOffset(p);return m>0&&R.logger.warn("MPEG2-TS detected but first sync word found @ offset "+m),m!==-1},n.syncOffset=function(p){for(var m=p.length,r=Math.min(g*5,p.length-g)+1,a=0;a<r;){for(var e=!1,c=a;c<m&&p[c]===71;c+=g)if(!e&&f(p,c)===0&&(e=!0),e&&c+g>r)return a;a++}return-1},n.createTrack=function(p,m){return{container:p==="video"||p==="audio"?"video/mp2t":void 0,type:p,id:I.RemuxerTrackIdConfig[p],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:p==="audio"?m:void 0}};var d=n.prototype;return d.resetInitSegment=function(p,m,r,a){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=n.createTrack("video"),this._audioTrack=n.createTrack("audio",a),this._id3Track=n.createTrack("id3"),this._txtTrack=n.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=m,this.videoCodec=r,this._duration=a},d.resetTimeStamp=function(){},d.resetContiguity=function(){var p=this._audioTrack,m=this._avcTrack,r=this._id3Track;p&&(p.pesData=null),m&&(m.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},d.demux=function(p,m,r,a){r===void 0&&(r=!1),a===void 0&&(a=!1),r||(this.sampleAes=null);var e,c=this._avcTrack,E=this._audioTrack,y=this._id3Track,k=this._txtTrack,M=c.pid,O=c.pesData,U=E.pid,F=y.pid,H=E.pesData,Y=y.pesData,Q=null,z=this.pmtParsed,ee=this._pmtId,J=p.length;if(this.remainderData&&(p=(0,I.appendUint8Array)(this.remainderData,p),J=p.length,this.remainderData=null),J<g&&!a)return this.remainderData=p,{audioTrack:E,videoTrack:c,id3Track:y,textTrack:k};var X=Math.max(0,n.syncOffset(p));J-=(J-X)%g,J<p.byteLength&&!a&&(this.remainderData=new Uint8Array(p.buffer,J,p.buffer.byteLength-J));for(var oe=0,le=X;le<J;le+=g)if(p[le]===71){var me=!!(p[le+1]&64),Ae=f(p,le),ge=(p[le+3]&48)>>4,ae=void 0;if(ge>1){if(ae=le+5+p[le+4],ae===le+g)continue}else ae=le+4;switch(Ae){case M:me&&(O&&(e=o(O))&&this.parseAVCPES(c,k,e,!1),O={data:[],size:0}),O&&(O.data.push(p.subarray(ae,le+g)),O.size+=le+g-ae);break;case U:if(me){if(H&&(e=o(H)))switch(E.segmentCodec){case"aac":this.parseAACPES(E,e);break;case"mp3":this.parseMPEGPES(E,e);break}H={data:[],size:0}}H&&(H.data.push(p.subarray(ae,le+g)),H.size+=le+g-ae);break;case F:me&&(Y&&(e=o(Y))&&this.parseID3PES(y,e),Y={data:[],size:0}),Y&&(Y.data.push(p.subarray(ae,le+g)),Y.size+=le+g-ae);break;case 0:me&&(ae+=p[ae]+1),ee=this._pmtId=u(p,ae);break;case ee:{me&&(ae+=p[ae]+1);var ue=h(p,ae,this.typeSupported,r);M=ue.avc,M>0&&(c.pid=M),U=ue.audio,U>0&&(E.pid=U,E.segmentCodec=ue.segmentCodec),F=ue.id3,F>0&&(y.pid=F),Q!==null&&!z&&(R.logger.warn("MPEG-TS PMT found at "+le+" after unknown PID '"+Q+"'. Backtracking to sync byte @"+X+" to parse all TS packets."),Q=null,le=X-188),z=this.pmtParsed=!0;break}case 17:case 8191:break;default:Q=Ae;break}}else oe++;oe>0&&this.observer.emit(G.Events.ERROR,G.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+oe+" TS packet/s that do not start with 0x47"}),c.pesData=O,E.pesData=H,y.pesData=Y;var ye={audioTrack:E,videoTrack:c,id3Track:y,textTrack:k};return a&&this.extractRemainingSamples(ye),ye},d.flush=function(){var p=this.remainderData;this.remainderData=null;var m;return p?m=this.demux(p,-1,!1,!0):m={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(m),this.sampleAes?this.decrypt(m,this.sampleAes):m},d.extractRemainingSamples=function(p){var m=p.audioTrack,r=p.videoTrack,a=p.id3Track,e=p.textTrack,c=r.pesData,E=m.pesData,y=a.pesData,k;if(c&&(k=o(c))?(this.parseAVCPES(r,e,k,!0),r.pesData=null):r.pesData=c,E&&(k=o(E))){switch(m.segmentCodec){case"aac":this.parseAACPES(m,k);break;case"mp3":this.parseMPEGPES(m,k);break}m.pesData=null}else E!=null&&E.size&&R.logger.log("last AAC PES packet truncated,might overlap between fragments"),m.pesData=E;y&&(k=o(y))?(this.parseID3PES(a,k),a.pesData=null):a.pesData=y},d.demuxSampleAes=function(p,m,r){var a=this.demux(p,r,!0,!this.config.progressive),e=this.sampleAes=new D.default(this.observer,this.config,m);return this.decrypt(a,e)},d.decrypt=function(p,m){return new Promise(function(r){var a=p.audioTrack,e=p.videoTrack;a.samples&&a.segmentCodec==="aac"?m.decryptAacSamples(a.samples,0,function(){e.samples?m.decryptAvcSamples(e.samples,0,0,function(){r(p)}):r(p)}):e.samples&&m.decryptAvcSamples(e.samples,0,0,function(){r(p)})})},d.destroy=function(){this._duration=0},d.parseAVCPES=function(p,m,r,a){var e=this,c=this.parseAVCNALu(p,r.data),E=!1,y=this.avcSample,k,M=!1;r.data=null,y&&c.length&&!p.audFound&&(s(y,p),y=this.avcSample=b(!1,r.pts,r.dts,"")),c.forEach(function(O){switch(O.type){case 1:{k=!0,y||(y=e.avcSample=b(!0,r.pts,r.dts,"")),E&&(y.debug+="NDR "),y.frame=!0;var U=O.data;if(M&&U.length>4){var F=new N.default(U).readSliceType();(F===2||F===4||F===7||F===9)&&(y.key=!0)}break}case 5:k=!0,y||(y=e.avcSample=b(!0,r.pts,r.dts,"")),E&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{k=!0,E&&y&&(y.debug+="SEI "),(0,I.parseSEIMessageFromNALu)(O.data,1,r.pts,m.samples);break}case 7:if(k=!0,M=!0,E&&y&&(y.debug+="SPS "),!p.sps){var H=new N.default(O.data),Y=H.readSPS();p.width=Y.width,p.height=Y.height,p.pixelRatio=Y.pixelRatio,p.sps=[O.data],p.duration=e._duration;for(var Q=O.data.subarray(1,4),z="avc1.",ee=0;ee<3;ee++){var J=Q[ee].toString(16);J.length<2&&(J="0"+J),z+=J}p.codec=z}break;case 8:k=!0,E&&y&&(y.debug+="PPS "),p.pps||(p.pps=[O.data]);break;case 9:k=!1,p.audFound=!0,y&&s(y,p),y=e.avcSample=b(!1,r.pts,r.dts,E?"AUD ":"");break;case 12:k=!0;break;default:k=!1,y&&(y.debug+="unknown NAL "+O.type+" ");break}if(y&&k){var X=y.units;X.push(O)}}),a&&y&&(s(y,p),this.avcSample=null)},d.getLastNalUnit=function(p){var m,r=this.avcSample,a;if((!r||r.units.length===0)&&(r=p[p.length-1]),(m=r)!==null&&m!==void 0&&m.units){var e=r.units;a=e[e.length-1]}return a},d.parseAVCNALu=function(p,m){var r=m.byteLength,a=p.naluState||0,e=a,c=[],E=0,y,k,M,O=-1,U=0;for(a===-1&&(O=0,U=m[0]&31,a=0,E=1);E<r;){if(y=m[E++],!a){a=y?0:1;continue}if(a===1){a=y?0:2;continue}if(!y)a=3;else if(y===1){if(O>=0){var F={data:m.subarray(O,E-a-1),type:U};c.push(F)}else{var H=this.getLastNalUnit(p.samples);if(H&&(e&&E<=4-e&&(H.state&&(H.data=H.data.subarray(0,H.data.byteLength-e))),k=E-a-1,k>0)){var Y=new Uint8Array(H.data.byteLength+k);Y.set(H.data,0),Y.set(m.subarray(0,k),H.data.byteLength),H.data=Y,H.state=0}}E<r?(M=m[E]&31,O=E,U=M,a=0):a=-1}else a=0}if(O>=0&&a>=0){var Q={data:m.subarray(O,r),type:U,state:a};c.push(Q)}if(c.length===0){var z=this.getLastNalUnit(p.samples);if(z){var ee=new Uint8Array(z.data.byteLength+m.byteLength);ee.set(z.data,0),ee.set(m,z.data.byteLength),z.data=ee}}return p.naluState=a,c},d.parseAACPES=function(p,m){var r=0,a=this.aacOverFlow,e=m.data;if(a){this.aacOverFlow=null;var c=a.missing,E=a.sample.unit.byteLength;if(c===-1){var y=new Uint8Array(E+e.byteLength);y.set(a.sample.unit,0),y.set(e,E),e=y}else{var k=E-c;a.sample.unit.set(e.subarray(0,c),k),p.samples.push(a.sample),r=a.missing}}var M,O;for(M=r,O=e.length;M<O-1&&!W.isHeader(e,M);M++);if(M!==r){var U,F;if(M<O-1?(U="AAC PES did not start with ADTS header,offset:"+M,F=!1):(U="no ADTS header found in AAC PES",F=!0),R.logger.warn("parsing error:"+U),this.observer.emit(G.Events.ERROR,G.Events.ERROR,{type:L.ErrorTypes.MEDIA_ERROR,details:L.ErrorDetails.FRAG_PARSING_ERROR,fatal:F,reason:U}),F)return}W.initTrackConfig(p,this.observer,e,M,this.audioCodec);var H;if(m.pts!==void 0)H=m.pts;else if(a){var Y=W.getFrameDuration(p.samplerate);H=a.sample.pts+Y}else{R.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var Q=0,z;M<O;)if(z=W.appendFrame(p,e,M,H,Q),M+=z.length,z.missing){this.aacOverFlow=z;break}else for(Q++;M<O-1&&!W.isHeader(e,M);M++);},d.parseMPEGPES=function(p,m){var r=m.data,a=r.length,e=0,c=0,E=m.pts;if(E===void 0){R.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<a;)if(P.isHeader(r,c)){var y=P.appendFrame(p,r,c,E,e);if(y)c+=y.length,e++;else break}else c++},d.parseID3PES=function(p,m){if(m.pts===void 0){R.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=T({},m,{type:this._avcTrack?_.MetadataSchema.emsg:_.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});p.samples.push(r)},n}();function b(n,d,v,p){return{key:n,frame:!1,pts:d,dts:v,units:[],debug:p,length:0}}function f(n,d){return((n[d+1]&31)<<8)+n[d+2]}function u(n,d){return(n[d+10]&31)<<8|n[d+11]}function h(n,d,v,p){var m={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(n[d+1]&15)<<8|n[d+2],a=d+3+r-4,e=(n[d+10]&15)<<8|n[d+11];for(d+=12+e;d<a;){var c=f(n,d);switch(n[d]){case 207:if(!p){R.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:m.audio===-1&&(m.audio=c);break;case 21:m.id3===-1&&(m.id3=c);break;case 219:if(!p){R.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:m.avc===-1&&(m.avc=c);break;case 3:case 4:v.mpeg!==!0&&v.mp3!==!0?R.logger.log("MPEG audio found, not supported in this browser"):m.audio===-1&&(m.audio=c,m.segmentCodec="mp3");break;case 36:R.logger.warn("Unsupported HEVC stream type found");break;default:break}d+=((n[d+3]&15)<<8|n[d+4])+5}return m}function o(n){var d=0,v,p,m,r,a,e=n.data;if(!n||n.size===0)return null;for(;e[0].length<19&&e.length>1;){var c=new Uint8Array(e[0].length+e[1].length);c.set(e[0]),c.set(e[1],e[0].length),e[0]=c,e.splice(1,1)}v=e[0];var E=(v[0]<<16)+(v[1]<<8)+v[2];if(E===1){if(p=(v[4]<<8)+v[5],p&&p>n.size-6)return null;var y=v[7];y&192&&(r=(v[9]&14)*536870912+(v[10]&255)*4194304+(v[11]&254)*16384+(v[12]&255)*128+(v[13]&254)/2,y&64?(a=(v[14]&14)*536870912+(v[15]&255)*4194304+(v[16]&254)*16384+(v[17]&255)*128+(v[18]&254)/2,r-a>60*9e4&&(R.logger.warn(Math.round((r-a)/9e4)+"s delta between PTS and DTS, align them"),r=a)):a=r),m=v[8];var k=m+9;if(n.size<=k)return null;n.size-=k;for(var M=new Uint8Array(n.size),O=0,U=e.length;O<U;O++){v=e[O];var F=v.byteLength;if(k)if(k>F){k-=F;continue}else v=v.subarray(k),F-=k,k=0;M.set(v,d),d+=F}return p&&(p-=m+3),{data:M,pts:r,dts:a,len:p}}return null}function s(n,d){if(n.units.length&&n.frame){if(n.pts===void 0){var v=d.samples,p=v.length;if(p){var m=v[p-1];n.pts=m.pts,n.dts=m.dts}else{d.dropped++;return}}d.samples.push(n)}n.debug.length&&R.logger.log(n.pts+"/"+n.dts+":"+n.debug)}const l=x},"./src/demux/webworkify-webpack.js":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>g});var W=function(){var b=ENTRY_MODULE,f={},u=function o(s){var l=f[s];if(l!==void 0)return l.exports;var n=f[s]={exports:{}};return b[s].call(n.exports,n,n.exports,o),n.exports};u.m=b,function(){u.n=function(o){var s=o&&o.__esModule?function(){return o.default}:function(){return o};return u.d(s,{a:s}),s}}(),function(){u.d=function(o,s){for(var l in s)u.o(s,l)&&!u.o(o,l)&&Object.defineProperty(o,l,{enumerable:!0,get:s[l]})}}(),function(){u.o=function(o,s){return Object.prototype.hasOwnProperty.call(o,s)}}(),function(){u.r=function(o){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}}();var h=u(ENTRY_MODULE);return h.default||h},P=W.toString().split("ENTRY_MODULE"),N="[\\.|\\-|\\+|\\w|/|@]+",D="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+N+").*?\\)";function G(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function I(x){return!isNaN(1*x)}function R(x,b,f){var u={};u[f]=[];var h=b.toString().replace(/^"[^"]+"/,"function"),o=h.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||h.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!o)return u;for(var s=o[1],l=new RegExp("(\\\\n|\\W)"+G(s)+D,"g"),n;n=l.exec(h);){if(n[3]==="dll-reference")continue;u[f].push(n[3])}for(l=new RegExp("\\("+G(s)+'\\("(dll-reference\\s('+N+'))"\\)\\)'+D,"g");n=l.exec(h);)x[n[2]]||(u[f].push(n[1]),x[n[2]]=w(n[1]).m),u[n[2]]=u[n[2]]||[],u[n[2]].push(n[4]);for(var d=Object.keys(u),v=0;v<d.length;v++)for(var p=0;p<u[d[v]].length;p++)I(u[d[v]][p])&&(u[d[v]][p]=1*u[d[v]][p]);return u}function L(x){var b=Object.keys(x);return b.reduce(function(f,u){return f||x[u].length>0},!1)}function _(x,b){for(var f={main:[b]},u={main:[]},h={main:{}};L(f);)for(var o=Object.keys(f),s=0;s<o.length;s++){var l=o[s],n=f[l],d=n.pop();if(h[l]=h[l]||{},h[l][d]||!x[l][d])continue;h[l][d]=!0,u[l]=u[l]||[],u[l].push(d);for(var v=R(x,x[l][d],l),p=Object.keys(v),m=0;m<p.length;m++)f[p[m]]=f[p[m]]||[],f[p[m]]=f[p[m]].concat(v[p[m]])}return u}function T(x,b,f,u){var h=x[u].map(function(o){return'"'+o+'": '+b[u][o].toString().replace(/^"[^"]+"/,"function")}).join(",");return P[0]+"{"+h+"}"+P[1]+'"'+f+'"'+P[2]}function g(x,b){b=b||{};var f={main:w.m},u=b.all?{main:Object.keys(f.main)}:_(f,x),h="";Object.keys(u).filter(function(d){return d!=="main"}).forEach(function(d){for(var v=0;u[d][v];)v++;u[d].push(v),f[d][v]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",h=h+("var "+d+" = ("+T(u,f,v,modules)+`)();
`)}),h=h+("new (("+T(u,f,x,"main")+")())(self);");var o=new window.Blob([h],{type:"text/javascript"}),s=window.URL||window.webkitURL||window.mozURL||window.msURL,l=s.createObjectURL(o),n=new window.Worker(l);return n.objectURL=l,n}},"./src/errors.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{ErrorDetails:()=>P,ErrorTypes:()=>W});var W;(function(N){N.NETWORK_ERROR="networkError",N.MEDIA_ERROR="mediaError",N.KEY_SYSTEM_ERROR="keySystemError",N.MUX_ERROR="muxError",N.OTHER_ERROR="otherError"})(W||(W={}));var P;(function(N){N.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",N.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",N.KEY_SYSTEM_NO_SESSION="keySystemNoSession",N.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",N.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",N.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",N.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",N.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",N.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",N.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",N.MANIFEST_LOAD_ERROR="manifestLoadError",N.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",N.MANIFEST_PARSING_ERROR="manifestParsingError",N.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",N.LEVEL_EMPTY_ERROR="levelEmptyError",N.LEVEL_LOAD_ERROR="levelLoadError",N.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",N.LEVEL_SWITCH_ERROR="levelSwitchError",N.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",N.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",N.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",N.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",N.FRAG_LOAD_ERROR="fragLoadError",N.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",N.FRAG_DECRYPT_ERROR="fragDecryptError",N.FRAG_PARSING_ERROR="fragParsingError",N.REMUX_ALLOC_ERROR="remuxAllocError",N.KEY_LOAD_ERROR="keyLoadError",N.KEY_LOAD_TIMEOUT="keyLoadTimeOut",N.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",N.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",N.BUFFER_APPEND_ERROR="bufferAppendError",N.BUFFER_APPENDING_ERROR="bufferAppendingError",N.BUFFER_STALLED_ERROR="bufferStalledError",N.BUFFER_FULL_ERROR="bufferFullError",N.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",N.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",N.INTERNAL_EXCEPTION="internalException",N.INTERNAL_ABORTED="aborted",N.UNKNOWN="unknown"})(P||(P={}))},"./src/events.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{Events:()=>W});var W;(function(P){P.MEDIA_ATTACHING="hlsMediaAttaching",P.MEDIA_ATTACHED="hlsMediaAttached",P.MEDIA_DETACHING="hlsMediaDetaching",P.MEDIA_DETACHED="hlsMediaDetached",P.BUFFER_RESET="hlsBufferReset",P.BUFFER_CODECS="hlsBufferCodecs",P.BUFFER_CREATED="hlsBufferCreated",P.BUFFER_APPENDING="hlsBufferAppending",P.BUFFER_APPENDED="hlsBufferAppended",P.BUFFER_EOS="hlsBufferEos",P.BUFFER_FLUSHING="hlsBufferFlushing",P.BUFFER_FLUSHED="hlsBufferFlushed",P.MANIFEST_LOADING="hlsManifestLoading",P.MANIFEST_LOADED="hlsManifestLoaded",P.MANIFEST_PARSED="hlsManifestParsed",P.LEVEL_SWITCHING="hlsLevelSwitching",P.LEVEL_SWITCHED="hlsLevelSwitched",P.LEVEL_LOADING="hlsLevelLoading",P.LEVEL_LOADED="hlsLevelLoaded",P.LEVEL_UPDATED="hlsLevelUpdated",P.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",P.LEVELS_UPDATED="hlsLevelsUpdated",P.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",P.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",P.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",P.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",P.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",P.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",P.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",P.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",P.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",P.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",P.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",P.CUES_PARSED="hlsCuesParsed",P.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",P.INIT_PTS_FOUND="hlsInitPtsFound",P.FRAG_LOADING="hlsFragLoading",P.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",P.FRAG_LOADED="hlsFragLoaded",P.FRAG_DECRYPTED="hlsFragDecrypted",P.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",P.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",P.FRAG_PARSING_METADATA="hlsFragParsingMetadata",P.FRAG_PARSED="hlsFragParsed",P.FRAG_BUFFERED="hlsFragBuffered",P.FRAG_CHANGED="hlsFragChanged",P.FPS_DROP="hlsFpsDrop",P.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",P.ERROR="hlsError",P.DESTROYING="hlsDestroying",P.KEY_LOADING="hlsKeyLoading",P.KEY_LOADED="hlsKeyLoaded",P.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",P.BACK_BUFFER_REACHED="hlsBackBufferReached"})(W||(W={}))},"./src/hls.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>v});var W=w("./node_modules/url-toolkit/src/url-toolkit.js"),P=w.n(W),N=w("./src/loader/playlist-loader.ts"),D=w("./src/controller/id3-track-controller.ts"),G=w("./src/controller/latency-controller.ts"),I=w("./src/controller/level-controller.ts"),R=w("./src/controller/fragment-tracker.ts"),L=w("./src/loader/key-loader.ts"),_=w("./src/controller/stream-controller.ts"),T=w("./src/is-supported.ts"),g=w("./src/utils/logger.ts"),x=w("./src/config.ts"),b=w("./node_modules/eventemitter3/index.js"),f=w.n(b),u=w("./src/events.ts"),h=w("./src/errors.ts"),o=w("./src/types/level.ts");function s(p,m){for(var r=0;r<m.length;r++){var a=m[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(p,n(a.key),a)}}function l(p,m,r){return m&&s(p.prototype,m),r&&s(p,r),Object.defineProperty(p,"prototype",{writable:!1}),p}function n(p){var m=d(p,"string");return typeof m=="symbol"?m:String(m)}function d(p,m){if(typeof p!="object"||p===null)return p;var r=p[Symbol.toPrimitive];if(r!==void 0){var a=r.call(p,m||"default");if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(p)}var v=function(){p.isSupported=function(){return(0,T.isSupported)()};function p(r){r===void 0&&(r={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new b.EventEmitter,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;var a=this.config=(0,x.mergeConfig)(p.DefaultConfig,r);this.userConfig=r,(0,g.enableLogs)(a.debug,"Hls instance"),this._autoLevelCapping=-1,a.progressive&&(0,x.enableStreamingMode)(a);var e=a.abrController,c=a.bufferController,E=a.capLevelController,y=a.fpsController,k=this.abrController=new e(this),M=this.bufferController=new c(this),O=this.capLevelController=new E(this),U=new y(this),F=new N.default(this),H=new D.default(this),Y=this.levelController=new I.default(this),Q=new R.FragmentTracker(this),z=new L.default(this.config),ee=this.streamController=new _.default(this,Q,z);O.setStreamController(ee),U.setStreamController(ee);var J=[F,Y,ee];this.networkControllers=J;var X=[k,M,O,U,H,Q];this.audioTrackController=this.createController(a.audioTrackController,J);var oe=a.audioStreamController;oe&&J.push(new oe(this,Q,z)),this.subtitleTrackController=this.createController(a.subtitleTrackController,J);var le=a.subtitleStreamController;le&&J.push(new le(this,Q,z)),this.createController(a.timelineController,X),z.emeController=this.emeController=this.createController(a.emeController,X),this.cmcdController=this.createController(a.cmcdController,X),this.latencyController=this.createController(G.default,X),this.coreComponents=X}var m=p.prototype;return m.createController=function(a,e){if(a){var c=new a(this);return e&&e.push(c),c}return null},m.on=function(a,e,c){c===void 0&&(c=this),this._emitter.on(a,e,c)},m.once=function(a,e,c){c===void 0&&(c=this),this._emitter.once(a,e,c)},m.removeAllListeners=function(a){this._emitter.removeAllListeners(a)},m.off=function(a,e,c,E){c===void 0&&(c=this),this._emitter.off(a,e,c,E)},m.listeners=function(a){return this._emitter.listeners(a)},m.emit=function(a,e,c){return this._emitter.emit(a,e,c)},m.trigger=function(a,e){if(this.config.debug)return this.emit(a,a,e);try{return this.emit(a,a,e)}catch(c){g.logger.error("An internal error happened while handling event "+a+'. Error message: "'+c.message+'". Here is a stacktrace:',c),this.trigger(u.Events.ERROR,{type:h.ErrorTypes.OTHER_ERROR,details:h.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:a,error:c})}return!1},m.listenerCount=function(a){return this._emitter.listenerCount(a)},m.destroy=function(){g.logger.log("destroy"),this.trigger(u.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(a){return a.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(a){return a.destroy()}),this.coreComponents.length=0},m.attachMedia=function(a){g.logger.log("attachMedia"),this._media=a,this.trigger(u.Events.MEDIA_ATTACHING,{media:a})},m.detachMedia=function(){g.logger.log("detachMedia"),this.trigger(u.Events.MEDIA_DETACHING,void 0),this._media=null},m.loadSource=function(a){this.stopLoad();var e=this.media,c=this.url,E=this.url=W.buildAbsoluteURL(self.location.href,a,{alwaysNormalize:!0});g.logger.log("loadSource:"+E),e&&c&&c!==E&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(e)),this.trigger(u.Events.MANIFEST_LOADING,{url:a})},m.startLoad=function(a){a===void 0&&(a=-1),g.logger.log("startLoad("+a+")"),this.networkControllers.forEach(function(e){e.startLoad(a)})},m.stopLoad=function(){g.logger.log("stopLoad"),this.networkControllers.forEach(function(a){a.stopLoad()})},m.swapAudioCodec=function(){g.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},m.recoverMediaError=function(){g.logger.log("recoverMediaError");var a=this._media;this.detachMedia(),a&&this.attachMedia(a)},m.removeLevel=function(a,e){e===void 0&&(e=0),this.levelController.removeLevel(a,e)},l(p,[{key:"levels",get:function(){var a=this.levelController.levels;return a||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(a){g.logger.log("set currentLevel:"+a),this.loadLevel=a,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(a){g.logger.log("set nextLevel:"+a),this.levelController.manualLevel=a,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(a){g.logger.log("set loadLevel:"+a),this.levelController.manualLevel=a}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(a){this.levelController.nextLoadLevel=a}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(a){g.logger.log("set firstLevel:"+a),this.levelController.firstLevel=a}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(a){g.logger.log("set startLevel:"+a),a!==-1&&(a=Math.max(a,this.minAutoLevel)),this.levelController.startLevel=a}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(a){var e=!!a;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(a){this._autoLevelCapping!==a&&(g.logger.log("set autoLevelCapping:"+a),this._autoLevelCapping=a)}},{key:"bandwidthEstimate",get:function(){var a=this.abrController.bwEstimator;return a?a.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(a){o.HdcpLevels.indexOf(a)>-1&&(this._maxHdcpLevel=a)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var a=this.levels,e=this.config.minAutoBitrate;if(!a)return 0;for(var c=a.length,E=0;E<c;E++)if(a[E].maxBitrate>=e)return E;return 0}},{key:"maxAutoLevel",get:function(){var a=this.levels,e=this.autoLevelCapping,c=this.maxHdcpLevel,E;if(e===-1&&a&&a.length?E=a.length-1:E=e,c)for(var y=E;y--;){var k=a[y].attrs["HDCP-LEVEL"];if(k&&k<=c)return y}return E}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(a){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,a)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var a=this.audioTrackController;return a?a.audioTracks:[]}},{key:"audioTrack",get:function(){var a=this.audioTrackController;return a?a.audioTrack:-1},set:function(a){var e=this.audioTrackController;e&&(e.audioTrack=a)}},{key:"subtitleTracks",get:function(){var a=this.subtitleTrackController;return a?a.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var a=this.subtitleTrackController;return a?a.subtitleTrack:-1},set:function(a){var e=this.subtitleTrackController;e&&(e.subtitleTrack=a)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var a=this.subtitleTrackController;return a?a.subtitleDisplay:!1},set:function(a){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=a)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(a){this.config.lowLatencyMode=a}},{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.3.5"}},{key:"Events",get:function(){return u.Events}},{key:"ErrorTypes",get:function(){return h.ErrorTypes}},{key:"ErrorDetails",get:function(){return h.ErrorDetails}},{key:"DefaultConfig",get:function(){return p.defaultConfig?p.defaultConfig:x.hlsDefaultConfig},set:function(a){p.defaultConfig=a}}]),p}();v.defaultConfig=void 0},"./src/is-supported.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{changeTypeSupported:()=>D,isSupported:()=>N});var W=w("./src/utils/mediasource-helper.ts");function P(){return self.SourceBuffer||self.WebKitSourceBuffer}function N(){var G=(0,W.getMediaSource)();if(!G)return!1;var I=P(),R=G&&typeof G.isTypeSupported=="function"&&G.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),L=!I||I.prototype&&typeof I.prototype.appendBuffer=="function"&&typeof I.prototype.remove=="function";return!!R&&!!L}function D(){var G,I=P();return typeof(I==null||((G=I.prototype)===null||G===void 0)?void 0:G.changeType)=="function"}},"./src/loader/date-range.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{DateRange:()=>T,DateRangeAttribute:()=>_});var W=w("./src/polyfills/number.ts"),P=w("./src/utils/attr-list.ts"),N=w("./src/utils/logger.ts");function D(){return D=Object.assign?Object.assign.bind():function(g){for(var x=1;x<arguments.length;x++){var b=arguments[x];for(var f in b)Object.prototype.hasOwnProperty.call(b,f)&&(g[f]=b[f])}return g},D.apply(this,arguments)}function G(g,x){for(var b=0;b<x.length;b++){var f=x[b];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(g,R(f.key),f)}}function I(g,x,b){return x&&G(g.prototype,x),b&&G(g,b),Object.defineProperty(g,"prototype",{writable:!1}),g}function R(g){var x=L(g,"string");return typeof x=="symbol"?x:String(x)}function L(g,x){if(typeof g!="object"||g===null)return g;var b=g[Symbol.toPrimitive];if(b!==void 0){var f=b.call(g,x||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(x==="string"?String:Number)(g)}var _;(function(g){g.ID="ID",g.CLASS="CLASS",g.START_DATE="START-DATE",g.DURATION="DURATION",g.END_DATE="END-DATE",g.END_ON_NEXT="END-ON-NEXT",g.PLANNED_DURATION="PLANNED-DURATION",g.SCTE35_OUT="SCTE35-OUT",g.SCTE35_IN="SCTE35-IN"})(_||(_={}));var T=function(){function g(x,b){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,b){var f=b.attr;for(var u in f)if(Object.prototype.hasOwnProperty.call(x,u)&&x[u]!==f[u]){N.logger.warn('DATERANGE tag attribute: "'+u+'" does not match for tags with ID: "'+x.ID+'"'),this._badValueForSameId=u;break}x=D(new P.AttrList({}),f,x)}if(this.attr=x,this._startDate=new Date(x[_.START_DATE]),_.END_DATE in this.attr){var h=new Date(this.attr[_.END_DATE]);(0,W.isFiniteNumber)(h.getTime())&&(this._endDate=h)}}return I(g,[{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 b=this.duration;return b!==null?new Date(this._startDate.getTime()+b*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var b=this.attr.decimalFloatingPoint(_.DURATION);if((0,W.isFiniteNumber)(b))return b}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&&(0,W.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),g}()},"./src/loader/fragment-loader.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{LoadError:()=>b,default:()=>g});var W=w("./src/polyfills/number.ts"),P=w("./src/errors.ts");function N(f,u){f.prototype=Object.create(u.prototype),f.prototype.constructor=f,L(f,u)}function D(f){var u=typeof Map=="function"?new Map:void 0;return D=function(o){if(o===null||!R(o))return o;if(typeof o!="function")throw new TypeError("Super expression must either be null or a function");if(typeof u!="undefined"){if(u.has(o))return u.get(o);u.set(o,s)}function s(){return G(o,arguments,_(this).constructor)}return s.prototype=Object.create(o.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),L(s,o)},D(f)}function G(f,u,h){return I()?G=Reflect.construct.bind():G=function(s,l,n){var d=[null];d.push.apply(d,l);var v=Function.bind.apply(s,d),p=new v;return n&&L(p,n.prototype),p},G.apply(null,arguments)}function I(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(f){return!1}}function R(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function L(f,u){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,s){return o.__proto__=s,o},L(f,u)}function _(f){return _=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},_(f)}var T=Math.pow(2,17),g=function(){function f(h){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=h}var u=f.prototype;return u.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},u.abort=function(){this.loader&&this.loader.abort()},u.load=function(o,s){var l=this,n=o.url;if(!n)return Promise.reject(new b({type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var d=this.config,v=d.fLoader,p=d.loader;return new Promise(function(m,r){l.loader&&l.loader.destroy();var a=l.loader=o.loader=v?new v(d):new p(d),e=x(o),c={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:o.sn==="initSegment"?Infinity:T};o.stats=a.stats,a.load(e,c,{onSuccess:function(y,k,M,O){l.resetLoader(o,a);var U=y.data;M.resetIV&&o.decryptdata&&(o.decryptdata.iv=new Uint8Array(U.slice(0,16)),U=U.slice(16)),m({frag:o,part:null,payload:U,networkDetails:O})},onError:function(y,k,M){l.resetLoader(o,a),r(new b({type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:y,networkDetails:M}))},onAbort:function(y,k,M){l.resetLoader(o,a),r(new b({type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,networkDetails:M}))},onTimeout:function(y,k,M){l.resetLoader(o,a),r(new b({type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,networkDetails:M}))},onProgress:function(y,k,M,O){s&&s({frag:o,part:null,payload:M,networkDetails:O})}})})},u.loadPart=function(o,s,l){var n=this;this.abort();var d=this.config,v=d.fLoader,p=d.loader;return new Promise(function(m,r){n.loader&&n.loader.destroy();var a=n.loader=o.loader=v?new v(d):new p(d),e=x(o,s),c={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:T};s.stats=a.stats,a.load(e,c,{onSuccess:function(y,k,M,O){n.resetLoader(o,a),n.updateStatsFromPart(o,s);var U={frag:o,part:s,payload:y.data,networkDetails:O};l(U),m(U)},onError:function(y,k,M){n.resetLoader(o,a),r(new b({type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:o,part:s,response:y,networkDetails:M}))},onAbort:function(y,k,M){o.stats.aborted=s.stats.aborted,n.resetLoader(o,a),r(new b({type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:o,part:s,networkDetails:M}))},onTimeout:function(y,k,M){n.resetLoader(o,a),r(new b({type:P.ErrorTypes.NETWORK_ERROR,details:P.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,part:s,networkDetails:M}))}})})},u.updateStatsFromPart=function(o,s){var l=o.stats,n=s.stats,d=n.total;if(l.loaded+=n.loaded,d){var v=Math.round(o.duration/s.duration),p=Math.min(Math.round(l.loaded/d),v),m=v-p,r=m*Math.round(l.loaded/p);l.total=l.loaded+r}else l.total=Math.max(l.loaded,l.total);var a=l.loading,e=n.loading;a.start?a.first+=e.first-e.start:(a.start=e.start,a.first=e.first),a.end=e.end},u.resetLoader=function(o,s){o.loader=null,this.loader===s&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),s.destroy()},f}();function x(f,u){u===void 0&&(u=null);var h=u||f,o={frag:f,part:u,responseType:"arraybuffer",url:h.url,headers:{},rangeStart:0,rangeEnd:0},s=h.byteRangeStartOffset,l=h.byteRangeEndOffset;if((0,W.isFiniteNumber)(s)&&(0,W.isFiniteNumber)(l)){var n,d=s,v=l;if(f.sn==="initSegment"&&((n=f.decryptdata)===null||n===void 0?void 0:n.method)==="AES-128"){var p=l-s;p%16&&(v=l+(16-p%16)),s!==0&&(o.resetIV=!0,d=s-16)}o.rangeStart=d,o.rangeEnd=v}return o}var b=function(f){N(u,f);function u(h){for(var o,s=arguments.length,l=new Array(s>1?s-1:0),n=1;n<s;n++)l[n-1]=arguments[n];return o=f.call.apply(f,[this].concat(l))||this,o.data=void 0,o.data=h,o}return u}(D(Error))},"./src/loader/fragment.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{BaseSegment:()=>x,ElementaryStreamTypes:()=>g,Fragment:()=>b,Part:()=>f});var W=w("./src/polyfills/number.ts"),P=w("./node_modules/url-toolkit/src/url-toolkit.js"),N=w.n(P),D=w("./src/loader/load-stats.ts");function G(u,h){u.prototype=Object.create(h.prototype),u.prototype.constructor=u,I(u,h)}function I(u,h){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,l){return s.__proto__=l,s},I(u,h)}function R(u,h){for(var o=0;o<h.length;o++){var s=h[o];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(u,_(s.key),s)}}function L(u,h,o){return h&&R(u.prototype,h),o&&R(u,o),Object.defineProperty(u,"prototype",{writable:!1}),u}function _(u){var h=T(u,"string");return typeof h=="symbol"?h:String(h)}function T(u,h){if(typeof u!="object"||u===null)return u;var o=u[Symbol.toPrimitive];if(o!==void 0){var s=o.call(u,h||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(u)}var g;(function(u){u.AUDIO="audio",u.VIDEO="video",u.AUDIOVIDEO="audiovideo"})(g||(g={}));var x=function(){function u(o){var s;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(s={},s[g.AUDIO]=null,s[g.VIDEO]=null,s[g.AUDIOVIDEO]=null,s),this.baseurl=o}var h=u.prototype;return h.setByteRange=function(s,l){var n=s.split("@",2),d=[];n.length===1?d[0]=l?l.byteRangeEndOffset:0:d[0]=parseInt(n[1]),d[1]=parseInt(n[0])+d[0],this._byteRange=d},L(u,[{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=(0,P.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(s){this._url=s}}]),u}(),b=function(u){G(h,u);function h(s,l){var n;return n=u.call(this,l)||this,n._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.appendedPTS=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 D.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.endList=void 0,n.type=s,n}var o=h.prototype;return o.setKeyFormat=function(l){if(this.levelkeys){var n=this.levelkeys[l];n&&!this._decryptdata&&(this._decryptdata=n.getDecryptData(this.sn))}},o.abortRequests=function(){var l,n;(l=this.loader)===null||l===void 0||l.abort(),(n=this.keyLoader)===null||n===void 0||n.abort()},o.setElementaryStreamInfo=function(l,n,d,v,p,m){m===void 0&&(m=!1);var r=this.elementaryStreams,a=r[l];if(!a){r[l]={startPTS:n,endPTS:d,startDTS:v,endDTS:p,partial:m};return}a.startPTS=Math.min(a.startPTS,n),a.endPTS=Math.max(a.endPTS,d),a.startDTS=Math.min(a.startDTS,v),a.endDTS=Math.max(a.endDTS,p)},o.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[g.AUDIO]=null,l[g.VIDEO]=null,l[g.AUDIOVIDEO]=null},L(h,[{key:"decryptdata",get:function(){var l=this.levelkeys;if(!l&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var n=this.levelkeys.identity;if(n)this._decryptdata=n.getDecryptData(this.sn);else{var d=Object.keys(this.levelkeys);if(d.length===1)return this._decryptdata=this.levelkeys[d[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!(0,W.isFiniteNumber)(this.programDateTime))return null;var l=(0,W.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;if((l=this._decryptdata)!==null&&l!==void 0&&l.encrypted)return!0;if(this.levelkeys){var n=Object.keys(this.levelkeys),d=n.length;if(d>1||d===1&&this.levelkeys[n[0]].encrypted)return!0}return!1}}]),h}(x),f=function(u){G(h,u);function h(o,s,l,n,d){var v;v=u.call(this,l)||this,v.fragOffset=0,v.duration=0,v.gap=!1,v.independent=!1,v.relurl=void 0,v.fragment=void 0,v.index=void 0,v.stats=new D.LoadStats,v.duration=o.decimalFloatingPoint("DURATION"),v.gap=o.bool("GAP"),v.independent=o.bool("INDEPENDENT"),v.relurl=o.enumeratedString("URI"),v.fragment=s,v.index=n;var p=o.enumeratedString("BYTERANGE");return p&&v.setByteRange(p,d),d&&(v.fragOffset=d.fragOffset+d.duration),v}return L(h,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var s=this.elementaryStreams;return!!(s.audio||s.video||s.audiovideo)}}]),h}(x)},"./src/loader/key-loader.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>N});var W=w("./src/errors.ts"),P=w("./src/loader/fragment-loader.ts"),N=function(){function D(I){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=I}var G=D.prototype;return G.abort=function(){for(var R in this.keyUriToKeyInfo){var L=this.keyUriToKeyInfo[R].loader;L&&L.abort()}},G.detach=function(){for(var R in this.keyUriToKeyInfo){var L=this.keyUriToKeyInfo[R];(L.mediaKeySessionContext||L.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[R]}},G.destroy=function(){this.detach();for(var R in this.keyUriToKeyInfo){var L=this.keyUriToKeyInfo[R].loader;L&&L.destroy()}this.keyUriToKeyInfo={}},G.createKeyLoadError=function(R,L,_,T){return L===void 0&&(L=W.ErrorDetails.KEY_LOAD_ERROR),new P.LoadError({type:W.ErrorTypes.NETWORK_ERROR,details:L,fatal:!1,frag:R,networkDetails:_})},G.loadClear=function(R,L){var _=this;if(this.emeController&&this.config.emeEnabled)for(var T=R.sn,g=R.cc,x=function(h){var o=L[h];if(g<=o.cc&&(T==="initSegment"||T<o.sn))return _.emeController.selectKeySystemFormat(o).then(function(s){o.setKeyFormat(s)}),"break"},b=0;b<L.length;b++){var f=x(b);if(f==="break")break}},G.load=function(R){var L=this;return!R.decryptdata&&R.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(R).then(function(_){return L.loadInternal(R,_)}):this.loadInternal(R)},G.loadInternal=function(R,L){var _,T;L&&R.setKeyFormat(L);var g=R.decryptdata;if(!g){var x=L?"Expected frag.decryptdata to be defined after setting format "+L:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(R,W.ErrorDetails.KEY_LOAD_ERROR,null,x))}var b=g.uri;if(!b)return Promise.reject(this.createKeyLoadError(R,W.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+b+'"'));var f=this.keyUriToKeyInfo[b];if((_=f)!==null&&_!==void 0&&_.decryptdata.key)return g.key=f.decryptdata.key,Promise.resolve({frag:R,keyInfo:f});if((T=f)!==null&&T!==void 0&&T.keyLoadPromise){var u;switch((u=f.mediaKeySessionContext)===null||u===void 0?void 0:u.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return f.keyLoadPromise.then(function(h){return g.key=h.keyInfo.decryptdata.key,{frag:R,keyInfo:f}})}}f=this.keyUriToKeyInfo[b]={decryptdata:g,keyLoadPromise:null,loader:null,mediaKeySessionContext:null};switch(g.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return g.keyFormat==="identity"?this.loadKeyHTTP(f,R):this.loadKeyEME(f,R);case"AES-128":return this.loadKeyHTTP(f,R);default:return Promise.reject(this.createKeyLoadError(R,W.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+g.method+'"'))}},G.loadKeyEME=function(R,L){var _={frag:L,keyInfo:R};if(this.emeController&&this.config.emeEnabled){var T=this.emeController.loadKey(_);if(T)return(R.keyLoadPromise=T.then(function(g){return R.mediaKeySessionContext=g,_})).catch(function(g){throw R.keyLoadPromise=null,g})}return Promise.resolve(_)},G.loadKeyHTTP=function(R,L){var _=this,T=this.config,g=T.loader,x=new g(T);return L.keyLoader=R.loader=x,R.keyLoadPromise=new Promise(function(b,f){var u={keyInfo:R,frag:L,responseType:"arraybuffer",url:R.decryptdata.uri},h={timeout:T.fragLoadingTimeOut,maxRetry:0,retryDelay:T.fragLoadingRetryDelay,maxRetryDelay:T.fragLoadingMaxRetryTimeout,highWaterMark:0},o={onSuccess:function(l,n,d,v){var p=d.frag,m=d.keyInfo,r=d.url;if(!p.decryptdata||m!==_.keyUriToKeyInfo[r])return f(_.createKeyLoadError(p,W.ErrorDetails.KEY_LOAD_ERROR,v,"after key load, decryptdata unset or changed"));m.decryptdata.key=p.decryptdata.key=new Uint8Array(l.data),p.keyLoader=null,m.loader=null,b({frag:p,keyInfo:m})},onError:function(l,n,d){_.resetLoader(n),f(_.createKeyLoadError(L,W.ErrorDetails.KEY_LOAD_ERROR,d))},onTimeout:function(l,n,d){_.resetLoader(n),f(_.createKeyLoadError(L,W.ErrorDetails.KEY_LOAD_TIMEOUT,d))},onAbort:function(l,n,d){_.resetLoader(n),f(_.createKeyLoadError(L,W.ErrorDetails.INTERNAL_ABORTED,d))}};x.load(u,h,o)})},G.resetLoader=function(R){var L=R.frag,_=R.keyInfo,T=R.url,g=_.loader;L.keyLoader===g&&(L.keyLoader=null,_.loader=null),delete this.keyUriToKeyInfo[T],g&&g.destroy()},D}()},"./src/loader/level-details.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{LevelDetails:()=>R});var W=w("./src/polyfills/number.ts");function P(L,_){for(var T=0;T<_.length;T++){var g=_[T];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(L,D(g.key),g)}}function N(L,_,T){return _&&P(L.prototype,_),T&&P(L,T),Object.defineProperty(L,"prototype",{writable:!1}),L}function D(L){var _=G(L,"string");return typeof _=="symbol"?_:String(_)}function G(L,_){if(typeof L!="object"||L===null)return L;var T=L[Symbol.toPrimitive];if(T!==void 0){var g=T.call(L,_||"default");if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(L)}var I=10,R=function(){function L(T){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.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=T}var _=L.prototype;return _.reloaded=function(g){if(!g){this.advanced=!0,this.updated=!0;return}var x=this.lastPartSn-g.lastPartSn,b=this.lastPartIndex-g.lastPartIndex;this.updated=this.endSN!==g.endSN||!!b||!!x,this.advanced=this.endSN>g.endSN||x>0||x===0&&b>0,this.updated||this.advanced?this.misses=Math.floor(g.misses*.6):this.misses=g.misses+1,this.availabilityDelay=g.availabilityDelay},N(L,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?(0,W.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||I}},{key:"drift",get:function(){var g=this.driftEndTime-this.driftStartTime;if(g>0){var x=this.driftEnd-this.driftStart;return x*1e3/g}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var g;return(g=this.partList)!==null&&g!==void 0&&g.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var g;return(g=this.fragments)!==null&&g!==void 0&&g.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 g;return(g=this.partList)!==null&&g!==void 0&&g.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var g;return(g=this.partList)!==null&&g!==void 0&&g.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),L}()},"./src/loader/level-key.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{LevelKey:()=>R});var W=w("./src/utils/keysystem-util.ts"),P=w("./src/utils/mediakeys-helper.ts"),N=w("./src/utils/mp4-tools.ts"),D=w("./src/utils/logger.ts"),G=w("./src/utils/numeric-encoding-utils.ts"),I={},R=function(){_.clearKeyUriToKeyIdMap=function(){I={}};function _(g,x,b,f,u){f===void 0&&(f=[1]),u===void 0&&(u=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=g,this.uri=x,this.keyFormat=b,this.keyFormatVersions=f,this.iv=u,this.encrypted=g?g!=="NONE":!1,this.isCommonEncryption=this.encrypted&&g!=="AES-128"}var T=_.prototype;return T.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case P.KeySystemFormats.FAIRPLAY:case P.KeySystemFormats.WIDEVINE:case P.KeySystemFormats.PLAYREADY:case P.KeySystemFormats.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},T.getDecryptData=function(x){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof x!="number"&&(this.method==="AES-128"&&!this.iv&&D.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),x=0);var b=L(x),f=new _(this.method,this.uri,"identity",this.keyFormatVersions,b);return f}var u=(0,W.convertDataUriToArrayBytes)(this.uri);if(u)switch(this.keyFormat){case P.KeySystemFormats.WIDEVINE:this.pssh=u,u.length>=22&&(this.keyId=u.subarray(u.length-22,u.length-6));break;case P.KeySystemFormats.PLAYREADY:{var h=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,N.mp4pssh)(h,null,u);var o=new Uint16Array(u.buffer,u.byteOffset,u.byteLength/2),s=String.fromCharCode.apply(null,Array.from(o)),l=s.substring(s.indexOf("<"),s.length),n=new DOMParser,d=n.parseFromString(l,"text/xml"),v=d.getElementsByTagName("KID")[0];if(v){var p=v.childNodes[0]?v.childNodes[0].nodeValue:v.getAttribute("VALUE");if(p){var m=(0,G.base64Decode)(p).subarray(0,16);(0,W.changeEndianness)(m),this.keyId=m}}break}default:{var r=u.subarray(0,16);if(r.length!==16){var a=new Uint8Array(16);a.set(r,16-r.length),r=a}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){var e=I[this.uri];if(!e){var c=Object.keys(I).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16);var E=new DataView(e.buffer,12,4);E.setUint32(0,c),I[this.uri]=e}this.keyId=e}return this},_}();function L(_){for(var T=new Uint8Array(16),g=12;g<16;g++)T[g]=_>>8*(15-g)&255;return T}},"./src/loader/load-stats.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{LoadStats:()=>W});var W=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}}},"./src/loader/m3u8-parser.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>h});var W=w("./src/polyfills/number.ts"),P=w("./node_modules/url-toolkit/src/url-toolkit.js"),N=w.n(P),D=w("./src/loader/date-range.ts"),G=w("./src/loader/fragment.ts"),I=w("./src/loader/level-details.ts"),R=w("./src/loader/level-key.ts"),L=w("./src/utils/attr-list.ts"),_=w("./src/utils/logger.ts"),T=w("./src/utils/codecs.ts");function g(){return g=Object.assign?Object.assign.bind():function(m){for(var r=1;r<arguments.length;r++){var a=arguments[r];for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&(m[e]=a[e])}return m},g.apply(this,arguments)}var x=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,b=/#EXT-X-MEDIA:(.*)/g,f=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),u=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|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("|")),h=function(){function m(){}return m.findGroup=function(a,e){for(var c=0;c<a.length;c++){var E=a[c];if(E.id===e)return E}},m.convertAVC1ToAVCOTI=function(a){var e=a.split(".");if(e.length>2){var c=e.shift()+".";return c+=parseInt(e.shift()).toString(16),c+=("000"+parseInt(e.shift()).toString(16)).slice(-4),c}return a},m.resolve=function(a,e){return(0,P.buildAbsoluteURL)(e,a,{alwaysNormalize:!0})},m.parseMasterPlaylist=function(a,e){var c=[],E=[],y={},k=[],M=!1;x.lastIndex=0;for(var O;(O=x.exec(a))!=null;)if(O[1]){var U,F=new L.AttrList(O[1]),H={attrs:F,bitrate:F.decimalInteger("AVERAGE-BANDWIDTH")||F.decimalInteger("BANDWIDTH"),name:F.NAME,url:m.resolve(O[2],e)},Y=F.decimalResolution("RESOLUTION");Y&&(H.width=Y.width,H.height=Y.height),s((F.CODECS||"").split(/[ ,]+/).filter(function(X){return X}),H),H.videoCodec&&H.videoCodec.indexOf("avc1")!==-1&&(H.videoCodec=m.convertAVC1ToAVCOTI(H.videoCodec)),(U=H.unknownCodecs)!==null&&U!==void 0&&U.length||E.push(H),c.push(H)}else if(O[3]){var Q=new L.AttrList(O[3]);Q["DATA-ID"]&&(M=!0,y[Q["DATA-ID"]]=Q)}else if(O[4]){var z=O[4],ee=o(z,e);ee.encrypted&&ee.isSupported()?k.push(ee):_.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+z+'"')}var J=E.length>0&&E.length<c.length;return{levels:J?E:c,sessionData:M?y:null,sessionKeys:k.length?k:null}},m.parseMasterPlaylistMedia=function(a,e,c,E){E===void 0&&(E=[]);var y,k=[],M=0;for(b.lastIndex=0;(y=b.exec(a))!==null;){var O=new L.AttrList(y[1]);if(O.TYPE===c){var U={attrs:O,bitrate:0,id:M++,groupId:O["GROUP-ID"],instreamId:O["INSTREAM-ID"],name:O.NAME||O.LANGUAGE||"",type:c,default:O.bool("DEFAULT"),autoselect:O.bool("AUTOSELECT"),forced:O.bool("FORCED"),lang:O.LANGUAGE,url:O.URI?m.resolve(O.URI,e):""};if(E.length){var F=m.findGroup(E,U.groupId)||E[0];l(U,F,"audioCodec"),l(U,F,"textCodec")}k.push(U)}}return k},m.parseLevelPlaylist=function(a,e,c,E,y){var k=new I.LevelDetails(e),M=k.fragments,O=null,U=0,F=0,H=0,Y=0,Q=null,z=new G.Fragment(E,e),ee,J,X,oe=-1,le=!1;for(f.lastIndex=0,k.m3u8=a;(ee=f.exec(a))!==null;){le&&(le=!1,z=new G.Fragment(E,e),z.start=H,z.sn=U,z.cc=Y,z.level=c,O&&(z.initSegment=O,z.rawProgramDateTime=O.rawProgramDateTime,O.rawProgramDateTime=null));var me=ee[1];if(me){z.duration=parseFloat(me);var Ae=(" "+ee[2]).slice(1);z.title=Ae||null,z.tagList.push(Ae?["INF",me,Ae]:["INF",me])}else if(ee[3])(0,W.isFiniteNumber)(z.duration)&&(z.start=H,X&&p(z,X,k),z.sn=U,z.level=c,z.cc=Y,z.urlId=y,M.push(z),z.relurl=(" "+ee[3]).slice(1),d(z,Q),Q=z,H+=z.duration,U++,F=0,le=!0);else if(ee[4]){var ge=(" "+ee[4]).slice(1);Q?z.setByteRange(ge,Q):z.setByteRange(ge)}else if(ee[5])z.rawProgramDateTime=(" "+ee[5]).slice(1),z.tagList.push(["PROGRAM-DATE-TIME",z.rawProgramDateTime]),oe===-1&&(oe=M.length);else{if(ee=ee[0].match(u),!ee){_.logger.warn("No matches on slow regex match for level playlist!");continue}for(J=1;J<ee.length&&!(typeof ee[J]!="undefined");J++);var ae=(" "+ee[J]).slice(1),ue=(" "+ee[J+1]).slice(1),ye=ee[J+2]?(" "+ee[J+2]).slice(1):"";switch(ae){case"PLAYLIST-TYPE":k.type=ue.toUpperCase();break;case"MEDIA-SEQUENCE":U=k.startSN=parseInt(ue);break;case"SKIP":{var Ee=new L.AttrList(ue),_e=Ee.decimalInteger("SKIPPED-SEGMENTS");if((0,W.isFiniteNumber)(_e)){k.skippedSegments=_e;for(var Se=_e;Se--;)M.unshift(null);U+=_e}var Te=Ee.enumeratedString("RECENTLY-REMOVED-DATERANGES");Te&&(k.recentlyRemovedDateranges=Te.split(" "));break}case"TARGETDURATION":k.targetduration=parseFloat(ue);break;case"VERSION":k.version=parseInt(ue);break;case"EXTM3U":break;case"ENDLIST":k.live=!1;break;case"#":(ue||ye)&&z.tagList.push(ye?[ue,ye]:[ue]);break;case"DISCONTINUITY":Y++,z.tagList.push(["DIS"]);break;case"GAP":z.tagList.push([ae]);break;case"BITRATE":z.tagList.push([ae,ue]);break;case"DATERANGE":{var Pe=new L.AttrList(ue),we=new D.DateRange(Pe,k.dateRanges[Pe.ID]);we.isValid||k.skippedSegments?k.dateRanges[we.id]=we:_.logger.warn('Ignoring invalid DATERANGE tag: "'+ue+'"'),z.tagList.push(["EXT-X-DATERANGE",ue]);break}case"DISCONTINUITY-SEQUENCE":Y=parseInt(ue);break;case"KEY":{var be=o(ue,e);if(be.isSupported()){if(be.method==="NONE"){X=void 0;break}X||(X={}),X[be.keyFormat]&&(X=g({},X)),X[be.keyFormat]=be}else _.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+ue+'"');break}case"START":{var Re=new L.AttrList(ue),De=Re.decimalFloatingPoint("TIME-OFFSET");(0,W.isFiniteNumber)(De)&&(k.startTimeOffset=De);break}case"MAP":{var ke=new L.AttrList(ue);if(z.duration){var Ie=new G.Fragment(E,e);v(Ie,ke,c,X),O=Ie,z.initSegment=O,O.rawProgramDateTime&&!z.rawProgramDateTime&&(z.rawProgramDateTime=O.rawProgramDateTime)}else v(z,ke,c,X),O=z,le=!0;break}case"SERVER-CONTROL":{var xe=new L.AttrList(ue);k.canBlockReload=xe.bool("CAN-BLOCK-RELOAD"),k.canSkipUntil=xe.optionalFloat("CAN-SKIP-UNTIL",0),k.canSkipDateRanges=k.canSkipUntil>0&&xe.bool("CAN-SKIP-DATERANGES"),k.partHoldBack=xe.optionalFloat("PART-HOLD-BACK",0),k.holdBack=xe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Fe=new L.AttrList(ue);k.partTarget=Fe.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Me=k.partList;Me||(Me=k.partList=[]);var pe=F>0?Me[Me.length-1]:void 0,Le=F++,ie=new G.Part(new L.AttrList(ue),z,e,Le,pe);Me.push(ie),z.duration+=ie.duration;break}case"PRELOAD-HINT":{var te=new L.AttrList(ue);k.preloadHint=te;break}case"RENDITION-REPORT":{var re=new L.AttrList(ue);k.renditionReports=k.renditionReports||[],k.renditionReports.push(re);break}default:_.logger.warn("line parsed but not handled: "+ee);break}}}Q&&!Q.relurl?(M.pop(),H-=Q.duration,k.partList&&(k.fragmentHint=Q)):k.partList&&(d(z,Q),z.cc=Y,k.fragmentHint=z,X&&p(z,X,k));var K=M.length,j=M[0],Z=M[K-1];if(H+=k.skippedSegments*k.targetduration,H>0&&K&&Z){k.averagetargetduration=H/K;var q=Z.sn;k.endSN=q!=="initSegment"?q:0,k.live||(Z.endList=!0),j&&(k.startCC=j.cc)}else k.endSN=0,k.startCC=0;return k.fragmentHint&&(H+=k.fragmentHint.duration),k.totalduration=H,k.endCC=Y,oe>0&&n(M,oe),k},m}();function o(m,r){var a,e,c=new L.AttrList(m),E=(a=c.enumeratedString("METHOD"))!=null?a:"",y=c.URI,k=c.hexadecimalInteger("IV"),M=c.enumeratedString("KEYFORMATVERSIONS"),O=(e=c.enumeratedString("KEYFORMAT"))!=null?e:"identity";y&&c.IV&&!k&&_.logger.error("Invalid IV: "+c.IV);var U=y?h.resolve(y,r):"",F=(M||"1").split("/").map(Number).filter(Number.isFinite);return new R.LevelKey(E,U,O,F,k)}function s(m,r){["video","audio","text"].forEach(function(a){var e=m.filter(function(E){return(0,T.isCodecType)(E,a)});if(e.length){var c=e.filter(function(E){return E.lastIndexOf("avc1",0)===0||E.lastIndexOf("mp4a",0)===0});r[a+"Codec"]=c.length>0?c[0]:e[0],m=m.filter(function(E){return e.indexOf(E)===-1})}}),r.unknownCodecs=m}function l(m,r,a){var e=r[a];e&&(m[a]=e)}function n(m,r){for(var a=m[r],e=r;e--;){var c=m[e];if(!c)return;c.programDateTime=a.programDateTime-c.duration*1e3,a=c}}function d(m,r){m.rawProgramDateTime?m.programDateTime=Date.parse(m.rawProgramDateTime):r!=null&&r.programDateTime&&(m.programDateTime=r.endProgramDateTime),(0,W.isFiniteNumber)(m.programDateTime)||(m.programDateTime=null,m.rawProgramDateTime=null)}function v(m,r,a,e){m.relurl=r.URI,r.BYTERANGE&&m.setByteRange(r.BYTERANGE),m.level=a,m.sn="initSegment",e&&(m.levelkeys=e),m.initSegment=null}function p(m,r,a){m.levelkeys=r;var e=a.encryptedFragments;(!e.length||e[e.length-1].levelkeys!==r)&&Object.keys(r).some(function(c){return r[c].isCommonEncryption})&&e.push(m)}},"./src/loader/playlist-loader.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>g});var W=w("./src/polyfills/number.ts"),P=w("./src/events.ts"),N=w("./src/errors.ts"),D=w("./src/utils/logger.ts"),G=w("./src/loader/m3u8-parser.ts"),I=w("./src/types/loader.ts"),R=w("./src/utils/attr-list.ts");function L(x){var b=x.type;switch(b){case I.PlaylistContextType.AUDIO_TRACK:return I.PlaylistLevelType.AUDIO;case I.PlaylistContextType.SUBTITLE_TRACK:return I.PlaylistLevelType.SUBTITLE;default:return I.PlaylistLevelType.MAIN}}function _(x,b){var f=x.url;return(f===void 0||f.indexOf("data:")===0)&&(f=b.url),f}var T=function(){function x(f){this.hls=void 0,this.loaders=Object.create(null),this.hls=f,this.registerListeners()}var b=x.prototype;return b.startLoad=function(u){},b.stopLoad=function(){this.destroyInternalLoaders()},b.registerListeners=function(){var u=this.hls;u.on(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(P.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),u.on(P.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},b.unregisterListeners=function(){var u=this.hls;u.off(P.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(P.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off(P.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),u.off(P.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},b.createInternalLoader=function(u){var h=this.hls.config,o=h.pLoader,s=h.loader,l=o||s,n=new l(h);return u.loader=n,this.loaders[u.type]=n,n},b.getInternalLoader=function(u){return this.loaders[u.type]},b.resetInternalLoader=function(u){this.loaders[u]&&delete this.loaders[u]},b.destroyInternalLoaders=function(){for(var u in this.loaders){var h=this.loaders[u];h&&h.destroy(),this.resetInternalLoader(u)}},b.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},b.onManifestLoading=function(u,h){var o=h.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:I.PlaylistContextType.MANIFEST,url:o,deliveryDirectives:null})},b.onLevelLoading=function(u,h){var o=h.id,s=h.level,l=h.url,n=h.deliveryDirectives;this.load({id:o,groupId:null,level:s,responseType:"text",type:I.PlaylistContextType.LEVEL,url:l,deliveryDirectives:n})},b.onAudioTrackLoading=function(u,h){var o=h.id,s=h.groupId,l=h.url,n=h.deliveryDirectives;this.load({id:o,groupId:s,level:null,responseType:"text",type:I.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:n})},b.onSubtitleTrackLoading=function(u,h){var o=h.id,s=h.groupId,l=h.url,n=h.deliveryDirectives;this.load({id:o,groupId:s,level:null,responseType:"text",type:I.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:n})},b.load=function(u){var h,o=this.hls.config,s=this.getInternalLoader(u);if(s){var l=s.context;if(l&&l.url===u.url){D.logger.trace("[playlist-loader]: playlist request ongoing");return}D.logger.log("[playlist-loader]: aborting previous loader for type: "+u.type),s.abort()}var n,d,v,p;switch(u.type){case I.PlaylistContextType.MANIFEST:n=o.manifestLoadingMaxRetry,d=o.manifestLoadingTimeOut,v=o.manifestLoadingRetryDelay,p=o.manifestLoadingMaxRetryTimeout;break;case I.PlaylistContextType.LEVEL:case I.PlaylistContextType.AUDIO_TRACK:case I.PlaylistContextType.SUBTITLE_TRACK:n=0,d=o.levelLoadingTimeOut;break;default:n=o.levelLoadingMaxRetry,d=o.levelLoadingTimeOut,v=o.levelLoadingRetryDelay,p=o.levelLoadingMaxRetryTimeout;break}if(s=this.createInternalLoader(u),(h=u.deliveryDirectives)!==null&&h!==void 0&&h.part){var m;if(u.type===I.PlaylistContextType.LEVEL&&u.level!==null?m=this.hls.levels[u.level].details:u.type===I.PlaylistContextType.AUDIO_TRACK&&u.id!==null?m=this.hls.audioTracks[u.id].details:u.type===I.PlaylistContextType.SUBTITLE_TRACK&&u.id!==null&&(m=this.hls.subtitleTracks[u.id].details),m){var r=m.partTarget,a=m.targetduration;r&&a&&(d=Math.min(Math.max(r*3,a*.8)*1e3,d))}}var e={timeout:d,maxRetry:n,retryDelay:v,maxRetryDelay:p,highWaterMark:0},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(u,e,c)},b.loadsuccess=function(u,h,o,s){s===void 0&&(s=null),this.resetInternalLoader(o.type);var l=u.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(u,o,"no EXTM3U delimiter",s);return}h.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(u,h,o,s):this.handleMasterPlaylist(u,h,o,s)},b.loaderror=function(u,h,o){o===void 0&&(o=null),this.handleNetworkError(h,o,!1,u)},b.loadtimeout=function(u,h,o){o===void 0&&(o=null),this.handleNetworkError(h,o,!0)},b.handleMasterPlaylist=function(u,h,o,s){var l=this.hls,n=u.data,d=_(u,o),v=G.default.parseMasterPlaylist(n,d),p=v.levels,m=v.sessionData,r=v.sessionKeys;if(!p.length){this.handleManifestParsingError(u,o,"no level found in manifest",s);return}var a=p.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),e=p.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),c=G.default.parseMasterPlaylistMedia(n,d,"AUDIO",a),E=G.default.parseMasterPlaylistMedia(n,d,"SUBTITLES",e),y=G.default.parseMasterPlaylistMedia(n,d,"CLOSED-CAPTIONS");if(c.length){var k=c.some(function(M){return!M.url});!k&&p[0].audioCodec&&!p[0].attrs.AUDIO&&(D.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),c.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new R.AttrList({}),bitrate:0,url:""}))}l.trigger(P.Events.MANIFEST_LOADED,{levels:p,audioTracks:c,subtitles:E,captions:y,url:d,stats:h,networkDetails:s,sessionData:m,sessionKeys:r})},b.handleTrackOrLevelPlaylist=function(u,h,o,s){var l=this.hls,n=o.id,d=o.level,v=o.type,p=_(u,o),m=(0,W.isFiniteNumber)(n)?n:0,r=(0,W.isFiniteNumber)(d)?d:m,a=L(o),e=G.default.parseLevelPlaylist(u.data,p,r,a,m);if(!e.fragments.length){l.trigger(P.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:typeof o.level=="number"?o.level:void 0});return}if(v===I.PlaylistContextType.MANIFEST){var c={attrs:new R.AttrList({}),bitrate:0,details:e,name:"",url:p};l.trigger(P.Events.MANIFEST_LOADED,{levels:[c],audioTracks:[],url:p,stats:h,networkDetails:s,sessionData:null,sessionKeys:null})}h.parsing.end=performance.now(),o.levelDetails=e,this.handlePlaylistLoaded(u,h,o,s)},b.handleManifestParsingError=function(u,h,o,s){this.hls.trigger(P.Events.ERROR,{type:N.ErrorTypes.NETWORK_ERROR,details:N.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:h.type===I.PlaylistContextType.MANIFEST,url:u.url,reason:o,response:u,context:h,networkDetails:s})},b.handleNetworkError=function(u,h,o,s){o===void 0&&(o=!1),D.logger.warn("[playlist-loader]: A network "+(o?"timeout":"error")+" occurred while loading "+u.type+" level: "+u.level+" id: "+u.id+' group-id: "'+u.groupId+'"');var l=N.ErrorDetails.UNKNOWN,n=!1,d=this.getInternalLoader(u);switch(u.type){case I.PlaylistContextType.MANIFEST:l=o?N.ErrorDetails.MANIFEST_LOAD_TIMEOUT:N.ErrorDetails.MANIFEST_LOAD_ERROR,n=!0;break;case I.PlaylistContextType.LEVEL:l=o?N.ErrorDetails.LEVEL_LOAD_TIMEOUT:N.ErrorDetails.LEVEL_LOAD_ERROR,n=!1;break;case I.PlaylistContextType.AUDIO_TRACK:l=o?N.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:N.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,n=!1;break;case I.PlaylistContextType.SUBTITLE_TRACK:l=o?N.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:N.ErrorDetails.SUBTITLE_LOAD_ERROR,n=!1;break}d&&this.resetInternalLoader(u.type);var v={type:N.ErrorTypes.NETWORK_ERROR,details:l,fatal:n,url:u.url,loader:d,context:u,networkDetails:h};s&&(v.response=s),this.hls.trigger(P.Events.ERROR,v)},b.handlePlaylistLoaded=function(u,h,o,s){var l=o.type,n=o.level,d=o.id,v=o.groupId,p=o.loader,m=o.levelDetails,r=o.deliveryDirectives;if(!(m!=null&&m.targetduration)){this.handleManifestParsingError(u,o,"invalid target duration",s);return}if(!p)return;m.live&&(p.getCacheAge&&(m.ageHeader=p.getCacheAge()||0),(!p.getCacheAge||isNaN(m.ageHeader))&&(m.ageHeader=0));switch(l){case I.PlaylistContextType.MANIFEST:case I.PlaylistContextType.LEVEL:this.hls.trigger(P.Events.LEVEL_LOADED,{details:m,level:n||0,id:d||0,stats:h,networkDetails:s,deliveryDirectives:r});break;case I.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(P.Events.AUDIO_TRACK_LOADED,{details:m,id:d||0,groupId:v||"",stats:h,networkDetails:s,deliveryDirectives:r});break;case I.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(P.Events.SUBTITLE_TRACK_LOADED,{details:m,id:d||0,groupId:v||"",stats:h,networkDetails:s,deliveryDirectives:r});break}},x}();const g=T},"./src/polyfills/number.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{MAX_SAFE_INTEGER:()=>P,isFiniteNumber:()=>W});var W=Number.isFinite||function(N){return typeof N=="number"&&isFinite(N)},P=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>P});var W=function(){function N(){}return N.getSilentFrame=function(G,I){switch(G){case"mp4a.40.2":if(I===1)return new Uint8Array([0,200,0,128,35,128]);if(I===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(I===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(I===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(I===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(I===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(I===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(I===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(I===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},N}();const P=W},"./src/remux/mp4-generator.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>N});var W=Math.pow(2,32)-1,P=function(){function D(){}return D.init=function(){D.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var I;for(I in D.types)D.types.hasOwnProperty(I)&&(D.types[I]=[I.charCodeAt(0),I.charCodeAt(1),I.charCodeAt(2),I.charCodeAt(3)]);var R=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),L=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);D.HDLR_TYPES={video:R,audio:L};var _=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=T,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var g=new Uint8Array([105,115,111,109]),x=new Uint8Array([97,118,99,49]),b=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,g,b,g,x),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,_))},D.box=function(I){for(var R=8,L=arguments.length,_=new Array(L>1?L-1:0),T=1;T<L;T++)_[T-1]=arguments[T];for(var g=_.length,x=g;g--;)R+=_[g].byteLength;var b=new Uint8Array(R);for(b[0]=R>>24&255,b[1]=R>>16&255,b[2]=R>>8&255,b[3]=R&255,b.set(I,4),g=0,R=8;g<x;g++)b.set(_[g],R),R+=_[g].byteLength;return b},D.hdlr=function(I){return D.box(D.types.hdlr,D.HDLR_TYPES[I])},D.mdat=function(I){return D.box(D.types.mdat,I)},D.mdhd=function(I,R){R*=I;var L=Math.floor(R/(W+1)),_=Math.floor(R%(W+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,I>>24&255,I>>16&255,I>>8&255,I&255,L>>24,L>>16&255,L>>8&255,L&255,_>>24,_>>16&255,_>>8&255,_&255,85,196,0,0]))},D.mdia=function(I){return D.box(D.types.mdia,D.mdhd(I.timescale,I.duration),D.hdlr(I.type),D.minf(I))},D.mfhd=function(I){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,I&255]))},D.minf=function(I){return I.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(I)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(I))},D.moof=function(I,R,L){return D.box(D.types.moof,D.mfhd(I),D.traf(L,R))},D.moov=function(I){for(var R=I.length,L=[];R--;)L[R]=D.trak(I[R]);return D.box.apply(null,[D.types.moov,D.mvhd(I[0].timescale,I[0].duration)].concat(L).concat(D.mvex(I)))},D.mvex=function(I){for(var R=I.length,L=[];R--;)L[R]=D.trex(I[R]);return D.box.apply(null,[D.types.mvex].concat(L))},D.mvhd=function(I,R){R*=I;var L=Math.floor(R/(W+1)),_=Math.floor(R%(W+1)),T=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,I>>24&255,I>>16&255,I>>8&255,I&255,L>>24,L>>16&255,L>>8&255,L&255,_>>24,_>>16&255,_>>8&255,_&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return D.box(D.types.mvhd,T)},D.sdtp=function(I){var R=I.samples||[],L=new Uint8Array(4+R.length),_,T;for(_=0;_<R.length;_++)T=R[_].flags,L[_+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return D.box(D.types.sdtp,L)},D.stbl=function(I){return D.box(D.types.stbl,D.stsd(I),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))},D.avc1=function(I){var R=[],L=[],_,T,g;for(_=0;_<I.sps.length;_++)T=I.sps[_],g=T.byteLength,R.push(g>>>8&255),R.push(g&255),R=R.concat(Array.prototype.slice.call(T));for(_=0;_<I.pps.length;_++)T=I.pps[_],g=T.byteLength,L.push(g>>>8&255),L.push(g&255),L=L.concat(Array.prototype.slice.call(T));var x=D.box(D.types.avcC,new Uint8Array([1,R[3],R[4],R[5],252|3,224|I.sps.length].concat(R).concat([I.pps.length]).concat(L))),b=I.width,f=I.height,u=I.pixelRatio[0],h=I.pixelRatio[1];return D.box(D.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,b>>8&255,b&255,f>>8&255,f&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),x,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,h>>24,h>>16&255,h>>8&255,h&255])))},D.esds=function(I){var R=I.config.length;return new Uint8Array([0,0,0,0,3,23+R,0,1,0,4,15+R,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([R]).concat(I.config).concat([6,1,2]))},D.mp4a=function(I){var R=I.samplerate;return D.box(D.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,I.channelCount,0,16,0,0,0,0,R>>8&255,R&255,0,0]),D.box(D.types.esds,D.esds(I)))},D.mp3=function(I){var R=I.samplerate;return D.box(D.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,I.channelCount,0,16,0,0,0,0,R>>8&255,R&255,0,0]))},D.stsd=function(I){return I.type==="audio"?I.segmentCodec==="mp3"&&I.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(I)):D.box(D.types.stsd,D.STSD,D.mp4a(I)):D.box(D.types.stsd,D.STSD,D.avc1(I))},D.tkhd=function(I){var R=I.id,L=I.duration*I.timescale,_=I.width,T=I.height,g=Math.floor(L/(W+1)),x=Math.floor(L%(W+1));return D.box(D.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,R&255,0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255,x>>24,x>>16&255,x>>8&255,x&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,_>>8&255,_&255,0,0,T>>8&255,T&255,0,0]))},D.traf=function(I,R){var L=D.sdtp(I),_=I.id,T=Math.floor(R/(W+1)),g=Math.floor(R%(W+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,_>>24,_>>16&255,_>>8&255,_&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,g>>24,g>>16&255,g>>8&255,g&255])),D.trun(I,L.length+16+20+8+16+8+8),L)},D.trak=function(I){return I.duration=I.duration||4294967295,D.box(D.types.trak,D.tkhd(I),D.mdia(I))},D.trex=function(I){var R=I.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},D.trun=function(I,R){var L=I.samples||[],_=L.length,T=12+16*_,g=new Uint8Array(T),x,b,f,u,h,o;for(R+=8+T,g.set([I.type==="video"?1:0,0,15,1,_>>>24&255,_>>>16&255,_>>>8&255,_&255,R>>>24&255,R>>>16&255,R>>>8&255,R&255],0),x=0;x<_;x++)b=L[x],f=b.duration,u=b.size,h=b.flags,o=b.cts,g.set([f>>>24&255,f>>>16&255,f>>>8&255,f&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,h.degradPrio&240<<8,h.degradPrio&15,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*x);return D.box(D.types.trun,g)},D.initSegment=function(I){D.types||D.init();var R=D.moov(I),L=new Uint8Array(D.FTYP.byteLength+R.byteLength);return L.set(D.FTYP),L.set(R,D.FTYP.byteLength),L},D}();P.types=void 0,P.HDLR_TYPES=void 0,P.STTS=void 0,P.STSC=void 0,P.STCO=void 0,P.STSZ=void 0,P.VMHD=void 0,P.SMHD=void 0,P.STSD=void 0,P.FTYP=void 0,P.DINF=void 0;const N=P},"./src/remux/mp4-remuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>u,flushTextTrackMetadataCueSamples:()=>s,flushTextTrackUserdataCueSamples:()=>l,normalizePts:()=>h});var W=w("./src/polyfills/number.ts"),P=w("./src/remux/aac-helper.ts"),N=w("./src/remux/mp4-generator.ts"),D=w("./src/events.ts"),G=w("./src/errors.ts"),I=w("./src/utils/logger.ts"),R=w("./src/types/loader.ts"),L=w("./src/utils/timescale-conversion.ts");function _(){return _=Object.assign?Object.assign.bind():function(v){for(var p=1;p<arguments.length;p++){var m=arguments[p];for(var r in m)Object.prototype.hasOwnProperty.call(m,r)&&(v[r]=m[r])}return v},_.apply(this,arguments)}var T=10*1e3,g=1024,x=1152,b=null,f=null,u=function(){function v(m,r,a,e){if(e===void 0&&(e=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=m,this.config=r,this.typeSupported=a,this.ISGenerated=!1,b===null){var c=navigator.userAgent||"",E=c.match(/Chrome\/(\d+)/i);b=E?parseInt(E[1]):0}if(f===null){var y=navigator.userAgent.match(/Safari\/(\d+)/i);f=y?parseInt(y[1]):0}}var p=v.prototype;return p.destroy=function(){},p.resetTimeStamp=function(r){I.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=r},p.resetNextTimestamp=function(){I.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},p.resetInitSegment=function(){I.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},p.getVideoStartPts=function(r){var a=!1,e=r.reduce(function(c,E){var y=E.pts-c;return y<-4294967296?(a=!0,h(c,E.pts)):y>0?c:E.pts},r[0].pts);return a&&I.logger.debug("PTS rollover detected"),e},p.remux=function(r,a,e,c,E,y,k,M){var O,U,F,H,Y,Q,z=E,ee=E,J=r.pid>-1,X=a.pid>-1,oe=a.samples.length,le=r.samples.length>0,me=k&&oe>0||oe>1,Ae=(!J||le)&&(!X||me)||this.ISGenerated||k;if(Ae){this.ISGenerated||(F=this.generateIS(r,a,E));var ge=this.isVideoContiguous,ae=-1,ue;if(me&&(ae=o(a.samples),!ge&&this.config.forceKeyFrameOnDiscontinuity))if(Q=!0,ae>0){I.logger.warn("[mp4-remuxer]: Dropped "+ae+" out of "+oe+" video samples due to a missing keyframe");var ye=this.getVideoStartPts(a.samples);a.samples=a.samples.slice(ae),a.dropped+=ae,ee+=(a.samples[0].pts-ye)/a.inputTimeScale,ue=ee}else ae===-1&&(I.logger.warn("[mp4-remuxer]: No keyframe found out of "+oe+" video samples"),Q=!1);if(this.ISGenerated){if(le&&me){var Ee=this.getVideoStartPts(a.samples),_e=h(r.samples[0].pts,Ee)-Ee,Se=_e/a.inputTimeScale;z+=Math.max(0,Se),ee+=Math.max(0,-Se)}if(le){if(r.samplerate||(I.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),F=this.generateIS(r,a,E)),U=this.remuxAudio(r,z,this.isAudioContiguous,y,X||me||M===R.PlaylistLevelType.AUDIO?ee:void 0),me){var Te=U?U.endPTS-U.startPTS:0;a.inputTimeScale||(I.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),F=this.generateIS(r,a,E)),O=this.remuxVideo(a,ee,ge,Te)}}else me&&(O=this.remuxVideo(a,ee,ge,0));O&&(O.firstKeyFrame=ae,O.independent=ae!==-1,O.firstKeyFramePTS=ue)}}return this.ISGenerated&&(e.samples.length&&(Y=s(e,E,this._initPTS,this._initDTS)),c.samples.length&&(H=l(c,E,this._initPTS))),{audio:U,video:O,initSegment:F,independent:Q,text:H,id3:Y}},p.generateIS=function(r,a,e){var c=r.samples,E=a.samples,y=this.typeSupported,k={},M=!(0,W.isFiniteNumber)(this._initPTS),O="audio/mp4",U,F,H;if(M&&(U=F=Infinity),r.config&&c.length){r.timescale=r.samplerate;switch(r.segmentCodec){case"mp3":y.mpeg?(O="audio/mpeg",r.codec=""):y.mp3&&(r.codec="mp3");break}k.audio={id:"audio",container:O,codec:r.codec,initSegment:r.segmentCodec==="mp3"&&y.mpeg?new Uint8Array(0):N.default.initSegment([r]),metadata:{channelCount:r.channelCount}},M&&(H=r.inputTimeScale,U=F=c[0].pts-Math.round(H*e))}if(a.sps&&a.pps&&E.length&&(a.timescale=a.inputTimeScale,k.video={id:"main",container:"video/mp4",codec:a.codec,initSegment:N.default.initSegment([a]),metadata:{width:a.width,height:a.height}},M)){H=a.inputTimeScale;var Y=this.getVideoStartPts(E),Q=Math.round(H*e);F=Math.min(F,h(E[0].dts,Y)-Q),U=Math.min(U,Y-Q)}if(Object.keys(k).length)return this.ISGenerated=!0,M&&(this._initPTS=U,this._initDTS=F),{tracks:k,initPTS:U,timescale:H}},p.remuxVideo=function(r,a,e,c){var E=r.inputTimeScale,y=r.samples,k=[],M=y.length,O=this._initPTS,U=this.nextAvcDts,F=8,H=this.videoSampleDuration,Y,Q,z=Number.POSITIVE_INFINITY,ee=Number.NEGATIVE_INFINITY,J=!1;if(!e||U===null){var X=a*E,oe=y[0].pts-h(y[0].dts,y[0].pts);U=X-oe}for(var le=0;le<M;le++){var me=y[le];me.pts=h(me.pts-O,U),me.dts=h(me.dts-O,U),me.dts<y[le>0?le-1:le].dts&&(J=!0)}J&&y.sort(function(_t,vt){var lt=_t.dts-vt.dts,Ct=_t.pts-vt.pts;return lt||Ct}),Y=y[0].dts,Q=y[y.length-1].dts;var Ae=Q-Y,ge=Ae?Math.round(Ae/(M-1)):H||r.inputTimeScale/30;if(e){var ae=Y-U,ue=ae>ge,ye=ae<-1;if((ue||ye)&&(ue?I.logger.warn("AVC: "+(0,L.toMsFromMpegTsClock)(ae,!0)+" ms ("+ae+"dts) hole between fragments detected, filling it"):I.logger.warn("AVC: "+(0,L.toMsFromMpegTsClock)(-ae,!0)+" ms ("+ae+"dts) overlapping between fragments detected"),!ye||U>y[0].pts)){Y=U;var Ee=y[0].pts-ae;y[0].dts=Y,y[0].pts=Ee,I.logger.log("Video: First PTS/DTS adjusted: "+(0,L.toMsFromMpegTsClock)(Ee,!0)+"/"+(0,L.toMsFromMpegTsClock)(Y,!0)+", delta: "+(0,L.toMsFromMpegTsClock)(ae,!0)+" ms")}}Y=Math.max(0,Y);for(var _e=0,Se=0,Te=0;Te<M;Te++){for(var Pe=y[Te],we=Pe.units,be=we.length,Re=0,De=0;De<be;De++)Re+=we[De].data.length;Se+=Re,_e+=be,Pe.length=Re,Pe.dts=Math.max(Pe.dts,Y),z=Math.min(Pe.pts,z),ee=Math.max(Pe.pts,ee)}Q=y[M-1].dts;var ke=Se+4*_e+8,Ie;try{Ie=new Uint8Array(ke)}catch(_t){this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:G.ErrorTypes.MUX_ERROR,details:G.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ke,reason:"fail allocating video mdat "+ke});return}var xe=new DataView(Ie.buffer);xe.setUint32(0,ke),Ie.set(N.default.types.mdat,4);for(var Fe=!1,Me=Number.POSITIVE_INFINITY,pe=Number.POSITIVE_INFINITY,Le=Number.NEGATIVE_INFINITY,ie=Number.NEGATIVE_INFINITY,te=0;te<M;te++){for(var re=y[te],K=re.units,j=0,Z=0,q=K.length;Z<q;Z++){var se=K[Z],de=se.data,ve=se.data.byteLength;xe.setUint32(F,ve),F+=4,Ie.set(de,F),F+=ve,j+=4+ve}var Ue=void 0;if(te<M-1)H=y[te+1].dts-re.dts,Ue=y[te+1].pts-re.pts;else{var Ge=this.config,We=te>0?re.dts-y[te-1].dts:ge;if(Ue=te>0?re.pts-y[te-1].pts:ge,Ge.stretchShortVideoTrack&&this.nextAudioPts!==null){var it=Math.floor(Ge.maxBufferHole*E),$e=(c?z+c*E:this.nextAudioPts)-re.pts;$e>it?(H=$e-We,H<0?H=We:Fe=!0,I.logger.log("[mp4-remuxer]: It is approximately "+$e/90+" ms to the next segment; using duration "+H/90+" ms for the last video frame.")):H=We}else H=We}var Ne=Math.round(re.pts-re.dts);Me=Math.min(Me,H),Le=Math.max(Le,H),pe=Math.min(pe,Ue),ie=Math.max(ie,Ue),k.push(new n(re.key,H,j,Ne))}if(k.length){if(b){if(b<70){var st=k[0].flags;st.dependsOn=2,st.isNonSync=0}}else if(f&&(ie-pe<Le-Me&&ge/Le<.025&&k[0].cts===0)){I.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var je=Y,Je=0,ot=k.length;Je<ot;Je++){var Ye=je+k[Je].duration,ct=je+k[Je].cts;if(Je<ot-1){var bt=Ye+k[Je+1].cts;k[Je].duration=bt-ct}else k[Je].duration=Je?k[Je-1].duration:ge;k[Je].cts=0,je=Ye}}}console.assert(H!==null,"mp4SampleDuration must be computed"),H=Fe||!H?ge:H,this.nextAvcDts=U=Q+H,this.videoSampleDuration=H,this.isVideoContiguous=!0;var mt=N.default.moof(r.sequenceNumber++,Y,_({},r,{samples:k})),Tt="video",He={data1:mt,data2:Ie,startPTS:z/E,endPTS:(ee+H)/E,startDTS:Y/E,endDTS:U/E,type:Tt,hasAudio:!1,hasVideo:!0,nb:k.length,dropped:r.dropped};return r.samples=[],r.dropped=0,console.assert(Ie.length,"MDAT length must not be zero"),He},p.remuxAudio=function(r,a,e,c,E){var y=r.inputTimeScale,k=r.samplerate?r.samplerate:y,M=y/k,O=r.segmentCodec==="aac"?g:x,U=O*M,F=this._initPTS,H=r.segmentCodec==="mp3"&&this.typeSupported.mpeg,Y=[],Q=E!==void 0,z=r.samples,ee=H?0:8,J=this.nextAudioPts||-1,X=a*y;if(this.isAudioContiguous=e=e||z.length&&J>0&&(c&&Math.abs(X-J)<9e3||Math.abs(h(z[0].pts-F,X)-J)<20*U),z.forEach(function(se){se.pts=h(se.pts-F,X)}),!e||J<0){if(z=z.filter(function(se){return se.pts>=0}),!z.length)return;E===0?J=0:c&&!Q?J=Math.max(0,X):J=z[0].pts}if(r.segmentCodec==="aac")for(var oe=this.config.maxAudioFramesDrift,le=0,me=J;le<z.length;le++){var Ae=z[le],ge=Ae.pts,ae=ge-me,ue=Math.abs(1e3*ae/y);if(ae<=-oe*U&&Q)le===0&&(I.logger.warn("Audio frame @ "+(ge/y).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*ae/y)+" ms."),this.nextAudioPts=J=me=ge);else if(ae>=oe*U&&ue<T&&Q){var ye=Math.round(ae/U);me=ge-ye*U,me<0&&(ye--,me+=U),le===0&&(this.nextAudioPts=J=me),I.logger.warn("[mp4-remuxer]: Injecting "+ye+" audio frame @ "+(me/y).toFixed(3)+"s due to "+Math.round(1e3*ae/y)+" ms gap.");for(var Ee=0;Ee<ye;Ee++){var _e=Math.max(me,0),Se=P.default.getSilentFrame(r.manifestCodec||r.codec,r.channelCount);Se||(I.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Se=Ae.unit.subarray()),z.splice(le,0,{unit:Se,pts:_e}),me+=U,le++}}Ae.pts=me,me+=U}for(var Te=null,Pe=null,we,be=0,Re=z.length;Re--;)be+=z[Re].unit.byteLength;for(var De=0,ke=z.length;De<ke;De++){var Ie=z[De],xe=Ie.unit,Fe=Ie.pts;if(Pe!==null){var Me=Y[De-1];Me.duration=Math.round((Fe-Pe)/M)}else if(e&&r.segmentCodec==="aac"&&(Fe=J),Te=Fe,be>0){be+=ee;try{we=new Uint8Array(be)}catch(se){this.observer.emit(D.Events.ERROR,D.Events.ERROR,{type:G.ErrorTypes.MUX_ERROR,details:G.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:be,reason:"fail allocating audio mdat "+be});return}if(!H){var pe=new DataView(we.buffer);pe.setUint32(0,be),we.set(N.default.types.mdat,4)}}else return;we.set(xe,ee);var Le=xe.byteLength;ee+=Le,Y.push(new n(!0,O,Le,0)),Pe=Fe}var ie=Y.length;if(!ie)return;var te=Y[Y.length-1];this.nextAudioPts=J=Pe+M*te.duration;var re=H?new Uint8Array(0):N.default.moof(r.sequenceNumber++,Te/M,_({},r,{samples:Y}));r.samples=[];var K=Te/y,j=J/y,Z="audio",q={data1:re,data2:we,startPTS:K,endPTS:j,startDTS:K,endDTS:j,type:Z,hasAudio:!0,hasVideo:!1,nb:ie};return this.isAudioContiguous=!0,console.assert(we.length,"MDAT length must not be zero"),q},p.remuxEmptyAudio=function(r,a,e,c){var E=r.inputTimeScale,y=r.samplerate?r.samplerate:E,k=E/y,M=this.nextAudioPts,O=(M!==null?M:c.startDTS*E)+this._initDTS,U=c.endDTS*E+this._initDTS,F=k*g,H=Math.ceil((U-O)/F),Y=P.default.getSilentFrame(r.manifestCodec||r.codec,r.channelCount);if(I.logger.warn("[mp4-remuxer]: remux empty Audio"),!Y){I.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var Q=[],z=0;z<H;z++){var ee=O+z*F;Q.push({unit:Y,pts:ee,dts:ee})}return r.samples=Q,this.remuxAudio(r,a,e,!1)},v}();function h(v,p){var m;if(p===null)return v;for(p<v?m=-8589934592:m=8589934592;Math.abs(v-p)>4294967296;)v+=m;return v}function o(v){for(var p=0;p<v.length;p++)if(v[p].key)return p;return-1}function s(v,p,m,r){var a=v.samples.length;if(!a)return;for(var e=v.inputTimeScale,c=0;c<a;c++){var E=v.samples[c];E.pts=h(E.pts-m,p*e)/e,E.dts=h(E.dts-r,p*e)/e}var y=v.samples;return v.samples=[],{samples:y}}function l(v,p,m){var r=v.samples.length;if(!r)return;for(var a=v.inputTimeScale,e=0;e<r;e++){var c=v.samples[e];c.pts=h(c.pts-m,p*a)/a}v.samples.sort(function(y,k){return y.pts-k.pts});var E=v.samples;return v.samples=[],{samples:E}}var n=function(p,m,r,a){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=m,this.size=r,this.cts=a,this.flags=new d(p)},d=function(p){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=p?2:1,this.isNonSync=p?0:1}},"./src/remux/passthrough-remuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>L});var W=w("./src/polyfills/number.ts"),P=w("./src/remux/mp4-remuxer.ts"),N=w("./src/utils/mp4-tools.ts"),D=w("./src/loader/fragment.ts"),G=w("./src/utils/logger.ts"),I=function(){function _(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var T=_.prototype;return T.destroy=function(){},T.resetTimeStamp=function(x){this.initPTS=x,this.lastEndTime=null},T.resetNextTimestamp=function(){this.lastEndTime=null},T.resetInitSegment=function(x,b,f,u){this.audioCodec=b,this.videoCodec=f,this.generateInitSegment((0,N.patchEncyptionData)(x,u)),this.emitInitSegment=!0},T.generateInitSegment=function(x){var b=this.audioCodec,f=this.videoCodec;if(!x||!x.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=(0,N.parseInitSegment)(x);b||(b=R(u.audio,D.ElementaryStreamTypes.AUDIO)),f||(f=R(u.video,D.ElementaryStreamTypes.VIDEO));var h={};u.audio&&u.video?h.audiovideo={container:"video/mp4",codec:b+","+f,initSegment:x,id:"main"}:u.audio?h.audio={container:"audio/mp4",codec:b,initSegment:x,id:"audio"}:u.video?h.video={container:"video/mp4",codec:f,initSegment:x,id:"main"}:G.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=h},T.remux=function(x,b,f,u,h){var o,s=this.initPTS,l=this.lastEndTime,n={audio:void 0,video:void 0,text:u,id3:f,initSegment:void 0};(0,W.isFiniteNumber)(l)||(l=this.lastEndTime=h||0);var d=b.samples;if(!d||!d.length)return n;var v={initPTS:void 0,timescale:1},p=this.initData;if((!p||!p.length)&&(this.generateInitSegment(d),p=this.initData),!p||!p.length)return G.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),n;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1);var m=(0,N.getStartDTS)(p,d);(0,W.isFiniteNumber)(s)||(this.initPTS=v.initPTS=s=m-h);var r=(0,N.getDuration)(d,p),a=x?m-s:l,e=a+r;(0,N.offsetStartDTS)(p,d,s),r>0?this.lastEndTime=e:(G.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var c=!!p.audio,E=!!p.video,y="";c&&(y+="audio"),E&&(y+="video");var k={data1:d,startPTS:a,startDTS:a,endPTS:e,endDTS:e,type:y,hasAudio:c,hasVideo:E,nb:1,dropped:0};n.audio=k.type==="audio"?k:void 0,n.video=k.type!=="audio"?k:void 0,n.initSegment=v;var M=(o=this.initPTS)!=null?o:0;return n.id3=(0,P.flushTextTrackMetadataCueSamples)(f,h,M,M),u.samples.length&&(n.text=(0,P.flushTextTrackUserdataCueSamples)(u,h,M)),n},_}();function R(_,T){var g=_==null?void 0:_.codec;return g&&g.length>4?g:g==="hvc1"||g==="hev1"?"hvc1.1.c.L120.90":g==="av01"?"av01.0.04M.08":g==="avc1"||T===D.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}const L=I},"./src/task-loop.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>W});var W=function(){function P(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var N=P.prototype;return N.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},N.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},N.onHandlerDestroyed=function(){},N.hasInterval=function(){return!!this._tickInterval},N.hasNextTick=function(){return!!this._tickTimer},N.setInterval=function(G){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,G),!0)},N.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},N.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},N.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},N.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},N.doTick=function(){},P}()},"./src/types/cmcd.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{CMCDObjectType:()=>P,CMCDStreamType:()=>D,CMCDStreamingFormat:()=>N,CMCDVersion:()=>W});var W=1,P;(function(G){G.MANIFEST="m",G.AUDIO="a",G.VIDEO="v",G.MUXED="av",G.INIT="i",G.CAPTION="c",G.TIMED_TEXT="tt",G.KEY="k",G.OTHER="o"})(P||(P={}));var N;(function(G){G.DASH="d",G.HLS="h",G.SMOOTH="s",G.OTHER="o"})(N||(N={}));var D;(function(G){G.VOD="v",G.LIVE="l"})(D||(D={}))},"./src/types/demuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{MetadataSchema:()=>W});var W;(function(P){P.audioId3="org.id3",P.dateRange="com.apple.quicktime.HLS",P.emsg="https://aomedia.org/emsg/ID3"})(W||(W={}))},"./src/types/level.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{HdcpLevels:()=>G,HlsSkip:()=>I,HlsUrlParameters:()=>L,Level:()=>_,getSkipValue:()=>R});function W(T,g){for(var x=0;x<g.length;x++){var b=g[x];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(T,N(b.key),b)}}function P(T,g,x){return g&&W(T.prototype,g),x&&W(T,x),Object.defineProperty(T,"prototype",{writable:!1}),T}function N(T){var g=D(T,"string");return typeof g=="symbol"?g:String(g)}function D(T,g){if(typeof T!="object"||T===null)return T;var x=T[Symbol.toPrimitive];if(x!==void 0){var b=x.call(T,g||"default");if(typeof b!="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(T)}var G=["NONE","TYPE-0","TYPE-1","TYPE-2",null],I;(function(T){T.No="",T.Yes="YES",T.v2="v2"})(I||(I={}));function R(T,g){var x=T.canSkipUntil,b=T.canSkipDateRanges,f=T.endSN,u=g!==void 0?g-f:0;return x&&u<x?b?I.v2:I.Yes:I.No}var L=function(){function T(x,b,f){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=b,this.skip=f}var g=T.prototype;return g.addDirectives=function(b){var f=new self.URL(b);return this.msn!==void 0&&f.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&f.searchParams.set("_HLS_part",this.part.toString()),this.skip&&f.searchParams.set("_HLS_skip",this.skip),f.href},T}(),_=function(){function T(g){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=[g.url],this.attrs=g.attrs,this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return P(T,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(x){var b=x%this.url.length;this._urlId!==b&&(this.details=void 0,this._urlId=b)}}]),T}()},"./src/types/loader.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{PlaylistContextType:()=>W,PlaylistLevelType:()=>P});var W;(function(N){N.MANIFEST="manifest",N.LEVEL="level",N.AUDIO_TRACK="audioTrack",N.SUBTITLE_TRACK="subtitleTrack"})(W||(W={}));var P;(function(N){N.MAIN="main",N.AUDIO="audio",N.SUBTITLE="subtitle"})(P||(P={}))},"./src/types/transmuxer.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{ChunkMetadata:()=>W});var W=function(D,G,I,R,L,_){R===void 0&&(R=0),L===void 0&&(L=-1),_===void 0&&(_=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=P(),this.buffering={audio:P(),video:P(),audiovideo:P()},this.level=D,this.sn=G,this.id=I,this.size=R,this.part=L,this.partial=_};function P(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{AttrList:()=>N});var W=/^(\d+)x(\d+)$/,P=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,N=function(){function D(I){typeof I=="string"&&(I=D.parseAttrList(I));for(var R in I)I.hasOwnProperty(R)&&(this[R]=I[R])}var G=D.prototype;return G.decimalInteger=function(R){var L=parseInt(this[R],10);return L>Number.MAX_SAFE_INTEGER?Infinity:L},G.hexadecimalInteger=function(R){if(this[R]){var L=(this[R]||"0x").slice(2);L=(L.length&1?"0":"")+L;for(var _=new Uint8Array(L.length/2),T=0;T<L.length/2;T++)_[T]=parseInt(L.slice(T*2,T*2+2),16);return _}else return null},G.hexadecimalIntegerAsNumber=function(R){var L=parseInt(this[R],16);return L>Number.MAX_SAFE_INTEGER?Infinity:L},G.decimalFloatingPoint=function(R){return parseFloat(this[R])},G.optionalFloat=function(R,L){var _=this[R];return _?parseFloat(_):L},G.enumeratedString=function(R){return this[R]},G.bool=function(R){return this[R]==="YES"},G.decimalResolution=function(R){var L=W.exec(this[R]);return L===null?void 0:{width:parseInt(L[1],10),height:parseInt(L[2],10)}},D.parseAttrList=function(R){var L,_={},T='"';for(P.lastIndex=0;(L=P.exec(R))!==null;){var g=L[2];g.indexOf(T)===0&&g.lastIndexOf(T)===g.length-1&&(g=g.slice(1,-1)),_[L[1]]=g}return _},D}()},"./src/utils/binary-search.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>P});var W={search:function(D,G){for(var I=0,R=D.length-1,L=null,_=null;I<=R;){L=(I+R)/2|0,_=D[L];var T=G(_);if(T>0)I=L+1;else if(T<0)R=L-1;else return _}return null}};const P=W},"./src/utils/buffer-helper.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{BufferHelper:()=>N});var W=w("./src/utils/logger.ts"),P={length:0,start:function(){return 0},end:function(){return 0}},N=function(){function D(){}return D.isBuffered=function(I,R){try{if(I){for(var L=D.getBuffered(I),_=0;_<L.length;_++)if(R>=L.start(_)&&R<=L.end(_))return!0}}catch(T){}return!1},D.bufferInfo=function(I,R,L){try{if(I){var _=D.getBuffered(I),T=[],g;for(g=0;g<_.length;g++)T.push({start:_.start(g),end:_.end(g)});return this.bufferedInfo(T,R,L)}}catch(x){}return{len:0,start:R,end:R,nextStart:void 0}},D.bufferedInfo=function(I,R,L){R=Math.max(0,R),I.sort(function(n,d){var v=n.start-d.start;return v||d.end-n.end});var _=[];if(L)for(var T=0;T<I.length;T++){var g=_.length;if(g){var x=_[g-1].end;I[T].start-x<L?I[T].end>x&&(_[g-1].end=I[T].end):_.push(I[T])}else _.push(I[T])}else _=I;for(var b=0,f,u=R,h=R,o=0;o<_.length;o++){var s=_[o].start,l=_[o].end;if(R+L>=s&&R<l)u=s,h=l,b=h-R;else if(R+L<s){f=s;break}}return{len:b,start:u||0,end:h||0,nextStart:f}},D.getBuffered=function(I){try{return I.buffered}catch(R){return W.logger.log("failed to get media.buffered",R),P}},D}()},"./src/utils/cea-608-parser.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{CaptionScreen:()=>o,Row:()=>h,default:()=>p});var W=w("./src/utils/logger.ts"),P={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},N=function(r){var a=r;return P.hasOwnProperty(r)&&(a=P[r]),String.fromCharCode(a)},D=15,G=100,I={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},R={17:2,18:4,21:6,22:8,23:10,19:13,20:15},L={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},_={25:2,26:4,29:6,30:8,31:10,27:13,28:15},T=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],g;(function(m){m[m.ERROR=0]="ERROR",m[m.TEXT=1]="TEXT",m[m.WARNING=2]="WARNING",m[m.INFO=2]="INFO",m[m.DEBUG=3]="DEBUG",m[m.DATA=3]="DATA"})(g||(g={}));var x=function(){function m(){this.time=null,this.verboseLevel=g.ERROR}var r=m.prototype;return r.log=function(e,c){if(this.verboseLevel>=e){var E=typeof c=="function"?c():c;W.logger.log(this.time+" ["+e+"] "+E)}},m}(),b=function(r){for(var a=[],e=0;e<r.length;e++)a.push(r[e].toString(16));return a},f=function(){function m(a,e,c,E,y){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=a||"white",this.underline=e||!1,this.italics=c||!1,this.background=E||"black",this.flash=y||!1}var r=m.prototype;return r.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},r.setStyles=function(e){for(var c=["foreground","underline","italics","background","flash"],E=0;E<c.length;E++){var y=c[E];e.hasOwnProperty(y)&&(this[y]=e[y])}},r.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},r.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},r.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},r.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},m}(),u=function(){function m(a,e,c,E,y,k){this.uchar=void 0,this.penState=void 0,this.uchar=a||" ",this.penState=new f(e,c,E,y,k)}var r=m.prototype;return r.reset=function(){this.uchar=" ",this.penState.reset()},r.setChar=function(e,c){this.uchar=e,this.penState.copy(c)},r.setPenState=function(e){this.penState.copy(e)},r.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},r.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},r.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},m}(),h=function(){function m(a){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var e=0;e<G;e++)this.chars.push(new u);this.logger=a,this.pos=0,this.currPenState=new f}var r=m.prototype;return r.equals=function(e){for(var c=!0,E=0;E<G;E++)if(!this.chars[E].equals(e.chars[E])){c=!1;break}return c},r.copy=function(e){for(var c=0;c<G;c++)this.chars[c].copy(e.chars[c])},r.isEmpty=function(){for(var e=!0,c=0;c<G;c++)if(!this.chars[c].isEmpty()){e=!1;break}return e},r.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(g.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>G&&(this.logger.log(g.DEBUG,"Too large cursor position "+this.pos),this.pos=G)},r.moveCursor=function(e){var c=this.pos+e;if(e>1)for(var E=this.pos+1;E<c+1;E++)this.chars[E].setPenState(this.currPenState);this.setCursor(c)},r.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},r.insertChar=function(e){var c=this;e>=144&&this.backSpace();var E=N(e);if(this.pos>=G){this.logger.log(g.ERROR,function(){return"Cannot insert "+e.toString(16)+" ("+E+") at position "+c.pos+". Skipping it!"});return}this.chars[this.pos].setChar(E,this.currPenState),this.moveCursor(1)},r.clearFromPos=function(e){var c;for(c=e;c<G;c++)this.chars[c].reset()},r.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},r.clearToEndOfRow=function(){this.clearFromPos(this.pos)},r.getTextString=function(){for(var e=[],c=!0,E=0;E<G;E++){var y=this.chars[E].uchar;y!==" "&&(c=!1),e.push(y)}return c?"":e.join("")},r.setPenStyles=function(e){this.currPenState.setStyles(e);var c=this.chars[this.pos];c.setPenState(this.currPenState)},m}(),o=function(){function m(a){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var e=0;e<D;e++)this.rows.push(new h(a));this.logger=a,this.currRow=D-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var r=m.prototype;return r.reset=function(){for(var e=0;e<D;e++)this.rows[e].clear();this.currRow=D-1},r.equals=function(e){for(var c=!0,E=0;E<D;E++)if(!this.rows[E].equals(e.rows[E])){c=!1;break}return c},r.copy=function(e){for(var c=0;c<D;c++)this.rows[c].copy(e.rows[c])},r.isEmpty=function(){for(var e=!0,c=0;c<D;c++)if(!this.rows[c].isEmpty()){e=!1;break}return e},r.backSpace=function(){var e=this.rows[this.currRow];e.backSpace()},r.clearToEndOfRow=function(){var e=this.rows[this.currRow];e.clearToEndOfRow()},r.insertChar=function(e){var c=this.rows[this.currRow];c.insertChar(e)},r.setPen=function(e){var c=this.rows[this.currRow];c.setPenStyles(e)},r.moveCursor=function(e){var c=this.rows[this.currRow];c.moveCursor(e)},r.setCursor=function(e){this.logger.log(g.INFO,"setCursor: "+e);var c=this.rows[this.currRow];c.setCursor(e)},r.setPAC=function(e){this.logger.log(g.INFO,function(){return"pacData = "+JSON.stringify(e)});var c=e.row-1;if(this.nrRollUpRows&&c<this.nrRollUpRows-1&&(c=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==c){for(var E=0;E<D;E++)this.rows[E].clear();var y=this.currRow+1-this.nrRollUpRows,k=this.lastOutputScreen;if(k){var M=k.rows[y].cueStartTime,O=this.logger.time;if(M&&O!==null&&M<O)for(var U=0;U<this.nrRollUpRows;U++)this.rows[c-this.nrRollUpRows+U+1].copy(k.rows[y+U])}}this.currRow=c;var F=this.rows[this.currRow];if(e.indent!==null){var H=e.indent,Y=Math.max(H-1,0);F.setCursor(e.indent),e.color=F.chars[Y].penState.foreground}var Q={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(Q)},r.setBkgData=function(e){this.logger.log(g.INFO,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},r.setRollUpRows=function(e){this.nrRollUpRows=e},r.rollUp=function(){var e=this;if(this.nrRollUpRows===null){this.logger.log(g.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(g.TEXT,function(){return e.getDisplayText()});var c=this.currRow+1-this.nrRollUpRows,E=this.rows.splice(c,1)[0];E.clear(),this.rows.splice(this.currRow,0,E),this.logger.log(g.INFO,"Rolling up")},r.getDisplayText=function(e){e=e||!1;for(var c=[],E="",y=-1,k=0;k<D;k++){var M=this.rows[k].getTextString();M&&(y=k+1,e?c.push("Row "+y+": '"+M+"'"):c.push(M.trim()))}return c.length>0&&(e?E="["+c.join(" | ")+"]":E=c.join(`
`)),E},r.getTextAndFormat=function(){return this.rows},m}(),s=function(){function m(a,e,c){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=a,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new o(c),this.nonDisplayedMemory=new o(c),this.lastOutputScreen=new o(c),this.currRollUpRow=this.displayedMemory.rows[D-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=c}var r=m.prototype;return r.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[D-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},r.getHandler=function(){return this.outputFilter},r.setHandler=function(e){this.outputFilter=e},r.setPAC=function(e){this.writeScreen.setPAC(e)},r.setBkgData=function(e){this.writeScreen.setBkgData(e)},r.setMode=function(e){if(e===this.mode)return;this.mode=e,this.logger.log(g.INFO,function(){return"MODE="+e}),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e},r.insertChars=function(e){for(var c=this,E=0;E<e.length;E++)this.writeScreen.insertChar(e[E]);var y=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(g.INFO,function(){return y+": "+c.writeScreen.getDisplayText(!0)}),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(g.TEXT,function(){return"DISPLAYED: "+c.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},r.ccRCL=function(){this.logger.log(g.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},r.ccBS=function(){if(this.logger.log(g.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},r.ccAOF=function(){},r.ccAON=function(){},r.ccDER=function(){this.logger.log(g.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},r.ccRU=function(e){this.logger.log(g.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},r.ccFON=function(){this.logger.log(g.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},r.ccRDC=function(){this.logger.log(g.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},r.ccTR=function(){this.logger.log(g.INFO,"TR"),this.setMode("MODE_TEXT")},r.ccRTD=function(){this.logger.log(g.INFO,"RTD"),this.setMode("MODE_TEXT")},r.ccEDM=function(){this.logger.log(g.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},r.ccCR=function(){this.logger.log(g.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},r.ccENM=function(){this.logger.log(g.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},r.ccEOC=function(){var e=this;if(this.logger.log(g.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var c=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=c,this.writeScreen=this.nonDisplayedMemory,this.logger.log(g.TEXT,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},r.ccTO=function(e){this.logger.log(g.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},r.ccMIDROW=function(e){var c={flash:!1};if(c.underline=e%2===1,c.italics=e>=46,c.italics)c.foreground="white";else{var E=Math.floor(e/2)-16,y=["white","green","blue","cyan","red","yellow","magenta"];c.foreground=y[E]}this.logger.log(g.INFO,"MIDROW: "+JSON.stringify(c)),this.writeScreen.setPen(c)},r.outputDataUpdate=function(e){e===void 0&&(e=!1);var c=this.logger.time;if(c===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=c:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,c,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:c),this.lastOutputScreen.copy(this.displayedMemory))},r.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},m}(),l=function(){function m(a,e,c){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var E=new x;this.channels=[null,new s(a,e,E),new s(a+1,c,E)],this.cmdHistory=v(),this.logger=E}var r=m.prototype;return r.getHandler=function(e){return this.channels[e].getHandler()},r.setHandler=function(e,c){this.channels[e].setHandler(c)},r.addData=function(e,c){var E,y,k,M=!1;this.logger.time=e;for(var O=0;O<c.length;O+=2){if(y=c[O]&127,k=c[O+1]&127,y===0&&k===0)continue;if(this.logger.log(g.DATA,"["+b([c[O],c[O+1]])+"] -> ("+b([y,k])+")"),E=this.parseCmd(y,k),E||(E=this.parseMidrow(y,k)),E||(E=this.parsePAC(y,k)),E||(E=this.parseBackgroundAttributes(y,k)),!E&&(M=this.parseChars(y,k),M)){var U=this.currentChannel;if(U&&U>0){var F=this.channels[U];F.insertChars(M)}else this.logger.log(g.WARNING,"No channel found yet. TEXT-MODE?")}!E&&!M&&this.logger.log(g.WARNING,"Couldn't parse cleaned data "+b([y,k])+" orig: "+b([c[O],c[O+1]]))}},r.parseCmd=function(e,c){var E=this.cmdHistory,y=(e===20||e===28||e===21||e===29)&&c>=32&&c<=47,k=(e===23||e===31)&&c>=33&&c<=35;if(!(y||k))return!1;if(d(e,c,E))return n(null,null,E),this.logger.log(g.DEBUG,"Repeated command ("+b([e,c])+") is dropped"),!0;var M=e===20||e===21||e===23?1:2,O=this.channels[M];return e===20||e===21||e===28||e===29?c===32?O.ccRCL():c===33?O.ccBS():c===34?O.ccAOF():c===35?O.ccAON():c===36?O.ccDER():c===37?O.ccRU(2):c===38?O.ccRU(3):c===39?O.ccRU(4):c===40?O.ccFON():c===41?O.ccRDC():c===42?O.ccTR():c===43?O.ccRTD():c===44?O.ccEDM():c===45?O.ccCR():c===46?O.ccENM():c===47&&O.ccEOC():O.ccTO(c-32),n(e,c,E),this.currentChannel=M,!0},r.parseMidrow=function(e,c){var E=0;if((e===17||e===25)&&c>=32&&c<=47){if(e===17?E=1:E=2,E!==this.currentChannel)return this.logger.log(g.ERROR,"Mismatch channel in midrow parsing"),!1;var y=this.channels[E];return y?(y.ccMIDROW(c),this.logger.log(g.DEBUG,"MIDROW ("+b([e,c])+")"),!0):!1}return!1},r.parsePAC=function(e,c){var E,y=this.cmdHistory,k=(e>=17&&e<=23||e>=25&&e<=31)&&c>=64&&c<=127,M=(e===16||e===24)&&c>=64&&c<=95;if(!(k||M))return!1;if(d(e,c,y))return n(null,null,y),!0;var O=e<=23?1:2;c>=64&&c<=95?E=O===1?I[e]:L[e]:E=O===1?R[e]:_[e];var U=this.channels[O];return U?(U.setPAC(this.interpretPAC(E,c)),n(e,c,y),this.currentChannel=O,!0):!1},r.interpretPAC=function(e,c){var E,y={color:null,italics:!1,indent:null,underline:!1,row:e};return c>95?E=c-96:E=c-64,y.underline=(E&1)===1,E<=13?y.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(E/2)]:E<=15?(y.italics=!0,y.color="white"):y.indent=Math.floor((E-16)/2)*4,y},r.parseChars=function(e,c){var E,y=null,k=null;if(e>=25?(E=2,k=e-8):(E=1,k=e),k>=17&&k<=19){var M;k===17?M=c+80:k===18?M=c+112:M=c+144,this.logger.log(g.INFO,"Special char '"+N(M)+"' in channel "+E),y=[M]}else e>=32&&e<=127&&(y=c===0?[e]:[e,c]);if(y){var O=b(y);this.logger.log(g.DEBUG,"Char codes = "+O.join(",")),n(e,c,this.cmdHistory)}return y},r.parseBackgroundAttributes=function(e,c){var E=(e===16||e===24)&&c>=32&&c<=47,y=(e===23||e===31)&&c>=45&&c<=47;if(!(E||y))return!1;var k,M={};e===16||e===24?(k=Math.floor((c-32)/2),M.background=T[k],c%2===1&&(M.background=M.background+"_semi")):c===45?M.background="transparent":(M.foreground="black",c===47&&(M.underline=!0));var O=e<=23?1:2,U=this.channels[O];return U.setBkgData(M),n(e,c,this.cmdHistory),!0},r.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var c=this.channels[e];c&&c.reset()}this.cmdHistory=v()},r.cueSplitAtTime=function(e){for(var c=0;c<this.channels.length;c++){var E=this.channels[c];E&&E.cueSplitAtTime(e)}},m}();function n(m,r,a){a.a=m,a.b=r}function d(m,r,a){return a.a===m&&a.b===r}function v(){return{a:null,b:null}}const p=l},"./src/utils/codecs.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{isCodecSupportedInMp4:()=>N,isCodecType:()=>P});var W={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}};function P(D,G){var I=W[G];return!!I&&I[D.slice(0,4)]===!0}function N(D,G){return MediaSource.isTypeSupported((G||"video")+'/mp4;codecs="'+D+'"')}},"./src/utils/cues.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>I});var W=w("./src/utils/vttparser.ts"),P=w("./src/utils/webvtt-parser.ts"),N=w("./src/utils/texttrack-utils.ts"),D=/\s/,G={newCue:function(L,_,T,g){for(var x=[],b,f,u,h,o,s=self.VTTCue||self.TextTrackCue,l=0;l<g.rows.length;l++)if(b=g.rows[l],u=!0,h=0,o="",!b.isEmpty()){for(var n=0;n<b.chars.length;n++)D.test(b.chars[n].uchar)&&u?h++:(o+=b.chars[n].uchar,u=!1);b.cueStartTime=_,_===T&&(T+=1e-4),h>=16?h--:h++;var d=(0,W.fixLineBreaks)(o.trim()),v=(0,P.generateCueId)(_,T,d);(!L||!L.cues||!L.cues.getCueById(v))&&(f=new s(_,T,d),f.id=v,f.line=l+1,f.align="left",f.position=10+Math.min(80,Math.floor(h*8/32)*10),x.push(f))}return L&&x.length&&(x.sort(function(p,m){return p.line==="auto"||m.line==="auto"?0:p.line>8&&m.line>8?m.line-p.line:p.line-m.line}),x.forEach(function(p){return(0,N.addCueToTrack)(L,p)})),x}};const I=G},"./src/utils/discontinuities.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{adjustSlidingStart:()=>L,alignMediaPlaylistByPDT:()=>x,alignPDT:()=>g,alignStream:()=>_,findDiscontinuousReferenceFrag:()=>I,findFirstFragWithCC:()=>D,shouldAlignOnDiscontinuities:()=>G});var W=w("./src/polyfills/number.ts"),P=w("./src/utils/logger.ts"),N=w("./src/controller/level-helper.ts");function D(b,f){for(var u=null,h=0,o=b.length;h<o;h++){var s=b[h];if(s&&s.cc===f){u=s;break}}return u}function G(b,f,u){return!!(f.details&&(u.endCC>u.startCC||b&&b.cc<u.startCC))}function I(b,f,u){u===void 0&&(u=0);var h=b.fragments,o=f.fragments;if(!o.length||!h.length){P.logger.log("No fragments to align");return}var s=D(h,o[0].cc);if(!s||s&&!s.startPTS){P.logger.log("No frag in previous level to align on");return}return s}function R(b,f){if(b){var u=b.start+f;b.start=b.startPTS=u,b.endPTS=u+b.duration}}function L(b,f){for(var u=f.fragments,h=0,o=u.length;h<o;h++)R(u[h],b);f.fragmentHint&&R(f.fragmentHint,b),f.alignedSliding=!0}function _(b,f,u){if(!f)return;T(b,u,f),!u.alignedSliding&&f.details&&g(u,f.details),!u.alignedSliding&&f.details&&!u.skippedSegments&&(0,N.adjustSliding)(f.details,u)}function T(b,f,u){if(G(b,u,f)){var h=I(u.details,f);h&&(0,W.isFiniteNumber)(h.start)&&(P.logger.log("Adjusting PTS using last level due to CC increase within current level "+f.url),L(h.start,f))}}function g(b,f){if(!f.fragments.length||!b.hasProgramDateTime||!f.hasProgramDateTime)return;var u=f.fragments[0].programDateTime,h=b.fragments[0].programDateTime,o=(h-u)/1e3+f.fragments[0].start;o&&(0,W.isFiniteNumber)(o)&&(P.logger.log("Adjusting PTS using programDateTime delta "+(h-u)+"ms, sliding:"+o.toFixed(3)+" "+b.url+" "),L(o,b))}function x(b,f){if(!b.hasProgramDateTime||!f.hasProgramDateTime)return;var u=b.fragments,h=f.fragments;if(!u.length||!h.length)return;var o=Math.round(h.length/2)-1,s=h[o],l=D(u,s.cc)||u[Math.round(u.length/2)-1],n=s.programDateTime,d=l.programDateTime;if(n===null||d===null)return;var v=(d-n)/1e3-(l.start-s.start);L(v,b)}},"./src/utils/ewma-bandwidth-estimator.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>N});var W=w("./src/utils/ewma.ts"),P=function(){function D(I,R,L){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=L,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new W.default(I),this.fast_=new W.default(R)}var G=D.prototype;return G.update=function(R,L){var _=this.slow_,T=this.fast_;this.slow_.halfLife!==R&&(this.slow_=new W.default(R,_.getEstimate(),_.getTotalWeight())),this.fast_.halfLife!==L&&(this.fast_=new W.default(L,T.getEstimate(),T.getTotalWeight()))},G.sample=function(R,L){R=Math.max(R,this.minDelayMs_);var _=8*L,T=R/1e3,g=_/T;this.fast_.sample(T,g),this.slow_.sample(T,g)},G.canEstimate=function(){var R=this.fast_;return R&&R.getTotalWeight()>=this.minWeight_},G.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},G.destroy=function(){},D}();const N=P},"./src/utils/ewma.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>P});var W=function(){function N(G,I,R){I===void 0&&(I=0),R===void 0&&(R=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=G,this.alpha_=G?Math.exp(Math.log(.5)/G):0,this.estimate_=I,this.totalWeight_=R}var D=N.prototype;return D.sample=function(I,R){var L=Math.pow(this.alpha_,I);this.estimate_=R*(1-L)+L*this.estimate_,this.totalWeight_+=I},D.getTotalWeight=function(){return this.totalWeight_},D.getEstimate=function(){if(this.alpha_){var I=1-Math.pow(this.alpha_,this.totalWeight_);if(I)return this.estimate_/I}return this.estimate_},N}();const P=W},"./src/utils/fetch-loader.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>o,fetchSupported:()=>x});var W=w("./src/polyfills/number.ts"),P=w("./src/loader/load-stats.ts"),N=w("./src/demux/chunk-cache.ts");function D(s,l){s.prototype=Object.create(l.prototype),s.prototype.constructor=s,_(s,l)}function G(s){var l=typeof Map=="function"?new Map:void 0;return G=function(d){if(d===null||!L(d))return d;if(typeof d!="function")throw new TypeError("Super expression must either be null or a function");if(typeof l!="undefined"){if(l.has(d))return l.get(d);l.set(d,v)}function v(){return I(d,arguments,T(this).constructor)}return v.prototype=Object.create(d.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),_(v,d)},G(s)}function I(s,l,n){return R()?I=Reflect.construct.bind():I=function(v,p,m){var r=[null];r.push.apply(r,p);var a=Function.bind.apply(v,r),e=new a;return m&&_(e,m.prototype),e},I.apply(null,arguments)}function R(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(s){return!1}}function L(s){return Function.toString.call(s).indexOf("[native code]")!==-1}function _(s,l){return _=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,v){return d.__proto__=v,d},_(s,l)}function T(s){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},T(s)}function g(){return g=Object.assign?Object.assign.bind():function(s){for(var l=1;l<arguments.length;l++){var n=arguments[l];for(var d in n)Object.prototype.hasOwnProperty.call(n,d)&&(s[d]=n[d])}return s},g.apply(this,arguments)}function x(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(s){}return!1}var b=function(){function s(n){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=n.fetchSetup||u,this.controller=new self.AbortController,this.stats=new P.LoadStats}var l=s.prototype;return l.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},l.abortInternal=function(){var d=this.response;(!d||!d.ok)&&(this.stats.aborted=!0,this.controller.abort())},l.abort=function(){var d;this.abortInternal(),(d=this.callbacks)!==null&&d!==void 0&&d.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},l.load=function(d,v,p){var m=this,r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();var a=f(d,this.controller.signal),e=p.onProgress,c=d.responseType==="arraybuffer",E=c?"byteLength":"length";this.context=d,this.config=v,this.callbacks=p,this.request=this.fetchSetup(d,a),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){m.abortInternal(),p.onTimeout(r,d,m.response)},v.timeout),self.fetch(this.request).then(function(y){if(m.response=m.loader=y,!y.ok){var k=y.status,M=y.statusText;throw new h(M||"fetch, bad network response",k,y)}return r.loading.first=Math.max(self.performance.now(),r.loading.start),r.total=parseInt(y.headers.get("Content-Length")||"0"),e&&(0,W.isFiniteNumber)(v.highWaterMark)?m.loadProgressively(y,r,d,v.highWaterMark,e):c?y.arrayBuffer():y.text()}).then(function(y){var k=m.response;self.clearTimeout(m.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);var M=y[E];M&&(r.loaded=r.total=M);var O={url:k.url,data:y};e&&!(0,W.isFiniteNumber)(v.highWaterMark)&&e(r,d,y,k),p.onSuccess(O,r,d,k)}).catch(function(y){if(self.clearTimeout(m.requestTimeout),r.aborted)return;var k=y&&y.code||0,M=y?y.message:null;p.onError({code:k,text:M},d,y?y.details:null)})},l.getCacheAge=function(){var d=null;if(this.response){var v=this.response.headers.get("age");d=v?parseFloat(v):null}return d},l.loadProgressively=function(d,v,p,m,r){m===void 0&&(m=0);var a=new N.default,e=d.body.getReader(),c=function E(){return e.read().then(function(y){if(y.done)return a.dataLength&&r(v,p,a.flush(),d),Promise.resolve(new ArrayBuffer(0));var k=y.value,M=k.length;return v.loaded+=M,M<m||a.dataLength?(a.push(k),a.dataLength>=m&&r(v,p,a.flush(),d)):r(v,p,k,d),E()}).catch(function(){return Promise.reject()})};return c()},s}();function f(s,l){var n={method:"GET",mode:"cors",credentials:"same-origin",signal:l,headers:new self.Headers(g({},s.headers))};return s.rangeEnd&&n.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),n}function u(s,l){return new self.Request(s.url,l)}var h=function(s){D(l,s);function l(n,d,v){var p;return p=s.call(this,n)||this,p.code=void 0,p.details=void 0,p.code=d,p.details=v,p}return l}(G(Error));const o=b},"./src/utils/hex.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>P});var W={hexDump:function(D){for(var G="",I=0;I<D.length;I++){var R=D[I].toString(16);R.length<2&&(R="0"+R),G+=R}return G}};const P=W},"./src/utils/imsc1-ttml-parser.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{IMSC1_CODEC:()=>L,parseIMSC1:()=>x});var W=w("./src/utils/mp4-tools.ts"),P=w("./src/utils/vttparser.ts"),N=w("./src/utils/vttcue.ts"),D=w("./src/demux/id3.ts"),G=w("./src/utils/timescale-conversion.ts"),I=w("./src/utils/webvtt-parser.ts");function R(){return R=Object.assign?Object.assign.bind():function(p){for(var m=1;m<arguments.length;m++){var r=arguments[m];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(p[a]=r[a])}return p},R.apply(this,arguments)}var L="stpp.ttml.im1t",_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,T=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,g={left:"start",center:"center",right:"end",start:"start",end:"end"};function x(p,m,r,a,e){var c=(0,W.findBox)(new Uint8Array(p),["mdat"]);if(c.length===0){e(new Error("Could not parse IMSC1 mdat"));return}var E=c.map(function(k){return(0,D.utf8ArrayToStr)(k)}),y=(0,G.toTimescaleFromScale)(m,1,r);try{E.forEach(function(k){return a(b(k,y))})}catch(k){e(k)}}function b(p,m){var r=new DOMParser,a=r.parseFromString(p,"text/xml"),e=a.getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");var c={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},E=Object.keys(c).reduce(function(U,F){return U[F]=e.getAttribute("ttp:"+F)||c[F],U},{}),y=e.getAttribute("xml:space")!=="preserve",k=u(f(e,"styling","style")),M=u(f(e,"layout","region")),O=f(e,"body","[begin]");return[].map.call(O,function(U){var F=h(U,y);if(!F||!U.hasAttribute("begin"))return null;var H=n(U.getAttribute("begin"),E),Y=n(U.getAttribute("dur"),E),Q=n(U.getAttribute("end"),E);if(H===null)throw l(U);if(Q===null){if(Y===null)throw l(U);Q=H+Y}var z=new N.default(H-m,Q-m,F);z.id=(0,I.generateCueId)(z.startTime,z.endTime,z.text);var ee=M[U.getAttribute("region")],J=k[U.getAttribute("style")],X=o(ee,J,k),oe=X.textAlign;if(oe){var le=g[oe];le&&(z.lineAlign=le),z.align=oe}return R(z,X),z}).filter(function(U){return U!==null})}function f(p,m,r){var a=p.getElementsByTagName(m)[0];return a?[].slice.call(a.querySelectorAll(r)):[]}function u(p){return p.reduce(function(m,r){var a=r.getAttribute("xml:id");return a&&(m[a]=r),m},{})}function h(p,m){return[].slice.call(p.childNodes).reduce(function(r,a,e){var c;return a.nodeName==="br"&&e?r+`
`:(c=a.childNodes)!==null&&c!==void 0&&c.length?h(a,m):m?r+a.textContent.trim().replace(/\s+/g," "):r+a.textContent},"")}function o(p,m,r){var a="http://www.w3.org/ns/ttml#styling",e=null,c=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],E=p!=null&&p.hasAttribute("style")?p.getAttribute("style"):null;return E&&r.hasOwnProperty(E)&&(e=r[E]),c.reduce(function(y,k){var M=s(m,a,k)||s(p,a,k)||s(e,a,k);return M&&(y[k]=M),y},{})}function s(p,m,r){return p&&p.hasAttributeNS(m,r)?p.getAttributeNS(m,r):null}function l(p){return new Error("Could not parse ttml timestamp "+p)}function n(p,m){if(!p)return null;var r=(0,P.parseTimeStamp)(p);return r===null&&(_.test(p)?r=d(p,m):T.test(p)&&(r=v(p,m))),r}function d(p,m){var r=_.exec(p),a=(r[4]|0)+(r[5]|0)/m.subFrameRate;return(r[1]|0)*3600+(r[2]|0)*60+(r[3]|0)+a/m.frameRate}function v(p,m){var r=T.exec(p),a=Number(r[1]),e=r[2];switch(e){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/m.frameRate;case"t":return a/m.tickRate}return a}},"./src/utils/keysystem-util.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{changeEndianness:()=>N,convertDataUriToArrayBytes:()=>D,strToUtf8array:()=>G});var W=w("./src/utils/numeric-encoding-utils.ts");function P(I){var R=G(I).subarray(0,16),L=new Uint8Array(16);return L.set(R,16-R.length),L}function N(I){var R=function(_,T,g){var x=_[T];_[T]=_[g],_[g]=x};R(I,0,3),R(I,1,2),R(I,4,5),R(I,6,7)}function D(I){var R=I.split(":"),L=null;if(R[0]==="data"&&R.length===2){var _=R[1].split(";"),T=_[_.length-1].split(",");if(T.length===2){var g=T[0]==="base64",x=T[1];g?(_.splice(-1,1),L=(0,W.base64Decode)(x)):L=P(x)}}return L}function G(I){return Uint8Array.from(unescape(encodeURIComponent(I)),function(R){return R.charCodeAt(0)})}},"./src/utils/logger.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{enableLogs:()=>I,logger:()=>R});var W=function(){},P={trace:W,debug:W,log:W,warn:W,info:W,error:W},N=P;function D(L){var _=self.console[L];return _?_.bind(self.console,"["+L+"] >"):W}function G(L){for(var _=arguments.length,T=new Array(_>1?_-1:0),g=1;g<_;g++)T[g-1]=arguments[g];T.forEach(function(x){N[x]=L[x]?L[x].bind(L):D(x)})}function I(L,_){if(self.console&&L===!0||typeof L=="object"){G(L,"debug","log","info","warn","error");try{N.log('Debug logs enabled for "'+_+'"')}catch(T){N=P}}else N=P}var R=N},"./src/utils/mediakeys-helper.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{KeySystemFormats:()=>P,KeySystemIds:()=>D,KeySystems:()=>W,getKeySystemsForConfig:()=>R,getSupportedMediaKeySystemConfigurations:()=>_,keySystemDomainToKeySystemFormat:()=>I,keySystemFormatToKeySystemDomain:()=>N,keySystemIdToKeySystemDomain:()=>G,requestMediaKeySystemAccess:()=>L});var W;(function(g){g.CLEARKEY="org.w3.clearkey",g.FAIRPLAY="com.apple.fps",g.PLAYREADY="com.microsoft.playready",g.WIDEVINE="com.widevine.alpha"})(W||(W={}));var P;(function(g){g.CLEARKEY="org.w3.clearkey",g.FAIRPLAY="com.apple.streamingkeydelivery",g.PLAYREADY="com.microsoft.playready",g.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"})(P||(P={}));function N(g){switch(g){case P.FAIRPLAY:return W.FAIRPLAY;case P.PLAYREADY:return W.PLAYREADY;case P.WIDEVINE:return W.WIDEVINE;case P.CLEARKEY:return W.CLEARKEY}}var D;(function(g){g.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"})(D||(D={}));function G(g){if(g===D.WIDEVINE)return W.WIDEVINE}function I(g){switch(g){case W.FAIRPLAY:return P.FAIRPLAY;case W.PLAYREADY:return P.PLAYREADY;case W.WIDEVINE:return P.WIDEVINE;case W.CLEARKEY:return P.CLEARKEY}}function R(g){var x=g.drmSystems,b=g.widevineLicenseUrl,f=x?[W.FAIRPLAY,W.WIDEVINE,W.PLAYREADY,W.CLEARKEY].filter(function(u){return!!x[u]}):[];return!f[W.WIDEVINE]&&b&&f.push(W.WIDEVINE),f}var L=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function _(g,x,b,f){var u;switch(g){case W.FAIRPLAY:u=["cenc","sinf"];break;case W.WIDEVINE:case W.PLAYREADY:u=["cenc"];break;case W.CLEARKEY:u=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+g)}return T(u,x,b,f)}function T(g,x,b,f){var u={initDataTypes:g,persistentState:f.persistentState||"not-allowed",distinctiveIdentifier:f.distinctiveIdentifier||"not-allowed",sessionTypes:f.sessionTypes||[f.sessionType||"temporary"],audioCapabilities:x.map(function(h){return{contentType:'audio/mp4; codecs="'+h+'"',robustness:f.audioRobustness||"",encryptionScheme:f.audioEncryptionScheme||null}}),videoCapabilities:b.map(function(h){return{contentType:'video/mp4; codecs="'+h+'"',robustness:f.videoRobustness||"",encryptionScheme:f.videoEncryptionScheme||null}})};return[u]}},"./src/utils/mediasource-helper.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{getMediaSource:()=>W});function W(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{RemuxerTrackIdConfig:()=>L,appendUint8Array:()=>m,bin2str:()=>_,computeRawDurationFromSamples:()=>d,discardEPB:()=>E,findBox:()=>f,getDuration:()=>n,getStartDTS:()=>l,mp4Box:()=>k,mp4pssh:()=>M,offsetStartDTS:()=>v,parseEmsg:()=>y,parseInitSegment:()=>h,parsePssh:()=>O,parseSEIMessageFromNALu:()=>c,parseSamples:()=>r,parseSegmentIndex:()=>u,parseSinf:()=>s,patchEncyptionData:()=>o,readSint32:()=>x,readUint16:()=>T,readUint32:()=>g,segmentValidRange:()=>p,writeUint32:()=>b});var W=w("./src/loader/fragment.ts"),P=w("./src/utils/typed-array.ts"),N=w("./src/demux/id3.ts"),D=w("./src/utils/logger.ts"),G=w("./src/utils/hex.ts"),I=Math.pow(2,32)-1,R=[].push,L={video:1,audio:2,id3:3,text:4};function _(U){return String.fromCharCode.apply(null,U)}function T(U,F){var H=U[F]<<8|U[F+1];return H<0?65536+H:H}function g(U,F){var H=x(U,F);return H<0?4294967296+H:H}function x(U,F){return U[F]<<24|U[F+1]<<16|U[F+2]<<8|U[F+3]}function b(U,F,H){U[F]=H>>24,U[F+1]=H>>16&255,U[F+2]=H>>8&255,U[F+3]=H&255}function f(U,F){var H=[];if(!F.length)return H;for(var Y=U.byteLength,Q=0;Q<Y;){var z=g(U,Q),ee=_(U.subarray(Q+4,Q+8)),J=z>1?Q+z:Y;if(ee===F[0])if(F.length===1)H.push(U.subarray(Q+8,J));else{var X=f(U.subarray(Q+8,J),F.slice(1));X.length&&R.apply(H,X)}Q=J}return H}function u(U){var F=[],H=U[0],Y=8,Q=g(U,Y);Y+=4;var z=0,ee=0;H===0?Y+=8:Y+=16,Y+=2;var J=U.length+ee,X=T(U,Y);Y+=2;for(var oe=0;oe<X;oe++){var le=Y,me=g(U,le);le+=4;var Ae=me&2147483647,ge=(me&2147483648)>>>31;if(ge===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ae=g(U,le);le+=4,F.push({referenceSize:Ae,subsegmentDuration:ae,info:{duration:ae/Q,start:J,end:J+Ae-1}}),J+=Ae,le+=4,Y=le}return{earliestPresentationTime:z,timescale:Q,version:H,referencesCount:X,references:F}}function h(U){for(var F=[],H=f(U,["moov","trak"]),Y=0;Y<H.length;Y++){var Q=H[Y],z=f(Q,["tkhd"])[0];if(z){var ee=z[0],J=ee===0?12:20,X=g(z,J),oe=f(Q,["mdia","mdhd"])[0];if(oe){ee=oe[0],J=ee===0?12:20;var le=g(oe,J),me=f(Q,["mdia","hdlr"])[0];if(me){var Ae=_(me.subarray(8,12)),ge={soun:W.ElementaryStreamTypes.AUDIO,vide:W.ElementaryStreamTypes.VIDEO}[Ae];if(ge){var ae=f(Q,["mdia","minf","stbl","stsd"])[0],ue=void 0;ae&&(ue=_(ae.subarray(12,16))),F[X]={timescale:le,type:ge},F[ge]={timescale:le,id:X,codec:ue}}}}}}var ye=f(U,["moov","mvex","trex"]);return ye.forEach(function(Ee){var _e=g(Ee,4),Se=F[_e];Se&&(Se.default={duration:g(Ee,12),flags:g(Ee,20)})}),F}function o(U,F){if(!U||!F)return U;var H=F.keyId;if(H&&F.isCommonEncryption){var Y=f(U,["moov","trak"]);Y.forEach(function(Q){var z=f(Q,["mdia","minf","stbl","stsd"])[0],ee=z.subarray(8),J=f(ee,["enca"]),X=J.length>0;X||(J=f(ee,["encv"])),J.forEach(function(oe){var le=X?oe.subarray(28):oe.subarray(78),me=f(le,["sinf"]);me.forEach(function(Ae){var ge=s(Ae);if(ge){var ae=ge.subarray(8,24);ae.some(function(ue){return ue!==0})||(D.logger.log("[eme] Patching keyId in 'enc"+(X?"a":"v")+">sinf>>tenc' box: "+G.default.hexDump(ae)+" -> "+G.default.hexDump(H)),ge.set(H,8))}})})})}return U}function s(U){var F=f(U,["schm"])[0];if(F){var H=_(F.subarray(4,8));if(H==="cbcs"||H==="cenc")return f(U,["schi","tenc"])[0]}return D.logger.error("[eme] missing 'schm' box"),null}function l(U,F){return f(F,["moof","traf"]).reduce(function(H,Y){var Q=f(Y,["tfdt"])[0],z=Q[0],ee=f(Y,["tfhd"]).reduce(function(J,X){var oe=g(X,4),le=U[oe];if(le){var me=g(Q,4);z===1&&(me*=Math.pow(2,32),me+=g(Q,8));var Ae=le.timescale||9e4,ge=me/Ae;if(isFinite(ge)&&(J===null||ge<J))return ge}return J},null);return ee!==null&&isFinite(ee)&&(H===null||ee<H)?ee:H},null)||0}function n(U,F){for(var H=0,Y=0,Q=0,z=f(U,["moof","traf"]),ee=0;ee<z.length;ee++){var J=z[ee],X=f(J,["tfhd"])[0],oe=g(X,4),le=F[oe];if(!le)continue;var me=le.default,Ae=g(X,0)|(me==null?void 0:me.flags),ge=me==null?void 0:me.duration;Ae&8&&(Ae&2?ge=g(X,12):ge=g(X,8));for(var ae=le.timescale||9e4,ue=f(J,["trun"]),ye=0;ye<ue.length;ye++){if(H=d(ue[ye]),!H&&ge){var Ee=g(ue[ye],4);H=ge*Ee}le.type===W.ElementaryStreamTypes.VIDEO?Y+=H/ae:le.type===W.ElementaryStreamTypes.AUDIO&&(Q+=H/ae)}}if(Y===0&&Q===0){for(var _e=0,Se=f(U,["sidx"]),Te=0;Te<Se.length;Te++){var Pe=u(Se[Te]);Pe!=null&&Pe.references&&(_e+=Pe.references.reduce(function(we,be){return we+be.info.duration||0},0))}return _e}return Y||Q}function d(U){var F=g(U,0),H=8;F&1&&(H+=4),F&4&&(H+=4);for(var Y=0,Q=g(U,4),z=0;z<Q;z++){if(F&256){var ee=g(U,H);Y+=ee,H+=4}F&512&&(H+=4),F&1024&&(H+=4),F&2048&&(H+=4)}return Y}function v(U,F,H){f(F,["moof","traf"]).forEach(function(Y){f(Y,["tfhd"]).forEach(function(Q){var z=g(Q,4),ee=U[z];if(!ee)return;var J=ee.timescale||9e4;f(Y,["tfdt"]).forEach(function(X){var oe=X[0],le=g(X,4);if(oe===0)le-=H*J,le=Math.max(le,0),b(X,4,le);else{le*=Math.pow(2,32),le+=g(X,8),le-=H*J,le=Math.max(le,0);var me=Math.floor(le/(I+1)),Ae=Math.floor(le%(I+1));b(X,4,me),b(X,8,Ae)}})})})}function p(U){var F={valid:null,remainder:null},H=f(U,["moof"]);if(H){if(H.length<2)return F.remainder=U,F}else return F;var Y=H[H.length-1];return F.valid=(0,P.sliceUint8)(U,0,Y.byteOffset-8),F.remainder=(0,P.sliceUint8)(U,Y.byteOffset-8),F}function m(U,F){var H=new Uint8Array(U.length+F.length);return H.set(U),H.set(F,U.length),H}function r(U,F){var H=[],Y=F.samples,Q=F.timescale,z=F.id,ee=!1,J=f(Y,["moof"]);return J.map(function(X){var oe=X.byteOffset-8,le=f(X,["traf"]);le.map(function(me){var Ae=f(me,["tfdt"]).map(function(ge){var ae=ge[0],ue=g(ge,4);return ae===1&&(ue*=Math.pow(2,32),ue+=g(ge,8)),ue/Q})[0];return Ae!==void 0&&(U=Ae),f(me,["tfhd"]).map(function(ge){var ae=g(ge,4),ue=g(ge,0)&16777215,ye=(ue&1)!==0,Ee=(ue&2)!==0,_e=(ue&8)!==0,Se=0,Te=(ue&16)!==0,Pe=0,we=(ue&32)!==0,be=8;ae===z&&(ye&&(be+=8),Ee&&(be+=4),_e&&(Se=g(ge,be),be+=4),Te&&(Pe=g(ge,be),be+=4),we&&(be+=4),F.type==="video"&&(ee=a(F.codec)),f(me,["trun"]).map(function(Re){var De=Re[0],ke=g(Re,0)&16777215,Ie=(ke&1)!==0,xe=0,Fe=(ke&4)!==0,Me=(ke&256)!==0,pe=0,Le=(ke&512)!==0,ie=0,te=(ke&1024)!==0,re=(ke&2048)!==0,K=0,j=g(Re,4),Z=8;Ie&&(xe=g(Re,Z),Z+=4),Fe&&(Z+=4);for(var q=xe+oe,se=0;se<j;se++){if(Me?(pe=g(Re,Z),Z+=4):pe=Se,Le?(ie=g(Re,Z),Z+=4):ie=Pe,te&&(Z+=4),re&&(De===0?K=g(Re,Z):K=x(Re,Z),Z+=4),F.type===W.ElementaryStreamTypes.VIDEO)for(var de=0;de<ie;){var ve=g(Y,q);if(q+=4,e(ee,Y[q])){var Ue=Y.subarray(q,q+ve);c(Ue,ee?2:1,U+K/Q,H)}q+=ve,de+=ve+4}U+=pe/Q}}))})})}),H}function a(U){if(!U)return!1;var F=U.indexOf("."),H=F<0?U:U.substring(0,F);return H==="hvc1"||H==="hev1"||H==="dvh1"||H==="dvhe"}function e(U,F){if(U){var H=F>>1&63;return H===39||H===40}else{var Y=F&31;return Y===6}}function c(U,F,H,Y){var Q=E(U),z=0;z+=F;for(var ee=0,J=0,X=!1,oe=0;z<Q.length;){ee=0;do{if(z>=Q.length)break;oe=Q[z++],ee+=oe}while(oe===255);J=0;do{if(z>=Q.length)break;oe=Q[z++],J+=oe}while(oe===255);var le=Q.length-z;if(!X&&ee===4&&z<Q.length){X=!0;var me=Q[z++];if(me===181){var Ae=T(Q,z);if(z+=2,Ae===49){var ge=g(Q,z);if(z+=4,ge===1195456820){var ae=Q[z++];if(ae===3){var ue=Q[z++],ye=31&ue,Ee=64&ue,_e=Ee?2+ye*3:0,Se=new Uint8Array(_e);if(Ee){Se[0]=ue;for(var Te=1;Te<_e;Te++)Se[Te]=Q[z++]}Y.push({type:ae,payloadType:ee,pts:H,bytes:Se})}}}}}else if(ee===5&&J<le){if(X=!0,J>16){for(var Pe=[],we=0;we<16;we++){var be=Q[z++].toString(16);Pe.push(be.length==1?"0"+be:be),(we===3||we===5||we===7||we===9)&&Pe.push("-")}for(var Re=J-16,De=new Uint8Array(Re),ke=0;ke<Re;ke++)De[ke]=Q[z++];Y.push({payloadType:ee,pts:H,uuid:Pe.join(""),userData:(0,N.utf8ArrayToStr)(De),userDataBytes:De})}}else if(J<le)z+=J;else if(J>le)break}}function E(U){for(var F=U.byteLength,H=[],Y=1;Y<F-2;)U[Y]===0&&U[Y+1]===0&&U[Y+2]===3?(H.push(Y+2),Y+=2):Y++;if(H.length===0)return U;var Q=F-H.length,z=new Uint8Array(Q),ee=0;for(Y=0;Y<Q;ee++,Y++)ee===H[0]&&(ee++,H.shift()),z[Y]=U[ee];return z}function y(U){var F=U[0],H="",Y="",Q=0,z=0,ee=0,J=0,X=0,oe=0;if(F===0){for(;_(U.subarray(oe,oe+1))!=="\0";)H+=_(U.subarray(oe,oe+1)),oe+=1;for(H+=_(U.subarray(oe,oe+1)),oe+=1;_(U.subarray(oe,oe+1))!=="\0";)Y+=_(U.subarray(oe,oe+1)),oe+=1;Y+=_(U.subarray(oe,oe+1)),oe+=1,Q=g(U,12),z=g(U,16),J=g(U,20),X=g(U,24),oe=28}else if(F===1){oe+=4,Q=g(U,oe),oe+=4;var le=g(U,oe);oe+=4;var me=g(U,oe);for(oe+=4,ee=Math.pow(2,32)*le+me,Number.isSafeInteger(ee)||(ee=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),J=g(U,oe),oe+=4,X=g(U,oe),oe+=4;_(U.subarray(oe,oe+1))!=="\0";)H+=_(U.subarray(oe,oe+1)),oe+=1;for(H+=_(U.subarray(oe,oe+1)),oe+=1;_(U.subarray(oe,oe+1))!=="\0";)Y+=_(U.subarray(oe,oe+1)),oe+=1;Y+=_(U.subarray(oe,oe+1)),oe+=1}var Ae=U.subarray(oe,U.byteLength);return{schemeIdUri:H,value:Y,timeScale:Q,presentationTime:ee,presentationTimeDelta:z,eventDuration:J,id:X,payload:Ae}}function k(U){for(var F=arguments.length,H=new Array(F>1?F-1:0),Y=1;Y<F;Y++)H[Y-1]=arguments[Y];for(var Q=H.length,z=8,ee=Q;ee--;)z+=H[ee].byteLength;var J=new Uint8Array(z);for(J[0]=z>>24&255,J[1]=z>>16&255,J[2]=z>>8&255,J[3]=z&255,J.set(U,4),ee=0,z=8;ee<Q;ee++)J.set(H[ee],z),z+=H[ee].byteLength;return J}function M(U,F,H){if(U.byteLength!==16)throw new RangeError("Invalid system id");var Y,Q;if(F){Y=1,Q=new Uint8Array(F.length*16);for(var z=0;z<F.length;z++){var ee=F[z];if(ee.byteLength!==16)throw new RangeError("Invalid key");Q.set(ee,z*16)}}else Y=0,Q=new Uint8Array;var J;Y>0?(J=new Uint8Array(4),F.length>0&&new DataView(J.buffer).setUint32(0,F.length,!1)):J=new Uint8Array;var X=new Uint8Array(4);return H&&H.byteLength>0&&new DataView(X.buffer).setUint32(0,H.byteLength,!1),k([112,115,115,104],new Uint8Array([Y,0,0,0]),U,J,Q,X,H||new Uint8Array)}function O(U){if(!(U instanceof ArrayBuffer)||U.byteLength<32)return null;var F={version:0,systemId:"",kids:null,data:null},H=new DataView(U),Y=H.getUint32(0);if(U.byteLength!==Y&&Y>44)return null;var Q=H.getUint32(4);if(Q!==1886614376)return null;if(F.version=H.getUint32(8)>>>24,F.version>1)return null;F.systemId=G.default.hexDump(new Uint8Array(U,12,16));var z=H.getUint32(28);if(F.version===0){if(Y-32<z)return null;F.data=new Uint8Array(U,32,z)}else if(F.version===1){F.kids=[];for(var ee=0;ee<z;ee++)F.kids.push(new Uint8Array(U,32+ee*16,16))}return F}},"./src/utils/numeric-encoding-utils.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{base64Decode:()=>I,base64DecodeToStr:()=>N,base64Encode:()=>D,base64ToBase64Url:()=>W,base64UrlEncode:()=>G,strToBase64Encode:()=>P});function W(R){return R.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function P(R){return btoa(R)}function N(R){return atob(R)}function D(R){return btoa(String.fromCharCode.apply(String,R))}function G(R){return W(D(R))}function I(R){return Uint8Array.from(atob(R),function(L){return L.charCodeAt(0)})}},"./src/utils/output-filter.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>W});var W=function(){function P(D,G){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=D,this.trackName=G}var N=P.prototype;return N.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},N.newCue=function(G,I,R){(this.startTime===null||this.startTime>G)&&(this.startTime=G),this.endTime=I,this.screen=R,this.timelineController.createCaptionsTrack(this.trackName)},N.reset=function(){this.cueRanges=[],this.startTime=null},P}()},"./src/utils/texttrack-utils.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{addCueToTrack:()=>N,clearCurrentCues:()=>D,getCuesInRange:()=>R,removeCuesInRange:()=>G,sendAddTrackEvent:()=>P});var W=w("./src/utils/logger.ts");function P(L,_){var T;try{T=new Event("addtrack")}catch(g){T=document.createEvent("Event"),T.initEvent("addtrack",!1,!1)}T.track=L,_.dispatchEvent(T)}function N(L,_){var T=L.mode;if(T==="disabled"&&(L.mode="hidden"),L.cues&&!L.cues.getCueById(_.id))try{if(L.addCue(_),!L.cues.getCueById(_.id))throw new Error("addCue is failed for: "+_)}catch(x){W.logger.debug("[texttrack-utils]: "+x);var g=new self.TextTrackCue(_.startTime,_.endTime,_.text);g.id=_.id,L.addCue(g)}T==="disabled"&&(L.mode=T)}function D(L){var _=L.mode;if(_==="disabled"&&(L.mode="hidden"),L.cues)for(var T=L.cues.length;T--;)L.removeCue(L.cues[T]);_==="disabled"&&(L.mode=_)}function G(L,_,T,g){var x=L.mode;if(x==="disabled"&&(L.mode="hidden"),L.cues&&L.cues.length>0)for(var b=R(L.cues,_,T),f=0;f<b.length;f++)(!g||g(b[f]))&&L.removeCue(b[f]);x==="disabled"&&(L.mode=x)}function I(L,_){if(_<L[0].startTime)return 0;var T=L.length-1;if(_>L[T].endTime)return-1;for(var g=0,x=T;g<=x;){var b=Math.floor((x+g)/2);if(_<L[b].startTime)x=b-1;else if(_>L[b].startTime&&g<T)g=b+1;else return b}return L[g].startTime-_<_-L[x].startTime?g:x}function R(L,_,T){var g=[],x=I(L,_);if(x>-1)for(var b=x,f=L.length;b<f;b++){var u=L[b];if(u.startTime>=_&&u.endTime<=T)g.push(u);else if(u.startTime>T)return g}return g}},"./src/utils/time-ranges.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>P});var W={toString:function(D){for(var G="",I=D.length,R=0;R<I;R++)G+="["+D.start(R).toFixed(3)+"-"+D.end(R).toFixed(3)+"]";return G}};const P=W},"./src/utils/timescale-conversion.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{toMpegTsClockFromTimescale:()=>G,toMsFromMpegTsClock:()=>D,toTimescaleFromBase:()=>P,toTimescaleFromScale:()=>N});var W=9e4;function P(I,R,L,_){L===void 0&&(L=1),_===void 0&&(_=!1);var T=I*R*L;return _?Math.round(T):T}function N(I,R,L,_){return L===void 0&&(L=1),_===void 0&&(_=!1),P(I,R,1/L,_)}function D(I,R){return R===void 0&&(R=!1),P(I,1e3,1/W,R)}function G(I,R){return R===void 0&&(R=1),P(I,W,1/R)}},"./src/utils/typed-array.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{sliceUint8:()=>W});function W(P,N,D){return Uint8Array.prototype.slice?P.slice(N,D):new Uint8Array(Array.prototype.slice.call(P,N,D))}},"./src/utils/vttcue.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>W});const W=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var P=["","lr","rl"],N=["start","middle","end","left","right"];function D(_,T){if(typeof T!="string")return!1;if(!Array.isArray(_))return!1;var g=T.toLowerCase();return~_.indexOf(g)?g:!1}function G(_){return D(P,_)}function I(_){return D(N,_)}function R(_){for(var T=arguments.length,g=new Array(T>1?T-1:0),x=1;x<T;x++)g[x-1]=arguments[x];for(var b=1;b<arguments.length;b++){var f=arguments[b];for(var u in f)_[u]=f[u]}return _}function L(_,T,g){var x=this,b={enumerable:!0};x.hasBeenReset=!1;var f="",u=!1,h=_,o=T,s=g,l=null,n="",d=!0,v="auto",p="start",m=50,r="middle",a=50,e="middle";Object.defineProperty(x,"id",R({},b,{get:function(){return f},set:function(E){f=""+E}})),Object.defineProperty(x,"pauseOnExit",R({},b,{get:function(){return u},set:function(E){u=!!E}})),Object.defineProperty(x,"startTime",R({},b,{get:function(){return h},set:function(E){if(typeof E!="number")throw new TypeError("Start time must be set to a number.");h=E,this.hasBeenReset=!0}})),Object.defineProperty(x,"endTime",R({},b,{get:function(){return o},set:function(E){if(typeof E!="number")throw new TypeError("End time must be set to a number.");o=E,this.hasBeenReset=!0}})),Object.defineProperty(x,"text",R({},b,{get:function(){return s},set:function(E){s=""+E,this.hasBeenReset=!0}})),Object.defineProperty(x,"region",R({},b,{get:function(){return l},set:function(E){l=E,this.hasBeenReset=!0}})),Object.defineProperty(x,"vertical",R({},b,{get:function(){return n},set:function(E){var y=G(E);if(y===!1)throw new SyntaxError("An invalid or illegal string was specified.");n=y,this.hasBeenReset=!0}})),Object.defineProperty(x,"snapToLines",R({},b,{get:function(){return d},set:function(E){d=!!E,this.hasBeenReset=!0}})),Object.defineProperty(x,"line",R({},b,{get:function(){return v},set:function(E){if(typeof E!="number"&&E!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");v=E,this.hasBeenReset=!0}})),Object.defineProperty(x,"lineAlign",R({},b,{get:function(){return p},set:function(E){var y=I(E);if(!y)throw new SyntaxError("An invalid or illegal string was specified.");p=y,this.hasBeenReset=!0}})),Object.defineProperty(x,"position",R({},b,{get:function(){return m},set:function(E){if(E<0||E>100)throw new Error("Position must be between 0 and 100.");m=E,this.hasBeenReset=!0}})),Object.defineProperty(x,"positionAlign",R({},b,{get:function(){return r},set:function(E){var y=I(E);if(!y)throw new SyntaxError("An invalid or illegal string was specified.");r=y,this.hasBeenReset=!0}})),Object.defineProperty(x,"size",R({},b,{get:function(){return a},set:function(E){if(E<0||E>100)throw new Error("Size must be between 0 and 100.");a=E,this.hasBeenReset=!0}})),Object.defineProperty(x,"align",R({},b,{get:function(){return e},set:function(E){var y=I(E);if(!y)throw new SyntaxError("An invalid or illegal string was specified.");e=y,this.hasBeenReset=!0}})),x.displayState=void 0}return L.prototype.getCueAsHTML=function(){var _=self.WebVTT;return _.convertCueToDOMTree(self,this.text)},L}()},"./src/utils/vttparser.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{VTTParser:()=>T,fixLineBreaks:()=>_,parseTimeStamp:()=>N});var W=w("./src/utils/vttcue.ts"),P=function(){function g(){}var x=g.prototype;return x.decode=function(f,u){if(!f)return"";if(typeof f!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(f))},g}();function N(g){function x(f,u,h,o){return(f|0)*3600+(u|0)*60+(h|0)+parseFloat(o||0)}var b=g.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return b?parseFloat(b[2])>59?x(b[2],b[3],0,b[4]):x(b[1],b[2],b[3],b[4]):null}var D=function(){function g(){this.values=Object.create(null)}var x=g.prototype;return x.set=function(f,u){!this.get(f)&&u!==""&&(this.values[f]=u)},x.get=function(f,u,h){return h?this.has(f)?this.values[f]:u[h]:this.has(f)?this.values[f]:u},x.has=function(f){return f in this.values},x.alt=function(f,u,h){for(var o=0;o<h.length;++o)if(u===h[o]){this.set(f,u);break}},x.integer=function(f,u){/^-?\d+$/.test(u)&&this.set(f,parseInt(u,10))},x.percent=function(f,u){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(u)){var h=parseFloat(u);if(h>=0&&h<=100)return this.set(f,h),!0}return!1},g}();function G(g,x,b,f){var u=f?g.split(f):[g];for(var h in u){if(typeof u[h]!="string")continue;var o=u[h].split(b);if(o.length!==2)continue;var s=o[0],l=o[1];x(s,l)}}var I=new W.default(0,0,""),R=I.align==="middle"?"middle":"center";function L(g,x,b){var f=g;function u(){var s=N(g);if(s===null)throw new Error("Malformed timestamp: "+f);return g=g.replace(/^[^\sa-zA-Z-]+/,""),s}function h(s,l){var n=new D;G(s,function(p,m){var r;switch(p){case"region":for(var a=b.length-1;a>=0;a--)if(b[a].id===m){n.set(p,b[a].region);break}break;case"vertical":n.alt(p,m,["rl","lr"]);break;case"line":r=m.split(","),n.integer(p,r[0]),n.percent(p,r[0])&&n.set("snapToLines",!1),n.alt(p,r[0],["auto"]),r.length===2&&n.alt("lineAlign",r[1],["start",R,"end"]);break;case"position":r=m.split(","),n.percent(p,r[0]),r.length===2&&n.alt("positionAlign",r[1],["start",R,"end","line-left","line-right","auto"]);break;case"size":n.percent(p,m);break;case"align":n.alt(p,m,["start",R,"end","left","right"]);break}},/:/,/\s/),l.region=n.get("region",null),l.vertical=n.get("vertical","");var d=n.get("line","auto");d==="auto"&&I.line===-1&&(d=-1),l.line=d,l.lineAlign=n.get("lineAlign","start"),l.snapToLines=n.get("snapToLines",!0),l.size=n.get("size",100),l.align=n.get("align",R);var v=n.get("position","auto");v==="auto"&&I.position===50&&(v=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=v}function o(){g=g.replace(/^\s+/,"")}if(o(),x.startTime=u(),o(),g.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+f);g=g.slice(3),o(),x.endTime=u(),o(),h(g,x)}function _(g){return g.replace(/<br(?: \/)?>/gi,`
`)}var T=function(){function g(){this.state="INITIAL",this.buffer="",this.decoder=new P,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var x=g.prototype;return x.parse=function(f){var u=this;f&&(u.buffer+=u.decoder.decode(f,{stream:!0}));function h(){var v=u.buffer,p=0;for(v=_(v);p<v.length&&v[p]!=="\r"&&v[p]!==`
`;)++p;var m=v.slice(0,p);return v[p]==="\r"&&++p,v[p]===`
`&&++p,u.buffer=v.slice(p),m}function o(v){G(v,function(p,m){},/:/)}try{var s="";if(u.state==="INITIAL"){if(!/\r\n|\n/.test(u.buffer))return this;s=h();var l=s.match(/^()?WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Error("Malformed WebVTT signature.");u.state="HEADER"}for(var n=!1;u.buffer;){if(!/\r\n|\n/.test(u.buffer))return this;n?n=!1:s=h();switch(u.state){case"HEADER":/:/.test(s)?o(s):s||(u.state="ID");continue;case"NOTE":s||(u.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(s)){u.state="NOTE";break}if(!s)continue;if(u.cue=new W.default(0,0,""),u.state="CUE",s.indexOf("-->")===-1){u.cue.id=s;continue}case"CUE":if(!u.cue){u.state="BADCUE";continue}try{L(s,u.cue,u.regionList)}catch(v){u.cue=null,u.state="BADCUE";continue}u.state="CUETEXT";continue;case"CUETEXT":{var d=s.indexOf("-->")!==-1;if(!s||d&&(n=!0)){u.oncue&&u.cue&&u.oncue(u.cue),u.cue=null,u.state="ID";continue}if(u.cue===null)continue;u.cue.text&&(u.cue.text+=`
`),u.cue.text+=s}continue;case"BADCUE":s||(u.state="ID")}}}catch(v){u.state==="CUETEXT"&&u.cue&&u.oncue&&u.oncue(u.cue),u.cue=null,u.state=u.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},x.flush=function(){var f=this;try{if((f.cue||f.state==="HEADER")&&(f.buffer+=`
`,f.parse()),f.state==="INITIAL"||f.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(u){f.onparsingerror&&f.onparsingerror(u)}return f.onflush&&f.onflush(),this},g}()},"./src/utils/webvtt-parser.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{generateCueId:()=>T,parseWebVTT:()=>x});var W=w("./src/polyfills/number.ts"),P=w("./src/utils/vttparser.ts"),N=w("./src/demux/id3.ts"),D=w("./src/utils/timescale-conversion.ts"),G=w("./src/remux/mp4-remuxer.ts"),I=/\r\n|\n\r|\n|\r/g,R=function(f,u,h){return h===void 0&&(h=0),f.slice(h,h+u.length)===u},L=function(f){var u=parseInt(f.slice(-3)),h=parseInt(f.slice(-6,-4)),o=parseInt(f.slice(-9,-7)),s=f.length>9?parseInt(f.substring(0,f.indexOf(":"))):0;if(!(0,W.isFiniteNumber)(u)||!(0,W.isFiniteNumber)(h)||!(0,W.isFiniteNumber)(o)||!(0,W.isFiniteNumber)(s))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+f);return u+=1e3*h,u+=60*1e3*o,u+=60*60*1e3*s,u},_=function(f){for(var u=5381,h=f.length;h;)u=u*33^f.charCodeAt(--h);return(u>>>0).toString()};function T(b,f,u){return _(b.toString())+_(f.toString())+_(u)}var g=function(f,u,h){var o=f[u],s=f[o.prevCC];if(!s||!s.new&&o.new){f.ccOffset=f.presentationOffset=o.start,o.new=!1;return}for(;(l=s)!==null&&l!==void 0&&l.new;){var l;f.ccOffset+=o.start-s.start,o.new=!1,o=s,s=f[o.prevCC]}f.presentationOffset=h};function x(b,f,u,h,o,s,l,n){var d=new P.VTTParser,v=(0,N.utf8ArrayToStr)(new Uint8Array(b)).trim().replace(I,`
`).split(`
`),p=[],m=(0,D.toMpegTsClockFromTimescale)(f,u),r="00:00.000",a=0,e=0,c,E=!0;d.oncue=function(y){var k=h[o],M=h.ccOffset,O=(a-m)/9e4;k!=null&&k.new&&(e!==void 0?M=h.ccOffset=k.start:g(h,o,O)),O&&(M=O-h.presentationOffset);var U=y.endTime-y.startTime,F=(0,G.normalizePts)((y.startTime+M-e)*9e4,s*9e4)/9e4;y.startTime=Math.max(F,0),y.endTime=Math.max(F+U,0);var H=y.text.trim();y.text=decodeURIComponent(encodeURIComponent(H)),y.id||(y.id=T(y.startTime,y.endTime,H)),y.endTime>0&&p.push(y)},d.onparsingerror=function(y){c=y},d.onflush=function(){if(c){n(c);return}l(p)},v.forEach(function(y){if(E)if(R(y,"X-TIMESTAMP-MAP=")){E=!1,y.slice(16).split(",").forEach(function(k){R(k,"LOCAL:")?r=k.slice(6):R(k,"MPEGTS:")&&(a=parseInt(k.slice(7)))});try{e=L(r)/1e3}catch(k){c=k}return}else y===""&&(E=!1);d.parse(y+`
`)}),d.flush()}},"./src/utils/xhr-loader.ts":(he,V,w)=>{"use strict";w.r(V),w.d(V,{default:()=>G});var W=w("./src/utils/logger.ts"),P=w("./src/loader/load-stats.ts"),N=/^age:\s*[\d.]+\s*$/m,D=function(){function I(L){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=L?L.xhrSetup:null,this.stats=new P.LoadStats,this.retryDelay=0}var R=I.prototype;return R.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},R.abortInternal=function(){var _=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),_&&(_.onreadystatechange=null,_.onprogress=null,_.readyState!==4&&(this.stats.aborted=!0,_.abort()))},R.abort=function(){var _;this.abortInternal(),(_=this.callbacks)!==null&&_!==void 0&&_.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},R.load=function(_,T,g){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=_,this.config=T,this.callbacks=g,this.retryDelay=T.retryDelay,this.loadInternal()},R.loadInternal=function(){var _=this.config,T=this.context;if(!_)return;var g=this.loader=new self.XMLHttpRequest,x=this.stats;x.loading.first=0,x.loaded=0;var b=this.xhrSetup;try{if(b)try{b(g,T.url)}catch(h){g.open("GET",T.url,!0),b(g,T.url)}g.readyState||g.open("GET",T.url,!0);var f=this.context.headers;if(f)for(var u in f)g.setRequestHeader(u,f[u])}catch(h){this.callbacks.onError({code:g.status,text:h.message},T,g);return}T.rangeEnd&&g.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),g.onreadystatechange=this.readystatechange.bind(this),g.onprogress=this.loadprogress.bind(this),g.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),_.timeout),g.send()},R.readystatechange=function(){var _=this.context,T=this.loader,g=this.stats;if(!_||!T)return;var x=T.readyState,b=this.config;if(g.aborted)return;if(x>=2)if(self.clearTimeout(this.requestTimeout),g.loading.first===0&&(g.loading.first=Math.max(self.performance.now(),g.loading.start)),x===4){T.onreadystatechange=null,T.onprogress=null;var f=T.status,u=T.responseType==="arraybuffer";if(f>=200&&f<300&&(u&&T.response||T.responseText!==null)){g.loading.end=Math.max(self.performance.now(),g.loading.first);var h,o;if(u?(h=T.response,o=h.byteLength):(h=T.responseText,o=h.length),g.loaded=g.total=o,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(g,_,h,T),!this.callbacks)return;var l={url:T.responseURL,data:h};this.callbacks.onSuccess(l,g,_,T)}else g.retry>=b.maxRetry||f>=400&&f<499?(W.logger.error(f+" while loading "+_.url),this.callbacks.onError({code:f,text:T.statusText},_,T)):(W.logger.warn(f+" while loading "+_.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,b.maxRetryDelay),g.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),b.timeout)},R.loadtimeout=function(){W.logger.warn("timeout while loading "+this.context.url);var _=this.callbacks;_&&(this.abortInternal(),_.onTimeout(this.stats,this.context,this.loader))},R.loadprogress=function(_){var T=this.stats;T.loaded=_.loaded,_.lengthComputable&&(T.total=_.total)},R.getCacheAge=function(){var _=null;if(this.loader&&N.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");_=T?parseFloat(T):null}return _},I}();const G=D},"./node_modules/eventemitter3/index.js":he=>{"use strict";var V=Object.prototype.hasOwnProperty,w="~";function W(){}Object.create&&(W.prototype=Object.create(null),new W().__proto__||(w=!1));function P(I,R,L){this.fn=I,this.context=R,this.once=L||!1}function N(I,R,L,_,T){if(typeof L!="function")throw new TypeError("The listener must be a function");var g=new P(L,_||I,T),x=w?w+R:R;return I._events[x]?I._events[x].fn?I._events[x]=[I._events[x],g]:I._events[x].push(g):(I._events[x]=g,I._eventsCount++),I}function D(I,R){--I._eventsCount===0?I._events=new W:delete I._events[R]}function G(){this._events=new W,this._eventsCount=0}G.prototype.eventNames=function(){var R=[],L,_;if(this._eventsCount===0)return R;for(_ in L=this._events)V.call(L,_)&&R.push(w?_.slice(1):_);return Object.getOwnPropertySymbols?R.concat(Object.getOwnPropertySymbols(L)):R},G.prototype.listeners=function(R){var L=w?w+R:R,_=this._events[L];if(!_)return[];if(_.fn)return[_.fn];for(var T=0,g=_.length,x=new Array(g);T<g;T++)x[T]=_[T].fn;return x},G.prototype.listenerCount=function(R){var L=w?w+R:R,_=this._events[L];return _?_.fn?1:_.length:0},G.prototype.emit=function(R,L,_,T,g,x){var b=w?w+R:R;if(!this._events[b])return!1;var f=this._events[b],u=arguments.length,h,o;if(f.fn){f.once&&this.removeListener(R,f.fn,void 0,!0);switch(u){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,L),!0;case 3:return f.fn.call(f.context,L,_),!0;case 4:return f.fn.call(f.context,L,_,T),!0;case 5:return f.fn.call(f.context,L,_,T,g),!0;case 6:return f.fn.call(f.context,L,_,T,g,x),!0}for(o=1,h=new Array(u-1);o<u;o++)h[o-1]=arguments[o];f.fn.apply(f.context,h)}else{var s=f.length,l;for(o=0;o<s;o++){f[o].once&&this.removeListener(R,f[o].fn,void 0,!0);switch(u){case 1:f[o].fn.call(f[o].context);break;case 2:f[o].fn.call(f[o].context,L);break;case 3:f[o].fn.call(f[o].context,L,_);break;case 4:f[o].fn.call(f[o].context,L,_,T);break;default:if(!h)for(l=1,h=new Array(u-1);l<u;l++)h[l-1]=arguments[l];f[o].fn.apply(f[o].context,h)}}}return!0},G.prototype.on=function(R,L,_){return N(this,R,L,_,!1)},G.prototype.once=function(R,L,_){return N(this,R,L,_,!0)},G.prototype.removeListener=function(R,L,_,T){var g=w?w+R:R;if(!this._events[g])return this;if(!L)return D(this,g),this;var x=this._events[g];if(x.fn)x.fn===L&&(!T||x.once)&&(!_||x.context===_)&&D(this,g);else{for(var b=0,f=[],u=x.length;b<u;b++)(x[b].fn!==L||T&&!x[b].once||_&&x[b].context!==_)&&f.push(x[b]);f.length?this._events[g]=f.length===1?f[0]:f:D(this,g)}return this},G.prototype.removeAllListeners=function(R){var L;return R?(L=w?w+R:R,this._events[L]&&D(this,L)):(this._events=new W,this._eventsCount=0),this},G.prototype.off=G.prototype.removeListener,G.prototype.addListener=G.prototype.on,G.prefixed=w,G.EventEmitter=G,he.exports=G},"./node_modules/url-toolkit/src/url-toolkit.js":function(he){(function(V){var w=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,W=/^(?=([^\/?#]*))\1([^]*)$/,P=/(?:\/|^)\.(?=\/)/g,N=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,D={buildAbsoluteURL:function(G,I,R){if(R=R||{},G=G.trim(),I=I.trim(),!I){if(!R.alwaysNormalize)return G;var L=D.parseURL(G);if(!L)throw new Error("Error trying to parse base URL.");return L.path=D.normalizePath(L.path),D.buildURLFromParts(L)}var _=D.parseURL(I);if(!_)throw new Error("Error trying to parse relative URL.");if(_.scheme)return R.alwaysNormalize?(_.path=D.normalizePath(_.path),D.buildURLFromParts(_)):I;var T=D.parseURL(G);if(!T)throw new Error("Error trying to parse base URL.");if(!T.netLoc&&T.path&&T.path[0]!=="/"){var g=W.exec(T.path);T.netLoc=g[1],T.path=g[2]}T.netLoc&&!T.path&&(T.path="/");var x={scheme:T.scheme,netLoc:_.netLoc,path:null,params:_.params,query:_.query,fragment:_.fragment};if(!_.netLoc&&(x.netLoc=T.netLoc,_.path[0]!=="/"))if(!_.path)x.path=T.path,_.params||(x.params=T.params,_.query||(x.query=T.query));else{var b=T.path,f=b.substring(0,b.lastIndexOf("/")+1)+_.path;x.path=D.normalizePath(f)}return x.path===null&&(x.path=R.alwaysNormalize?D.normalizePath(_.path):_.path),D.buildURLFromParts(x)},parseURL:function(G){var I=w.exec(G);return I?{scheme:I[1]||"",netLoc:I[2]||"",path:I[3]||"",params:I[4]||"",query:I[5]||"",fragment:I[6]||""}:null},normalizePath:function(G){for(G=G.split("").reverse().join("").replace(P,"");G.length!==(G=G.replace(N,"")).length;);return G.split("").reverse().join("")},buildURLFromParts:function(G){return G.scheme+G.netLoc+G.path+G.params+G.query+G.fragment}};he.exports=D})(this)}},tt={};function ze(he){var V=tt[he];if(V!==void 0)return V.exports;var w=tt[he]={exports:{}};return et[he].call(w.exports,w,w.exports,ze),w.exports}ze.m=et,(()=>{ze.n=he=>{var V=he&&he.__esModule?()=>he.default:()=>he;return ze.d(V,{a:V}),V}})(),(()=>{ze.d=(he,V)=>{for(var w in V)ze.o(V,w)&&!ze.o(he,w)&&Object.defineProperty(he,w,{enumerable:!0,get:V[w]})}})(),(()=>{ze.o=(he,V)=>Object.prototype.hasOwnProperty.call(he,V)})(),(()=>{ze.r=he=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(he,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(he,"__esModule",{value:!0})}})();var Ve=ze("./src/hls.ts");return Ve=Ve.default,Ve})())},vHTk:function(qe,Qe,fe){qe.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}},"yTi+":function(qe,Qe,fe){qe.exports=fe.p+"static/AssistantCode3.fdd8db3c.jpeg"},zvqp:function(qe,Qe,fe){qe.exports={flex_box_center:"flex_box_center___3si-j",flex_space_between:"flex_space_between___1JkB6",flex_box_vertical_center:"flex_box_vertical_center___298wI",flex_box_center_end:"flex_box_center_end___1kjbU",flex_box_column:"flex_box_column___2_dkP",content:"content___YUEGP",title:"title___1gIWf",menu:"menu___tZhO5",contcats:"contcats___3chvG",cooperatives:"cooperatives___U0UdA",imgWrp:"imgWrp___3N3oq"}}}]);