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.
133 lines
705 KiB
133 lines
705 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[241,7],{"+NIl":function(ut,Qe,q){(function(Q){Q(q("VrN/"))})(function(Q){"use strict";Q.defineMode("stex",function(G,A){"use strict";function W(C,T){C.cmdState.push(T)}function k(C){return C.cmdState.length>0?C.cmdState[C.cmdState.length-1]:null}function O(C){var T=C.cmdState.pop();T&&T.closeBracket()}function U(C){for(var T=C.cmdState,E=T.length-1;E>=0;E--){var l=T[E];if(l.name=="DEFAULT")continue;return l}return{styleIdentifier:function(){return null}}}function F(C,T,E){return function(){this.name=C,this.bracketNo=0,this.style=T,this.styles=E,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var R={};R.importmodule=F("importmodule","tag",["string","builtin"]),R.documentclass=F("documentclass","tag",["","atom"]),R.usepackage=F("usepackage","tag",["atom"]),R.begin=F("begin","tag",["atom"]),R.end=F("end","tag",["atom"]),R.label=F("label","tag",["atom"]),R.ref=F("ref","tag",["atom"]),R.eqref=F("eqref","tag",["atom"]),R.cite=F("cite","tag",["atom"]),R.bibitem=F("bibitem","tag",["atom"]),R.Bibitem=F("Bibitem","tag",["atom"]),R.RBibitem=F("RBibitem","tag",["atom"]),R.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function _(C,T){C.f=T}function v(C,T){var E;if(C.match(/^\\[a-zA-Z@]+/)){var l=C.current().slice(1);return E=R.hasOwnProperty(l)?R[l]:R.DEFAULT,E=new E,W(T,E),_(T,D),E.style}if(C.match(/^\\[$&%#{}_]/))return"tag";if(C.match(/^\\[,;!\/\\]/))return"tag";if(C.match("\\["))return _(T,function(s,u){return S(s,u,"\\]")}),"keyword";if(C.match("\\("))return _(T,function(s,u){return S(s,u,"\\)")}),"keyword";if(C.match("$$"))return _(T,function(s,u){return S(s,u,"$$")}),"keyword";if(C.match("$"))return _(T,function(s,u){return S(s,u,"$")}),"keyword";var o=C.next();if(o=="%")return C.skipToEnd(),"comment";if(o=="}"||o=="]"){if(E=k(T),E)E.closeBracket(o),_(T,D);else return"error";return"bracket"}else return o=="{"||o=="["?(E=R.DEFAULT,E=new E,W(T,E),"bracket"):/\d/.test(o)?(C.eatWhile(/[\w.%]/),"atom"):(C.eatWhile(/[\w\-_]/),E=U(T),E.name=="begin"&&(E.argument=C.current()),E.styleIdentifier())}function S(C,T,E){if(C.eatSpace())return null;if(E&&C.match(E))return _(T,v),"keyword";if(C.match(/^\\[a-zA-Z@]+/))return"tag";if(C.match(/^[a-zA-Z]+/))return"variable-2";if(C.match(/^\\[$&%#{}_]/))return"tag";if(C.match(/^\\[,;!\/]/))return"tag";if(C.match(/^[\^_&]/))return"tag";if(C.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(C.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var l=C.next();return l=="{"||l=="}"||l=="["||l=="]"||l=="("||l==")"?"bracket":l=="%"?(C.skipToEnd(),"comment"):"error"}function D(C,T){var E=C.peek(),l;return E=="{"||E=="["?(l=k(T),l.openBracket(E),C.eat(E),_(T,v),"bracket"):/[ \t\r]/.test(E)?(C.eat(E),null):(_(T,v),O(T),v(C,T))}return{startState:function(){var C=A.inMathMode?function(T,E){return S(T,E)}:v;return{cmdState:[],f:C}},copyState:function(C){return{cmdState:C.cmdState.slice(),f:C.f}},token:function(C,T){return T.f(C,T)},blankLine:function(C){C.f=v,C.cmdState.length=0},lineComment:"%"}}),Q.defineMIME("text/x-stex","stex"),Q.defineMIME("text/x-latex","stex")})},"19Vz":function(ut,Qe,q){(function(Q){Q(q("VrN/"))})(function(Q){Q.defineOption("placeholder","",function(F,R,_){var v=_&&_!=Q.Init;if(R&&!v)F.on("blur",k),F.on("change",O),F.on("swapDoc",O),Q.on(F.getInputField(),"compositionupdate",F.state.placeholderCompose=function(){W(F)}),O(F);else if(!R&&v){F.off("blur",k),F.off("change",O),F.off("swapDoc",O),Q.off(F.getInputField(),"compositionupdate",F.state.placeholderCompose),G(F);var S=F.getWrapperElement();S.className=S.className.replace(" CodeMirror-empty","")}R&&!F.hasFocus()&&k(F)});function G(F){F.state.placeholder&&(F.state.placeholder.parentNode.removeChild(F.state.placeholder),F.state.placeholder=null)}function A(F){G(F);var R=F.state.placeholder=document.createElement("pre");R.style.cssText="height: 0; overflow: visible",R.style.direction=F.getOption("direction"),R.className="CodeMirror-placeholder CodeMirror-line-like";var _=F.getOption("placeholder");typeof _=="string"&&(_=document.createTextNode(_)),R.appendChild(_),F.display.lineSpace.insertBefore(R,F.display.lineSpace.firstChild)}function W(F){setTimeout(function(){var R=!1,_=F.getInputField();_.nodeName=="TEXTAREA"?R=!_.value:F.lineCount()==1&&(R=!/[^\u200b]/.test(_.querySelector(".CodeMirror-line").textContent)),R?A(F):G(F)},20)}function k(F){U(F)&&A(F)}function O(F){var R=F.getWrapperElement(),_=U(F);R.className=R.className.replace(" CodeMirror-empty","")+(_?" CodeMirror-empty":""),_?A(F):G(F)}function U(F){return F.lineCount()===1&&F.getLine(0)===""}})},"1eCo":function(ut,Qe,q){(function(Q){Q(q("VrN/"))})(function(Q){"use strict";var G={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},A={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};Q.defineMode("xml",function(W,k){var O=W.indentUnit,U={},F=k.htmlMode?G:A;for(var R in F)U[R]=F[R];for(var R in k)U[R]=k[R];var _,v;function S(a,b){function g(N){return b.tokenize=N,N(a,b)}var x=a.next();if(x=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?g(T("atom","]]>")):null:a.match("--")?g(T("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),g(E(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),b.tokenize=T("meta","?>"),"meta"):(_=a.eat("/")?"closeTag":"openTag",b.tokenize=D,"tag bracket");if(x=="&"){var P;return a.eat("#")?a.eat("x")?P=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):P=a.eatWhile(/[\d]/)&&a.eat(";"):P=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),P?"atom":"error"}else return a.eatWhile(/[^&<]/),null}S.isInText=!0;function D(a,b){var g=a.next();if(g==">"||g=="/"&&a.eat(">"))return b.tokenize=S,_=g==">"?"endTag":"selfcloseTag","tag bracket";if(g=="=")return _="equals",null;if(g=="<"){b.tokenize=S,b.state=u,b.tagName=b.tagStart=null;var x=b.tokenize(a,b);return x?x+" tag error":"tag error"}else return/[\'\"]/.test(g)?(b.tokenize=C(g),b.stringStartCol=a.column(),b.tokenize(a,b)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function C(a){var b=function(g,x){for(;!g.eol();)if(g.next()==a){x.tokenize=D;break}return"string"};return b.isInAttribute=!0,b}function T(a,b){return function(g,x){for(;!g.eol();){if(g.match(b)){x.tokenize=S;break}g.next()}return a}}function E(a){return function(b,g){for(var x;(x=b.next())!=null;){if(x=="<")return g.tokenize=E(a+1),g.tokenize(b,g);if(x==">")if(a==1){g.tokenize=S;break}else return g.tokenize=E(a-1),g.tokenize(b,g)}return"meta"}}function l(a,b,g){this.prev=a.context,this.tagName=b,this.indent=a.indented,this.startOfLine=g,(U.doNotIndent.hasOwnProperty(b)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function s(a,b){for(var g;;){if(!a.context)return;if(g=a.context.tagName,!U.contextGrabbers.hasOwnProperty(g)||!U.contextGrabbers[g].hasOwnProperty(b))return;o(a)}}function u(a,b,g){return a=="openTag"?(g.tagStart=b.column(),w):a=="closeTag"?m:u}function w(a,b,g){return a=="word"?(g.tagName=b.current(),v="tag",p):U.allowMissingTagName&&a=="endTag"?(v="tag bracket",p(a,b,g)):(v="error",w)}function m(a,b,g){if(a=="word"){var x=b.current();return g.context&&g.context.tagName!=x&&U.implicitlyClosed.hasOwnProperty(g.context.tagName)&&o(g),g.context&&g.context.tagName==x||U.matchClosing===!1?(v="tag",h):(v="tag error",L)}else return U.allowMissingTagName&&a=="endTag"?(v="tag bracket",h(a,b,g)):(v="error",L)}function h(a,b,g){return a!="endTag"?(v="error",h):(o(g),u)}function L(a,b,g){return v="error",h(a,b,g)}function p(a,b,g){if(a=="word")return v="attribute",c;if(a=="endTag"||a=="selfcloseTag"){var x=g.tagName,P=g.tagStart;return g.tagName=g.tagStart=null,a=="selfcloseTag"||U.autoSelfClosers.hasOwnProperty(x)?s(g,x):(s(g,x),g.context=new l(g,x,P==g.indented)),u}return v="error",p}function c(a,b,g){return a=="equals"?f:(U.allowMissing||(v="error"),p(a,b,g))}function f(a,b,g){return a=="string"?d:a=="word"&&U.allowUnquoted?(v="string",p):(v="error",p(a,b,g))}function d(a,b,g){return a=="string"?d:p(a,b,g)}return{startState:function(a){var b={tokenize:S,state:u,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(b.baseIndent=a),b},token:function(a,b){if(!b.tagName&&a.sol()&&(b.indented=a.indentation()),a.eatSpace())return null;_=null;var g=b.tokenize(a,b);return(g||_)&&g!="comment"&&(v=null,b.state=b.state(_||g,a,b),v&&(g=v=="error"?g+" error":v)),g},indent:function(a,b,g){var x=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+O;if(x&&x.noIndent)return Q.Pass;if(a.tokenize!=D&&a.tokenize!=S)return g?g.match(/^(\s*)/)[0].length:0;if(a.tagName)return U.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+O*(U.multilineTagIndentFactor||1);if(U.alignCDATA&&/<!\[CDATA\[/.test(b))return 0;var P=b&&/^<(\/)?([\w_:\.-]*)/.exec(b);if(P&&P[1])for(;x;)if(x.tagName==P[2]){x=x.prev;break}else if(U.implicitlyClosed.hasOwnProperty(x.tagName))x=x.prev;else break;else if(P)for(;x;){var N=U.contextGrabbers[x.tagName];if(N&&N.hasOwnProperty(P[2]))x=x.prev;else break}for(;x&&x.prev&&!x.startOfLine;)x=x.prev;return x?x.indent+O:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:U.htmlMode?"html":"xml",helperType:U.htmlMode?"html":"xml",skipAttribute:function(a){a.state==f&&(a.state=p)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var b=[],g=a.context;g;g=g.prev)g.tagName&&b.push(g.tagName);return b.reverse()}}}),Q.defineMIME("text/xml","xml"),Q.defineMIME("application/xml","xml"),Q.mimeModes.hasOwnProperty("text/html")||Q.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"389U":function(ut,Qe,q){"use strict";q.r(Qe);var Q=q("+L6B"),G=q("2/Rp"),A=q("oBTY"),W=q("giR+"),k=q("fyUT"),O=q("5Dmo"),U=q("3S7+"),F=q("sRBo"),R=q("kaz8"),_=q("2qtc"),v=q("kLXV"),S=q("miYZ"),D=q("tsqr"),C=q("k1fw"),T=q("9og8"),E=q("tJVT"),l=q("PpiC"),o=q("5NDa"),s=q("5rEg"),u=q("OaEy"),w=q("2fM7"),m=q("WmNS"),h=q.n(m),L=q("cDcd"),p=q.n(L),c=q("9kvl"),f=q("Ot1p"),d=q("HBuW"),a=q("LvDl"),b=q.n(a),g=q("bNIU"),x=q.n(g),P=q("9ZNV"),N=q("fnXi"),H=q("nuEh"),X=q("UqFu"),B=w.a.Option,I=s.a.TextArea,Y=function(se){var de=se.shixunsDetail,Se=se.dispatch,ge=se.match,pe=se.practiceSetting,he=Object(l.a)(se,["shixunsDetail","dispatch","match","practiceSetting"]),me=Object(L.useState)({}),ae=Object(E.a)(me,2),ue=ae[0],xe=ae[1],Fe=Object(L.useState)([]),Re=Object(E.a)(Fe,2),Ie=Re[0],Ke=Re[1],De=Object(L.useState)(!1),Ce=Object(E.a)(De,2),Me=Ce[0],Be=Ce[1],je=Object(L.useRef)(null),_e=Object(L.useRef)({editData:null,answerList:null}),Le=Object(L.useState)(!0),$e=Object(E.a)(Le,2),Je=$e[0],We=$e[1];Object(L.useEffect)(function(){He()},[]),Object(L.useEffect)(function(){be()},[ue,Ie]);var He=function(){var ve=Object(T.a)(h.a.mark(function Ee(){return h.a.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return We(!0),ee.next=3,et();case 3:return ee.next=5,Ye();case 5:We(!1);case 6:case"end":return ee.stop()}},Ee)}));return function(){return ve.apply(this,arguments)}}(),et=function(){var ve=Object(T.a)(h.a.mark(function Ee(){var oe;return h.a.wrap(function(re){for(;;)switch(re.prev=re.next){case 0:return re.next=2,Object(d.H)({id:ge.params.id,challengeId:ge.params.challengesId,tab:2});case 2:oe=re.sent,_e.current.editData=oe,oe&&xe(oe);case 5:case"end":return re.stop()}},Ee)}));return function(){return ve.apply(this,arguments)}}(),Ye=function(){var ve=Object(T.a)(h.a.mark(function Ee(){var oe,ee;return h.a.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:return V.next=2,Object(d.I)({id:ge.params.id,challengeId:ge.params.challengesId});case 2:oe=V.sent,ee=oe.map(function($){return Object(C.a)(Object(C.a)({},$),{},{contents:Object(X.a)($.contents)})}),_e.current.answerList=ee,oe&&Ke(ee);case 6:case"end":return V.stop()}},Ee)}));return function(){return ve.apply(this,arguments)}}(),Ve=function(){var ve=Object(T.a)(h.a.mark(function Ee(){var oe,ee,re;return h.a.wrap(function($){for(;;)switch($.prev=$.next){case 0:if(Be(!0),oe=Ie.map(function(J){return J.score}),ee=oe.reduce(function(J,ne){return J+ne},0),!(ee!==100&&Ie!==null&&Ie!==void 0&&Ie.length)){$.next=7;break}return Be(!1),D.b.info("\u6D4B\u8BD5\u96C6\u7684\u8BC4\u5206\u5360\u6BD4\u4E4B\u548C\u5FC5\u987B\u7B49\u4E8E100"),$.abrupt("return");case 7:if(Ie.every(function(J){return J.name})){$.next=11;break}return Be(!1),D.b.info("\u8BF7\u5148\u586B\u5199\u53C2\u8003\u7B54\u6848\u540D\u79F0"),$.abrupt("return");case 11:if(Ie.every(function(J){return J.contents})){$.next=15;break}return Be(!1),D.b.info("\u8BF7\u5148\u586B\u5199\u53C2\u8003\u7B54\u6848\u5185\u5BB9"),$.abrupt("return");case 15:return $.next=17,Object(d.Lb)({id:ge.params.id,challengeId:ge.params.challengesId,challenge_answer:Ie,hide_answer:ue==null?void 0:ue.hide_answer,disable_copy:ue==null?void 0:ue.disable_copy});case 17:re=$.sent,Be(!1),Se({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}}),re!=null&&re.message&&D.b.info(re.message),re.status===1&&c.d.push("/shixuns/".concat(ge.params.id,"/edit/").concat(ge.params.challengesId,"/tab=4"));case 22:case"end":return $.stop()}},Ee)}));return function(){return ve.apply(this,arguments)}}(),be=function(){clearTimeout(je.current),je.current=setTimeout(Ze,500)},Ze=function(){!Object(a.isEqual)(_e.current.editData,ue)||!Object(a.isEqual)(_e.current.answerList,Ie)?Se({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!0}}):Se({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})},Ge=function(){var Ee,oe=function(){c.d.push("/shixuns/".concat(ge.params.id,"/challenges")),Se({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};pe!=null&&(Ee=pe.sideBar)!==null&&Ee!==void 0&&Ee.confirmLeave?v.a.confirm({title:"\u79BB\u5F00\u6B64\u9875\u63D0\u793A",content:"\u7CFB\u7EDF\u53EF\u80FD\u4E0D\u4F1A\u4FDD\u5B58\u60A8\u6240\u505A\u7684\u66F4\u6539\u3002",okText:"\u79BB\u5F00",cancelText:"\u53D6\u6D88",onOk:function(){oe()}}):oe()};return p.a.createElement("section",{className:x.a.bg},p.a.createElement("div",{className:x.a.formWrap},p.a.createElement(N.a,{activeIndex:2}),p.a.createElement("div",{className:x.a.check},p.a.createElement("div",null,p.a.createElement(R.a,{checked:ue==null?void 0:ue.hide_answer,onChange:function(Ee){return xe(Object(C.a)(Object(C.a)({},ue),{},{hide_answer:Ee.target.checked}))}},"\u9690\u85CF\u53C2\u8003\u7B54\u6848\u6A21\u5757")),p.a.createElement("div",null,p.a.createElement(R.a,{checked:ue==null?void 0:ue.disable_copy,onChange:function(Ee){return xe(Object(C.a)(Object(C.a)({},ue),{},{disable_copy:Ee.target.checked}))}},"\u7981\u6B62\u590D\u5236\u53C2\u8003\u7B54\u6848"))),p.a.createElement("div",{className:x.a.fieldWrap},p.a.createElement("p",null,"\u53EF\u4EE5\u5C06\u53C2\u8003\u7B54\u6848\u5206\u7EA7\u8BBE\u7F6E\uFF0C\u8BA9\u5B66\u5458\u81EA\u884C\u9009\u62E9\u7EA7\u522B\uFF0C\u6BCF\u7EA7\u67E5\u770B\u540E\u6309\u7167\u6BD4\u4F8B\u6263\u5206\u503C\uFF08\u5B66\u5458\u5DF2\u5B8C\u6210\u4EFB\u52A1\u518D\u67E5\u770B\uFF0C\u5219\u4E0D\u5F71\u54CD\u5B66\u5458\u5DF2\u83B7\u5F97\u7684\u6210\u7EE9\uFF09"),p.a.createElement("p",null,"\u793A\u4F8B\uFF1A\u7EA7\u522B1\uFF0C\u6263\u51CF\u5206\u503C\u5360\u6BD425%\uFF1B\u7EA7\u522B2\uFF0C\u6263\u51CF\u5206\u503C\u5360\u6BD435%\uFF1B\u7EA7\u522B3\uFF0C\u6263\u51CF\u5206\u503C\u5360\u6BD440%\uFF1B"),p.a.createElement("p",null,"\u82E5\u5B66\u5458\u9009\u62E9\u67E5\u770B\u7EA7\u522B1\u7684\u7B54\u6848\uFF0C\u5C06\u88AB\u6263\u51CF25%\u7684\u5206\u503C\uFF1B\u9009\u62E9\u67E5\u770B\u7EA7\u522B2\u7684\u7B54\u6848\uFF0C\u5C06\u88AB\u6263\u51CF60%\u7684\u5206\u503C\uFF1B\u9009\u62E9\u67E5\u770B\u7EA7\u522B3\u7684\u7B54\u6848\uFF0C\u5C06\u88AB\u6263\u51CF100%\u7684\u5206\u503C\u3002"),Ie==null?void 0:Ie.map(function(ve,Ee){return p.a.createElement("div",{key:Ee,className:"mt30 pb5"},p.a.createElement("div",{className:x.a.flexRow},p.a.createElement("b",{className:"font16"},"\u7EA7\u522B\uFF1A",Ee+1),p.a.createElement("div",{className:"tr flex1"},p.a.createElement(U.a,{placement:"bottom",title:"\u5220\u9664"},p.a.createElement("span",{className:"font14 c-red current",onClick:function(){var ee=Ie.filter(function($,J){return J!==Ee}),re=Math.floor(100/ee.length),V=re+100%ee.length;ee=ee.map(function($,J){return J===ee.length-1?Object(C.a)(Object(C.a)({},$),{},{score:V}):Object(C.a)(Object(C.a)({},$),{},{score:re})}),Ke(ee)}},"\u5220\xA0\u9664")))),p.a.createElement("div",{className:x.a.contentWrap},p.a.createElement("div",{className:x.a.flexRow},p.a.createElement("div",null,p.a.createElement("p",{className:"font16"},"\u540D\u79F0\uFF1A"),p.a.createElement(s.a,{bordered:!1,value:ve.name,onChange:function(ee){var re=Ie.map(function(V,$){return $===Ee?Object(C.a)(Object(C.a)({},V),{},{name:ee.target.value}):V});Ke(re)}})),p.a.createElement("div",{className:"ml10"},p.a.createElement("p",{className:"font16"},"\u6263\u51CF\u5206\u503C\u5360\u6BD4\uFF1A"),p.a.createElement(k.a,{min:0,max:100,value:ve.score,onChange:function(ee){var re=Ie.map(function(V,$){return $===Ee?Object(C.a)(Object(C.a)({},V),{},{score:ee}):V});Ke(re)}})))),p.a.createElement("div",{className:"mt10 mb10"},p.a.createElement("div",{className:"font16 mb20"},"\u5185\u5BB9\uFF1A"),p.a.createElement(f.a,{placeholder:"\u5EFA\u8BAE\u63D0\u4F9B\u5305\u62EC\u6587\u4EF6\u6240\u6709\u4EE3\u7801\u7684\u5B8C\u6574\u7B54\u6848",defaultValue:ve.contents,onChange:function(ee){var re=Ie.map(function(V,$){return $===Ee?Object(C.a)(Object(C.a)({},V),{},{contents:ee}):V});Ke(re)}})))}),p.a.createElement("div",null,p.a.createElement(G.a,{type:"primary",size:"large",ghost:!0,style:{width:200},className:"mt10",onClick:function(){var Ee=[].concat(Object(A.a)(Ie),[{name:"\u89E3\u9898\u601D\u8DEF".concat(Ie.length+1),contents:"",score:0,id:null,level:null}]),oe=Math.floor(100/Ee.length),ee=oe+100%Ee.length;Ee=Ee.map(function(re,V){return V===Ee.length-1?Object(C.a)(Object(C.a)({},re),{},{score:ee}):Object(C.a)(Object(C.a)({},re),{},{score:oe})}),Ke(Ee)}},"\u65B0\u589E\u53C2\u8003\u7B54\u6848")))),p.a.createElement(P.a,{onOk:Ve,className:"customFixedButton",onCancel:Ge,loading:Me}),p.a.createElement(H.a,{loading:Je}))};Qe.default=Object(c.a)(function(te){var se=te.shixunsDetail,de=te.newCourse,Se=te.globalSetting,ge=te.practiceSetting;return{shixunsDetail:se,newCourse:de,globalSetting:Se,practiceSetting:ge}})(Y)},"7Cbv":function(ut,Qe,q){"use strict";var Q=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),G=new Uint8Array(16);function A(){if(!Q)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Q(G)}var W=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function k(D){return typeof D=="string"&&W.test(D)}for(var O=k,U=[],F=0;F<256;++F)U.push((F+256).toString(16).substr(1));function R(D){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,T=(U[D[C+0]]+U[D[C+1]]+U[D[C+2]]+U[D[C+3]]+"-"+U[D[C+4]]+U[D[C+5]]+"-"+U[D[C+6]]+U[D[C+7]]+"-"+U[D[C+8]]+U[D[C+9]]+"-"+U[D[C+10]]+U[D[C+11]]+U[D[C+12]]+U[D[C+13]]+U[D[C+14]]+U[D[C+15]]).toLowerCase();if(!O(T))throw TypeError("Stringified UUID is invalid");return T}var _=R;function v(D,C,T){D=D||{};var E=D.random||(D.rng||A)();if(E[6]=E[6]&15|64,E[8]=E[8]&63|128,C){T=T||0;for(var l=0;l<16;++l)C[T+l]=E[l];return C}return _(E)}var S=Qe.a=v},"7ahc":function(ut,Qe,q){"use strict";q.d(Qe,"a",function(){return w});var Q=q("k1fw"),G=q("0Owb"),A=q("+L6B"),W=q("2/Rp"),k=q("y8nQ"),O=q("Vl3Y"),U=q("tJVT"),F=q("OaEy"),R=q("2fM7"),_=q("cDcd"),v=q.n(_),S=q("VrN/"),D=q.n(S),C=q("p77/"),T=q.n(C),E=q("c5Ni"),l=q.n(E),o=R.a.Option,s={labelCol:{span:4},wrapperCol:{span:20}},u={asp:["ASP","vbscript"],actionscript:["ActionScript(3.0)/Flash/Flex","clike"],bash:["Bash/Bat","shell"],css:["CSS","css"],c:["C","clike"],cpp:["C++","clike"],csharp:["C#","clike"],coffeescript:["CoffeeScript","coffeescript"],d:["D","d"],dart:["Dart","dart"],delphi:["Delphi/Pascal","pascal"],erlang:["Erlang","erlang"],go:["Golang","go"],groovy:["Groovy","groovy"],html:["HTML","text/html"],java:["Java","clike"],json:["JSON","text/json"],javascript:["Javascript","javascript"],lua:["Lua","lua"],less:["LESS","css"],markdown:["Markdown","gfm"],"objective-c":["Objective-C","clike"],php:["PHP","php"],perl:["Perl","perl"],python:["Python","python"],r:["R","r"],rst:["reStructedText","rst"],ruby:["Ruby","ruby"],sql:["SQL","sql"],sass:["SASS/SCSS","sass"],shell:["Shell","shell"],scala:["Scala","clike"],swift:["Swift","clike"],vb:["VB/VBScript","vb"],xml:["XML","text/xml"],yaml:["YAML","yaml"]};Qe.b=function(m){var h=m.callback,L=m.onCancel,p=Object(_.useState)("python"),c=Object(U.a)(p,2),f=c[0],d=c[1];function a(g){d(u[g][1])}function b(g){h(g)}return v.a.createElement(O.a,Object(G.a)({},s,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:b}),v.a.createElement(O.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},v.a.createElement(R.a,{onChange:a},Object.keys(u).map(function(g){return v.a.createElement(o,{key:g,value:g},u[g][0])}))),v.a.createElement(O.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},v.a.createElement(w,{mode:f})),v.a.createElement("div",{className:"flex-container flex-end"},v.a.createElement(W.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),v.a.createElement(W.a,{type:"ghost",onClick:L},"\u53D6\u6D88")))};function w(m){var h=m.value,L=m.onChange,p=m.mode,c=m.options,f=c===void 0?{}:c,d=Object(_.useRef)(),a=Object(_.useState)(),b=Object(U.a)(a,2),g=b[0],x=b[1];return Object(_.useEffect)(function(){if(g){function P(N){var H=N.getValue();L&&L(H)}return g.on("change",P),function(){g.off("change",P)}}},[g,L]),Object(_.useEffect)(function(){g&&g.setOption("mode",p)},[g,p]),Object(_.useEffect)(function(){g&&((h!==g.getValue()||h==="")&&setTimeout(function(){g.setValue(h||" ")},300))},[g,h]),Object(_.useEffect)(function(){if(d.current&&!g){var P=D.a.fromTextArea(d.current,Object(Q.a)({mode:p,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},f));x(P)}},[d.current,g]),v.a.createElement("div",{className:"my-codemirror-container"},v.a.createElement("textarea",{ref:d}))}},"7ixt":function(ut,Qe,q){"use strict";q.d(Qe,"a",function(){return A});var Q={adjustX:1,adjustY:1},G=[0,0],A={left:{points:["cr","cl"],overflow:Q,offset:[-4,0],targetOffset:G},right:{points:["cl","cr"],overflow:Q,offset:[4,0],targetOffset:G},top:{points:["bc","tc"],overflow:Q,offset:[0,-4],targetOffset:G},bottom:{points:["tc","bc"],overflow:Q,offset:[0,4],targetOffset:G},topLeft:{points:["bl","tl"],overflow:Q,offset:[0,-4],targetOffset:G},leftTop:{points:["tr","tl"],overflow:Q,offset:[-4,0],targetOffset:G},topRight:{points:["br","tr"],overflow:Q,offset:[0,-4],targetOffset:G},rightTop:{points:["tl","tr"],overflow:Q,offset:[4,0],targetOffset:G},bottomRight:{points:["tr","br"],overflow:Q,offset:[0,4],targetOffset:G},rightBottom:{points:["bl","br"],overflow:Q,offset:[4,0],targetOffset:G},bottomLeft:{points:["tl","bl"],overflow:Q,offset:[0,4],targetOffset:G},leftBottom:{points:["br","bl"],overflow:Q,offset:[-4,0],targetOffset:G}},W=A},"8EBN":function(ut,Qe,q){(function(Q){Q(q("VrN/"))})(function(Q){"use strict";Q.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var G=0;G<Q.modeInfo.length;G++){var A=Q.modeInfo[G];A.mimes&&(A.mime=A.mimes[0])}Q.findModeByMIME=function(W){W=W.toLowerCase();for(var k=0;k<Q.modeInfo.length;k++){var O=Q.modeInfo[k];if(O.mime==W)return O;if(O.mimes){for(var U=0;U<O.mimes.length;U++)if(O.mimes[U]==W)return O}}if(/\+xml$/.test(W))return Q.findModeByMIME("application/xml");if(/\+json$/.test(W))return Q.findModeByMIME("application/json")},Q.findModeByExtension=function(W){W=W.toLowerCase();for(var k=0;k<Q.modeInfo.length;k++){var O=Q.modeInfo[k];if(O.ext){for(var U=0;U<O.ext.length;U++)if(O.ext[U]==W)return O}}},Q.findModeByFileName=function(W){for(var k=0;k<Q.modeInfo.length;k++){var O=Q.modeInfo[k];if(O.file&&O.file.test(W))return O}var U=W.lastIndexOf("."),F=U>-1&&W.substring(U+1,W.length);if(F)return Q.findModeByExtension(F)},Q.findModeByName=function(W){W=W.toLowerCase();for(var k=0;k<Q.modeInfo.length;k++){var O=Q.modeInfo[k];if(O.name.toLowerCase()==W)return O;if(O.alias){for(var U=0;U<O.alias.length;U++)if(O.alias[U].toLowerCase()==W)return O}}}})},"8hTe":function(ut,Qe,q){ut.exports={button:"button___1wy9m"}},"93VE":function(ut,Qe,q){},"9Bee":function(ut,Qe,q){"use strict";var Q=q("DYRE"),G=q("zeV3"),A=q("+L6B"),W=q("2/Rp"),k=q("k1fw"),O=q("tJVT"),U=q("cDcd"),F=q.n(U),R=q("vg9a"),_=q("DlQD"),v=q.n(_),S=q("rUJ1");function D(pe,he){var me=pe.match(/^(\s+)(?:```)/);if(me===null)return he;var ae=me[1];return he.split(`
|
|
`).map(function(ue){var xe=ue.match(/^\s+/);if(xe===null)return ue;var Fe=Object(O.a)(xe,1),Re=Fe[0];return Re.length>=ae.length?ue.slice(ae.length):ue}).join(`
|
|
`)}var C=[],T=["<ul>"],E=new v.a.Renderer,l=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function o(){C.length=0,T=["<ul>"]}var s={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function u(pe,he,me,ae){if(he>=pe.length||pe[he].level<=me)return he;var ue=pe[he];ae.push("<li><a href='#"+ue.anchor+"'>"+ue.text+"</a>"),he++;var xe=[];return he=u(pe,he,ue.level,xe),xe.length>0&&(ae.push("<ul>"),xe.forEach(function(Fe){ae.push(Fe)}),ae.push("</ul>")),ae.push("</li>"),he=u(pe,he,me,ae),he}function w(){return u(C,0,0,T),T.push("</ul>"),T.join("")}var m={heading:function(he){var me=l.exec(he);if(me)return{type:"heading",raw:me[0],depth:me[1].length,text:me[2]}},fences:function(he){var me=this.rules.block.fences.exec(he);if(me){var ae=me[0],ue=D(ae,me[3]||""),xe=me[2]?me[2].trim():me[2];if(["latex","katex","math"].indexOf(xe)>=0){var Fe=p(),Re=ue;ue=Fe,c[Fe]={type:"block",expression:Re}}return{type:"code",raw:ae,lang:xe,text:ue}}}},h=/(?:\${2})([^\n`]+?)(?:\${2})/gi,L=0,p=function(){return"__special_katext_id_".concat(L++,"__")},c={};function f(){return c}function d(){L=0,c={}}function a(pe){return pe=pe.replace(h,function(he,me){var ae=p();return c[ae]={type:"inline",expression:me},ae}),pe}var b=E.listitem;E.listitem=function(pe){return b(a(pe))};var g=E.paragraph;E.paragraph=function(pe){return g(a(pe))};var x=E.tablecell;E.tablecell=function(pe,he){return x(a(pe),he)},E.code=function(pe,he,me){var ae=(he||"").match(/\S*/)[0];return ae?["latex","katex","math"].indexOf(ae)>=0?"<p class='editormd-tex'>".concat(pe,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(he,'">').concat(me?pe:Object(S.escape)(pe,!0),`</code></pre>
|
|
`):'<pre class="prettyprint linenums"><code>'+(me?pe:Object(S.escape)(pe,!0))+"</code></pre>"},E.heading=function(pe,he,me){var ae=this.options.headerPrefix+me.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return C.push({anchor:ae,level:he,text:pe}),"<h"+he+' id="'+ae+'">'+pe+"</h"+he+">"},v.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),v.a.use({tokenizer:m,renderer:E});var P=v.a,N=q("SJMd"),H=q("ulZh"),X=q.n(H),B=q("m3rI"),I=q("Oy/b"),Y=q("p5ED"),te=q("8hTe"),se=q.n(te),de=/<pre[^>]*>/g;function Se(pe){var he=document.createElement("div");return he.innerHTML=pe,he.childNodes.length===0?"":he.childNodes[0].nodeValue}var ge=Qe.a=function(pe){var he=pe.value,me=he===void 0?"":he,ae=pe.edit,ue=ae===void 0?!1:ae,xe=pe.className,Fe=pe.showTextOnly,Re=pe.showLines,Ie=pe.replaces,Ke=pe.zoomImg,De=pe.hasMask,Ce=pe.style,Me=Ce===void 0?{}:Ce,Be=pe.stylesPrev,je=Be===void 0?{}:Be,_e=String(me),Le=Object(U.useRef)(),$e=Object(U.useRef)(),Je=Object(U.useState)(""),We=Object(O.a)(Je,2),He=We[0],et=We[1],Ye=Object(U.useState)("office"),Ve=Object(O.a)(Ye,2),be=Ve[0],Ze=Ve[1],Ge=Object(U.useMemo)(function(){try{var re=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,V=/\"\/api\/attachments\/|\"\/attachments\/download\//g,$=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;_e=_e.replace(re,"("+B.a.API_SERVER+"/api/attachments/").replace(V,'"'+B.a.API_SERVER+"/api/attachments/").replace($,'"'+B.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(ye){}var J=P(_e),ne=f();if(_e.match(/\[TOC\]/)&&(J=J.replace("<p>[TOC]</p>",w()),o()),J=J.replace(/(__special_katext_id_\d+__)/g,function(ye,we){var ze=ne[we],it=ze.type,tt=ze.expression;return Object(I.renderToString)(Se(tt)||"",{displayMode:it==="block",throwOnError:!1,output:"html"})}),J=J.replace(/▁/g,"\u2581\u2581\u2581"),d(),Fe){var le=document.createElement("div");return le.innerHTML=J,le.innerText}return setTimeout(function(){return oe()},500),J},[_e]),ve=Object(U.useRef)();s.WebkitLineClamp=Re,Re&&(Me=Object(k.a)(Object(k.a)({},Me),s));function Ee(re){var V=re.target;if(V.tagName.toUpperCase()==="IMG"){if(Ke){var $=V.getAttribute("src");et($),Ze("image")}}else if(V.tagName.toUpperCase()==="A"){var J=V.getAttribute("href");if(J.indexOf("office")>-1)re.preventDefault(),et(J),Ze("office");else if(J.indexOf("application/pdf")>-1)re.preventDefault(),et(J),Ze("pdf");else if(J.indexOf("text/html")>-1)re.preventDefault(),et(J),Ze("html");else if(J.startsWith("#")){re.preventDefault();var ne=document.getElementById(J.replace("#",""));ne&&ne.scrollIntoView(!0)}}}var oe=function(){var V,$=(V=ve.current)===null||V===void 0?void 0:V.querySelectorAll("video");$==null||$.forEach(function(J){if(J.oncontextmenu=function(){return!1},J.src.indexOf(".m3u8")>-1&&!J.canPlayType("application/vnd.apple.mpegurl")){if(X.a.isSupported()){var ne=new X.a;ne.loadSource(J.src),ne.attachMedia(J)}}})};Object(U.useEffect)(function(){if(ve.current&&Ge&&(Ge.match(de)&&window.PR.prettyPrint()),ve.current)return ve.current.addEventListener("click",Ee),function(){ve.current.removeEventListener("click",Ee),d(),o()}},[Ge,ve.current,Ee]);var ee=function(V){if(!ue)return;V.target.nodeName==="IMG"?(Le.current.style.display="flex",Le.current.style.width=V.target.clientWidth+"px",Le.current.style.height=V.target.clientHeight+"px",Le.current.style.top=V.target.offsetTop+"px",Le.current.style.left=V.target.offsetLeft+"px",$e.current.src=V.target.getAttribute("src")):Le.current.style.display="none"};return F.a.createElement("div",{style:{position:"relative"}},F.a.createElement("div",{ref:ve,style:Object(k.a)({},Me),className:"".concat(xe||""," markdown-body ").concat(se.a.mdBody),onMouseOver:ee,dangerouslySetInnerHTML:{__html:Ge}}),F.a.createElement("div",{ref:Le,className:se.a.button},F.a.createElement(G.a,null,F.a.createElement(W.a,{onClick:function(){return openCrop()}},"\u88C1\u526A"),F.a.createElement(W.a,{onClick:function(){return openEditor()}},"\u7F16\u8F91"))),F.a.createElement("img",{ref:$e,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1,top:"-10000px"}}),F.a.createElement(Y.a,{close:!0,data:He,type:He!=null&&He.length?be:"",style:Object(k.a)({},je),onClose:function(){return et("")}}))}},"9VGf":function(ut,Qe,q){"use strict";q.d(Qe,"a",function(){return A});var Q=q("cDcd"),G=q.n(Q);function A(W,k){var O=Object(Q.useRef)();Object(Q.useEffect)(function(){O.current=W}),Object(Q.useEffect)(function(){function U(){O.current()}if(k!==null){var F=setInterval(U,k);return function(){return clearInterval(F)}}},[k])}},"9ZNV":function(ut,Qe,q){"use strict";q.d(Qe,"a",function(){return _});var Q=q("0Owb"),G=q("+L6B"),A=q("2/Rp"),W=q("cDcd"),k=q.n(W),O=q("UUDw"),U=q.n(O),F=q("TSYQ"),R=q.n(F),_=function(S){var D=S.cancelText,C=D===void 0?"\u53D6\u6D88":D,T=S.okText,E=T===void 0?"\u786E\u5B9A":T,l=S.loading,o=l===void 0?!1:l,s=S.hasOkBtn,u=s===void 0?!0:s,w=S.okButtonProps,m=w===void 0?{}:w,h=S.onCancel,L=h===void 0?function(){}:h,p=S.onOk,c=p===void 0?function(){}:p,f=S.className,d=f===void 0?"":f;return k.a.createElement("div",{className:R()(U.a.buttonFixed,d)},k.a.createElement("div",{className:U.a.buttonWrap},k.a.createElement(A.a,{size:"large",className:"".concat(U.a.button," mr20"),onClick:L},C),u&&k.a.createElement(A.a,Object(Q.a)({size:"large",type:"primary",className:"".concat(U.a.button," mr20"),loading:o,onClick:c},m),E)))}},Bd2K:function(ut,Qe,q){(function(Q){Q(q("VrN/"),q("osHv"))})(function(Q){Q.defineOption("autoCloseTags",!1,function(R,_,v){if(v!=Q.Init&&v&&R.removeKeyMap("autoCloseTags"),!_)return;var S={name:"autoCloseTags"};(typeof _!="object"||_.whenClosing!==!1)&&(S["'/'"]=function(D){return O(D)}),(typeof _!="object"||_.whenOpening!==!1)&&(S["'>'"]=function(D){return W(D)}),R.addKeyMap(S)});var G=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],A=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function W(R){if(R.getOption("disableInput"))return Q.Pass;for(var _=R.listSelections(),v=[],S=R.getOption("autoCloseTags"),D=0;D<_.length;D++){if(!_[D].empty())return Q.Pass;var C=_[D].head,T=R.getTokenAt(C),E=Q.innerMode(R.getMode(),T.state),l=E.state,o=E.mode.xmlCurrentTag&&E.mode.xmlCurrentTag(l),s=o&&o.name;if(!s)return Q.Pass;var u=E.mode.configuration=="html",w=typeof S=="object"&&S.dontCloseTags||u&&G,m=typeof S=="object"&&S.indentTags||u&&A;T.end>C.ch&&(s=s.slice(0,s.length-T.end+C.ch));var h=s.toLowerCase();if(!s||T.type=="string"&&(T.end!=C.ch||!/[\"\']/.test(T.string.charAt(T.string.length-1))||T.string.length==1)||T.type=="tag"&&o.close||T.string.indexOf("/")==C.ch-T.start-1||w&&U(w,h)>-1||F(R,E.mode.xmlCurrentContext&&E.mode.xmlCurrentContext(l)||[],s,C,!0))return Q.Pass;var L=typeof S=="object"&&S.emptyTags;if(L&&U(L,s)>-1){v[D]={text:"/>",newPos:Q.Pos(C.line,C.ch+2)};continue}var p=m&&U(m,h)>-1;v[D]={indent:p,text:">"+(p?`
|
|
|
|
`:"")+"</"+s+">",newPos:p?Q.Pos(C.line+1,0):Q.Pos(C.line,C.ch+1)}}for(var c=typeof S=="object"&&S.dontIndentOnAutoClose,D=_.length-1;D>=0;D--){var f=v[D];R.replaceRange(f.text,_[D].head,_[D].anchor,"+insert");var d=R.listSelections().slice(0);d[D]={head:f.newPos,anchor:f.newPos},R.setSelections(d),!c&&f.indent&&(R.indentLine(f.newPos.line,null,!0),R.indentLine(f.newPos.line+1,null,!0))}}function k(R,_){for(var v=R.listSelections(),S=[],D=_?"/":"</",C=R.getOption("autoCloseTags"),T=typeof C=="object"&&C.dontIndentOnSlash,E=0;E<v.length;E++){if(!v[E].empty())return Q.Pass;var l=v[E].head,o=R.getTokenAt(l),s=Q.innerMode(R.getMode(),o.state),u=s.state;if(_&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=l.ch-1))return Q.Pass;var w,m=s.mode.name!="xml"&&R.getMode().name=="htmlmixed";if(m&&s.mode.name=="javascript")w=D+"script";else if(m&&s.mode.name=="css")w=D+"style";else{var h=s.mode.xmlCurrentContext&&s.mode.xmlCurrentContext(u);if(!h||h.length&&F(R,h,h[h.length-1],l))return Q.Pass;w=D+h[h.length-1]}R.getLine(l.line).charAt(o.end)!=">"&&(w+=">"),S[E]=w}if(R.replaceSelections(S),v=R.listSelections(),!T)for(var E=0;E<v.length;E++)(E==v.length-1||v[E].head.line<v[E+1].head.line)&&R.indentLine(v[E].head.line)}function O(R){return R.getOption("disableInput")?Q.Pass:k(R,!0)}Q.commands.closeTag=function(R){return k(R)};function U(R,_){if(R.indexOf)return R.indexOf(_);for(var v=0,S=R.length;v<S;++v)if(R[v]==_)return v;return-1}function F(R,_,v,S,D){if(!Q.scanForClosingTag)return!1;var C=Math.min(R.lastLine()+1,S.line+500),T=Q.scanForClosingTag(R,S,null,C);if(!T||T.tag!=v)return!1;for(var E=D?1:0,l=_.length-1;l>=0&&_[l]==v;l--)++E;S=T.to;for(var l=1;l<E;l++){var o=Q.scanForClosingTag(R,S,null,C);if(!o||o.tag!=v)return!1;S=o.to}return!0}})},BjJ7:function(ut,Qe,q){"use strict";q.d(Qe,"d",function(){return G}),q.d(Qe,"c",function(){return A}),q.d(Qe,"e",function(){return W}),q.d(Qe,"b",function(){return k}),q.d(Qe,"a",function(){return U});var Q=q("m3rI");function G(F){var R=!0;if(F.length>0){for(var _=0;_<F.length;_++)if(F[_].compile_success==0||!F[_].compile_success){R=!1;break}}else R=!1;return R}function A(F){for(var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",_=[],v=0;v<F.length;v++){var S=F[v],D=R?"".concat(R,"/").concat(S.name):"".concat(S.name);_.push({title:S.name,isLeaf:!(S.type==="tree"),key:D})}return _}function W(F,R,_){for(var v=0;v<F.length;v++){var S=F[v];if(S.key===R){S.children=_;break}S.children&&W(S.children,R,_)}return F}function k(F,R,_){var v;return function(){var S=this,D=arguments,C=function(){v=null,_||F.apply(S,D)},T=_&&!v;clearTimeout(v),v=setTimeout(C,R),T&&F.apply(S,D)}}var O=!0,U=Q.a.API_SERVER},"C+DQ":function(ut,Qe,q){},DlQD:function(ut,Qe,q){(function(Q,G){ut.exports=G()})(this,function(){"use strict";function Q(oe,ee){for(var re=0;re<ee.length;re++){var V=ee[re];V.enumerable=V.enumerable||!1,V.configurable=!0,"value"in V&&(V.writable=!0),Object.defineProperty(oe,V.key,V)}}function G(oe,ee,re){return ee&&Q(oe.prototype,ee),re&&Q(oe,re),oe}function A(oe,ee){if(!oe)return;if(typeof oe=="string")return W(oe,ee);var re=Object.prototype.toString.call(oe).slice(8,-1);if(re==="Object"&&oe.constructor&&(re=oe.constructor.name),re==="Map"||re==="Set")return Array.from(oe);if(re==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(re))return W(oe,ee)}function W(oe,ee){(ee==null||ee>oe.length)&&(ee=oe.length);for(var re=0,V=new Array(ee);re<ee;re++)V[re]=oe[re];return V}function k(oe,ee){var re;if(typeof Symbol=="undefined"||oe[Symbol.iterator]==null){if(Array.isArray(oe)||(re=A(oe))||ee&&oe&&typeof oe.length=="number"){re&&(oe=re);var V=0;return function(){return V>=oe.length?{done:!0}:{done:!1,value:oe[V++]}}}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=oe[Symbol.iterator](),re.next.bind(re)}function O(oe,ee){return ee={exports:{}},oe(ee,ee.exports),ee.exports}var U=O(function(oe){function ee(){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(V){oe.exports.defaults=V}oe.exports={defaults:ee(),getDefaults:ee,changeDefaults:re}}),F=U.defaults,R=U.getDefaults,_=U.changeDefaults,v=/[&<>"']/,S=/[&<>"']/g,D=/[<>"']|&(?!#?\w+;)/,C=/[<>"']|&(?!#?\w+;)/g,T={"&":"&","<":"<",">":">",'"':""","'":"'"},E=function(ee){return T[ee]};function l(oe,ee){if(ee){if(v.test(oe))return oe.replace(S,E)}else if(D.test(oe))return oe.replace(C,E);return oe}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function s(oe){return oe.replace(o,function(ee,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 u=/(^|[^\[])\^/g;function w(oe,ee){oe=oe.source||oe,ee=ee||"";var re={replace:function($,J){return J=J.source||J,J=J.replace(u,"$1"),oe=oe.replace($,J),re},getRegex:function(){return new RegExp(oe,ee)}};return re}var m=/[^\w:]/g,h=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function L(oe,ee,re){if(oe){var V;try{V=decodeURIComponent(s(re)).replace(m,"").toLowerCase()}catch($){return null}if(V.indexOf("javascript:")===0||V.indexOf("vbscript:")===0||V.indexOf("data:")===0)return null}ee&&!h.test(re)&&(re=a(ee,re));try{re=encodeURI(re).replace(/%25/g,"%")}catch($){return null}return re}var p={},c=/^[^:]+:\/*[^/]*$/,f=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(oe,ee){p[" "+oe]||(c.test(oe)?p[" "+oe]=oe+"/":p[" "+oe]=P(oe,"/",!0)),oe=p[" "+oe];var re=oe.indexOf(":")===-1;return ee.substring(0,2)==="//"?re?ee:oe.replace(f,"$1")+ee:ee.charAt(0)==="/"?re?ee:oe.replace(d,"$1")+ee:oe+ee}var b={exec:function(){}};function g(oe){for(var ee=1,re,V;ee<arguments.length;ee++){re=arguments[ee];for(V in re)Object.prototype.hasOwnProperty.call(re,V)&&(oe[V]=re[V])}return oe}function x(oe,ee){var re=oe.replace(/\|/g,function(J,ne,le){for(var ye=!1,we=ne;--we>=0&&le[we]==="\\";)ye=!ye;return ye?"|":" |"}),V=re.split(/ \|/),$=0;if(V.length>ee)V.splice(ee);else for(;V.length<ee;)V.push("");for(;$<V.length;$++)V[$]=V[$].trim().replace(/\\\|/g,"|");return V}function P(oe,ee,re){var V=oe.length;if(V===0)return"";for(var $=0;$<V;){var J=oe.charAt(V-$-1);if(J===ee&&!re)$++;else if(J!==ee&&re)$++;else break}return oe.substr(0,V-$)}function N(oe,ee){if(oe.indexOf(ee[1])===-1)return-1;for(var re=oe.length,V=0,$=0;$<re;$++)if(oe[$]==="\\")$++;else if(oe[$]===ee[0])V++;else if(oe[$]===ee[1]&&(V--,V<0))return $;return-1}function H(oe){oe&&oe.sanitize&&!oe.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 X={escape:l,unescape:s,edit:w,cleanUrl:L,resolveUrl:a,noopTest:b,merge:g,splitCells:x,rtrim:P,findClosingBracket:N,checkSanitizeDeprecation:H},B=U.defaults,I=X.rtrim,Y=X.splitCells,te=X.escape,se=X.findClosingBracket;function de(oe,ee,re){var V=ee.href,$=ee.title?te(ee.title):null,J=oe[1].replace(/\\([\[\]])/g,"$1");return oe[0].charAt(0)!=="!"?{type:"link",raw:re,href:V,title:$,text:J}:{type:"image",raw:re,href:V,title:$,text:te(J)}}function Se(oe,ee){var re=oe.match(/^(\s+)(?:```)/);if(re===null)return ee;var V=re[1];return ee.split(`
|
|
`).map(function($){var J=$.match(/^\s+/);if(J===null)return $;var ne=J[0];return ne.length>=V.length?$.slice(V.length):$}).join(`
|
|
`)}var ge=function(){function oe(re){this.options=re||B}var ee=oe.prototype;return ee.space=function(V){var $=this.rules.block.newline.exec(V);if($)return $[0].length>1?{type:"space",raw:$[0]}:{raw:`
|
|
`}},ee.code=function(V,$){var J=this.rules.block.code.exec(V);if(J){var ne=$[$.length-1];if(ne&&ne.type==="paragraph")return{raw:J[0],text:J[0].trimRight()};var le=J[0].replace(/^ {4}/gm,"");return{type:"code",raw:J[0],codeBlockStyle:"indented",text:this.options.pedantic?le:I(le,`
|
|
`)}}},ee.fences=function(V){var $=this.rules.block.fences.exec(V);if($){var J=$[0],ne=Se(J,$[3]||"");return{type:"code",raw:J,lang:$[2]?$[2].trim():$[2],text:ne}}},ee.heading=function(V){var $=this.rules.block.heading.exec(V);if($)return{type:"heading",raw:$[0],depth:$[1].length,text:$[2]}},ee.nptable=function(V){var $=this.rules.block.nptable.exec(V);if($){var J={type:"table",header:Y($[1].replace(/^ *| *\| *$/g,"")),align:$[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:$[3]?$[3].replace(/\n$/,"").split(`
|
|
`):[],raw:$[0]};if(J.header.length===J.align.length){var ne=J.align.length,le;for(le=0;le<ne;le++)/^ *-+: *$/.test(J.align[le])?J.align[le]="right":/^ *:-+: *$/.test(J.align[le])?J.align[le]="center":/^ *:-+ *$/.test(J.align[le])?J.align[le]="left":J.align[le]=null;for(ne=J.cells.length,le=0;le<ne;le++)J.cells[le]=Y(J.cells[le],J.header.length);return J}}},ee.hr=function(V){var $=this.rules.block.hr.exec(V);if($)return{type:"hr",raw:$[0]}},ee.blockquote=function(V){var $=this.rules.block.blockquote.exec(V);if($){var J=$[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:$[0],text:J}}},ee.list=function(V){var $=this.rules.block.list.exec(V);if($){for(var J=$[0],ne=$[2],le=ne.length>1,ye=ne[ne.length-1]===")",we={type:"list",raw:J,ordered:le,start:le?+ne.slice(0,-1):"",loose:!1,items:[]},ze=$[0].match(this.rules.block.item),it=!1,tt,xt,ht,ot,Ct,yt,Bt,Ft=ze.length,bt=0;bt<Ft;bt++)tt=ze[bt],J=tt,xt=tt.length,tt=tt.replace(/^ *([*+-]|\d+[.)]) */,""),~tt.indexOf(`
|
|
`)&&(xt-=tt.length,tt=this.options.pedantic?tt.replace(/^ {1,4}/gm,""):tt.replace(new RegExp("^ {1,"+xt+"}","gm"),"")),bt!==Ft-1&&(ht=this.rules.block.bullet.exec(ze[bt+1])[0],(le?ht.length===1||!ye&&ht[ht.length-1]===")":ht.length>1||this.options.smartLists&&ht!==ne)&&(ot=ze.slice(bt+1).join(`
|
|
`),we.raw=we.raw.substring(0,we.raw.length-ot.length),bt=Ft-1)),Ct=it||/\n\n(?!\s*$)/.test(tt),bt!==Ft-1&&(it=tt.charAt(tt.length-1)===`
|
|
`,Ct||(Ct=it)),Ct&&(we.loose=!0),yt=/^\[[ xX]\] /.test(tt),Bt=void 0,yt&&(Bt=tt[1]!==" ",tt=tt.replace(/^\[[ xX]\] +/,"")),we.items.push({type:"list_item",raw:J,task:yt,checked:Bt,loose:Ct,text:tt});return we}},ee.html=function(V){var $=this.rules.block.html.exec(V);if($)return{type:this.options.sanitize?"paragraph":"html",raw:$[0],pre:!this.options.sanitizer&&($[1]==="pre"||$[1]==="script"||$[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer($[0]):te($[0]):$[0]}},ee.def=function(V){var $=this.rules.block.def.exec(V);if($){$[3]&&($[3]=$[3].substring(1,$[3].length-1));var J=$[1].toLowerCase().replace(/\s+/g," ");return{tag:J,raw:$[0],href:$[2],title:$[3]}}},ee.table=function(V){var $=this.rules.block.table.exec(V);if($){var J={type:"table",header:Y($[1].replace(/^ *| *\| *$/g,"")),align:$[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:$[3]?$[3].replace(/\n$/,"").split(`
|
|
`):[]};if(J.header.length===J.align.length){J.raw=$[0];var ne=J.align.length,le;for(le=0;le<ne;le++)/^ *-+: *$/.test(J.align[le])?J.align[le]="right":/^ *:-+: *$/.test(J.align[le])?J.align[le]="center":/^ *:-+ *$/.test(J.align[le])?J.align[le]="left":J.align[le]=null;for(ne=J.cells.length,le=0;le<ne;le++)J.cells[le]=Y(J.cells[le].replace(/^ *\| *| *\| *$/g,""),J.header.length);return J}}},ee.lheading=function(V){var $=this.rules.block.lheading.exec(V);if($)return{type:"heading",raw:$[0],depth:$[2].charAt(0)==="="?1:2,text:$[1]}},ee.paragraph=function(V){var $=this.rules.block.paragraph.exec(V);if($)return{type:"paragraph",raw:$[0],text:$[1].charAt($[1].length-1)===`
|
|
`?$[1].slice(0,-1):$[1]}},ee.text=function(V,$){var J=this.rules.block.text.exec(V);if(J){var ne=$[$.length-1];return ne&&ne.type==="text"?{raw:J[0],text:J[0]}:{type:"text",raw:J[0],text:J[0]}}},ee.escape=function(V){var $=this.rules.inline.escape.exec(V);if($)return{type:"escape",raw:$[0],text:te($[1])}},ee.tag=function(V,$,J){var ne=this.rules.inline.tag.exec(V);if(ne)return!$&&/^<a /i.test(ne[0])?$=!0:$&&/^<\/a>/i.test(ne[0])&&($=!1),!J&&/^<(pre|code|kbd|script)(\s|>)/i.test(ne[0])?J=!0:J&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ne[0])&&(J=!1),{type:this.options.sanitize?"text":"html",raw:ne[0],inLink:$,inRawBlock:J,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ne[0]):te(ne[0]):ne[0]}},ee.link=function(V){var $=this.rules.inline.link.exec(V);if($){var J=se($[2],"()");if(J>-1){var ne=$[0].indexOf("!")===0?5:4,le=ne+$[1].length+J;$[2]=$[2].substring(0,J),$[0]=$[0].substring(0,le).trim(),$[3]=""}var ye=$[2],we="";if(this.options.pedantic){var ze=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ye);ze?(ye=ze[1],we=ze[3]):we=""}else we=$[3]?$[3].slice(1,-1):"";ye=ye.trim().replace(/^<([\s\S]*)>$/,"$1");var it=de($,{href:ye&&ye.replace(this.rules.inline._escapes,"$1"),title:we&&we.replace(this.rules.inline._escapes,"$1")},$[0]);return it}},ee.reflink=function(V,$){var J;if((J=this.rules.inline.reflink.exec(V))||(J=this.rules.inline.nolink.exec(V))){var ne=(J[2]||J[1]).replace(/\s+/g," ");if(ne=$[ne.toLowerCase()],!ne||!ne.href){var le=J[0].charAt(0);return{type:"text",raw:le,text:le}}var ye=de(J,ne,J[0]);return ye}},ee.strong=function(V,$,J){J===void 0&&(J="");var ne=this.rules.inline.strong.start.exec(V);if(ne&&(!ne[1]||ne[1]&&(J===""||this.rules.inline.punctuation.exec(J)))){$=$.slice(-1*V.length);var le=ne[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;le.lastIndex=0;for(var ye;(ne=le.exec($))!=null;)if(ye=this.rules.inline.strong.middle.exec($.slice(0,ne.index+3)),ye)return{type:"strong",raw:V.slice(0,ye[0].length),text:V.slice(2,ye[0].length-2)}}},ee.em=function(V,$,J){J===void 0&&(J="");var ne=this.rules.inline.em.start.exec(V);if(ne&&(!ne[1]||ne[1]&&(J===""||this.rules.inline.punctuation.exec(J)))){$=$.slice(-1*V.length);var le=ne[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;le.lastIndex=0;for(var ye;(ne=le.exec($))!=null;)if(ye=this.rules.inline.em.middle.exec($.slice(0,ne.index+2)),ye)return{type:"em",raw:V.slice(0,ye[0].length),text:V.slice(1,ye[0].length-1)}}},ee.codespan=function(V){var $=this.rules.inline.code.exec(V);if($){var J=$[2].replace(/\n/g," "),ne=/[^ ]/.test(J),le=J.startsWith(" ")&&J.endsWith(" ");return ne&&le&&(J=J.substring(1,J.length-1)),J=te(J,!0),{type:"codespan",raw:$[0],text:J}}},ee.br=function(V){var $=this.rules.inline.br.exec(V);if($)return{type:"br",raw:$[0]}},ee.del=function(V){var $=this.rules.inline.del.exec(V);if($)return{type:"del",raw:$[0],text:$[1]}},ee.autolink=function(V,$){var J=this.rules.inline.autolink.exec(V);if(J){var ne,le;return J[2]==="@"?(ne=te(this.options.mangle?$(J[1]):J[1]),le="mailto:"+ne):(ne=te(J[1]),le=ne),{type:"link",raw:J[0],text:ne,href:le,tokens:[{type:"text",raw:ne,text:ne}]}}},ee.url=function(V,$){var J;if(J=this.rules.inline.url.exec(V)){var ne,le;if(J[2]==="@")ne=te(this.options.mangle?$(J[0]):J[0]),le="mailto:"+ne;else{var ye;do ye=J[0],J[0]=this.rules.inline._backpedal.exec(J[0])[0];while(ye!==J[0]);ne=te(J[0]),J[1]==="www."?le="http://"+ne:le=ne}return{type:"link",raw:J[0],text:ne,href:le,tokens:[{type:"text",raw:ne,text:ne}]}}},ee.inlineText=function(V,$,J){var ne=this.rules.inline.text.exec(V);if(ne){var le;return $?le=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ne[0]):te(ne[0]):ne[0]:le=te(this.options.smartypants?J(ne[0]):ne[0]),{type:"text",raw:ne[0],text:le}}},oe}(),pe=X.noopTest,he=X.edit,me=X.merge,ae={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:pe,table:pe,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ae._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ae._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ae.def=he(ae.def).replace("label",ae._label).replace("title",ae._title).getRegex(),ae.bullet=/(?:[*+-]|\d{1,9}[.)])/,ae.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ae.item=he(ae.item,"gm").replace(/bull/g,ae.bullet).getRegex(),ae.list=he(ae.list).replace(/bull/g,ae.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ae.def.source+")").getRegex(),ae._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",ae._comment=/<!--(?!-?>)[\s\S]*?-->/,ae.html=he(ae.html,"i").replace("comment",ae._comment).replace("tag",ae._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ae.paragraph=he(ae._paragraph).replace("hr",ae.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",ae._tag).getRegex(),ae.blockquote=he(ae.blockquote).replace("paragraph",ae.paragraph).getRegex(),ae.normal=me({},ae),ae.gfm=me({},ae.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*|$)"}),ae.gfm.nptable=he(ae.gfm.nptable).replace("hr",ae.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",ae._tag).getRegex(),ae.gfm.table=he(ae.gfm.table).replace("hr",ae.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",ae._tag).getRegex(),ae.pedantic=me({},ae.normal,{html:he(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ae._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:pe,paragraph:he(ae.normal._paragraph).replace("hr",ae.hr).replace("heading",` *#{1,6} *[^
|
|
]`).replace("lheading",ae.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var ue={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:pe,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:pe,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};ue._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",ue.punctuation=he(ue.punctuation).replace(/punctuation/g,ue._punctuation).getRegex(),ue._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",ue._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",ue.em.start=he(ue.em.start).replace(/punctuation/g,ue._punctuation).getRegex(),ue.em.middle=he(ue.em.middle).replace(/punctuation/g,ue._punctuation).replace(/overlapSkip/g,ue._overlapSkip).getRegex(),ue.em.endAst=he(ue.em.endAst,"g").replace(/punctuation/g,ue._punctuation).getRegex(),ue.em.endUnd=he(ue.em.endUnd,"g").replace(/punctuation/g,ue._punctuation).getRegex(),ue.strong.start=he(ue.strong.start).replace(/punctuation/g,ue._punctuation).getRegex(),ue.strong.middle=he(ue.strong.middle).replace(/punctuation/g,ue._punctuation).replace(/blockSkip/g,ue._blockSkip).getRegex(),ue.strong.endAst=he(ue.strong.endAst,"g").replace(/punctuation/g,ue._punctuation).getRegex(),ue.strong.endUnd=he(ue.strong.endUnd,"g").replace(/punctuation/g,ue._punctuation).getRegex(),ue.blockSkip=he(ue._blockSkip,"g").getRegex(),ue.overlapSkip=he(ue._overlapSkip,"g").getRegex(),ue._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,ue._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,ue._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])?)+(?![-_])/,ue.autolink=he(ue.autolink).replace("scheme",ue._scheme).replace("email",ue._email).getRegex(),ue._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,ue.tag=he(ue.tag).replace("comment",ae._comment).replace("attribute",ue._attribute).getRegex(),ue._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,ue._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,ue._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,ue.link=he(ue.link).replace("label",ue._label).replace("href",ue._href).replace("title",ue._title).getRegex(),ue.reflink=he(ue.reflink).replace("label",ue._label).getRegex(),ue.reflinkSearch=he(ue.reflinkSearch,"g").replace("reflink",ue.reflink).replace("nolink",ue.nolink).getRegex(),ue.normal=me({},ue),ue.pedantic=me({},ue.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:he(/^!?\[(label)\]\((.*?)\)/).replace("label",ue._label).getRegex(),reflink:he(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ue._label).getRegex()}),ue.gfm=me({},ue.normal,{escape:he(ue.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),ue.gfm.url=he(ue.gfm.url,"i").replace("email",ue.gfm._extended_email).getRegex(),ue.breaks=me({},ue.gfm,{br:he(ue.br).replace("{2,}","*").getRegex(),text:he(ue.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var xe={block:ae,inline:ue},Fe=U.defaults,Re=xe.block,Ie=xe.inline;function Ke(oe){return oe.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 De(oe){var ee="",re,V,$=oe.length;for(re=0;re<$;re++)V=oe.charCodeAt(re),Math.random()>.5&&(V="x"+V.toString(16)),ee+="&#"+V+";";return ee}var Ce=function(){function oe(re){this.tokens=[],this.tokens.links=Object.create(null),this.options=re||Fe,this.options.tokenizer=this.options.tokenizer||new ge,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var V={block:Re.normal,inline:Ie.normal};this.options.pedantic?(V.block=Re.pedantic,V.inline=Ie.pedantic):this.options.gfm&&(V.block=Re.gfm,this.options.breaks?V.inline=Ie.breaks:V.inline=Ie.gfm),this.tokenizer.rules=V}oe.lex=function(V,$){var J=new oe($);return J.lex(V)};var ee=oe.prototype;return ee.lex=function(V){return V=V.replace(/\r\n|\r/g,`
|
|
`).replace(/\t/g," "),this.blockTokens(V,this.tokens,!0),this.inline(this.tokens),this.tokens},ee.blockTokens=function(V,$,J){$===void 0&&($=[]),J===void 0&&(J=!0),V=V.replace(/^ +$/gm,"");for(var ne,le,ye,we;V;){if(ne=this.tokenizer.space(V)){V=V.substring(ne.raw.length),ne.type&&$.push(ne);continue}if(ne=this.tokenizer.code(V,$)){V=V.substring(ne.raw.length),ne.type?$.push(ne):(we=$[$.length-1],we.raw+=`
|
|
`+ne.raw,we.text+=`
|
|
`+ne.text);continue}if(ne=this.tokenizer.fences(V)){V=V.substring(ne.raw.length),$.push(ne);continue}if(ne=this.tokenizer.heading(V)){V=V.substring(ne.raw.length),$.push(ne);continue}if(ne=this.tokenizer.nptable(V)){V=V.substring(ne.raw.length),$.push(ne);continue}if(ne=this.tokenizer.hr(V)){V=V.substring(ne.raw.length),$.push(ne);continue}if(ne=this.tokenizer.blockquote(V)){V=V.substring(ne.raw.length),ne.tokens=this.blockTokens(ne.text,[],J),$.push(ne);continue}if(ne=this.tokenizer.list(V)){for(V=V.substring(ne.raw.length),ye=ne.items.length,le=0;le<ye;le++)ne.items[le].tokens=this.blockTokens(ne.items[le].text,[],!1);$.push(ne);continue}if(ne=this.tokenizer.html(V)){V=V.substring(ne.raw.length),$.push(ne);continue}if(J&&(ne=this.tokenizer.def(V))){V=V.substring(ne.raw.length),this.tokens.links[ne.tag]||(this.tokens.links[ne.tag]={href:ne.href,title:ne.title});continue}if(ne=this.tokenizer.table(V)){V=V.substring(ne.raw.length),$.push(ne);continue}if(ne=this.tokenizer.lheading(V)){V=V.substring(ne.raw.length),$.push(ne);continue}if(J&&(ne=this.tokenizer.paragraph(V))){V=V.substring(ne.raw.length),$.push(ne);continue}if(ne=this.tokenizer.text(V,$)){V=V.substring(ne.raw.length),ne.type?$.push(ne):(we=$[$.length-1],we.raw+=`
|
|
`+ne.raw,we.text+=`
|
|
`+ne.text);continue}if(V){var ze="Infinite loop on byte: "+V.charCodeAt(0);if(this.options.silent){console.error(ze);break}else throw new Error(ze)}}return $},ee.inline=function(V){var $,J,ne,le,ye,we,ze=V.length;for($=0;$<ze;$++){we=V[$];switch(we.type){case"paragraph":case"text":case"heading":{we.tokens=[],this.inlineTokens(we.text,we.tokens);break}case"table":{for(we.tokens={header:[],cells:[]},le=we.header.length,J=0;J<le;J++)we.tokens.header[J]=[],this.inlineTokens(we.header[J],we.tokens.header[J]);for(le=we.cells.length,J=0;J<le;J++)for(ye=we.cells[J],we.tokens.cells[J]=[],ne=0;ne<ye.length;ne++)we.tokens.cells[J][ne]=[],this.inlineTokens(ye[ne],we.tokens.cells[J][ne]);break}case"blockquote":{this.inline(we.tokens);break}case"list":{for(le=we.items.length,J=0;J<le;J++)this.inline(we.items[J].tokens);break}}}return V},ee.inlineTokens=function(V,$,J,ne,le){$===void 0&&($=[]),J===void 0&&(J=!1),ne===void 0&&(ne=!1),le===void 0&&(le="");var ye,we=V,ze;if(this.tokens.links){var it=Object.keys(this.tokens.links);if(it.length>0)for(;(ze=this.tokenizer.rules.inline.reflinkSearch.exec(we))!=null;)it.includes(ze[0].slice(ze[0].lastIndexOf("[")+1,-1))&&(we=we.slice(0,ze.index)+"["+"a".repeat(ze[0].length-2)+"]"+we.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(ze=this.tokenizer.rules.inline.blockSkip.exec(we))!=null;)we=we.slice(0,ze.index)+"["+"a".repeat(ze[0].length-2)+"]"+we.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;V;){if(ye=this.tokenizer.escape(V)){V=V.substring(ye.raw.length),$.push(ye);continue}if(ye=this.tokenizer.tag(V,J,ne)){V=V.substring(ye.raw.length),J=ye.inLink,ne=ye.inRawBlock,$.push(ye);continue}if(ye=this.tokenizer.link(V)){V=V.substring(ye.raw.length),ye.type==="link"&&(ye.tokens=this.inlineTokens(ye.text,[],!0,ne)),$.push(ye);continue}if(ye=this.tokenizer.reflink(V,this.tokens.links)){V=V.substring(ye.raw.length),ye.type==="link"&&(ye.tokens=this.inlineTokens(ye.text,[],!0,ne)),$.push(ye);continue}if(ye=this.tokenizer.strong(V,we,le)){V=V.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],J,ne),$.push(ye);continue}if(ye=this.tokenizer.em(V,we,le)){V=V.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],J,ne),$.push(ye);continue}if(ye=this.tokenizer.codespan(V)){V=V.substring(ye.raw.length),$.push(ye);continue}if(ye=this.tokenizer.br(V)){V=V.substring(ye.raw.length),$.push(ye);continue}if(ye=this.tokenizer.del(V)){V=V.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],J,ne),$.push(ye);continue}if(ye=this.tokenizer.autolink(V,De)){V=V.substring(ye.raw.length),$.push(ye);continue}if(!J&&(ye=this.tokenizer.url(V,De))){V=V.substring(ye.raw.length),$.push(ye);continue}if(ye=this.tokenizer.inlineText(V,ne,Ke)){V=V.substring(ye.raw.length),le=ye.raw.slice(-1),$.push(ye);continue}if(V){var tt="Infinite loop on byte: "+V.charCodeAt(0);if(this.options.silent){console.error(tt);break}else throw new Error(tt)}}return $},G(oe,null,[{key:"rules",get:function(){return{block:Re,inline:Ie}}}]),oe}(),Me=U.defaults,Be=X.cleanUrl,je=X.escape,_e=function(){function oe(re){this.options=re||Me}var ee=oe.prototype;return ee.code=function(V,$,J){var ne=($||"").match(/\S*/)[0];if(this.options.highlight){var le=this.options.highlight(V,ne);le!=null&&le!==V&&(J=!0,V=le)}return ne?'<pre><code class="'+this.options.langPrefix+je(ne,!0)+'">'+(J?V:je(V,!0))+`</code></pre>
|
|
`:"<pre><code>"+(J?V:je(V,!0))+`</code></pre>
|
|
`},ee.blockquote=function(V){return`<blockquote>
|
|
`+V+`</blockquote>
|
|
`},ee.html=function(V){return V},ee.heading=function(V,$,J,ne){return this.options.headerIds?"<h"+$+' id="'+this.options.headerPrefix+ne.slug(J)+'">'+V+"</h"+$+`>
|
|
`:"<h"+$+">"+V+"</h"+$+`>
|
|
`},ee.hr=function(){return this.options.xhtml?`<hr/>
|
|
`:`<hr>
|
|
`},ee.list=function(V,$,J){var ne=$?"ol":"ul",le=$&&J!==1?' start="'+J+'"':"";return"<"+ne+le+`>
|
|
`+V+"</"+ne+`>
|
|
`},ee.listitem=function(V){return"<li>"+V+`</li>
|
|
`},ee.checkbox=function(V){return"<input "+(V?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},ee.paragraph=function(V){return"<p>"+V+`</p>
|
|
`},ee.table=function(V,$){return $&&($="<tbody>"+$+"</tbody>"),`<table>
|
|
<thead>
|
|
`+V+`</thead>
|
|
`+$+`</table>
|
|
`},ee.tablerow=function(V){return`<tr>
|
|
`+V+`</tr>
|
|
`},ee.tablecell=function(V,$){var J=$.header?"th":"td",ne=$.align?"<"+J+' align="'+$.align+'">':"<"+J+">";return ne+V+"</"+J+`>
|
|
`},ee.strong=function(V){return"<strong>"+V+"</strong>"},ee.em=function(V){return"<em>"+V+"</em>"},ee.codespan=function(V){return"<code>"+V+"</code>"},ee.br=function(){return this.options.xhtml?"<br/>":"<br>"},ee.del=function(V){return"<del>"+V+"</del>"},ee.link=function(V,$,J){if(V=Be(this.options.sanitize,this.options.baseUrl,V),V===null)return J;var ne='<a href="'+je(V)+'"';return $&&(ne+=' title="'+$+'"'),ne+=">"+J+"</a>",ne},ee.image=function(V,$,J){if(V=Be(this.options.sanitize,this.options.baseUrl,V),V===null)return J;var ne='<img src="'+V+'" alt="'+J+'"';return $&&(ne+=' title="'+$+'"'),ne+=this.options.xhtml?"/>":">",ne},ee.text=function(V){return V},oe}(),Le=function(){function oe(){}var ee=oe.prototype;return ee.strong=function(V){return V},ee.em=function(V){return V},ee.codespan=function(V){return V},ee.del=function(V){return V},ee.html=function(V){return V},ee.text=function(V){return V},ee.link=function(V,$,J){return""+J},ee.image=function(V,$,J){return""+J},ee.br=function(){return""},oe}(),$e=function(){function oe(){this.seen={}}var ee=oe.prototype;return ee.slug=function(V){var $=V.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty($)){var J=$;do this.seen[J]++,$=J+"-"+this.seen[J];while(this.seen.hasOwnProperty($))}return this.seen[$]=0,$},oe}(),Je=U.defaults,We=X.unescape,He=function(){function oe(re){this.options=re||Je,this.options.renderer=this.options.renderer||new _e,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Le,this.slugger=new $e}oe.parse=function(V,$){var J=new oe($);return J.parse(V)};var ee=oe.prototype;return ee.parse=function(V,$){$===void 0&&($=!0);var J="",ne,le,ye,we,ze,it,tt,xt,ht,ot,Ct,yt,Bt,Ft,bt,Cr,Rr,lr,pr=V.length;for(ne=0;ne<pr;ne++){ot=V[ne];switch(ot.type){case"space":continue;case"hr":{J+=this.renderer.hr();continue}case"heading":{J+=this.renderer.heading(this.parseInline(ot.tokens),ot.depth,We(this.parseInline(ot.tokens,this.textRenderer)),this.slugger);continue}case"code":{J+=this.renderer.code(ot.text,ot.lang,ot.escaped);continue}case"table":{for(xt="",tt="",we=ot.header.length,le=0;le<we;le++)tt+=this.renderer.tablecell(this.parseInline(ot.tokens.header[le]),{header:!0,align:ot.align[le]});for(xt+=this.renderer.tablerow(tt),ht="",we=ot.cells.length,le=0;le<we;le++){for(it=ot.tokens.cells[le],tt="",ze=it.length,ye=0;ye<ze;ye++)tt+=this.renderer.tablecell(this.parseInline(it[ye]),{header:!1,align:ot.align[ye]});ht+=this.renderer.tablerow(tt)}J+=this.renderer.table(xt,ht);continue}case"blockquote":{ht=this.parse(ot.tokens),J+=this.renderer.blockquote(ht);continue}case"list":{for(Ct=ot.ordered,yt=ot.start,Bt=ot.loose,we=ot.items.length,ht="",le=0;le<we;le++)bt=ot.items[le],Cr=bt.checked,Rr=bt.task,Ft="",bt.task&&(lr=this.renderer.checkbox(Cr),Bt?bt.tokens.length>0&&bt.tokens[0].type==="text"?(bt.tokens[0].text=lr+" "+bt.tokens[0].text,bt.tokens[0].tokens&&bt.tokens[0].tokens.length>0&&bt.tokens[0].tokens[0].type==="text"&&(bt.tokens[0].tokens[0].text=lr+" "+bt.tokens[0].tokens[0].text)):bt.tokens.unshift({type:"text",text:lr}):Ft+=lr),Ft+=this.parse(bt.tokens,Bt),ht+=this.renderer.listitem(Ft,Rr,Cr);J+=this.renderer.list(ht,Ct,yt);continue}case"html":{J+=this.renderer.html(ot.text);continue}case"paragraph":{J+=this.renderer.paragraph(this.parseInline(ot.tokens));continue}case"text":{for(ht=ot.tokens?this.parseInline(ot.tokens):ot.text;ne+1<pr&&V[ne+1].type==="text";)ot=V[++ne],ht+=`
|
|
`+(ot.tokens?this.parseInline(ot.tokens):ot.text);J+=$?this.renderer.paragraph(ht):ht;continue}default:{var fr='Token with "'+ot.type+'" type was not found.';if(this.options.silent){console.error(fr);return}else throw new Error(fr)}}}return J},ee.parseInline=function(V,$){$=$||this.renderer;var J="",ne,le,ye=V.length;for(ne=0;ne<ye;ne++){le=V[ne];switch(le.type){case"escape":{J+=$.text(le.text);break}case"html":{J+=$.html(le.text);break}case"link":{J+=$.link(le.href,le.title,this.parseInline(le.tokens,$));break}case"image":{J+=$.image(le.href,le.title,le.text);break}case"strong":{J+=$.strong(this.parseInline(le.tokens,$));break}case"em":{J+=$.em(this.parseInline(le.tokens,$));break}case"codespan":{J+=$.codespan(le.text);break}case"br":{J+=$.br();break}case"del":{J+=$.del(this.parseInline(le.tokens,$));break}case"text":{J+=$.text(le.text);break}default:{var we='Token with "'+le.type+'" type was not found.';if(this.options.silent){console.error(we);return}else throw new Error(we)}}}return J},oe}(),et=X.merge,Ye=X.checkSanitizeDeprecation,Ve=X.escape,be=U.getDefaults,Ze=U.changeDefaults,Ge=U.defaults;function ve(oe,ee,re){if(typeof oe=="undefined"||oe===null)throw new Error("marked(): input parameter is undefined or null");if(typeof oe!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(oe)+", string expected");if(typeof ee=="function"&&(re=ee,ee=null),ee=et({},ve.defaults,ee||{}),Ye(ee),re){var V=ee.highlight,$;try{$=Ce.lex(oe,ee)}catch(ye){return re(ye)}var J=function(we){var ze;if(!we)try{ze=He.parse($,ee)}catch(it){we=it}return ee.highlight=V,we?re(we):re(null,ze)};if(!V||V.length<3)return J();if(delete ee.highlight,!$.length)return J();var ne=0;ve.walkTokens($,function(ye){ye.type==="code"&&(ne++,setTimeout(function(){V(ye.text,ye.lang,function(we,ze){if(we)return J(we);ze!=null&&ze!==ye.text&&(ye.text=ze,ye.escaped=!0),ne--,ne===0&&J()})},0))}),ne===0&&J();return}try{var le=Ce.lex(oe,ee);return ee.walkTokens&&ve.walkTokens(le,ee.walkTokens),He.parse(le,ee)}catch(ye){if(ye.message+=`
|
|
Please report this to https://github.com/markedjs/marked.`,ee.silent)return"<p>An error occurred:</p><pre>"+Ve(ye.message+"",!0)+"</pre>";throw ye}}ve.options=ve.setOptions=function(oe){return et(ve.defaults,oe),Ze(ve.defaults),ve},ve.getDefaults=be,ve.defaults=Ge,ve.use=function(oe){var ee=et({},oe);if(oe.renderer&&function(){var V=ve.defaults.renderer||new _e,$=function(le){var ye=V[le];V[le]=function(){for(var we=arguments.length,ze=new Array(we),it=0;it<we;it++)ze[it]=arguments[it];var tt=oe.renderer[le].apply(V,ze);return tt===!1&&(tt=ye.apply(V,ze)),tt}};for(var J in oe.renderer)$(J);ee.renderer=V}(),oe.tokenizer&&function(){var V=ve.defaults.tokenizer||new ge,$=function(le){var ye=V[le];V[le]=function(){for(var we=arguments.length,ze=new Array(we),it=0;it<we;it++)ze[it]=arguments[it];var tt=oe.tokenizer[le].apply(V,ze);return tt===!1&&(tt=ye.apply(V,ze)),tt}};for(var J in oe.tokenizer)$(J);ee.tokenizer=V}(),oe.walkTokens){var re=ve.defaults.walkTokens;ee.walkTokens=function(V){oe.walkTokens(V),re&&re(V)}}ve.setOptions(ee)},ve.walkTokens=function(oe,ee){for(var re=k(oe),V;!(V=re()).done;){var $=V.value;ee($);switch($.type){case"table":{for(var J=k($.tokens.header),ne;!(ne=J()).done;){var le=ne.value;ve.walkTokens(le,ee)}for(var ye=k($.tokens.cells),we;!(we=ye()).done;)for(var ze=we.value,it=k(ze),tt;!(tt=it()).done;){var xt=tt.value;ve.walkTokens(xt,ee)}break}case"list":{ve.walkTokens($.items,ee);break}default:$.tokens&&ve.walkTokens($.tokens,ee)}}},ve.Parser=He,ve.parser=He.parse,ve.Renderer=_e,ve.TextRenderer=Le,ve.Lexer=Ce,ve.lexer=Ce.lex,ve.Tokenizer=ge,ve.Slugger=$e,ve.parse=ve;var Ee=ve;return Ee})},ELLl:function(ut,Qe,q){(function(Q){Q(q("VrN/"))})(function(Q){var G={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},A=Q.Pos;Q.defineOption("autoCloseBrackets",!1,function(T,E,l){l&&l!=Q.Init&&(T.removeKeyMap(k),T.state.closeBrackets=null),E&&(O(W(E,"pairs")),T.state.closeBrackets=E,T.addKeyMap(k))});function W(T,E){return E=="pairs"&&typeof T=="string"?T:typeof T=="object"&&T[E]!=null?T[E]:G[E]}var k={Backspace:R,Enter:_};function O(T){for(var E=0;E<T.length;E++){var l=T.charAt(E),o="'"+l+"'";k[o]||(k[o]=U(l))}}O(G.pairs+"`");function U(T){return function(E){return S(E,T)}}function F(T){var E=T.state.closeBrackets;if(!E||E.override)return E;var l=T.getModeAt(T.getCursor());return l.closeBrackets||E}function R(T){var E=F(T);if(!E||T.getOption("disableInput"))return Q.Pass;for(var l=W(E,"pairs"),o=T.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return Q.Pass;var u=D(T,o[s].head);if(!u||l.indexOf(u)%2!=0)return Q.Pass}for(var s=o.length-1;s>=0;s--){var w=o[s].head;T.replaceRange("",A(w.line,w.ch-1),A(w.line,w.ch+1),"+delete")}}function _(T){var E=F(T),l=E&&W(E,"explode");if(!l||T.getOption("disableInput"))return Q.Pass;for(var o=T.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return Q.Pass;var u=D(T,o[s].head);if(!u||l.indexOf(u)%2!=0)return Q.Pass}T.operation(function(){var w=T.lineSeparator()||`
|
|
`;T.replaceSelection(w+w,null),T.execCommand("goCharLeft"),o=T.listSelections();for(var m=0;m<o.length;m++){var h=o[m].head.line;T.indentLine(h,null,!0),T.indentLine(h+1,null,!0)}})}function v(T){var E=Q.cmpPos(T.anchor,T.head)>0;return{anchor:new A(T.anchor.line,T.anchor.ch+(E?-1:1)),head:new A(T.head.line,T.head.ch+(E?1:-1))}}function S(T,E){var l=F(T);if(!l||T.getOption("disableInput"))return Q.Pass;var o=W(l,"pairs"),s=o.indexOf(E);if(s==-1)return Q.Pass;for(var u=W(l,"closeBefore"),w=W(l,"triples"),m=o.charAt(s+1)==E,h=T.listSelections(),L=s%2==0,p,c=0;c<h.length;c++){var f=h[c],d=f.head,a,b=T.getRange(d,A(d.line,d.ch+1));if(L&&!f.empty())a="surround";else if((m||!L)&&b==E)m&&C(T,d)?a="both":w.indexOf(E)>=0&&T.getRange(d,A(d.line,d.ch+3))==E+E+E?a="skipThree":a="skip";else if(m&&d.ch>1&&w.indexOf(E)>=0&&T.getRange(A(d.line,d.ch-2),d)==E+E){if(d.ch>2&&/\bstring/.test(T.getTokenTypeAt(A(d.line,d.ch-2))))return Q.Pass;a="addFour"}else if(m){var g=d.ch==0?" ":T.getRange(A(d.line,d.ch-1),d);if(!Q.isWordChar(b)&&g!=E&&!Q.isWordChar(g))a="both";else return Q.Pass}else if(L&&(b.length===0||/\s/.test(b)||u.indexOf(b)>-1))a="both";else return Q.Pass;if(!p)p=a;else if(p!=a)return Q.Pass}var x=s%2?o.charAt(s-1):E,P=s%2?E:o.charAt(s+1);T.operation(function(){if(p=="skip")T.execCommand("goCharRight");else if(p=="skipThree")for(var N=0;N<3;N++)T.execCommand("goCharRight");else if(p=="surround"){for(var H=T.getSelections(),N=0;N<H.length;N++)H[N]=x+H[N]+P;T.replaceSelections(H,"around"),H=T.listSelections().slice();for(var N=0;N<H.length;N++)H[N]=v(H[N]);T.setSelections(H)}else p=="both"?(T.replaceSelection(x+P,null),T.triggerElectric(x+P),T.execCommand("goCharLeft")):p=="addFour"&&(T.replaceSelection(x+x+x+x,"before"),T.execCommand("goCharRight"))})}function D(T,E){var l=T.getRange(A(E.line,E.ch-1),A(E.line,E.ch+1));return l.length==2?l:null}function C(T,E){var l=T.getTokenAt(A(E.line,E.ch+1));return/\bstring/.test(l.type)&&l.start==E.ch&&(E.ch==0||!/\bstring/.test(T.getTokenTypeAt(E)))}})},F8wB:function(ut,Qe,q){ut.exports={loading:"loading___1SIOG"}},Gytx:function(ut,Qe){ut.exports=function(Q,G,A,W){var k=A?A.call(W,Q,G):void 0;if(k!==void 0)return!!k;if(Q===G)return!0;if(typeof Q!="object"||!Q||typeof G!="object"||!G)return!1;var O=Object.keys(Q),U=Object.keys(G);if(O.length!==U.length)return!1;for(var F=Object.prototype.hasOwnProperty.bind(G),R=0;R<O.length;R++){var _=O[R];if(!F(_))return!1;var v=Q[_],S=G[_];if(k=A?A.call(W,v,S,_):void 0,k===!1||k===void 0&&v!==S)return!1}return!0}},HmJG:function(ut,Qe,q){},LdHM:function(ut,Qe,q){"use strict";q.d(Qe,"b",function(){return u}),q.d(Qe,"a",function(){return m});var Q=q("1OyB"),G=q("vuIU"),A=q("Ji7U"),W=q("LK+K"),k=q("cDcd"),O=q("rePB"),U=q("Ff2n"),F=q("ODXe"),R=q("4IlW"),_=q("bX4T"),v=q("YrtM"),S=q("TSYQ"),D=q.n(S),C=q("+nKL"),T=q("8OUc"),E=function(Y,te){var se=Y.prefixCls,de=Y.id,Se=Y.flattenOptions,ge=Y.childrenAsData,pe=Y.values,he=Y.searchValue,me=Y.multiple,ae=Y.defaultActiveFirstOption,ue=Y.height,xe=Y.itemHeight,Fe=Y.notFoundContent,Re=Y.open,Ie=Y.menuItemSelectedIcon,Ke=Y.virtual,De=Y.onSelect,Ce=Y.onToggleOpen,Me=Y.onActiveValue,Be=Y.onScroll,je=Y.onMouseEnter,_e="".concat(se,"-item"),Le=Object(v.a)(function(){return Se},[Re,Se],function(Ee,oe){return oe[0]&&Ee[1]!==oe[1]}),$e=k.useRef(null),Je=function(oe){oe.preventDefault()},We=function(oe){$e.current&&$e.current.scrollTo({index:oe})},He=function(oe){for(var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,re=Le.length,V=0;V<re;V+=1){var $=(oe+V*ee+re)%re,J=Le[$],ne=J.group,le=J.data;if(!ne&&!le.disabled)return $}return-1},et=k.useState(function(){return He(0)}),Ye=Object(F.a)(et,2),Ve=Ye[0],be=Ye[1],Ze=function(oe){be(oe);var ee=Le[oe];if(!ee){Me(null,-1);return}Me(ee.data.value,oe)};k.useEffect(function(){Ze(ae!==!1?He(0):-1)},[Le.length,he]),k.useEffect(function(){var Ee=setTimeout(function(){if(!me&&Re&&pe.size===1){var oe=Array.from(pe)[0],ee=Le.findIndex(function(re){var V=re.data;return V.value===oe});Ze(ee),We(ee)}});return function(){return clearTimeout(Ee)}},[Re]);var Ge=function(oe){oe!==void 0&&De(oe,{selected:!pe.has(oe)}),me||Ce(!1)};if(k.useImperativeHandle(te,function(){return{onKeyDown:function(oe){var ee=oe.which;switch(ee){case R.a.UP:case R.a.DOWN:{var re=0;if(ee===R.a.UP?re=-1:ee===R.a.DOWN&&(re=1),re!==0){var V=He(Ve+re,re);We(V),Ze(V)}break}case R.a.ENTER:{var $=Le[Ve];$&&!$.data.disabled?Ge($.data.value):Ge(void 0),Re&&oe.preventDefault();break}case R.a.ESC:Ce(!1)}},onKeyUp:function(){},scrollTo:function(oe){We(oe)}}}),Le.length===0)return k.createElement("div",{role:"listbox",id:"".concat(de,"_list"),className:"".concat(_e,"-empty"),onMouseDown:Je},Fe);function ve(Ee){var oe=Le[Ee];if(!oe)return null;var ee=oe.data||{},re=ee.value,V=ee.label,$=ee.children,J=Object(_.a)(ee,!0),ne=ge?$:V;return oe?k.createElement("div",Object.assign({"aria-label":typeof ne=="string"?ne:null},J,{key:Ee,role:"option",id:"".concat(de,"_list_").concat(Ee),"aria-selected":pe.has(re)}),re):null}return k.createElement(k.Fragment,null,k.createElement("div",{role:"listbox",id:"".concat(de,"_list"),style:{height:0,width:0,overflow:"hidden"}},ve(Ve-1),ve(Ve),ve(Ve+1)),k.createElement(C.a,{itemKey:"key",ref:$e,data:Le,height:ue,itemHeight:xe,fullHeight:!1,onMouseDown:Je,onScroll:Be,virtual:Ke,onMouseEnter:je},function(Ee,oe){var ee,re=Ee.group,V=Ee.groupOption,$=Ee.data,J=$.label,ne=$.key;if(re)return k.createElement("div",{className:D()(_e,"".concat(_e,"-group"))},J!==void 0?J:ne);var le=$.disabled,ye=$.value,we=$.title,ze=$.children,it=$.style,tt=$.className,xt=Object(U.a)($,["disabled","value","title","children","style","className"]),ht=pe.has(ye),ot="".concat(_e,"-option"),Ct=D()(_e,ot,tt,(ee={},Object(O.a)(ee,"".concat(ot,"-grouped"),V),Object(O.a)(ee,"".concat(ot,"-active"),Ve===oe&&!le),Object(O.a)(ee,"".concat(ot,"-disabled"),le),Object(O.a)(ee,"".concat(ot,"-selected"),ht),ee)),yt=ge?ze:J,Bt=!Ie||typeof Ie=="function"||ht;return k.createElement("div",Object.assign({},xt,{"aria-selected":ht,className:Ct,title:we,onMouseMove:function(){if(Ve===oe||le)return;Ze(oe)},onClick:function(){le||Ge(ye)},style:it}),k.createElement("div",{className:"".concat(ot,"-content")},yt||ye),k.isValidElement(Ie)||ht,Bt&&k.createElement(T.a,{className:"".concat(_e,"-option-state"),customizeIcon:Ie,customizeIconProps:{isSelected:ht}},ht?"\u2713":null))}))},l=k.forwardRef(E);l.displayName="OptionList";var o=l,s=function(){return null};s.isSelectOption=!0;var u=s,w=function(){return null};w.isSelectOptGroup=!0;var m=w,h=q("VTBJ"),L=q("Zm9Q");function p(I){var Y=I.key,te=I.props,se=te.children,de=te.value,Se=Object(U.a)(te,["children","value"]);return Object(h.a)({key:Y,value:de!==void 0?de:Y,children:se},Se)}function c(I){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(L.a)(I).map(function(te,se){if(!k.isValidElement(te)||!te.type)return null;var de=te.type.isSelectOptGroup,Se=te.key,ge=te.props,pe=ge.children,he=Object(U.a)(ge,["children"]);return Y||!de?p(te):Object(h.a)(Object(h.a)({key:"__RC_SELECT_GRP__".concat(Se===null?se:Se,"__"),label:Se},he),{},{options:c(pe)})}).filter(function(te){return te})}var f=q("2Qr1"),d=q("qNPg"),a=q("U8pU"),b=q("Kwbf"),g=q("WKfj");function x(I){var Y=I.mode,te=I.options,se=I.children,de=I.backfill,Se=I.allowClear,ge=I.placeholder,pe=I.getInputElement,he=I.showSearch,me=I.onSearch,ae=I.defaultOpen,ue=I.autoFocus,xe=I.labelInValue,Fe=I.value,Re=I.inputValue,Ie=I.optionLabelProp,Ke=Y==="multiple"||Y==="tags",De=he!==void 0?he:Ke||Y==="combobox",Ce=te||c(se);if(Object(b.a)(Y!=="tags"||Ce.every(function(_e){return!_e.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),Y==="tags"||Y==="combobox"){var Me=Ce.some(function(_e){return _e.options?_e.options.some(function(Le){return typeof("value"in Le?Le.value:Le.key)=="number"}):typeof("value"in _e?_e.value:_e.key)=="number"});Object(b.a)(!Me,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(b.a)(Y!=="combobox"||!Ie,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(b.a)(Y==="combobox"||!de,"`backfill` only works with `combobox` mode."),Object(b.a)(Y==="combobox"||!pe,"`getInputElement` only work with `combobox` mode."),Object(b.b)(Y!=="combobox"||!pe||!Se||!ge,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),me&&!De&&Y!=="combobox"&&Y!=="tags"&&Object(b.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(b.b)(!ae||ue,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),Fe!=null){var Be=Object(g.d)(Fe);Object(b.a)(!xe||Be.every(function(_e){return Object(a.a)(_e)==="object"&&("key"in _e||"value"in _e)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(b.a)(!Ke||Array.isArray(Fe),"`value` should be array when `mode` is `multiple` or `tags`")}if(se){var je=null;Object(L.a)(se).some(function(_e){if(!k.isValidElement(_e)||!_e.type)return!1;var Le=_e.type;if(Le.isSelectOption)return!1;if(Le.isSelectOptGroup){var $e=Object(L.a)(_e.props.children).every(function(Je){return!k.isValidElement(Je)||!_e.type||Je.type.isSelectOption?!0:(je=Je.type,!1)});return!$e}return je=Le,!0}),je&&Object(b.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(je.displayName||je.name||je,"`.")),Object(b.a)(Re===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var P=x,N=Object(d.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:c,flattenOptions:f.d,getLabeledValue:f.e,filterOptions:f.b,isValueDisabled:f.g,findValueOption:f.c,warningProps:P,fillOptionsWithMissingValue:f.a}),H=function(I){Object(A.a)(te,I);var Y=Object(W.a)(te);function te(){var se;return Object(Q.a)(this,te),se=Y.apply(this,arguments),se.selectRef=k.createRef(),se.focus=function(){se.selectRef.current.focus()},se.blur=function(){se.selectRef.current.blur()},se}return Object(G.a)(te,[{key:"render",value:function(){return k.createElement(N,Object.assign({ref:this.selectRef},this.props))}}]),te}(k.Component);H.Option=u,H.OptGroup=m;var X=H,B=Qe.c=X},M8RZ:function(ut,Qe,q){"use strict";q.d(Qe,"a",function(){return R});var Q=q("fWQN"),G=q("mtLc"),A=q("yKVA"),W=q("879j"),k=q("cDcd"),O=q.n(k),U=q("faye"),F=q.n(U),R=function(_){Object(A.a)(S,_);var v=Object(W.a)(S);function S(D){var C;Object(Q.a)(this,S),C=v.call(this,D);var T=window.document;return C.node=T.createElement("div"),T.body.appendChild(C.node),C}return Object(G.a)(S,[{key:"render",value:function(){var C=this.props.children;return Object(U.createPortal)(C,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),S}(O.a.Component)},OLES:function(ut,Qe,q){"use strict";var Q=q("U8pU"),G=q("VTBJ"),A=q("Ff2n"),W=q("cDcd"),k=q("uciX"),O=q("7ixt"),U=function(D){var C=D.overlay,T=D.prefixCls,E=D.id,l=D.overlayInnerStyle;return W.createElement("div",{className:"".concat(T,"-inner"),id:E,role:"tooltip",style:l},typeof C=="function"?C():C)},F=U,R=function(D,C){var T=D.overlayClassName,E=D.trigger,l=E===void 0?["hover"]:E,o=D.mouseEnterDelay,s=o===void 0?0:o,u=D.mouseLeaveDelay,w=u===void 0?.1:u,m=D.overlayStyle,h=D.prefixCls,L=h===void 0?"rc-tooltip":h,p=D.children,c=D.onVisibleChange,f=D.afterVisibleChange,d=D.transitionName,a=D.animation,b=D.placement,g=b===void 0?"right":b,x=D.align,P=x===void 0?{}:x,N=D.destroyTooltipOnHide,H=N===void 0?!1:N,X=D.defaultVisible,B=D.getTooltipContainer,I=D.overlayInnerStyle,Y=Object(A.a)(D,["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle"]),te=Object(W.useRef)(null);Object(W.useImperativeHandle)(C,function(){return te.current});var se=Object(G.a)({},Y);"visible"in D&&(se.popupVisible=D.visible);var de=function(){var me=D.arrowContent,ae=me===void 0?null:me,ue=D.overlay,xe=D.id;return[W.createElement("div",{className:"".concat(L,"-arrow"),key:"arrow"},ae),W.createElement(F,{key:"content",prefixCls:L,id:xe,overlay:ue,overlayInnerStyle:I})]},Se=!1,ge=!1;if(typeof H=="boolean")Se=H;else if(H&&Object(Q.a)(H)==="object"){var pe=H.keepParent;Se=pe===!0,ge=pe===!1}return W.createElement(k.a,Object.assign({popupClassName:T,prefixCls:L,popup:de,action:l,builtinPlacements:O.a,popupPlacement:g,ref:te,popupAlign:P,getPopupContainer:B,onPopupVisibleChange:c,afterPopupVisibleChange:f,popupTransitionName:d,popupAnimation:a,defaultPopupVisible:X,destroyPopupOnHide:Se,autoDestroy:ge,mouseLeaveDelay:w,popupStyle:m,mouseEnterDelay:s},se),p)},_=Object(W.forwardRef)(R),v=Qe.a=_},Ot1p:function(ut,Qe,q){"use strict";var Q=q("2qtc"),G=q("kLXV"),A=q("rAM+"),W=q("miYZ"),k=q("tsqr"),O=q("9og8"),U=q("tJVT"),F=q("jrin"),R=q("WmNS"),_=q.n(R),v=q("cDcd"),S=q.n(v),D=q("VrN/"),C=q.n(D),T=q("bdgK"),E=q("p77/"),l=q("Bd2K"),o=q("ELLl"),s=q("19Vz"),u=q("lZu9"),w=q("+NIl"),m=q("kSUc"),h=q("9Bee"),L=function(le){var ye=le.value,we=ye===void 0?"":ye,ze=le.className,it=le.showTextOnly,tt=le.showLines,xt=le.style,ht=xt===void 0?{}:xt,ot=Object(v.useMemo)(function(){return""},[we]);return S.a.createElement(S.a.Fragment,null,S.a.createElement("div",{dangerouslySetInnerHTML:{__html:ot}}))},p=q("0Owb"),c=q("dejd"),f=q("C+DQ"),d=q("1vsH"),a=q("m3rI"),b=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function g(le){var ye=le.onActionCallback,we=le.title,ze=le.icon,it=le.actionName,tt=le.className,xt=tt===void 0?"":tt,ht=le.children;function ot(){ye(it)}return S.a.createElement("a",{title:we,className:xt,onClick:ot},S.a.createElement("i",{className:"md-iconfont ".concat(ze)}),ht)}var x=function(le){var ye=le.watch,we=le.showNullButton,ze=le.onActionCallback,it=le.fullScreen,tt=le.insertTemp,xt=le.hidetoolBar,ht=le.uuid,ot=le.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(d.G)("_educoder_session_login"),"&_educoder_session=").concat(Object(d.G)("_educoder_session"),"&key=").concat(ht,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var Ct=[].concat(b,[{title:"".concat(ye?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(ye?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return S.a.createElement("ul",{className:"markdown-toolbar-container"},!xt&&Ct.map(function(yt,Bt){return S.a.createElement("li",{key:Bt},yt.actionName?S.a.createElement(g,Object(p.a)({},yt,{onActionCallback:ze})):S.a.createElement("span",{className:"v-line"}))}),we?S.a.createElement("li",null,S.a.createElement(g,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:ze},S.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,tt&&S.a.createElement("li",null,S.a.createElement(g,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(tt),onActionCallback:ze},S.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),S.a.createElement("li",{className:"btn-full-screen"},S.a.createElement(g,{icon:"".concat(it?"icon-shrink":"icon-enlarge"),title:it?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:ze})))},P=q("M8RZ"),N=q("+L6B"),H=q("2/Rp"),X=q("y8nQ"),B=q("Vl3Y"),I=q("5NDa"),Y=q("5rEg"),te={labelCol:{span:4},wrapperCol:{span:20}},se=function(le){var ye=le.callback,we=le.onCancel;function ze(it){ye(it)}return S.a.createElement(B.a,Object(p.a)({},te,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:ze}),S.a.createElement(B.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},S.a.createElement(Y.a,null)),S.a.createElement(B.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},S.a.createElement(Y.a,null)),S.a.createElement("div",{className:"flex-container flex-end"},S.a.createElement(H.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),S.a.createElement(H.a,{type:"ghost",onClick:we},"\u53D6\u6D88")))},de=q("7ahc"),Se=q("HmJG"),ge=q("BjJ7"),pe=B.a.useForm,he={width:280,marginRight:10},me={labelCol:{span:5},wrapperCol:{span:19}},ae=function(le){var ye=le.callback,we=le.onCancel,ze=pe(),it=Object(U.a)(ze,1),tt=it[0];function xt(Ct){ye(Ct)}function ht(Ct,yt){if(Ct.status===-1){k.b.error(Ct.message);return}tt.setFieldsValue({src:"/api/attachments/".concat(Ct.id),type:yt.type})}function ot(Ct){var yt=Ct.target.files[0];xe(yt,ht)}return S.a.createElement(B.a,Object(p.a)({form:tt},me,{className:"upload-image-panel",onFinish:xt}),S.a.createElement(B.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},S.a.createElement("div",{className:"flex-container"},S.a.createElement(B.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},S.a.createElement(Y.a,{style:he})),S.a.createElement(ue,{onFileChange:ot}))),S.a.createElement(B.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},S.a.createElement(Y.a,{style:{width:264}})),S.a.createElement(B.a.Item,{style:{textAlign:"right"}},S.a.createElement(H.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),S.a.createElement(H.a,{type:"ghost",onClick:we},"\u53D6\u6D88")))};function ue(le){var ye=le.onFileChange;return S.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",S.a.createElement("input",{type:"file",onChange:ye}))}function xe(le,ye){if(!le)throw new String("\u6CA1\u6709\u6587\u4EF6");var we=new FormData;we.append("editormd-image-file",le),we.append("file_param_name","editormd-image-file"),we.append("byxhr","true");var ze=new window.XMLHttpRequest;ze.withCredentials=!0,ze.addEventListener("load",function(it){ye(JSON.parse(it.target.responseText),le)},!1),ze.addEventListener("error",function(it){console.error(it)},!1),ze.open("POST","".concat(ge.a,"/api/attachments.json")),ze.send(we)}var Fe=q("giR+"),Re=q("fyUT"),Ie=q("7Kak"),Ke=q("9yH6"),De=Ke.a.Group,Ce={margin:"0 8px"},Me=function(le){var ye=le.callback,we=le.onCancel;function ze(it){ye(it)}return S.a.createElement(B.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:ze},S.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},S.a.createElement("span",{style:Ce},"\u5355\u5143\u683C\u6570\uFF1A"),S.a.createElement("span",{style:Ce},"\u884C\u6570"),S.a.createElement(B.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},S.a.createElement(Re.a,null)),S.a.createElement("span",{style:Ce},"\u5217\u6570"),S.a.createElement(B.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},S.a.createElement(Re.a,null))),S.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},S.a.createElement("span",{style:Ce},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),S.a.createElement(B.a.Item,{name:"align"},S.a.createElement(De,null,S.a.createElement(Ke.a,{value:"default"},S.a.createElement("i",{className:"fa fa-align-justify"})),S.a.createElement(Ke.a,{value:"left"},S.a.createElement("i",{className:"fa fa-align-left"})),S.a.createElement(Ke.a,{value:"center"},S.a.createElement("i",{className:"fa fa-align-center"})),S.a.createElement(Ke.a,{value:"right"},S.a.createElement("i",{className:"fa fa-align-right"}))))),S.a.createElement("div",{className:"flex-container flex-end"},S.a.createElement(H.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),S.a.createElement(H.a,{type:"ghost",onClick:we},"\u53D6\u6D88")))},Be=q("ErOA"),je=q("7Cbv"),_e="link",Le="upload-image",$e="code-block",Je="add-table",We="------------",He={default:We,left:":".concat(We),center:":".concat(We,":"),right:"".concat(We,":")},et=q("9VGf"),Ye,Ve;function be(){}var Ze=0,Ge=1e4,ve="\u2581",Ee=`
|
|
**\u6A21\u677F\u6807\u9898**
|
|
\u6A21\u677F\u6B63\u6587\u5185\u5BB9\uFF0C\u53EF\u8F93\u5165\u6587\u672C\u5185\u5BB9\u548C\u7C98\u8D34\u56FE\u7247\u7B49\u64CD\u4F5C`;function oe(le){return/^\d+$/.test(le)?"".concat(le,"px"):le}var ee=navigator.platform.toUpperCase().indexOf("MAC")>=0,re=ee?"Cmd":"Ctrl",V=["pptm","pptx","ppt","pot","pps","ppa","potx","ppsx","ppam","pptm","potm","ppsm","doc","docx","dot","dotx","docm","dotm","xls","xlsx","csv","xlt","xla","xltx","xlsm","xltm","xlam","xlsb"],$=(Ye={},Object(F.a)(Ye,re+"-B","bold"),Object(F.a)(Ye,re+"-I","italic"),Ye),J=(Ve={},Object(F.a)(Ve,_e,"\u6DFB\u52A0\u94FE\u63A5"),Object(F.a)(Ve,$e,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(F.a)(Ve,Le,"\u6DFB\u52A0\u6587\u4EF6"),Object(F.a)(Ve,Je,"\u6DFB\u52A0\u8868\u683C"),Ve),ne=Qe.a=function(le){var ye=le.defaultValue,we=ye===void 0?"":ye,ze=le.onChange,it=le.width,tt=it===void 0?"100%":it,xt=le.height,ht=xt===void 0?400:xt,ot=le.miniToolbar,Ct=ot===void 0?!1:ot,yt=le.isFocus,Bt=yt===void 0?!1:yt,Ft=le.watch,bt=le.insertTemp,Cr=le.mode,Rr=Cr===void 0?"markdown":Cr,lr=le.id,pr=lr===void 0?"markdown-editor-id":lr,fr=le.showResizeBar,ia=fr===void 0?!1:fr,Lr=le.noStorage,Hn=Lr===void 0?!1:Lr,Kn=le.showNullButton,Rt=Kn===void 0?!1:Kn,rt=le.hidetoolBar,Pr=rt===void 0?!1:rt,mn=le.fullScreen,Zt=mn===void 0?!1:mn,Tt=le.onBlur,gr=le.onCMBeforeChange,kr=le.onFullScreen,pn=le.className,Oe=pn===void 0?"":pn,dt=le.disablePaste,Gn=dt===void 0?!1:dt,gn=le.placeholder,vn=gn===void 0?"":gn,Qr=le.values,yn=Qr===void 0?"":Qr,ft=Object(v.useState)(null),Li=Object(U.a)(ft,2),Pe=Li[0],bn=Li[1],hr=Object(v.useState)(we),zn=Object(U.a)(hr,2),Zr=zn[0],vr=zn[1],Vn=Object(v.useState)(Ft),Xn=Object(U.a)(Vn,2),yr=Xn[0],Yn=Xn[1],Ai=Object(v.useState)(Zt),$n=Object(U.a)(Ai,2),br=$n[0],Di=$n[1],aa=Object(v.useState)(""),Jn=Object(U.a)(aa,2),$t=Jn[0],Wr=Jn[1],oa=Object(v.useState)(0),qr=Object(U.a)(oa,2),Er=qr[0],Qn=qr[1],sa=Object(v.useState)(ht),_i=Object(U.a)(sa,2),Oi=_i[0],En=_i[1],Ri=Object(v.useState)(!1),Pi=Object(U.a)(Ri,2),la=Pi[0],xn=Pi[1],en=Object(v.useRef)(Object(je.a)()),tn=Object(v.useRef)(!1),Tn=Object(v.useRef)(),Mr=Object(v.useRef)(),Ir=Object(v.useRef)(),Fr=Object(v.useRef)(),Sn=Object(v.useRef)(),ki=function(){var nt=Object(O.a)(_.a.mark(function ct(){var st,pt;return _.a.wrap(function(At){for(;;)switch(At.prev=At.next){case 0:return At.next=2,Object(Be.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:en.current}});case 2:pt=At.sent,pt!=null&&(st=pt.attachments)!==null&&st!==void 0&&st.length&&(console.log("cm:",Pe,Mr),pt.attachments.map(function(vt){vt.content_type.indexOf("image")>-1?Pe.replaceSelection(".concat(vt.content_type,")")):vt.content_type.indexOf("video")>-1?Pe.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):vt.content_type.indexOf("pdf")>-1?Pe.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(vt.id,"?type=").concat(vt.content_type,'&disposition=inline" target="_blank">').concat(vt.name,"</a>")):Pe.replaceSelection("[".concat(vt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(vt.id,"?type=").concat(vt.content_type,")"))}));case 4:case"end":return At.stop()}},ct)}));return function(){return nt.apply(this,arguments)}}();Object(v.useEffect)(function(){vr(yn),Pe==null||Pe.setValue(yn)},[yn]),Object(v.useEffect)(function(){kr==null||kr(br)},[br]),Object(v.useEffect)(function(){if(Mr.current){var nt=C.a.fromTextArea(Mr.current,{mode:Rr,lineNumbers:!Ct,lineWrapping:!0,value:we,autoCloseTags:!0,autoCloseBrackets:!0});Bt&&nt.focus();function ct(st,pt){if(Gn){pt.preventDefault();return}var Et=pt.clipboardData;if(Et){var At=Et.types.toString(),vt=Et.items;if(At==="Files"||Et.types.indexOf("Files")>-1){if(pt.preventDefault(),Rr=="stex")return;try{var Ut,qt=vt[1];((Ut=vt[0])===null||Ut===void 0?void 0:Ut.kind)==="file"&&(qt=vt[0]);var gt=qt.getAsFile(),Ur=gt.name.split(".").pop();xe(gt,function(St){if(St.id){var er,Vt,mr;(gt==null||((er=gt.type)===null||er===void 0)?void 0:er.indexOf("image"))>-1?nt.replaceSelection(".concat(St.content_type,")")):(gt==null||((Vt=gt.type)===null||Vt===void 0)?void 0:Vt.indexOf("video"))>-1?nt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,'"></video>')):(gt==null||((mr=gt.type)===null||mr===void 0)?void 0:mr.indexOf("pdf"))>-1?nt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,"?type=").concat(gt.type,'&disposition=inline" target="_blank">').concat(gt.name,"</a>")):V.includes(Ur)?nt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,'?type=office&disposition=inline" target="_blank">').concat(gt.name,"</a>")):nt.replaceSelection("[".concat(gt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,"?type=").concat(St.content_type,")"))}else(St==null?void 0:St.status)===401&&(document.location.href="/user/login")})}catch(St){k.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return nt.on("paste",ct),nt.on("dragleave",function(st,pt){Ir.current.classList.remove("mouse-hover-md")}),nt.on("dragover",function(st,pt){Ir.current.classList.add("mouse-hover-md")}),nt.on("drop",function(st,pt){Ir.current.classList.add("mouse-hover-md");var Et;if(Et=pt.dataTransfer.files,Et.length>0){pt.preventDefault(),pt.stopPropagation();for(var At=function(qt){var gt=Et[qt],Ur=gt.name.split(".").pop();xe(gt,function(St){if(St.id){var er,Vt,mr;(gt==null||((er=gt.type)===null||er===void 0)?void 0:er.indexOf("image"))>-1?nt.replaceSelection(".concat(St.content_type,")")):(gt==null||((Vt=gt.type)===null||Vt===void 0)?void 0:Vt.indexOf("video"))>-1?nt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,'"></video>')):(gt==null||((mr=gt.type)===null||mr===void 0)?void 0:mr.indexOf("pdf"))>-1?nt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,"?type=").concat(gt.type,'&disposition=inline" target="_blank">').concat(gt.name,"</a>")):V.includes(Ur)?nt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,'?type=office&disposition=inline" target="_blank">').concat(gt.name,"</a>")):nt.replaceSelection("[".concat(gt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,"?type=").concat(St.content_type,")"))}else(St==null?void 0:St.status)===401&&(document.location.href="/user/login")})},vt=0;vt<Et.length;vt++)At(vt)}}),bn(nt),function(){nt.off("paste",ct)}}},[]);var ur=Object(v.useCallback)(function(){if(Ir.current)try{}catch(nt){console.log(nt,"---- to set md editor body height")}},[Oi,Ir,br]);Object(v.useEffect)(function(){function nt(){var st=new T.default(function(pt){var Et=Object(A.a)(pt),At;try{for(Et.s();!(At=Et.n()).done;){var vt=At.value;(vt.target.offsetHeight>0||vt.target.offsetWidth>0)&&(ur(),Pe.setSize("100%","100%"),Pe.refresh())}}catch(Ut){Et.e(Ut)}finally{Et.f()}});return st.observe(Mr.current.parentElement),st}if(Pe){var ct=nt();return function(){ct.unobserve(Mr.current.parentElement)}}},[Pe,ur]),Object(v.useEffect)(function(){if(Pe){for(var nt=[],ct=function(){var vt=pt[st];Et=Object(U.a)(vt,2);var Ut=Et[0],qt=Et[1],gt=Object(F.a)({},Ut,function(){Mi(qt)});nt.push(gt),Pe.addKeyMap(gt)},st=0,pt=Object.entries($);st<pt.length;st++){var Et;ct()}return Tn.current=setInterval(function(){tn.current&&ki()},4e3),function(){clearInterval(Tn.current);var At=Object(A.a)(nt),vt;try{for(At.s();!(vt=At.n()).done;){var Ut=vt.value;Pe.removeKeyMap(Ut)}}catch(qt){At.e(qt)}finally{At.f()}}}},[Pe]),Object(v.useEffect)(function(){Zt!==br&&Di(Zt)},[Zt]),Object(et.a)(function(){if(!Hn&&Er>0){var nt=new Date().getTime(),ct=window.sessionStorage.getItem(pr);nt>=Er+Ge&&(!ct||ct!==Zr)&&(window.sessionStorage.setItem(pr,Zr),xn(!0))}},Ge),Object(v.useEffect)(function(){Yn(Ft)},[Pe,Ft]),Object(v.useEffect)(function(){Pe&&(Bt&&Pe.focus())},[Pe,Bt]),Object(v.useEffect)(function(){if(yr&&Pe){var nt=Pe.getScrollerElement();function ct(st){var pt=st.target;if(Sn.current){var Et=pt.scrollTop/pt.scrollHeight;Sn.current.scrollTop=Sn.current.scrollHeight*Et}}return nt.addEventListener("scroll",ct),function(){nt.removeEventListener("scroll",ct)}}},[Pe,yr]),Object(v.useEffect)(function(){if(Pe&&gr){function nt(ct,st){gr(ct,st)}return Pe.on("beforeChange",nt),function(){Pe.off("beforeChange",nt)}}},[Pe,gr]),Object(v.useEffect)(function(){if(Pe&&Tt){function nt(){Tt(Pe.getValue())}return Pe.on("blur",nt),function(){Pe.off("blur",nt)}}},[Pe,Tt]),Object(v.useEffect)(function(){if(Pe){function nt(ct){var st=ct.getValue();vr(st),Qn(new Date().getTime()),ct.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),ze&&ze(st)}return Pe.on("change",nt),function(){Pe.off("change",nt)}}},[Pe,ze]),Object(v.useEffect)(function(){Pe&&(we==null?(Pe.setValue(""),vr("")):we!==Pe.getValue()&&(Pe.setValue(we),vr(we),Pe.setCursor(Pe.lineCount(),0)))},[Pe,we]);var Mi=Object(v.useCallback)(function(nt){var ct=Pe.getCursor(),st=Pe.getSelection(),pt=st.split(`
|
|
`);switch(nt){case"bold":return Pe.replaceSelection("**"+st+"**"),st===""&&Pe.setCursor(ct.line,ct.ch+2),Pe.focus();case"italic":return Pe.replaceSelection("*"+st+"*"),st===""&&Pe.setCursor(ct.line,ct.ch+1),Pe.focus();case"code":return Pe.replaceSelection("`"+st+"`"),st===""&&Pe.setCursor(ct.line,ct.ch+1),Pe.focus();case"inline-latex":return Pe.replaceSelection("`$$"+st+"$$`"),st===""&&Pe.setCursor(ct.line,ct.ch+3),Pe.focus();case"latex":return Pe.replaceSelection("```latex\n"+st+"\n```"),Pe.setCursor(ct.line+1,st.length+1),Pe.focus();case"line-break":return Pe.replaceSelection(`<br/>
|
|
`),Pe.focus();case"list-ul":return st===""?Pe.replaceSelection("- "+st):Pe.replaceSelection(pt.map(function(Et){return Et===""?"":"- ".concat(Et)}).join(`
|
|
`)),Pe.focus();case"list-ol":return st===""?Pe.replaceSelection("1. "+st):Pe.replaceSelection(pt.map(function(Et,At){return Et===""?"":"".concat(At+1,". ").concat(Et)}).join(`
|
|
`)),Pe.focus();case"add-null-ch":return st===""&&Pe.setCursor(ct.line,ct.ch+1),Pe.replaceSelection(ve),Pe.focus();case"inster-template-1":return st===""&&Pe.setCursor(ct.line,ct.ch),Pe.replaceSelection(Ee),Pe.focus();case"eraser":return Pe.setValue(""),Pe.focus();case"trigger-watch":return Yn(!yr),Pe.focus();case"trigger-full-screen":return Di(!br),Pe.focus();case _e:Wr(_e);return;case $e:Wr($e);return;case Le:Wr(Le);return;case Je:Wr(Je);return;default:throw new Error}},[Pe,yr,br]),wn=Object(v.useCallback)(function(nt){Wr("");switch($t){case _e:var ct=nt.title,st=nt.link;return Pe.replaceSelection("[".concat(ct,"](").concat(st,")")),Pe.focus();case $e:var pt=nt.language,Et=nt.content;return Pe.replaceSelection(["```"+pt,Et,"```"].join(`
|
|
`)),Pe.focus();case Le:var At=nt.src,vt=nt.alt;return vt?Pe.replaceSelection(".concat(At,' "').concat(vt,'" )')):Pe.replaceSelection("")),Pe.focus();case Je:for(var Ut=nt.row,qt=nt.col,gt=nt.align,Ur=`
|
|
`,St=0;St<Ut;St++){for(var er=[],Vt=[],mr=0;mr<qt;mr++)St===1&&Vt.push(He[gt]),er.push(" ");St===1&&(Ur+="| ".concat(Vt.join(" | "),` |
|
|
`)),Ur+="| ".concat(er.join(qt===1?"":" | "),` |
|
|
`)}return Pe.replaceSelection(Ur+`
|
|
`),Pe.focus();default:throw new Error}},[Pe,$t]),Zn=Object(v.useMemo)(function(){switch($t){case _e:return S.a.createElement(se,{callback:wn,onCancel:Hr});case $e:return S.a.createElement(de.b,{callback:wn,onCancel:Hr});case Le:return S.a.createElement(ae,{callback:wn,onCancel:Hr});case Je:return S.a.createElement(Me,{callback:wn,onCancel:Hr});default:return null}},[$t]);function Hr(){Wr("")}Object(v.useEffect)(function(){if(Fr.current){var nt=Fr.current,ct=!1,st=0;function pt(vt){ct=!0,st=vt.pageY}function Et(){ct=!1}function At(vt){if(ct){var Ut=vt.pageY-st;Ut<0&&(Ut=0),Ut>300&&(Ut=300);var qt=ht+Ut+"px";En(qt)}}return nt.addEventListener("mousedown",pt),document.addEventListener("mousemove",At),document.addEventListener("mouseup",Et),function(){nt.removeEventListener("mousedown",pt),document.removeEventListener("mousemove",At),document.removeEventListener("mouseup",Et)}}},[Pe,Fr]),Object(v.useEffect)(function(){En(ht)},[ht]);var Ar=oe(tt),qn=oe(Oi),xr={width:Ar,height:qn},ei=Object(v.useMemo)(function(){if(Er){var nt=new Date(Er),ct=nt.getHours(),st=nt.getMinutes(),pt=nt.getSeconds();return ct=ct<10?"0"+ct:ct,st=st<10?"0"+st:st,pt=pt<10?"0"+pt:pt,"".concat(ct,":").concat(st,":").concat(pt)}return 0},[Er]);function Ii(){window.sessionStorage.removeItem(pr),xn(!1),Qn(0)}function rn(){xn(!1),Qn(0),Pe.setValue(window.sessionStorage.getItem(pr))}function ua(nt,ct){var st=Pe.getValue();st=st.replace(nt,ct),vr(st),Pe==null||Pe.setValue(st)}return S.a.createElement(v.Fragment,null,S.a.createElement("div",{className:"markdown-editor-wrapper",ref:Ir},S.a.createElement("div",{className:"markdown-editor-container ".concat(Oe," ").concat(yr?"on-preview":""," ").concat(Ct?"mini":""," ").concat(br?"full-screen":""),style:xr},S.a.createElement(x,{insertTemp:bt,watch:yr,fullScreen:br,showNullButton:Rt,onActionCallback:Mi,hidetoolBar:Pr,uuid:en.current,setOpenPhones:function(){tn.current=!0}}),S.a.createElement("div",{className:"markdown-editor-body"},S.a.createElement("div",{className:"codemirror-container"},S.a.createElement("textarea",{ref:Mr,placeholder:vn})),yr?S.a.createElement("div",{ref:Sn,className:"preview-container"},Rr==="stex"&&S.a.createElement(L,{value:Zr}),Rr!=="stex"&&S.a.createElement(h.a,{edit:!0,value:Zr,replaces:ua})):null))),ia?S.a.createElement("a",{ref:Fr,className:"editor-resize"}):null,S.a.createElement(P.a,null,J[$t]?S.a.createElement(G.a,{centered:!0,title:J[$t],visible:!0,onCancel:Hr,footer:null,className:"markdown-popup-form"},Zn):null))}},SJMd:function(ut,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 q,Q,G,A=!1,W,k;window.PR_SHOULD_USE_CONTINUATION=!0;var O,U;(function(){var F=window,R=["break,continue,do,else,for,if,return,while"],_=[R,"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"],v=[_,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],S=[v,"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"],D=[v,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],C=[v,"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"],T="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",E=[v,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],l="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",o=[R,"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"],s=[R,"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"],u=[R,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],w=[S,C,D,E,l,o,s,u],m=/^(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",L="kwd",p="com",c="typ",f="lit",d="pun",a="pln",b="tag",g="dec",x="src",P="atn",N="atv",H="nocode",X="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function B(De){for(var Ce=0,Me=!1,Be=!1,je=0,_e=De.length;je<_e;++je){var Le=De[je];if(Le.ignoreCase)Be=!0;else if(/[a-z]/i.test(Le.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Me=!0,Be=!1;break}}var $e={b:8,t:9,n:10,v:11,f:12,r:13};function Je(Ve){var be=Ve.charCodeAt(0);if(be!==92)return be;var Ze=Ve.charAt(1);return be=$e[Ze],be||("0"<=Ze&&Ze<="7"?parseInt(Ve.substring(1),8):Ze==="u"||Ze==="x"?parseInt(Ve.substring(2),16):Ve.charCodeAt(1))}function We(Ve){if(Ve<32)return(Ve<16?"\\x0":"\\x")+Ve.toString(16);var be=String.fromCharCode(Ve);return be==="\\"||be==="-"||be==="]"||be==="^"?"\\"+be:be}function He(Ve){var be=Ve.substring(1,Ve.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")),Ze=[],Ge=be[0]==="^",ve=["["];Ge&&ve.push("^");for(var Ee=Ge?1:0,oe=be.length;Ee<oe;++Ee){var ee=be[Ee];if(/\\[bdsw]/i.test(ee))ve.push(ee);else{var re=Je(ee),V;Ee+2<oe&&be[Ee+1]==="-"?(V=Je(be[Ee+2]),Ee+=2):V=re,Ze.push([re,V]),V<65||re>122||(V<65||re>90||Ze.push([Math.max(65,re)|32,Math.min(V,90)|32]),V<97||re>122||Ze.push([Math.max(97,re)&~32,Math.min(V,122)&~32]))}}Ze.sort(function(le,ye){return le[0]-ye[0]||ye[1]-le[1]});for(var $=[],J=[],Ee=0;Ee<Ze.length;++Ee){var ne=Ze[Ee];ne[0]<=J[1]+1?J[1]=Math.max(J[1],ne[1]):$.push(J=ne)}for(var Ee=0;Ee<$.length;++Ee){var ne=$[Ee];ve.push(We(ne[0])),ne[1]>ne[0]&&(ne[1]+1>ne[0]&&ve.push("-"),ve.push(We(ne[1])))}return ve.push("]"),ve.join("")}function et(Ve){for(var be=Ve.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")),Ze=be.length,Ge=[],ve=0,Ee=0;ve<Ze;++ve){var oe=be[ve];if(oe==="(")++Ee;else if(oe.charAt(0)==="\\"){var ee=+oe.substring(1);ee&&(ee<=Ee?Ge[ee]=-1:be[ve]=We(ee))}}for(var ve=1;ve<Ge.length;++ve)Ge[ve]===-1&&(Ge[ve]=++Ce);for(var ve=0,Ee=0;ve<Ze;++ve){var oe=be[ve];if(oe==="(")++Ee,Ge[Ee]||(be[ve]="(?:");else if(oe.charAt(0)==="\\"){var ee=+oe.substring(1);ee&&ee<=Ee&&(be[ve]="\\"+Ge[ee])}}for(var ve=0;ve<Ze;++ve)be[ve]==="^"&&be[ve+1]!=="^"&&(be[ve]="");if(Ve.ignoreCase&&Me)for(var ve=0;ve<Ze;++ve){var oe=be[ve],re=oe.charAt(0);oe.length>=2&&re==="["?be[ve]=He(oe):re!=="\\"&&(be[ve]=oe.replace(/[a-zA-Z]/g,function(J){var ne=J.charCodeAt(0);return"["+String.fromCharCode(ne&~32,ne|32)+"]"}))}return be.join("")}for(var Ye=[],je=0,_e=De.length;je<_e;++je){var Le=De[je];if(Le.global||Le.multiline)throw new Error(""+Le);Ye.push("(?:"+et(Le)+")")}return new RegExp(Ye.join("|"),Be?"gi":"g")}function I(De,Ce){var Me=/(?:^|\s)nocode(?:\s|$)/,Be=[],je=0,_e=[],Le=0;function $e(Je){var We=Je.nodeType;if(We==1){if(Me.test(Je.className))return;for(var He=Je.firstChild;He;He=He.nextSibling)$e(He);var et=Je.nodeName.toLowerCase();(et==="br"||et==="li")&&(Be[Le]=`
|
|
`,_e[Le<<1]=je++,_e[Le++<<1|1]=Je)}else if(We==3||We==4){var Ye=Je.nodeValue;Ye.length&&(Ce?Ye=Ye.replace(/\r\n?/g,`
|
|
`):Ye=Ye.replace(/[ \t\r\n]+/g," "),Be[Le]=Ye,_e[Le<<1]=je,je+=Ye.length,_e[Le++<<1|1]=Je)}}return $e(De),{sourceCode:Be.join("").replace(/\n$/,""),spans:_e}}function Y(De,Ce,Me,Be,je){if(!Me)return;var _e={sourceNode:De,pre:1,langExtension:null,numberLines:null,sourceCode:Me,spans:null,basePos:Ce,decorations:null};Be(_e),je.push.apply(je,_e.decorations)}var te=/\S/;function se(De){for(var Ce=void 0,Me=De.firstChild;Me;Me=Me.nextSibling){var Be=Me.nodeType;Ce=Be===1?Ce?De:Me:Be===3&&te.test(Me.nodeValue)?De:Ce}return Ce===De?void 0:Ce}function de(De,Ce){var Me={},Be;(function(){for(var Le=De.concat(Ce),$e=[],Je={},We=0,He=Le.length;We<He;++We){var et=Le[We],Ye=et[3];if(Ye)for(var Ve=Ye.length;--Ve>=0;)Me[Ye.charAt(Ve)]=et;var be=et[1],Ze=""+be;Je.hasOwnProperty(Ze)||($e.push(be),Je[Ze]=null)}$e.push(/[\0-\uffff]/),Be=B($e)})();var je=Ce.length,_e=function(Le){for(var $e=Le.sourceCode,Je=Le.basePos,We=Le.sourceNode,He=[Je,a],et=0,Ye=$e.match(Be)||[],Ve={},be=0,Ze=Ye.length;be<Ze;++be){var Ge=Ye[be],ve=Ve[Ge],Ee=void 0,oe;if(typeof ve=="string")oe=!1;else{var ee=Me[Ge.charAt(0)];if(ee)Ee=Ge.match(ee[1]),ve=ee[0];else{for(var re=0;re<je;++re)if(ee=Ce[re],Ee=Ge.match(ee[1]),Ee){ve=ee[0];break}Ee||(ve=a)}oe=ve.length>=5&&ve.substring(0,5)==="lang-",oe&&!(Ee&&typeof Ee[1]=="string")&&(oe=!1,ve=x),oe||(Ve[Ge]=ve)}var V=et;if(et+=Ge.length,!oe)He.push(Je+V,ve);else{var $=Ee[1],J=Ge.indexOf($),ne=J+$.length;Ee[2]&&(ne=Ge.length-Ee[2].length,J=ne-$.length);var le=ve.substring(5);Y(We,Je+V,Ge.substring(0,J),_e,He),Y(We,Je+V+J,$,ue(le,$),He),Y(We,Je+V+ne,Ge.substring(ne),_e,He)}}Le.decorations=He};return _e}function Se(De){var Ce=[],Me=[];De.tripleQuotedStrings?Ce.push([h,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):De.multiLineStrings?Ce.push([h,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Ce.push([h,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),De.verbatimStrings&&Me.push([h,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Be=De.hashComments;Be&&(De.cStyleComments?(Be>1?Ce.push([p,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Ce.push([p,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Me.push([h,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Ce.push([p,/^#[^\r\n]*/,null,"#"])),De.cStyleComments&&(Me.push([p,/^\/\/[^\r\n]*/,null]),Me.push([p,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var je=De.regexLiterals;if(je){var _e=je>1?"":`
|
|
\r`,Le=_e?".":"[\\S\\s]",$e="/(?=[^/*"+_e+"])(?:[^/\\x5B\\x5C"+_e+"]|\\x5C"+Le+"|\\x5B(?:[^\\x5C\\x5D"+_e+"]|\\x5C"+Le+")*(?:\\x5D|$))+/";Me.push(["lang-regex",RegExp("^"+X+"("+$e+")")])}var Je=De.types;Je&&Me.push([c,Je]);var We=(""+De.keywords).replace(/^ | $/g,"");We.length&&Me.push([L,new RegExp("^(?:"+We.replace(/[\s,]+/g,"|")+")\\b"),null]),Ce.push([a,/^\s+/,null,` \r
|
|
\xA0`]);var He="^.[^\\s\\w.$@'\"`/\\\\]*";return De.regexLiterals&&(He+="(?!s*/)"),Me.push([f,/^@[a-z_$][a-z_$@0-9]*/i,null],[c,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[f,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[d,new RegExp(He),null]),de(Ce,Me)}var ge=Se({keywords:w,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function pe(De,Ce,Me){for(var Be=/(?:^|\s)nocode(?:\s|$)/,je=/\r\n?|\n/,_e=De.ownerDocument,Le=_e.createElement("li");De.firstChild;)Le.appendChild(De.firstChild);var $e=[Le];function Je(be){var Ze=be.nodeType;if(Ze==1&&!Be.test(be.className))if(be.nodeName==="br")We(be),be.parentNode&&be.parentNode.removeChild(be);else for(var Ge=be.firstChild;Ge;Ge=Ge.nextSibling)Je(Ge);else if((Ze==3||Ze==4)&&Me){var ve=be.nodeValue,Ee=ve.match(je);if(Ee){var oe=ve.substring(0,Ee.index);be.nodeValue=oe;var ee=ve.substring(Ee.index+Ee[0].length);if(ee){var re=be.parentNode;re.insertBefore(_e.createTextNode(ee),be.nextSibling)}We(be),oe||be.parentNode.removeChild(be)}}}function We(be){for(;!be.nextSibling;)if(be=be.parentNode,!be)return;function Ze(Ee,oe){var ee=oe?Ee.cloneNode(!1):Ee,re=Ee.parentNode;if(re){var V=Ze(re,1),$=Ee.nextSibling;V.appendChild(ee);for(var J=$;J;J=$)$=J.nextSibling,V.appendChild(J)}return ee}for(var Ge=Ze(be.nextSibling,0),ve;(ve=Ge.parentNode)&&ve.nodeType===1;)Ge=ve;$e.push(Ge)}for(var He=0;He<$e.length;++He)Je($e[He]);Ce===(Ce|0)&&$e[0].setAttribute("value",Ce);var et=_e.createElement("ol");et.className="linenums";for(var Ye=Math.max(0,Ce-1|0)||0,He=0,Ve=$e.length;He<Ve;++He)Le=$e[He],Le.className="L"+(He+Ye)%10,Le.firstChild||Le.appendChild(_e.createTextNode("\xA0")),et.appendChild(Le);De.appendChild(et)}function he(De){var Ce=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Ce=Ce&&+Ce[1]<=8;var Me=/\n/g,Be=De.sourceCode,je=Be.length,_e=0,Le=De.spans,$e=Le.length,Je=0,We=De.decorations,He=We.length,et=0;We[He]=je;var Ye,Ve;for(Ve=Ye=0;Ve<He;)We[Ve]!==We[Ve+2]?(We[Ye++]=We[Ve++],We[Ye++]=We[Ve++]):Ve+=2;for(He=Ye,Ve=Ye=0;Ve<He;){for(var be=We[Ve],Ze=We[Ve+1],Ge=Ve+2;Ge+2<=He&&We[Ge+1]===Ze;)Ge+=2;We[Ye++]=be,We[Ye++]=Ze,Ve=Ge}He=We.length=Ye;var ve=De.sourceNode,Ee="";ve&&(Ee=ve.style.display,ve.style.display="none");try{for(var oe=null;Je<$e;){var ee=Le[Je],re=Le[Je+2]||je,V=We[et+2]||je,Ge=Math.min(re,V),$=Le[Je+1],J;if($.nodeType!==1&&(J=Be.substring(_e,Ge))){Ce&&(J=J.replace(Me,"\r")),$.nodeValue=J;var ne=$.ownerDocument,le=ne.createElement("span");le.className=We[et+1];var ye=$.parentNode;ye.replaceChild(le,$),le.appendChild($),_e<re&&(Le[Je+1]=$=ne.createTextNode(Be.substring(Ge,re)),ye.insertBefore($,le.nextSibling))}_e=Ge,_e>=re&&(Je+=2),_e>=V&&(et+=2)}}finally{ve&&(ve.style.display=Ee)}}var me={};function ae(De,Ce){for(var Me=Ce.length;--Me>=0;){var Be=Ce[Me];me.hasOwnProperty(Be)?F.console&&console.warn("cannot override language handler %s",Be):me[Be]=De}}function ue(De,Ce){return De&&me.hasOwnProperty(De)||(De=/^\s*</.test(Ce)?"default-markup":"default-code"),me[De]}ae(ge,["default-code"]),ae(de([],[[a,/^[^<?]+/],[g,/^<!\w[^>]*(?:>|$)/],[p,/^<\!--[\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"]),ae(de([[a,/^[\s]+/,null,` \r
|
|
`],[N,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[b,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!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"]),ae(de([],[[N,/^[\s\S]+/]]),["uq.val"]),ae(Se({keywords:S,hashComments:!0,cStyleComments:!0,types:m}),["c","cc","cpp","cxx","cyc","m"]),ae(Se({keywords:"null,true,false"}),["json"]),ae(Se({keywords:C,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:m}),["cs"]),ae(Se({keywords:D,cStyleComments:!0}),["java"]),ae(Se({keywords:u,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ae(Se({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ae(Se({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ae(Se({keywords:s,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ae(Se({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ae(Se({keywords:T,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ae(de([],[[h,/^[\s\S]+/]]),["regex"]);function xe(De){var Ce=De.langExtension;try{var Me=I(De.sourceNode,De.pre),Be=Me.sourceCode;De.sourceCode=Be,De.spans=Me.spans,De.basePos=0,ue(Ce,Be)(De),he(De)}catch(je){F.console&&console.log(je&&je.stack||je)}}function Fe(De,Ce,Me){var Be=Me||!1,je=Ce||null,_e=document.createElement("div");_e.innerHTML="<pre>"+De+"</pre>",_e=_e.firstChild,Be&&pe(_e,Be,!0);var Le={langExtension:je,numberLines:Be,sourceNode:_e,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return xe(Le),_e.innerHTML}function Re(De,Ce){var Me=Ce||document.body,Be=Me.ownerDocument||document;function je(ee){return Me.getElementsByTagName(ee)}for(var _e=[je("pre"),je("code"),je("xmp")],Le=[],$e=0;$e<_e.length;++$e)for(var Je=0,We=_e[$e].length;Je<We;++Je)Le.push(_e[$e][Je]);_e=null;var He=Date;He.now||(He={now:function(){return+new Date}});var et=0,Ye=/\blang(?:uage)?-([\w.]+)(?!\S)/,Ve=/\bprettyprint\b/,be=/\bprettyprinted\b/,Ze=/pre|xmp/i,Ge=/^code$/i,ve=/^(?:pre|code|xmp)$/i,Ee={};function oe(){for(var ee=F.PR_SHOULD_USE_CONTINUATION?He.now()+250:Infinity;et<Le.length&&He.now()<ee;et++){for(var re=Le[et],V=Ee,$=re;$=$.previousSibling;){var J=$.nodeType,ne=(J===7||J===8)&&$.nodeValue;if(ne?!/^\??prettify\b/.test(ne):J!==3||/\S/.test($.nodeValue))break;if(ne){V={},ne.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Ft,bt,Cr){V[bt]=Cr});break}}var le=re.className;if((V!==Ee||Ve.test(le))&&!be.test(le)){for(var ye=!1,we=re.parentNode;we;we=we.parentNode){var ze=we.tagName;if(ve.test(ze)&&we.className&&Ve.test(we.className)){ye=!0;break}}if(!ye){re.className+=" prettyprinted";var it=V.lang;if(!it){it=le.match(Ye);var tt;!it&&(tt=se(re))&&Ge.test(tt.tagName)&&(it=tt.className.match(Ye)),it&&(it=it[1])}var xt;if(Ze.test(re.tagName))xt=1;else{var ht=re.currentStyle,ot=Be.defaultView,Ct=ht?ht.whiteSpace:ot&&ot.getComputedStyle?ot.getComputedStyle(re,null).getPropertyValue("white-space"):0;xt=Ct&&Ct.substring(0,3)==="pre"}var yt=V.linenums;(yt=yt==="true"||+yt)||(yt=le.match(/\blinenums\b(?::(\d+))?/),yt=yt?yt[1]&&yt[1].length?+yt[1]:!0:!1),yt&&pe(re,yt,xt);var Bt={langExtension:it,sourceNode:re,numberLines:yt,pre:xt,sourceCode:null,basePos:null,spans:null,decorations:null};xe(Bt)}}}et<Le.length?F.setTimeout(oe,250):typeof De=="function"&&De()}oe()}var Ie=F.PR={createSimpleLexer:de,registerLangHandler:ae,sourceDecorator:Se,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:N,PR_COMMENT:p,PR_DECLARATION:g,PR_KEYWORD:L,PR_LITERAL:f,PR_NOCODE:H,PR_PLAIN:a,PR_PUNCTUATION:d,PR_SOURCE:x,PR_STRING:h,PR_TAG:b,PR_TYPE:c,prettyPrintOne:A?F.prettyPrintOne=Fe:O=Fe,prettyPrint:U=A?F.prettyPrint=Re:U=Re},Ke=F.define;typeof Ke=="function"&&Ke.amd&&Ke("google-code-prettify",[],function(){return Ie})})()},UUDw:function(ut,Qe,q){ut.exports={buttonFixed:"buttonFixed___2zLVJ",button:"button___-JgFH",buttonWrap:"buttonWrap___aZhhk"}},UqFu:function(ut,Qe,q){"use strict";q.d(Qe,"a",function(){return Q});var Q=function(A){var W=document.createElement("textarea");return W.value=A,W.value}},"VrN/":function(ut,Qe,q){(function(Q,G){ut.exports=G()})(this,function(){"use strict";var Q=navigator.userAgent,G=navigator.platform,A=/gecko\/\d/i.test(Q),W=/MSIE \d/.test(Q),k=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Q),O=/Edge\/(\d+)/.exec(Q),U=W||k||O,F=U&&(W?document.documentMode||6:+(O||k)[1]),R=!O&&/WebKit\//.test(Q),_=R&&/Qt\/\d+\.\d+/.test(Q),v=!O&&/Chrome\//.test(Q),S=/Opera\//.test(Q),D=/Apple Computer/.test(navigator.vendor),C=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(Q),T=/PhantomJS/.test(Q),E=!O&&/AppleWebKit/.test(Q)&&/Mobile\/\w+/.test(Q),l=/Android/.test(Q),o=E||l||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(Q),s=E||/Mac/.test(G),u=/\bCrOS\b/.test(Q),w=/win/i.test(G),m=S&&Q.match(/Version\/(\d*\.\d*)/);m&&(m=Number(m[1])),m&&m>=15&&(S=!1,R=!0);var h=s&&(_||S&&(m==null||m<12.11)),L=A||U&&F>=9;function p(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var c=function(e,t){var n=e.className,r=p(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}};function f(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function d(e,t){return f(e).appendChild(t)}function a(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),typeof t=="string")i.appendChild(document.createTextNode(t));else if(t)for(var y=0;y<t.length;++y)i.appendChild(t[y]);return i}function b(e,t,n,r){var i=a(e,t,n,r);return i.setAttribute("role","presentation"),i}var g;document.createRange?g=function(e,t,n,r){var i=document.createRange();return i.setEnd(r||e,n),i.setStart(e,t),i}:g=function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r};function x(e,t){if(t.nodeType==3&&(t=t.parentNode),e.contains)return e.contains(t);do if(t.nodeType==11&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function P(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function N(e,t){var n=e.className;p(t).test(n)||(e.className+=(n?" ":"")+t)}function H(e,t){for(var n=e.split(" "),r=0;r<n.length;r++)n[r]&&!p(n[r]).test(t)&&(t+=" "+n[r]);return t}var X=function(e){e.select()};E?X=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:U&&(X=function(e){try{e.select()}catch(t){}});function B(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function I(e,t,n){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(n!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function Y(e,t,n,r,i){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var y=r||0,M=i||0;;){var j=e.indexOf(" ",y);if(j<0||j>=t)return M+(t-y);M+=j-y,M+=n-M%n,y=j+1}}var te=function(){this.id=null,this.f=null,this.time=0,this.handler=B(this.onTimeout,this)};te.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},te.prototype.set=function(e,t){this.f=t;var n=+new Date+e;(!this.id||n<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=n)};function se(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}var de=50,Se={toString:function(){return"CodeMirror.Pass"}},ge={scroll:!1},pe={origin:"*mouse"},he={origin:"+move"};function me(e,t,n){for(var r=0,i=0;;){var y=e.indexOf(" ",r);y==-1&&(y=e.length);var M=y-r;if(y==e.length||i+M>=t)return r+Math.min(M,t-i);if(i+=y-r,i+=n-i%n,r=y+1,i>=t)return r}}var ae=[""];function ue(e){for(;ae.length<=e;)ae.push(xe(ae)+" ");return ae[e]}function xe(e){return e[e.length-1]}function Fe(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Re(e,t,n){for(var r=0,i=n(t);r<e.length&&n(e[r])<=i;)r++;e.splice(r,0,t)}function Ie(){}function Ke(e,t){var n;return Object.create?n=Object.create(e):(Ie.prototype=e,n=new Ie),t&&I(t,n),n}var De=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Ce(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||De.test(e))}function Me(e,t){return t?t.source.indexOf("\\w")>-1&&Ce(e)?!0:t.test(e):Ce(e)}function Be(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var je=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function _e(e){return e.charCodeAt(0)>=768&&je.test(e)}function Le(e,t,n){for(;(n<0?t>0:t<e.length)&&_e(e.charAt(t));)t+=n;return t}function $e(e,t,n){for(var r=t>n?-1:1;;){if(t==n)return t;var i=(t+n)/2,y=r<0?Math.ceil(i):Math.floor(i);if(y==t)return e(y)?t:n;e(y)?n=y:t=y+r}}function Je(e,t,n,r){if(!e)return r(t,n,"ltr",0);for(var i=!1,y=0;y<e.length;++y){var M=e[y];(M.from<n&&M.to>t||t==n&&M.to==t)&&(r(Math.max(M.from,t),Math.min(M.to,n),M.level==1?"rtl":"ltr",y),i=!0)}i||r(t,n,"ltr")}var We=null;function He(e,t,n){var r;We=null;for(var i=0;i<e.length;++i){var y=e[i];if(y.from<t&&y.to>t)return i;y.to==t&&(y.from!=y.to&&n=="before"?r=i:We=i),y.from==t&&(y.from!=y.to&&n!="before"?r=i:We=i)}return r!=null?r:We}var et=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function n(z){return z<=247?e.charAt(z):1424<=z&&z<=1524?"R":1536<=z&&z<=1785?t.charAt(z-1536):1774<=z&&z<=2220?"r":8192<=z&&z<=8203?"w":z==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,y=/[LRr]/,M=/[Lb1n]/,j=/[1n]/;function K(z,Z,ie){this.level=z,this.from=Z,this.to=ie}return function(z,Z){var ie=Z=="ltr"?"L":"R";if(z.length==0||Z=="ltr"&&!r.test(z))return!1;for(var fe=z.length,ce=[],Te=0;Te<fe;++Te)ce.push(n(z.charCodeAt(Te)));for(var Ae=0,ke=ie;Ae<fe;++Ae){var Ue=ce[Ae];Ue=="m"?ce[Ae]=ke:ke=Ue}for(var Xe=0,Ne=ie;Xe<fe;++Xe){var qe=ce[Xe];qe=="1"&&Ne=="r"?ce[Xe]="n":y.test(qe)&&(Ne=qe,qe=="r"&&(ce[Xe]="R"))}for(var lt=1,at=ce[0];lt<fe-1;++lt){var mt=ce[lt];mt=="+"&&at=="1"&&ce[lt+1]=="1"?ce[lt]="1":mt==","&&at==ce[lt+1]&&(at=="1"||at=="n")&&(ce[lt]=at),at=mt}for(var Dt=0;Dt<fe;++Dt){var Ht=ce[Dt];if(Ht==",")ce[Dt]="N";else if(Ht=="%"){var Ot=void 0;for(Ot=Dt+1;Ot<fe&&ce[Ot]=="%";++Ot);for(var sr=Dt&&ce[Dt-1]=="!"||Ot<fe&&ce[Ot]=="1"?"1":"N",nr=Dt;nr<Ot;++nr)ce[nr]=sr;Dt=Ot-1}}for(var Mt=0,ir=ie;Mt<fe;++Mt){var zt=ce[Mt];ir=="L"&&zt=="1"?ce[Mt]="L":y.test(zt)&&(ir=zt)}for(var Nt=0;Nt<fe;++Nt)if(i.test(ce[Nt])){var It=void 0;for(It=Nt+1;It<fe&&i.test(ce[It]);++It);for(var Pt=(Nt?ce[Nt-1]:ie)=="L",ar=(It<fe?ce[It]:ie)=="L",jn=Pt==ar?Pt?"L":"R":ie,Jr=Nt;Jr<It;++Jr)ce[Jr]=jn;Nt=It-1}for(var Yt=[],Or,Kt=0;Kt<fe;)if(M.test(ce[Kt])){var Va=Kt;for(++Kt;Kt<fe&&M.test(ce[Kt]);++Kt);Yt.push(new K(0,Va,Kt))}else{var jr=Kt,fn=Yt.length,hn=Z=="rtl"?1:0;for(++Kt;Kt<fe&&ce[Kt]!="L";++Kt);for(var Qt=jr;Qt<Kt;)if(j.test(ce[Qt])){jr<Qt&&(Yt.splice(fn,0,new K(1,jr,Qt)),fn+=hn);var Wn=Qt;for(++Qt;Qt<Kt&&j.test(ce[Qt]);++Qt);Yt.splice(fn,0,new K(2,Wn,Qt)),fn+=hn,jr=Qt}else++Qt;jr<Kt&&Yt.splice(fn,0,new K(1,jr,Kt))}return Z=="ltr"&&(Yt[0].level==1&&(Or=z.match(/^\s+/))&&(Yt[0].from=Or[0].length,Yt.unshift(new K(0,0,Or[0].length))),xe(Yt).level==1&&(Or=z.match(/\s+$/))&&(xe(Yt).to-=Or[0].length,Yt.push(new K(0,fe-Or[0].length,fe)))),Z=="rtl"?Yt.reverse():Yt}}();function Ye(e,t){var n=e.order;return n==null&&(n=e.order=et(e.text,t)),n}var Ve=[],be=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||Ve).concat(n)}};function Ze(e,t){return e._handlers&&e._handlers[t]||Ve}function Ge(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers,i=r&&r[t];if(i){var y=se(i,n);y>-1&&(r[t]=i.slice(0,y).concat(i.slice(y+1)))}}}function ve(e,t){var n=Ze(e,t);if(!n.length)return;for(var r=Array.prototype.slice.call(arguments,2),i=0;i<n.length;++i)n[i].apply(null,r)}function Ee(e,t,n){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),ve(e,n||t.type,e,t),J(t)||t.codemirrorIgnore}function oe(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)se(n,t[r])==-1&&n.push(t[r])}function ee(e,t){return Ze(e,t).length>0}function re(e){e.prototype.on=function(t,n){be(this,t,n)},e.prototype.off=function(t,n){Ge(this,t,n)}}function V(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function $(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function J(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ne(e){V(e),$(e)}function le(e){return e.target||e.srcElement}function ye(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),s&&e.ctrlKey&&t==1&&(t=3),t}var we=function(){if(U&&F<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),ze;function it(e){if(ze==null){var t=a("span","\u200B");d(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(ze=t.offsetWidth<=1&&t.offsetHeight>2&&!(U&&F<8))}var n=ze?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}var tt;function xt(e){if(tt!=null)return tt;var t=d(e,document.createTextNode("A\u062EA")),n=g(t,0,1).getBoundingClientRect(),r=g(t,1,2).getBoundingClientRect();return f(e),!n||n.left==n.right?!1:tt=r.right-n.right<3}var ht=`
|
|
|
|
b`.split(/\n/).length!=3?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf(`
|
|
`,t);i==-1&&(i=e.length);var y=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),M=y.indexOf("\r");M!=-1?(n.push(y.slice(0,M)),t+=M+1):(n.push(y),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},ot=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},Ct=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),yt=null;function Bt(e){if(yt!=null)return yt;var t=d(e,a("span","x")),n=t.getBoundingClientRect(),r=g(t,0,1).getBoundingClientRect();return yt=Math.abs(n.left-r.left)>1}var Ft={},bt={};function Cr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ft[e]=t}function Rr(e,t){bt[e]=t}function lr(e){if(typeof e=="string"&&bt.hasOwnProperty(e))e=bt[e];else if(e&&typeof e.name=="string"&&bt.hasOwnProperty(e.name)){var t=bt[e.name];typeof t=="string"&&(t={name:t}),e=Ke(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return lr("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return lr("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function pr(e,t){t=lr(t);var n=Ft[t.name];if(!n)return pr(e,"text/plain");var r=n(e,t);if(fr.hasOwnProperty(t.name)){var i=fr[t.name];for(var y in i){if(!i.hasOwnProperty(y))continue;r.hasOwnProperty(y)&&(r["_"+y]=r[y]),r[y]=i[y]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var M in t.modeProps)r[M]=t.modeProps[M];return r}var fr={};function ia(e,t){var n=fr.hasOwnProperty(e)?fr[e]:fr[e]={};I(t,n)}function Lr(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function Hn(e,t){for(var n;e.innerMode&&!(n=e.innerMode(t),!n||n.mode==e);)t=n.state,e=n.mode;return n||{mode:e,state:t}}function Kn(e,t,n){return e.startState?e.startState(t,n):!0}var Rt=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};Rt.prototype.eol=function(){return this.pos>=this.string.length},Rt.prototype.sol=function(){return this.pos==this.lineStart},Rt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Rt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Rt.prototype.eat=function(e){var t=this.string.charAt(this.pos),n;if(typeof e=="string"?n=t==e:n=t&&(e.test?e.test(t):e(t)),n)return++this.pos,t},Rt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Rt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Rt.prototype.skipToEnd=function(){this.pos=this.string.length},Rt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Rt.prototype.backUp=function(e){this.pos-=e},Rt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Y(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)},Rt.prototype.indentation=function(){return Y(this.string,null,this.tabSize)-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)},Rt.prototype.match=function(e,t,n){if(typeof e=="string"){var r=function(M){return n?M.toLowerCase():M},i=this.string.substr(this.pos,e.length);if(r(i)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var y=this.string.slice(this.pos).match(e);return y&&y.index>0?null:(y&&t!==!1&&(this.pos+=y[0].length),y)}},Rt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Rt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Rt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Rt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function rt(e,t){if(t-=e.first,t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],y=i.chunkSize();if(t<y){n=i;break}t-=y}return n.lines[t]}function Pr(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(y){var M=y.text;i==n.line&&(M=M.slice(0,n.ch)),i==t.line&&(M=M.slice(t.ch)),r.push(M),++i}),r}function mn(e,t,n){var r=[];return e.iter(t,n,function(i){r.push(i.text)}),r}function Zt(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function Tt(e){if(e.parent==null)return null;for(var t=e.parent,n=se(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var i=0;!(r.children[i]==t);++i)n+=r.children[i].chunkSize();return n+t.first}function gr(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],y=i.height;if(t<y){e=i;continue e}t-=y,n+=i.chunkSize()}return n}while(!e.lines);for(var M=0;M<e.lines.length;++M){var j=e.lines[M],K=j.height;if(t<K)break;t-=K}return n+M}function kr(e,t){return t>=e.first&&t<e.first+e.size}function pn(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Oe(e,t,n){if(n===void 0&&(n=null),!(this instanceof Oe))return new Oe(e,t,n);this.line=e,this.ch=t,this.sticky=n}function dt(e,t){return e.line-t.line||e.ch-t.ch}function Gn(e,t){return e.sticky==t.sticky&&dt(e,t)==0}function gn(e){return Oe(e.line,e.ch)}function vn(e,t){return dt(e,t)<0?t:e}function Qr(e,t){return dt(e,t)<0?e:t}function yn(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function ft(e,t){if(t.line<e.first)return Oe(e.first,0);var n=e.first+e.size-1;return t.line>n?Oe(n,rt(e,n).text.length):Li(t,rt(e,t.line).text.length)}function Li(e,t){var n=e.ch;return n==null||n>t?Oe(e.line,t):n<0?Oe(e.line,0):e}function Pe(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=ft(e,t[r]);return n}var bn=function(e,t){this.state=e,this.lookAhead=t},hr=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};hr.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},hr.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},hr.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},hr.fromSaved=function(e,t,n){return t instanceof bn?new hr(e,Lr(e.mode,t.state),n,t.lookAhead):new hr(e,Lr(e.mode,t),n)},hr.prototype.save=function(e){var t=e!==!1?Lr(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new bn(t,this.maxLookAhead):t};function zn(e,t,n,r){var i=[e.state.modeGen],y={};br(e,t.text,e.doc.mode,n,function(z,Z){return i.push(z,Z)},y,r);for(var M=n.state,j=function(z){n.baseTokens=i;var Z=e.state.overlays[z],ie=1,fe=0;n.state=!0,br(e,t.text,Z.mode,n,function(ce,Te){for(var Ae=ie;fe<ce;){var ke=i[ie];ke>ce&&i.splice(ie,1,ce,i[ie+1],ke),ie+=2,fe=Math.min(ce,ke)}if(!Te)return;if(Z.opaque)i.splice(Ae,ie-Ae,ce,"overlay "+Te),ie=Ae+2;else for(;Ae<ie;Ae+=2){var Ue=i[Ae+1];i[Ae+1]=(Ue?Ue+" ":"")+"overlay "+Te}},y),n.state=M,n.baseTokens=null,n.baseTokenPos=1},K=0;K<e.state.overlays.length;++K)j(K);return{styles:i,classes:y.bgClass||y.textClass?y:null}}function Zr(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=vr(e,Tt(t)),i=t.text.length>e.options.maxHighlightLength&&Lr(e.doc.mode,r.state),y=zn(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=y.styles,y.classes?t.styleClasses=y.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function vr(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new hr(r,!0,t);var y=Di(e,t,n),M=y>r.first&&rt(r,y-1).stateAfter,j=M?hr.fromSaved(r,M,y):new hr(r,Kn(r.mode),y);return r.iter(y,t,function(K){Vn(e,K.text,j);var z=j.line;K.stateAfter=z==t-1||z%5==0||z>=i.viewFrom&&z<i.viewTo?j.save():null,j.nextLine()}),n&&(r.modeFrontier=j.line),j}function Vn(e,t,n,r){var i=e.doc.mode,y=new Rt(t,e.options.tabSize,n);for(y.start=y.pos=r||0,t==""&&Xn(i,n.state);!y.eol();)yr(i,y,n.state),y.start=y.pos}function Xn(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var n=Hn(e,t);if(n.mode.blankLine)return n.mode.blankLine(n.state)}function yr(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=Hn(e,n).mode);var y=e.token(t,n);if(t.pos>t.start)return y}throw new Error("Mode "+e.name+" failed to advance stream.")}var Yn=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function Ai(e,t,n,r){var i=e.doc,y=i.mode,M;t=ft(i,t);var j=rt(i,t.line),K=vr(e,t.line,n),z=new Rt(j.text,e.options.tabSize,K),Z;for(r&&(Z=[]);(r||z.pos<t.ch)&&!z.eol();)z.start=z.pos,M=yr(y,z,K.state),r&&Z.push(new Yn(z,M,Lr(i.mode,K.state)));return r?Z:new Yn(z,M,K.state)}function $n(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";t[r]==null?t[r]=n[2]:new RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+n[2])}return e}function br(e,t,n,r,i,y,M){var j=n.flattenSpans;j==null&&(j=e.options.flattenSpans);var K=0,z=null,Z=new Rt(t,e.options.tabSize,r),ie,fe=e.options.addModeClass&&[null];for(t==""&&$n(Xn(n,r.state),y);!Z.eol();){if(Z.pos>e.options.maxHighlightLength?(j=!1,M&&Vn(e,t,r,Z.pos),Z.pos=t.length,ie=null):ie=$n(yr(n,Z,r.state,fe),y),fe){var ce=fe[0].name;ce&&(ie="m-"+(ie?ce+" "+ie:ce))}if(!j||z!=ie){for(;K<Z.start;)K=Math.min(Z.start,K+5e3),i(K,z);z=ie}Z.start=Z.pos}for(;K<Z.pos;){var Te=Math.min(Z.pos,K+5e3);i(Te,z),K=Te}}function Di(e,t,n){for(var r,i,y=e.doc,M=n?-1:t-(e.doc.mode.innerMode?1e3:100),j=t;j>M;--j){if(j<=y.first)return y.first;var K=rt(y,j-1),z=K.stateAfter;if(z&&(!n||j+(z instanceof bn?z.lookAhead:0)<=y.modeFrontier))return j;var Z=Y(K.text,null,e.options.tabSize);(i==null||r>Z)&&(i=j-1,r=Z)}return i}function aa(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var n=e.first,r=t-1;r>n;r--){var i=rt(e,r).stateAfter;if(i&&(!(i instanceof bn)||r+i.lookAhead<t)){n=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,n)}var Jn=!1,$t=!1;function Wr(){Jn=!0}function oa(){$t=!0}function qr(e,t,n){this.marker=e,this.from=t,this.to=n}function Er(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function Qn(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function sa(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function _i(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var y=e[i],M=y.marker,j=y.from==null||(M.inclusiveLeft?y.from<=t:y.from<t);if(j||y.from==t&&M.type=="bookmark"&&(!n||!y.marker.insertLeft)){var K=y.to==null||(M.inclusiveRight?y.to>=t:y.to>t);(r||(r=[])).push(new qr(M,y.from,K?null:y.to))}}return r}function Oi(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var y=e[i],M=y.marker,j=y.to==null||(M.inclusiveRight?y.to>=t:y.to>t);if(j||y.from==t&&M.type=="bookmark"&&(!n||y.marker.insertLeft)){var K=y.from==null||(M.inclusiveLeft?y.from<=t:y.from<t);(r||(r=[])).push(new qr(M,K?null:y.from-t,y.to==null?null:y.to-t))}}return r}function En(e,t){if(t.full)return null;var n=kr(e,t.from.line)&&rt(e,t.from.line).markedSpans,r=kr(e,t.to.line)&&rt(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,y=t.to.ch,M=dt(t.from,t.to)==0,j=_i(n,i,M),K=Oi(r,y,M),z=t.text.length==1,Z=xe(t.text).length+(z?i:0);if(j)for(var ie=0;ie<j.length;++ie){var fe=j[ie];if(fe.to==null){var ce=Er(K,fe.marker);ce?z&&(fe.to=ce.to==null?null:ce.to+Z):fe.to=i}}if(K)for(var Te=0;Te<K.length;++Te){var Ae=K[Te];if(Ae.to!=null&&(Ae.to+=Z),Ae.from==null){var ke=Er(j,Ae.marker);ke||(Ae.from=Z,z&&(j||(j=[])).push(Ae))}else Ae.from+=Z,z&&(j||(j=[])).push(Ae)}j&&(j=Ri(j)),K&&K!=j&&(K=Ri(K));var Ue=[j];if(!z){var Xe=t.text.length-2,Ne;if(Xe>0&&j)for(var qe=0;qe<j.length;++qe)j[qe].to==null&&(Ne||(Ne=[])).push(new qr(j[qe].marker,null,null));for(var lt=0;lt<Xe;++lt)Ue.push(Ne);Ue.push(K)}return Ue}function Ri(e){for(var t=0;t<e.length;++t){var n=e[t];n.from!=null&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Pi(e,t,n){var r=null;if(e.iter(t.line,n.line+1,function(ce){if(ce.markedSpans)for(var Te=0;Te<ce.markedSpans.length;++Te){var Ae=ce.markedSpans[Te].marker;Ae.readOnly&&(!r||se(r,Ae)==-1)&&(r||(r=[])).push(Ae)}}),!r)return null;for(var i=[{from:t,to:n}],y=0;y<r.length;++y)for(var M=r[y],j=M.find(0),K=0;K<i.length;++K){var z=i[K];if(dt(z.to,j.from)<0||dt(z.from,j.to)>0)continue;var Z=[K,1],ie=dt(z.from,j.from),fe=dt(z.to,j.to);(ie<0||!M.inclusiveLeft&&!ie)&&Z.push({from:z.from,to:j.from}),(fe>0||!M.inclusiveRight&&!fe)&&Z.push({from:j.to,to:z.to}),i.splice.apply(i,Z),K+=Z.length-3}return i}function la(e){var t=e.markedSpans;if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}function xn(e,t){if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}function en(e){return e.inclusiveLeft?-1:0}function tn(e){return e.inclusiveRight?1:0}function Tn(e,t){var n=e.lines.length-t.lines.length;if(n!=0)return n;var r=e.find(),i=t.find(),y=dt(r.from,i.from)||en(e)-en(t);if(y)return-y;var M=dt(r.to,i.to)||tn(e)-tn(t);return M||t.id-e.id}function Mr(e,t){var n=$t&&e.markedSpans,r;if(n)for(var i=void 0,y=0;y<n.length;++y)i=n[y],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||Tn(r,i.marker)<0)&&(r=i.marker);return r}function Ir(e){return Mr(e,!0)}function Fr(e){return Mr(e,!1)}function Sn(e,t){var n=$t&&e.markedSpans,r;if(n)for(var i=0;i<n.length;++i){var y=n[i];y.marker.collapsed&&(y.from==null||y.from<t)&&(y.to==null||y.to>t)&&(!r||Tn(r,y.marker)<0)&&(r=y.marker)}return r}function ki(e,t,n,r,i){var y=rt(e,t),M=$t&&y.markedSpans;if(M)for(var j=0;j<M.length;++j){var K=M[j];if(!K.marker.collapsed)continue;var z=K.marker.find(0),Z=dt(z.from,n)||en(K.marker)-en(i),ie=dt(z.to,r)||tn(K.marker)-tn(i);if(Z>=0&&ie<=0||Z<=0&&ie>=0)continue;if(Z<=0&&(K.marker.inclusiveRight&&i.inclusiveLeft?dt(z.to,n)>=0:dt(z.to,n)>0)||Z>=0&&(K.marker.inclusiveRight&&i.inclusiveLeft?dt(z.from,r)<=0:dt(z.from,r)<0))return!0}}function ur(e){for(var t;t=Ir(e);)e=t.find(-1,!0).line;return e}function Mi(e){for(var t;t=Fr(e);)e=t.find(1,!0).line;return e}function wn(e){for(var t,n;t=Fr(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function Zn(e,t){var n=rt(e,t),r=ur(n);return n==r?t:Tt(r)}function Hr(e,t){if(t>e.lastLine())return t;var n=rt(e,t),r;if(!Ar(e,n))return t;for(;r=Fr(n);)n=r.find(1,!0).line;return Tt(n)+1}function Ar(e,t){var n=$t&&t.markedSpans;if(n)for(var r=void 0,i=0;i<n.length;++i){if(r=n[i],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&qn(e,t,r))return!0}}function qn(e,t,n){if(n.to==null){var r=n.marker.find(1,!0);return qn(e,r.line,Er(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i=void 0,y=0;y<t.markedSpans.length;++y)if(i=t.markedSpans[y],i.marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(i.to==null||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&qn(e,t,i))return!0}function xr(e){e=ur(e);for(var t=0,n=e.parent,r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var y=n.parent;y;n=y,y=n.parent)for(var M=0;M<y.children.length;++M){var j=y.children[M];if(j==n)break;t+=j.height}return t}function ei(e){if(e.height==0)return 0;for(var t=e.text.length,n,r=e;n=Ir(r);){var i=n.find(0,!0);r=i.from.line,t+=i.from.ch-i.to.ch}for(r=e;n=Fr(r);){var y=n.find(0,!0);t-=r.text.length-y.from.ch,r=y.to.line,t+=r.text.length-y.to.ch}return t}function Ii(e){var t=e.display,n=e.doc;t.maxLine=rt(n,n.first),t.maxLineLength=ei(t.maxLine),t.maxLineChanged=!0,n.iter(function(r){var i=ei(r);i>t.maxLineLength&&(t.maxLineLength=i,t.maxLine=r)})}var rn=function(e,t,n){this.text=e,xn(this,t),this.height=n?n(this):1};rn.prototype.lineNo=function(){return Tt(this)},re(rn);function ua(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),la(e),xn(e,n);var i=r?r(e):1;i!=e.height&&Zt(e,i)}function nt(e){e.parent=null,la(e)}var ct={},st={};function pt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?st:ct;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Et(e,t){var n=b("span",null,null,R?"padding-right: .1px":null),r={pre:b("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var y=i?t.rest[i-1]:t.line,M=void 0;r.pos=0,r.addToken=vt,xt(e.display.measure)&&(M=Ye(y,e.doc.direction))&&(r.addToken=qt(r.addToken,M)),r.map=[];var j=t!=e.display.externalMeasured&&Tt(y);Ur(y,r,Zr(e,y,j)),y.styleClasses&&(y.styleClasses.bgClass&&(r.bgClass=H(y.styleClasses.bgClass,r.bgClass||"")),y.styleClasses.textClass&&(r.textClass=H(y.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(it(e.display.measure))),i==0?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(R){var K=r.content.lastChild;(/\bcm-tab\b/.test(K.className)||K.querySelector&&K.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return ve(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=H(r.pre.className,r.textClass||"")),r}function At(e){var t=a("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function vt(e,t,n,r,i,y,M){if(!t)return;var j=e.splitSpaces?Ut(t,e.trailingSpace):t,K=e.cm.state.specialChars,z=!1,Z;if(!K.test(t))e.col+=t.length,Z=document.createTextNode(j),e.map.push(e.pos,e.pos+t.length,Z),U&&F<9&&(z=!0),e.pos+=t.length;else{Z=document.createDocumentFragment();for(var ie=0;;){K.lastIndex=ie;var fe=K.exec(t),ce=fe?fe.index-ie:t.length-ie;if(ce){var Te=document.createTextNode(j.slice(ie,ie+ce));U&&F<9?Z.appendChild(a("span",[Te])):Z.appendChild(Te),e.map.push(e.pos,e.pos+ce,Te),e.col+=ce,e.pos+=ce}if(!fe)break;ie+=ce+1;var Ae=void 0;if(fe[0]==" "){var ke=e.cm.options.tabSize,Ue=ke-e.col%ke;Ae=Z.appendChild(a("span",ue(Ue),"cm-tab")),Ae.setAttribute("role","presentation"),Ae.setAttribute("cm-text"," "),e.col+=Ue}else fe[0]=="\r"||fe[0]==`
|
|
`?(Ae=Z.appendChild(a("span",fe[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ae.setAttribute("cm-text",fe[0]),e.col+=1):(Ae=e.cm.options.specialCharPlaceholder(fe[0]),Ae.setAttribute("cm-text",fe[0]),U&&F<9?Z.appendChild(a("span",[Ae])):Z.appendChild(Ae),e.col+=1);e.map.push(e.pos,e.pos+1,Ae),e.pos++}}if(e.trailingSpace=j.charCodeAt(t.length-1)==32,n||r||i||z||y||M){var Xe=n||"";r&&(Xe+=r),i&&(Xe+=i);var Ne=a("span",[Z],Xe,y);if(M)for(var qe in M)M.hasOwnProperty(qe)&&qe!="style"&&qe!="class"&&Ne.setAttribute(qe,M[qe]);return e.content.appendChild(Ne)}e.content.appendChild(Z)}function Ut(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,r="",i=0;i<e.length;i++){var y=e.charAt(i);y==" "&&n&&(i==e.length-1||e.charCodeAt(i+1)==32)&&(y="\xA0"),r+=y,n=y==" "}return r}function qt(e,t){return function(n,r,i,y,M,j,K){i=i?i+" cm-force-border":"cm-force-border";for(var z=n.pos,Z=z+r.length;;){for(var ie=void 0,fe=0;fe<t.length&&!(ie=t[fe],ie.to>z&&ie.from<=z);fe++);if(ie.to>=Z)return e(n,r,i,y,M,j,K);e(n,r.slice(0,ie.to-z),i,y,null,j,K),y=null,r=r.slice(ie.to-z),z=ie.to}}}function gt(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function Ur(e,t,n){var r=e.markedSpans,i=e.text,y=0;if(!r){for(var M=1;M<n.length;M+=2)t.addToken(t,i.slice(y,y=n[M]),pt(n[M+1],t.cm.options));return}for(var j=i.length,K=0,z=1,Z="",ie,fe,ce=0,Te,Ae,ke,Ue,Xe;;){if(ce==K){Te=Ae=ke=fe="",Xe=null,Ue=null,ce=Infinity;for(var Ne=[],qe=void 0,lt=0;lt<r.length;++lt){var at=r[lt],mt=at.marker;if(mt.type=="bookmark"&&at.from==K&&mt.widgetNode)Ne.push(mt);else if(at.from<=K&&(at.to==null||at.to>K||mt.collapsed&&at.to==K&&at.from==K)){if(at.to!=null&&at.to!=K&&ce>at.to&&(ce=at.to,Ae=""),mt.className&&(Te+=" "+mt.className),mt.css&&(fe=(fe?fe+";":"")+mt.css),mt.startStyle&&at.from==K&&(ke+=" "+mt.startStyle),mt.endStyle&&at.to==ce&&(qe||(qe=[])).push(mt.endStyle,at.to),mt.title&&((Xe||(Xe={})).title=mt.title),mt.attributes)for(var Dt in mt.attributes)(Xe||(Xe={}))[Dt]=mt.attributes[Dt];mt.collapsed&&(!Ue||Tn(Ue.marker,mt)<0)&&(Ue=at)}else at.from>K&&ce>at.from&&(ce=at.from)}if(qe)for(var Ht=0;Ht<qe.length;Ht+=2)qe[Ht+1]==ce&&(Ae+=" "+qe[Ht]);if(!Ue||Ue.from==K)for(var Ot=0;Ot<Ne.length;++Ot)gt(t,0,Ne[Ot]);if(Ue&&(Ue.from||0)==K){if(gt(t,(Ue.to==null?j+1:Ue.to)-K,Ue.marker,Ue.from==null),Ue.to==null)return;Ue.to==K&&(Ue=!1)}}if(K>=j)break;for(var sr=Math.min(j,ce);;){if(Z){var nr=K+Z.length;if(!Ue){var Mt=nr>sr?Z.slice(0,sr-K):Z;t.addToken(t,Mt,ie?ie+Te:Te,ke,K+Mt.length==ce?Ae:"",fe,Xe)}if(nr>=sr){Z=Z.slice(sr-K),K=sr;break}K=nr,ke=""}Z=i.slice(y,y=n[z++]),ie=pt(n[z++],t.cm.options)}}}function St(e,t,n){this.line=t,this.rest=wn(t),this.size=this.rest?Tt(xe(this.rest))-n+1:1,this.node=this.text=null,this.hidden=Ar(e,t)}function er(e,t,n){for(var r=[],i,y=t;y<n;y=i){var M=new St(e.doc,rt(e.doc,y),y);i=y+M.size,r.push(M)}return r}var Vt=null;function mr(e){Vt?Vt.ops.push(e):e.ownsGroup=Vt={ops:[e],delayedCallbacks:[]}}function Os(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(n<t.length)}function Rs(e,t){var n=e.ownsGroup;if(!n)return;try{Os(n)}finally{Vt=null,t(n)}}var ti=null;function Gt(e,t){var n=Ze(e,t);if(!n.length)return;var r=Array.prototype.slice.call(arguments,2),i;Vt?i=Vt.delayedCallbacks:ti?i=ti:(i=ti=[],setTimeout(Ps,0));for(var y=function(j){i.push(function(){return n[j].apply(null,r)})},M=0;M<n.length;++M)y(M)}function Ps(){var e=ti;ti=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,n,r){for(var i=0;i<t.changes.length;i++){var y=t.changes[i];y=="text"?Ms(e,t):y=="gutter"?Ja(e,t,n,r):y=="class"?da(e,t):y=="widget"&&Is(e,t,r)}t.changes=null}function ri(e){return e.node==e.text&&(e.node=a("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),U&&F<8&&(e.node.style.zIndex=2)),e.node}function ks(e,t){var n=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),t.background)n?t.background.className=n:(t.background.parentNode.removeChild(t.background),t.background=null);else if(n){var r=ri(t);t.background=r.insertBefore(a("div",null,n),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Et(e,t)}function Ms(e,t){var n=t.text.className,r=$a(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,da(e,t)):n&&(t.text.className=n)}function da(e,t){ks(e,t),t.line.wrapClass?ri(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var n=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=n||""}function Ja(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=ri(t);t.gutterBackground=a("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),i.insertBefore(t.gutterBackground,t.text)}var y=t.line.gutterMarkers;if(e.options.lineNumbers||y){var M=ri(t),j=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(j),M.insertBefore(j,t.text),t.line.gutterClass&&(j.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!y||!y["CodeMirror-linenumbers"])&&(t.lineNumber=j.appendChild(a("div",pn(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),y)for(var K=0;K<e.display.gutterSpecs.length;++K){var z=e.display.gutterSpecs[K].className,Z=y.hasOwnProperty(z)&&y[z];Z&&j.appendChild(a("div",[Z],"CodeMirror-gutter-elt","left: "+r.gutterLeft[z]+"px; width: "+r.gutterWidth[z]+"px"))}}}function Is(e,t,n){t.alignable&&(t.alignable=null);for(var r=p("CodeMirror-linewidget"),i=t.node.firstChild,y=void 0;i;i=y)y=i.nextSibling,r.test(i.className)&&t.node.removeChild(i);Qa(e,t,n)}function Fs(e,t,n,r){var i=$a(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),da(e,t),Ja(e,t,n,r),Qa(e,t,r),t.node}function Qa(e,t,n){if(Za(e,t.line,t,n,!0),t.rest)for(var r=0;r<t.rest.length;r++)Za(e,t.rest[r],t,n,!1)}function Za(e,t,n,r,i){if(!t.widgets)return;for(var y=ri(n),M=0,j=t.widgets;M<j.length;++M){var K=j[M],z=a("div",[K.node],"CodeMirror-linewidget"+(K.className?" "+K.className:""));K.handleMouseEvents||z.setAttribute("cm-ignore-events","true"),Us(K,z,n,r),e.display.input.setUneditable(z),i&&K.above?y.insertBefore(z,n.gutter||n.text):y.appendChild(z),Gt(K,"redraw")}}function Us(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function ni(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!x(document.body,e.node)){var n="position: relative;";e.coverGutter&&(n+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(n+="width: "+t.display.wrapper.clientWidth+"px;"),d(t.display.measure,a("div",[e.node],null,n))}return e.height=e.node.parentNode.offsetHeight}function Nr(e,t){for(var n=le(t);n!=e.wrapper;n=n.parentNode)if(!n||n.nodeType==1&&n.getAttribute("cm-ignore-events")=="true"||n.parentNode==e.sizer&&n!=e.mover)return!0}function Fi(e){return e.lineSpace.offsetTop}function ca(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=d(e.measure,a("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function Dr(e){return de-e.display.nativeBarWidth}function nn(e){return e.display.scroller.clientWidth-Dr(e)-e.display.barWidth}function fa(e){return e.display.scroller.clientHeight-Dr(e)-e.display.barHeight}function Ns(e,t,n){var r=e.options.lineWrapping,i=r&&nn(e);if(!t.measure.heights||r&&t.measure.width!=i){var y=t.measure.heights=[];if(r){t.measure.width=i;for(var M=t.text.firstChild.getClientRects(),j=0;j<M.length-1;j++){var K=M[j],z=M[j+1];Math.abs(K.bottom-z.bottom)>2&&y.push((K.bottom+z.top)/2-n.top)}}y.push(n.bottom-n.top)}}function eo(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var i=0;i<e.rest.length;i++)if(Tt(e.rest[i])>n)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Bs(e,t){t=ur(t);var n=Tt(t),r=e.display.externalMeasured=new St(e.doc,t,n);r.lineN=n;var i=r.built=Et(e,r);return r.text=i.pre,d(e.display.lineMeasure,i.pre),r}function to(e,t,n,r){return _r(e,Cn(e,t),n,r)}function ha(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[sn(e,t)];var n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size)return n}function Cn(e,t){var n=Tt(t),r=ha(e,n);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,n,ba(e)),e.curOp.forceUpdate=!0),r||(r=Bs(e,t));var i=eo(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function _r(e,t,n,r,i){t.before&&(n=-1);var y=n+(r||""),M;return t.cache.hasOwnProperty(y)?M=t.cache[y]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Ns(e,t.view,t.rect),t.hasHeights=!0),M=Ws(e,t,n,r),M.bogus||(t.cache[y]=M)),{left:M.left,right:M.right,top:i?M.rtop:M.top,bottom:i?M.rbottom:M.bottom}}var ro={left:0,right:0,top:0,bottom:0};function no(e,t,n){for(var r,i,y,M,j,K,z=0;z<e.length;z+=3)if(j=e[z],K=e[z+1],t<j?(i=0,y=1,M="left"):t<K?(i=t-j,y=i+1):(z==e.length-3||t==K&&e[z+3]>t)&&(y=K-j,i=y-1,t>=K&&(M="right")),i!=null){if(r=e[z+2],j==K&&n==(r.insertLeft?"left":"right")&&(M=n),n=="left"&&i==0)for(;z&&e[z-2]==e[z-3]&&e[z-1].insertLeft;)r=e[(z-=3)+2],M="left";if(n=="right"&&i==K-j)for(;z<e.length-3&&e[z+3]==e[z+4]&&!e[z+5].insertLeft;)r=e[(z+=3)+2],M="right";break}return{node:r,start:i,end:y,collapse:M,coverStart:j,coverEnd:K}}function js(e,t){var n=ro;if(t=="left")for(var r=0;r<e.length&&!((n=e[r]).left!=n.right);r++);else for(var i=e.length-1;i>=0&&!((n=e[i]).left!=n.right);i--);return n}function Ws(e,t,n,r){var i=no(t.map,n,r),y=i.node,M=i.start,j=i.end,K=i.collapse,z;if(y.nodeType==3){for(var Z=0;Z<4;Z++){for(;M&&_e(t.line.text.charAt(i.coverStart+M));)--M;for(;i.coverStart+j<i.coverEnd&&_e(t.line.text.charAt(i.coverStart+j));)++j;if(U&&F<9&&M==0&&j==i.coverEnd-i.coverStart?z=y.parentNode.getBoundingClientRect():z=js(g(y,M,j).getClientRects(),r),z.left||z.right||M==0)break;j=M,M=M-1,K="right"}U&&F<11&&(z=Hs(e.display.measure,z))}else{M>0&&(K=r="right");var ie;e.options.lineWrapping&&(ie=y.getClientRects()).length>1?z=ie[r=="right"?ie.length-1:0]:z=y.getBoundingClientRect()}if(U&&F<9&&!M&&(!z||!z.left&&!z.right)){var fe=y.parentNode.getClientRects()[0];fe?z={left:fe.left,right:fe.left+An(e.display),top:fe.top,bottom:fe.bottom}:z=ro}for(var ce=z.top-t.rect.top,Te=z.bottom-t.rect.top,Ae=(ce+Te)/2,ke=t.view.measure.heights,Ue=0;Ue<ke.length-1&&!(Ae<ke[Ue]);Ue++);var Xe=Ue?ke[Ue-1]:0,Ne=ke[Ue],qe={left:(K=="right"?z.right:z.left)-t.rect.left,right:(K=="left"?z.left:z.right)-t.rect.left,top:Xe,bottom:Ne};return!z.left&&!z.right&&(qe.bogus=!0),e.options.singleCursorHeightPerLine||(qe.rtop=ce,qe.rbottom=Te),qe}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Bt(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function io(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function ao(e){e.display.externalMeasure=null,f(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)io(e.display.view[t])}function ii(e){ao(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function oo(){return v&&l?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return v&&l?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function ma(e){var t=0;if(e.widgets)for(var n=0;n<e.widgets.length;++n)e.widgets[n].above&&(t+=ni(e.widgets[n]));return t}function Ui(e,t,n,r,i){if(!i){var y=ma(t);n.top+=y,n.bottom+=y}if(r=="line")return n;r||(r="local");var M=xr(t);if(r=="local"?M+=Fi(e.display):M-=e.display.viewOffset,r=="page"||r=="window"){var j=e.display.lineSpace.getBoundingClientRect();M+=j.top+(r=="window"?0:so());var K=j.left+(r=="window"?0:oo());n.left+=K,n.right+=K}return n.top+=M,n.bottom+=M,n}function lo(e,t,n){if(n=="div")return t;var r=t.left,i=t.top;if(n=="page")r-=oo(),i-=so();else if(n=="local"||!n){var y=e.display.sizer.getBoundingClientRect();r+=y.left,i+=y.top}var M=e.display.lineSpace.getBoundingClientRect();return{left:r-M.left,top:i-M.top}}function pa(e,t,n,r,i){return r||(r=rt(e.doc,t.line)),Ui(e,r,to(e,r,t.ch,i),n)}function Tr(e,t,n,r,i,y){r=r||rt(e.doc,t.line),i||(i=Cn(e,r));function M(Te,Ae){var ke=_r(e,i,Te,Ae?"right":"left",y);return Ae?ke.left=ke.right:ke.right=ke.left,Ui(e,r,ke,n)}var j=Ye(r,e.doc.direction),K=t.ch,z=t.sticky;if(K>=r.text.length?(K=r.text.length,z="before"):K<=0&&(K=0,z="after"),!j)return M(z=="before"?K-1:K,z=="before");function Z(Te,Ae,ke){var Ue=j[Ae],Xe=Ue.level==1;return M(ke?Te-1:Te,Xe!=ke)}var ie=He(j,K,z),fe=We,ce=Z(K,ie,z=="before");return fe!=null&&(ce.other=Z(K,fe,z!="before")),ce}function uo(e,t){var n=0;t=ft(e.doc,t),e.options.lineWrapping||(n=An(e.display)*t.ch);var r=rt(e.doc,t.line),i=xr(r)+Fi(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function ga(e,t,n,r,i){var y=Oe(e,t,n);return y.xRel=i,r&&(y.outside=r),y}function va(e,t,n){var r=e.doc;if(n+=e.display.viewOffset,n<0)return ga(r.first,0,null,-1,-1);var i=gr(r,n),y=r.first+r.size-1;if(i>y)return ga(r.first+r.size-1,rt(r,y).text.length,null,1,1);t<0&&(t=0);for(var M=rt(r,i);;){var j=Ks(e,M,i,t,n),K=Sn(M,j.ch+(j.xRel>0||j.outside>0?1:0));if(!K)return j;var z=K.find(1);if(z.line==i)return z;M=rt(r,i=z.line)}}function co(e,t,n,r){r-=ma(t);var i=t.text.length,y=$e(function(M){return _r(e,n,M-1).bottom<=r},i,0);return i=$e(function(M){return _r(e,n,M).top>r},y,i),{begin:y,end:i}}function fo(e,t,n,r){n||(n=Cn(e,t));var i=Ui(e,t,_r(e,n,r),"line").top;return co(e,t,n,i)}function ya(e,t,n,r){return e.bottom<=n?!1:e.top>n?!0:(r?e.left:e.right)>t}function Ks(e,t,n,r,i){i-=xr(t);var y=Cn(e,t),M=ma(t),j=0,K=t.text.length,z=!0,Z=Ye(t,e.doc.direction);if(Z){var ie=(e.options.lineWrapping?zs:Gs)(e,t,n,y,Z,r,i);z=ie.level!=1,j=z?ie.from:ie.to-1,K=z?ie.to:ie.from-1}var fe=null,ce=null,Te=$e(function(lt){var at=_r(e,y,lt);return at.top+=M,at.bottom+=M,ya(at,r,i,!1)?(at.top<=i&&at.left<=r&&(fe=lt,ce=at),!0):!1},j,K),Ae,ke,Ue=!1;if(ce){var Xe=r-ce.left<ce.right-r,Ne=Xe==z;Te=fe+(Ne?0:1),ke=Ne?"after":"before",Ae=Xe?ce.left:ce.right}else{!z&&(Te==K||Te==j)&&Te++,ke=Te==0?"after":Te==t.text.length?"before":_r(e,y,Te-(z?1:0)).bottom+M<=i==z?"after":"before";var qe=Tr(e,Oe(n,Te,ke),"line",t,y);Ae=qe.left,Ue=i<qe.top?-1:i>=qe.bottom?1:0}return Te=Le(t.text,Te,1),ga(n,Te,ke,Ue,r-Ae)}function Gs(e,t,n,r,i,y,M){var j=$e(function(ie){var fe=i[ie],ce=fe.level!=1;return ya(Tr(e,Oe(n,ce?fe.to:fe.from,ce?"before":"after"),"line",t,r),y,M,!0)},0,i.length-1),K=i[j];if(j>0){var z=K.level!=1,Z=Tr(e,Oe(n,z?K.from:K.to,z?"after":"before"),"line",t,r);ya(Z,y,M,!0)&&Z.top>M&&(K=i[j-1])}return K}function zs(e,t,n,r,i,y,M){var j=co(e,t,r,M),K=j.begin,z=j.end;/\s/.test(t.text.charAt(z-1))&&z--;for(var Z=null,ie=null,fe=0;fe<i.length;fe++){var ce=i[fe];if(ce.from>=z||ce.to<=K)continue;var Te=ce.level!=1,Ae=_r(e,r,Te?Math.min(z,ce.to)-1:Math.max(K,ce.from)).right,ke=Ae<y?y-Ae+1e9:Ae-y;(!Z||ie>ke)&&(Z=ce,ie=ke)}return Z||(Z=i[i.length-1]),Z.from<K&&(Z={from:K,to:Z.to,level:Z.level}),Z.to>z&&(Z={from:Z.from,to:z,level:Z.level}),Z}var an;function Ln(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(an==null){an=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)an.appendChild(document.createTextNode("x")),an.appendChild(a("br"));an.appendChild(document.createTextNode("x"))}d(e.measure,an);var n=an.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),f(e.measure),n||1}function An(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),n=a("pre",[t],"CodeMirror-line-like");d(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function ba(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,y=t.gutters.firstChild,M=0;y;y=y.nextSibling,++M){var j=e.display.gutterSpecs[M].className;n[j]=y.offsetLeft+y.clientLeft+i,r[j]=y.clientWidth}return{fixedPos:Ea(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Ea(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function ho(e){var t=Ln(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/An(e.display)-3);return function(i){if(Ar(e.doc,i))return 0;var y=0;if(i.widgets)for(var M=0;M<i.widgets.length;M++)i.widgets[M].height&&(y+=i.widgets[M].height);return n?y+(Math.ceil(i.text.length/r)||1)*t:y+t}}function xa(e){var t=e.doc,n=ho(e);t.iter(function(r){var i=n(r);i!=r.height&&Zt(r,i)})}function on(e,t,n,r){var i=e.display;if(!n&&le(t).getAttribute("cm-not-content")=="true")return null;var y,M,j=i.lineSpace.getBoundingClientRect();try{y=t.clientX-j.left,M=t.clientY-j.top}catch(ie){return null}var K=va(e,y,M),z;if(r&&K.xRel>0&&(z=rt(e.doc,K.line).text).length==K.ch){var Z=Y(z,z.length,e.options.tabSize)-z.length;K=Oe(K.line,Math.max(0,Math.round((y-qa(e.display).left)/An(e.display))-Z))}return K}function sn(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var n=e.display.view,r=0;r<n.length;r++)if(t-=n[r].size,t<0)return r}function tr(e,t,n,r){t==null&&(t=e.doc.first),n==null&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;if(r&&n<i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)$t&&Zn(e.doc,t)<i.viewTo&&Gr(e);else if(n<=i.viewFrom)$t&&Hr(e.doc,n+r)>i.viewFrom?Gr(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Gr(e);else if(t<=i.viewFrom){var y=Ni(e,n,n+r,1);y?(i.view=i.view.slice(y.index),i.viewFrom=y.lineN,i.viewTo+=r):Gr(e)}else if(n>=i.viewTo){var M=Ni(e,t,t,-1);M?(i.view=i.view.slice(0,M.index),i.viewTo=M.lineN):Gr(e)}else{var j=Ni(e,t,t,-1),K=Ni(e,n,n+r,1);j&&K?(i.view=i.view.slice(0,j.index).concat(er(e,j.lineN,K.lineN)).concat(i.view.slice(K.index)),i.viewTo+=r):Gr(e)}var z=i.externalMeasured;z&&(n<z.lineN?z.lineN+=r:t<z.lineN+z.size&&(i.externalMeasured=null))}function Kr(e,t,n){e.curOp.viewChanged=!0;var r=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;var y=r.view[sn(e,t)];if(y.node==null)return;var M=y.changes||(y.changes=[]);se(M,n)==-1&&M.push(n)}function Gr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Ni(e,t,n,r){var i=sn(e,t),y,M=e.display.view;if(!$t||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var j=e.display.viewFrom,K=0;K<i;K++)j+=M[K].size;if(j!=t){if(r>0){if(i==M.length-1)return null;y=j+M[i].size-t,i++}else y=j-t;t+=y,n+=y}for(;Zn(e.doc,n)!=n;){if(i==(r<0?0:M.length-1))return null;n+=r*M[i-(r<0?1:0)].size,i+=r}return{index:i,lineN:n}}function Vs(e,t,n){var r=e.display,i=r.view;i.length==0||t>=r.viewTo||n<=r.viewFrom?(r.view=er(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=er(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(sn(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(er(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,sn(e,n)))),r.viewTo=n}function mo(e){for(var t=e.display.view,n=0,r=0;r<t.length;r++){var i=t[r];!i.hidden&&(!i.node||i.changes)&&++n}return n}function ai(e){e.display.input.showSelection(e.display.input.prepareSelection())}function po(e,t){t===void 0&&(t=!0);for(var n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),y=r.selection=document.createDocumentFragment(),M=0;M<n.sel.ranges.length;M++){if(!t&&M==n.sel.primIndex)continue;var j=n.sel.ranges[M];if(j.from().line>=e.display.viewTo||j.to().line<e.display.viewFrom)continue;var K=j.empty();(K||e.options.showCursorWhenSelecting)&&go(e,j.head,i),K||Xs(e,j,y)}return r}function go(e,t,n){var r=Tr(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(a("div","\xA0","CodeMirror-cursor"));if(i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var y=n.appendChild(a("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));y.style.display="",y.style.left=r.other.left+"px",y.style.top=r.other.top+"px",y.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Bi(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,n){var r=e.display,i=e.doc,y=document.createDocumentFragment(),M=qa(e.display),j=M.left,K=Math.max(r.sizerWidth,nn(e)-r.sizer.offsetLeft)-M.right,z=i.direction=="ltr";function Z(Ne,qe,lt,at){qe<0&&(qe=0),qe=Math.round(qe),at=Math.round(at),y.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+Ne+`px;
|
|
top: `+qe+"px; width: "+(lt==null?K-Ne:lt)+`px;
|
|
height: `+(at-qe)+"px"))}function ie(Ne,qe,lt){var at=rt(i,Ne),mt=at.text.length,Dt,Ht;function Ot(Mt,ir){return pa(e,Oe(Ne,Mt),"div",at,ir)}function sr(Mt,ir,zt){var Nt=fo(e,at,null,Mt),It=ir=="ltr"==(zt=="after")?"left":"right",Pt=zt=="after"?Nt.begin:Nt.end-(/\s/.test(at.text.charAt(Nt.end-1))?2:1);return Ot(Pt,It)[It]}var nr=Ye(at,i.direction);return Je(nr,qe||0,lt==null?mt:lt,function(Mt,ir,zt,Nt){var It=zt=="ltr",Pt=Ot(Mt,It?"left":"right"),ar=Ot(ir-1,It?"right":"left"),jn=qe==null&&Mt==0,Jr=lt==null&&ir==mt,Yt=Nt==0,Or=!nr||Nt==nr.length-1;if(ar.top-Pt.top<=3){var Kt=(z?jn:Jr)&&Yt,Va=(z?Jr:jn)&&Or,jr=Kt?j:(It?Pt:ar).left,fn=Va?K:(It?ar:Pt).right;Z(jr,Pt.top,fn-jr,Pt.bottom)}else{var hn,Qt,Wn,Xa;It?(hn=z&&jn&&Yt?j:Pt.left,Qt=z?K:sr(Mt,zt,"before"),Wn=z?j:sr(ir,zt,"after"),Xa=z&&Jr&&Or?K:ar.right):(hn=z?sr(Mt,zt,"before"):j,Qt=!z&&jn&&Yt?K:Pt.right,Wn=!z&&Jr&&Or?j:ar.left,Xa=z?sr(ir,zt,"after"):K),Z(hn,Pt.top,Qt-hn,Pt.bottom),Pt.bottom<ar.top&&Z(j,Pt.bottom,null,ar.top),Z(Wn,ar.top,Xa-Wn,ar.bottom)}(!Dt||Bi(Pt,Dt)<0)&&(Dt=Pt),Bi(ar,Dt)<0&&(Dt=ar),(!Ht||Bi(Pt,Ht)<0)&&(Ht=Pt),Bi(ar,Ht)<0&&(Ht=ar)}),{start:Dt,end:Ht}}var fe=t.from(),ce=t.to();if(fe.line==ce.line)ie(fe.line,fe.ch,ce.ch);else{var Te=rt(i,fe.line),Ae=rt(i,ce.line),ke=ur(Te)==ur(Ae),Ue=ie(fe.line,fe.ch,ke?Te.text.length+1:null).end,Xe=ie(ce.line,ke?0:null,ce.ch).start;ke&&(Ue.top<Xe.top-2?(Z(Ue.right,Ue.top,null,Ue.bottom),Z(j,Xe.top,Xe.left,Xe.bottom)):Z(Ue.right,Ue.top,Xe.left-Ue.right,Ue.bottom)),Ue.bottom<Xe.top&&Z(j,Ue.bottom,null,Xe.top)}n.appendChild(y)}function Ta(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Dn(e),t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Sa(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Dn(e))},100)}function Sa(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(ve(e,"focus",e,t),e.state.focused=!0,N(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),R&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Ta(e)}function Dn(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(ve(e,"blur",e,t),e.state.focused=!1,c(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function ji(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var i=t.view[r],y=e.options.lineWrapping,M=void 0,j=0;if(i.hidden)continue;if(U&&F<8){var K=i.node.offsetTop+i.node.offsetHeight;M=K-n,n=K}else{var z=i.node.getBoundingClientRect();M=z.bottom-z.top,!y&&i.text.firstChild&&(j=i.text.firstChild.getBoundingClientRect().right-z.left-1)}var Z=i.line.height-M;if((Z>.005||Z<-.005)&&(Zt(i.line,M),bo(i.line),i.rest))for(var ie=0;ie<i.rest.length;ie++)bo(i.rest[ie]);if(j>e.display.sizerWidth){var fe=Math.ceil(j/An(e.display));fe>e.display.maxLineLength&&(e.display.maxLineLength=fe,e.display.maxLine=i.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var n=e.widgets[t],r=n.node.parentNode;r&&(n.height=r.offsetHeight)}}function Wi(e,t,n){var r=n&&n.top!=null?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Fi(e));var i=n&&n.bottom!=null?n.bottom:r+e.wrapper.clientHeight,y=gr(t,r),M=gr(t,i);if(n&&n.ensure){var j=n.ensure.from.line,K=n.ensure.to.line;j<y?(y=j,M=gr(t,xr(rt(t,j))+e.wrapper.clientHeight)):Math.min(K,t.lastLine())>=M&&(y=gr(t,xr(rt(t,K))-e.wrapper.clientHeight),M=K)}return{from:y,to:Math.max(M,y+1)}}function Ys(e,t){if(Ee(e,"scrollCursorIntoView"))return;var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),i!=null&&!T){var y=a("div","\u200B",null,`position: absolute;
|
|
top: `+(t.top-n.viewOffset-Fi(e.display))+`px;
|
|
height: `+(t.bottom-t.top+Dr(e)+n.barHeight)+`px;
|
|
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(y),y.scrollIntoView(i),e.display.lineSpace.removeChild(y)}}function $s(e,t,n,r){r==null&&(r=0);var i;!e.options.lineWrapping&&t==n&&(t=t.ch?Oe(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,n=t.sticky=="before"?Oe(t.line,t.ch+1,"before"):t);for(var y=0;y<5;y++){var M=!1,j=Tr(e,t),K=!n||n==t?j:Tr(e,n);i={left:Math.min(j.left,K.left),top:Math.min(j.top,K.top)-r,right:Math.max(j.left,K.left),bottom:Math.max(j.bottom,K.bottom)+r};var z=wa(e,i),Z=e.doc.scrollTop,ie=e.doc.scrollLeft;if(z.scrollTop!=null&&(si(e,z.scrollTop),Math.abs(e.doc.scrollTop-Z)>1&&(M=!0)),z.scrollLeft!=null&&(ln(e,z.scrollLeft),Math.abs(e.doc.scrollLeft-ie)>1&&(M=!0)),!M)break}return i}function Js(e,t){var n=wa(e,t);n.scrollTop!=null&&si(e,n.scrollTop),n.scrollLeft!=null&&ln(e,n.scrollLeft)}function wa(e,t){var n=e.display,r=Ln(e.display);t.top<0&&(t.top=0);var i=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:n.scroller.scrollTop,y=fa(e),M={};t.bottom-t.top>y&&(t.bottom=t.top+y);var j=e.doc.height+ca(n),K=t.top<r,z=t.bottom>j-r;if(t.top<i)M.scrollTop=K?0:t.top;else if(t.bottom>i+y){var Z=Math.min(t.top,(z?j:t.bottom)-y);Z!=i&&(M.scrollTop=Z)}var ie=e.options.fixedGutter?0:n.gutters.offsetWidth,fe=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:n.scroller.scrollLeft-ie,ce=nn(e)-n.gutters.offsetWidth,Te=t.right-t.left>ce;return Te&&(t.right=t.left+ce),t.left<10?M.scrollLeft=0:t.left<fe?M.scrollLeft=Math.max(0,t.left+ie-(Te?0:10)):t.right>ce+fe-3&&(M.scrollLeft=t.right+(Te?0:10)-ce),M}function Ca(e,t){if(t==null)return;Hi(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function _n(e){Hi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function oi(e,t,n){(t!=null||n!=null)&&Hi(e),t!=null&&(e.curOp.scrollLeft=t),n!=null&&(e.curOp.scrollTop=n)}function Qs(e,t){Hi(e),e.curOp.scrollToPos=t}function Hi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=uo(e,t.from),r=uo(e,t.to);Eo(e,n,r,t.margin)}}function Eo(e,t,n,r){var i=wa(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});oi(e,i.scrollLeft,i.scrollTop)}function si(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;A||Aa(e,{top:t}),xo(e,t,!0),A&&Aa(e),di(e,100)}function xo(e,t,n){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!n)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function ln(e,t,n,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,Lo(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function li(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+ca(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Dr(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var un=function(e,t,n){this.cm=n;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),be(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),be(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,U&&F<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};un.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var y=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+y)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(r==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},un.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},un.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},un.prototype.zeroWidthHack=function(){var e=s&&!C?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new te,this.disableVert=new te},un.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto";function r(){var i=e.getBoundingClientRect(),y=n=="vert"?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1);y!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},un.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var ui=function(){};ui.prototype.update=function(){return{bottom:0,right:0}},ui.prototype.setScrollLeft=function(){},ui.prototype.setScrollTop=function(){},ui.prototype.clear=function(){};function On(e,t){t||(t=li(e));var n=e.display.barWidth,r=e.display.barHeight;To(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&ji(e),To(e,li(e)),n=e.display.barWidth,r=e.display.barHeight}function To(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}var So={native:un,null:ui};function wo(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&c(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new So[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),be(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,n){n=="horizontal"?ln(e,t):si(e,t)},e),e.display.scrollbars.addClass&&N(e.display.wrapper,e.display.scrollbars.addClass)}var Zs=0;function dn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Zs},mr(e.curOp)}function cn(e){var t=e.curOp;t&&Rs(t,function(n){for(var r=0;r<n.ops.length;r++)n.ops[r].cm.curOp=null;qs(n)})}function qs(e){for(var t=e.ops,n=0;n<t.length;n++)el(t[n]);for(var r=0;r<t.length;r++)tl(t[r]);for(var i=0;i<t.length;i++)rl(t[i]);for(var y=0;y<t.length;y++)nl(t[y]);for(var M=0;M<t.length;M++)il(t[M])}function el(e){var t=e.cm,n=t.display;ol(t),e.updateMaxLine&&Ii(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Ki(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&La(e.cm,e.update)}function rl(e){var t=e.cm,n=t.display;e.updatedDisplay&&ji(t),e.barMeasure=li(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Dr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-nn(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function nl(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&ln(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var n=e.focus&&e.focus==P();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,n),(e.updatedDisplay||e.startHeight!=t.doc.height)&&On(t,e.barMeasure),e.updatedDisplay&&_a(t,e.barMeasure),e.selectionChanged&&Ta(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),n&&vo(e.cm)}function il(e){var t=e.cm,n=t.display,r=t.doc;if(e.updatedDisplay&&Co(t,e.update),n.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(n.wheelStartX=n.wheelStartY=null),e.scrollTop!=null&&xo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&ln(t,e.scrollLeft,!0,!0),e.scrollToPos){var i=$s(t,ft(r,e.scrollToPos.from),ft(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,i)}var y=e.maybeHiddenMarkers,M=e.maybeUnhiddenMarkers;if(y)for(var j=0;j<y.length;++j)y[j].lines.length||ve(y[j],"hide");if(M)for(var K=0;K<M.length;++K)M[K].lines.length&&ve(M[K],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&ve(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function or(e,t){if(e.curOp)return t();dn(e);try{return t()}finally{cn(e)}}function jt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);dn(e);try{return t.apply(e,arguments)}finally{cn(e)}}}function Jt(e){return function(){if(this.curOp)return e.apply(this,arguments);dn(this);try{return e.apply(this,arguments)}finally{cn(this)}}}function Wt(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);dn(t);try{return e.apply(this,arguments)}finally{cn(t)}}}function di(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,B(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var n=+new Date+e.options.workTime,r=vr(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(y){if(r.line>=e.display.viewFrom){var M=y.styles,j=y.text.length>e.options.maxHighlightLength?Lr(t.mode,r.state):null,K=zn(e,y,r,!0);j&&(r.state=j),y.styles=K.styles;var z=y.styleClasses,Z=K.classes;Z?y.styleClasses=Z:z&&(y.styleClasses=null);for(var ie=!M||M.length!=y.styles.length||z!=Z&&(!z||!Z||z.bgClass!=Z.bgClass||z.textClass!=Z.textClass),fe=0;!ie&&fe<M.length;++fe)ie=M[fe]!=y.styles[fe];ie&&i.push(r.line),y.stateAfter=r.save(),r.nextLine()}else y.text.length<=e.options.maxHighlightLength&&Vn(e,y.text,r),y.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>n)return di(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),i.length&&or(e,function(){for(var y=0;y<i.length;y++)Kr(e,i[y],"text")})}var Ki=function(e,t,n){var r=e.display;this.viewport=t,this.visible=Wi(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=nn(e),this.force=n,this.dims=ba(e),this.events=[]};Ki.prototype.signal=function(e,t){ee(e,t)&&this.events.push(arguments)},Ki.prototype.finish=function(){for(var e=0;e<this.events.length;e++)ve.apply(null,this.events[e])};function ol(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Dr(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Dr(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=P();if(!t||!x(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&x(e.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}function ll(e){if(!e||!e.activeElt||e.activeElt==P())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&x(document.body,e.anchorNode)&&x(document.body,e.focusNode)){var t=window.getSelection(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}function La(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return Gr(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&mo(e)==0)return!1;Ao(e)&&(Gr(e),t.dims=ba(e));var i=r.first+r.size,y=Math.max(t.visible.from-e.options.viewportMargin,r.first),M=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<y&&y-n.viewFrom<20&&(y=Math.max(r.first,n.viewFrom)),n.viewTo>M&&n.viewTo-M<20&&(M=Math.min(i,n.viewTo)),$t&&(y=Zn(e.doc,y),M=Hr(e.doc,M));var j=y!=n.viewFrom||M!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Vs(e,y,M),n.viewOffset=xr(rt(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var K=mo(e);if(!j&&K==0&&!t.force&&n.renderedView==n.view&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return!1;var z=sl(e);return K>4&&(n.lineDiv.style.display="none"),ul(e,n.updateLineNumbers,t.dims),K>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,ll(z),f(n.cursorDiv),f(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,j&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,di(e,400)),n.updateLineNumbers=null,!0}function Co(e,t){for(var n=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==nn(e)){if(n&&n.top!=null&&(n={top:Math.min(e.doc.height+ca(e.display)-fa(e),n.top)}),t.visible=Wi(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Wi(e.display,e.doc,n));if(!La(e,t))break;ji(e);var i=li(e);ai(e),On(e,i),_a(e,i),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Aa(e,t){var n=new Ki(e,t);if(La(e,n)){ji(e),Co(e,n);var r=li(e);ai(e),On(e,r),_a(e,r),n.finish()}}function ul(e,t,n){var r=e.display,i=e.options.lineNumbers,y=r.lineDiv,M=y.firstChild;function j(Te){var Ae=Te.nextSibling;return R&&s&&e.display.currentWheelTarget==Te?Te.style.display="none":Te.parentNode.removeChild(Te),Ae}for(var K=r.view,z=r.viewFrom,Z=0;Z<K.length;Z++){var ie=K[Z];if(!ie.hidden)if(!ie.node||ie.node.parentNode!=y){var fe=Fs(e,ie,z,n);y.insertBefore(fe,M)}else{for(;M!=ie.node;)M=j(M);var ce=i&&t!=null&&t<=z&&ie.lineNumber;ie.changes&&(se(ie.changes,"gutter")>-1&&(ce=!1),Ya(e,ie,z,n)),ce&&(f(ie.lineNumber),ie.lineNumber.appendChild(document.createTextNode(pn(e.options,z)))),M=ie.node.nextSibling}z+=ie.size}for(;M;)M=j(M)}function Da(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function _a(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Dr(e)+"px"}function Lo(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=Ea(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,y=r+"px",M=0;M<n.length;M++)if(!n[M].hidden){e.options.fixedGutter&&(n[M].gutter&&(n[M].gutter.style.left=y),n[M].gutterBackground&&(n[M].gutterBackground.style.left=y));var j=n[M].alignable;if(j)for(var K=0;K<j.length;K++)j[K].style.left=y}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}function Ao(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=pn(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(a("div",[a("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),y=i.firstChild.offsetWidth,M=i.offsetWidth-y;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(y,r.lineGutter.offsetWidth-M)+1,r.lineNumWidth=r.lineNumInnerWidth+M,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",Da(e.display),!0}return!1}function Oa(e,t){for(var n=[],r=!1,i=0;i<e.length;i++){var y=e[i],M=null;if(typeof y!="string"&&(M=y.style,y=y.className),y=="CodeMirror-linenumbers")if(t)r=!0;else continue;n.push({className:y,style:M})}return t&&!r&&n.push({className:"CodeMirror-linenumbers",style:null}),n}function Do(e){var t=e.gutters,n=e.gutterSpecs;f(t),e.lineGutter=null;for(var r=0;r<n.length;++r){var i=n[r],y=i.className,M=i.style,j=t.appendChild(a("div",null,"CodeMirror-gutter "+y));M&&(j.style.cssText=M),y=="CodeMirror-linenumbers"&&(e.lineGutter=j,j.style.width=(e.lineNumWidth||1)+"px")}t.style.display=n.length?"":"none",Da(e)}function ci(e){Do(e.display),tr(e),Lo(e)}function dl(e,t,n,r){var i=this;this.input=n,i.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=b("div",null,"CodeMirror-code"),i.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=a("div",null,"CodeMirror-cursors"),i.measure=a("div",null,"CodeMirror-measure"),i.lineMeasure=a("div",null,"CodeMirror-measure"),i.lineSpace=b("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none");var y=b("div",[i.lineSpace],"CodeMirror-lines");i.mover=a("div",[y],null,"position: relative"),i.sizer=a("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=a("div",null,null,"position: absolute; height: "+de+"px; width: 1px;"),i.gutters=a("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=a("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=a("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),U&&F<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),!R&&!(A&&o)&&(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,i.gutterSpecs=Oa(r.gutters,r.lineNumbers),Do(i),n.init(i)}var Gi=0,dr=null;U?dr=-.53:A?dr=15:v?dr=-.7:D&&(dr=-1/3);function _o(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),n==null&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:n==null&&(n=e.wheelDelta),{x:t,y:n}}function cl(e){var t=_o(e);return t.x*=dr,t.y*=dr,t}function Oo(e,t){var n=_o(t),r=n.x,i=n.y,y=e.display,M=y.scroller,j=M.scrollWidth>M.clientWidth,K=M.scrollHeight>M.clientHeight;if(!(r&&j||i&&K))return;if(i&&s&&R){e:for(var z=t.target,Z=y.view;z!=M;z=z.parentNode)for(var ie=0;ie<Z.length;ie++)if(Z[ie].node==z){e.display.currentWheelTarget=z;break e}}if(r&&!A&&!S&&dr!=null){i&&K&&si(e,Math.max(0,M.scrollTop+i*dr)),ln(e,Math.max(0,M.scrollLeft+r*dr)),(!i||i&&K)&&V(t),y.wheelStartX=null;return}if(i&&dr!=null){var fe=i*dr,ce=e.doc.scrollTop,Te=ce+y.wrapper.clientHeight;fe<0?ce=Math.max(0,ce+fe-50):Te=Math.min(e.doc.height,Te+fe+50),Aa(e,{top:ce,bottom:Te})}Gi<20&&(y.wheelStartX==null?(y.wheelStartX=M.scrollLeft,y.wheelStartY=M.scrollTop,y.wheelDX=r,y.wheelDY=i,setTimeout(function(){if(y.wheelStartX==null)return;var Ae=M.scrollLeft-y.wheelStartX,ke=M.scrollTop-y.wheelStartY,Ue=ke&&y.wheelDY&&ke/y.wheelDY||Ae&&y.wheelDX&&Ae/y.wheelDX;if(y.wheelStartX=y.wheelStartY=null,!Ue)return;dr=(dr*Gi+Ue)/(Gi+1),++Gi},200)):(y.wheelDX+=r,y.wheelDY+=i))}var cr=function(e,t){this.ranges=e,this.primIndex=t};cr.prototype.primary=function(){return this.ranges[this.primIndex]},cr.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],r=e.ranges[t];if(!Gn(n.anchor,r.anchor)||!Gn(n.head,r.head))return!1}return!0},cr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new wt(gn(this.ranges[t].anchor),gn(this.ranges[t].head));return new cr(e,this.primIndex)},cr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},cr.prototype.contains=function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(dt(t,r.from())>=0&&dt(e,r.to())<=0)return n}return-1};var wt=function(e,t){this.anchor=e,this.head=t};wt.prototype.from=function(){return Qr(this.anchor,this.head)},wt.prototype.to=function(){return vn(this.anchor,this.head)},wt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Sr(e,t,n){var r=e&&e.options.selectionsMayTouch,i=t[n];t.sort(function(fe,ce){return dt(fe.from(),ce.from())}),n=se(t,i);for(var y=1;y<t.length;y++){var M=t[y],j=t[y-1],K=dt(j.to(),M.from());if(r&&!M.empty()?K>0:K>=0){var z=Qr(j.from(),M.from()),Z=vn(j.to(),M.to()),ie=j.empty()?M.from()==M.head:j.from()==j.head;y<=n&&--n,t.splice(--y,2,new wt(ie?Z:z,ie?z:Z))}}return new cr(t,n)}function zr(e,t){return new cr([new wt(e,t||e)],0)}function Vr(e){return e.text?Oe(e.from.line+e.text.length-1,xe(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ro(e,t){if(dt(e,t.from)<0)return e;if(dt(e,t.to)<=0)return Vr(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Vr(t).ch-t.to.ch),Oe(n,r)}function Ra(e,t){for(var n=[],r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new wt(Ro(i.anchor,t),Ro(i.head,t)))}return Sr(e.cm,n,e.sel.primIndex)}function Po(e,t,n){return e.line==t.line?Oe(n.line,e.ch-t.ch+n.ch):Oe(n.line+(e.line-t.line),e.ch)}function fl(e,t,n){for(var r=[],i=Oe(e.first,0),y=i,M=0;M<t.length;M++){var j=t[M],K=Po(j.from,i,y),z=Po(Vr(j),i,y);if(i=j.to,y=z,n=="around"){var Z=e.sel.ranges[M],ie=dt(Z.head,Z.anchor)<0;r[M]=new wt(ie?z:K,ie?K:z)}else r[M]=new wt(K,K)}return new cr(r,e.sel.primIndex)}function Pa(e){e.doc.mode=pr(e.options,e.doc.modeOption),fi(e)}function fi(e){e.doc.iter(function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,di(e,100),e.state.modeGen++,e.curOp&&tr(e)}function ko(e,t){return t.from.ch==0&&t.to.ch==0&&xe(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function ka(e,t,n,r){function i(Xe){return n?n[Xe]:null}function y(Xe,Ne,qe){ua(Xe,Ne,qe,r),Gt(Xe,"change",Xe,t)}function M(Xe,Ne){for(var qe=[],lt=Xe;lt<Ne;++lt)qe.push(new rn(z[lt],i(lt),r));return qe}var j=t.from,K=t.to,z=t.text,Z=rt(e,j.line),ie=rt(e,K.line),fe=xe(z),ce=i(z.length-1),Te=K.line-j.line;if(t.full)e.insert(0,M(0,z.length)),e.remove(z.length,e.size-z.length);else if(ko(e,t)){var Ae=M(0,z.length-1);y(ie,ie.text,ce),Te&&e.remove(j.line,Te),Ae.length&&e.insert(j.line,Ae)}else if(Z==ie)if(z.length==1)y(Z,Z.text.slice(0,j.ch)+fe+Z.text.slice(K.ch),ce);else{var ke=M(1,z.length-1);ke.push(new rn(fe+Z.text.slice(K.ch),ce,r)),y(Z,Z.text.slice(0,j.ch)+z[0],i(0)),e.insert(j.line+1,ke)}else if(z.length==1)y(Z,Z.text.slice(0,j.ch)+z[0]+ie.text.slice(K.ch),i(0)),e.remove(j.line+1,Te);else{y(Z,Z.text.slice(0,j.ch)+z[0],i(0)),y(ie,fe+ie.text.slice(K.ch),ce);var Ue=M(1,z.length-1);Te>1&&e.remove(j.line+1,Te-1),e.insert(j.line+1,Ue)}Gt(e,"change",e,t)}function Xr(e,t,n){function r(i,y,M){if(i.linked)for(var j=0;j<i.linked.length;++j){var K=i.linked[j];if(K.doc==y)continue;var z=M&&K.sharedHist;if(n&&!z)continue;t(K.doc,z),r(K.doc,i,z)}}r(e,null,!0)}function Mo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,xa(e),Pa(e),Io(e),e.options.lineWrapping||Ii(e),e.options.mode=t.modeOption,tr(e)}function Io(e){(e.doc.direction=="rtl"?N:c)(e.display.lineDiv,"CodeMirror-rtl")}function hl(e){or(e,function(){Io(e),tr(e)})}function zi(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ma(e,t){var n={from:gn(t.from),to:Vr(t),text:Pr(e,t.from,t.to)};return No(e,n,t.from.line,t.to.line+1),Xr(e,function(r){return No(r,n,t.from.line,t.to.line+1)},!0),n}function Fo(e){for(;e.length;){var t=xe(e);if(t.ranges)e.pop();else break}}function ml(e,t){if(t)return Fo(e.done),xe(e.done);if(e.done.length&&!xe(e.done).ranges)return xe(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),xe(e.done)}function Uo(e,t,n,r){var i=e.history;i.undone.length=0;var y=+new Date,M,j;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&i.lastModTime>y-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(M=ml(i,i.lastOp==r)))j=xe(M.changes),dt(t.from,t.to)==0&&dt(t.from,j.to)==0?j.to=Vr(t):M.changes.push(Ma(e,t));else{var K=xe(i.done);for((!K||!K.ranges)&&Vi(e.sel,i.done),M={changes:[Ma(e,t)],generation:i.generation},i.done.push(M);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=y,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,j||ve(e,"historyAdded")}function pl(e,t,n,r){var i=t.charAt(0);return i=="*"||i=="+"&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,n,r){var i=e.history,y=r&&r.origin;n==i.lastSelOp||y&&i.lastSelOrigin==y&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==y||pl(e,y,xe(i.done),t))?i.done[i.done.length-1]=t:Vi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=y,i.lastSelOp=n,r&&r.clearRedo!==!1&&Fo(i.undone)}function Vi(e,t){var n=xe(t);n&&n.ranges&&n.equals(e)||t.push(e)}function No(e,t,n,r){var i=t["spans_"+e.id],y=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(M){M.markedSpans&&((i||(i=t["spans_"+e.id]={}))[y]=M.markedSpans),++y})}function vl(e){if(!e)return null;for(var t,n=0;n<e.length;++n)e[n].marker.explicitlyCleared?t||(t=e.slice(0,n)):t&&t.push(e[n]);return t?t.length?t:null:e}function yl(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=[],i=0;i<t.text.length;++i)r.push(vl(n[i]));return r}function Bo(e,t){var n=yl(e,t),r=En(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var y=n[i],M=r[i];if(y&&M){e:for(var j=0;j<M.length;++j){for(var K=M[j],z=0;z<y.length;++z)if(y[z].marker==K.marker)continue e;y.push(K)}}else M&&(n[i]=M)}return n}function Rn(e,t,n){for(var r=[],i=0;i<e.length;++i){var y=e[i];if(y.ranges){r.push(n?cr.prototype.deepCopy.call(y):y);continue}var M=y.changes,j=[];r.push({changes:j});for(var K=0;K<M.length;++K){var z=M[K],Z=void 0;if(j.push({from:z.from,to:z.to,text:z.text}),t)for(var ie in z)(Z=ie.match(/^spans_(\d+)$/))&&(se(t,Number(Z[1]))>-1&&(xe(j)[ie]=z[ie],delete z[ie]))}}return r}function Ia(e,t,n,r){if(r){var i=e.anchor;if(n){var y=dt(t,i)<0;y!=dt(n,i)<0?(i=t,t=n):y!=dt(t,n)<0&&(t=n)}return new wt(i,t)}else return new wt(n||t,t)}function Xi(e,t,n,r,i){i==null&&(i=e.cm&&(e.cm.display.shift||e.extend)),Xt(e,new cr([Ia(e.sel.primary(),t,n,i)],0),r)}function jo(e,t,n){for(var r=[],i=e.cm&&(e.cm.display.shift||e.extend),y=0;y<e.sel.ranges.length;y++)r[y]=Ia(e.sel.ranges[y],t[y],null,i);var M=Sr(e.cm,r,e.sel.primIndex);Xt(e,M,n)}function Fa(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,Xt(e,Sr(e.cm,i,e.sel.primIndex),r)}function Wo(e,t,n,r){Xt(e,zr(t,n),r)}function bl(e,t,n){var r={ranges:t.ranges,update:function(i){this.ranges=[];for(var y=0;y<i.length;y++)this.ranges[y]=new wt(ft(e,i[y].anchor),ft(e,i[y].head))},origin:n&&n.origin};return ve(e,"beforeSelectionChange",e,r),e.cm&&ve(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Sr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,n){var r=e.history.done,i=xe(r);i&&i.ranges?(r[r.length-1]=t,Yi(e,t,n)):Xt(e,t,n)}function Xt(e,t,n){Yi(e,t,n),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function Yi(e,t,n){(ee(e,"beforeSelectionChange")||e.cm&&ee(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,n));var r=n&&n.bias||(dt(t.primary().head,e.sel.primary().head)<0?-1:1);Ko(e,zo(e,t,r,!0)),!(n&&n.scroll===!1)&&e.cm&&_n(e.cm)}function Ko(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,oe(e.cm)),Gt(e,"cursorActivity",e)}function Go(e){Ko(e,zo(e,e.sel,null,!1))}function zo(e,t,n,r){for(var i,y=0;y<t.ranges.length;y++){var M=t.ranges[y],j=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[y],K=$i(e,M.anchor,j&&j.anchor,n,r),z=$i(e,M.head,j&&j.head,n,r);(i||K!=M.anchor||z!=M.head)&&(i||(i=t.ranges.slice(0,y)),i[y]=new wt(K,z))}return i?Sr(e.cm,i,t.primIndex):t}function Pn(e,t,n,r,i){var y=rt(e,t.line);if(y.markedSpans)for(var M=0;M<y.markedSpans.length;++M){var j=y.markedSpans[M],K=j.marker,z="selectLeft"in K?!K.selectLeft:K.inclusiveLeft,Z="selectRight"in K?!K.selectRight:K.inclusiveRight;if((j.from==null||(z?j.from<=t.ch:j.from<t.ch))&&(j.to==null||(Z?j.to>=t.ch:j.to>t.ch))){if(i&&(ve(K,"beforeCursorEnter"),K.explicitlyCleared))if(y.markedSpans){--M;continue}else break;if(!K.atomic)continue;if(n){var ie=K.find(r<0?1:-1),fe=void 0;if((r<0?Z:z)&&(ie=Vo(e,ie,-r,ie&&ie.line==t.line?y:null)),ie&&ie.line==t.line&&(fe=dt(ie,n))&&(r<0?fe<0:fe>0))return Pn(e,ie,t,r,i)}var ce=K.find(r<0?-1:1);return(r<0?z:Z)&&(ce=Vo(e,ce,r,ce.line==t.line?y:null)),ce?Pn(e,ce,t,r,i):null}}return t}function $i(e,t,n,r,i){var y=r||1,M=Pn(e,t,n,y,i)||!i&&Pn(e,t,n,y,!0)||Pn(e,t,n,-y,i)||!i&&Pn(e,t,n,-y,!0);return M||(e.cantEdit=!0,Oe(e.first,0))}function Vo(e,t,n,r){return n<0&&t.ch==0?t.line>e.first?ft(e,Oe(t.line-1)):null:n>0&&t.ch==(r||rt(e,t.line)).text.length?t.line<e.first+e.size-1?Oe(t.line+1,0):null:new Oe(t.line,t.ch+n)}function Xo(e){e.setSelection(Oe(e.firstLine(),0),Oe(e.lastLine()),ge)}function Yo(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return n&&(r.update=function(i,y,M,j){i&&(r.from=ft(e,i)),y&&(r.to=ft(e,y)),M&&(r.text=M),j!==void 0&&(r.origin=j)}),ve(e,"beforeChange",e,r),e.cm&&ve(e.cm,"beforeChange",e.cm,r),r.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function kn(e,t,n){if(e.cm){if(!e.cm.curOp)return jt(e.cm,kn)(e,t,n);if(e.cm.state.suppressEdits)return}if((ee(e,"beforeChange")||e.cm&&ee(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Jn&&!n&&Pi(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)$o(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&dt(t.from,t.to)==0)return;var n=Ra(e,t);Uo(e,t,n,e.cm?e.cm.curOp.id:NaN),hi(e,t,n,En(e,t));var r=[];Xr(e,function(i,y){!y&&se(r,i.history)==-1&&(qo(i.history,t),r.push(i.history)),hi(i,t,null,En(i,t))})}function Ji(e,t,n){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!n)return;for(var i=e.history,y,M=e.sel,j=t=="undo"?i.done:i.undone,K=t=="undo"?i.undone:i.done,z=0;z<j.length&&!(y=j[z],n?y.ranges&&!y.equals(e.sel):!y.ranges);z++);if(z==j.length)return;for(i.lastOrigin=i.lastSelOrigin=null;;)if(y=j.pop(),y.ranges){if(Vi(y,K),n&&!y.equals(e.sel)){Xt(e,y,{clearRedo:!1});return}M=y}else if(r){j.push(y);return}else break;var Z=[];Vi(M,K),K.push({changes:Z,generation:i.generation}),i.generation=y.generation||++i.maxGeneration;for(var ie=ee(e,"beforeChange")||e.cm&&ee(e.cm,"beforeChange"),fe=function(Ae){var ke=y.changes[Ae];if(ke.origin=t,ie&&!Yo(e,ke,!1))return j.length=0,{};Z.push(Ma(e,ke));var Ue=Ae?Ra(e,ke):xe(j);hi(e,ke,Ue,Bo(e,ke)),!Ae&&e.cm&&e.cm.scrollIntoView({from:ke.from,to:Vr(ke)});var Xe=[];Xr(e,function(Ne,qe){!qe&&se(Xe,Ne.history)==-1&&(qo(Ne.history,ke),Xe.push(Ne.history)),hi(Ne,ke,null,Bo(Ne,ke))})},ce=y.changes.length-1;ce>=0;--ce){var Te=fe(ce);if(Te)return Te.v}}function Jo(e,t){if(t==0)return;if(e.first+=t,e.sel=new cr(Fe(e.sel.ranges,function(i){return new wt(Oe(i.anchor.line+t,i.anchor.ch),Oe(i.head.line+t,i.head.ch))}),e.sel.primIndex),e.cm){tr(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)Kr(e.cm,r,"gutter")}}function hi(e,t,n,r){if(e.cm&&!e.cm.curOp)return jt(e.cm,hi)(e,t,n,r);if(t.to.line<e.first){Jo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Jo(e,i),t={from:Oe(e.first,0),to:Oe(t.to.line+i,t.to.ch),text:[xe(t.text)],origin:t.origin}}var y=e.lastLine();t.to.line>y&&(t={from:t.from,to:Oe(y,rt(e,y).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Pr(e,t.from,t.to),n||(n=Ra(e,t)),e.cm?El(e.cm,t,r):ka(e,t,r),Yi(e,n,ge),e.cantEdit&&$i(e,Oe(e.firstLine(),0))&&(e.cantEdit=!1)}function El(e,t,n){var r=e.doc,i=e.display,y=t.from,M=t.to,j=!1,K=y.line;e.options.lineWrapping||(K=Tt(ur(rt(r,y.line))),r.iter(K,M.line+1,function(ce){if(ce==i.maxLine)return j=!0,!0})),r.sel.contains(t.from,t.to)>-1&&oe(e),ka(r,t,n,ho(e)),e.options.lineWrapping||(r.iter(K,y.line+t.text.length,function(ce){var Te=ei(ce);Te>i.maxLineLength&&(i.maxLine=ce,i.maxLineLength=Te,i.maxLineChanged=!0,j=!1)}),j&&(e.curOp.updateMaxLine=!0)),aa(r,y.line),di(e,400);var z=t.text.length-(M.line-y.line)-1;t.full?tr(e):y.line==M.line&&t.text.length==1&&!ko(e.doc,t)?Kr(e,y.line,"text"):tr(e,y.line,M.line+1,z);var Z=ee(e,"changes"),ie=ee(e,"change");if(ie||Z){var fe={from:y,to:M,text:t.text,removed:t.removed,origin:t.origin};ie&&Gt(e,"change",e,fe),Z&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(fe)}e.display.selForContextMenu=null}function Mn(e,t,n,r,i){var y;r||(r=n),dt(r,n)<0&&(y=[r,n],n=y[0],r=y[1]),typeof t=="string"&&(t=e.splitLines(t)),kn(e,{from:n,to:r,text:t,origin:i})}function Qo(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function Zo(e,t,n,r){for(var i=0;i<e.length;++i){var y=e[i],M=!0;if(y.ranges){y.copied||(y=e[i]=y.deepCopy(),y.copied=!0);for(var j=0;j<y.ranges.length;j++)Qo(y.ranges[j].anchor,t,n,r),Qo(y.ranges[j].head,t,n,r);continue}for(var K=0;K<y.changes.length;++K){var z=y.changes[K];if(n<z.from.line)z.from=Oe(z.from.line+r,z.from.ch),z.to=Oe(z.to.line+r,z.to.ch);else if(t<=z.to.line){M=!1;break}}M||(e.splice(0,i+1),i=0)}}function qo(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;Zo(e.done,n,r,i),Zo(e.undone,n,r,i)}function mi(e,t,n,r){var i=t,y=t;return typeof t=="number"?y=rt(e,yn(e,t)):i=Tt(t),i==null?null:(r(y,i)&&e.cm&&Kr(e.cm,i,n),y)}function pi(e){this.lines=e,this.parent=null;for(var t=0,n=0;n<e.length;++n)e[n].parent=this,t+=e[n].height;this.height=t}pi.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;n<r;++n){var i=this.lines[n];this.height-=i.height,nt(i),Gt(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}};function gi(e){this.children=e;for(var t=0,n=0,r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}gi.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(e<i){var y=Math.min(t,i-e),M=r.height;if(r.removeInner(e,y),this.height-=M-r.height,i==y&&(this.children.splice(n--,1),r.parent=null),(t-=y)==0)break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof pi))){var j=[];this.collapse(j),this.children=[new pi(j)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],y=i.chunkSize();if(e<=y){if(i.insertInner(e,t,n),i.lines&&i.lines.length>50){for(var M=i.lines.length%25+25,j=M;j<i.lines.length;){var K=new pi(i.lines.slice(j,j+=25));i.height-=K.height,this.children.splice(++r,0,K),K.parent=this}i.lines=i.lines.slice(0,M),this.maybeSpill()}break}e-=y}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new gi(t);if(e.parent){e.size-=n.size,e.height-=n.height;var i=se(e.parent.children,e);e.parent.children.splice(i+1,0,n)}else{var r=new gi(e.children);r.parent=e,e.children=[r,n],e=r}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],y=i.chunkSize();if(e<y){var M=Math.min(t,y-e);if(i.iterN(e,M,n))return!0;if((t-=M)==0)break;e=0}else e-=y}}};var vi=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.doc=e,this.node=t};vi.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,n=this.line,r=Tt(n);if(r==null||!t)return;for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var y=ni(this);Zt(n,Math.max(0,n.height-y)),e&&(or(e,function(){es(e,n,-y),Kr(e,r,"widget")}),Gt(e,"lineWidgetCleared",e,this,r))},vi.prototype.changed=function(){var e=this,t=this.height,n=this.doc.cm,r=this.line;this.height=null;var i=ni(this)-t;if(!i)return;Ar(this.doc,r)||Zt(r,r.height+i),n&&or(n,function(){n.curOp.forceUpdate=!0,es(n,r,i),Gt(n,"lineWidgetChanged",n,e,Tt(r))})},re(vi);function es(e,t,n){xr(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Ca(e,n)}function xl(e,t,n,r){var i=new vi(e,n,r),y=e.cm;return y&&i.noHScroll&&(y.display.alignWidgets=!0),mi(e,t,"widget",function(M){var j=M.widgets||(M.widgets=[]);if(i.insertAt==null?j.push(i):j.splice(Math.min(j.length-1,Math.max(0,i.insertAt)),0,i),i.line=M,y&&!Ar(e,M)){var K=xr(M)<e.scrollTop;Zt(M,M.height+ni(i)),K&&Ca(y,i.height),y.curOp.forceUpdate=!0}return!0}),y&&Gt(y,"lineWidgetAdded",y,i,typeof t=="number"?t:Tt(t)),i}var ts=0,Yr=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};Yr.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&dn(e),ee(this,"clear")){var n=this.find();n&&Gt(this,"clear",n.from,n.to)}for(var r=null,i=null,y=0;y<this.lines.length;++y){var M=this.lines[y],j=Er(M.markedSpans,this);e&&!this.collapsed?Kr(e,Tt(M),"text"):e&&(j.to!=null&&(i=Tt(M)),j.from!=null&&(r=Tt(M))),M.markedSpans=Qn(M.markedSpans,j),j.from==null&&this.collapsed&&!Ar(this.doc,M)&&e&&Zt(M,Ln(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var K=0;K<this.lines.length;++K){var z=ur(this.lines[K]),Z=ei(z);Z>e.display.maxLineLength&&(e.display.maxLine=z,e.display.maxLineLength=Z,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&tr(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Go(e.doc)),e&&Gt(e,"markerCleared",e,this,r,i),t&&cn(e),this.parent&&this.parent.clear()},Yr.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var n,r,i=0;i<this.lines.length;++i){var y=this.lines[i],M=Er(y.markedSpans,this);if(M.from!=null&&(n=Oe(t?y:Tt(y),M.from),e==-1))return n;if(M.to!=null&&(r=Oe(t?y:Tt(y),M.to),e==1))return r}return n&&{from:n,to:r}},Yr.prototype.changed=function(){var e=this,t=this.find(-1,!0),n=this,r=this.doc.cm;if(!t||!r)return;or(r,function(){var i=t.line,y=Tt(t.line),M=ha(r,y);if(M&&(io(M),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Ar(n.doc,i)&&n.height!=null){var j=n.height;n.height=null;var K=ni(n)-j;K&&Zt(i,i.height+K)}Gt(r,"markerChanged",r,e)})},Yr.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||se(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Yr.prototype.detachLine=function(e){if(this.lines.splice(se(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},re(Yr);function In(e,t,n,r,i){if(r&&r.shared)return Tl(e,t,n,r,i);if(e.cm&&!e.cm.curOp)return jt(e.cm,In)(e,t,n,r,i);var y=new Yr(e,i),M=dt(t,n);if(r&&I(r,y,!1),M>0||M==0&&y.clearWhenEmpty!==!1)return y;if(y.replacedWith&&(y.collapsed=!0,y.widgetNode=b("span",[y.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||y.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(y.widgetNode.insertLeft=!0)),y.collapsed){if(ki(e,t.line,t,n,y)||t.line!=n.line&&ki(e,n.line,t,n,y))throw new Error("Inserting collapsed marker partially overlapping an existing one");oa()}y.addToHistory&&Uo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var j=t.line,K=e.cm,z;if(e.iter(j,n.line+1,function(ie){K&&y.collapsed&&!K.options.lineWrapping&&ur(ie)==K.display.maxLine&&(z=!0),y.collapsed&&j!=t.line&&Zt(ie,0),sa(ie,new qr(y,j==t.line?t.ch:null,j==n.line?n.ch:null)),++j}),y.collapsed&&e.iter(t.line,n.line+1,function(ie){Ar(e,ie)&&Zt(ie,0)}),y.clearOnEnter&&be(y,"beforeCursorEnter",function(){return y.clear()}),y.readOnly&&(Wr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),y.collapsed&&(y.id=++ts,y.atomic=!0),K){if(z&&(K.curOp.updateMaxLine=!0),y.collapsed)tr(K,t.line,n.line+1);else if(y.className||y.startStyle||y.endStyle||y.css||y.attributes||y.title)for(var Z=t.line;Z<=n.line;Z++)Kr(K,Z,"text");y.atomic&&Go(K.doc),Gt(K,"markerAdded",K,y)}return y}var yi=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};yi.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Gt(this,"clear")},yi.prototype.find=function(e,t){return this.primary.find(e,t)},re(yi);function Tl(e,t,n,r,i){r=I(r),r.shared=!1;var y=[In(e,t,n,r,i)],M=y[0],j=r.widgetNode;return Xr(e,function(K){j&&(r.widgetNode=j.cloneNode(!0)),y.push(In(K,ft(K,t),ft(K,n),r,i));for(var z=0;z<K.linked.length;++z)if(K.linked[z].isParent)return;M=xe(y)}),new yi(y,M)}function rs(e){return e.findMarks(Oe(e.first,0),e.clipPos(Oe(e.lastLine())),function(t){return t.parent})}function Sl(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),y=e.clipPos(i.from),M=e.clipPos(i.to);if(dt(y,M)){var j=In(e,y,M,r.primary,r.primary.type);r.markers.push(j),j.parent=r}}}function wl(e){for(var t=function(r){var i=e[r],y=[i.primary.doc];Xr(i.primary.doc,function(K){return y.push(K)});for(var M=0;M<i.markers.length;M++){var j=i.markers[M];se(y,j.doc)==-1&&(j.parent=null,i.markers.splice(M--,1))}},n=0;n<e.length;n++)t(n)}var Cl=0,rr=function(e,t,n,r,i){if(!(this instanceof rr))return new rr(e,t,n,r,i);n==null&&(n=0),gi.call(this,[new pi([new rn("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=n;var y=Oe(n,0);this.sel=zr(y),this.history=new zi(null),this.id=++Cl,this.modeOption=t,this.lineSep=r,this.direction=i=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),ka(this,{from:y,to:y,text:e}),Xt(this,zr(y),ge)};rr.prototype=Ke(gi.prototype,{constructor:rr,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=mn(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:Wt(function(e){var t=Oe(this.first,0),n=this.first+this.size-1;kn(this,{from:t,to:Oe(n,rt(this,n).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&oi(this.cm,0,0),Xt(this,zr(t),ge)}),replaceRange:function(e,t,n,r){t=ft(this,t),n=n?ft(this,n):t,Mn(this,e,t,n,r)},getRange:function(e,t,n){var r=Pr(this,ft(this,e),ft(this,t));return n===!1?r:r.join(n||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(kr(this,e))return rt(this,e)},getLineNumber:function(e){return Tt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=rt(this,e)),ur(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return ft(this,e)},getCursor:function(e){var t=this.sel.primary(),n;return e==null||e=="head"?n=t.head:e=="anchor"?n=t.anchor:e=="end"||e=="to"||e===!1?n=t.to():n=t.from(),n},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Wt(function(e,t,n){Wo(this,ft(this,typeof e=="number"?Oe(e,t||0):e),null,n)}),setSelection:Wt(function(e,t,n){Wo(this,ft(this,e),ft(this,t||e),n)}),extendSelection:Wt(function(e,t,n){Xi(this,ft(this,e),t&&ft(this,t),n)}),extendSelections:Wt(function(e,t){jo(this,Pe(this,e),t)}),extendSelectionsBy:Wt(function(e,t){var n=Fe(this.sel.ranges,e);jo(this,Pe(this,n),t)}),setSelections:Wt(function(e,t,n){if(!e.length)return;for(var r=[],i=0;i<e.length;i++)r[i]=new wt(ft(this,e[i].anchor),ft(this,e[i].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Xt(this,Sr(this.cm,r,t),n)}),addSelection:Wt(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new wt(ft(this,e),ft(this,t||e))),Xt(this,Sr(this.cm,r,r.length-1),n)}),getSelection:function(e){for(var t=this.sel.ranges,n,r=0;r<t.length;r++){var i=Pr(this,t[r].from(),t[r].to());n=n?n.concat(i):i}return e===!1?n:n.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],n=this.sel.ranges,r=0;r<n.length;r++){var i=Pr(this,n[r].from(),n[r].to());e!==!1&&(i=i.join(e||this.lineSeparator())),t[r]=i}return t},replaceSelection:function(e,t,n){for(var r=[],i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:Wt(function(e,t,n){for(var r=[],i=this.sel,y=0;y<i.ranges.length;y++){var M=i.ranges[y];r[y]={from:M.from(),to:M.to(),text:this.splitLines(e[y]),origin:n}}for(var j=t&&t!="end"&&fl(this,r,t),K=r.length-1;K>=0;K--)kn(this,r[K]);j?Ho(this,j):this.cm&&_n(this.cm)}),undo:Wt(function(){Ji(this,"undo")}),redo:Wt(function(){Ji(this,"redo")}),undoSelection:Wt(function(){Ji(this,"undo",!0)}),redoSelection:Wt(function(){Ji(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var i=0;i<e.undone.length;i++)e.undone[i].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){var e=this;this.history=new zi(this.history.maxGeneration),Xr(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:Rn(this.history.done),undone:Rn(this.history.undone)}},setHistory:function(e){var t=this.history=new zi(this.history.maxGeneration);t.done=Rn(e.done.slice(0),null,!0),t.undone=Rn(e.undone.slice(0),null,!0)},setGutterMarker:Wt(function(e,t,n){return mi(this,e,"gutter",function(r){var i=r.gutterMarkers||(r.gutterMarkers={});return i[t]=n,!n&&Be(i)&&(r.gutterMarkers=null),!0})}),clearGutter:Wt(function(e){var t=this;this.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&mi(t,n,"gutter",function(){return n.gutterMarkers[e]=null,Be(n.gutterMarkers)&&(n.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!kr(this,e))return null;if(t=e,e=rt(this,e),!e)return null}else if(t=Tt(e),t==null)return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:Wt(function(e,t,n){return mi(this,e,t=="gutter"?"gutter":"class",function(r){var i=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!r[i])r[i]=n;else{if(p(n).test(r[i]))return!1;r[i]+=" "+n}return!0})}),removeLineClass:Wt(function(e,t,n){return mi(this,e,t=="gutter"?"gutter":"class",function(r){var i=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",y=r[i];if(y)if(n==null)r[i]=null;else{var M=y.match(p(n));if(!M)return!1;var j=M.index+M[0].length;r[i]=y.slice(0,M.index)+(!M.index||j==y.length?"":" ")+y.slice(j)||null}else return!1;return!0})}),addLineWidget:Wt(function(e,t,n){return xl(this,e,t,n)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,n){return In(this,ft(this,e),ft(this,t),n,n&&n.type||"range")},setBookmark:function(e,t){var n={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return e=ft(this,e),In(this,e,e,n,"bookmark")},findMarksAt:function(e){e=ft(this,e);var t=[],n=rt(this,e.line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(i.from==null||i.from<=e.ch)&&(i.to==null||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=ft(this,e),t=ft(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(y){var M=y.markedSpans;if(M)for(var j=0;j<M.length;j++){var K=M[j];!(K.to!=null&&i==e.line&&e.ch>=K.to||K.from==null&&i!=e.line||K.from!=null&&i==t.line&&K.from>=t.ch)&&(!n||n(K.marker))&&r.push(K.marker.parent||K.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)n[r].from!=null&&e.push(n[r].marker)}),e},posFromIndex:function(e){var t,n=this.first,r=this.lineSeparator().length;return this.iter(function(i){var y=i.text.length+r;if(y>e)return t=e,!0;e-=y,++n}),ft(this,Oe(n,t))},indexFromPos:function(e){e=ft(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var n=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+n}),t},copy:function(e){var t=new rr(mn(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<n&&(n=e.to);var r=new rr(mn(this,t,n),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Sl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof _t&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var n=this.linked[t];if(n.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),wl(rs(this));break}if(e.history==this.history){var r=[e.id];Xr(e,function(i){return r.push(i.id)},!0),e.history=new zi(null),e.history.done=Rn(this.history.done,r),e.history.undone=Rn(this.history.undone,r)}},iterLinkedDocs:function(e){Xr(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):ht(e)},lineSeparator:function(){return this.lineSep||`
|
|
`},setDirection:Wt(function(e){if(e!="rtl"&&(e="ltr"),e==this.direction)return;this.direction=e,this.iter(function(t){return t.order=null}),this.cm&&hl(this.cm)})}),rr.prototype.eachLine=rr.prototype.iter;var ns=0;function Ll(e){var t=this;if(is(t),Ee(t,e)||Nr(t.display,e))return;V(e),U&&(ns=+new Date);var n=on(t,e,!0),r=e.dataTransfer.files;if(!n||t.isReadOnly())return;if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,y=Array(i),M=0,j=function(){++M==i&&jt(t,function(){n=ft(t.doc,n);var ce={from:n,to:n,text:t.doc.splitLines(y.filter(function(Te){return Te!=null}).join(t.doc.lineSeparator())),origin:"paste"};kn(t.doc,ce),Ho(t.doc,zr(ft(t.doc,n),ft(t.doc,Vr(ce))))})()},K=function(ce,Te){if(t.options.allowDropFileTypes&&se(t.options.allowDropFileTypes,ce.type)==-1){j();return}var Ae=new FileReader;Ae.onerror=function(){return j()},Ae.onload=function(){var ke=Ae.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(ke)){j();return}y[Te]=ke,j()},Ae.readAsText(ce)},z=0;z<r.length;z++)K(r[z],z);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var Z=e.dataTransfer.getData("Text");if(Z){var ie;if(t.state.draggingText&&!t.state.draggingText.copy&&(ie=t.listSelections()),Yi(t.doc,zr(n,n)),ie)for(var fe=0;fe<ie.length;++fe)Mn(t.doc,"",ie[fe].anchor,ie[fe].head,"drag");t.replaceSelection(Z,"around","paste"),t.display.input.focus()}}catch(ce){}}}function Al(e,t){if(U&&(!e.state.draggingText||+new Date-ns<100)){ne(t);return}if(Ee(e,t)||Nr(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!D){var n=a("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",S&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),S&&n.parentNode.removeChild(n)}}function Dl(e,t){var n=on(e,t);if(!n)return;var r=document.createDocumentFragment();go(e,n,r),e.display.dragCursor||(e.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),d(e.display.dragCursor,r)}function is(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function as(e){if(!document.getElementsByClassName)return;for(var t=document.getElementsByClassName("CodeMirror"),n=[],r=0;r<t.length;r++){var i=t[r].CodeMirror;i&&n.push(i)}n.length&&n[0].operation(function(){for(var y=0;y<n.length;y++)e(n[y])})}var os=!1;function _l(){if(os)return;Ol(),os=!0}function Ol(){var e;be(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Rl)},100))}),be(window,"blur",function(){return as(Dn)})}function Rl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var $r={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},bi=0;bi<10;bi++)$r[bi+48]=$r[bi+96]=String(bi);for(var Qi=65;Qi<=90;Qi++)$r[Qi]=String.fromCharCode(Qi);for(var Ei=1;Ei<=12;Ei++)$r[Ei+111]=$r[Ei+63235]="F"+Ei;var Br={};Br.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Br.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Br.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Br.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Br.default=s?Br.macDefault:Br.pcDefault;function Pl(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var n,r,i,y,M=0;M<t.length-1;M++){var j=t[M];if(/^(cmd|meta|m)$/i.test(j))y=!0;else if(/^a(lt)?$/i.test(j))n=!0;else if(/^(c|ctrl|control)$/i.test(j))r=!0;else if(/^s(hift)?$/i.test(j))i=!0;else throw new Error("Unrecognized modifier name: "+j)}return n&&(e="Alt-"+e),r&&(e="Ctrl-"+e),y&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function kl(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if(r=="..."){delete e[n];continue}for(var i=Fe(n.split(" "),Pl),y=0;y<i.length;y++){var M=void 0,j=void 0;y==i.length-1?(j=i.join(" "),M=r):(j=i.slice(0,y+1).join(" "),M="...");var K=t[j];if(!K)t[j]=M;else if(K!=M)throw new Error("Inconsistent bindings for "+j)}delete e[n]}for(var z in t)e[z]=t[z];return e}function Fn(e,t,n,r){t=Zi(t);var i=t.call?t.call(e,r):t[e];if(i===!1)return"nothing";if(i==="...")return"multi";if(i!=null&&n(i))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return Fn(e,t.fallthrough,n,r);for(var y=0;y<t.fallthrough.length;y++){var M=Fn(e,t.fallthrough[y],n,r);if(M)return M}}}function ss(e){var t=typeof e=="string"?e:$r[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,n){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(h?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(h?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!n&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(S&&e.keyCode==34&&e.char)return!1;var n=$r[e.keyCode];return n==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(n=e.code),ls(n,e,t))}function Zi(e){return typeof e=="string"?Br[e]:e}function Un(e,t){for(var n=e.doc.sel.ranges,r=[],i=0;i<n.length;i++){for(var y=t(n[i]);r.length&&dt(y.from,xe(r).to)<=0;){var M=r.pop();if(dt(M.from,y.from)<0){y.from=M.from;break}}r.push(y)}or(e,function(){for(var j=r.length-1;j>=0;j--)Mn(e.doc,"",r[j].from,r[j].to,"+delete");_n(e)})}function Ua(e,t,n){var r=Le(e.text,t+n,n);return r<0||r>e.text.length?null:r}function Na(e,t,n){var r=Ua(e,t.ch,n);return r==null?null:new Oe(t.line,r,n<0?"after":"before")}function Ba(e,t,n,r,i){if(e){t.doc.direction=="rtl"&&(i=-i);var y=Ye(n,t.doc.direction);if(y){var M=i<0?xe(y):y[0],j=i<0==(M.level==1),K=j?"after":"before",z;if(M.level>0||t.doc.direction=="rtl"){var Z=Cn(t,n);z=i<0?n.text.length-1:0;var ie=_r(t,Z,z).top;z=$e(function(fe){return _r(t,Z,fe).top==ie},i<0==(M.level==1)?M.from:M.to-1,z),K=="before"&&(z=Ua(n,z,1))}else z=i<0?M.to:M.from;return new Oe(r,z,K)}}return new Oe(r,i<0?n.text.length:0,i<0?"before":"after")}function Ml(e,t,n,r){var i=Ye(t,e.doc.direction);if(!i)return Na(t,n,r);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var y=He(i,n.ch,n.sticky),M=i[y];if(e.doc.direction=="ltr"&&M.level%2==0&&(r>0?M.to>n.ch:M.from<n.ch))return Na(t,n,r);var j=function(Ue,Xe){return Ua(t,Ue instanceof Oe?Ue.ch:Ue,Xe)},K,z=function(Ue){return e.options.lineWrapping?(K=K||Cn(e,t),fo(e,t,K,Ue)):{begin:0,end:t.text.length}},Z=z(n.sticky=="before"?j(n,-1):n.ch);if(e.doc.direction=="rtl"||M.level==1){var ie=M.level==1==r<0,fe=j(n,ie?1:-1);if(fe!=null&&(ie?fe<=M.to&&fe<=Z.end:fe>=M.from&&fe>=Z.begin)){var ce=ie?"before":"after";return new Oe(n.line,fe,ce)}}var Te=function(Ue,Xe,Ne){for(var qe=function(Dt,Ht){return Ht?new Oe(n.line,j(Dt,1),"before"):new Oe(n.line,Dt,"after")};Ue>=0&&Ue<i.length;Ue+=Xe){var lt=i[Ue],at=Xe>0==(lt.level!=1),mt=at?Ne.begin:j(Ne.end,-1);if(lt.from<=mt&&mt<lt.to)return qe(mt,at);if(mt=at?lt.from:j(lt.to,-1),Ne.begin<=mt&&mt<Ne.end)return qe(mt,at)}},Ae=Te(y+r,r,Z);if(Ae)return Ae;var ke=r>0?Z.end:j(Z.begin,-1);return ke!=null&&!(r>0&&ke==t.text.length)&&(Ae=Te(r>0?0:i.length-1,r,z(ke)),Ae)?Ae:null}var xi={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),ge)},killLine:function(e){return Un(e,function(t){if(t.empty()){var n=rt(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:Oe(t.head.line+1,0)}:{from:t.head,to:Oe(t.head.line,n)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return Un(e,function(t){return{from:Oe(t.from().line,0),to:ft(e.doc,Oe(t.to().line+1,0))}})},delLineLeft:function(e){return Un(e,function(t){return{from:Oe(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return Un(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){return Un(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(Oe(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Oe(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return ds(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return cs(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return Il(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},he)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},he)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?cs(e,t.head):r},he)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection(" ")},insertSoftTab:function(e){for(var t=[],n=e.listSelections(),r=e.options.tabSize,i=0;i<n.length;i++){var y=n[i].from(),M=Y(e.getLine(y.line),y.ch,r);t.push(ue(r-M%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return or(e,function(){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var i=t[r].head,y=rt(e.doc,i.line).text;if(y){if(i.ch==y.length&&(i=new Oe(i.line,i.ch-1)),i.ch>0)i=new Oe(i.line,i.ch+1),e.replaceRange(y.charAt(i.ch-1)+y.charAt(i.ch-2),Oe(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var M=rt(e.doc,i.line-1).text;M&&(i=new Oe(i.line,1),e.replaceRange(y.charAt(0)+e.doc.lineSeparator()+M.charAt(M.length-1),Oe(i.line-1,M.length-1),i,"+transpose"))}}n.push(new wt(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){return or(e,function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);_n(e)})},openLine:function(e){return e.replaceSelection(`
|
|
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function ds(e,t){var n=rt(e.doc,t),r=ur(n);return r!=n&&(t=Tt(r)),Ba(!0,e,r,t,1)}function Il(e,t){var n=rt(e.doc,t),r=Mi(n);return r!=n&&(t=Tt(r)),Ba(!0,e,n,t,-1)}function cs(e,t){var n=ds(e,t.line),r=rt(e.doc,n.line),i=Ye(r,e.doc.direction);if(!i||i[0].level==0){var y=Math.max(n.ch,r.text.search(/\S/)),M=t.line==n.line&&t.ch<=y&&t.ch;return Oe(n.line,M?0:y,n.sticky)}return n}function qi(e,t,n){if(typeof t=="string"&&(t=xi[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Se}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function Fl(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=Fn(t,e.state.keyMaps[r],n,e);if(i)return i}return e.options.extraKeys&&Fn(t,e.options.extraKeys,n,e)||Fn(t,e.options.keyMap,n,e)}var Ul=new te;function Ti(e,t,n,r){var i=e.state.keySeq;if(i){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Ul.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),fs(e,i+" "+t,n,r))return!0}return fs(e,t,n,r)}function fs(e,t,n,r){var i=Fl(e,t,r);return i=="multi"&&(e.state.keySeq=t),i=="handled"&&Gt(e,"keyHandled",e,t,n),(i=="handled"||i=="multi")&&(V(n),Ta(e)),!!i}function hs(e,t){var n=us(t,!0);return n?t.shiftKey&&!e.state.keySeq?Ti(e,"Shift-"+n,t,function(r){return qi(e,r,!0)})||Ti(e,n,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return qi(e,r)}):Ti(e,n,t,function(r){return qi(e,r)}):!1}function Nl(e,t,n){return Ti(e,"'"+n+"'",t,function(r){return qi(e,r,!0)})}var ja=null;function ms(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=P(),Ee(t,e))return;U&&F<11&&e.keyCode==27&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=n==16||e.shiftKey;var r=hs(t,e);S&&(ja=r?n:null,!r&&n==88&&!Ct&&(s?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),A&&!s&&!r&&n==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),n==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Bl(t)}function Bl(e){var t=e.display.lineDiv;N(t,"CodeMirror-crosshair");function n(r){(r.keyCode==18||!r.altKey)&&(c(t,"CodeMirror-crosshair"),Ge(document,"keyup",n),Ge(document,"mouseover",n))}be(document,"keyup",n),be(document,"mouseover",n)}function ps(e){e.keyCode==16&&(this.doc.sel.shift=!1),Ee(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(Nr(t.display,e)||Ee(t,e)||e.ctrlKey&&!e.altKey||s&&e.metaKey)return;var n=e.keyCode,r=e.charCode;if(S&&n==ja){ja=null,V(e);return}if(S&&(!e.which||e.which<10)&&hs(t,e))return;var i=String.fromCharCode(r==null?n:r);if(i=="\b")return;if(Nl(t,e,i))return;t.display.input.onKeyPress(e)}var jl=400,Wa=function(e,t,n){this.time=e,this.pos=t,this.button=n};Wa.prototype.compare=function(e,t,n){return this.time+jl>e&&dt(t,this.pos)==0&&n==this.button};var Si,wi;function Wl(e,t){var n=+new Date;return wi&&wi.compare(n,e,t)?(Si=wi=null,"triple"):Si&&Si.compare(n,e,t)?(wi=new Wa(n,e,t),Si=null,"double"):(Si=new Wa(n,e,t),wi=null,"single")}function vs(e){var t=this,n=t.display;if(Ee(t,e)||n.activeTouch&&n.input.supportsTouch())return;if(n.input.ensurePolled(),n.shift=e.shiftKey,Nr(n,e)){R||(n.scroller.draggable=!1,setTimeout(function(){return n.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=on(t,e),i=ye(e),y=r?Wl(r,i):"single";if(window.focus(),i==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,i,r,y,e))return;i==1?r?Gl(t,r,y,e):le(e)==n.scroller&&V(e):i==2?(r&&Xi(t.doc,r),setTimeout(function(){return n.input.focus()},20)):i==3&&(L?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,n,r,i){var y="Click";return r=="double"?y="Double"+y:r=="triple"&&(y="Triple"+y),y=(t==1?"Left":t==2?"Middle":"Right")+y,Ti(e,ls(y,i),i,function(M){if(typeof M=="string"&&(M=xi[M]),!M)return!1;var j=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),j=M(e,n)!=Se}finally{e.state.suppressEdits=!1}return j})}function Kl(e,t,n){var r=e.getOption("configureMouse"),i=r?r(e,t,n):{};if(i.unit==null){var y=u?n.shiftKey&&n.metaKey:n.altKey;i.unit=y?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(i.extend==null||e.doc.extend)&&(i.extend=e.doc.extend||n.shiftKey),i.addNew==null&&(i.addNew=s?n.metaKey:n.ctrlKey),i.moveOnDrag==null&&(i.moveOnDrag=!(s?n.altKey:n.ctrlKey)),i}function Gl(e,t,n,r){U?setTimeout(B(vo,e),0):e.curOp.focus=P();var i=Kl(e,n,r),y=e.doc.sel,M;e.options.dragDrop&&we&&!e.isReadOnly()&&n=="single"&&(M=y.contains(t))>-1&&(dt((M=y.ranges[M]).from(),t)<0||t.xRel>0)&&(dt(M.to(),t)>0||t.xRel<0)?zl(e,r,t,i):Vl(e,r,t,i)}function zl(e,t,n,r){var i=e.display,y=!1,M=jt(e,function(z){R&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ge(i.wrapper.ownerDocument,"mouseup",M),Ge(i.wrapper.ownerDocument,"mousemove",j),Ge(i.scroller,"dragstart",K),Ge(i.scroller,"drop",M),y||(V(z),r.addNew||Xi(e.doc,n,null,null,r.extend),R&&!D||U&&F==9?setTimeout(function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()},20):i.input.focus())}),j=function(z){y=y||Math.abs(t.clientX-z.clientX)+Math.abs(t.clientY-z.clientY)>=10},K=function(){return y=!0};R&&(i.scroller.draggable=!0),e.state.draggingText=M,M.copy=!r.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop(),be(i.wrapper.ownerDocument,"mouseup",M),be(i.wrapper.ownerDocument,"mousemove",j),be(i.scroller,"dragstart",K),be(i.scroller,"drop",M),yo(e),setTimeout(function(){return i.input.focus()},20)}function ys(e,t,n){if(n=="char")return new wt(t,t);if(n=="word")return e.findWordAt(t);if(n=="line")return new wt(Oe(t.line,0),ft(e.doc,Oe(t.line+1,0)));var r=n(e,t);return new wt(r.from,r.to)}function Vl(e,t,n,r){var i=e.display,y=e.doc;V(t);var M,j,K=y.sel,z=K.ranges;if(r.addNew&&!r.extend?(j=y.sel.contains(n),j>-1?M=z[j]:M=new wt(n,n)):(M=y.sel.primary(),j=y.sel.primIndex),r.unit=="rectangle")r.addNew||(M=new wt(n,n)),n=on(e,t,!0,!0),j=-1;else{var Z=ys(e,n,r.unit);r.extend?M=Ia(M,Z.anchor,Z.head,r.extend):M=Z}r.addNew?j==-1?(j=z.length,Xt(y,Sr(e,z.concat([M]),j),{scroll:!1,origin:"*mouse"})):z.length>1&&z[j].empty()&&r.unit=="char"&&!r.extend?(Xt(y,Sr(e,z.slice(0,j).concat(z.slice(j+1)),0),{scroll:!1,origin:"*mouse"}),K=y.sel):Fa(y,j,M,pe):(j=0,Xt(y,new cr([M],0),pe),K=y.sel);var ie=n;function fe(Ne){if(dt(ie,Ne)==0)return;if(ie=Ne,r.unit=="rectangle"){for(var qe=[],lt=e.options.tabSize,at=Y(rt(y,n.line).text,n.ch,lt),mt=Y(rt(y,Ne.line).text,Ne.ch,lt),Dt=Math.min(at,mt),Ht=Math.max(at,mt),Ot=Math.min(n.line,Ne.line),sr=Math.min(e.lastLine(),Math.max(n.line,Ne.line));Ot<=sr;Ot++){var nr=rt(y,Ot).text,Mt=me(nr,Dt,lt);Dt==Ht?qe.push(new wt(Oe(Ot,Mt),Oe(Ot,Mt))):nr.length>Mt&&qe.push(new wt(Oe(Ot,Mt),Oe(Ot,me(nr,Ht,lt))))}qe.length||qe.push(new wt(n,n)),Xt(y,Sr(e,K.ranges.slice(0,j).concat(qe),j),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Ne)}else{var ir=M,zt=ys(e,Ne,r.unit),Nt=ir.anchor,It;dt(zt.anchor,Nt)>0?(It=zt.head,Nt=Qr(ir.from(),zt.anchor)):(It=zt.anchor,Nt=vn(ir.to(),zt.head));var Pt=K.ranges.slice(0);Pt[j]=Xl(e,new wt(ft(y,Nt),It)),Xt(y,Sr(e,Pt,j),pe)}}var ce=i.wrapper.getBoundingClientRect(),Te=0;function Ae(Ne){var qe=++Te,lt=on(e,Ne,!0,r.unit=="rectangle");if(!lt)return;if(dt(lt,ie)!=0){e.curOp.focus=P(),fe(lt);var at=Wi(i,y);(lt.line>=at.to||lt.line<at.from)&&setTimeout(jt(e,function(){Te==qe&&Ae(Ne)}),150)}else{var mt=Ne.clientY<ce.top?-20:Ne.clientY>ce.bottom?20:0;mt&&setTimeout(jt(e,function(){if(Te!=qe)return;i.scroller.scrollTop+=mt,Ae(Ne)}),50)}}function ke(Ne){e.state.selectingText=!1,Te=Infinity,Ne&&(V(Ne),i.input.focus()),Ge(i.wrapper.ownerDocument,"mousemove",Ue),Ge(i.wrapper.ownerDocument,"mouseup",Xe),y.history.lastSelOrigin=null}var Ue=jt(e,function(Ne){Ne.buttons===0||!ye(Ne)?ke(Ne):Ae(Ne)}),Xe=jt(e,ke);e.state.selectingText=Xe,be(i.wrapper.ownerDocument,"mousemove",Ue),be(i.wrapper.ownerDocument,"mouseup",Xe)}function Xl(e,t){var n=t.anchor,r=t.head,i=rt(e.doc,n.line);if(dt(n,r)==0&&n.sticky==r.sticky)return t;var y=Ye(i);if(!y)return t;var M=He(y,n.ch,n.sticky),j=y[M];if(j.from!=n.ch&&j.to!=n.ch)return t;var K=M+(j.from==n.ch==(j.level!=1)?0:1);if(K==0||K==y.length)return t;var z;if(r.line!=n.line)z=(r.line-n.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var Z=He(y,r.ch,r.sticky),ie=Z-M||(r.ch-n.ch)*(j.level==1?-1:1);Z==K-1||Z==K?z=ie<0:z=ie>0}var fe=y[K+(z?-1:0)],ce=z==(fe.level==1),Te=ce?fe.from:fe.to,Ae=ce?"after":"before";return n.ch==Te&&n.sticky==Ae?t:new wt(new Oe(n.line,Te,Ae),r)}function bs(e,t,n,r){var i,y;if(t.touches)i=t.touches[0].clientX,y=t.touches[0].clientY;else try{i=t.clientX,y=t.clientY}catch(fe){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&V(t);var M=e.display,j=M.lineDiv.getBoundingClientRect();if(y>j.bottom||!ee(e,n))return J(t);y-=j.top-M.viewOffset;for(var K=0;K<e.display.gutterSpecs.length;++K){var z=M.gutters.childNodes[K];if(z&&z.getBoundingClientRect().right>=i){var Z=gr(e.doc,y),ie=e.display.gutterSpecs[K];return ve(e,n,e,Z,ie.className,t),J(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function Es(e,t){if(Nr(e.display,t)||Yl(e,t))return;if(Ee(e,t,"contextmenu"))return;L||e.display.input.onContextMenu(t)}function Yl(e,t){return ee(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function xs(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ii(e)}var Nn={toString:function(){return"CodeMirror.Init"}},Ts={},ea={};function $l(e){var t=e.optionHandlers;function n(r,i,y,M){e.defaults[r]=i,y&&(t[r]=M?function(j,K,z){z!=Nn&&y(j,K,z)}:y)}e.defineOption=n,e.Init=Nn,n("value","",function(r,i){return r.setValue(i)},!0),n("mode",null,function(r,i){r.doc.modeOption=i,Pa(r)},!0),n("indentUnit",2,Pa,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,function(r){fi(r),ii(r),tr(r)},!0),n("lineSeparator",null,function(r,i){if(r.doc.lineSep=i,!i)return;var y=[],M=r.doc.first;r.doc.iter(function(K){for(var z=0;;){var Z=K.text.indexOf(i,z);if(Z==-1)break;z=Z+i.length,y.push(Oe(M,Z))}M++});for(var j=y.length-1;j>=0;j--)Mn(r.doc,i,y[j],Oe(y[j].line,y[j].ch+i.length))}),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,i,y){r.state.specialChars=new RegExp(i.source+(i.test(" ")?"":"| "),"g"),y!=Nn&&r.refresh()}),n("specialCharPlaceholder",At,function(r){return r.refresh()},!0),n("electricChars",!0),n("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),n("spellcheck",!1,function(r,i){return r.getInputField().spellcheck=i},!0),n("autocorrect",!1,function(r,i){return r.getInputField().autocorrect=i},!0),n("autocapitalize",!1,function(r,i){return r.getInputField().autocapitalize=i},!0),n("rtlMoveVisually",!w),n("wholeLineUpdateBefore",!0),n("theme","default",function(r){xs(r),ci(r)},!0),n("keyMap","default",function(r,i,y){var M=Zi(i),j=y!=Nn&&Zi(y);j&&j.detach&&j.detach(r,M),M.attach&&M.attach(r,j||null)}),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Ql,!0),n("gutters",[],function(r,i){r.display.gutterSpecs=Oa(i,r.options.lineNumbers),ci(r)},!0),n("fixedGutter",!0,function(r,i){r.display.gutters.style.left=i?Ea(r.display)+"px":"0",r.refresh()},!0),n("coverGutterNextToScrollbar",!1,function(r){return On(r)},!0),n("scrollbarStyle","native",function(r){wo(r),On(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),n("lineNumbers",!1,function(r,i){r.display.gutterSpecs=Oa(r.options.gutters,i),ci(r)},!0),n("firstLineNumber",1,ci,!0),n("lineNumberFormatter",function(r){return r},ci,!0),n("showCursorWhenSelecting",!1,ai,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,function(r,i){i=="nocursor"&&(Dn(r),r.display.input.blur()),r.display.input.readOnlyChanged(i)}),n("screenReaderLabel",null,function(r,i){i=i===""?null:i,r.display.input.screenReaderLabelChanged(i)}),n("disableInput",!1,function(r,i){i||r.display.input.reset()},!0),n("dragDrop",!0,Jl),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,ai,!0),n("singleCursorHeightPerLine",!0,ai,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,fi,!0),n("addModeClass",!1,fi,!0),n("pollInterval",100),n("undoDepth",200,function(r,i){return r.doc.history.undoDepth=i}),n("historyEventDelay",1250),n("viewportMargin",10,function(r){return r.refresh()},!0),n("maxHighlightLength",1e4,fi,!0),n("moveInputWithCursor",!0,function(r,i){i||r.display.input.resetPosition()}),n("tabindex",null,function(r,i){return r.display.input.getField().tabIndex=i||""}),n("autofocus",null),n("direction","ltr",function(r,i){return r.doc.setDirection(i)},!0),n("phrases",null)}function Jl(e,t,n){var r=n&&n!=Nn;if(!t!=!r){var i=e.display.dragFunctions,y=t?be:Ge;y(e.display.scroller,"dragstart",i.start),y(e.display.scroller,"dragenter",i.enter),y(e.display.scroller,"dragover",i.over),y(e.display.scroller,"dragleave",i.leave),y(e.display.scroller,"drop",i.drop)}}function Ql(e){e.options.lineWrapping?(N(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(c(e.display.wrapper,"CodeMirror-wrap"),Ii(e)),xa(e),tr(e),ii(e),setTimeout(function(){return On(e)},100)}function _t(e,t){var n=this;if(!(this instanceof _t))return new _t(e,t);this.options=t=t?I(t):{},I(Ts,t,!1);var r=t.value;typeof r=="string"?r=new rr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new _t.inputStyles[t.inputStyle](this),y=this.display=new dl(e,r,i,t);y.wrapper.CodeMirror=this,xs(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),wo(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new te,keySeq:null,specialChars:null},t.autofocus&&!o&&y.input.focus(),U&&F<11&&setTimeout(function(){return n.display.input.reset(!0)},20),Zl(this),_l(),dn(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){n.hasFocus()&&!n.state.focused&&Sa(n)},20):Dn(this);for(var M in ea)ea.hasOwnProperty(M)&&ea[M](this,t[M],Nn);Ao(this),t.finishInit&&t.finishInit(this);for(var j=0;j<Ka.length;++j)Ka[j](this);cn(this),R&&t.lineWrapping&&getComputedStyle(y.lineDiv).textRendering=="optimizelegibility"&&(y.lineDiv.style.textRendering="auto")}_t.defaults=Ts,_t.optionHandlers=ea;function Zl(e){var t=e.display;be(t.scroller,"mousedown",jt(e,vs)),U&&F<11?be(t.scroller,"dblclick",jt(e,function(K){if(Ee(e,K))return;var z=on(e,K);if(!z||Ha(e,K)||Nr(e.display,K))return;V(K);var Z=e.findWordAt(z);Xi(e.doc,Z.anchor,Z.head)})):be(t.scroller,"dblclick",function(K){return Ee(e,K)||V(K)}),be(t.scroller,"contextmenu",function(K){return Es(e,K)}),be(t.input.getField(),"contextmenu",function(K){t.scroller.contains(K.target)||Es(e,K)});var n,r={end:0};function i(){t.activeTouch&&(n=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function y(K){if(K.touches.length!=1)return!1;var z=K.touches[0];return z.radiusX<=1&&z.radiusY<=1}function M(K,z){if(z.left==null)return!0;var Z=z.left-K.left,ie=z.top-K.top;return Z*Z+ie*ie>20*20}be(t.scroller,"touchstart",function(K){if(!Ee(e,K)&&!y(K)&&!Ha(e,K)){t.input.ensurePolled(),clearTimeout(n);var z=+new Date;t.activeTouch={start:z,moved:!1,prev:z-r.end<=300?r:null},K.touches.length==1&&(t.activeTouch.left=K.touches[0].pageX,t.activeTouch.top=K.touches[0].pageY)}}),be(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),be(t.scroller,"touchend",function(K){var z=t.activeTouch;if(z&&!Nr(t,K)&&z.left!=null&&!z.moved&&new Date-z.start<300){var Z=e.coordsChar(t.activeTouch,"page"),ie;!z.prev||M(z,z.prev)?ie=new wt(Z,Z):!z.prev.prev||M(z,z.prev.prev)?ie=e.findWordAt(Z):ie=new wt(Oe(Z.line,0),ft(e.doc,Oe(Z.line+1,0))),e.setSelection(ie.anchor,ie.head),e.focus(),V(K)}i()}),be(t.scroller,"touchcancel",i),be(t.scroller,"scroll",function(){t.scroller.clientHeight&&(si(e,t.scroller.scrollTop),ln(e,t.scroller.scrollLeft,!0),ve(e,"scroll",e))}),be(t.scroller,"mousewheel",function(K){return Oo(e,K)}),be(t.scroller,"DOMMouseScroll",function(K){return Oo(e,K)}),be(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(K){Ee(e,K)||ne(K)},over:function(K){Ee(e,K)||(Dl(e,K),ne(K))},start:function(K){return Al(e,K)},drop:jt(e,Ll),leave:function(K){Ee(e,K)||is(e)}};var j=t.input.getField();be(j,"keyup",function(K){return ps.call(e,K)}),be(j,"keydown",jt(e,ms)),be(j,"keypress",jt(e,gs)),be(j,"focus",function(K){return Sa(e,K)}),be(j,"blur",function(K){return Dn(e,K)})}var Ka=[];_t.defineInitHook=function(e){return Ka.push(e)};function Ci(e,t,n,r){var i=e.doc,y;n==null&&(n="add"),n=="smart"&&(i.mode.indent?y=vr(e,t).state:n="prev");var M=e.options.tabSize,j=rt(i,t),K=Y(j.text,null,M);j.stateAfter&&(j.stateAfter=null);var z=j.text.match(/^\s*/)[0],Z;if(!r&&!/\S/.test(j.text))Z=0,n="not";else if(n=="smart"&&(Z=i.mode.indent(y,j.text.slice(z.length),j.text),Z==Se||Z>150)){if(!r)return;n="prev"}n=="prev"?t>i.first?Z=Y(rt(i,t-1).text,null,M):Z=0:n=="add"?Z=K+e.options.indentUnit:n=="subtract"?Z=K-e.options.indentUnit:typeof n=="number"&&(Z=K+n),Z=Math.max(0,Z);var ie="",fe=0;if(e.options.indentWithTabs)for(var ce=Math.floor(Z/M);ce;--ce)fe+=M,ie+=" ";if(fe<Z&&(ie+=ue(Z-fe)),ie!=z)return Mn(i,ie,Oe(t,0),Oe(t,z.length),"+input"),j.stateAfter=null,!0;for(var Te=0;Te<i.sel.ranges.length;Te++){var Ae=i.sel.ranges[Te];if(Ae.head.line==t&&Ae.head.ch<z.length){var ke=Oe(t,z.length);Fa(i,Te,new wt(ke,ke));break}}}var wr=null;function ta(e){wr=e}function Ga(e,t,n,r,i){var y=e.doc;e.display.shift=!1,r||(r=y.sel);var M=+new Date-200,j=i=="paste"||e.state.pasteIncoming>M,K=ht(t),z=null;if(j&&r.ranges.length>1)if(wr&&wr.text.join(`
|
|
`)==t){if(r.ranges.length%wr.text.length==0){z=[];for(var Z=0;Z<wr.text.length;Z++)z.push(y.splitLines(wr.text[Z]))}}else K.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(z=Fe(K,function(Ue){return[Ue]}));for(var ie=e.curOp.updateInput,fe=r.ranges.length-1;fe>=0;fe--){var ce=r.ranges[fe],Te=ce.from(),Ae=ce.to();ce.empty()&&(n&&n>0?Te=Oe(Te.line,Te.ch-n):e.state.overwrite&&!j?Ae=Oe(Ae.line,Math.min(rt(y,Ae.line).text.length,Ae.ch+xe(K).length)):j&&wr&&wr.lineWise&&wr.text.join(`
|
|
`)==K.join(`
|
|
`)&&(Te=Ae=Oe(Te.line,0)));var ke={from:Te,to:Ae,text:z?z[fe%z.length]:K,origin:i||(j?"paste":e.state.cutIncoming>M?"cut":"+input")};kn(e.doc,ke),Gt(e,"inputRead",e,ke)}t&&!j&&ws(e,t),_n(e),e.curOp.updateInput<2&&(e.curOp.updateInput=ie),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ss(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&or(t,function(){return Ga(t,n,0,null,"paste")}),!0}function ws(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)continue;var y=e.getModeAt(i.head),M=!1;if(y.electricChars){for(var j=0;j<y.electricChars.length;j++)if(t.indexOf(y.electricChars.charAt(j))>-1){M=Ci(e,i.head.line,"smart");break}}else y.electricInput&&(y.electricInput.test(rt(e.doc,i.head.line).text.slice(0,i.head.ch))&&(M=Ci(e,i.head.line,"smart")));M&&Gt(e,"electricInput",e,i.head.line)}}function Cs(e){for(var t=[],n=[],r=0;r<e.doc.sel.ranges.length;r++){var i=e.doc.sel.ranges[r].head.line,y={anchor:Oe(i,0),head:Oe(i+1,0)};n.push(y),t.push(e.getRange(y.anchor,y.head))}return{text:t,ranges:n}}function Ls(e,t,n,r){e.setAttribute("autocorrect",n?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function As(){var e=a("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=a("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return R?e.style.width="1000px":e.setAttribute("wrap","off"),E&&(e.style.border="1px solid black"),Ls(e),t}function ql(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,i){var y=this.options,M=y[r];if(y[r]==i&&r!="mode")return;y[r]=i,t.hasOwnProperty(r)&&jt(this,t[r])(this,i,M),ve(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,i){this.state.keyMaps[i?"push":"unshift"](Zi(r))},removeKeyMap:function(r){for(var i=this.state.keyMaps,y=0;y<i.length;++y)if(i[y]==r||i[y].name==r)return i.splice(y,1),!0},addOverlay:Jt(function(r,i){var y=r.token?r:e.getMode(this.options,r);if(y.startState)throw new Error("Overlays may not be stateful.");Re(this.state.overlays,{mode:y,modeSpec:r,opaque:i&&i.opaque,priority:i&&i.priority||0},function(M){return M.priority}),this.state.modeGen++,tr(this)}),removeOverlay:Jt(function(r){for(var i=this.state.overlays,y=0;y<i.length;++y){var M=i[y].modeSpec;if(M==r||typeof r=="string"&&M.name==r){i.splice(y,1),this.state.modeGen++,tr(this);return}}}),indentLine:Jt(function(r,i,y){typeof i!="string"&&typeof i!="number"&&(i==null?i=this.options.smartIndent?"smart":"prev":i=i?"add":"subtract"),kr(this.doc,r)&&Ci(this,r,i,y)}),indentSelection:Jt(function(r){for(var i=this.doc.sel.ranges,y=-1,M=0;M<i.length;M++){var j=i[M];if(j.empty())j.head.line>y&&(Ci(this,j.head.line,r,!0),y=j.head.line,M==this.doc.sel.primIndex&&_n(this));else{var K=j.from(),z=j.to(),Z=Math.max(y,K.line);y=Math.min(this.lastLine(),z.line-(z.ch?0:1))+1;for(var ie=Z;ie<y;++ie)Ci(this,ie,r);var fe=this.doc.sel.ranges;K.ch==0&&i.length==fe.length&&fe[M].from().ch>0&&Fa(this.doc,M,new wt(K,fe[M].to()),ge)}}}),getTokenAt:function(r,i){return Ai(this,r,i)},getLineTokens:function(r,i){return Ai(this,Oe(r),i,!0)},getTokenTypeAt:function(r){r=ft(this.doc,r);var i=Zr(this,rt(this.doc,r.line)),y=0,M=(i.length-1)/2,j=r.ch,K;if(j==0)K=i[2];else for(;;){var z=y+M>>1;if((z?i[z*2-1]:0)>=j)M=z;else if(i[z*2+1]<j)y=z+1;else{K=i[z*2+2];break}}var Z=K?K.indexOf("overlay "):-1;return Z<0?K:Z==0?null:K.slice(0,Z-1)},getModeAt:function(r){var i=this.doc.mode;return i.innerMode?e.innerMode(i,this.getTokenAt(r).state).mode:i},getHelper:function(r,i){return this.getHelpers(r,i)[0]},getHelpers:function(r,i){var y=[];if(!n.hasOwnProperty(i))return y;var M=n[i],j=this.getModeAt(r);if(typeof j[i]=="string")M[j[i]]&&y.push(M[j[i]]);else if(j[i])for(var K=0;K<j[i].length;K++){var z=M[j[i][K]];z&&y.push(z)}else j.helperType&&M[j.helperType]?y.push(M[j.helperType]):M[j.name]&&y.push(M[j.name]);for(var Z=0;Z<M._global.length;Z++){var ie=M._global[Z];ie.pred(j,this)&&se(y,ie.val)==-1&&y.push(ie.val)}return y},getStateAfter:function(r,i){var y=this.doc;return r=yn(y,r==null?y.first+y.size-1:r),vr(this,r+1,i).state},cursorCoords:function(r,i){var y,M=this.doc.sel.primary();return r==null?y=M.head:typeof r=="object"?y=ft(this.doc,r):y=r?M.from():M.to(),Tr(this,y,i||"page")},charCoords:function(r,i){return pa(this,ft(this.doc,r),i||"page")},coordsChar:function(r,i){return r=lo(this,r,i||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,i){return r=lo(this,{top:r,left:0},i||"page").top,gr(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,i,y){var M=!1,j;if(typeof r=="number"){var K=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>K&&(r=K,M=!0),j=rt(this.doc,r)}else j=r;return Ui(this,j,{top:0,left:0},i||"page",y||M).top+(M?this.doc.height-xr(j):0)},defaultTextHeight:function(){return Ln(this.display)},defaultCharWidth:function(){return An(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,i,y,M,j){var K=this.display;r=Tr(this,ft(this.doc,r));var z=r.bottom,Z=r.left;if(i.style.position="absolute",i.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(i),K.sizer.appendChild(i),M=="over")z=r.top;else if(M=="above"||M=="near"){var ie=Math.max(K.wrapper.clientHeight,this.doc.height),fe=Math.max(K.sizer.clientWidth,K.lineSpace.clientWidth);(M=="above"||r.bottom+i.offsetHeight>ie)&&r.top>i.offsetHeight?z=r.top-i.offsetHeight:r.bottom+i.offsetHeight<=ie&&(z=r.bottom),Z+i.offsetWidth>fe&&(Z=fe-i.offsetWidth)}i.style.top=z+"px",i.style.left=i.style.right="",j=="right"?(Z=K.sizer.clientWidth-i.offsetWidth,i.style.right="0px"):(j=="left"?Z=0:j=="middle"&&(Z=(K.sizer.clientWidth-i.offsetWidth)/2),i.style.left=Z+"px"),y&&Js(this,{left:Z,top:z,right:Z+i.offsetWidth,bottom:z+i.offsetHeight})},triggerOnKeyDown:Jt(ms),triggerOnKeyPress:Jt(gs),triggerOnKeyUp:ps,triggerOnMouseDown:Jt(vs),execCommand:function(r){if(xi.hasOwnProperty(r))return xi[r].call(null,this)},triggerElectric:Jt(function(r){ws(this,r)}),findPosH:function(r,i,y,M){var j=1;i<0&&(j=-1,i=-i);for(var K=ft(this.doc,r),z=0;z<i&&!(K=za(this.doc,K,j,y,M),K.hitSide);++z);return K},moveH:Jt(function(r,i){var y=this;this.extendSelectionsBy(function(M){return y.display.shift||y.doc.extend||M.empty()?za(y.doc,M.head,r,i,y.options.rtlMoveVisually):r<0?M.from():M.to()},he)}),deleteH:Jt(function(r,i){var y=this.doc.sel,M=this.doc;y.somethingSelected()?M.replaceSelection("",null,"+delete"):Un(this,function(j){var K=za(M,j.head,r,i,!1);return r<0?{from:K,to:j.head}:{from:j.head,to:K}})}),findPosV:function(r,i,y,M){var j=1,K=M;i<0&&(j=-1,i=-i);for(var z=ft(this.doc,r),Z=0;Z<i;++Z){var ie=Tr(this,z,"div");if(K==null?K=ie.left:ie.left=K,z=Ds(this,ie,j,y),z.hitSide)break}return z},moveV:Jt(function(r,i){var y=this,M=this.doc,j=[],K=!this.display.shift&&!M.extend&&M.sel.somethingSelected();if(M.extendSelectionsBy(function(Z){if(K)return r<0?Z.from():Z.to();var ie=Tr(y,Z.head,"div");Z.goalColumn!=null&&(ie.left=Z.goalColumn),j.push(ie.left);var fe=Ds(y,ie,r,i);return i=="page"&&Z==M.sel.primary()&&Ca(y,pa(y,fe,"div").top-ie.top),fe},he),j.length)for(var z=0;z<M.sel.ranges.length;z++)M.sel.ranges[z].goalColumn=j[z]}),findWordAt:function(r){var i=this.doc,y=rt(i,r.line).text,M=r.ch,j=r.ch;if(y){var K=this.getHelper(r,"wordChars");(r.sticky=="before"||j==y.length)&&M?--M:++j;for(var z=y.charAt(M),Z=Me(z,K)?function(ie){return Me(ie,K)}:/\s/.test(z)?function(ie){return/\s/.test(ie)}:function(ie){return!/\s/.test(ie)&&!Me(ie)};M>0&&Z(y.charAt(M-1));)--M;for(;j<y.length&&Z(y.charAt(j));)++j}return new wt(Oe(r.line,M),Oe(r.line,j))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?N(this.display.cursorDiv,"CodeMirror-overwrite"):c(this.display.cursorDiv,"CodeMirror-overwrite"),ve(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==P()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:Jt(function(r,i){oi(this,r,i)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-Dr(this)-this.display.barHeight,width:r.scrollWidth-Dr(this)-this.display.barWidth,clientHeight:fa(this),clientWidth:nn(this)}},scrollIntoView:Jt(function(r,i){r==null?(r={from:this.doc.sel.primary().head,to:null},i==null&&(i=this.options.cursorScrollMargin)):typeof r=="number"?r={from:Oe(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=i||0,r.from.line!=null?Qs(this,r):Eo(this,r.from,r.to,r.margin)}),setSize:Jt(function(r,i){var y=this,M=function(K){return typeof K=="number"||/^\d+$/.test(String(K))?K+"px":K};r!=null&&(this.display.wrapper.style.width=M(r)),i!=null&&(this.display.wrapper.style.height=M(i)),this.options.lineWrapping&&ao(this);var j=this.display.viewFrom;this.doc.iter(j,this.display.viewTo,function(K){if(K.widgets){for(var z=0;z<K.widgets.length;z++)if(K.widgets[z].noHScroll){Kr(y,j,"widget");break}}++j}),this.curOp.forceUpdate=!0,ve(this,"refresh",this)}),operation:function(r){return or(this,r)},startOperation:function(){return dn(this)},endOperation:function(){return cn(this)},refresh:Jt(function(){var r=this.display.cachedTextHeight;tr(this),this.curOp.forceUpdate=!0,ii(this),oi(this,this.doc.scrollLeft,this.doc.scrollTop),Da(this.display),(r==null||Math.abs(r-Ln(this.display))>.5||this.options.lineWrapping)&&xa(this),ve(this,"refresh",this)}),swapDoc:Jt(function(r){var i=this.doc;return i.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),ii(this),this.display.input.reset(),oi(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Gt(this,"swapDoc",this,i),i}),phrase:function(r){var i=this.options.phrases;return i&&Object.prototype.hasOwnProperty.call(i,r)?i[r]:r},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},re(e),e.registerHelper=function(r,i,y){n.hasOwnProperty(r)||(n[r]=e[r]={_global:[]}),n[r][i]=y},e.registerGlobalHelper=function(r,i,y,M){e.registerHelper(r,i,M),n[r]._global.push({pred:y,val:M})}}function za(e,t,n,r,i){var y=t,M=n,j=rt(e,t.line),K=i&&e.direction=="rtl"?-n:n;function z(){var Xe=t.line+K;return Xe<e.first||Xe>=e.first+e.size?!1:(t=new Oe(Xe,t.ch,t.sticky),j=rt(e,Xe))}function Z(Xe){var Ne;if(r=="codepoint"){var qe=j.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(qe)?Ne=null:Ne=new Oe(t.line,Math.max(0,Math.min(j.text.length,t.ch+n*(qe>=55296&&qe<56320?2:1))),-n)}else i?Ne=Ml(e.cm,j,t,n):Ne=Na(j,t,n);if(Ne==null)if(!Xe&&z())t=Ba(i,e.cm,j,t.line,K);else return!1;else t=Ne;return!0}if(r=="char"||r=="codepoint")Z();else if(r=="column")Z(!0);else if(r=="word"||r=="group")for(var ie=null,fe=r=="group",ce=e.cm&&e.cm.getHelper(t,"wordChars"),Te=!0;!(n<0&&!Z(!Te));Te=!1){var Ae=j.text.charAt(t.ch)||`
|
|
`,ke=Me(Ae,ce)?"w":fe&&Ae==`
|
|
`?"n":!fe||/\s/.test(Ae)?null:"p";if(fe&&!Te&&!ke&&(ke="s"),ie&&ie!=ke){n<0&&(n=1,Z(),t.sticky="after");break}if(ke&&(ie=ke),n>0&&!Z(!Te))break}var Ue=$i(e,t,y,M,!0);return Gn(y,Ue)&&(Ue.hitSide=!0),Ue}function Ds(e,t,n,r){var i=e.doc,y=t.left,M;if(r=="page"){var j=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),K=Math.max(j-.5*Ln(e.display),3);M=(n>0?t.bottom:t.top)+n*K}else r=="line"&&(M=n>0?t.bottom+3:t.top-3);for(var z;!(z=va(e,y,M),!z.outside);){if(n<0?M<=0:M>=i.height){z.hitSide=!0;break}M+=n*5}return z}var Lt=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new te,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Lt.prototype.init=function(e){var t=this,n=this,r=n.cm,i=n.div=e.lineDiv;Ls(i,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function y(j){for(var K=j.target;K;K=K.parentNode){if(K==i)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(K.className))break}return!1}be(i,"paste",function(j){if(!y(j)||Ee(r,j)||Ss(j,r))return;F<=11&&setTimeout(jt(r,function(){return t.updateFromDOM()}),20)}),be(i,"compositionstart",function(j){t.composing={data:j.data,done:!1}}),be(i,"compositionupdate",function(j){t.composing||(t.composing={data:j.data,done:!1})}),be(i,"compositionend",function(j){t.composing&&(j.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),be(i,"touchstart",function(){return n.forceCompositionEnd()}),be(i,"input",function(){t.composing||t.readFromDOMSoon()});function M(j){if(!y(j)||Ee(r,j))return;if(r.somethingSelected())ta({lineWise:!1,text:r.getSelections()}),j.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var K=Cs(r);ta({lineWise:!0,text:K.text}),j.type=="cut"&&r.operation(function(){r.setSelections(K.ranges,0,ge),r.replaceSelection("",null,"cut")})}else return;if(j.clipboardData){j.clipboardData.clearData();var z=wr.text.join(`
|
|
`);if(j.clipboardData.setData("Text",z),j.clipboardData.getData("Text")==z){j.preventDefault();return}}var Z=As(),ie=Z.firstChild;r.display.lineSpace.insertBefore(Z,r.display.lineSpace.firstChild),ie.value=wr.text.join(`
|
|
`);var fe=document.activeElement;X(ie),setTimeout(function(){r.display.lineSpace.removeChild(Z),fe.focus(),fe==i&&n.showPrimarySelection()},50)}be(i,"copy",M),be(i,"cut",M)},Lt.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Lt.prototype.prepareSelection=function(){var e=po(this.cm,!1);return e.focus=document.activeElement==this.div,e},Lt.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},Lt.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Lt.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,n=t.doc.sel.primary(),r=n.from(),i=n.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||i.line<t.display.viewFrom){e.removeAllRanges();return}var y=ra(t,e.anchorNode,e.anchorOffset),M=ra(t,e.focusNode,e.focusOffset);if(y&&!y.bad&&M&&!M.bad&&dt(Qr(y,M),r)==0&&dt(vn(y,M),i)==0)return;var j=t.display.view,K=r.line>=t.display.viewFrom&&_s(t,r)||{node:j[0].measure.map[2],offset:0},z=i.line<t.display.viewTo&&_s(t,i);if(!z){var Z=j[j.length-1].measure,ie=Z.maps?Z.maps[Z.maps.length-1]:Z.map;z={node:ie[ie.length-1],offset:ie[ie.length-2]-ie[ie.length-3]}}if(!K||!z){e.removeAllRanges();return}var fe=e.rangeCount&&e.getRangeAt(0),ce;try{ce=g(K.node,K.offset,z.offset,z.node)}catch(Te){}ce&&(!A&&t.state.focused?(e.collapse(K.node,K.offset),ce.collapsed||(e.removeAllRanges(),e.addRange(ce))):(e.removeAllRanges(),e.addRange(ce)),fe&&e.anchorNode==null?e.addRange(fe):A&&this.startGracePeriod()),this.rememberSelection()},Lt.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},Lt.prototype.showMultipleSelections=function(e){d(this.cm.display.cursorDiv,e.cursors),d(this.cm.display.selectionDiv,e.selection)},Lt.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Lt.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return x(this.div,t)},Lt.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},Lt.prototype.blur=function(){this.div.blur()},Lt.prototype.getField=function(){return this.div},Lt.prototype.supportsTouch=function(){return!0},Lt.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():or(this.cm,function(){return e.cm.curOp.selectionChanged=!0});function t(){e.cm.state.focused&&(e.pollSelection(),e.polling.set(e.cm.options.pollInterval,t))}this.polling.set(this.cm.options.pollInterval,t)},Lt.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Lt.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(l&&v&&this.cm.display.gutterSpecs.length&&eu(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(this.composing)return;this.rememberSelection();var n=ra(t,e.anchorNode,e.anchorOffset),r=ra(t,e.focusNode,e.focusOffset);n&&r&&or(t,function(){Xt(t.doc,zr(n,r),ge),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},Lt.prototype.pollContent=function(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,n=e.doc.sel.primary(),r=n.from(),i=n.to();if(r.ch==0&&r.line>e.firstLine()&&(r=Oe(r.line-1,rt(e.doc,r.line-1).length)),i.ch==rt(e.doc,i.line).text.length&&i.line<e.lastLine()&&(i=Oe(i.line+1,0)),r.line<t.viewFrom||i.line>t.viewTo-1)return!1;var y,M,j;r.line==t.viewFrom||(y=sn(e,r.line))==0?(M=Tt(t.view[0].line),j=t.view[0].node):(M=Tt(t.view[y].line),j=t.view[y-1].node.nextSibling);var K=sn(e,i.line),z,Z;if(K==t.view.length-1?(z=t.viewTo-1,Z=t.lineDiv.lastChild):(z=Tt(t.view[K+1].line)-1,Z=t.view[K+1].node.previousSibling),!j)return!1;for(var ie=e.doc.splitLines(tu(e,j,Z,M,z)),fe=Pr(e.doc,Oe(M,0),Oe(z,rt(e.doc,z).text.length));ie.length>1&&fe.length>1;)if(xe(ie)==xe(fe))ie.pop(),fe.pop(),z--;else if(ie[0]==fe[0])ie.shift(),fe.shift(),M++;else break;for(var ce=0,Te=0,Ae=ie[0],ke=fe[0],Ue=Math.min(Ae.length,ke.length);ce<Ue&&Ae.charCodeAt(ce)==ke.charCodeAt(ce);)++ce;for(var Xe=xe(ie),Ne=xe(fe),qe=Math.min(Xe.length-(ie.length==1?ce:0),Ne.length-(fe.length==1?ce:0));Te<qe&&Xe.charCodeAt(Xe.length-Te-1)==Ne.charCodeAt(Ne.length-Te-1);)++Te;if(ie.length==1&&fe.length==1&&M==r.line)for(;ce&&ce>r.ch&&Xe.charCodeAt(Xe.length-Te-1)==Ne.charCodeAt(Ne.length-Te-1);)ce--,Te++;ie[ie.length-1]=Xe.slice(0,Xe.length-Te).replace(/^\u200b+/,""),ie[0]=ie[0].slice(ce).replace(/\u200b+$/,"");var lt=Oe(M,ce),at=Oe(z,fe.length?xe(fe).length-Te:0);if(ie.length>1||ie[0]||dt(lt,at))return Mn(e.doc,ie,lt,at,"+input"),!0},Lt.prototype.ensurePolled=function(){this.forceCompositionEnd()},Lt.prototype.reset=function(){this.forceCompositionEnd()},Lt.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},Lt.prototype.readFromDOMSoon=function(){var e=this;if(this.readDOMTimeout!=null)return;this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing)if(e.composing.done)e.composing=null;else return;e.updateFromDOM()},80)},Lt.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&or(this.cm,function(){return tr(e.cm)})},Lt.prototype.setUneditable=function(e){e.contentEditable="false"},Lt.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||jt(this.cm,Ga)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},Lt.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},Lt.prototype.onContextMenu=function(){},Lt.prototype.resetPosition=function(){},Lt.prototype.needsContentAttribute=!0;function _s(e,t){var n=ha(e,t.line);if(!n||n.hidden)return null;var r=rt(e.doc,t.line),i=eo(n,r,t.line),y=Ye(r,e.doc.direction),M="left";if(y){var j=He(y,t.ch);M=j%2?"right":"left"}var K=no(i.map,t.ch,M);return K.offset=K.collapse=="right"?K.end:K.start,K}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Bn(e,t){return t&&(e.bad=!0),e}function tu(e,t,n,r,i){var y="",M=!1,j=e.doc.lineSeparator(),K=!1;function z(ce){return function(Te){return Te.id==ce}}function Z(){M&&(y+=j,K&&(y+=j),M=K=!1)}function ie(ce){ce&&(Z(),y+=ce)}function fe(ce){if(ce.nodeType==1){var Te=ce.getAttribute("cm-text");if(Te){ie(Te);return}var Ae=ce.getAttribute("cm-marker"),ke;if(Ae){var Ue=e.findMarks(Oe(r,0),Oe(i+1,0),z(+Ae));Ue.length&&(ke=Ue[0].find(0))&&ie(Pr(e.doc,ke.from,ke.to).join(j));return}if(ce.getAttribute("contenteditable")=="false")return;var Xe=/^(pre|div|p|li|table|br)$/i.test(ce.nodeName);if(!/^br$/i.test(ce.nodeName)&&ce.textContent.length==0)return;Xe&&Z();for(var Ne=0;Ne<ce.childNodes.length;Ne++)fe(ce.childNodes[Ne]);/^(pre|p)$/i.test(ce.nodeName)&&(K=!0),Xe&&(M=!0)}else ce.nodeType==3&&ie(ce.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(fe(t),t==n);)t=t.nextSibling,K=!1;return y}function ra(e,t,n){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[n],!r)return Bn(e.clipPos(Oe(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var y=e.display.view[i];if(y.node==r)return ru(y,t,n)}}function ru(e,t,n){var r=e.text.firstChild,i=!1;if(!t||!x(r,t))return Bn(Oe(Tt(e.line),0),!0);if(t==r&&(i=!0,t=r.childNodes[n],n=0,!t)){var y=e.rest?xe(e.rest):e.line;return Bn(Oe(Tt(y),y.text.length),i)}var M=t.nodeType==3?t:null,j=t;for(!M&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(M=t.firstChild,n&&(n=M.nodeValue.length));j.parentNode!=r;)j=j.parentNode;var K=e.measure,z=K.maps;function Z(ke,Ue,Xe){for(var Ne=-1;Ne<(z?z.length:0);Ne++)for(var qe=Ne<0?K.map:z[Ne],lt=0;lt<qe.length;lt+=3){var at=qe[lt+2];if(at==ke||at==Ue){var mt=Tt(Ne<0?e.line:e.rest[Ne]),Dt=qe[lt]+Xe;return(Xe<0||at!=ke)&&(Dt=qe[lt+(Xe?1:0)]),Oe(mt,Dt)}}}var ie=Z(M,j,n);if(ie)return Bn(ie,i);for(var fe=j.nextSibling,ce=M?M.nodeValue.length-n:0;fe;fe=fe.nextSibling){if(ie=Z(fe,fe.firstChild,0),ie)return Bn(Oe(ie.line,ie.ch-ce),i);ce+=fe.textContent.length}for(var Te=j.previousSibling,Ae=n;Te;Te=Te.previousSibling){if(ie=Z(Te,Te.firstChild,-1),ie)return Bn(Oe(ie.line,ie.ch+Ae),i);Ae+=Te.textContent.length}}var kt=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new te,this.hasSelection=!1,this.composing=null};kt.prototype.init=function(e){var t=this,n=this,r=this.cm;this.createField(e);var i=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),E&&(i.style.width="0px"),be(i,"input",function(){U&&F>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()}),be(i,"paste",function(M){if(Ee(r,M)||Ss(M,r))return;r.state.pasteIncoming=+new Date,n.fastPoll()});function y(M){if(Ee(r,M))return;if(r.somethingSelected())ta({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var j=Cs(r);ta({lineWise:!0,text:j.text}),M.type=="cut"?r.setSelections(j.ranges,null,ge):(n.prevInput="",i.value=j.text.join(`
|
|
`),X(i))}else return;M.type=="cut"&&(r.state.cutIncoming=+new Date)}be(i,"cut",y),be(i,"copy",y),be(e.scroller,"paste",function(M){if(Nr(e,M)||Ee(r,M))return;if(!i.dispatchEvent){r.state.pasteIncoming=+new Date,n.focus();return}var j=new Event("paste");j.clipboardData=M.clipboardData,i.dispatchEvent(j)}),be(e.lineSpace,"selectstart",function(M){Nr(e,M)||V(M)}),be(i,"compositionstart",function(){var M=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:M,range:r.markText(M,r.getCursor("to"),{className:"CodeMirror-composing"})}}),be(i,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},kt.prototype.createField=function(e){this.wrapper=As(),this.textarea=this.wrapper.firstChild},kt.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},kt.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=po(e);if(e.options.moveInputWithCursor){var i=Tr(e,n.sel.primary().head,"div"),y=t.wrapper.getBoundingClientRect(),M=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+M.top-y.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+M.left-y.left))}return r},kt.prototype.showSelection=function(e){var t=this.cm,n=t.display;d(n.cursorDiv,e.cursors),d(n.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},kt.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&X(this.textarea),U&&F>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",U&&F>=9&&(this.hasSelection=null))},kt.prototype.getField=function(){return this.textarea},kt.prototype.supportsTouch=function(){return!1},kt.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||P()!=this.textarea))try{this.textarea.focus()}catch(e){}},kt.prototype.blur=function(){this.textarea.blur()},kt.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},kt.prototype.receivedFocus=function(){this.slowPoll()},kt.prototype.slowPoll=function(){var e=this;if(this.pollingFast)return;this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},kt.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function n(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,n)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,n)},kt.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||ot(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(U&&F>=9&&this.hasSelection===i||s&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var y=i.charCodeAt(0);if(y==8203&&!r&&(r="\u200B"),y==8666)return this.reset(),this.cm.execCommand("undo")}for(var M=0,j=Math.min(r.length,i.length);M<j&&r.charCodeAt(M)==i.charCodeAt(M);)++M;return or(t,function(){Ga(t,i.slice(M),r.length-M,null,e.composing?"*compose":null),i.length>1e3||i.indexOf(`
|
|
`)>-1?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},kt.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},kt.prototype.onKeyPress=function(){U&&F>=9&&(this.hasSelection=null),this.fastPoll()},kt.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,i=t.textarea;t.contextMenuPending&&t.contextMenuPending();var y=on(n,e),M=r.scroller.scrollTop;if(!y||S)return;var j=n.options.resetSelectionOnContextMenu;j&&n.doc.sel.contains(y)==-1&&jt(n,Xt)(n.doc,zr(y),ge);var K=i.style.cssText,z=t.wrapper.style.cssText,Z=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",i.style.cssText=`position: absolute; width: 30px; height: 30px;
|
|
top: `+(e.clientY-Z.top-5)+"px; left: "+(e.clientX-Z.left-5)+`px;
|
|
z-index: 1000; background: `+(U?"rgba(255, 255, 255, .05)":"transparent")+`;
|
|
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var ie;R&&(ie=window.scrollY),r.input.focus(),R&&window.scrollTo(null,ie),r.input.reset(),n.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=ce,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll);function fe(){if(i.selectionStart!=null){var Ae=n.somethingSelected(),ke="\u200B"+(Ae?i.value:"");i.value="\u21DA",i.value=ke,t.prevInput=Ae?"":"\u200B",i.selectionStart=1,i.selectionEnd=ke.length,r.selForContextMenu=n.doc.sel}}function ce(){if(t.contextMenuPending!=ce)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=z,i.style.cssText=K,U&&F<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=M),i.selectionStart!=null){(!U||U&&F<9)&&fe();var Ae=0,ke=function(){r.selForContextMenu==n.doc.sel&&i.selectionStart==0&&i.selectionEnd>0&&t.prevInput=="\u200B"?jt(n,Xo)(n):Ae++<10?r.detectingSelectAll=setTimeout(ke,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(ke,200)}}if(U&&F>=9&&fe(),L){ne(e);var Te=function(){Ge(window,"mouseup",Te),setTimeout(ce,20)};be(window,"mouseup",Te)}else setTimeout(ce,50)},kt.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},kt.prototype.setUneditable=function(){},kt.prototype.needsContentAttribute=!1;function nu(e,t){if(t=t?I(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),t.autofocus==null){var n=P();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}function r(){e.value=j.getValue()}var i;if(e.form&&(be(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var y=e.form;i=y.submit;try{var M=y.submit=function(){r(),y.submit=i,y.submit(),y.submit=M}}catch(K){}}t.finishInit=function(K){K.save=r,K.getTextArea=function(){return e},K.toTextArea=function(){K.toTextArea=isNaN,r(),e.parentNode.removeChild(K.getWrapperElement()),e.style.display="",e.form&&(Ge(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=i))}},e.style.display="none";var j=_t(function(K){return e.parentNode.insertBefore(K,e.nextSibling)},t);return j}function iu(e){e.off=Ge,e.on=be,e.wheelEventPixels=cl,e.Doc=rr,e.splitLines=ht,e.countColumn=Y,e.findColumn=me,e.isWordChar=Ce,e.Pass=Se,e.signal=ve,e.Line=rn,e.changeEnd=Vr,e.scrollbarModel=So,e.Pos=Oe,e.cmpPos=dt,e.modes=Ft,e.mimeModes=bt,e.resolveMode=lr,e.getMode=pr,e.modeExtensions=fr,e.extendMode=ia,e.copyState=Lr,e.startState=Kn,e.innerMode=Hn,e.commands=xi,e.keyMap=Br,e.keyName=us,e.isModifierKey=ss,e.lookupKey=Fn,e.normalizeKeyMap=kl,e.StringStream=Rt,e.SharedTextMarker=yi,e.TextMarker=Yr,e.LineWidget=vi,e.e_preventDefault=V,e.e_stopPropagation=$,e.e_stop=ne,e.addClass=N,e.contains=x,e.rmClass=c,e.keyNames=$r}$l(_t),ql(_t);var au="iter insert remove copy getEditor constructor".split(" ");for(var na in rr.prototype)rr.prototype.hasOwnProperty(na)&&se(au,na)<0&&(_t.prototype[na]=function(e){return function(){return e.apply(this.doc,arguments)}}(rr.prototype[na]));return re(rr),_t.inputStyles={textarea:kt,contenteditable:Lt},_t.defineMode=function(e){!_t.defaults.mode&&e!="null"&&(_t.defaults.mode=e),Cr.apply(this,arguments)},_t.defineMIME=Rr,_t.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),_t.defineMIME("text/plain","null"),_t.defineExtension=function(e,t){_t.prototype[e]=t},_t.defineDocExtension=function(e,t){rr.prototype[e]=t},_t.fromTextArea=nu,iu(_t),_t.version="5.58.2",_t})},Y1PL:function(ut,Qe,q){"use strict";q.r(Qe),q.d(Qe,"ResizableTextArea",function(){return se});var Q=q("wx14"),G=q("1OyB"),A=q("vuIU"),W=q("Ji7U"),k=q("LK+K"),O=q("cDcd"),U=q("VTBJ"),F=q("rePB"),R=q("Zm9Q"),_=q("Kwbf"),v=q("c+Xe"),S=q("m+aA"),D=q("bdgK"),C=new Map;function T(ge){ge.forEach(function(pe){var he,me=pe.target;(he=C.get(me))===null||he===void 0||he.forEach(function(ae){return ae(me)})})}var E=new D.default(T),l=null,o=null;function s(ge,pe){C.has(ge)||(C.set(ge,new Set),E.observe(ge)),C.get(ge).add(pe)}function u(ge,pe){C.has(ge)&&(C.get(ge).delete(pe),C.get(ge).size||(E.unobserve(ge),C.delete(ge)))}var w=function(ge){Object(W.a)(he,ge);var pe=Object(k.a)(he);function he(){return Object(G.a)(this,he),pe.apply(this,arguments)}return Object(A.a)(he,[{key:"render",value:function(){return this.props.children}}]),he}(O.Component),m=O.createContext(null);function h(ge){var pe=ge.children,he=ge.onBatchResize,me=O.useRef(0),ae=O.useRef([]),ue=O.useContext(m),xe=O.useCallback(function(Fe,Re,Ie){me.current+=1;var Ke=me.current;ae.current.push({size:Fe,element:Re,data:Ie}),Promise.resolve().then(function(){Ke===me.current&&(he==null||he(ae.current),ae.current=[])}),ue==null||ue(Fe,Re,Ie)},[he,ue]);return O.createElement(m.Provider,{value:xe},pe)}function L(ge){var pe=ge.children,he=ge.disabled,me=O.useRef(null),ae=O.useRef(null),ue=O.useContext(m),xe=O.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Fe=O.isValidElement(pe)&&Object(v.c)(pe),Re=Fe?pe.ref:null,Ie=O.useMemo(function(){return Object(v.a)(Re,me)},[Re,me]),Ke=O.useRef(ge);Ke.current=ge;var De=O.useCallback(function(Ce){var Me=Ke.current,Be=Me.onResize,je=Me.data,_e=Ce.getBoundingClientRect(),Le=_e.width,$e=_e.height,Je=Ce.offsetWidth,We=Ce.offsetHeight,He=Math.floor(Le),et=Math.floor($e);if(xe.current.width!==He||xe.current.height!==et||xe.current.offsetWidth!==Je||xe.current.offsetHeight!==We){var Ye={width:He,height:et,offsetWidth:Je,offsetHeight:We};xe.current=Ye;var Ve=Je===Math.round(Le)?Le:Je,be=We===Math.round($e)?$e:We,Ze=Object(U.a)(Object(U.a)({},Ye),{},{offsetWidth:Ve,offsetHeight:be});ue==null||ue(Ze,Ce,je),Be&&Promise.resolve().then(function(){Be(Ze,Ce)})}},[]);return O.useEffect(function(){var Ce=Object(S.a)(me.current)||Object(S.a)(ae.current);return Ce&&!he&&s(Ce,De),function(){return u(Ce,De)}},[me.current,he]),O.createElement(w,{ref:ae},Fe?O.cloneElement(pe,{ref:Ie}):pe)}var p="rc-observer-key";function c(ge){var pe=ge.children,he=Object(R.a)(pe);return he.map(function(me,ae){var ue=(me==null?void 0:me.key)||"".concat(p,"-").concat(ae);return O.createElement(L,Object(Q.a)({},ge,{key:ue}),me)})}c.Collection=h;var f=c,d=q("bT9E"),a=q("TSYQ"),b=q.n(a),g=`
|
|
min-height:0 !important;
|
|
max-height:none !important;
|
|
height:0 !important;
|
|
visibility:hidden !important;
|
|
overflow:hidden !important;
|
|
position:absolute !important;
|
|
z-index:-1000 !important;
|
|
top:0 !important;
|
|
right:0 !important
|
|
`,x=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","font-variant","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing","word-break"],P={},N;function H(ge){var pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,he=ge.getAttribute("id")||ge.getAttribute("data-reactid")||ge.getAttribute("name");if(pe&&P[he])return P[he];var me=window.getComputedStyle(ge),ae=me.getPropertyValue("box-sizing")||me.getPropertyValue("-moz-box-sizing")||me.getPropertyValue("-webkit-box-sizing"),ue=parseFloat(me.getPropertyValue("padding-bottom"))+parseFloat(me.getPropertyValue("padding-top")),xe=parseFloat(me.getPropertyValue("border-bottom-width"))+parseFloat(me.getPropertyValue("border-top-width")),Fe=x.map(function(Ie){return"".concat(Ie,":").concat(me.getPropertyValue(Ie))}).join(";"),Re={sizingStyle:Fe,paddingSize:ue,borderSize:xe,boxSizing:ae};return pe&&he&&(P[he]=Re),Re}function X(ge){var pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,he=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,me=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;N||(N=document.createElement("textarea"),N.setAttribute("tab-index","-1"),N.setAttribute("aria-hidden","true"),document.body.appendChild(N)),ge.getAttribute("wrap")?N.setAttribute("wrap",ge.getAttribute("wrap")):N.removeAttribute("wrap");var ae=H(ge,pe),ue=ae.paddingSize,xe=ae.borderSize,Fe=ae.boxSizing,Re=ae.sizingStyle;N.setAttribute("style","".concat(Re,";").concat(g)),N.value=ge.value||ge.placeholder||"";var Ie=Number.MIN_SAFE_INTEGER,Ke=Number.MAX_SAFE_INTEGER,De=N.scrollHeight,Ce;if(Fe==="border-box"?De+=xe:Fe==="content-box"&&(De-=ue),he!==null||me!==null){N.value=" ";var Me=N.scrollHeight-ue;he!==null&&(Ie=Me*he,Fe==="border-box"&&(Ie=Ie+ue+xe),De=Math.max(Ie,De)),me!==null&&(Ke=Me*me,Fe==="border-box"&&(Ke=Ke+ue+xe),Ce=De>Ke?"":"hidden",De=Math.min(Ke,De))}return{height:De,minHeight:Ie,maxHeight:Ke,overflowY:Ce,resize:"none"}}var B=q("Gytx"),I=q.n(B),Y;(function(ge){ge[ge.NONE=0]="NONE",ge[ge.RESIZING=1]="RESIZING",ge[ge.RESIZED=2]="RESIZED"})(Y||(Y={}));var te=function(ge){Object(W.a)(he,ge);var pe=Object(k.a)(he);function he(me){var ae;return Object(G.a)(this,he),ae=pe.call(this,me),ae.nextFrameActionId=void 0,ae.resizeFrameId=void 0,ae.textArea=void 0,ae.saveTextArea=function(ue){ae.textArea=ue},ae.handleResize=function(ue){var xe=ae.state.resizeStatus,Fe=ae.props,Re=Fe.autoSize,Ie=Fe.onResize;if(xe!==Y.NONE)return;typeof Ie=="function"&&Ie(ue),Re&&ae.resizeOnNextFrame()},ae.resizeOnNextFrame=function(){cancelAnimationFrame(ae.nextFrameActionId),ae.nextFrameActionId=requestAnimationFrame(ae.resizeTextarea)},ae.resizeTextarea=function(){var ue=ae.props.autoSize;if(!ue||!ae.textArea)return;var xe=ue.minRows,Fe=ue.maxRows,Re=X(ae.textArea,!1,xe,Fe);ae.setState({textareaStyles:Re,resizeStatus:Y.RESIZING},function(){cancelAnimationFrame(ae.resizeFrameId),ae.resizeFrameId=requestAnimationFrame(function(){ae.setState({resizeStatus:Y.RESIZED},function(){ae.resizeFrameId=requestAnimationFrame(function(){ae.setState({resizeStatus:Y.NONE}),ae.fixFirefoxAutoScroll()})})})})},ae.renderTextArea=function(){var ue=ae.props,xe=ue.prefixCls,Fe=xe===void 0?"rc-textarea":xe,Re=ue.autoSize,Ie=ue.onResize,Ke=ue.className,De=ue.disabled,Ce=ae.state,Me=Ce.textareaStyles,Be=Ce.resizeStatus,je=Object(d.a)(ae.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),_e=b()(Fe,Ke,Object(F.a)({},"".concat(Fe,"-disabled"),De));"value"in je&&(je.value=je.value||"");var Le=Object(U.a)(Object(U.a)(Object(U.a)({},ae.props.style),Me),Be===Y.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return O.createElement(f,{onResize:ae.handleResize,disabled:!(Re||Ie)},O.createElement("textarea",Object(Q.a)({},je,{className:_e,style:Le,ref:ae.saveTextArea})))},ae.state={textareaStyles:{},resizeStatus:Y.NONE},ae}return Object(A.a)(he,[{key:"componentDidUpdate",value:function(ae){(ae.value!==this.props.value||!I()(ae.autoSize,this.props.autoSize))&&this.resizeTextarea()}},{key:"componentWillUnmount",value:function(){cancelAnimationFrame(this.nextFrameActionId),cancelAnimationFrame(this.resizeFrameId)}},{key:"fixFirefoxAutoScroll",value:function(){try{if(document.activeElement===this.textArea){var ae=this.textArea.selectionStart,ue=this.textArea.selectionEnd;this.textArea.setSelectionRange(ae,ue)}}catch(xe){}}},{key:"render",value:function(){return this.renderTextArea()}}]),he}(O.Component),se=te,de=function(ge){Object(W.a)(he,ge);var pe=Object(k.a)(he);function he(me){var ae;Object(G.a)(this,he),ae=pe.call(this,me),ae.resizableTextArea=void 0,ae.focus=function(){ae.resizableTextArea.textArea.focus()},ae.saveTextArea=function(xe){ae.resizableTextArea=xe},ae.handleChange=function(xe){var Fe=ae.props.onChange;ae.setValue(xe.target.value,function(){ae.resizableTextArea.resizeTextarea()}),Fe&&Fe(xe)},ae.handleKeyDown=function(xe){var Fe=ae.props,Re=Fe.onPressEnter,Ie=Fe.onKeyDown;xe.keyCode===13&&Re&&Re(xe),Ie&&Ie(xe)};var ue=typeof me.value=="undefined"||me.value===null?me.defaultValue:me.value;return ae.state={value:ue},ae}return Object(A.a)(he,[{key:"setValue",value:function(ae,ue){"value"in this.props||this.setState({value:ae},ue)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return O.createElement(se,Object(Q.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ae){return"value"in ae?{value:ae.value}:null}}]),he}(O.Component),Se=Qe.default=de},ZpRC:function(ut,Qe,q){"use strict";function Q(v){return typeof v=="object"&&v!=null&&v.nodeType===1}function G(v,S){return(!S||v!=="hidden")&&v!=="visible"&&v!=="clip"}function A(v,S){if(v.clientHeight<v.scrollHeight||v.clientWidth<v.scrollWidth){var D=getComputedStyle(v,null);return G(D.overflowY,S)||G(D.overflowX,S)||function(C){var T=function(E){if(!E.ownerDocument||!E.ownerDocument.defaultView)return null;try{return E.ownerDocument.defaultView.frameElement}catch(l){return null}}(C);return!!T&&(T.clientHeight<C.scrollHeight||T.clientWidth<C.scrollWidth)}(v)}return!1}function W(v,S,D,C,T,E,l,o){return E<v&&l>S||E>v&&l<S?0:E<=v&&o<=D||l>=S&&o>=D?E-v-C:l>S&&o<D||E<v&&o>D?l-S+T:0}var k=function(v,S){var D=window,C=S.scrollMode,T=S.block,E=S.inline,l=S.boundary,o=S.skipOverflowHiddenElements,s=typeof l=="function"?l:function(Me){return Me!==l};if(!Q(v))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,w=[],m=v;Q(m)&&s(m);){if((m=m.parentElement)===u){w.push(m);break}m!=null&&m===document.body&&A(m)&&!A(document.documentElement)||m!=null&&A(m,o)&&w.push(m)}for(var h=D.visualViewport?D.visualViewport.width:innerWidth,L=D.visualViewport?D.visualViewport.height:innerHeight,p=window.scrollX||pageXOffset,c=window.scrollY||pageYOffset,f=v.getBoundingClientRect(),d=f.height,a=f.width,b=f.top,g=f.right,x=f.bottom,P=f.left,N=T==="start"||T==="nearest"?b:T==="end"?x:b+d/2,H=E==="center"?P+a/2:E==="end"?g:P,X=[],B=0;B<w.length;B++){var I=w[B],Y=I.getBoundingClientRect(),te=Y.height,se=Y.width,de=Y.top,Se=Y.right,ge=Y.bottom,pe=Y.left;if(C==="if-needed"&&b>=0&&P>=0&&x<=L&&g<=h&&b>=de&&x<=ge&&P>=pe&&g<=Se)return X;var he=getComputedStyle(I),me=parseInt(he.borderLeftWidth,10),ae=parseInt(he.borderTopWidth,10),ue=parseInt(he.borderRightWidth,10),xe=parseInt(he.borderBottomWidth,10),Fe=0,Re=0,Ie="offsetWidth"in I?I.offsetWidth-I.clientWidth-me-ue:0,Ke="offsetHeight"in I?I.offsetHeight-I.clientHeight-ae-xe:0;if(u===I)Fe=T==="start"?N:T==="end"?N-L:T==="nearest"?W(c,c+L,L,ae,xe,c+N,c+N+d,d):N-L/2,Re=E==="start"?H:E==="center"?H-h/2:E==="end"?H-h:W(p,p+h,h,me,ue,p+H,p+H+a,a),Fe=Math.max(0,Fe+c),Re=Math.max(0,Re+p);else{Fe=T==="start"?N-de-ae:T==="end"?N-ge+xe+Ke:T==="nearest"?W(de,ge,te,ae,xe+Ke,N,N+d,d):N-(de+te/2)+Ke/2,Re=E==="start"?H-pe-me:E==="center"?H-(pe+se/2)+Ie/2:E==="end"?H-Se+ue+Ie:W(pe,Se,se,me,ue+Ie,H,H+a,a);var De=I.scrollLeft,Ce=I.scrollTop;N+=Ce-(Fe=Math.max(0,Math.min(Ce+Fe,I.scrollHeight-te+Ke))),H+=De-(Re=Math.max(0,Math.min(De+Re,I.scrollWidth-se+Ie)))}X.push({el:I,top:Fe,left:Re})}return X};function O(v){return v===Object(v)&&Object.keys(v).length!==0}function U(v,S){S===void 0&&(S="auto");var D="scrollBehavior"in document.body.style;v.forEach(function(C){var T=C.el,E=C.top,l=C.left;T.scroll&&D?T.scroll({top:E,left:l,behavior:S}):(T.scrollTop=E,T.scrollLeft=l)})}function F(v){return v===!1?{block:"end",inline:"nearest"}:O(v)?v:{block:"start",inline:"nearest"}}function R(v,S){var D=!v.ownerDocument.documentElement.contains(v);if(O(S)&&typeof S.behavior=="function")return S.behavior(D?[]:k(v,S));if(D)return;var C=F(S);return U(k(v,C),C.behavior)}var _=Qe.a=R},bNIU:function(ut,Qe,q){ut.exports={flex_box_center:"flex_box_center___4ZFPv",flex_space_between:"flex_space_between___1poVp",flex_box_vertical_center:"flex_box_vertical_center___2vHuy",flex_box_center_end:"flex_box_center_end___3AGfr",flex_box_column:"flex_box_column___9QgjS",bg:"bg___2D1BG",flexRow:"flexRow___3qWci",flexJustifyCenter:"flexJustifyCenter___ONt7G",flexAlignEnd:"flexAlignEnd___XXRbD",flexAlingCenter:"flexAlingCenter___3bK98",flexAlignCenter:"flexAlignCenter___2Ct2A",flexColumn:"flexColumn___JTR6P",formWrap:"formWrap___3QUHG",titleWrap:"titleWrap___1MIxp",fieldWrap:"fieldWrap___YXlbk",mdWrap:"mdWrap___ZlPmu",backgroundFa:"backgroundFa___2s4Lu",button:"button___KQ_S9",icons:"icons___zqUcb",navBar:"navBar___3taGH",active:"active____5MwL",tipWrap:"tipWrap___2wfhG",tip:"tip___3fuVl",width300:"width300___1tL-J",popover:"popover___2mWr7",groupWrap:"groupWrap___2zY7s",check:"check___3Eies"}},bT9E:function(ut,Qe,q){"use strict";q.d(Qe,"a",function(){return G});var Q=q("VTBJ");function G(A,W){var k=Object(Q.a)({},A);return Array.isArray(W)&&W.forEach(function(O){delete k[O]}),k}},c5Ni:function(ut,Qe,q){},dejd:function(ut,Qe,q){},dmUQ:function(ut,Qe,q){"use strict";var Q=q("Ff2n"),G=q("rePB"),A=q("1OyB"),W=q("vuIU"),k=q("Ji7U"),O=q("md7G"),U=q("foSv"),F=q("cDcd"),R=q.n(F),_=q("TSYQ"),v=q.n(_),S=q("4IlW");function D(d,a){var b=Object.keys(d);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(d);a&&(g=g.filter(function(x){return Object.getOwnPropertyDescriptor(d,x).enumerable})),b.push.apply(b,g)}return b}function C(d){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?D(Object(b),!0).forEach(function(g){Object(G.a)(d,g,b[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(b)):D(Object(b)).forEach(function(g){Object.defineProperty(d,g,Object.getOwnPropertyDescriptor(b,g))})}return d}function T(d){var a=E();return function(){var g=Object(U.a)(d),x;if(a){var P=Object(U.a)(this).constructor;x=Reflect.construct(g,arguments,P)}else x=g.apply(this,arguments);return Object(O.a)(this,x)}}function E(){if(typeof Reflect=="undefined"||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(d){return!1}}function l(){}function o(d){d.preventDefault()}var s=function(a){return a.replace(/[^\w.-]+/g,"")},u=200,w=600,m=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,h=function(a){return a!=null},L=function(a,b){return b===a||typeof b=="number"&&typeof a=="number"&&isNaN(b)&&isNaN(a)},p=function(d){Object(k.a)(b,d);var a=T(b);function b(g){var x;Object(A.a)(this,b),x=a.call(this,g),x.onKeyDown=function(H){var X=x.props,B=X.onKeyDown,I=X.onPressEnter;if(H.keyCode===S.a.UP){var Y=x.getRatio(H);x.up(H,Y,null),x.stop()}else if(H.keyCode===S.a.DOWN){var te=x.getRatio(H);x.down(H,te,null),x.stop()}else H.keyCode===S.a.ENTER&&I&&I(H);if(x.recordCursorPosition(),x.lastKeyCode=H.keyCode,B){for(var se=arguments.length,de=new Array(se>1?se-1:0),Se=1;Se<se;Se++)de[Se-1]=arguments[Se];B.apply(void 0,[H].concat(de))}},x.onKeyUp=function(H){var X=x.props.onKeyUp;if(x.stop(),x.recordCursorPosition(),X){for(var B=arguments.length,I=new Array(B>1?B-1:0),Y=1;Y<B;Y++)I[Y-1]=arguments[Y];X.apply(void 0,[H].concat(I))}},x.onChange=function(H){var X=x.props.onChange;x.state.focused&&(x.inputting=!0),x.rawInput=x.props.parser(x.getValueFromEvent(H)),x.setState({inputValue:x.rawInput}),X(x.toNumber(x.rawInput))},x.onMouseUp=function(){var H=x.props.onMouseUp;x.recordCursorPosition(),H&&H.apply(void 0,arguments)},x.onFocus=function(){var H;x.setState({focused:!0}),(H=x.props).onFocus.apply(H,arguments)},x.onBlur=function(){var H=x.props.onBlur;x.inputting=!1,x.setState({focused:!1});var X=x.getCurrentValidValue(x.state.inputValue),B=x.setValue(X,l);if(H){var I=x.input.value,Y=x.getInputDisplayValue({focus:!1,value:B});x.input.value=Y&&Number(Y),H.apply(void 0,arguments),x.input.value=I}},x.getRatio=function(H){var X=1;return H.metaKey||H.ctrlKey?X=.1:H.shiftKey&&(X=10),X},x.getFullNum=function(H){return isNaN(H)?H:/e/i.test(String(H))?Number(H).toFixed(18).replace(/\.?0+$/,""):H},x.getPrecision=function(H){if(h(x.props.precision))return x.props.precision;var X=String(H);if(X.indexOf("e-")>=0)return parseInt(X.slice(X.indexOf("e-")+2),10);var B=0;return X.indexOf(".")>=0&&(B=X.length-X.indexOf(".")-1),B},x.getInputDisplayValue=function(H){var X=H||x.state,B=X.focused,I=X.inputValue,Y=X.value,te;B?te=I:te=x.toPrecisionAsStep(Y),te==null&&(te="");var se=x.formatWrapper(te);return h(x.props.decimalSeparator)&&(se=se.toString().replace(".",x.props.decimalSeparator)),se},x.recordCursorPosition=function(){try{x.cursorStart=x.input.selectionStart,x.cursorEnd=x.input.selectionEnd,x.currentValue=x.input.value,x.cursorBefore=x.input.value.substring(0,x.cursorStart),x.cursorAfter=x.input.value.substring(x.cursorEnd)}catch(H){}},x.restoreByAfter=function(H){if(H===void 0)return!1;var X=x.input.value,B=X.lastIndexOf(H);if(B===-1)return!1;var I=x.cursorBefore.length;return x.lastKeyCode===S.a.DELETE&&x.cursorBefore.charAt(I-1)===H[0]?(x.fixCaret(I,I),!0):B+H.length===X.length?(x.fixCaret(B,B),!0):!1},x.partRestoreByAfter=function(H){return H===void 0?!1:Array.prototype.some.call(H,function(X,B){var I=H.substring(B);return x.restoreByAfter(I)})},x.isNotCompleteNumber=function(H){return isNaN(H)||H===""||H===null||H&&H.toString().indexOf(".")===H.toString().length-1},x.stop=function(){x.autoStepTimer&&clearTimeout(x.autoStepTimer)},x.down=function(H,X,B){x.pressingUpOrDown=!0,x.step("down",H,X,B)},x.up=function(H,X,B){x.pressingUpOrDown=!0,x.step("up",H,X,B)},x.saveInput=function(H){x.input=H};var P=g.value;P===void 0&&(P=g.defaultValue),x.state={focused:g.autoFocus};var N=x.getValidValue(x.toNumber(P));return x.state=C(C({},x.state),{},{inputValue:x.toPrecisionAsStep(N),value:N}),x}return Object(W.a)(b,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(x){var P=this.props,N=P.value,H=P.onChange,X=P.max,B=P.min,I=this.state.focused;if(x){if(!L(x.value,N)||!L(x.max,X)||!L(x.min,B)){var Y=I?N:this.getValidValue(N),te;this.pressingUpOrDown?te=Y:this.inputting?te=this.rawInput:te=this.toPrecisionAsStep(Y),this.setState({value:Y,inputValue:te})}var se="value"in this.props?N:this.state.value;"max"in this.props&&x.max!==X&&typeof se=="number"&&se>X&&H&&H(X),"min"in this.props&&x.min!==B&&typeof se=="number"&&se<B&&H&&H(B)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var de=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===S.a.BACKSPACE?de=this.cursorStart-1:this.lastKeyCode===S.a.DELETE&&(de=this.cursorStart):de=this.input.value.length,this.fixCaret(de,de)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case S.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case S.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(Se){}if(this.lastKeyCode=null,!this.pressingUpOrDown)return;this.props.focusOnUpDown&&this.state.focused&&(document.activeElement!==this.input&&this.focus())}},{key:"componentWillUnmount",value:function(){this.stop()}},{key:"getCurrentValidValue",value:function(x){var P=x;return P===""?P="":this.isNotCompleteNumber(parseFloat(P))?P=this.state.value:P=this.getValidValue(P),this.toNumber(P)}},{key:"getValueFromEvent",value:function(x){var P=x.target.value.trim().replace(/。/g,".");return h(this.props.decimalSeparator)&&(P=P.replace(this.props.decimalSeparator,".")),P}},{key:"getValidValue",value:function(x){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,N=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,H=parseFloat(x);return isNaN(H)?x:(H<P&&(H=P),H>N&&(H=N),H)}},{key:"setValue",value:function(x,P){var N=this.props.precision,H=this.isNotCompleteNumber(parseFloat(x))?null:parseFloat(x),X=this.state.value,B=X===void 0?null:X,I=this.state.inputValue,Y=I===void 0?null:I,te=typeof H=="number"?H.toFixed(N):"".concat(H),se=H!==B||te!=="".concat(Y);return"value"in this.props?(Y=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:Y},P)):this.setState({value:H,inputValue:this.toPrecisionAsStep(x)},P),se&&this.props.onChange(H),H}},{key:"getMaxPrecision",value:function(x){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,N=this.props,H=N.precision,X=N.step;if(h(H))return H;var B=this.getPrecision(P),I=this.getPrecision(X),Y=this.getPrecision(x);return x?Math.max(Y,B+I):B+I}},{key:"getPrecisionFactor",value:function(x){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,N=this.getMaxPrecision(x,P);return Math.pow(10,N)}},{key:"focus",value:function(){this.input.focus(),this.recordCursorPosition()}},{key:"blur",value:function(){this.input.blur()}},{key:"select",value:function(){this.input.select()}},{key:"formatWrapper",value:function(x){return this.props.formatter?this.props.formatter(x):x}},{key:"toPrecisionAsStep",value:function(x){if(this.isNotCompleteNumber(x)||x==="")return x;var P=Math.abs(this.getMaxPrecision(x));return isNaN(P)?x.toString():Number(x).toFixed(P)}},{key:"toNumber",value:function(x){var P=this.props.precision,N=this.state.focused,H=x&&x.length>16&&N;return this.isNotCompleteNumber(x)||H?x:h(P)?Math.round(x*Math.pow(10,P))/Math.pow(10,P):Number(x)}},{key:"upStep",value:function(x,P){var N=this.props.step,H=this.getPrecisionFactor(x,P),X=Math.abs(this.getMaxPrecision(x,P)),B=((H*x+H*N*P)/H).toFixed(X);return this.toNumber(B)}},{key:"downStep",value:function(x,P){var N=this.props.step,H=this.getPrecisionFactor(x,P),X=Math.abs(this.getMaxPrecision(x,P)),B=((H*x-H*N*P)/H).toFixed(X);return this.toNumber(B)}},{key:"step",value:function(x,P){var N=this,H=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,X=arguments.length>3?arguments[3]:void 0;this.stop(),P&&(P.persist(),P.preventDefault());var B=this.props;if(B.disabled)return;var I=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(I))return;var Y=this["".concat(x,"Step")](I,H),te=Y>B.max||Y<B.min;if(Y>B.max?Y=B.max:Y<B.min&&(Y=B.min),this.setValue(Y,null),this.setState({focused:!0},function(){N.pressingUpOrDown=!1}),te)return;this.autoStepTimer=setTimeout(function(){N[x](P,H,!0)},X?u:w)}},{key:"fixCaret",value:function(x,P){if(x===void 0||P===void 0||!this.input||!this.input.value)return;try{var N=this.input.selectionStart,H=this.input.selectionEnd;(x!==N||P!==H)&&this.input.setSelectionRange(x,P)}catch(X){}}},{key:"render",value:function(){var x,P=this.props,N=P.prefixCls,H=P.disabled,X=P.readOnly,B=P.useTouch,I=P.autoComplete,Y=P.upHandler,te=P.downHandler,se=P.className,de=P.max,Se=P.min,ge=P.style,pe=P.title,he=P.onMouseEnter,me=P.onMouseLeave,ae=P.onMouseOver,ue=P.onMouseOut,xe=P.required,Fe=P.onClick,Re=P.tabIndex,Ie=P.type,Ke=P.placeholder,De=P.id,Ce=P.inputMode,Me=P.pattern,Be=P.step,je=P.maxLength,_e=P.autoFocus,Le=P.name,$e=P.onPaste,Je=P.onInput,We=Object(Q.a)(P,["prefixCls","disabled","readOnly","useTouch","autoComplete","upHandler","downHandler","className","max","min","style","title","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","required","onClick","tabIndex","type","placeholder","id","inputMode","pattern","step","maxLength","autoFocus","name","onPaste","onInput"]),He=this.state,et=He.value,Ye=He.focused,Ve=v()(N,(x={},Object(G.a)(x,se,!!se),Object(G.a)(x,"".concat(N,"-disabled"),H),Object(G.a)(x,"".concat(N,"-focused"),Ye),x)),be={};Object.keys(We).forEach(function(ne){(ne.substr(0,5)==="data-"||ne.substr(0,5)==="aria-"||ne==="role")&&(be[ne]=We[ne])});var Ze=!X&&!H,Ge=this.getInputDisplayValue(null),ve=(et||et===0)&&(isNaN(et)||Number(et)>=de),Ee=(et||et===0)&&(isNaN(et)||Number(et)<=Se),oe=ve||H||X,ee=Ee||H||X,re=v()("".concat(N,"-handler"),"".concat(N,"-handler-up"),Object(G.a)({},"".concat(N,"-handler-up-disabled"),oe)),V=v()("".concat(N,"-handler"),"".concat(N,"-handler-down"),Object(G.a)({},"".concat(N,"-handler-down-disabled"),ee)),$=B?{onTouchStart:oe?l:this.up,onTouchEnd:this.stop}:{onMouseDown:oe?l:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},J=B?{onTouchStart:ee?l:this.down,onTouchEnd:this.stop}:{onMouseDown:ee?l:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return R.a.createElement("div",{className:Ve,style:ge,title:pe,onMouseEnter:he,onMouseLeave:me,onMouseOver:ae,onMouseOut:ue,onFocus:function(){return null},onBlur:function(){return null}},R.a.createElement("div",{className:"".concat(N,"-handler-wrap")},R.a.createElement("span",Object.assign({unselectable:"on"},$,{role:"button","aria-label":"Increase Value","aria-disabled":oe,className:re}),Y||R.a.createElement("span",{unselectable:"on",className:"".concat(N,"-handler-up-inner"),onClick:o})),R.a.createElement("span",Object.assign({unselectable:"on"},J,{role:"button","aria-label":"Decrease Value","aria-disabled":ee,className:V}),te||R.a.createElement("span",{unselectable:"on",className:"".concat(N,"-handler-down-inner"),onClick:o}))),R.a.createElement("div",{className:"".concat(N,"-input-wrap")},R.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":Se,"aria-valuemax":de,"aria-valuenow":et,required:xe,type:Ie,placeholder:Ke,onPaste:$e,onClick:Fe,onMouseUp:this.onMouseUp,className:"".concat(N,"-input"),tabIndex:Re,autoComplete:I,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:Ze?this.onKeyDown:l,onKeyUp:Ze?this.onKeyUp:l,autoFocus:_e,maxLength:je,readOnly:X,disabled:H,max:de,min:Se,step:Be,name:Le,title:pe,id:De,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(Ge),pattern:Me,inputMode:Ce,onInput:Je},be))))}}]),b}(R.a.Component);p.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:m,min:-m,step:1,style:{},onChange:l,onKeyDown:l,onPressEnter:l,onFocus:l,onBlur:l,parser:s,required:!1,autoComplete:"off"};var c=p,f=Qe.a=c},fnXi:function(ut,Qe,q){"use strict";var Q=q("2qtc"),G=q("kLXV"),A=q("cDcd"),W=q.n(A),k=q("Ty5D"),O=q("9kvl"),U=q("93VE"),F=q.n(U),R=function(v){var S=v.activeIndex,D=v.isEdit,C=D===void 0?!0:D,T=v.dispatch,E=v.practiceSetting,l=Object(k.i)(),o=l.id,s=l.challengesId,u=Object(A.useMemo)(function(){return[{name:"\u672C\u5173\u4EFB\u52A1",url:"/shixuns/".concat(o,"/edit/").concat(s,"/editcheckpoint")},{name:"\u8BC4\u6D4B\u8BBE\u7F6E",url:"/shixuns/".concat(o,"/edit/").concat(s,"/tab=2")},{name:"\u53C2\u8003\u7B54\u6848",url:"/shixuns/".concat(o,"/edit/").concat(s,"/tab=3")},{name:"\u5173\u5361\u6392\u884C\u699C",url:"/shixuns/".concat(o,"/edit/").concat(s,"/tab=4")}]},[o,s]),w=function(h){var L,p=function(){O.d.push(h),T({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};E!=null&&(L=E.sideBar)!==null&&L!==void 0&&L.confirmLeave?G.a.confirm({title:"\u79BB\u5F00\u6B64\u9875\u63D0\u793A",content:"\u7CFB\u7EDF\u53EF\u80FD\u4E0D\u4F1A\u4FDD\u5B58\u60A8\u6240\u505A\u7684\u66F4\u6539\u3002",okText:"\u79BB\u5F00",cancelText:"\u53D6\u6D88",onOk:function(){p()}}):p()};return W.a.createElement("ul",{className:"challenge-nav"},C?u.map(function(m,h){return S===h?W.a.createElement("li",{key:m.url}," ",W.a.createElement("a",{className:"active"},m.name)," "):W.a.createElement("li",{key:m.url}," ",W.a.createElement("a",{onClick:function(){return w(m.url)}},m.name)," ")}):W.a.createElement("li",{key:u[0].url}," ",W.a.createElement("a",{className:"active"},u[0].name)," "))};Qe.a=Object(O.a)(function(_){var v=_.globalSetting,S=_.practiceSetting;return{globalSetting:v,practiceSetting:S}})(R)},kSUc:function(ut,Qe,q){},lZu9:function(ut,Qe,q){(function(Q){Q(q("VrN/"),q("1eCo"),q("8EBN"))})(function(Q){"use strict";Q.defineMode("markdown",function(G,A){var W=Q.getMode(G,"text/html"),k=W.name=="null";function O(B){if(Q.findModeByName){var I=Q.findModeByName(B);I&&(B=I.mime||I.mimes[0])}var Y=Q.getMode(G,B);return Y.name=="null"?null:Y}A.highlightFormatting===void 0&&(A.highlightFormatting=!1),A.maxBlockquoteDepth===void 0&&(A.maxBlockquoteDepth=0),A.taskLists===void 0&&(A.taskLists=!1),A.strikethrough===void 0&&(A.strikethrough=!1),A.emoji===void 0&&(A.emoji=!1),A.fencedCodeBlockHighlighting===void 0&&(A.fencedCodeBlockHighlighting=!0),A.fencedCodeBlockDefaultMode===void 0&&(A.fencedCodeBlockDefaultMode="text/plain"),A.xml===void 0&&(A.xml=!0),A.tokenTypeOverrides===void 0&&(A.tokenTypeOverrides={});var U={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var F in U)U.hasOwnProperty(F)&&A.tokenTypeOverrides[F]&&(U[F]=A.tokenTypeOverrides[F]);var R=/^([*\-_])(?:\s*\1){2,}\s*$/,_=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,v=/^\[(x| )\](?=\s)/i,S=A.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,D=/^ {0,3}(?:\={1,}|-{2,})\s*$/,C=/^[^#!\[\]*_\\<>` "'(~:]+/,T=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,E=/^\s*\[[^\]]+?\]:.*$/,l=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,o=" ";function s(B,I,Y){return I.f=I.inline=Y,Y(B,I)}function u(B,I,Y){return I.f=I.block=Y,Y(B,I)}function w(B){return!B||!/\S/.test(B.string)}function m(B){if(B.linkTitle=!1,B.linkHref=!1,B.linkText=!1,B.em=!1,B.strong=!1,B.strikethrough=!1,B.quote=0,B.indentedCode=!1,B.f==L){var I=k;if(!I){var Y=Q.innerMode(W,B.htmlState);I=Y.mode.name=="xml"&&Y.state.tagStart===null&&!Y.state.context&&Y.state.tokenize.isInText}I&&(B.f=d,B.block=h,B.htmlState=null)}return B.trailingSpace=0,B.trailingSpaceNewLine=!1,B.prevLine=B.thisLine,B.thisLine={stream:null},null}function h(B,I){var Y=B.column()===I.indentation,te=w(I.prevLine.stream),se=I.indentedCode,de=I.prevLine.hr,Se=I.list!==!1,ge=(I.listStack[I.listStack.length-1]||0)+3;I.indentedCode=!1;var pe=I.indentation;if(I.indentationDiff===null&&(I.indentationDiff=I.indentation,Se)){for(I.list=null;pe<I.listStack[I.listStack.length-1];)I.listStack.pop(),I.listStack.length?I.indentation=I.listStack[I.listStack.length-1]:I.list=!1;I.list!==!1&&(I.indentationDiff=pe-I.listStack[I.listStack.length-1])}var he=!te&&!de&&!I.prevLine.header&&(!Se||!se)&&!I.prevLine.fencedCodeEnd,me=(I.list===!1||de||te)&&I.indentation<=ge&&B.match(R),ae=null;if(I.indentationDiff>=4&&(se||I.prevLine.fencedCodeEnd||I.prevLine.header||te))return B.skipToEnd(),I.indentedCode=!0,U.code;if(B.eatSpace())return null;if(Y&&I.indentation<=ge&&(ae=B.match(S))&&ae[1].length<=6)return I.quote=0,I.header=ae[1].length,I.thisLine.header=!0,A.highlightFormatting&&(I.formatting="header"),I.f=I.inline,c(I);if(I.indentation<=ge&&B.eat(">"))return I.quote=Y?1:I.quote+1,A.highlightFormatting&&(I.formatting="quote"),B.eatSpace(),c(I);if(!me&&!I.setext&&Y&&I.indentation<=ge&&(ae=B.match(_))){var ue=ae[1]?"ol":"ul";return I.indentation=pe+B.current().length,I.list=!0,I.quote=0,I.listStack.push(I.indentation),I.em=!1,I.strong=!1,I.code=!1,I.strikethrough=!1,A.taskLists&&B.match(v,!1)&&(I.taskList=!0),I.f=I.inline,A.highlightFormatting&&(I.formatting=["list","list-"+ue]),c(I)}else{if(Y&&I.indentation<=ge&&(ae=B.match(T,!0)))return I.quote=0,I.fencedEndRE=new RegExp(ae[1]+"+ *$"),I.localMode=A.fencedCodeBlockHighlighting&&O(ae[2]||A.fencedCodeBlockDefaultMode),I.localMode&&(I.localState=Q.startState(I.localMode)),I.f=I.block=p,A.highlightFormatting&&(I.formatting="code-block"),I.code=-1,c(I);if(I.setext||(!he||!Se)&&!I.quote&&I.list===!1&&!I.code&&!me&&!E.test(B.string)&&(ae=B.lookAhead(1))&&(ae=ae.match(D)))return I.setext?(I.header=I.setext,I.setext=0,B.skipToEnd(),A.highlightFormatting&&(I.formatting="header")):(I.header=ae[0].charAt(0)=="="?1:2,I.setext=I.header),I.thisLine.header=!0,I.f=I.inline,c(I);if(me)return B.skipToEnd(),I.hr=!0,I.thisLine.hr=!0,U.hr;if(B.peek()==="[")return s(B,I,P)}return s(B,I,I.inline)}function L(B,I){var Y=W.token(B,I.htmlState);if(!k){var te=Q.innerMode(W,I.htmlState);(te.mode.name=="xml"&&te.state.tagStart===null&&!te.state.context&&te.state.tokenize.isInText||I.md_inside&&B.current().indexOf(">")>-1)&&(I.f=d,I.block=h,I.htmlState=null)}return Y}function p(B,I){var Y=I.listStack[I.listStack.length-1]||0,te=I.indentation<Y,se=Y+3;if(I.fencedEndRE&&I.indentation<=se&&(te||B.match(I.fencedEndRE))){A.highlightFormatting&&(I.formatting="code-block");var de;return te||(de=c(I)),I.localMode=I.localState=null,I.block=h,I.f=d,I.fencedEndRE=null,I.code=0,I.thisLine.fencedCodeEnd=!0,te?u(B,I,I.block):de}else return I.localMode?I.localMode.token(B,I.localState):(B.skipToEnd(),U.code)}function c(B){var I=[];if(B.formatting){I.push(U.formatting),typeof B.formatting=="string"&&(B.formatting=[B.formatting]);for(var Y=0;Y<B.formatting.length;Y++)I.push(U.formatting+"-"+B.formatting[Y]),B.formatting[Y]==="header"&&I.push(U.formatting+"-"+B.formatting[Y]+"-"+B.header),B.formatting[Y]==="quote"&&(!A.maxBlockquoteDepth||A.maxBlockquoteDepth>=B.quote?I.push(U.formatting+"-"+B.formatting[Y]+"-"+B.quote):I.push("error"))}if(B.taskOpen)return I.push("meta"),I.length?I.join(" "):null;if(B.taskClosed)return I.push("property"),I.length?I.join(" "):null;if(B.linkHref?I.push(U.linkHref,"url"):(B.strong&&I.push(U.strong),B.em&&I.push(U.em),B.strikethrough&&I.push(U.strikethrough),B.emoji&&I.push(U.emoji),B.linkText&&I.push(U.linkText),B.code&&I.push(U.code),B.image&&I.push(U.image),B.imageAltText&&I.push(U.imageAltText,"link"),B.imageMarker&&I.push(U.imageMarker)),B.header&&I.push(U.header,U.header+"-"+B.header),B.quote&&(I.push(U.quote),!A.maxBlockquoteDepth||A.maxBlockquoteDepth>=B.quote?I.push(U.quote+"-"+B.quote):I.push(U.quote+"-"+A.maxBlockquoteDepth)),B.list!==!1){var te=(B.listStack.length-1)%3;te?te===1?I.push(U.list2):I.push(U.list3):I.push(U.list1)}return B.trailingSpaceNewLine?I.push("trailing-space-new-line"):B.trailingSpace&&I.push("trailing-space-"+(B.trailingSpace%2?"a":"b")),I.length?I.join(" "):null}function f(B,I){return B.match(C,!0)?c(I):void 0}function d(B,I){var Y=I.text(B,I);if(typeof Y!="undefined")return Y;if(I.list)return I.list=null,c(I);if(I.taskList){var te=B.match(v,!0)[1]===" ";return te?I.taskOpen=!0:I.taskClosed=!0,A.highlightFormatting&&(I.formatting="task"),I.taskList=!1,c(I)}if(I.taskOpen=!1,I.taskClosed=!1,I.header&&B.match(/^#+$/,!0))return A.highlightFormatting&&(I.formatting="header"),c(I);var se=B.next();if(I.linkTitle){I.linkTitle=!1;var de=se;se==="("&&(de=")"),de=(de+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Se="^\\s*(?:[^"+de+"\\\\]+|\\\\\\\\|\\\\.)"+de;if(B.match(new RegExp(Se),!0))return U.linkHref}if(se==="`"){var ge=I.formatting;A.highlightFormatting&&(I.formatting="code"),B.eatWhile("`");var pe=B.current().length;if(I.code==0&&(!I.quote||pe==1))return I.code=pe,c(I);if(pe==I.code){var he=c(I);return I.code=0,he}else return I.formatting=ge,c(I)}else if(I.code)return c(I);if(se==="\\"&&(B.next(),A.highlightFormatting)){var me=c(I),ae=U.formatting+"-escape";return me?me+" "+ae:ae}if(se==="!"&&B.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return I.imageMarker=!0,I.image=!0,A.highlightFormatting&&(I.formatting="image"),c(I);if(se==="["&&I.imageMarker&&B.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return I.imageMarker=!1,I.imageAltText=!0,A.highlightFormatting&&(I.formatting="image"),c(I);if(se==="]"&&I.imageAltText){A.highlightFormatting&&(I.formatting="image");var me=c(I);return I.imageAltText=!1,I.image=!1,I.inline=I.f=b,me}if(se==="["&&!I.image)return I.linkText&&B.match(/^.*?\]/)||(I.linkText=!0,A.highlightFormatting&&(I.formatting="link")),c(I);if(se==="]"&&I.linkText){A.highlightFormatting&&(I.formatting="link");var me=c(I);return I.linkText=!1,I.inline=I.f=B.match(/\(.*?\)| ?\[.*?\]/,!1)?b:d,me}if(se==="<"&&B.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){I.f=I.inline=a,A.highlightFormatting&&(I.formatting="link");var me=c(I);return me?me+=" ":me="",me+U.linkInline}if(se==="<"&&B.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){I.f=I.inline=a,A.highlightFormatting&&(I.formatting="link");var me=c(I);return me?me+=" ":me="",me+U.linkEmail}if(A.xml&&se==="<"&&B.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var ue=B.string.indexOf(">",B.pos);if(ue!=-1){var xe=B.string.substring(B.start,ue);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(xe)&&(I.md_inside=!0)}return B.backUp(1),I.htmlState=Q.startState(W),u(B,I,L)}if(A.xml&&se==="<"&&B.match(/^\/\w*?>/))return I.md_inside=!1,"tag";if(se==="*"||se==="_"){for(var Fe=1,Re=B.pos==1?" ":B.string.charAt(B.pos-2);Fe<3&&B.eat(se);)Fe++;var Ie=B.peek()||" ",Ke=!/\s/.test(Ie)&&(!l.test(Ie)||/\s/.test(Re)||l.test(Re)),De=!/\s/.test(Re)&&(!l.test(Re)||/\s/.test(Ie)||l.test(Ie)),Ce=null,Me=null;if(Fe%2&&(!I.em&&Ke&&(se==="*"||!De||l.test(Re))?Ce=!0:I.em==se&&De&&(se==="*"||!Ke||l.test(Ie))&&(Ce=!1)),Fe>1&&(!I.strong&&Ke&&(se==="*"||!De||l.test(Re))?Me=!0:I.strong==se&&De&&(se==="*"||!Ke||l.test(Ie))&&(Me=!1)),Me!=null||Ce!=null){A.highlightFormatting&&(I.formatting=Ce==null?"strong":Me==null?"em":"strong em"),Ce===!0&&(I.em=se),Me===!0&&(I.strong=se);var he=c(I);return Ce===!1&&(I.em=!1),Me===!1&&(I.strong=!1),he}}else if(se===" "&&(B.eat("*")||B.eat("_"))){if(B.peek()===" ")return c(I);B.backUp(1)}if(A.strikethrough){if(se==="~"&&B.eatWhile(se)){if(I.strikethrough){A.highlightFormatting&&(I.formatting="strikethrough");var he=c(I);return I.strikethrough=!1,he}else if(B.match(/^[^\s]/,!1))return I.strikethrough=!0,A.highlightFormatting&&(I.formatting="strikethrough"),c(I)}else if(se===" "&&B.match(/^~~/,!0)){if(B.peek()===" ")return c(I);B.backUp(2)}}if(A.emoji&&se===":"&&B.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){I.emoji=!0,A.highlightFormatting&&(I.formatting="emoji");var Be=c(I);return I.emoji=!1,Be}return se===" "&&(B.match(/^ +$/,!1)?I.trailingSpace++:I.trailingSpace&&(I.trailingSpaceNewLine=!0)),c(I)}function a(B,I){var Y=B.next();if(Y===">"){I.f=I.inline=d,A.highlightFormatting&&(I.formatting="link");var te=c(I);return te?te+=" ":te="",te+U.linkInline}return B.match(/^[^>]+/,!0),U.linkInline}function b(B,I){if(B.eatSpace())return null;var Y=B.next();return Y==="("||Y==="["?(I.f=I.inline=x(Y==="("?")":"]"),A.highlightFormatting&&(I.formatting="link-string"),I.linkHref=!0,c(I)):"error"}var g={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function x(B){return function(I,Y){var te=I.next();if(te===B){Y.f=Y.inline=d,A.highlightFormatting&&(Y.formatting="link-string");var se=c(Y);return Y.linkHref=!1,se}return I.match(g[B]),Y.linkHref=!0,c(Y)}}function P(B,I){return B.match(/^([^\]\\]|\\.)*\]:/,!1)?(I.f=N,B.next(),A.highlightFormatting&&(I.formatting="link"),I.linkText=!0,c(I)):s(B,I,d)}function N(B,I){if(B.match(/^\]:/,!0)){I.f=I.inline=H,A.highlightFormatting&&(I.formatting="link");var Y=c(I);return I.linkText=!1,Y}return B.match(/^([^\]\\]|\\.)+/,!0),U.linkText}function H(B,I){return B.eatSpace()?null:(B.match(/^[^\s]+/,!0),B.peek()===void 0?I.linkTitle=!0:B.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),I.f=I.inline=d,U.linkHref+" url")}var X={startState:function(){return{f:h,prevLine:{stream:null},thisLine:{stream:null},block:h,htmlState:null,indentation:0,inline:d,text:f,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(B){return{f:B.f,prevLine:B.prevLine,thisLine:B.thisLine,block:B.block,htmlState:B.htmlState&&Q.copyState(W,B.htmlState),indentation:B.indentation,localMode:B.localMode,localState:B.localMode?Q.copyState(B.localMode,B.localState):null,inline:B.inline,text:B.text,formatting:!1,linkText:B.linkText,linkTitle:B.linkTitle,linkHref:B.linkHref,code:B.code,em:B.em,strong:B.strong,strikethrough:B.strikethrough,emoji:B.emoji,header:B.header,setext:B.setext,hr:B.hr,taskList:B.taskList,list:B.list,listStack:B.listStack.slice(0),quote:B.quote,indentedCode:B.indentedCode,trailingSpace:B.trailingSpace,trailingSpaceNewLine:B.trailingSpaceNewLine,md_inside:B.md_inside,fencedEndRE:B.fencedEndRE}},token:function(B,I){if(I.formatting=!1,B!=I.thisLine.stream){if(I.header=0,I.hr=!1,B.match(/^\s*$/,!0))return m(I),null;if(I.prevLine=I.thisLine,I.thisLine={stream:B},I.taskList=!1,I.trailingSpace=0,I.trailingSpaceNewLine=!1,!I.localState&&(I.f=I.block,I.f!=L)){var Y=B.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(I.indentation=Y,I.indentationDiff=null,Y>0)return null}}return I.f(B,I)},innerMode:function(B){return B.block==L?{state:B.htmlState,mode:W}:B.localState?{state:B.localState,mode:B.localMode}:{state:B,mode:X}},indent:function(B,I,Y){return B.block==L&&W.indent?W.indent(B.htmlState,I,Y):B.localState&&B.localMode.indent?B.localMode.indent(B.localState,I,Y):Q.Pass},blankLine:m,getType:c,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return X},"xml"),Q.defineMIME("text/markdown","markdown"),Q.defineMIME("text/x-markdown","markdown")})},nuEh:function(ut,Qe,q){"use strict";var Q=q("T2oS"),G=q("W9HT"),A=q("cDcd"),W=q.n(A),k=q("F8wB"),O=q.n(k),U=function(R){var _=R.loading;return _?W.a.createElement("div",{className:O.a.loading},W.a.createElement(G.a,null)):W.a.createElement(W.a.Fragment,null)};Qe.a=U},osHv:function(ut,Qe,q){(function(Q){Q(q("VrN/"))})(function(Q){"use strict";var G=Q.Pos;function A(l,o){return l.line-o.line||l.ch-o.ch}var W="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",k=W+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",O=new RegExp("<(/?)(["+W+"]["+k+"]*)","g");function U(l,o,s,u){this.line=o,this.ch=s,this.cm=l,this.text=l.getLine(o),this.min=u?Math.max(u.from,l.firstLine()):l.firstLine(),this.max=u?Math.min(u.to-1,l.lastLine()):l.lastLine()}function F(l,o){var s=l.cm.getTokenTypeAt(G(l.line,o));return s&&/\btag\b/.test(s)}function R(l){return l.line>=l.max?void 0:(l.ch=0,l.text=l.cm.getLine(++l.line),!0)}function _(l){return l.line<=l.min?void 0:(l.text=l.cm.getLine(--l.line),l.ch=l.text.length,!0)}function v(l){for(;;){var o=l.text.indexOf(">",l.ch);if(o==-1){if(R(l))continue;return}if(!F(l,o+1)){l.ch=o+1;continue}var s=l.text.lastIndexOf("/",o),u=s>-1&&!/\S/.test(l.text.slice(s+1,o));return l.ch=o+1,u?"selfClose":"regular"}}function S(l){for(;;){var o=l.ch?l.text.lastIndexOf("<",l.ch-1):-1;if(o==-1){if(_(l))continue;return}if(!F(l,o+1)){l.ch=o;continue}O.lastIndex=o,l.ch=o;var s=O.exec(l.text);if(s&&s.index==o)return s}}function D(l){for(;;){O.lastIndex=l.ch;var o=O.exec(l.text);if(!o){if(R(l))continue;return}if(!F(l,o.index+1)){l.ch=o.index+1;continue}return l.ch=o.index+o[0].length,o}}function C(l){for(;;){var o=l.ch?l.text.lastIndexOf(">",l.ch-1):-1;if(o==-1){if(_(l))continue;return}if(!F(l,o+1)){l.ch=o;continue}var s=l.text.lastIndexOf("/",o),u=s>-1&&!/\S/.test(l.text.slice(s+1,o));return l.ch=o+1,u?"selfClose":"regular"}}function T(l,o){for(var s=[];;){var u=D(l),w,m=l.line,h=l.ch-(u?u[0].length:0);if(!u||!(w=v(l)))return;if(w=="selfClose")continue;if(u[1]){for(var L=s.length-1;L>=0;--L)if(s[L]==u[2]){s.length=L;break}if(L<0&&(!o||o==u[2]))return{tag:u[2],from:G(m,h),to:G(l.line,l.ch)}}else s.push(u[2])}}function E(l,o){for(var s=[];;){var u=C(l);if(!u)return;if(u=="selfClose"){S(l);continue}var w=l.line,m=l.ch,h=S(l);if(!h)return;if(h[1])s.push(h[2]);else{for(var L=s.length-1;L>=0;--L)if(s[L]==h[2]){s.length=L;break}if(L<0&&(!o||o==h[2]))return{tag:h[2],from:G(l.line,l.ch),to:G(w,m)}}}}Q.registerHelper("fold","xml",function(l,o){for(var s=new U(l,o.line,0);;){var u=D(s);if(!u||s.line!=o.line)return;var w=v(s);if(!w)return;if(!u[1]&&w!="selfClose"){var m=G(s.line,s.ch),h=T(s,u[2]);return h&&A(h.from,m)>0?{from:m,to:h.from}:null}}}),Q.findMatchingTag=function(l,o,s){var u=new U(l,o.line,o.ch,s);if(u.text.indexOf(">")==-1&&u.text.indexOf("<")==-1)return;var w=v(u),m=w&&G(u.line,u.ch),h=w&&S(u);if(!w||!h||A(u,o)>0)return;var L={from:G(u.line,u.ch),to:m,tag:h[2]};return w=="selfClose"?{open:L,close:null,at:"open"}:h[1]?{open:E(u,h[2]),close:L,at:"close"}:(u=new U(l,m.line,m.ch,s),{open:L,close:T(u,h[2]),at:"open"})},Q.findEnclosingTag=function(l,o,s,u){for(var w=new U(l,o.line,o.ch,s);;){var m=E(w,u);if(!m)break;var h=new U(l,o.line,o.ch,s),L=T(h,m.tag);if(L)return{open:m,close:L}}},Q.scanForClosingTag=function(l,o,s,u){var w=new U(l,o.line,o.ch,u?{from:0,to:u}:null);return T(w,s)}})},"p77/":function(ut,Qe,q){},rUJ1:function(ut,Qe){const q=/[&<>"']/,Q=/[&<>"']/g,G=/[<>"']|&(?!#?\w+;)/,A=/[<>"']|&(?!#?\w+;)/g,W={"&":"&","<":"<",">":">",'"':""","'":"'"},k=p=>W[p];function O(p,c){if(c){if(q.test(p))return p.replace(Q,k)}else if(G.test(p))return p.replace(A,k);return p}const U=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function F(p){return p.replace(U,(c,f)=>(f=f.toLowerCase(),f==="colon"?":":f.charAt(0)==="#"?f.charAt(1)==="x"?String.fromCharCode(parseInt(f.substring(2),16)):String.fromCharCode(+f.substring(1)):""))}const R=/(^|[^\[])\^/g;function _(p,c){p=p.source||p,c=c||"";const f={replace:(d,a)=>(a=a.source||a,a=a.replace(R,"$1"),p=p.replace(d,a),f),getRegex:()=>new RegExp(p,c)};return f}const v=/[^\w:]/g,S=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function D(p,c,f){if(p){let d;try{d=decodeURIComponent(F(f)).replace(v,"").toLowerCase()}catch(a){return null}if(d.indexOf("javascript:")===0||d.indexOf("vbscript:")===0||d.indexOf("data:")===0)return null}c&&!S.test(f)&&(f=o(c,f));try{f=encodeURI(f).replace(/%25/g,"%")}catch(d){return null}return f}const C={},T=/^[^:]+:\/*[^/]*$/,E=/^([^:]+:)[\s\S]*$/,l=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(p,c){C[" "+p]||(T.test(p)?C[" "+p]=p+"/":C[" "+p]=m(p,"/",!0)),p=C[" "+p];const f=p.indexOf(":")===-1;return c.substring(0,2)==="//"?f?c:p.replace(E,"$1")+c:c.charAt(0)==="/"?f?c:p.replace(l,"$1")+c:p+c}const s={exec:function(){}};function u(p){let c=1,f,d;for(;c<arguments.length;c++){f=arguments[c];for(d in f)Object.prototype.hasOwnProperty.call(f,d)&&(p[d]=f[d])}return p}function w(p,c){const f=p.replace(/\|/g,(b,g,x)=>{let P=!1,N=g;for(;--N>=0&&x[N]==="\\";)P=!P;return P?"|":" |"}),d=f.split(/ \|/);let a=0;if(d.length>c)d.splice(c);else for(;d.length<c;)d.push("");for(;a<d.length;a++)d[a]=d[a].trim().replace(/\\\|/g,"|");return d}function m(p,c,f){const d=p.length;if(d===0)return"";let a=0;for(;a<d;){const b=p.charAt(d-a-1);if(b===c&&!f)a++;else if(b!==c&&f)a++;else break}return p.substr(0,d-a)}function h(p,c){if(p.indexOf(c[1])===-1)return-1;const f=p.length;let d=0,a=0;for(;a<f;a++)if(p[a]==="\\")a++;else if(p[a]===c[0])d++;else if(p[a]===c[1]&&(d--,d<0))return a;return-1}function L(p){p&&p.sanitize&&!p.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")}ut.exports={escape:O,unescape:F,edit:_,cleanUrl:D,resolveUrl:o,noopTest:s,merge:u,splitCells:w,rtrim:m,findClosingBracket:h,checkSanitizeDeprecation:L}},ulZh:function(ut,Qe,q){typeof window!="undefined"&&function(G,A){ut.exports=A()}(this,function(){return function(Q){var G={};function A(W){if(G[W])return G[W].exports;var k=G[W]={i:W,l:!1,exports:{}};return Q[W].call(k.exports,k,k.exports,A),k.l=!0,k.exports}return A.m=Q,A.c=G,A.d=function(W,k,O){A.o(W,k)||Object.defineProperty(W,k,{enumerable:!0,get:O})},A.r=function(W){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(W,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(W,"__esModule",{value:!0})},A.t=function(W,k){if(k&1&&(W=A(W)),k&8)return W;if(k&4&&typeof W=="object"&&W&&W.__esModule)return W;var O=Object.create(null);if(A.r(O),Object.defineProperty(O,"default",{enumerable:!0,value:W}),k&2&&typeof W!="string")for(var U in W)A.d(O,U,function(F){return W[F]}.bind(null,U));return O},A.n=function(W){var k=W&&W.__esModule?function(){return W.default}:function(){return W};return A.d(k,"a",k),k},A.o=function(W,k){return Object.prototype.hasOwnProperty.call(W,k)},A.p="/dist/",A(A.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(Q,G,A){"use strict";var W=Object.prototype.hasOwnProperty,k="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(k=!1));function U(v,S,D){this.fn=v,this.context=S,this.once=D||!1}function F(v,S,D,C,T){if(typeof D!="function")throw new TypeError("The listener must be a function");var E=new U(D,C||v,T),l=k?k+S:S;return v._events[l]?v._events[l].fn?v._events[l]=[v._events[l],E]:v._events[l].push(E):(v._events[l]=E,v._eventsCount++),v}function R(v,S){--v._eventsCount===0?v._events=new O:delete v._events[S]}function _(){this._events=new O,this._eventsCount=0}_.prototype.eventNames=function(){var S=[],D,C;if(this._eventsCount===0)return S;for(C in D=this._events)W.call(D,C)&&S.push(k?C.slice(1):C);return Object.getOwnPropertySymbols?S.concat(Object.getOwnPropertySymbols(D)):S},_.prototype.listeners=function(S){var D=k?k+S:S,C=this._events[D];if(!C)return[];if(C.fn)return[C.fn];for(var T=0,E=C.length,l=new Array(E);T<E;T++)l[T]=C[T].fn;return l},_.prototype.listenerCount=function(S){var D=k?k+S:S,C=this._events[D];return C?C.fn?1:C.length:0},_.prototype.emit=function(S,D,C,T,E,l){var o=k?k+S:S;if(!this._events[o])return!1;var s=this._events[o],u=arguments.length,w,m;if(s.fn){s.once&&this.removeListener(S,s.fn,void 0,!0);switch(u){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,D),!0;case 3:return s.fn.call(s.context,D,C),!0;case 4:return s.fn.call(s.context,D,C,T),!0;case 5:return s.fn.call(s.context,D,C,T,E),!0;case 6:return s.fn.call(s.context,D,C,T,E,l),!0}for(m=1,w=new Array(u-1);m<u;m++)w[m-1]=arguments[m];s.fn.apply(s.context,w)}else{var h=s.length,L;for(m=0;m<h;m++){s[m].once&&this.removeListener(S,s[m].fn,void 0,!0);switch(u){case 1:s[m].fn.call(s[m].context);break;case 2:s[m].fn.call(s[m].context,D);break;case 3:s[m].fn.call(s[m].context,D,C);break;case 4:s[m].fn.call(s[m].context,D,C,T);break;default:if(!w)for(L=1,w=new Array(u-1);L<u;L++)w[L-1]=arguments[L];s[m].fn.apply(s[m].context,w)}}}return!0},_.prototype.on=function(S,D,C){return F(this,S,D,C,!1)},_.prototype.once=function(S,D,C){return F(this,S,D,C,!0)},_.prototype.removeListener=function(S,D,C,T){var E=k?k+S:S;if(!this._events[E])return this;if(!D)return R(this,E),this;var l=this._events[E];if(l.fn)l.fn===D&&(!T||l.once)&&(!C||l.context===C)&&R(this,E);else{for(var o=0,s=[],u=l.length;o<u;o++)(l[o].fn!==D||T&&!l[o].once||C&&l[o].context!==C)&&s.push(l[o]);s.length?this._events[E]=s.length===1?s[0]:s:R(this,E)}return this},_.prototype.removeAllListeners=function(S){var D;return S?(D=k?k+S:S,this._events[D]&&R(this,D)):(this._events=new O,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=k,_.EventEmitter=_,Q.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(Q,G,A){(function(W){var k=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,O=/^([^\/?#]*)([^]*)$/,U=/(?:\/|^)\.(?=\/)/g,F=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,R={buildAbsoluteURL:function(_,v,S){if(S=S||{},_=_.trim(),v=v.trim(),!v){if(!S.alwaysNormalize)return _;var D=R.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");return D.path=R.normalizePath(D.path),R.buildURLFromParts(D)}var C=R.parseURL(v);if(!C)throw new Error("Error trying to parse relative URL.");if(C.scheme)return S.alwaysNormalize?(C.path=R.normalizePath(C.path),R.buildURLFromParts(C)):v;var T=R.parseURL(_);if(!T)throw new Error("Error trying to parse base URL.");if(!T.netLoc&&T.path&&T.path[0]!=="/"){var E=O.exec(T.path);T.netLoc=E[1],T.path=E[2]}T.netLoc&&!T.path&&(T.path="/");var l={scheme:T.scheme,netLoc:C.netLoc,path:null,params:C.params,query:C.query,fragment:C.fragment};if(!C.netLoc&&(l.netLoc=T.netLoc,C.path[0]!=="/"))if(!C.path)l.path=T.path,C.params||(l.params=T.params,C.query||(l.query=T.query));else{var o=T.path,s=o.substring(0,o.lastIndexOf("/")+1)+C.path;l.path=R.normalizePath(s)}return l.path===null&&(l.path=S.alwaysNormalize?R.normalizePath(C.path):C.path),R.buildURLFromParts(l)},parseURL:function(_){var v=k.exec(_);return v?{scheme:v[1]||"",netLoc:v[2]||"",path:v[3]||"",params:v[4]||"",query:v[5]||"",fragment:v[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(U,"");_.length!==(_=_.replace(F,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};Q.exports=R})(this)},"./node_modules/webworkify-webpack/index.js":function(Q,G,A){function W(S){var D={};function C(E){if(D[E])return D[E].exports;var l=D[E]={i:E,l:!1,exports:{}};return S[E].call(l.exports,l,l.exports,C),l.l=!0,l.exports}C.m=S,C.c=D,C.i=function(E){return E},C.d=function(E,l,o){C.o(E,l)||Object.defineProperty(E,l,{configurable:!1,enumerable:!0,get:o})},C.r=function(E){Object.defineProperty(E,"__esModule",{value:!0})},C.n=function(E){var l=E&&E.__esModule?function(){return E.default}:function(){return E};return C.d(l,"a",l),l},C.o=function(E,l){return Object.prototype.hasOwnProperty.call(E,l)},C.p="/",C.oe=function(E){throw console.error(E),E};var T=C(C.s=ENTRY_MODULE);return T.default||T}var k="[\\.|\\-|\\+|\\w|/|@]+",O="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+k+").*?\\)";function U(S){return(S+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function F(S){return!isNaN(1*S)}function R(S,D,C){var T={};T[C]=[];var E=D.toString(),l=E.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!l)return T;for(var o=l[1],s=new RegExp("(\\\\n|\\W)"+U(o)+O,"g"),u;u=s.exec(E);){if(u[3]==="dll-reference")continue;T[C].push(u[3])}for(s=new RegExp("\\("+U(o)+'\\("(dll-reference\\s('+k+'))"\\)\\)'+O,"g");u=s.exec(E);)S[u[2]]||(T[C].push(u[1]),S[u[2]]=A(u[1]).m),T[u[2]]=T[u[2]]||[],T[u[2]].push(u[4]);for(var w=Object.keys(T),m=0;m<w.length;m++)for(var h=0;h<T[w[m]].length;h++)F(T[w[m]][h])&&(T[w[m]][h]=1*T[w[m]][h]);return T}function _(S){var D=Object.keys(S);return D.reduce(function(C,T){return C||S[T].length>0},!1)}function v(S,D){for(var C={main:[D]},T={main:[]},E={main:{}};_(C);)for(var l=Object.keys(C),o=0;o<l.length;o++){var s=l[o],u=C[s],w=u.pop();if(E[s]=E[s]||{},E[s][w]||!S[s][w])continue;E[s][w]=!0,T[s]=T[s]||[],T[s].push(w);for(var m=R(S,S[s][w],s),h=Object.keys(m),L=0;L<h.length;L++)C[h[L]]=C[h[L]]||[],C[h[L]]=C[h[L]].concat(m[h[L]])}return T}Q.exports=function(S,D){D=D||{};var C={main:A.m},T=D.all?{main:Object.keys(C.main)}:v(C,S),E="";Object.keys(T).filter(function(w){return w!=="main"}).forEach(function(w){for(var m=0;T[w][m];)m++;T[w].push(m),C[w][m]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",E=E+"var "+w+" = ("+W.toString().replace("ENTRY_MODULE",JSON.stringify(m))+")({"+T[w].map(function(h){return""+JSON.stringify(h)+": "+C[w][h].toString()}).join(",")+`});
|
|
`}),E=E+"new (("+W.toString().replace("ENTRY_MODULE",JSON.stringify(S))+")({"+T.main.map(function(w){return""+JSON.stringify(w)+": "+C.main[w].toString()}).join(",")+"}))(self);";var l=new window.Blob([E],{type:"text/javascript"});if(D.bare)return l;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,s=o.createObjectURL(l),u=new window.Worker(s);return u.objectURL=s,u}},"./src/config.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"hlsDefaultConfig",function(){return L}),A.d(G,"mergeConfig",function(){return c}),A.d(G,"enableStreamingMode",function(){return f});var W=A("./src/controller/abr-controller.ts"),k=A("./src/controller/audio-stream-controller.ts"),O=A("./src/controller/audio-track-controller.ts"),U=A("./src/controller/subtitle-stream-controller.ts"),F=A("./src/controller/subtitle-track-controller.ts"),R=A("./src/controller/buffer-controller.ts"),_=A("./src/controller/timeline-controller.ts"),v=A("./src/controller/cap-level-controller.ts"),S=A("./src/controller/fps-controller.ts"),D=A("./src/controller/eme-controller.ts"),C=A("./src/controller/cmcd-controller.ts"),T=A("./src/utils/xhr-loader.ts"),E=A("./src/utils/fetch-loader.ts"),l=A("./src/utils/cues.ts"),o=A("./src/utils/mediakeys-helper.ts"),s=A("./src/utils/logger.ts");function u(){return u=Object.assign||function(d){for(var a=1;a<arguments.length;a++){var b=arguments[a];for(var g in b)Object.prototype.hasOwnProperty.call(b,g)&&(d[g]=b[g])}return d},u.apply(this,arguments)}function w(d,a){var b=Object.keys(d);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(d);a&&(g=g.filter(function(x){return Object.getOwnPropertyDescriptor(d,x).enumerable})),b.push.apply(b,g)}return b}function m(d){for(var a=1;a<arguments.length;a++){var b=arguments[a]!=null?arguments[a]:{};a%2?w(Object(b),!0).forEach(function(g){h(d,g,b[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(b)):w(Object(b)).forEach(function(g){Object.defineProperty(d,g,Object.getOwnPropertyDescriptor(b,g))})}return d}function h(d,a,b){return a in d?Object.defineProperty(d,a,{value:b,enumerable:!0,configurable:!0,writable:!0}):d[a]=b,d}var L=m(m({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!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:T.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:W.default,bufferController:R.default,capLevelController:v.default,fpsController:S.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,drmSystemOptions:{},requestMediaKeySystemAccessFunc:o.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},p()),{},{subtitleStreamController:U.SubtitleStreamController,subtitleTrackController:F.default,timelineController:_.TimelineController,audioStreamController:k.default,audioTrackController:O.default,emeController:D.default,cmcdController:C.default});function p(){return{cueHandler:l.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function c(d,a){if((a.liveSyncDurationCount||a.liveMaxLatencyDurationCount)&&(a.liveSyncDuration||a.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(a.liveMaxLatencyDurationCount!==void 0&&(a.liveSyncDurationCount===void 0||a.liveMaxLatencyDurationCount<=a.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(a.liveMaxLatencyDuration!==void 0&&(a.liveSyncDuration===void 0||a.liveMaxLatencyDuration<=a.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return u({},d,a)}function f(d){var a=d.loader;if(a!==E.default&&a!==T.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var b=Object(E.fetchSupported)();b&&(d.loader=E.default,d.progressive=!0,d.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/polyfills/number.ts"),k=A("./src/utils/ewma-bandwidth-estimator.ts"),O=A("./src/events.ts"),U=A("./src/utils/buffer-helper.ts"),F=A("./src/errors.ts"),R=A("./src/types/loader.ts"),_=A("./src/utils/logger.ts");function v(C,T){for(var E=0;E<T.length;E++){var l=T[E];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(C,l.key,l)}}function S(C,T,E){return T&&v(C.prototype,T),E&&v(C,E),C}var D=function(){function C(E){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=E;var l=E.config;this.bwEstimator=new k.default(l.abrEwmaSlowVoD,l.abrEwmaFastVoD,l.abrEwmaDefaultEstimate),this.registerListeners()}var T=C.prototype;return T.registerListeners=function(){var l=this.hls;l.on(O.Events.FRAG_LOADING,this.onFragLoading,this),l.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),l.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.on(O.Events.ERROR,this.onError,this)},T.unregisterListeners=function(){var l=this.hls;l.off(O.Events.FRAG_LOADING,this.onFragLoading,this),l.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),l.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),l.off(O.Events.ERROR,this.onError,this)},T.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},T.onFragLoading=function(l,o){var s=o.frag;if(s.type===R.PlaylistLevelType.MAIN&&!this.timer){var u;this.fragCurrent=s,this.partCurrent=(u=o.part)!=null?u:null,this.timer=self.setInterval(this.onCheck,100)}},T.onLevelLoaded=function(l,o){var s=this.hls.config;o.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},T._abandonRulesCheck=function(){var l=this.fragCurrent,o=this.partCurrent,s=this.hls,u=s.autoLevelEnabled,w=s.config,m=s.media;if(!l||!m)return;var h=o?o.stats:l.stats,L=o?o.duration:l.duration;if(h.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!u||m.paused||!m.playbackRate||!m.readyState)return;var p=performance.now()-h.loading.start,c=Math.abs(m.playbackRate);if(p<=500*L/c)return;var f=s.levels,d=s.minAutoLevel,a=f[l.level],b=h.total||Math.max(h.loaded,Math.round(L*a.maxBitrate/8)),g=Math.max(1,h.bwEstimate?h.bwEstimate/8:h.loaded*1e3/p),x=(b-h.loaded)/g,P=m.currentTime,N=(U.BufferHelper.bufferInfo(m,P,w.maxBufferHole).end-P)/c;if(N>=2*L/c||x<=N)return;var H=Number.POSITIVE_INFINITY,X;for(X=l.level-1;X>d;X--){var B=f[X].maxBitrate;if(H=L*B/(8*.8*g),H<N)break}if(H>=x)return;var I=this.bwEstimator.getEstimate();_.logger.warn("Fragment "+l.sn+(o?" part "+o.index:"")+" of level "+l.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+X+`
|
|
Current BW estimate: `+(Object(W.isFiniteNumber)(I)?(I/1024).toFixed(3):"Unknown")+` Kb/s
|
|
Estimated load time for current fragment: `+x.toFixed(3)+` s
|
|
Estimated load time for the next fragment: `+H.toFixed(3)+` s
|
|
Time to underbuffer: `+N.toFixed(3)+" s"),s.nextLoadLevel=X,this.bwEstimator.sample(p,h.loaded),this.clearTimer(),l.loader&&(this.fragCurrent=this.partCurrent=null,l.loader.abort()),s.trigger(O.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:l,part:o,stats:h})},T.onFragLoaded=function(l,o){var s=o.frag,u=o.part;if(s.type===R.PlaylistLevelType.MAIN&&Object(W.isFiniteNumber)(s.sn)){var w=u?u.stats:s.stats,m=u?u.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var h=this.hls.levels[s.level],L=(h.loaded?h.loaded.bytes:0)+w.loaded,p=(h.loaded?h.loaded.duration:0)+m;h.loaded={bytes:L,duration:p},h.realBitrate=Math.round(8*L/p)}if(s.bitrateTest){var c={stats:w,frag:s,part:u,id:s.type};this.onFragBuffered(O.Events.FRAG_BUFFERED,c),s.bitrateTest=!1}}},T.onFragBuffered=function(l,o){var s=o.frag,u=o.part,w=u?u.stats:s.stats;if(w.aborted)return;if(s.type!==R.PlaylistLevelType.MAIN||s.sn==="initSegment")return;var m=w.parsing.end-w.loading.start;this.bwEstimator.sample(m,w.loaded),w.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=m/1e3:this.bitrateTestDelay=0},T.onError=function(l,o){switch(o.details){case F.ErrorDetails.FRAG_LOAD_ERROR:case F.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},T.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},T.getNextABRAutoLevel=function(){var l=this.fragCurrent,o=this.partCurrent,s=this.hls,u=s.maxAutoLevel,w=s.config,m=s.minAutoLevel,h=s.media,L=o?o.duration:l?l.duration:0,p=h?h.currentTime:0,c=h&&h.playbackRate!==0?Math.abs(h.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():w.abrEwmaDefaultEstimate,d=(U.BufferHelper.bufferInfo(h,p,w.maxBufferHole).end-p)/c,a=this.findBestLevel(f,m,u,d,w.abrBandWidthFactor,w.abrBandWidthUpFactor);if(a>=0)return a;_.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var b=L?Math.min(L,w.maxStarvationDelay):w.maxStarvationDelay,g=w.abrBandWidthFactor,x=w.abrBandWidthUpFactor;if(!d){var P=this.bitrateTestDelay;if(P){var N=L?Math.min(L,w.maxLoadingDelay):w.maxLoadingDelay;b=N-P,_.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*b)+" ms"),g=x=1}}return a=this.findBestLevel(f,m,u,d+b,g,x),Math.max(a,0)},T.findBestLevel=function(l,o,s,u,w,m){for(var h,L=this.fragCurrent,p=this.partCurrent,c=this.lastLoadedFragLevel,f=this.hls.levels,d=f[c],a=!!(d!=null&&(h=d.details)!==null&&h!==void 0&&h.live),b=d==null?void 0:d.codecSet,g=p?p.duration:L?L.duration:0,x=s;x>=o;x--){var P=f[x];if(!P||b&&P.codecSet!==b)continue;var N=P.details,H=(p?N==null?void 0:N.partTarget:N==null?void 0:N.averagetargetduration)||g,X=void 0;x<=c?X=w*l:X=m*l;var B=f[x].maxBitrate,I=B*H/X;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+x+"/"+Math.round(X)+"/"+B+"/"+H+"/"+u+"/"+I),X>B&&(!I||a&&!this.bitrateTestDelay||I<u))return x}return-1},S(C,[{key:"nextAutoLevel",get:function(){var l=this._nextAutoLevel,o=this.bwEstimator;if(l!==-1&&(!o||!o.canEstimate()))return l;var s=this.getNextABRAutoLevel();return l!==-1&&(s=Math.min(l,s)),s},set:function(l){this._nextAutoLevel=l}}]),C}();G.default=D},"./src/controller/audio-stream-controller.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/polyfills/number.ts"),k=A("./src/controller/base-stream-controller.ts"),O=A("./src/events.ts"),U=A("./src/utils/buffer-helper.ts"),F=A("./src/controller/fragment-tracker.ts"),R=A("./src/types/level.ts"),_=A("./src/types/loader.ts"),v=A("./src/loader/fragment.ts"),S=A("./src/demux/chunk-cache.ts"),D=A("./src/demux/transmuxer-interface.ts"),C=A("./src/types/transmuxer.ts"),T=A("./src/controller/fragment-finders.ts"),E=A("./src/utils/discontinuities.ts"),l=A("./src/errors.ts"),o=A("./src/utils/logger.ts");function s(){return s=Object.assign||function(L){for(var p=1;p<arguments.length;p++){var c=arguments[p];for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(L[f]=c[f])}return L},s.apply(this,arguments)}function u(L,p){L.prototype=Object.create(p.prototype),L.prototype.constructor=L,w(L,p)}function w(L,p){return w=Object.setPrototypeOf||function(f,d){return f.__proto__=d,f},w(L,p)}var m=100,h=function(L){u(p,L);function p(f,d){var a;return a=L.call(this,f,d,"[audio-stream-controller]")||this,a.videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.audioSwitch=!1,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a._registerListeners(),a}var c=p.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var d=this.hls;d.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(O.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.on(O.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(O.Events.ERROR,this.onError,this),d.on(O.Events.BUFFER_RESET,this.onBufferReset,this),d.on(O.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(O.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var d=this.hls;d.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(O.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.off(O.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(O.Events.ERROR,this.onError,this),d.off(O.Events.BUFFER_RESET,this.onBufferReset,this),d.off(O.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(O.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(d,a){var b=a.frag,g=a.id,x=a.initPTS;if(g==="main"){var P=b.cc;this.initPTS[b.cc]=x,this.log("InitPTS for cc: "+P+" found from main: "+x),this.videoTrackCC=P,this.state===k.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(d){if(!this.levels){this.startPosition=d,this.state=k.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(m),this.fragLoadError=0,a>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=k.State.IDLE):(this.loadedmetadata=!1,this.state=k.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()},c.doTick=function(){switch(this.state){case k.State.IDLE:this.doTickIdle();break;case k.State.WAITING_TRACK:{var d,a=this.levels,b=this.trackId,g=a==null||((d=a[b])===null||d===void 0)?void 0:d.details;if(g){if(this.waitForCdnTuneIn(g))break;this.state=k.State.WAITING_INIT_PTS}break}case k.State.FRAG_LOADING_WAITING_RETRY:{var x,P=performance.now(),N=this.retryDate;(!N||P>=N||(x=this.media)!==null&&x!==void 0&&x.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=k.State.IDLE);break}case k.State.WAITING_INIT_PTS:{var H=this.waitingData;if(H){var X=H.frag,B=H.part,I=H.cache,Y=H.complete;if(this.initPTS[X.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=k.State.FRAG_LOADING;var te=I.flush(),se={frag:X,part:B,payload:te,networkDetails:null};this._handleFragmentLoadProgress(se),Y&&L.prototype._handleFragmentLoadComplete.call(this,se)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+X.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var de=this.getLoadPosition(),Se=U.BufferHelper.bufferInfo(this.mediaBuffer,de,this.config.maxBufferHole),ge=Object(T.fragmentWithinToleranceTest)(Se.end,this.config.maxFragLookUpTolerance,X);ge<0&&(o.logger.log("Waiting fragment cc ("+X.cc+") @ "+X.start+" cancelled because another fragment at "+Se.end+" is needed"),this.clearWaitingFragment())}}else this.state=k.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var d=this.waitingData;d&&(this.fragmentTracker.removeFragment(d.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=k.State.IDLE)},c.onTickEnd=function(){var d=this.media;if(!d||!d.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:d,b=a.buffered;!this.loadedmetadata&&b.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime},c.doTickIdle=function(){var d,a,b=this.hls,g=this.levels,x=this.media,P=this.trackId,N=b.config;if(!g||!g[P])return;if(!x&&(this.startFragRequested||!N.startFragPrefetch))return;var H=g[P],X=H.details;if(!X||X.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(X)){this.state=k.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,v.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var B=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.AUDIO);if(B===null)return;var I=B.len,Y=this.getMaxBufferLength(),te=this.audioSwitch;if(I>=Y&&!te)return;if(!te&&this._streamEnded(B,X)){b.trigger(O.Events.BUFFER_EOS,{type:"audio"}),this.state=k.State.ENDED;return}var se=X.fragments,de=se[0].start,Se=B.end;if(te){var ge=this.getLoadPosition();Se=ge,X.PTSKnown&&ge<de&&((B.end>de||B.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),x.currentTime=de+.05))}var pe=this.getNextFragment(Se,X);if(!pe){this.bufferFlushed=!0;return}((d=pe.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((a=pe.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(pe,X):this.loadFragment(pe,X,Se)},c.getMaxBufferLength=function(){var d=L.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN);return a===null?d:Math.max(d,a.len)},c.onMediaDetaching=function(){this.videoBuffer=null,L.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(d,a){var b=a.audioTracks;this.resetTransmuxer(),this.levels=b.map(function(g){return new R.Level(g)})},c.onAudioTrackSwitching=function(d,a){var b=!!a.url;this.trackId=a.id;var g=this.fragCurrent;g!=null&&g.loader&&g.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),b?this.setInterval(m):this.resetTransmuxer(),b?(this.audioSwitch=!0,this.state=k.State.IDLE):this.state=k.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(d,a){this.mainDetails=a.details},c.onAudioTrackLoaded=function(d,a){var b,g=this.levels,x=a.details,P=a.id;if(!g){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+x.startSN+","+x.endSN+"],duration:"+x.totalduration);var N=g[P],H=0;if(x.live||(b=N.details)!==null&&b!==void 0&&b.live){var X=this.mainDetails;if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed||!X)return;!N.details&&x.hasProgramDateTime&&X.hasProgramDateTime?(Object(E.alignMediaPlaylistByPDT)(x,X),H=x.fragments[0].start):H=this.alignPlaylists(x,N.details)}N.details=x,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!x.live)&&this.setStartPosition(N.details,H),this.state===k.State.WAITING_TRACK&&!this.waitForCdnTuneIn(x)&&(this.state=k.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(d){var a,b=d.frag,g=d.part,x=d.payload,P=this.config,N=this.trackId,H=this.levels;if(!H){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+b.sn+" of level "+b.level+" will not be buffered");return}var X=H[N];console.assert(X,"Audio track is defined on fragment load progress");var B=X.details;console.assert(B,"Audio track details are defined on fragment load progress");var I=P.defaultAudioCodec||X.audioCodec||"mp4a.40.2",Y=this.transmuxer;Y||(Y=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var te=this.initPTS[b.cc],se=(a=b.initSegment)===null||a===void 0?void 0:a.data;if(te!==void 0){var de=!1,Se=g?g.index:-1,ge=Se!==-1,pe=new C.ChunkMetadata(b.level,b.sn,b.stats.chunkCount,x.byteLength,Se,ge);Y.push(x,se,I,"",b,g,B.totalduration,de,pe,te)}else{o.logger.log("Unknown video PTS for cc "+b.cc+", waiting for video PTS before demuxing audio frag "+b.sn+" of ["+B.startSN+" ,"+B.endSN+"],track "+N);var he=this.waitingData=this.waitingData||{frag:b,part:g,cache:new S.default,complete:!1},me=he.cache;me.push(new Uint8Array(x)),this.waitingVideoCC=this.videoTrackCC,this.state=k.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(d){if(this.waitingData){this.waitingData.complete=!0;return}L.prototype._handleFragmentLoadComplete.call(this,d)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(d,a){var b=a.tracks.audio;b&&(this.mediaBuffer=b.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},c.onFragBuffered=function(d,a){var b=a.frag,g=a.part;if(b.type!==_.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(b)){this.warn("Fragment "+b.sn+(g?" p: "+g.index:"")+" of level "+b.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}b.sn!=="initSegment"&&(this.fragPrevious=b,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(O.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(b,g)},c.onError=function(d,a){switch(a.details){case l.ErrorDetails.FRAG_LOAD_ERROR:case l.ErrorDetails.FRAG_LOAD_TIMEOUT:case l.ErrorDetails.KEY_LOAD_ERROR:case l.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,a);break;case l.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case l.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==k.State.ERROR&&this.state!==k.State.STOPPED&&(this.state=a.fatal?k.State.ERROR:k.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case l.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===k.State.PARSING||this.state===k.State.PARSED)){var b=!0,g=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);g&&g.len>.5&&(b=!this.reduceMaxBufferLength(g.len)),b&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,L.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(d,a){var b=a.type;b===v.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(d){var a,b="audio",g=this.hls,x=d.remuxResult,P=d.chunkMeta,N=this.getCurrentContext(P);if(!N){this.warn("The loading context changed while buffering fragment "+P.sn+" of level "+P.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(P.level);return}var H=N.frag,X=N.part,B=x.audio,I=x.text,Y=x.id3,te=x.initSegment;if(this.fragContextChanged(H))return;if(this.state=k.State.PARSING,this.audioSwitch&&B&&this.completeAudioSwitch(),te!=null&&te.tracks&&(this._bufferInitSegment(te.tracks,H,P),g.trigger(O.Events.FRAG_PARSING_INIT_SEGMENT,{frag:H,id:b,tracks:te.tracks})),B){var se=B.startPTS,de=B.endPTS,Se=B.startDTS,ge=B.endDTS;X&&(X.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:de,startDTS:Se,endDTS:ge}),H.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,se,de,Se,ge),this.bufferFragmentData(B,H,X,P)}if(Y!=null&&(a=Y.samples)!==null&&a!==void 0&&a.length){var pe=s({frag:H,id:b},Y);g.trigger(O.Events.FRAG_PARSING_METADATA,pe)}if(I){var he=s({frag:H,id:b},I);g.trigger(O.Events.FRAG_PARSING_USERDATA,he)}},c._bufferInitSegment=function(d,a,b){if(this.state!==k.State.PARSING)return;d.video&&delete d.video;var g=d.audio;if(!g)return;g.levelCodec=g.codec,g.id="audio",this.log("Init audio buffer, container:"+g.container+", codecs[parsed]=["+g.codec+"]"),this.hls.trigger(O.Events.BUFFER_CODECS,d);var x=g.initSegment;if(x!=null&&x.byteLength){var P={type:"audio",frag:a,part:null,chunkMeta:b,parent:a.type,data:x};this.hls.trigger(O.Events.BUFFER_APPENDING,P)}this.tick()},c.loadFragment=function(d,a,b){var g=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||g===F.FragmentState.NOT_LOADED||g===F.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):a.live&&!Object(W.isFiniteNumber)(this.initPTS[d.cc])?(this.log("Waiting for video PTS in continuity counter "+d.cc+" of live stream before loading audio fragment "+d.sn+" of level "+this.trackId),this.state=k.State.WAITING_INIT_PTS):(this.startFragRequested=!0,L.prototype.loadFragment.call(this,d,a,b)))},c.completeAudioSwitch=function(){var d=this.hls,a=this.media,b=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),L.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,d.trigger(O.Events.AUDIO_TRACK_SWITCHED,{id:b})},p}(k.default);G.default=h},"./src/controller/audio-track-controller.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/events.ts"),k=A("./src/errors.ts"),O=A("./src/controller/base-playlist-controller.ts"),U=A("./src/types/loader.ts");function F(D,C){for(var T=0;T<C.length;T++){var E=C[T];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(D,E.key,E)}}function R(D,C,T){return C&&F(D.prototype,C),T&&F(D,T),D}function _(D,C){D.prototype=Object.create(C.prototype),D.prototype.constructor=D,v(D,C)}function v(D,C){return v=Object.setPrototypeOf||function(E,l){return E.__proto__=l,E},v(D,C)}var S=function(D){_(C,D);function C(E){var l;return l=D.call(this,E,"[audio-track-controller]")||this,l.tracks=[],l.groupId=null,l.tracksInGroup=[],l.trackId=-1,l.trackName="",l.selectDefaultTrack=!0,l.registerListeners(),l}var T=C.prototype;return T.registerListeners=function(){var l=this.hls;l.on(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),l.on(W.Events.LEVEL_LOADING,this.onLevelLoading,this),l.on(W.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),l.on(W.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.on(W.Events.ERROR,this.onError,this)},T.unregisterListeners=function(){var l=this.hls;l.off(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),l.off(W.Events.LEVEL_LOADING,this.onLevelLoading,this),l.off(W.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),l.off(W.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),l.off(W.Events.ERROR,this.onError,this)},T.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},T.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},T.onManifestParsed=function(l,o){this.tracks=o.audioTracks||[]},T.onAudioTrackLoaded=function(l,o){var s=o.id,u=o.details,w=this.tracksInGroup[s];if(!w){this.warn("Invalid audio track id "+s);return}var m=w.details;w.details=o.details,this.log("audioTrack "+s+" loaded ["+u.startSN+"-"+u.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,o,m))},T.onLevelLoading=function(l,o){this.switchLevel(o.level)},T.onLevelSwitching=function(l,o){this.switchLevel(o.level)},T.switchLevel=function(l){var o=this.hls.levels[l];if(!(o!=null&&o.audioGroupIds))return;var s=o.audioGroupIds[o.urlId];if(this.groupId!==s){this.groupId=s;var u=this.tracks.filter(function(m){return!s||m.groupId===s});this.selectDefaultTrack&&!u.some(function(m){return m.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var w={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger(W.Events.AUDIO_TRACKS_UPDATED,w),this.selectInitialTrack()}},T.onError=function(l,o){if(D.prototype.onError.call(this,l,o),o.fatal||!o.context)return;o.context.type===U.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},T.setAudioTrack=function(l){var o=this.tracksInGroup;if(l<0||l>=o.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var s=o[this.trackId];this.log("Now switching to audio-track index "+l);var u=o[l],w=u.id,m=u.groupId,h=m===void 0?"":m,L=u.name,p=u.type,c=u.url;if(this.trackId=l,this.trackName=L,this.selectDefaultTrack=!1,this.hls.trigger(W.Events.AUDIO_TRACK_SWITCHING,{id:w,groupId:h,name:L,type:p,url:c}),u.details&&!u.details.live)return;var f=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(f)},T.selectInitialTrack=function(){var l=this.tracksInGroup;console.assert(l.length,"Initial audio track should be selected when tracks are known");var o=this.trackName,s=this.findTrackId(o)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},T.findTrackId=function(l){for(var o=this.tracksInGroup,s=0;s<o.length;s++){var u=o[s];if((!this.selectDefaultTrack||u.default)&&(!l||l===u.name))return u.id}return-1},T.loadPlaylist=function(l){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var s=o.id,u=o.groupId,w=o.url;if(l)try{w=l.addDirectives(w)}catch(m){this.warn("Could not construct new URL with HLS Delivery Directives: "+m)}this.log("loading audio-track playlist for id: "+s),this.clearTimer(),this.hls.trigger(W.Events.AUDIO_TRACK_LOADING,{url:w,id:s,groupId:u,deliveryDirectives:l||null})}},R(C,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(l){this.selectDefaultTrack=!1,this.setAudioTrack(l)}}]),C}(O.default);G.default=S},"./src/controller/base-playlist-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return R});var W=A("./src/polyfills/number.ts"),k=A("./src/types/level.ts"),O=A("./src/controller/level-helper.ts"),U=A("./src/utils/logger.ts"),F=A("./src/errors.ts"),R=function(){function _(S,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=U.logger.log.bind(U.logger,D+":"),this.warn=U.logger.warn.bind(U.logger,D+":"),this.hls=S}var v=_.prototype;return v.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},v.onError=function(D,C){C.fatal&&C.type===F.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},v.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},v.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},v.stopLoad=function(){this.canLoad=!1,this.clearTimer()},v.switchParams=function(D,C){var T=C==null?void 0:C.renditionReports;if(T)for(var E=0;E<T.length;E++){var l=T[E],o=""+l.URI;if(o===D.substr(-o.length)){var s=parseInt(l["LAST-MSN"]),u=parseInt(l["LAST-PART"]);if(C&&this.hls.config.lowLatencyMode){var w=Math.min(C.age-C.partTarget,C.targetduration);u!==void 0&&w>C.partTarget&&(u+=1)}if(Object(W.isFiniteNumber)(s))return new k.HlsUrlParameters(s,Object(W.isFiniteNumber)(u)?u:void 0,k.HlsSkip.No)}}},v.loadPlaylist=function(D){},v.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},v.playlistLoaded=function(D,C,T){var E=this,l=C.details,o=C.stats,s=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(l.advancedDateTime=Date.now()-s,l.live||T!=null&&T.live){if(l.reloaded(T),T&&this.log("live playlist "+D+" "+(l.advanced?"REFRESHED "+l.lastPartSn+"-"+l.lastPartIndex:"MISSED")),T&&l.fragments.length>0&&Object(O.mergeDetails)(T,l),!this.canLoad||!l.live)return;var u,w=void 0,m=void 0;if(l.canBlockReload&&l.endSN&&l.advanced){var h=this.hls.config.lowLatencyMode,L=l.lastPartSn,p=l.endSN,c=l.lastPartIndex,f=c!==-1,d=L===p,a=h?0:c;f?(w=d?p+1:L,m=d?a:c+1):w=p+1;var b=l.age,g=b+l.ageHeader,x=Math.min(g-l.partTarget,l.targetduration*1.5);if(x>0){if(T&&x>T.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+T.tuneInGoal+" to: "+x+" with playlist age: "+l.age),x=0;else{var P=Math.floor(x/l.targetduration);if(w+=P,m!==void 0){var N=Math.round(x%l.targetduration/l.partTarget);m+=N}this.log("CDN Tune-in age: "+l.ageHeader+"s last advanced "+b.toFixed(2)+"s goal: "+x+" skip sn "+P+" to part "+m)}l.tuneInGoal=x}if(u=this.getDeliveryDirectives(l,C.deliveryDirectives,w,m),h||!d){this.loadPlaylist(u);return}}else u=this.getDeliveryDirectives(l,C.deliveryDirectives,w,m);var H=Object(O.computeReloadInterval)(l,o);w!==void 0&&l.canBlockReload&&(H-=l.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(H)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(u)},H)}else this.clearTimer()},v.getDeliveryDirectives=function(D,C,T,E){var l=Object(k.getSkipValue)(D,T);return C!=null&&C.skip&&D.deltaUpdateFailed&&(T=C.msn,E=C.part,l=k.HlsSkip.No),new k.HlsUrlParameters(T,E,l)},v.retryLoadingOrFail=function(D){var C=this,T=this.hls.config,E=this.retryCount<T.levelLoadingMaxRetry;if(E){var l;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(l=D.context)!==null&&l!==void 0&&l.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*T.levelLoadingRetryDelay,T.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return C.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return E},_}()},"./src/controller/base-stream-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"State",function(){return p}),A.d(G,"default",function(){return c});var W=A("./src/polyfills/number.ts"),k=A("./src/task-loop.ts"),O=A("./src/controller/fragment-tracker.ts"),U=A("./src/utils/buffer-helper.ts"),F=A("./src/utils/logger.ts"),R=A("./src/events.ts"),_=A("./src/errors.ts"),v=A("./src/types/transmuxer.ts"),S=A("./src/utils/mp4-tools.ts"),D=A("./src/utils/discontinuities.ts"),C=A("./src/controller/fragment-finders.ts"),T=A("./src/controller/level-helper.ts"),E=A("./src/loader/fragment-loader.ts"),l=A("./src/crypt/decrypter.ts"),o=A("./src/utils/time-ranges.ts"),s=A("./src/types/loader.ts");function u(f,d){for(var a=0;a<d.length;a++){var b=d[a];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(f,b.key,b)}}function w(f,d,a){return d&&u(f.prototype,d),a&&u(f,a),f}function m(f){if(f===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f}function h(f,d){f.prototype=Object.create(d.prototype),f.prototype.constructor=f,L(f,d)}function L(f,d){return L=Object.setPrototypeOf||function(b,g){return b.__proto__=g,b},L(f,d)}var p={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",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},c=function(f){h(d,f);function d(b,g,x){var P;return P=f.call(this)||this,P.hls=void 0,P.fragPrevious=null,P.fragCurrent=null,P.fragmentTracker=void 0,P.transmuxer=null,P._state=p.STOPPED,P.media=void 0,P.mediaBuffer=void 0,P.config=void 0,P.bitrateTest=!1,P.lastCurrentTime=0,P.nextLoadPosition=0,P.startPosition=0,P.loadedmetadata=!1,P.fragLoadError=0,P.retryDate=0,P.levels=null,P.fragmentLoader=void 0,P.levelLastLoaded=null,P.startFragRequested=!1,P.decrypter=void 0,P.initPTS=[],P.onvseeking=null,P.onvended=null,P.logPrefix="",P.log=void 0,P.warn=void 0,P.logPrefix=x,P.log=F.logger.log.bind(F.logger,x+":"),P.warn=F.logger.warn.bind(F.logger,x+":"),P.hls=b,P.fragmentLoader=new E.default(b.config),P.fragmentTracker=g,P.config=b.config,P.decrypter=new l.default(b,b.config),b.on(R.Events.KEY_LOADED,P.onKeyLoaded,m(P)),P}var a=d.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(g){},a.stopLoad=function(){this.fragmentLoader.abort();var g=this.fragCurrent;g&&this.fragmentTracker.removeFragment(g),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=p.STOPPED},a._streamEnded=function(g,x){var P=this.fragCurrent,N=this.fragmentTracker;if(!x.live&&P&&P.sn===x.endSN&&!g.nextStart){var H=N.getState(P);return H===O.FragmentState.PARTIAL||H===O.FragmentState.OK}return!1},a.onMediaAttached=function(g,x){var P=this.media=this.mediaBuffer=x.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),P.addEventListener("seeking",this.onvseeking),P.addEventListener("ended",this.onvended);var N=this.config;this.levels&&N.autoStartLoad&&this.state===p.STOPPED&&this.startLoad(N.startPosition)},a.onMediaDetaching=function(){var g=this.media;g!=null&&g.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),g&&(g.removeEventListener("seeking",this.onvseeking),g.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var g=this.config,x=this.fragCurrent,P=this.media,N=this.mediaBuffer,H=this.state,X=P?P.currentTime:0,B=U.BufferHelper.bufferInfo(N||P,X,g.maxBufferHole);if(this.log("media seeking to "+(Object(W.isFiniteNumber)(X)?X.toFixed(3):X)+", state: "+H),H===p.ENDED)this.resetLoadingState();else if(x&&!B.len){var I=g.maxFragLookUpTolerance,Y=x.start-I,te=x.start+x.duration+I,se=X>te;(X<Y||se)&&(se&&x.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),x.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=X),!this.loadedmetadata&&!B.len&&(this.nextLoadPosition=this.startPosition=X),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(g,x){if(this.state!==p.KEY_LOADING||x.frag!==this.fragCurrent||!this.levels)return;this.state=p.IDLE;var P=this.levels[x.frag.level].details;P&&this.loadFragment(x.frag,P,x.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),f.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=p.STOPPED,this.hls.off(R.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,f.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(g,x){this.log("Loading key for "+g.sn+" of ["+x.startSN+"-"+x.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level),this.state=p.KEY_LOADING,this.fragCurrent=g,this.hls.trigger(R.Events.KEY_LOADING,{frag:g})},a.loadFragment=function(g,x,P){this._loadFragForPlayback(g,x,P)},a._loadFragForPlayback=function(g,x,P){var N=this,H=function(B){if(N.fragContextChanged(g)){N.warn("Fragment "+g.sn+(B.part?" p: "+B.part.index:"")+" of level "+g.level+" was dropped during download."),N.fragmentTracker.removeFragment(g);return}g.stats.chunkCount++,N._handleFragmentLoadProgress(B)};this._doFragLoad(g,x,P,H).then(function(X){if(!X)return;N.fragLoadError=0;var B=N.state;if(N.fragContextChanged(g)){(B===p.FRAG_LOADING||B===p.BACKTRACKING||!N.fragCurrent&&B===p.PARSING)&&(N.fragmentTracker.removeFragment(g),N.state=p.IDLE);return}if("payload"in X&&(N.log("Loaded fragment "+g.sn+" of level "+g.level),N.hls.trigger(R.Events.FRAG_LOADED,X),N.state===p.BACKTRACKING)){N.fragmentTracker.backtrack(g,X),N.resetFragmentLoading(g);return}N._handleFragmentLoadComplete(X)}).catch(function(X){N.warn(X),N.resetFragmentLoading(g)})},a.flushMainBuffer=function(g,x,P){if(P===void 0&&(P=null),!(g-x))return;var N={startOffset:g,endOffset:x,type:P};this.fragLoadError=0,this.hls.trigger(R.Events.BUFFER_FLUSHING,N)},a._loadInitSegment=function(g){var x=this;this._doFragLoad(g).then(function(P){if(!P||x.fragContextChanged(g)||!x.levels)throw new Error("init load aborted");return P}).then(function(P){var N=x.hls,H=P.payload,X=g.decryptdata;if(H&&H.byteLength>0&&X&&X.key&&X.iv&&X.method==="AES-128"){var B=self.performance.now();return x.decrypter.webCryptoDecrypt(new Uint8Array(H),X.key.buffer,X.iv.buffer).then(function(I){var Y=self.performance.now();return N.trigger(R.Events.FRAG_DECRYPTED,{frag:g,payload:I,stats:{tstart:B,tdecrypt:Y}}),P.payload=I,P})}return P}).then(function(P){var N=x.fragCurrent,H=x.hls,X=x.levels;if(!X)throw new Error("init load aborted, missing levels");var B=X[g.level].details;console.assert(B,"Level details are defined when init segment is loaded");var I=g.stats;x.state=p.IDLE,x.fragLoadError=0,g.data=new Uint8Array(P.payload),I.parsing.start=I.buffering.start=self.performance.now(),I.parsing.end=I.buffering.end=self.performance.now(),P.frag===N&&H.trigger(R.Events.FRAG_BUFFERED,{stats:I,frag:N,part:null,id:g.type}),x.tick()}).catch(function(P){x.warn(P),x.resetFragmentLoading(g)})},a.fragContextChanged=function(g){var x=this.fragCurrent;return!g||!x||g.level!==x.level||g.sn!==x.sn||g.urlId!==x.urlId},a.fragBufferedComplete=function(g,x){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+g.type+" sn: "+g.sn+(x?" part: "+x.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+g.level+" "+o.default.toString(U.BufferHelper.getBuffered(P))),this.state=p.IDLE,this.tick()},a._handleFragmentLoadComplete=function(g){var x=this.transmuxer;if(!x)return;var P=g.frag,N=g.part,H=g.partsLoaded,X=!H||H.length===0||H.some(function(I){return!I}),B=new v.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,N?N.index:-1,!X);x.flush(B)},a._handleFragmentLoadProgress=function(g){},a._doFragLoad=function(g,x,P,N){var H=this;if(P===void 0&&(P=null),!this.levels)throw new Error("frag load aborted, missing levels");if(P=Math.max(g.start,P||0),this.config.lowLatencyMode&&x){var X=x.partList;if(X&&N){P>g.end&&x.fragmentHint&&(g=x.fragmentHint);var B=this.getNextPart(X,g,P);if(B>-1){var I=X[B];return this.log("Loading part sn: "+g.sn+" p: "+I.index+" cc: "+g.cc+" of playlist ["+x.startSN+"-"+x.endSN+"] parts [0-"+B+"-"+(X.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=I.start+I.duration,this.state=p.FRAG_LOADING,this.hls.trigger(R.Events.FRAG_LOADING,{frag:g,part:X[B],targetBufferTime:P}),this.doFragPartsLoad(g,X,B,N).catch(function(Y){return H.handleFragLoadError(Y)})}else if(!g.url||this.loadedEndOfParts(X,P))return Promise.resolve(null)}}return this.log("Loading fragment "+g.sn+" cc: "+g.cc+" "+(x?"of ["+x.startSN+"-"+x.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+g.level+", target: "+parseFloat(P.toFixed(3))),Object(W.isFiniteNumber)(g.sn)&&!this.bitrateTest&&(this.nextLoadPosition=g.start+g.duration),this.state=p.FRAG_LOADING,this.hls.trigger(R.Events.FRAG_LOADING,{frag:g,targetBufferTime:P}),this.fragmentLoader.load(g,N).catch(function(Y){return H.handleFragLoadError(Y)})},a.doFragPartsLoad=function(g,x,P,N){var H=this;return new Promise(function(X,B){var I=[],Y=function te(se){var de=x[se];H.fragmentLoader.loadPart(g,de,N).then(function(Se){I[de.index]=Se;var ge=Se.part;H.hls.trigger(R.Events.FRAG_LOADED,Se);var pe=x[se+1];if(pe&&pe.fragment===g)te(se+1);else return X({frag:g,part:ge,partsLoaded:I})}).catch(B)};Y(P)})},a.handleFragLoadError=function(g){var x=g.data;return x&&x.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(x.frag,x.part):this.hls.trigger(R.Events.ERROR,x),null},a._handleTransmuxerFlush=function(g){var x=this.getCurrentContext(g);if(!x||this.state!==p.PARSING){this.fragCurrent||(this.state=p.IDLE);return}var P=x.frag,N=x.part,H=x.level,X=self.performance.now();P.stats.parsing.end=X,N&&(N.stats.parsing.end=X),this.updateLevelTiming(P,N,H,g.partial)},a.getCurrentContext=function(g){var x=this.levels,P=g.level,N=g.sn,H=g.part;if(!x||!x[P])return this.warn("Levels object was unset while buffering fragment "+N+" of level "+P+". The current chunk will not be buffered."),null;var X=x[P],B=H>-1?Object(T.getPartWith)(X,N,H):null,I=B?B.fragment:Object(T.getFragmentWithSN)(X,N,this.fragCurrent);return I?{frag:I,part:B,level:X}:null},a.bufferFragmentData=function(g,x,P,N){if(!g||this.state!==p.PARSING)return;var H=g.data1,X=g.data2,B=H;if(H&&X&&(B=Object(S.appendUint8Array)(H,X)),!B||!B.length)return;var I={type:g.type,frag:x,part:P,chunkMeta:N,parent:x.type,data:B};this.hls.trigger(R.Events.BUFFER_APPENDING,I),g.dropped&&g.independent&&!P&&this.flushBufferGap(x)},a.flushBufferGap=function(g){var x=this.media;if(!x)return;if(!U.BufferHelper.isBuffered(x,x.currentTime)){this.flushMainBuffer(0,g.start);return}var P=x.currentTime,N=U.BufferHelper.bufferInfo(x,P,0),H=g.duration,X=Math.min(this.config.maxFragLookUpTolerance*2,H*.25),B=Math.max(Math.min(g.start-X,N.end-X),P+X);g.start-B>X&&this.flushMainBuffer(B,g.start)},a.getFwdBufferInfo=function(g,x){var P=this.config,N=this.getLoadPosition();if(!Object(W.isFiniteNumber)(N))return null;var H=U.BufferHelper.bufferInfo(g,N,P.maxBufferHole);if(H.len===0&&H.nextStart!==void 0){var X=this.fragmentTracker.getBufferedFrag(N,x);if(X&&H.nextStart<X.end)return U.BufferHelper.bufferInfo(g,N,Math.max(H.nextStart,P.maxBufferHole))}return H},a.getMaxBufferLength=function(g){var x=this.config,P;return g?P=Math.max(8*x.maxBufferSize/g,x.maxBufferLength):P=x.maxBufferLength,Math.min(P,x.maxMaxBufferLength)},a.reduceMaxBufferLength=function(g){var x=this.config,P=g||x.maxBufferLength;return x.maxMaxBufferLength>=P?(x.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+x.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(g,x){var P,N,H=x.fragments,X=H.length;if(!X)return null;var B=this.config,I=H[0].start,Y;if(x.live){var te=B.initialLiveManifestSize;if(X<te)return this.warn("Not enough fragments to start playback (have: "+X+", need: "+te+")"),null;!x.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(Y=this.getInitialLiveFragment(x,H),this.startPosition=Y?this.hls.liveSyncPosition||Y.start:g)}else g<=I&&(Y=H[0]);if(!Y){var se=B.lowLatencyMode?x.partEnd:x.fragmentEnd;Y=this.getFragmentAtPosition(g,se,x)}return(P=Y)!==null&&P!==void 0&&P.initSegment&&!((N=Y)!==null&&N!==void 0&&N.initSegment.data)&&!this.bitrateTest&&(Y=Y.initSegment),Y},a.getNextPart=function(g,x,P){for(var N=-1,H=!1,X=!0,B=0,I=g.length;B<I;B++){var Y=g[B];if(X=X&&!Y.independent,N>-1&&P<Y.start)break;var te=Y.loaded;!te&&(H||Y.independent||X)&&Y.fragment===x&&(N=B),H=te}return N},a.loadedEndOfParts=function(g,x){var P=g[g.length-1];return P&&x>P.start&&P.loaded},a.getInitialLiveFragment=function(g,x){var P=this.fragPrevious,N=null;if(P){if(g.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),N=Object(C.findFragmentByPDT)(x,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!N){var H=P.sn+1;if(H>=g.startSN&&H<=g.endSN){var X=x[H-g.startSN];P.cc===X.cc&&(N=X,this.log("Live playlist, switching playlist, load frag with next SN: "+N.sn))}N||(N=Object(C.findFragWithCC)(x,P.cc),N&&this.log("Live playlist, switching playlist, load frag with same CC: "+N.sn))}}else{var B=this.hls.liveSyncPosition;B!==null&&(N=this.getFragmentAtPosition(B,this.bitrateTest?g.fragmentEnd:g.edge,g))}return N},a.getFragmentAtPosition=function(g,x,P){var N=this.config,H=this.fragPrevious,X=P.fragments,B=P.endSN,I=P.fragmentHint,Y=N.maxFragLookUpTolerance,te=!!(N.lowLatencyMode&&P.partList&&I);te&&I&&!this.bitrateTest&&(X=X.concat(I),B=I.sn);var se;if(g<x){var de=g>x-Y?0:Y;se=Object(C.findFragmentByPTS)(H,X,g,de)}else se=X[X.length-1];if(se){var Se=se.sn-P.startSN,ge=H&&se.level===H.level,pe=X[Se+1],he=this.fragmentTracker.getState(se);if(he===O.FragmentState.BACKTRACKED){se=null;for(var me=Se;X[me]&&this.fragmentTracker.getState(X[me])===O.FragmentState.BACKTRACKED;)H?se=X[me--]:se=X[--me];se||(se=pe)}else H&&se.sn===H.sn&&!te&&(ge&&(se.sn<B&&this.fragmentTracker.getState(pe)!==O.FragmentState.OK?(this.log("SN "+se.sn+" just loaded, load next one: "+pe.sn),se=pe):se=null))}return se},a.synchronizeToLiveEdge=function(g){var x=this.config,P=this.media;if(!P)return;var N=this.hls.liveSyncPosition,H=P.currentTime,X=g.fragments[0].start,B=g.edge,I=H>=X-x.maxFragLookUpTolerance&&H<=B;if(N!==null&&P.duration>N&&(H<N||!I)){var Y=x.liveMaxLatencyDuration!==void 0?x.liveMaxLatencyDuration:x.liveMaxLatencyDurationCount*g.targetduration;(!I&&P.readyState<4||H<B-Y)&&(this.loadedmetadata||(this.nextLoadPosition=N),P.readyState&&(this.warn("Playback: "+H.toFixed(3)+" is located too far from the end of live sliding playlist: "+B+", reset currentTime to : "+N.toFixed(3)),P.currentTime=N))}},a.alignPlaylists=function(g,x){var P=this.levels,N=this.levelLastLoaded,H=this.fragPrevious,X=N!==null?P[N]:null,B=g.fragments.length;if(!B)return this.warn("No fragments in live playlist"),0;var I=g.fragments[0].start,Y=!x,te=g.alignedSliding&&Object(W.isFiniteNumber)(I);if(Y||!te&&!I){Object(D.alignStream)(H,X,g);var se=g.fragments[0].start;return this.log("Live playlist sliding: "+se.toFixed(2)+" start-sn: "+(x?x.startSN:"na")+"->"+g.startSN+" prev-sn: "+(H?H.sn:"na")+" fragments: "+B),se}return I},a.waitForCdnTuneIn=function(g){var x=3;return g.live&&g.canBlockReload&&g.tuneInGoal>Math.max(g.partHoldBack,g.partTarget*x)},a.setStartPosition=function(g,x){var P=this.startPosition;if(P<x&&(P=-1),P===-1||this.lastCurrentTime===-1){var N=g.startTimeOffset;Object(W.isFiniteNumber)(N)?(P=x+N,N<0&&(P+=g.totalduration),P=Math.min(Math.max(x,P),x+g.totalduration),this.log("Start time offset "+N+" found in playlist, adjust startPosition to "+P),this.startPosition=P):g.live?P=this.hls.liveSyncPosition||x:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},a.getLoadPosition=function(){var g=this.media,x=0;return this.loadedmetadata&&g?x=g.currentTime:this.nextLoadPosition&&(x=this.nextLoadPosition),x},a.handleFragLoadAborted=function(g,x){this.transmuxer&&g.sn!=="initSegment"&&g.stats.aborted&&(this.warn("Fragment "+g.sn+(x?" part"+x.index:"")+" of level "+g.level+" was aborted"),this.resetFragmentLoading(g))},a.resetFragmentLoading=function(g){(!this.fragCurrent||!this.fragContextChanged(g))&&(this.state=p.IDLE)},a.onFragmentOrKeyLoadError=function(g,x){if(x.fatal)return;var P=x.frag;if(!P||P.type!==g)return;var N=this.fragCurrent;console.assert(N&&P.sn===N.sn&&P.level===N.level&&P.urlId===N.urlId,"Frag load error must match current frag to retry");var H=this.config;if(this.fragLoadError+1<=H.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(P.level))return;var X=Math.min(Math.pow(2,this.fragLoadError)*H.fragLoadingRetryDelay,H.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+g+" "+P.level+" failed to load, retrying in "+X+"ms"),this.retryDate=self.performance.now()+X,this.fragLoadError++,this.state=p.FRAG_LOADING_WAITING_RETRY}else x.levelRetry?(g===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=p.IDLE):(F.logger.error(x.details+" reaches max retry, redispatch as fatal ..."),x.fatal=!0,this.hls.stopLoad(),this.state=p.ERROR)},a.afterBufferFlushed=function(g,x,P){if(!g)return;var N=U.BufferHelper.getBuffered(g);this.fragmentTracker.detectEvictedFragments(x,N,P),this.state===p.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=p.IDLE},a.resetLiveStartWhenNotLoaded=function(g){if(!this.loadedmetadata){this.startFragRequested=!1;var x=this.levels?this.levels[g].details:null;if(x!=null&&x.live)return this.startPosition=-1,this.setStartPosition(x,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(g,x,P,N){var H=this,X=P.details;console.assert(!!X,"level.details must be defined");var B=Object.keys(g.elementaryStreams).reduce(function(I,Y){var te=g.elementaryStreams[Y];if(te){var se=te.endPTS-te.startPTS;if(se<=0)return H.warn("Could not parse fragment "+g.sn+" "+Y+" duration reliably ("+se+") resetting transmuxer to fallback to playlist timing"),H.resetTransmuxer(),I||!1;var de=N?0:Object(T.updateFragPTSDTS)(X,g,te.startPTS,te.endPTS,te.startDTS,te.endDTS);return H.hls.trigger(R.Events.LEVEL_PTS_UPDATED,{details:X,level:P,drift:de,type:Y,frag:g,start:te.startPTS,end:te.endPTS}),!0}return I},!1);B?(this.state=p.PARSED,this.hls.trigger(R.Events.FRAG_PARSED,{frag:g,part:x})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},w(d,[{key:"state",get:function(){return this._state},set:function(g){var x=this._state;x!==g&&(this._state=g,this.log(x+"->"+g))}}]),d}(k.default)},"./src/controller/buffer-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return C});var W=A("./src/polyfills/number.ts"),k=A("./src/events.ts"),O=A("./src/utils/logger.ts"),U=A("./src/errors.ts"),F=A("./src/utils/buffer-helper.ts"),R=A("./src/utils/mediasource-helper.ts"),_=A("./src/loader/fragment.ts"),v=A("./src/controller/buffer-operation-queue.ts"),S=Object(R.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,C=function(){function T(l){var o=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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var s=o.hls,u=o.media,w=o.mediaSource;O.logger.log("[buffer-controller]: Media source opened"),u&&(o.updateMediaElementDuration(),s.trigger(k.Events.MEDIA_ATTACHED,{media:u})),w&&w.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){O.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){O.logger.log("[buffer-controller]: Media source ended")},this.hls=l,this._initSourceBuffer(),this.registerListeners()}var E=T.prototype;return E.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},E.destroy=function(){this.unregisterListeners(),this.details=null},E.registerListeners=function(){var o=this.hls;o.on(k.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(k.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(k.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(k.Events.BUFFER_RESET,this.onBufferReset,this),o.on(k.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(k.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(k.Events.BUFFER_EOS,this.onBufferEos,this),o.on(k.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(k.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(k.Events.FRAG_PARSED,this.onFragParsed,this),o.on(k.Events.FRAG_CHANGED,this.onFragChanged,this)},E.unregisterListeners=function(){var o=this.hls;o.off(k.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(k.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(k.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(k.Events.BUFFER_RESET,this.onBufferReset,this),o.off(k.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(k.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(k.Events.BUFFER_EOS,this.onBufferEos,this),o.off(k.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(k.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(k.Events.FRAG_PARSED,this.onFragParsed,this),o.off(k.Events.FRAG_CHANGED,this.onFragChanged,this)},E._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new v.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},E.onManifestParsed=function(o,s){var u=2;(s.audio&&!s.video||!s.altAudio)&&(u=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=u,this.details=null,O.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},E.onMediaAttaching=function(o,s){var u=this.media=s.media;if(u&&S){var w=this.mediaSource=new S;w.addEventListener("sourceopen",this._onMediaSourceOpen),w.addEventListener("sourceended",this._onMediaSourceEnded),w.addEventListener("sourceclose",this._onMediaSourceClose),u.src=self.URL.createObjectURL(w),this._objectUrl=u.src}},E.onMediaDetaching=function(){var o=this.media,s=this.mediaSource,u=this._objectUrl;if(s){if(O.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(w){O.logger.warn("[buffer-controller]: onMediaDetaching: "+w.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(u&&self.URL.revokeObjectURL(u),o.src===u?(o.removeAttribute("src"),o.load()):O.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(k.Events.MEDIA_DETACHED,void 0)},E.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(s){var u=o.sourceBuffer[s];try{u&&(o.removeBufferListeners(s),o.mediaSource&&o.mediaSource.removeSourceBuffer(u),o.sourceBuffer[s]=void 0)}catch(w){O.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",w)}}),this._initSourceBuffer()},E.onBufferCodecs=function(o,s){var u=this,w=this.getSourceBufferTypes().length;if(Object.keys(s).forEach(function(m){if(w){var h=u.tracks[m];if(h&&typeof h.buffer.changeType=="function"){var L=s[m],p=L.codec,c=L.levelCodec,f=L.container,d=(h.levelCodec||h.codec).replace(D,"$1"),a=(c||p).replace(D,"$1");if(d!==a){var b=f+";codecs="+(c||p);u.appendChangeType(m,b)}}}else u.pendingTracks[m]=s[m]}),w)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},E.appendChangeType=function(o,s){var u=this,w=this.operationQueue,m={execute:function(){var L=u.sourceBuffer[o];L&&(O.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+s),L.changeType(s)),w.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(L){O.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",L)}};w.append(m,o)},E.onBufferAppending=function(o,s){var u=this,w=this.hls,m=this.operationQueue,h=this.tracks,L=s.data,p=s.type,c=s.frag,f=s.part,d=s.chunkMeta,a=d.buffering[p],b=self.performance.now();a.start=b;var g=c.stats.buffering,x=f?f.stats.buffering:null;g.start===0&&(g.start=b),x&&x.start===0&&(x.start=b);var P=h.audio,N=p==="audio"&&d.id===1&&(P==null?void 0:P.container)==="audio/mpeg",H={execute:function(){if(a.executeStart=self.performance.now(),N){var B=u.sourceBuffer[p];if(B){var I=c.start-B.timestampOffset;Math.abs(I)>=.1&&(O.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+c.start+" (delta: "+I+") sn: "+c.sn+")"),B.timestampOffset=c.start)}}u.appendExecutor(L,p)},onStart:function(){},onComplete:function(){var B=self.performance.now();a.executeEnd=a.end=B,g.first===0&&(g.first=B),x&&x.first===0&&(x.first=B);var I=u.sourceBuffer,Y={};for(var te in I)Y[te]=F.BufferHelper.getBuffered(I[te]);u.appendError=0,u.hls.trigger(k.Events.BUFFER_APPENDED,{type:p,frag:c,part:f,chunkMeta:d,parent:c.type,timeRanges:Y})},onError:function(B){O.logger.error("[buffer-controller]: Error encountered while trying to append to the "+p+" SourceBuffer",B);var I={type:U.ErrorTypes.MEDIA_ERROR,parent:c.type,details:U.ErrorDetails.BUFFER_APPEND_ERROR,err:B,fatal:!1};B.code===DOMException.QUOTA_EXCEEDED_ERR?I.details=U.ErrorDetails.BUFFER_FULL_ERROR:(u.appendError++,I.details=U.ErrorDetails.BUFFER_APPEND_ERROR,u.appendError>w.config.appendErrorMaxRetry&&(O.logger.error("[buffer-controller]: Failed "+w.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),I.fatal=!0)),w.trigger(k.Events.ERROR,I)}};m.append(H,p)},E.onBufferFlushing=function(o,s){var u=this,w=this.operationQueue,m=function(L){return{execute:u.removeExecutor.bind(u,L,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){u.hls.trigger(k.Events.BUFFER_FLUSHED,{type:L})},onError:function(c){O.logger.warn("[buffer-controller]: Failed to remove from "+L+" SourceBuffer",c)}}};s.type?w.append(m(s.type),s.type):this.getSourceBufferTypes().forEach(function(h){w.append(m(h),h)})},E.onFragParsed=function(o,s){var u=this,w=s.frag,m=s.part,h=[],L=m?m.elementaryStreams:w.elementaryStreams;L[_.ElementaryStreamTypes.AUDIOVIDEO]?h.push("audiovideo"):(L[_.ElementaryStreamTypes.AUDIO]&&h.push("audio"),L[_.ElementaryStreamTypes.VIDEO]&&h.push("video"));var p=function(){var f=self.performance.now();w.stats.buffering.end=f,m&&(m.stats.buffering.end=f);var d=m?m.stats:w.stats;u.hls.trigger(k.Events.FRAG_BUFFERED,{frag:w,part:m,stats:d,id:w.type})};h.length===0&&O.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+w.type+" level: "+w.level+" sn: "+w.sn),this.blockBuffers(p,h)},E.onFragChanged=function(o,s){this.flushBackBuffer()},E.onBufferEos=function(o,s){var u=this,w=this.getSourceBufferTypes().reduce(function(m,h){var L=u.sourceBuffer[h];return(!s.type||s.type===h)&&(L&&!L.ended&&(L.ended=!0,O.logger.log("[buffer-controller]: "+h+" sourceBuffer now EOS"))),m&&!!(!L||L.ended)},!0);w&&this.blockBuffers(function(){var m=u.mediaSource;if(!m||m.readyState!=="open")return;m.endOfStream()})},E.onLevelUpdated=function(o,s){var u=s.details;if(!u.fragments.length)return;this.details=u,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},E.flushBackBuffer=function(){var o=this.hls,s=this.details,u=this.media,w=this.sourceBuffer;if(!u||s===null)return;var m=this.getSourceBufferTypes();if(!m.length)return;var h=s.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object(W.isFiniteNumber)(h)||h<0)return;var L=u.currentTime,p=s.levelTargetDuration,c=Math.max(h,p),f=Math.floor(L/p)*p-c;m.forEach(function(d){var a=w[d];if(a){var b=F.BufferHelper.getBuffered(a);b.length>0&&f>b.start(0)&&(o.trigger(k.Events.BACK_BUFFER_REACHED,{bufferEnd:f}),s.live&&o.trigger(k.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f}),o.trigger(k.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:d}))}})},E.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,s=this.hls,u=this.media,w=this.mediaSource,m=o.fragments[0].start+o.totalduration,h=u.duration,L=Object(W.isFiniteNumber)(w.duration)?w.duration:0;o.live&&s.config.liveDurationInfinity?(O.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),w.duration=Infinity,this.updateSeekableRange(o)):(m>L&&m>h||!Object(W.isFiniteNumber)(h))&&(O.logger.log("[buffer-controller]: Updating Media Source duration to "+m.toFixed(3)),w.duration=m)},E.updateSeekableRange=function(o){var s=this.mediaSource,u=o.fragments,w=u.length;if(w&&o.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var m=Math.max(0,u[0].start),h=Math.max(m,m+o.totalduration);s.setLiveSeekableRange(m,h)}},E.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,s=this.operationQueue,u=this.pendingTracks,w=Object.keys(u).length;if(w&&!o||w===2){this.createSourceBuffers(u),this.pendingTracks={};var m=this.getSourceBufferTypes();if(m.length===0){this.hls.trigger(k.Events.ERROR,{type:U.ErrorTypes.MEDIA_ERROR,details:U.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}m.forEach(function(h){s.executeNext(h)})}},E.createSourceBuffers=function(o){var s=this.sourceBuffer,u=this.mediaSource;if(!u)throw Error("createSourceBuffers called when mediaSource was null");var w=0;for(var m in o)if(!s[m]){var h=o[m];if(!h)throw Error("source buffer exists for track "+m+", however track does not");var L=h.levelCodec||h.codec,p=h.container+";codecs="+L;O.logger.log("[buffer-controller]: creating sourceBuffer("+p+")");try{var c=s[m]=u.addSourceBuffer(p),f=m;this.addBufferListener(f,"updatestart",this._onSBUpdateStart),this.addBufferListener(f,"updateend",this._onSBUpdateEnd),this.addBufferListener(f,"error",this._onSBUpdateError),this.tracks[m]={buffer:c,codec:L,container:h.container,levelCodec:h.levelCodec,id:h.id},w++}catch(d){O.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(k.Events.ERROR,{type:U.ErrorTypes.MEDIA_ERROR,details:U.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:p})}}w&&this.hls.trigger(k.Events.BUFFER_CREATED,{tracks:this.tracks})},E._onSBUpdateStart=function(o){var s=this.operationQueue,u=s.current(o);u.onStart()},E._onSBUpdateEnd=function(o){var s=this.operationQueue,u=s.current(o);u.onComplete(),s.shiftAndExecuteNext(o)},E._onSBUpdateError=function(o,s){O.logger.error("[buffer-controller]: "+o+" SourceBuffer error",s),this.hls.trigger(k.Events.ERROR,{type:U.ErrorTypes.MEDIA_ERROR,details:U.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var u=this.operationQueue.current(o);u&&u.onError(s)},E.removeExecutor=function(o,s,u){var w=this.media,m=this.mediaSource,h=this.operationQueue,L=this.sourceBuffer,p=L[o];if(!w||!m||!p){O.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(o);return}var c=Object(W.isFiniteNumber)(w.duration)?w.duration:Infinity,f=Object(W.isFiniteNumber)(m.duration)?m.duration:Infinity,d=Math.max(0,s),a=Math.min(u,c,f);a>d?(O.logger.log("[buffer-controller]: Removing ["+d+","+a+"] from the "+o+" SourceBuffer"),console.assert(!p.updating,o+" sourceBuffer must not be updating"),p.remove(d,a)):h.shiftAndExecuteNext(o)},E.appendExecutor=function(o,s){var u=this.operationQueue,w=this.sourceBuffer,m=w[s];if(!m){O.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),u.shiftAndExecuteNext(s);return}m.ended=!1,console.assert(!m.updating,s+" sourceBuffer must not be updating"),m.appendBuffer(o)},E.blockBuffers=function(o,s){var u=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){O.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var w=this.operationQueue,m=s.map(function(h){return w.appendBlocker(h)});Promise.all(m).then(function(){o(),s.forEach(function(h){var L=u.sourceBuffer[h];(!L||!L.updating)&&w.shiftAndExecuteNext(h)})})},E.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},E.addBufferListener=function(o,s,u){var w=this.sourceBuffer[o];if(!w)return;var m=u.bind(this,o);this.listeners[o].push({event:s,listener:m}),w.addEventListener(s,m)},E.removeBufferListeners=function(o){var s=this.sourceBuffer[o];if(!s)return;this.listeners[o].forEach(function(u){s.removeEventListener(u.event,u.listener)})},T}()},"./src/controller/buffer-operation-queue.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return k});var W=A("./src/utils/logger.ts"),k=function(){function O(F){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=F}var U=O.prototype;return U.append=function(R,_){var v=this.queues[_];v.push(R),v.length===1&&this.buffers[_]&&this.executeNext(_)},U.insertAbort=function(R,_){var v=this.queues[_];v.unshift(R),this.executeNext(_)},U.appendBlocker=function(R){var _,v=new Promise(function(D){_=D}),S={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(S,R),v},U.executeNext=function(R){var _=this.buffers,v=this.queues,S=_[R],D=v[R];if(D.length){var C=D[0];try{C.execute()}catch(T){W.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),C.onError(T),(!S||!S.updating)&&(D.shift(),this.executeNext(R))}}},U.shiftAndExecuteNext=function(R){this.queues[R].shift(),this.executeNext(R)},U.current=function(R){return this.queues[R][0]},O}()},"./src/controller/cap-level-controller.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/events.ts");function k(F,R){for(var _=0;_<R.length;_++){var v=R[_];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(F,v.key,v)}}function O(F,R,_){return R&&k(F.prototype,R),_&&k(F,_),F}var U=function(){function F(_){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=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var R=F.prototype;return R.setStreamController=function(v){this.streamController=v},R.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},R.registerListeners=function(){var v=this.hls;v.on(W.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.on(W.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.on(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(W.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.on(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},R.unregisterListener=function(){var v=this.hls;v.off(W.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.off(W.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(W.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(W.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.off(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},R.onFpsDropLevelCapping=function(v,S){F.isLevelAllowed(S.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(S.droppedLevel)},R.onMediaAttaching=function(v,S){this.media=S.media instanceof HTMLVideoElement?S.media:null},R.onManifestParsed=function(v,S){var D=this.hls;this.restrictedLevels=[],this.firstLevel=S.firstLevel,D.config.capLevelToPlayerSize&&S.video&&this.startCapping()},R.onBufferCodecs=function(v,S){var D=this.hls;D.config.capLevelToPlayerSize&&S.video&&this.startCapping()},R.onMediaDetaching=function(){this.stopCapping()},R.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var v=this.hls.levels;if(v.length){var S=this.hls;S.autoLevelCapping=this.getMaxLevel(v.length-1),S.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=S.autoLevelCapping}}},R.getMaxLevel=function(v){var S=this,D=this.hls.levels;if(!D.length)return-1;var C=D.filter(function(T,E){return F.isLevelAllowed(E,S.restrictedLevels)&&E<=v});return this.clientRect=null,F.getMaxLevelByMediaSize(C,this.mediaWidth,this.mediaHeight)},R.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()},R.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},R.getDimensions=function(){if(this.clientRect)return this.clientRect;var v=this.media,S={width:0,height:0};if(v){var D=v.getBoundingClientRect();S.width=D.width,S.height=D.height,!S.width&&!S.height&&(S.width=D.right-D.left||v.width||0,S.height=D.bottom-D.top||v.height||0)}return this.clientRect=S,S},F.isLevelAllowed=function(v,S){return S===void 0&&(S=[]),S.indexOf(v)===-1},F.getMaxLevelByMediaSize=function(v,S,D){if(!v||!v.length)return-1;for(var C=function(s,u){return u?s.width!==u.width||s.height!==u.height:!0},T=v.length-1,E=0;E<v.length;E+=1){var l=v[E];if((l.width>=S||l.height>=D)&&C(l,v[E+1])){T=E;break}}return T},O(F,[{key:"mediaWidth",get:function(){return this.getDimensions().width*F.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*F.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var v=1;try{v=self.devicePixelRatio}catch(S){}return v}}]),F}();G.default=U},"./src/controller/cmcd-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return C});var W=A("./src/events.ts"),k=A("./src/types/cmcd.ts"),O=A("./src/utils/buffer-helper.ts"),U=A("./src/utils/logger.ts");function F(T,E){for(var l=0;l<E.length;l++){var o=E[l];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(T,o.key,o)}}function R(T,E,l){return E&&F(T.prototype,E),l&&F(T,l),T}function _(T,E){var l=typeof Symbol!="undefined"&&T[Symbol.iterator]||T["@@iterator"];if(l)return(l=l.call(T)).next.bind(l);if(Array.isArray(T)||(l=v(T))||E&&T&&typeof T.length=="number"){l&&(T=l);var o=0;return function(){return o>=T.length?{done:!0}:{done:!1,value:T[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 v(T,E){if(!T)return;if(typeof T=="string")return S(T,E);var l=Object.prototype.toString.call(T).slice(8,-1);if(l==="Object"&&T.constructor&&(l=T.constructor.name),l==="Map"||l==="Set")return Array.from(T);if(l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return S(T,E)}function S(T,E){(E==null||E>T.length)&&(E=T.length);for(var l=0,o=new Array(E);l<E;l++)o[l]=T[l];return o}function D(){return D=Object.assign||function(T){for(var E=1;E<arguments.length;E++){var l=arguments[E];for(var o in l)Object.prototype.hasOwnProperty.call(l,o)&&(T[o]=l[o])}return T},D.apply(this,arguments)}var C=function(){function T(l){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(w){try{o.apply(w,{ot:k.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(m){U.logger.warn("Could not generate manifest CMCD data.",m)}},this.applyFragmentData=function(w){try{var m=w.frag,h=o.hls.levels[m.level],L=o.getObjectType(m),p={d:m.duration*1e3,ot:L};(L===k.CMCDObjectType.VIDEO||L===k.CMCDObjectType.AUDIO||L==k.CMCDObjectType.MUXED)&&(p.br=h.bitrate/1e3,p.tb=o.getTopBandwidth(L),p.bl=o.getBufferLength(L)),o.apply(w,p)}catch(c){U.logger.warn("Could not generate segment CMCD data.",c)}},this.hls=l;var s=this.config=l.config,u=s.cmcd;u!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=u.sessionId||T.uuid(),this.cid=u.contentId,this.useHeaders=u.useHeaders===!0,this.registerListeners())}var E=T.prototype;return E.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)},E.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()},E.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},E.onMediaAttached=function(o,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},E.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},E.onBufferCreated=function(o,s){var u,w;this.audioBuffer=(u=s.tracks.audio)===null||u===void 0?void 0:u.buffer,this.videoBuffer=(w=s.tracks.video)===null||w===void 0?void 0:w.buffer},E.createData=function(){var o;return{v:k.CMCDVersion,sf:k.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}},E.apply=function(o,s){s===void 0&&(s={}),D(s,this.createData());var u=s.ot===k.CMCDObjectType.INIT||s.ot===k.CMCDObjectType.VIDEO||s.ot===k.CMCDObjectType.MUXED;if(this.starved&&u&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var w=T.toHeaders(s);if(!Object.keys(w).length)return;o.headers||(o.headers={}),D(o.headers,w)}else{var m=T.toQuery(s);if(!m)return;o.url=T.appendQueryToUri(o.url,m)}},E.getObjectType=function(o){var s=o.type;return s==="subtitle"?k.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?k.CMCDObjectType.INIT:s==="audio"?k.CMCDObjectType.AUDIO:s==="main"?this.hls.audioTracks.length?k.CMCDObjectType.VIDEO:k.CMCDObjectType.MUXED:void 0},E.getTopBandwidth=function(o){for(var s=0,u=o===k.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,w=_(u),m;!(m=w()).done;){var h=m.value;h.bitrate>s&&(s=h.bitrate)}return s>0?s:NaN},E.getBufferLength=function(o){var s=this.hls.media,u=o===k.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!u||!s)return NaN;var w=O.BufferHelper.bufferInfo(u,s.currentTime,this.config.maxBufferHole);return w.len*1e3},E.createPlaylistLoader=function(){var o=this.config.pLoader,s=this.applyPlaylistData,u=o||this.config.loader;return function(){function w(h){this.loader=void 0,this.loader=new u(h)}var m=w.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(L,p,c){s(L),this.loader.load(L,p,c)},R(w,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),w}()},E.createFragmentLoader=function(){var o=this.config.fLoader,s=this.applyFragmentData,u=o||this.config.loader;return function(){function w(h){this.loader=void 0,this.loader=new u(h)}var m=w.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(L,p,c){s(L),this.loader.load(L,p,c)},R(w,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),w}()},T.uuid=function(){var o=URL.createObjectURL(new Blob),s=o.toString();return URL.revokeObjectURL(o),s.substr(s.lastIndexOf("/")+1)},T.serialize=function(o){for(var s=[],u=function(N){return!Number.isNaN(N)&&N!=null&&N!==""&&N!==!1},w=function(N){return Math.round(N)},m=function(N){return w(N/100)*100},h=function(N){return encodeURIComponent(N)},L={br:w,d:w,bl:m,dl:m,mtp:m,nor:h,rtp:m,tb:w},p=Object.keys(o||{}).sort(),c=_(p),f;!(f=c()).done;){var d=f.value,a=o[d];if(!u(a))continue;if(d==="v"&&a===1)continue;if(d=="pr"&&a===1)continue;var b=L[d];b&&(a=b(a));var g=typeof a,x=void 0;d==="ot"||d==="sf"||d==="st"?x=d+"="+a:g==="boolean"?x=d:g==="number"?x=d+"="+a:x=d+"="+JSON.stringify(a),s.push(x)}return s.join(",")},T.toHeaders=function(o){for(var s=Object.keys(o),u={},w=["Object","Request","Session","Status"],m=[{},{},{},{}],h={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},L=0,p=s;L<p.length;L++){var c=p[L],f=h[c]!=null?h[c]:1;m[f][c]=o[c]}for(var d=0;d<m.length;d++){var a=T.serialize(m[d]);a&&(u["CMCD-"+w[d]]=a)}return u},T.toQuery=function(o){return"CMCD="+encodeURIComponent(T.serialize(o))},T.appendQueryToUri=function(o,s){if(!s)return o;var u=o.includes("?")?"&":"?";return""+o+u+s},T}()},"./src/controller/eme-controller.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/events.ts"),k=A("./src/errors.ts"),O=A("./src/utils/logger.ts"),U=A("./src/utils/mediakeys-helper.ts");function F(C,T){for(var E=0;E<T.length;E++){var l=T[E];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(C,l.key,l)}}function R(C,T,E){return T&&F(C.prototype,T),E&&F(C,E),C}var _=3,v=function(T,E,l){var o={audioCapabilities:[],videoCapabilities:[]};return T.forEach(function(s){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:l.audioRobustness||""})}),E.forEach(function(s){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:l.videoRobustness||""})}),[o]},S=function(T,E,l,o){switch(T){case U.KeySystems.WIDEVINE:return v(E,l,o);default:throw new Error("Unknown key-system: "+T)}},D=function(){function C(E){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=E,this._config=E.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var T=C.prototype;return T.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},T._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_PARSED,this.onManifestParsed,this)},T._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_PARSED,this.onManifestParsed,this)},T.getLicenseServerUrl=function(l){switch(l){case U.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+l+'"')},T._attemptKeySystemAccess=function(l,o,s){var u=this,w=S(l,o,s,this._drmSystemOptions);O.logger.log("Requesting encrypted media key-system access");var m=this.requestMediaKeySystemAccess(l,w);this.mediaKeysPromise=m.then(function(h){return u._onMediaKeySystemAccessObtained(l,h)}),m.catch(function(h){O.logger.error('Failed to obtain key-system "'+l+'" access:',h)})},T._onMediaKeySystemAccessObtained=function(l,o){var s=this;O.logger.log('Access for key-system "'+l+'" obtained');var u={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:l};this._mediaKeysList.push(u);var w=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(m){return u.mediaKeys=m,O.logger.log('Media-keys created for key-system "'+l+'"'),s._onMediaKeysCreated(),m});return w.catch(function(m){O.logger.error("Failed to create media-keys:",m)}),w},T._onMediaKeysCreated=function(){var l=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),l._onNewMediaKeySession(o.mediaKeysSession))})},T._onNewMediaKeySession=function(l){var o=this;O.logger.log("New key-system session "+l.sessionId),l.addEventListener("message",function(s){o._onKeySessionMessage(l,s.message)},!1)},T._onKeySessionMessage=function(l,o){O.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(s){O.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),l.update(s)})},T.onMediaEncrypted=function(l){var o=this;if(O.logger.log('Media is encrypted using "'+l.initDataType+'" init data type'),!this.mediaKeysPromise){O.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(w){if(!o._media)return;o._attemptSetMediaKeys(w),o._generateRequestWithPreferredKeySession(l.initDataType,l.initData)};this.mediaKeysPromise.then(s).catch(s)},T._attemptSetMediaKeys=function(l){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var o=this._mediaKeysList[0];if(!o||!o.mediaKeys){O.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}O.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},T._generateRequestWithPreferredKeySession=function(l,o){var s=this,u=this._mediaKeysList[0];if(!u){O.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(u.mediaKeysSessionInitialized){O.logger.warn("Key-Session already initialized but requested again");return}var w=u.mediaKeysSession;if(!w){O.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){O.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}O.logger.log('Generating key-session request for "'+l+'" init data type'),u.mediaKeysSessionInitialized=!0,w.generateRequest(l,o).then(function(){O.logger.debug("Key-session generation succeeded")}).catch(function(m){O.logger.error("Error generating key-session request:",m),s.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},T._createLicenseXhr=function(l,o,s){var u=new XMLHttpRequest;u.responseType="arraybuffer",u.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,u,l,o,s);var w=this._licenseXhrSetup;if(w)try{w.call(this.hls,u,l),w=void 0}catch(m){O.logger.error(m)}try{u.readyState||u.open("POST",l,!0),w&&w.call(this.hls,u,l)}catch(m){throw new Error("issue setting up KeySystem license XHR "+m)}return u},T._onLicenseRequestReadyStageChange=function(l,o,s,u){switch(l.readyState){case 4:if(l.status===200){this._requestLicenseFailureCount=0,O.logger.log("License request succeeded");var w=l.response,m=this._licenseResponseCallback;if(m)try{w=m.call(this.hls,l,o)}catch(L){O.logger.error(L)}u(w)}else{if(O.logger.error("License Request XHR failed ("+o+"). Status: "+l.status+" ("+l.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var h=_-this._requestLicenseFailureCount+1;O.logger.warn("Retrying license request, "+h+" attempts left"),this._requestLicense(s,u)}break}},T._generateLicenseRequestChallenge=function(l,o){switch(l.mediaKeySystemDomain){case U.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+l.mediaKeySystemDomain)},T._requestLicense=function(l,o){O.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){O.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var u=this.getLicenseServerUrl(s.mediaKeySystemDomain),w=this._createLicenseXhr(u,l,o);O.logger.log("Sending license request to URL: "+u);var m=this._generateLicenseRequestChallenge(s,l);w.send(m)}catch(h){O.logger.error("Failure requesting DRM license: "+h),this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},T.onMediaAttached=function(l,o){if(!this._emeEnabled)return;var s=o.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)},T.onMediaDetached=function(){var l=this._media,o=this._mediaKeysList;if(!l)return;l.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(o.map(function(s){if(s.mediaKeysSession)return s.mediaKeysSession.close().catch(function(){})})).then(function(){return l.setMediaKeys(null)}).catch(function(){})},T.onManifestParsed=function(l,o){if(!this._emeEnabled)return;var s=o.levels.map(function(w){return w.audioCodec}).filter(function(w){return!!w}),u=o.levels.map(function(w){return w.videoCodec}).filter(function(w){return!!w});this._attemptKeySystemAccess(U.KeySystems.WIDEVINE,s,u)},R(C,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),C}();G.default=D},"./src/controller/fps-controller.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/events.ts"),k=A("./src/utils/logger.ts"),O=function(){function U(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 F=U.prototype;return F.setStreamController=function(_){this.streamController=_},F.registerListeners=function(){this.hls.on(W.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},F.unregisterListeners=function(){this.hls.off(W.Events.MEDIA_ATTACHING,this.onMediaAttaching)},F.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},F.onMediaAttaching=function(_,v){var S=this.hls.config;if(S.capLevelOnFPSDrop){var D=v.media instanceof self.HTMLVideoElement?v.media:null;this.media=D,D&&typeof D.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),S.fpsDroppedMonitoringPeriod)}},F.checkFPS=function(_,v,S){var D=performance.now();if(v){if(this.lastTime){var C=D-this.lastTime,T=S-this.lastDroppedFrames,E=v-this.lastDecodedFrames,l=1e3*T/C,o=this.hls;if(o.trigger(W.Events.FPS_DROP,{currentDropped:T,currentDecoded:E,totalDroppedFrames:S}),l>0&&T>o.config.fpsDroppedMonitoringThreshold*E){var s=o.currentLevel;k.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),s>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=s)&&(s=s-1,o.trigger(W.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:o.currentLevel}),o.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=S,this.lastDecodedFrames=v}},F.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var v=_.getVideoPlaybackQuality();this.checkFPS(_,v.totalVideoFrames,v.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},U}();G.default=O},"./src/controller/fragment-finders.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"findFragmentByPDT",function(){return O}),A.d(G,"findFragmentByPTS",function(){return U}),A.d(G,"fragmentWithinToleranceTest",function(){return F}),A.d(G,"pdtWithinToleranceTest",function(){return R}),A.d(G,"findFragWithCC",function(){return _});var W=A("./src/polyfills/number.ts"),k=A("./src/utils/binary-search.ts");function O(v,S,D){if(S===null||!Array.isArray(v)||!v.length||!Object(W.isFiniteNumber)(S))return null;var C=v[0].programDateTime;if(S<(C||0))return null;var T=v[v.length-1].endProgramDateTime;if(S>=(T||0))return null;D=D||0;for(var E=0;E<v.length;++E){var l=v[E];if(R(S,D,l))return l}return null}function U(v,S,D,C){D===void 0&&(D=0),C===void 0&&(C=0);var T=null;if(v?T=S[v.sn-S[0].sn+1]||null:D===0&&S[0].start===0&&(T=S[0]),T&&F(D,C,T)===0)return T;var E=k.default.search(S,F.bind(null,D,C));return E||T}function F(v,S,D){v===void 0&&(v=0),S===void 0&&(S=0);var C=Math.min(S,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-C<=v?1:D.start-C>v&&D.start?-1:0}function R(v,S,D){var C=Math.min(S,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,T=D.endProgramDateTime||0;return T-C>v}function _(v,S){return k.default.search(v,function(D){return D.cc<S?1:D.cc>S?-1:0})}},"./src/controller/fragment-tracker.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"FragmentState",function(){return O}),A.d(G,"FragmentTracker",function(){return U});var W=A("./src/events.ts"),k=A("./src/types/loader.ts"),O;(function(_){_.NOT_LOADED="NOT_LOADED",_.BACKTRACKED="BACKTRACKED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(O||(O={}));var U=function(){function _(S){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=S,this._registerListeners()}var v=_.prototype;return v._registerListeners=function(){var D=this.hls;D.on(W.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(W.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(W.Events.FRAG_LOADED,this.onFragLoaded,this)},v._unregisterListeners=function(){var D=this.hls;D.off(W.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(W.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(W.Events.FRAG_LOADED,this.onFragLoaded,this)},v.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},v.getAppendedFrag=function(D,C){if(C===k.PlaylistLevelType.MAIN){var T=this.activeFragment,E=this.activeParts;if(!T)return null;if(E)for(var l=E.length;l--;){var o=E[l],s=o?o.end:T.appendedPTS;if(o.start<=D&&s!==void 0&&D<=s)return l>9&&(this.activeParts=E.slice(l-9)),o}else if(T.start<=D&&T.appendedPTS!==void 0&&D<=T.appendedPTS)return T}return this.getBufferedFrag(D,C)},v.getBufferedFrag=function(D,C){for(var T=this.fragments,E=Object.keys(T),l=E.length;l--;){var o=T[E[l]];if((o==null?void 0:o.body.type)===C&&o.buffered){var s=o.body;if(s.start<=D&&D<=s.end)return s}}return null},v.detectEvictedFragments=function(D,C,T){var E=this;Object.keys(this.fragments).forEach(function(l){var o=E.fragments[l];if(!o)return;if(!o.buffered){o.body.type===T&&E.removeFragment(o.body);return}var s=o.range[D];if(!s)return;s.time.some(function(u){var w=!E.isTimeBuffered(u.startPTS,u.endPTS,C);return w&&E.removeFragment(o.body),w})})},v.detectPartialFragments=function(D){var C=this,T=this.timeRanges,E=D.frag,l=D.part;if(!T||E.sn==="initSegment")return;var o=R(E),s=this.fragments[o];if(!s)return;Object.keys(T).forEach(function(u){var w=E.elementaryStreams[u];if(!w)return;var m=T[u],h=l!==null||w.partial===!0;s.range[u]=C.getBufferedTimes(E,l,h,m)}),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body)},v.fragBuffered=function(D){var C=R(D),T=this.fragments[C];T&&(T.backtrack=T.loaded=null,T.buffered=!0)},v.getBufferedTimes=function(D,C,T,E){for(var l={time:[],partial:T},o=C?C.start:D.start,s=C?C.end:D.end,u=D.minEndPTS||s,w=D.maxStartPTS||o,m=0;m<E.length;m++){var h=E.start(m)-this.bufferPadding,L=E.end(m)+this.bufferPadding;if(w>=h&&u<=L){l.time.push({startPTS:Math.max(o,E.start(m)),endPTS:Math.min(s,E.end(m))});break}else if(o<L&&s>h)l.partial=!0,l.time.push({startPTS:Math.max(o,E.start(m)),endPTS:Math.min(s,E.end(m))});else if(s<=h)break}return l},v.getPartialFragment=function(D){var C=null,T,E,l,o=0,s=this.bufferPadding,u=this.fragments;return Object.keys(u).forEach(function(w){var m=u[w];if(!m)return;F(m)&&(E=m.body.start-s,l=m.body.end+s,D>=E&&D<=l&&(T=Math.min(D-E,l-D),o<=T&&(C=m.body,o=T)))}),C},v.getState=function(D){var C=R(D),T=this.fragments[C];return T?T.buffered?F(T)?O.PARTIAL:O.OK:T.backtrack?O.BACKTRACKED:O.APPENDING:O.NOT_LOADED},v.backtrack=function(D,C){var T=R(D),E=this.fragments[T];if(!E||E.backtrack)return null;var l=E.backtrack=C||E.loaded;return E.loaded=null,l},v.getBacktrackData=function(D){var C=R(D),T=this.fragments[C];if(T){var E,l=T.backtrack;if(l!=null&&(E=l.payload)!==null&&E!==void 0&&E.byteLength)return l;this.removeFragment(D)}return null},v.isTimeBuffered=function(D,C,T){for(var E,l,o=0;o<T.length;o++){if(E=T.start(o)-this.bufferPadding,l=T.end(o)+this.bufferPadding,D>=E&&C<=l)return!0;if(C<=E)return!1}return!1},v.onFragLoaded=function(D,C){var T=C.frag,E=C.part;if(T.sn==="initSegment"||T.bitrateTest||E)return;var l=R(T);this.fragments[l]={body:T,loaded:C,backtrack:null,buffered:!1,range:Object.create(null)}},v.onBufferAppended=function(D,C){var T=this,E=C.frag,l=C.part,o=C.timeRanges;if(E.type===k.PlaylistLevelType.MAIN)if(this.activeFragment=E,l){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(l)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(u){var w=o[u];if(T.detectEvictedFragments(u,w),!l)for(var m=0;m<w.length;m++)E.appendedPTS=Math.max(w.end(m),E.appendedPTS||0)})},v.onFragBuffered=function(D,C){this.detectPartialFragments(C)},v.hasFragment=function(D){var C=R(D);return!!this.fragments[C]},v.removeFragmentsInRange=function(D,C,T){var E=this;Object.keys(this.fragments).forEach(function(l){var o=E.fragments[l];if(!o)return;if(o.buffered){var s=o.body;s.type===T&&s.start<C&&s.end>D&&E.removeFragment(s)}})},v.removeFragment=function(D){var C=R(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[C]},v.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function F(_){var v,S;return _.buffered&&(((v=_.range.video)===null||v===void 0?void 0:v.partial)||((S=_.range.audio)===null||S===void 0?void 0:S.partial))}function R(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"STALL_MINIMUM_DURATION_MS",function(){return F}),A.d(G,"MAX_START_GAP_JUMP",function(){return R}),A.d(G,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),A.d(G,"SKIP_BUFFER_RANGE_START",function(){return v}),A.d(G,"default",function(){return S});var W=A("./src/utils/buffer-helper.ts"),k=A("./src/errors.ts"),O=A("./src/events.ts"),U=A("./src/utils/logger.ts"),F=250,R=2,_=.1,v=.05,S=function(){function D(T,E,l,o){this.config=void 0,this.media=void 0,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=T,this.media=E,this.fragmentTracker=l,this.hls=o}var C=D.prototype;return C.destroy=function(){this.hls=this.fragmentTracker=this.media=null},C.poll=function(E){var l=this.config,o=this.media,s=this.stalled,u=o.currentTime,w=o.seeking,m=this.seeking&&!w,h=!this.seeking&&w;if(this.seeking=w,u!==E){if(this.moved=!0,s!==null){if(this.stallReported){var L=self.performance.now()-s;U.logger.warn("playback not stuck anymore @"+u+", after "+Math.round(L)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((h||m)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!W.BufferHelper.getBuffered(o).length)return;var p=W.BufferHelper.bufferInfo(o,u,0),c=p.len>0,f=p.nextStart||0;if(!c&&!f)return;if(w){var d=p.len>R,a=!f||f-u>R&&!this.fragmentTracker.getPartialFragment(u);if(d||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var b,g=Math.max(f,p.start||0)-u,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=x==null||((b=x.details)===null||b===void 0)?void 0:b.live,N=P?x.details.targetduration*2:R;if(g>0&&g<=N){this._trySkipBufferHole(null);return}}var H=self.performance.now();if(s===null){this.stalled=H;return}var X=H-s;!w&&X>=F&&this._reportStall(p.len);var B=W.BufferHelper.bufferInfo(o,u,l.maxBufferHole);this._tryFixBufferStall(B,X)},C._tryFixBufferStall=function(E,l){var o=this.config,s=this.fragmentTracker,u=this.media,w=u.currentTime,m=s.getPartialFragment(w);if(m){var h=this._trySkipBufferHole(m);if(h)return}E.len>o.maxBufferHole&&l>o.highBufferWatchdogPeriod*1e3&&(U.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},C._reportStall=function(E){var l=this.hls,o=this.media,s=this.stallReported;s||(this.stallReported=!0,U.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+E+")"),l.trigger(O.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:E}))},C._trySkipBufferHole=function(E){for(var l=this.config,o=this.hls,s=this.media,u=s.currentTime,w=0,m=W.BufferHelper.getBuffered(s),h=0;h<m.length;h++){var L=m.start(h);if(u+l.maxBufferHole>=w&&u<L){var p=Math.max(L+v,s.currentTime+_);return U.logger.warn("skipping hole, adjusting currentTime from "+u+" to "+p),this.moved=!0,this.stalled=null,s.currentTime=p,E&&o.trigger(O.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+u+" to "+p,frag:E}),p}w=m.end(h)}return 0},C._tryNudgeBuffer=function(){var E=this.config,l=this.hls,o=this.media,s=o.currentTime,u=(this.nudgeRetry||0)+1;if(this.nudgeRetry=u,u<E.nudgeMaxRetry){var w=s+u*E.nudgeOffset;U.logger.warn("Nudging 'currentTime' from "+s+" to "+w),o.currentTime=w,l.trigger(O.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else U.logger.error("Playhead still not moving while enough data buffered @"+s+" after "+E.nudgeMaxRetry+" nudges"),l.trigger(O.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},D}()},"./src/controller/id3-track-controller.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/events.ts"),k=A("./src/utils/texttrack-utils.ts"),O=A("./src/demux/id3.ts"),U=.25,F=function(){function R(v){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=v,this._registerListeners()}var _=R.prototype;return _.destroy=function(){this._unregisterListeners()},_._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.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),S.on(W.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_._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.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),S.off(W.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},_.onMediaAttached=function(S,D){this.media=D.media},_.onMediaDetaching=function(){if(!this.id3Track)return;Object(k.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},_.getID3Track=function(S){if(!this.media)return;for(var D=0;D<S.length;D++){var C=S[D];if(C.kind==="metadata"&&C.label==="id3")return Object(k.sendAddTrackEvent)(C,this.media),C}return this.media.addTextTrack("metadata","id3")},_.onFragParsingMetadata=function(S,D){if(!this.media)return;var C=D.frag,T=D.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var E=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,l=0;l<T.length;l++){var o=O.getID3Frames(T[l].data);if(o){var s=T[l].pts,u=l<T.length-1?T[l+1].pts:C.end,w=u-s;w<=0&&(u=s+U);for(var m=0;m<o.length;m++){var h=o[m];if(!O.isTimeStampFrame(h)){var L=new E(s,u,"");L.value=h,this.id3Track.addCue(L)}}}}},_.onBufferFlushing=function(S,D){var C=D.startOffset,T=D.endOffset,E=D.type;if(!E||E==="audio"){var l=this.id3Track;l&&Object(k.removeCuesInRange)(l,C,T)}},R}();G.default=F},"./src/controller/latency-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return R});var W=A("./src/errors.ts"),k=A("./src/events.ts"),O=A("./src/utils/logger.ts");function U(_,v){for(var S=0;S<v.length;S++){var D=v[S];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function F(_,v,S){return v&&U(_.prototype,v),S&&U(_,S),_}var R=function(){function _(S){var D=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 D.timeupdate()},this.hls=S,this.config=S.config,this.registerListeners()}var v=_.prototype;return v.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},v.registerListeners=function(){this.hls.on(k.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(k.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(k.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(k.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(k.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){this.hls.off(k.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(k.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(k.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(k.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(k.Events.ERROR,this.onError)},v.onMediaAttached=function(D,C){this.media=C.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},v.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},v.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},v.onLevelUpdated=function(D,C){var T=C.details;this.levelDetails=T,T.advanced&&this.timeupdate(),!T.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},v.onError=function(D,C){if(C.details!==W.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,O.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},v.timeupdate=function(){var D=this.media,C=this.levelDetails;if(!D||!C)return;this.currentTime=D.currentTime;var T=this.computeLatency();if(T===null)return;this._latency=T;var E=this.config,l=E.lowLatencyMode,o=E.maxLiveSyncPlaybackRate;if(!l||o===1)return;var s=this.targetLatency;if(s===null)return;var u=T-s,w=Math.min(this.maxLatency,s+C.targetduration),m=u<w;if(C.live&&m&&u>.05&&this.forwardBufferLength>1){var h=Math.min(2,Math.max(1,o)),L=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20;D.playbackRate=Math.min(h,Math.max(1,L))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)},v.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},v.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},F(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,C=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:C?D.liveMaxLatencyDurationCount*C.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var C=D.holdBack,T=D.partHoldBack,E=D.targetduration,l=this.config,o=l.liveSyncDuration,s=l.liveSyncDurationCount,u=l.lowLatencyMode,w=this.hls.userConfig,m=u&&T||C;(w.liveSyncDuration||w.liveSyncDurationCount||m===0)&&(m=o!==void 0?o:s*E);var h=E,L=1;return m+Math.min(this.stallCount*L,h)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),C=this.targetLatency,T=this.levelDetails;if(D===null||C===null||T===null)return null;var E=T.edge,l=D-C-this.edgeStalled,o=E-T.totalduration,s=E-(this.config.lowLatencyMode&&T.partTarget||T.targetduration);return Math.min(Math.max(o,l),s)}},{key:"drift",get:function(){var D=this.levelDetails;return D===null?1:D.drift}},{key:"edgeStalled",get:function(){var D=this.levelDetails;if(D===null)return 0;var C=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-C,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,C=this.levelDetails;if(!D||!C)return 0;var T=D.buffered.length;return T?D.buffered.end(T-1):C.edge-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return l});var W=A("./src/types/level.ts"),k=A("./src/events.ts"),O=A("./src/errors.ts"),U=A("./src/utils/codecs.ts"),F=A("./src/controller/level-helper.ts"),R=A("./src/controller/base-playlist-controller.ts"),_=A("./src/types/loader.ts");function v(){return v=Object.assign||function(o){for(var s=1;s<arguments.length;s++){var u=arguments[s];for(var w in u)Object.prototype.hasOwnProperty.call(u,w)&&(o[w]=u[w])}return o},v.apply(this,arguments)}function S(o,s){for(var u=0;u<s.length;u++){var w=s[u];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(o,w.key,w)}}function D(o,s,u){return s&&S(o.prototype,s),u&&S(o,u),o}function C(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,T(o,s)}function T(o,s){return T=Object.setPrototypeOf||function(w,m){return w.__proto__=m,w},T(o,s)}var E=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),l=function(o){C(s,o);function s(w){var m;return m=o.call(this,w,"[level-controller]")||this,m._levels=[],m._firstLevel=-1,m._startLevel=void 0,m.currentLevelIndex=-1,m.manualLevelIndex=-1,m.onParsedComplete=void 0,m._registerListeners(),m}var u=s.prototype;return u._registerListeners=function(){var m=this.hls;m.on(k.Events.MANIFEST_LOADED,this.onManifestLoaded,this),m.on(k.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.on(k.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.on(k.Events.FRAG_LOADED,this.onFragLoaded,this),m.on(k.Events.ERROR,this.onError,this)},u._unregisterListeners=function(){var m=this.hls;m.off(k.Events.MANIFEST_LOADED,this.onManifestLoaded,this),m.off(k.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.off(k.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.off(k.Events.FRAG_LOADED,this.onFragLoaded,this),m.off(k.Events.ERROR,this.onError,this)},u.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},u.startLoad=function(){var m=this._levels;m.forEach(function(h){h.loadError=0}),o.prototype.startLoad.call(this)},u.onManifestLoaded=function(m,h){var L=[],p=[],c=[],f,d={},a,b=!1,g=!1,x=!1;if(h.levels.forEach(function(X){var B=X.attrs;b=b||!!(X.width&&X.height),g=g||!!X.videoCodec,x=x||!!X.audioCodec,E&&X.audioCodec&&X.audioCodec.indexOf("mp4a.40.34")!==-1&&(X.audioCodec=void 0);var I=X.bitrate+"-"+X.attrs.RESOLUTION+"-"+X.attrs.CODECS;a=d[I],a?a.url.push(X.url):(a=new W.Level(X),d[I]=a,L.push(a)),B&&(B.AUDIO&&Object(F.addGroupId)(a,"audio",B.AUDIO),B.SUBTITLES&&Object(F.addGroupId)(a,"text",B.SUBTITLES))}),(b||g)&&x&&(L=L.filter(function(X){var B=X.videoCodec,I=X.width,Y=X.height;return!!B||!!(I&&Y)})),L=L.filter(function(X){var B=X.audioCodec,I=X.videoCodec;return(!B||Object(U.isCodecSupportedInMp4)(B,"audio"))&&(!I||Object(U.isCodecSupportedInMp4)(I,"video"))}),h.audioTracks&&(p=h.audioTracks.filter(function(X){return!X.audioCodec||Object(U.isCodecSupportedInMp4)(X.audioCodec,"audio")}),Object(F.assignTrackIdsByGroup)(p)),h.subtitles&&(c=h.subtitles,Object(F.assignTrackIdsByGroup)(c)),L.length>0){f=L[0].bitrate,L.sort(function(X,B){return X.bitrate-B.bitrate}),this._levels=L;for(var P=0;P<L.length;P++)if(L[P].bitrate===f){this._firstLevel=P,this.log("manifest loaded, "+L.length+" level(s) found, first bitrate: "+f);break}var N=x&&!g,H={levels:L,audioTracks:p,subtitleTracks:c,firstLevel:this._firstLevel,stats:h.stats,audio:x,video:g,altAudio:!N&&p.some(function(X){return!!X.url})};this.hls.trigger(k.Events.MANIFEST_PARSED,H),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(k.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:h.url,reason:"no level with compatible codecs found in manifest"})},u.onError=function(m,h){if(o.prototype.onError.call(this,m,h),h.fatal)return;var L=h.context,p=this._levels[this.currentLevelIndex];if(L&&(L.type===_.PlaylistContextType.AUDIO_TRACK&&p.audioGroupIds&&L.groupId===p.audioGroupIds[p.urlId]||L.type===_.PlaylistContextType.SUBTITLE_TRACK&&p.textGroupIds&&L.groupId===p.textGroupIds[p.urlId])){this.redundantFailover(this.currentLevelIndex);return}var c=!1,f=!0,d;switch(h.details){case O.ErrorDetails.FRAG_LOAD_ERROR:case O.ErrorDetails.FRAG_LOAD_TIMEOUT:case O.ErrorDetails.KEY_LOAD_ERROR:case O.ErrorDetails.KEY_LOAD_TIMEOUT:if(h.frag){var a=this._levels[h.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(d=h.frag.level)):d=h.frag.level}break;case O.ErrorDetails.LEVEL_LOAD_ERROR:case O.ErrorDetails.LEVEL_LOAD_TIMEOUT:L&&(L.deliveryDirectives&&(f=!1),d=L.level),c=!0;break;case O.ErrorDetails.REMUX_ALLOC_ERROR:d=h.level,c=!0;break}d!==void 0&&this.recoverLevel(h,d,c,f)},u.recoverLevel=function(m,h,L,p){var c=m.details,f=this._levels[h];if(f.loadError++,L){var d=this.retryLoadingOrFail(m);if(d)m.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(p){var a=f.url.length;if(a>1&&f.loadError<a)m.levelRetry=!0,this.redundantFailover(h);else if(this.manualLevelIndex===-1){var b=h===0?this._levels.length-1:h-1;this.currentLevelIndex!==b&&this._levels[b].loadError===0&&(this.warn(c+": switch to "+b),m.levelRetry=!0,this.hls.nextAutoLevel=b)}}},u.redundantFailover=function(m){var h=this._levels[m],L=h.url.length;if(L>1){var p=(h.urlId+1)%L;this.warn("Switching to redundant URL-id "+p),this._levels.forEach(function(c){c.urlId=p}),this.level=m}},u.onFragLoaded=function(m,h){var L=h.frag;if(L!==void 0&&L.type===_.PlaylistLevelType.MAIN){var p=this._levels[L.level];p!==void 0&&(p.fragmentError=0,p.loadError=0)}},u.onLevelLoaded=function(m,h){var L,p=h.level,c=h.details,f=this._levels[p];if(!f){var d;this.warn("Invalid level index "+p),(d=h.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(c.deltaUpdateFailed=!0);return}p===this.currentLevelIndex?(f.fragmentError===0&&(f.loadError=0,this.retryCount=0),this.playlistLoaded(p,h,f.details)):(L=h.deliveryDirectives)!==null&&L!==void 0&&L.skip&&(c.deltaUpdateFailed=!0)},u.onAudioTrackSwitched=function(m,h){var L=this.hls.levels[this.currentLevelIndex];if(!L)return;if(L.audioGroupIds){for(var p=-1,c=this.hls.audioTracks[h.id].groupId,f=0;f<L.audioGroupIds.length;f++)if(L.audioGroupIds[f]===c){p=f;break}p!==L.urlId&&(L.urlId=p,this.startLoad())}},u.loadPlaylist=function(m){var h=this.currentLevelIndex,L=this._levels[h];if(this.canLoad&&L&&L.url.length>0){var p=L.urlId,c=L.url[p];if(m)try{c=m.addDirectives(c)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("Attempt loading level index "+h+(m?" at sn "+m.msn+" part "+m.part:"")+" with URL-id "+p+" "+c),this.clearTimer(),this.hls.trigger(k.Events.LEVEL_LOADING,{url:c,level:h,id:p,deliveryDirectives:m||null})}},u.removeLevel=function(m,h){var L=function(f,d){return d!==h},p=this._levels.filter(function(c,f){return f!==m?!0:c.url.length>1&&h!==void 0?(c.url=c.url.filter(L),c.audioGroupIds&&(c.audioGroupIds=c.audioGroupIds.filter(L)),c.textGroupIds&&(c.textGroupIds=c.textGroupIds.filter(L)),c.urlId=0,!0):!1}).map(function(c,f){var d=c.details;return d!=null&&d.fragments&&d.fragments.forEach(function(a){a.level=f}),c});this._levels=p,this.hls.trigger(k.Events.LEVELS_UPDATED,{levels:p})},D(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(m){var h,L=this._levels;if(L.length===0)return;if(this.currentLevelIndex===m&&(h=L[m])!==null&&h!==void 0&&h.details)return;if(m<0||m>=L.length){var p=m<0;if(this.hls.trigger(k.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.LEVEL_SWITCH_ERROR,level:m,fatal:p,reason:"invalid level idx"}),p)return;m=Math.min(m,L.length-1)}this.clearTimer();var c=this.currentLevelIndex,f=L[c],d=L[m];this.log("switching to level "+m+" from "+c),this.currentLevelIndex=m;var a=v({},d,{level:m,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete a._urlId,this.hls.trigger(k.Events.LEVEL_SWITCHING,a);var b=d.details;if(!b||b.live){var g=this.switchParams(d.uri,f==null?void 0:f.details);this.loadPlaylist(g)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(m){this.manualLevelIndex=m,this._startLevel===void 0&&(this._startLevel=m),m!==-1&&(this.level=m)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(m){this._firstLevel=m}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var m=this.hls.config.startLevel;return m!==void 0?m:this._firstLevel}else return this._startLevel},set:function(m){this._startLevel=m}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(m){this.level=m,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=m)}}]),s}(R.default)},"./src/controller/level-helper.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"addGroupId",function(){return O}),A.d(G,"assignTrackIdsByGroup",function(){return U}),A.d(G,"updatePTS",function(){return F}),A.d(G,"updateFragPTSDTS",function(){return _}),A.d(G,"mergeDetails",function(){return v}),A.d(G,"mapPartIntersection",function(){return S}),A.d(G,"mapFragmentIntersection",function(){return D}),A.d(G,"adjustSliding",function(){return C}),A.d(G,"addSliding",function(){return T}),A.d(G,"computeReloadInterval",function(){return E}),A.d(G,"getFragmentWithSN",function(){return l}),A.d(G,"getPartWith",function(){return o});var W=A("./src/polyfills/number.ts"),k=A("./src/utils/logger.ts");function O(s,u,w){switch(u){case"audio":s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds.push(w);break;case"text":s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds.push(w);break}}function U(s){var u={};s.forEach(function(w){var m=w.groupId||"";w.id=u[m]=u[m]||0,u[m]++})}function F(s,u,w){var m=s[u],h=s[w];R(m,h)}function R(s,u){var w=u.startPTS;if(Object(W.isFiniteNumber)(w)){var m=0,h;u.sn>s.sn?(m=w-s.start,h=s):(m=s.start-w,h=u),h.duration!==m&&(h.duration=m)}else if(u.sn>s.sn){var L=s.cc===u.cc;L&&s.minEndPTS?u.start=s.start+(s.minEndPTS-s.start):u.start=s.start+s.duration}else u.start=Math.max(s.start-u.duration,0)}function _(s,u,w,m,h,L){var p=m-w;p<=0&&(k.logger.warn("Fragment should have a positive duration",u),m=w+u.duration,L=h+u.duration);var c=w,f=m,d=u.startPTS,a=u.endPTS;if(Object(W.isFiniteNumber)(d)){var b=Math.abs(d-w);Object(W.isFiniteNumber)(u.deltaPTS)?u.deltaPTS=Math.max(b,u.deltaPTS):u.deltaPTS=b,c=Math.max(w,d),w=Math.min(w,d),h=Math.min(h,u.startDTS),f=Math.min(m,a),m=Math.max(m,a),L=Math.max(L,u.endDTS)}u.duration=m-w;var g=w-u.start;u.appendedPTS=m,u.start=u.startPTS=w,u.maxStartPTS=c,u.startDTS=h,u.endPTS=m,u.minEndPTS=f,u.endDTS=L;var x=u.sn;if(!s||x<s.startSN||x>s.endSN)return 0;var P,N=x-s.startSN,H=s.fragments;for(H[N]=u,P=N;P>0;P--)R(H[P],H[P-1]);for(P=N;P<H.length-1;P++)R(H[P],H[P+1]);return s.fragmentHint&&R(H[H.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,g}function v(s,u){for(var w=null,m=s.fragments,h=m.length-1;h>=0;h--){var L=m[h].initSegment;if(L){w=L;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var p=0,c;if(D(s,u,function(P,N){P.relurl&&(p=P.cc-N.cc),Object(W.isFiniteNumber)(P.startPTS)&&Object(W.isFiniteNumber)(P.endPTS)&&(N.start=N.startPTS=P.startPTS,N.startDTS=P.startDTS,N.appendedPTS=P.appendedPTS,N.maxStartPTS=P.maxStartPTS,N.endPTS=P.endPTS,N.endDTS=P.endDTS,N.minEndPTS=P.minEndPTS,N.duration=P.endPTS-P.startPTS,N.duration&&(c=N),u.PTSKnown=u.alignedSliding=!0),N.elementaryStreams=P.elementaryStreams,N.loader=P.loader,N.stats=P.stats,N.urlId=P.urlId,P.initSegment&&(N.initSegment=P.initSegment,w=P.initSegment)}),w){var f=u.fragmentHint?u.fragments.concat(u.fragmentHint):u.fragments;f.forEach(function(P){var N;(!P.initSegment||P.initSegment.relurl===((N=w)===null||N===void 0?void 0:N.relurl))&&(P.initSegment=w)})}if(u.skippedSegments&&(u.deltaUpdateFailed=u.fragments.some(function(P){return!P}),u.deltaUpdateFailed)){k.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=u.skippedSegments;d--;)u.fragments.shift();u.startSN=u.fragments[0].sn,u.startCC=u.fragments[0].cc}var a=u.fragments;if(p){k.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<a.length;b++)a[b].cc+=p}u.skippedSegments&&(u.startCC=u.fragments[0].cc),S(s.partList,u.partList,function(P,N){N.elementaryStreams=P.elementaryStreams,N.stats=P.stats}),c?_(u,c,c.startPTS,c.endPTS,c.startDTS,c.endDTS):C(s,u),a.length&&(u.totalduration=u.edge-a[0].start),u.driftStartTime=s.driftStartTime,u.driftStart=s.driftStart;var g=u.advancedDateTime;if(u.advanced&&g){var x=u.edge;u.driftStart||(u.driftStartTime=g,u.driftStart=x),u.driftEndTime=g,u.driftEnd=x}else u.driftEndTime=s.driftEndTime,u.driftEnd=s.driftEnd,u.advancedDateTime=s.advancedDateTime}function S(s,u,w){if(s&&u)for(var m=0,h=0,L=s.length;h<=L;h++){var p=s[h],c=u[h+m];p&&c&&p.index===c.index&&p.fragment.sn===c.fragment.sn?w(p,c):m--}}function D(s,u,w){for(var m=u.skippedSegments,h=Math.max(s.startSN,u.startSN)-u.startSN,L=(s.fragmentHint?1:0)+(m?u.endSN:Math.min(s.endSN,u.endSN))-u.startSN,p=u.startSN-s.startSN,c=u.fragmentHint?u.fragments.concat(u.fragmentHint):u.fragments,f=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,d=h;d<=L;d++){var a=f[p+d],b=c[d];m&&!b&&d<m&&(b=u.fragments[d]=a),a&&b&&w(a,b)}}function C(s,u){var w=u.startSN+u.skippedSegments-s.startSN,m=s.fragments;if(w<0||w>=m.length)return;T(u,m[w].start)}function T(s,u){if(u){for(var w=s.fragments,m=s.skippedSegments;m<w.length;m++)w[m].start+=u;s.fragmentHint&&(s.fragmentHint.start+=u)}}function E(s,u){var w=1e3*s.levelTargetDuration,m=w/2,h=s.age,L=h>0&&h<w*3,p=u.loading.end-u.loading.start,c,f=s.availabilityDelay;if(s.updated===!1)if(L){var d=333*s.misses;c=Math.max(Math.min(m,p*2),d),s.availabilityDelay=(s.availabilityDelay||0)+c}else c=m;else L?(f=Math.min(f||w/2,h),s.availabilityDelay=f,c=f+w-h):c=w-p;return Math.round(c)}function l(s,u,w){if(!s||!s.details)return null;var m=s.details,h=m.fragments[u-m.startSN];return h||(h=m.fragmentHint,h&&h.sn===u?h:u<m.startSN&&w&&w.sn===u?w:null)}function o(s,u,w){if(!s||!s.details)return null;var m=s.details.partList;if(m)for(var h=m.length;h--;){var L=m[h];if(L.index===w&&L.fragment.sn===u)return L}return null}},"./src/controller/stream-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return m});var W=A("./src/polyfills/number.ts"),k=A("./src/controller/base-stream-controller.ts"),O=A("./src/is-supported.ts"),U=A("./src/events.ts"),F=A("./src/utils/buffer-helper.ts"),R=A("./src/controller/fragment-tracker.ts"),_=A("./src/types/loader.ts"),v=A("./src/loader/fragment.ts"),S=A("./src/demux/transmuxer-interface.ts"),D=A("./src/types/transmuxer.ts"),C=A("./src/controller/gap-controller.ts"),T=A("./src/errors.ts"),E=A("./src/utils/logger.ts");function l(h,L){for(var p=0;p<L.length;p++){var c=L[p];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(h,c.key,c)}}function o(h,L,p){return L&&l(h.prototype,L),p&&l(h,p),h}function s(h,L){h.prototype=Object.create(L.prototype),h.prototype.constructor=h,u(h,L)}function u(h,L){return u=Object.setPrototypeOf||function(c,f){return c.__proto__=f,c},u(h,L)}var w=100,m=function(h){s(L,h);function L(c,f){var d;return d=h.call(this,c,f,"[stream-controller]")||this,d.audioCodecSwap=!1,d.gapController=null,d.level=-1,d._forceStartLoad=!1,d.altAudio=!1,d.audioOnly=!1,d.fragPlaying=null,d.onvplaying=null,d.onvseeked=null,d.fragLastKbps=0,d.stalled=!1,d.couldBacktrack=!1,d.audioCodecSwitch=!1,d.videoBuffer=null,d._registerListeners(),d}var p=L.prototype;return p._registerListeners=function(){var f=this.hls;f.on(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.on(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(U.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(U.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(U.Events.LEVEL_LOADING,this.onLevelLoading,this),f.on(U.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(U.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.on(U.Events.ERROR,this.onError,this),f.on(U.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.on(U.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.on(U.Events.BUFFER_CREATED,this.onBufferCreated,this),f.on(U.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.on(U.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.on(U.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p._unregisterListeners=function(){var f=this.hls;f.off(U.Events.MEDIA_ATTACHED,this.onMediaAttached,this),f.off(U.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.off(U.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.off(U.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(U.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(U.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),f.off(U.Events.ERROR,this.onError,this),f.off(U.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),f.off(U.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.off(U.Events.BUFFER_CREATED,this.onBufferCreated,this),f.off(U.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),f.off(U.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),f.off(U.Events.FRAG_BUFFERED,this.onFragBuffered,this)},p.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},p.startLoad=function(f){if(this.levels){var d=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(w),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var b=a.startLevel;b===-1&&(a.config.testBandwidth?(b=0,this.bitrateTest=!0):b=a.nextAutoLevel),this.level=a.nextLoadLevel=b,this.loadedmetadata=!1}d>0&&f===-1&&(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),f=d),this.state=k.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=f,this.tick()}else this._forceStartLoad=!0,this.state=k.State.STOPPED},p.stopLoad=function(){this._forceStartLoad=!1,h.prototype.stopLoad.call(this)},p.doTick=function(){switch(this.state){case k.State.IDLE:this.doTickIdle();break;case k.State.WAITING_LEVEL:{var f,d=this.levels,a=this.level,b=d==null||((f=d[a])===null||f===void 0)?void 0:f.details;if(b&&(!b.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(b))break;this.state=k.State.IDLE;break}break}case k.State.FRAG_LOADING_WAITING_RETRY:{var g,x=self.performance.now(),P=this.retryDate;(!P||x>=P||(g=this.media)!==null&&g!==void 0&&g.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=k.State.IDLE)}break;default:break}this.onTickEnd()},p.onTickEnd=function(){h.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},p.doTickIdle=function(){var f,d,a=this.hls,b=this.levelLastLoaded,g=this.levels,x=this.media,P=a.config,N=a.nextLoadLevel;if(b===null||!x&&(this.startFragRequested||!P.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!g||!g[N])return;var H=g[N];this.level=a.nextLoadLevel=N;var X=H.details;if(!X||this.state===k.State.WAITING_LEVEL||X.live&&this.levelLastLoaded!==N){this.state=k.State.WAITING_LEVEL;return}var B=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:x,_.PlaylistLevelType.MAIN);if(B===null)return;var I=B.len,Y=this.getMaxBufferLength(H.maxBitrate);if(I>=Y)return;if(this._streamEnded(B,X)){var te={};this.altAudio&&(te.type="video"),this.hls.trigger(U.Events.BUFFER_EOS,te),this.state=k.State.ENDED;return}var se=B.end,de=this.getNextFragment(se,X);if(this.couldBacktrack&&!this.fragPrevious&&de&&de.sn!=="initSegment"){var Se=de.sn-X.startSN;Se>1&&(de=X.fragments[Se-1],this.fragmentTracker.removeFragment(de))}if(de&&this.fragmentTracker.getState(de)===R.FragmentState.OK&&this.nextLoadPosition>se){var ge=this.audioOnly&&!this.altAudio?v.ElementaryStreamTypes.AUDIO:v.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(x,ge,_.PlaylistLevelType.MAIN),de=this.getNextFragment(this.nextLoadPosition,X)}if(!de)return;de.initSegment&&!de.initSegment.data&&!this.bitrateTest&&(de=de.initSegment),((f=de.decryptdata)===null||f===void 0?void 0:f.keyFormat)==="identity"&&!((d=de.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(de,X):this.loadFragment(de,X,se)},p.loadFragment=function(f,d,a){var b,g=this.fragmentTracker.getState(f);if(this.fragCurrent=f,g===R.FragmentState.BACKTRACKED){var x=this.fragmentTracker.getBacktrackData(f);if(x){this._handleFragmentLoadProgress(x),this._handleFragmentLoadComplete(x);return}else g=R.FragmentState.NOT_LOADED}g===R.FragmentState.NOT_LOADED||g===R.FragmentState.PARTIAL?f.sn==="initSegment"?this._loadInitSegment(f):this.bitrateTest?(f.bitrateTest=!0,this.log("Fragment "+f.sn+" of level "+f.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(f)):(this.startFragRequested=!0,h.prototype.loadFragment.call(this,f,d,a)):g===R.FragmentState.APPENDING?this.reduceMaxBufferLength(f.duration)&&this.fragmentTracker.removeFragment(f):((b=this.media)===null||b===void 0?void 0:b.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},p.getAppendedFrag=function(f){var d=this.fragmentTracker.getAppendedFrag(f,_.PlaylistLevelType.MAIN);return d&&"fragment"in d?d.fragment:d},p.getBufferedFrag=function(f){return this.fragmentTracker.getBufferedFrag(f,_.PlaylistLevelType.MAIN)},p.followingBufferedFrag=function(f){return f?this.getBufferedFrag(f.end+.5):null},p.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},p.nextLevelSwitch=function(){var f=this.levels,d=this.media;if(d!=null&&d.readyState){var a,b=this.getAppendedFrag(d.currentTime);if(b&&b.start>1&&this.flushMainBuffer(0,b.start-1),!d.paused&&f){var g=this.hls.nextLoadLevel,x=f[g],P=this.fragLastKbps;P&&this.fragCurrent?a=this.fragCurrent.duration*x.maxBitrate/(1e3*P)+1:a=0}else a=0;var N=this.getBufferedFrag(d.currentTime+a);if(N){var H=this.followingBufferedFrag(N);if(H){this.abortCurrentFrag();var X=H.maxStartPTS?H.maxStartPTS:H.start,B=H.duration,I=Math.max(N.end,X+Math.min(Math.max(B-this.config.maxFragLookUpTolerance,B*.5),B*.75));this.flushMainBuffer(I,Number.POSITIVE_INFINITY)}}}},p.abortCurrentFrag=function(){var f=this.fragCurrent;this.fragCurrent=null,f!=null&&f.loader&&f.loader.abort(),this.state===k.State.KEY_LOADING&&(this.state=k.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},p.flushMainBuffer=function(f,d){h.prototype.flushMainBuffer.call(this,f,d,this.altAudio?"video":null)},p.onMediaAttached=function(f,d){h.prototype.onMediaAttached.call(this,f,d);var a=d.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),a.addEventListener("playing",this.onvplaying),a.addEventListener("seeked",this.onvseeked),this.gapController=new C.default(this.config,a,this.fragmentTracker,this.hls)},p.onMediaDetaching=function(){var f=this.media;f&&(f.removeEventListener("playing",this.onvplaying),f.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),h.prototype.onMediaDetaching.call(this)},p.onMediaPlaying=function(){this.tick()},p.onMediaSeeked=function(){var f=this.media,d=f?f.currentTime:null;Object(W.isFiniteNumber)(d)&&this.log("Media seeked to "+d.toFixed(3)),this.tick()},p.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(U.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},p.onManifestParsed=function(f,d){var a=!1,b=!1,g;d.levels.forEach(function(x){g=x.audioCodec,g&&(g.indexOf("mp4a.40.2")!==-1&&(a=!0),g.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=a&&b&&!Object(O.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=d.levels,this.startFragRequested=!1},p.onLevelLoading=function(f,d){var a=this.levels;if(!a||this.state!==k.State.IDLE)return;var b=a[d.level];(!b.details||b.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(b.details))&&(this.state=k.State.WAITING_LEVEL)},p.onLevelLoaded=function(f,d){var a,b=this.levels,g=d.level,x=d.details,P=x.totalduration;if(!b){this.warn("Levels were reset while loading level "+g);return}this.log("Level "+g+" loaded ["+x.startSN+","+x.endSN+"], cc ["+x.startCC+", "+x.endCC+"] duration:"+P);var N=this.fragCurrent;N&&(this.state===k.State.FRAG_LOADING||this.state===k.State.FRAG_LOADING_WAITING_RETRY)&&(N.level!==d.level&&N.loader&&(this.state=k.State.IDLE,N.loader.abort()));var H=b[g],X=0;if(x.live||(a=H.details)!==null&&a!==void 0&&a.live){if(x.fragments[0]||(x.deltaUpdateFailed=!0),x.deltaUpdateFailed)return;X=this.alignPlaylists(x,H.details)}if(H.details=x,this.levelLastLoaded=g,this.hls.trigger(U.Events.LEVEL_UPDATED,{details:x,level:g}),this.state===k.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(x))return;this.state=k.State.IDLE}this.startFragRequested?x.live&&this.synchronizeToLiveEdge(x):this.setStartPosition(x,X),this.tick()},p._handleFragmentLoadProgress=function(f){var d,a=f.frag,b=f.part,g=f.payload,x=this.levels;if(!x){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var P=x[a.level],N=P.details;if(!N){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var H=P.videoCodec,X=N.PTSKnown||!N.live,B=(d=a.initSegment)===null||d===void 0?void 0:d.data,I=this._getAudioCodec(P),Y=this.transmuxer=this.transmuxer||new S.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),te=b?b.index:-1,se=te!==-1,de=new D.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,g.byteLength,te,se),Se=this.initPTS[a.cc];Y.push(g,B,I,H,a,b,N.totalduration,X,de,Se)},p.onAudioTrackSwitching=function(f,d){var a=this.altAudio,b=!!d.url,g=d.id;if(!b){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var x=this.fragCurrent;x!=null&&x.loader&&(this.log("Switching to main audio track, cancel main fragment load"),x.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;a&&P.trigger(U.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(U.Events.AUDIO_TRACK_SWITCHED,{id:g})}},p.onAudioTrackSwitched=function(f,d){var a=d.id,b=!!this.hls.audioTracks[a].url;if(b){var g=this.videoBuffer;g&&this.mediaBuffer!==g&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=g)}this.altAudio=b,this.tick()},p.onBufferCreated=function(f,d){var a=d.tracks,b,g,x=!1;for(var P in a){var N=a[P];if(N.id==="main"){if(g=P,b=N,P==="video"){var H=a[P];H&&(this.videoBuffer=H.buffer)}}else x=!0}x&&b?(this.log("Alternate track found, use "+g+".buffered to schedule main fragment loading"),this.mediaBuffer=b.buffer):this.mediaBuffer=this.media},p.onFragBuffered=function(f,d){var a=d.frag,b=d.part;if(a&&a.type!==_.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(b?" p: "+b.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===k.State.PARSED&&(this.state=k.State.IDLE);return}var g=b?b.stats:a.stats;this.fragLastKbps=Math.round(8*g.total/(g.buffering.end-g.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,b)},p.onError=function(f,d){switch(d.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:case T.ErrorDetails.KEY_LOAD_ERROR:case T.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,d);break;case T.ErrorDetails.LEVEL_LOAD_ERROR:case T.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==k.State.ERROR&&(d.fatal?(this.warn(""+d.details),this.state=k.State.ERROR):!d.levelRetry&&this.state===k.State.WAITING_LEVEL&&(this.state=k.State.IDLE));break;case T.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="main"&&(this.state===k.State.PARSING||this.state===k.State.PARSED)){var a=!0,b=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);b&&b.len>.5&&(a=!this.reduceMaxBufferLength(b.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},p.checkBuffer=function(){var f=this.media,d=this.gapController;if(!f||!d||!f.readyState)return;var a=F.BufferHelper.getBuffered(f);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):d.poll(this.lastCurrentTime),this.lastCurrentTime=f.currentTime},p.onFragLoadEmergencyAborted=function(){this.state=k.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},p.onBufferFlushed=function(f,d){var a=d.type;if(a!==v.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var b=(a===v.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(b,a,_.PlaylistLevelType.MAIN)}},p.onLevelsUpdated=function(f,d){this.levels=d.levels},p.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},p.seekToStartPos=function(){var f=this.media,d=f.currentTime,a=this.startPosition;if(a>=0&&d<a){if(f.seeking){E.logger.log("could not seek to "+a+", already seeking at "+d);return}var b=F.BufferHelper.getBuffered(f),g=b.length?b.start(0):0,x=g-a;x>0&&(x<this.config.maxBufferHole||x<this.config.maxFragLookUpTolerance)&&(E.logger.log("adjusting start position by "+x+" to match buffer start"),a+=x,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+d),f.currentTime=a}},p._getAudioCodec=function(f){var d=this.config.defaultAudioCodec||f.audioCodec;return this.audioCodecSwap&&d&&(this.log("Swapping audio codec"),d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5"),d},p._loadBitrateTestFrag=function(f){var d=this;this._doFragLoad(f).then(function(a){var b=d.hls;if(!a||b.nextLoadLevel||d.fragContextChanged(f))return;d.fragLoadError=0,d.state=k.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var g=f.stats;g.parsing.start=g.parsing.end=g.buffering.start=g.buffering.end=self.performance.now(),b.trigger(U.Events.FRAG_LOADED,a)})},p._handleTransmuxComplete=function(f){var d,a="main",b=this.hls,g=f.remuxResult,x=f.chunkMeta,P=this.getCurrentContext(x);if(!P){this.warn("The loading context changed while buffering fragment "+x.sn+" of level "+x.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(x.level);return}var N=P.frag,H=P.part,X=P.level,B=g.video,I=g.text,Y=g.id3,te=g.initSegment,se=this.altAudio?void 0:g.audio;if(this.fragContextChanged(N))return;if(this.state=k.State.PARSING,te){te.tracks&&(this._bufferInitSegment(X,te.tracks,N,x),b.trigger(U.Events.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:a,tracks:te.tracks}));var de=te.initPTS,Se=te.timescale;Object(W.isFiniteNumber)(de)&&(this.initPTS[N.cc]=de,b.trigger(U.Events.INIT_PTS_FOUND,{frag:N,id:a,initPTS:de,timescale:Se}))}if(B&&g.independent!==!1){if(X.details){var ge=B.startPTS,pe=B.endPTS,he=B.startDTS,me=B.endDTS;if(H)H.elementaryStreams[B.type]={startPTS:ge,endPTS:pe,startDTS:he,endDTS:me};else if(B.firstKeyFrame&&B.independent&&(this.couldBacktrack=!0),B.dropped&&B.independent){var ae=this.getLoadPosition()+this.config.maxBufferHole;if(ae<ge){this.backtrack(N);return}N.setElementaryStreamInfo(B.type,N.start,pe,N.start,me,!0)}N.setElementaryStreamInfo(B.type,ge,pe,he,me),this.bufferFragmentData(B,N,H,x)}}else if(g.independent===!1){this.backtrack(N);return}if(se){var ue=se.startPTS,xe=se.endPTS,Fe=se.startDTS,Re=se.endDTS;H&&(H.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:ue,endPTS:xe,startDTS:Fe,endDTS:Re}),N.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,ue,xe,Fe,Re),this.bufferFragmentData(se,N,H,x)}if(Y!=null&&(d=Y.samples)!==null&&d!==void 0&&d.length){var Ie={frag:N,id:a,samples:Y.samples};b.trigger(U.Events.FRAG_PARSING_METADATA,Ie)}if(I){var Ke={frag:N,id:a,samples:I.samples};b.trigger(U.Events.FRAG_PARSING_USERDATA,Ke)}},p._bufferInitSegment=function(f,d,a,b){var g=this;if(this.state!==k.State.PARSING)return;this.audioOnly=!!d.audio&&!d.video,this.altAudio&&!this.audioOnly&&delete d.audio;var x=d.audio,P=d.video,N=d.audiovideo;if(x){var H=f.audioCodec,X=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(H&&(H.indexOf("mp4a.40.5")!==-1?H="mp4a.40.2":H="mp4a.40.5"),x.metadata.channelCount!==1&&X.indexOf("firefox")===-1&&(H="mp4a.40.5")),X.indexOf("android")!==-1&&x.container!=="audio/mpeg"&&(H="mp4a.40.2",this.log("Android: force audio codec to "+H)),f.audioCodec&&f.audioCodec!==H&&this.log('Swapping manifest audio codec "'+f.audioCodec+'" for "'+H+'"'),x.levelCodec=H,x.id="main",this.log("Init audio buffer, container:"+x.container+", codecs[selected/level/parsed]=["+(H||"")+"/"+(f.audioCodec||"")+"/"+x.codec+"]")}P&&(P.levelCodec=f.videoCodec,P.id="main",this.log("Init video buffer, container:"+P.container+", codecs[level/parsed]=["+(f.videoCodec||"")+"/"+P.codec+"]")),N&&this.log("Init audiovideo buffer, container:"+N.container+", codecs[level/parsed]=["+(f.attrs.CODECS||"")+"/"+N.codec+"]"),this.hls.trigger(U.Events.BUFFER_CODECS,d),Object.keys(d).forEach(function(B){var I=d[B],Y=I.initSegment;Y!=null&&Y.byteLength&&g.hls.trigger(U.Events.BUFFER_APPENDING,{type:B,data:Y,frag:a,part:null,chunkMeta:b,parent:a.type})}),this.tick()},p.backtrack=function(f){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(f);var d=this.fragmentTracker.backtrack(f);this.fragPrevious=null,this.nextLoadPosition=f.start,d?this.resetFragmentLoading(f):this.state=k.State.BACKTRACKING},p.checkFragmentChanged=function(){var f=this.media,d=null;if(f&&f.readyState>1&&f.seeking===!1){var a=f.currentTime;if(F.BufferHelper.isBuffered(f,a)?d=this.getAppendedFrag(a):F.BufferHelper.isBuffered(f,a+.1)&&(d=this.getAppendedFrag(a+.1)),d){var b=this.fragPlaying,g=d.level;(!b||d.sn!==b.sn||b.level!==g||d.urlId!==b.urlId)&&(this.hls.trigger(U.Events.FRAG_CHANGED,{frag:d}),(!b||b.level!==g)&&this.hls.trigger(U.Events.LEVEL_SWITCHED,{level:g}),this.fragPlaying=d)}}},o(L,[{key:"nextLevel",get:function(){var f=this.nextBufferedFrag;return f?f.level:-1}},{key:"currentLevel",get:function(){var f=this.media;if(f){var d=this.getAppendedFrag(f.currentTime);if(d)return d.level}return-1}},{key:"nextBufferedFrag",get:function(){var f=this.media;if(f){var d=this.getAppendedFrag(f.currentTime);return this.followingBufferedFrag(d)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),L}(k.default)},"./src/controller/subtitle-stream-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"SubtitleStreamController",function(){return s});var W=A("./src/events.ts"),k=A("./src/utils/logger.ts"),O=A("./src/utils/buffer-helper.ts"),U=A("./src/controller/fragment-finders.ts"),F=A("./src/utils/discontinuities.ts"),R=A("./src/controller/level-helper.ts"),_=A("./src/controller/fragment-tracker.ts"),v=A("./src/controller/base-stream-controller.ts"),S=A("./src/types/loader.ts"),D=A("./src/types/level.ts");function C(u,w){for(var m=0;m<w.length;m++){var h=w[m];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(u,h.key,h)}}function T(u,w,m){return w&&C(u.prototype,w),m&&C(u,m),u}function E(u,w){u.prototype=Object.create(w.prototype),u.prototype.constructor=u,l(u,w)}function l(u,w){return l=Object.setPrototypeOf||function(h,L){return h.__proto__=L,h},l(u,w)}var o=500,s=function(u){E(w,u);function w(h,L){var p;return p=u.call(this,h,L,"[subtitle-stream-controller]")||this,p.levels=[],p.currentTrackId=-1,p.tracksBuffered=[],p.mainDetails=null,p._registerListeners(),p}var m=w.prototype;return m.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},m._registerListeners=function(){var L=this.hls;L.on(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.on(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.on(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),L.on(W.Events.LEVEL_LOADED,this.onLevelLoaded,this),L.on(W.Events.ERROR,this.onError,this),L.on(W.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),L.on(W.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),L.on(W.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),L.on(W.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),L.on(W.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m._unregisterListeners=function(){var L=this.hls;L.off(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.off(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.off(W.Events.MANIFEST_LOADING,this.onManifestLoading,this),L.off(W.Events.LEVEL_LOADED,this.onLevelLoaded,this),L.off(W.Events.ERROR,this.onError,this),L.off(W.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),L.off(W.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),L.off(W.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),L.off(W.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),L.off(W.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m.startLoad=function(){this.stopLoad(),this.state=v.State.IDLE,this.setInterval(o),this.tick()},m.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},m.onLevelLoaded=function(L,p){this.mainDetails=p.details},m.onSubtitleFragProcessed=function(L,p){var c=p.frag,f=p.success;if(this.fragPrevious=c,this.state=v.State.IDLE,!f)return;var d=this.tracksBuffered[this.currentTrackId];if(!d)return;for(var a,b=c.start,g=0;g<d.length;g++)if(b>=d[g].start&&b<=d[g].end){a=d[g];break}var x=c.start+c.duration;a?a.end=x:(a={start:b,end:x},d.push(a)),this.fragmentTracker.fragBuffered(c)},m.onBufferFlushing=function(L,p){var c=p.startOffset,f=p.endOffset;if(c===0&&f!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,a=this.levels;if(!a.length||!a[d]||!a[d].details)return;var b=a[d].details,g=b.targetduration,x=f-g;if(x<=0)return;p.endOffsetSubtitles=Math.max(0,x),this.tracksBuffered.forEach(function(P){for(var N=0;N<P.length;){if(P[N].end<=x){P.shift();continue}else if(P[N].start<x)P[N].start=x;else break;N++}}),this.fragmentTracker.removeFragmentsInRange(c,x,S.PlaylistLevelType.SUBTITLE)}},m.onError=function(L,p){var c,f=p.frag;if(!f||f.type!==S.PlaylistLevelType.SUBTITLE)return;(c=this.fragCurrent)!==null&&c!==void 0&&c.loader&&this.fragCurrent.loader.abort(),this.state=v.State.IDLE},m.onSubtitleTracksUpdated=function(L,p){var c=this,f=p.subtitleTracks;this.tracksBuffered=[],this.levels=f.map(function(d){return new D.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){c.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},m.onSubtitleTrackSwitch=function(L,p){if(this.currentTrackId=p.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var c=this.levels[this.currentTrackId];c!=null&&c.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,c&&this.setInterval(o)},m.onSubtitleTrackLoaded=function(L,p){var c,f=p.details,d=p.id,a=this.currentTrackId,b=this.levels;if(!b.length)return;var g=b[a];if(d>=b.length||d!==a||!g)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,f.live||(c=g.details)!==null&&c!==void 0&&c.live){var x=this.mainDetails;if(f.deltaUpdateFailed||!x)return;var P=x.fragments[0];if(!g.details)f.hasProgramDateTime&&x.hasProgramDateTime?Object(F.alignMediaPlaylistByPDT)(f,x):P&&Object(R.addSliding)(f,P.start);else{var N=this.alignPlaylists(f,g.details);N===0&&P&&Object(R.addSliding)(f,P.start)}}if(g.details=f,this.levelLastLoaded=d,this.tick(),f.live&&!this.fragCurrent&&this.media&&this.state===v.State.IDLE){var H=Object(U.findFragmentByPTS)(null,f.fragments,this.media.currentTime,0);H||(this.warn("Subtitle playlist not aligned with playback"),g.details=void 0)}},m._handleFragmentLoadComplete=function(L){var p=L.frag,c=L.payload,f=p.decryptdata,d=this.hls;if(this.fragContextChanged(p))return;if(c&&c.byteLength>0&&f&&f.key&&f.iv&&f.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(c),f.key.buffer,f.iv.buffer).then(function(b){var g=performance.now();d.trigger(W.Events.FRAG_DECRYPTED,{frag:p,payload:b,stats:{tstart:a,tdecrypt:g}})})}},m.doTick=function(){if(!this.media){this.state=v.State.IDLE;return}if(this.state===v.State.IDLE){var L,p=this.currentTrackId,c=this.levels;if(!c.length||!c[p]||!c[p].details)return;var f=c[p].details,d=f.targetduration,a=this.config,b=this.media,g=O.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,b.currentTime-d,a.maxBufferHole),x=g.end,P=g.len,N=this.getMaxBufferLength()+d;if(P>N)return;console.assert(f,"Subtitle track details are defined on idle subtitle stream controller tick");var H=f.fragments,X=H.length,B=f.edge,I,Y=this.fragPrevious;if(x<B){var te=a.maxFragLookUpTolerance;Y&&f.hasProgramDateTime&&(I=Object(U.findFragmentByPDT)(H,Y.endProgramDateTime,te)),I||(I=Object(U.findFragmentByPTS)(Y,H,x,te),!I&&Y&&Y.start<H[0].start&&(I=H[0]))}else I=H[X-1];(L=I)!==null&&L!==void 0&&L.encrypted?(k.logger.log("Loading key for "+I.sn),this.state=v.State.KEY_LOADING,this.hls.trigger(W.Events.KEY_LOADING,{frag:I})):I&&this.fragmentTracker.getState(I)===_.FragmentState.NOT_LOADED&&this.loadFragment(I,f,x)}},m.loadFragment=function(L,p,c){this.fragCurrent=L,u.prototype.loadFragment.call(this,L,p,c)},T(w,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),w}(v.default)},"./src/controller/subtitle-track-controller.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/events.ts"),k=A("./src/utils/texttrack-utils.ts"),O=A("./src/controller/base-playlist-controller.ts"),U=A("./src/types/loader.ts");function F(C,T){for(var E=0;E<T.length;E++){var l=T[E];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(C,l.key,l)}}function R(C,T,E){return T&&F(C.prototype,T),E&&F(C,E),C}function _(C,T){C.prototype=Object.create(T.prototype),C.prototype.constructor=C,v(C,T)}function v(C,T){return v=Object.setPrototypeOf||function(l,o){return l.__proto__=o,l},v(C,T)}var S=function(C){_(T,C);function T(l){var o;return o=C.call(this,l,"[subtitle-track-controller]")||this,o.media=null,o.tracks=[],o.groupId=null,o.tracksInGroup=[],o.trackId=-1,o.selectDefaultTrack=!0,o.queuedDefaultTrack=-1,o.trackChangeListener=function(){return o.onTextTracksChanged()},o.asyncPollTrackChange=function(){return o.pollTrackChange(0)},o.useTextTrackPolling=!1,o.subtitlePollingInterval=-1,o.subtitleDisplay=!0,o.registerListeners(),o}var E=T.prototype;return E.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,C.prototype.destroy.call(this)},E.registerListeners=function(){var o=this.hls;o.on(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),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.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on(W.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){var o=this.hls;o.off(W.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(W.Events.MEDIA_DETACHING,this.onMediaDetaching,this),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.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off(W.Events.ERROR,this.onError,this)},E.onMediaAttached=function(o,s){if(this.media=s.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)},E.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},E.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 o=D(this.media.textTracks);o.forEach(function(s){Object(k.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null},E.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},E.onManifestParsed=function(o,s){this.tracks=s.subtitleTracks},E.onSubtitleTrackLoaded=function(o,s){var u=s.id,w=s.details,m=this.trackId,h=this.tracksInGroup[m];if(!h){this.warn("Invalid subtitle track id "+u);return}var L=h.details;h.details=s.details,this.log("subtitle track "+u+" loaded ["+w.startSN+"-"+w.endSN+"]"),u===this.trackId&&(this.retryCount=0,this.playlistLoaded(u,s,L))},E.onLevelLoading=function(o,s){this.switchLevel(s.level)},E.onLevelSwitching=function(o,s){this.switchLevel(s.level)},E.switchLevel=function(o){var s=this.hls.levels[o];if(!(s!=null&&s.textGroupIds))return;var u=s.textGroupIds[s.urlId];if(this.groupId!==u){var w=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,m=this.tracks.filter(function(p){return!u||p.groupId===u});this.tracksInGroup=m;var h=this.findTrackId(w==null?void 0:w.name)||this.findTrackId();this.groupId=u;var L={subtitleTracks:m};this.log("Updating subtitle tracks, "+m.length+' track(s) found in "'+u+'" group-id'),this.hls.trigger(W.Events.SUBTITLE_TRACKS_UPDATED,L),h!==-1&&this.setSubtitleTrack(h,w)}},E.findTrackId=function(o){for(var s=this.tracksInGroup,u=0;u<s.length;u++){var w=s[u];if((!this.selectDefaultTrack||w.default)&&(!o||o===w.name))return w.id}return-1},E.onError=function(o,s){if(C.prototype.onError.call(this,o,s),s.fatal||!s.context)return;s.context.type===U.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},E.loadPlaylist=function(o){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var u=s.id,w=s.groupId,m=s.url;if(o)try{m=o.addDirectives(m)}catch(h){this.warn("Could not construct new URL with HLS Delivery Directives: "+h)}this.log("Loading subtitle playlist for id "+u),this.hls.trigger(W.Events.SUBTITLE_TRACK_LOADING,{url:m,id:u,groupId:w,deliveryDirectives:o||null})}},E.toggleTrackModes=function(o){var s=this,u=this.media,w=this.subtitleDisplay,m=this.trackId;if(!u)return;var h=D(u.textTracks),L=h.filter(function(f){return f.groupId===s.groupId});if(o===-1)[].slice.call(h).forEach(function(f){f.mode="disabled"});else{var p=L[m];p&&(p.mode="disabled")}var c=L[o];c&&(c.mode=w?"showing":"hidden")},E.setSubtitleTrack=function(o,s){var u,w=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(u=w[o])!==null&&u!==void 0&&u.details)||o<-1||o>=w.length)return;this.clearTimer();var m=w[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,m){var h=m.id,L=m.groupId,p=L===void 0?"":L,c=m.name,f=m.type,d=m.url;this.hls.trigger(W.Events.SUBTITLE_TRACK_SWITCH,{id:h,groupId:p,name:c,type:f,url:d});var a=this.switchParams(m.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger(W.Events.SUBTITLE_TRACK_SWITCH,{id:o})},E.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,s=D(this.media.textTracks),u=0;u<s.length;u++)if(s[u].mode==="hidden")o=u;else if(s[u].mode==="showing"){o=u;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},R(T,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(o){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(o,s)}}]),T}(O.default);function D(C){for(var T=[],E=0;E<C.length;E++){var l=C[E];l.kind==="subtitles"&&l.label&&T.push(C[E])}return T}G.default=S},"./src/controller/timeline-controller.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"TimelineController",function(){return D});var W=A("./src/polyfills/number.ts"),k=A("./src/events.ts"),O=A("./src/utils/cea-608-parser.ts"),U=A("./src/utils/output-filter.ts"),F=A("./src/utils/webvtt-parser.ts"),R=A("./src/utils/texttrack-utils.ts"),_=A("./src/utils/imsc1-ttml-parser.ts"),v=A("./src/types/loader.ts"),S=A("./src/utils/logger.ts"),D=function(){function l(s){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=E(),this.captionsProperties=void 0,this.hls=s,this.config=s.config,this.Cues=s.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 u=new U.default(this,"textTrack1"),w=new U.default(this,"textTrack2"),m=new U.default(this,"textTrack3"),h=new U.default(this,"textTrack4");this.cea608Parser1=new O.default(1,u,w),this.cea608Parser2=new O.default(3,m,h)}s.on(k.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.on(k.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(k.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(k.Events.MANIFEST_LOADED,this.onManifestLoaded,this),s.on(k.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),s.on(k.Events.FRAG_LOADING,this.onFragLoading,this),s.on(k.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(k.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),s.on(k.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),s.on(k.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(k.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),s.on(k.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=l.prototype;return o.destroy=function(){var u=this.hls;u.off(k.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),u.off(k.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(k.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(k.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.off(k.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.off(k.Events.FRAG_LOADING,this.onFragLoading,this),u.off(k.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(k.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),u.off(k.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),u.off(k.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.off(k.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),u.off(k.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(u,w,m,h,L){for(var p=!1,c=L.length;c--;){var f=L[c],d=T(f[0],f[1],w,m);if(d>=0&&(f[0]=Math.min(f[0],w),f[1]=Math.max(f[1],m),p=!0,d/(m-w)>.5))return}if(p||L.push([w,m]),this.config.renderTextTracksNatively){var a=this.captionsTracks[u];this.Cues.newCue(a,w,m,h)}else{var b=this.Cues.newCue(null,w,m,h);this.hls.trigger(k.Events.CUES_PARSED,{type:"captions",cues:b,track:u})}},o.onInitPtsFound=function(u,w){var m=this,h=w.frag,L=w.id,p=w.initPTS,c=w.timescale,f=this.unparsedVttFrags;L==="main"&&(this.initPTS[h.cc]=p,this.timescale[h.cc]=c),f.length&&(this.unparsedVttFrags=[],f.forEach(function(d){m.onFragLoaded(k.Events.FRAG_LOADED,d)}))},o.getExistingTrack=function(u){var w=this.media;if(w)for(var m=0;m<w.textTracks.length;m++){var h=w.textTracks[m];if(h[u])return h}return null},o.createCaptionsTrack=function(u){this.config.renderTextTracksNatively?this.createNativeTrack(u):this.createNonNativeTrack(u)},o.createNativeTrack=function(u){if(this.captionsTracks[u])return;var w=this.captionsProperties,m=this.captionsTracks,h=this.media,L=w[u],p=L.label,c=L.languageCode,f=this.getExistingTrack(u);if(f)m[u]=f,Object(R.clearCurrentCues)(m[u]),Object(R.sendAddTrackEvent)(m[u],h);else{var d=this.createTextTrack("captions",p,c);d&&(d[u]=!0,m[u]=d)}},o.createNonNativeTrack=function(u){if(this.nonNativeCaptionsTracks[u])return;var w=this.captionsProperties[u];if(!w)return;var m=w.label,h={_id:u,label:m,kind:"captions",default:w.media?!!w.media.default:!1,closedCaptions:w.media};this.nonNativeCaptionsTracks[u]=h,this.hls.trigger(k.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[h]})},o.createTextTrack=function(u,w,m){var h=this.media;return h?h.addTextTrack(u,w,m):void 0},o.onMediaAttaching=function(u,w){this.media=w.media,this._cleanTracks()},o.onMediaDetaching=function(){var u=this.captionsTracks;Object.keys(u).forEach(function(w){Object(R.clearCurrentCues)(u[w]),delete u[w]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=E(),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())},o._cleanTracks=function(){var u=this.media;if(!u)return;var w=u.textTracks;if(w)for(var m=0;m<w.length;m++)Object(R.clearCurrentCues)(w[m])},o.onSubtitleTracksUpdated=function(u,w){var m=this;this.textTracks=[];var h=w.subtitleTracks||[],L=h.some(function(d){return d.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||L&&this.config.enableIMSC1){var p=this.tracks&&h&&this.tracks.length===h.length;if(this.tracks=h||[],this.config.renderTextTracksNatively){var c=this.media?this.media.textTracks:[];this.tracks.forEach(function(d,a){var b;if(a<c.length){for(var g=null,x=0;x<c.length;x++)if(C(c[x],d)){g=c[x];break}g&&(b=g)}b?Object(R.clearCurrentCues)(b):(b=m.createTextTrack("subtitles",d.name,d.lang),b&&(b.mode="disabled")),b&&(b.groupId=d.groupId,m.textTracks.push(b))})}else if(!p&&this.tracks&&this.tracks.length){var f=this.tracks.map(function(d){return{label:d.name,kind:d.type.toLowerCase(),default:d.default,subtitleTrack:d}});this.hls.trigger(k.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:f})}}},o.onManifestLoaded=function(u,w){var m=this;this.config.enableCEA708Captions&&w.captions&&w.captions.forEach(function(h){var L=/(?:CC|SERVICE)([1-4])/.exec(h.instreamId);if(!L)return;var p="textTrack"+L[1],c=m.captionsProperties[p];if(!c)return;c.label=h.name,h.lang&&(c.languageCode=h.lang),c.media=h})},o.onFragLoading=function(u,w){var m=this.cea608Parser1,h=this.cea608Parser2,L=this.lastSn,p=this.lastPartIndex;if(!this.enabled||!(m&&h))return;if(w.frag.type===v.PlaylistLevelType.MAIN){var c,f,d=w.frag.sn,a=(c=w==null||((f=w.part)===null||f===void 0)?void 0:f.index)!=null?c:-1;d===L+1||d===L&&a===p+1||(m.reset(),h.reset()),this.lastSn=d,this.lastPartIndex=a}},o.onFragLoaded=function(u,w){var m=w.frag,h=w.payload,L=this.initPTS,p=this.unparsedVttFrags;if(m.type===v.PlaylistLevelType.SUBTITLE)if(h.byteLength){if(!Object(W.isFiniteNumber)(L[m.cc])){p.push(w),L.length&&this.hls.trigger(k.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Missing initial subtitle PTS")});return}var c=m.decryptdata;if(c==null||c.key==null||c.method!=="AES-128"){var f=this.tracks[m.level],d=this.vttCCs;d[m.cc]||(d[m.cc]={start:m.start,prevCC:this.prevCC,new:!0},this.prevCC=m.cc),f&&f.textCodec===_.IMSC1_CODEC?this._parseIMSC1(m,h):this._parseVTTs(m,h,d)}}else this.hls.trigger(k.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(u,w){var m=this,h=this.hls;Object(_.parseIMSC1)(w,this.initPTS[u.cc],this.timescale[u.cc],function(L){m._appendCues(L,u.level),h.trigger(k.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:u})},function(L){S.logger.log("Failed to parse IMSC1: "+L),h.trigger(k.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:u,error:L})})},o._parseVTTs=function(u,w,m){var h=this,L=this.hls;Object(F.parseWebVTT)(w,this.initPTS[u.cc],this.timescale[u.cc],m,u.cc,u.start,function(p){h._appendCues(p,u.level),L.trigger(k.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:u})},function(p){h._fallbackToIMSC1(u,w),S.logger.log("Failed to parse VTT cue: "+p),L.trigger(k.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:u,error:p})})},o._fallbackToIMSC1=function(u,w){var m=this,h=this.tracks[u.level];h.textCodec||Object(_.parseIMSC1)(w,this.initPTS[u.cc],this.timescale[u.cc],function(){h.textCodec=_.IMSC1_CODEC,m._parseIMSC1(u,w)},function(){h.textCodec="wvtt"})},o._appendCues=function(u,w){var m=this.hls;if(this.config.renderTextTracksNatively){var h=this.textTracks[w];if(h.mode==="disabled")return;u.forEach(function(c){return Object(R.addCueToTrack)(h,c)})}else{var L=this.tracks[w],p=L.default?"default":"subtitles"+w;m.trigger(k.Events.CUES_PARSED,{type:"subtitles",cues:u,track:p})}},o.onFragDecrypted=function(u,w){var m=w.frag;if(m.type===v.PlaylistLevelType.SUBTITLE){if(!Object(W.isFiniteNumber)(this.initPTS[m.cc])){this.unparsedVttFrags.push(w);return}this.onFragLoaded(k.Events.FRAG_LOADED,w)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(u,w){var m=this.cea608Parser1,h=this.cea608Parser2;if(!this.enabled||!(m&&h))return;for(var L=0;L<w.samples.length;L++){var p=w.samples[L].bytes;if(p){var c=this.extractCea608Data(p);m.addData(w.samples[L].pts,c[0]),h.addData(w.samples[L].pts,c[1])}}},o.onBufferFlushing=function(u,w){var m=w.startOffset,h=w.endOffset,L=w.endOffsetSubtitles,p=w.type,c=this.media;if(!c||c.currentTime<h)return;if(!p||p==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(a){return Object(R.removeCuesInRange)(f[a],m,h)})}if(this.config.renderTextTracksNatively&&(m===0&&L!==void 0)){var d=this.textTracks;Object.keys(d).forEach(function(a){return Object(R.removeCuesInRange)(d[a],m,L)})}},o.extractCea608Data=function(u){for(var w=u[0]&31,m=2,h=[[],[]],L=0;L<w;L++){var p=u[m++],c=127&u[m++],f=127&u[m++],d=(4&p)!==0,a=3&p;if(c===0&&f===0)continue;d&&((a===0||a===1)&&(h[a].push(c),h[a].push(f)))}return h},l}();function C(l,o){return l&&l.label===o.name&&!(l.textTrack1||l.textTrack2)}function T(l,o,s,u){return Math.min(o,u)-Math.max(l,s)}function E(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return W});var W=function(){function k(U,F){this.subtle=void 0,this.aesIV=void 0,this.subtle=U,this.aesIV=F}var O=k.prototype;return O.decrypt=function(F,R){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},R,F)},k}()},"./src/crypt/aes-decryptor.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"removePadding",function(){return k}),A.d(G,"default",function(){return O});var W=A("./src/utils/typed-array.ts");function k(U){var F=U.byteLength,R=F&&new DataView(U.buffer).getUint8(F-1);return R?Object(W.sliceUint8)(U,0,F-R):U}var O=function(){function U(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var F=U.prototype;return F.uint8ArrayToUint32Array_=function(_){for(var v=new DataView(_),S=new Uint32Array(4),D=0;D<4;D++)S[D]=v.getUint32(D*4);return S},F.initTable=function(){var _=this.sBox,v=this.invSBox,S=this.subMix,D=S[0],C=S[1],T=S[2],E=S[3],l=this.invSubMix,o=l[0],s=l[1],u=l[2],w=l[3],m=new Uint32Array(256),h=0,L=0,p=0;for(p=0;p<256;p++)p<128?m[p]=p<<1:m[p]=p<<1^283;for(p=0;p<256;p++){var c=L^L<<1^L<<2^L<<3^L<<4;c=c>>>8^c&255^99,_[h]=c,v[c]=h;var f=m[h],d=m[f],a=m[d],b=m[c]*257^c*16843008;D[h]=b<<24|b>>>8,C[h]=b<<16|b>>>16,T[h]=b<<8|b>>>24,E[h]=b,b=a*16843009^d*65537^f*257^h*16843008,o[c]=b<<24|b>>>8,s[c]=b<<16|b>>>16,u[c]=b<<8|b>>>24,w[c]=b,h?(h=f^m[m[m[a^f]]],L^=m[m[L]]):h=L=1}},F.expandKey=function(_){for(var v=this.uint8ArrayToUint32Array_(_),S=!0,D=0;D<v.length&&S;)S=v[D]===this.key[D],D++;if(S)return;this.key=v;var C=this.keySize=v.length;if(C!==4&&C!==6&&C!==8)throw new Error("Invalid aes key size="+C);var T=this.ksRows=(C+6+1)*4,E,l,o=this.keySchedule=new Uint32Array(T),s=this.invKeySchedule=new Uint32Array(T),u=this.sBox,w=this.rcon,m=this.invSubMix,h=m[0],L=m[1],p=m[2],c=m[3],f,d;for(E=0;E<T;E++){if(E<C){f=o[E]=v[E];continue}d=f,E%C===0?(d=d<<8|d>>>24,d=u[d>>>24]<<24|u[d>>>16&255]<<16|u[d>>>8&255]<<8|u[d&255],d^=w[E/C|0]<<24):C>6&&E%C===4&&(d=u[d>>>24]<<24|u[d>>>16&255]<<16|u[d>>>8&255]<<8|u[d&255]),o[E]=f=(o[E-C]^d)>>>0}for(l=0;l<T;l++)E=T-l,l&3?d=o[E]:d=o[E-4],l<4||E<=4?s[l]=d:s[l]=h[u[d>>>24]]^L[u[d>>>16&255]]^p[u[d>>>8&255]]^c[u[d&255]],s[l]=s[l]>>>0},F.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},F.decrypt=function(_,v,S){for(var D=this.keySize+6,C=this.invKeySchedule,T=this.invSBox,E=this.invSubMix,l=E[0],o=E[1],s=E[2],u=E[3],w=this.uint8ArrayToUint32Array_(S),m=w[0],h=w[1],L=w[2],p=w[3],c=new Int32Array(_),f=new Int32Array(c.length),d,a,b,g,x,P,N,H,X,B,I,Y,te,se,de=this.networkToHostOrderSwap;v<c.length;){for(X=de(c[v]),B=de(c[v+1]),I=de(c[v+2]),Y=de(c[v+3]),x=X^C[0],P=Y^C[1],N=I^C[2],H=B^C[3],te=4,se=1;se<D;se++)d=l[x>>>24]^o[P>>16&255]^s[N>>8&255]^u[H&255]^C[te],a=l[P>>>24]^o[N>>16&255]^s[H>>8&255]^u[x&255]^C[te+1],b=l[N>>>24]^o[H>>16&255]^s[x>>8&255]^u[P&255]^C[te+2],g=l[H>>>24]^o[x>>16&255]^s[P>>8&255]^u[N&255]^C[te+3],x=d,P=a,N=b,H=g,te=te+4;d=T[x>>>24]<<24^T[P>>16&255]<<16^T[N>>8&255]<<8^T[H&255]^C[te],a=T[P>>>24]<<24^T[N>>16&255]<<16^T[H>>8&255]<<8^T[x&255]^C[te+1],b=T[N>>>24]<<24^T[H>>16&255]<<16^T[x>>8&255]<<8^T[P&255]^C[te+2],g=T[H>>>24]<<24^T[x>>16&255]<<16^T[P>>8&255]<<8^T[N&255]^C[te+3],f[v]=de(d^m),f[v+1]=de(g^h),f[v+2]=de(b^L),f[v+3]=de(a^p),m=X,h=B,L=I,p=Y,v=v+4}return f.buffer},U}()},"./src/crypt/decrypter.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return v});var W=A("./src/crypt/aes-crypto.ts"),k=A("./src/crypt/fast-aes-key.ts"),O=A("./src/crypt/aes-decryptor.ts"),U=A("./src/utils/logger.ts"),F=A("./src/utils/mp4-tools.ts"),R=A("./src/utils/typed-array.ts"),_=16,v=function(){function S(C,T,E){var l=E===void 0?{}:E,o=l.removePKCS7Padding,s=o===void 0?!0:o;if(this.logEnabled=!0,this.observer=void 0,this.config=void 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.observer=C,this.config=T,this.removePKCS7Padding=s,s)try{var u=self.crypto;u&&(this.subtle=u.subtle||u.webkitSubtle)}catch(w){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=S.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var T=this.currentResult;if(!T){this.reset();return}var E=new Uint8Array(T);return this.reset(),this.removePKCS7Padding?Object(O.removePadding)(E):E},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(T,E,l,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(T),E,l);var s=this.flush();s&&o(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(T),E,l).then(o)},D.softwareDecrypt=function(T,E,l){var o=this.currentIV,s=this.currentResult,u=this.remainderData;this.logOnce("JS AES decrypt"),u&&(T=Object(F.appendUint8Array)(u,T),this.remainderData=null);var w=this.getValidChunk(T);if(!w.length)return null;o&&(l=o);var m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new O.default),m.expandKey(E);var h=s;return this.currentResult=m.decrypt(w.buffer,0,l),this.currentIV=Object(R.sliceUint8)(w,-16).buffer,h||null},D.webCryptoDecrypt=function(T,E,l){var o=this,s=this.subtle;return(this.key!==E||!this.fastAesKey)&&(this.key=E,this.fastAesKey=new k.default(s,E)),this.fastAesKey.expandKey().then(function(u){if(!s)return Promise.reject(new Error("web crypto not initialized"));var w=new W.default(s,l);return w.decrypt(T.buffer,u)}).catch(function(u){return o.onWebCryptoError(u,T,E,l)})},D.onWebCryptoError=function(T,E,l,o){return U.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",T),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(E,l,o)},D.getValidChunk=function(T){var E=T,l=T.length-T.length%_;return l!==T.length&&(E=Object(R.sliceUint8)(T,0,l),this.remainderData=Object(R.sliceUint8)(T,l)),E},D.logOnce=function(T){if(!this.logEnabled)return;U.logger.log("[decrypter.ts]: "+T),this.logEnabled=!1},S}()},"./src/crypt/fast-aes-key.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return W});var W=function(){function k(U,F){this.subtle=void 0,this.key=void 0,this.subtle=U,this.key=F}var O=k.prototype;return O.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},k}()},"./src/demux/aacdemuxer.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/demux/base-audio-demuxer.ts"),k=A("./src/demux/adts.ts"),O=A("./src/utils/logger.ts"),U=A("./src/demux/id3.ts");function F(v,S){v.prototype=Object.create(S.prototype),v.prototype.constructor=v,R(v,S)}function R(v,S){return R=Object.setPrototypeOf||function(C,T){return C.__proto__=T,C},R(v,S)}var _=function(v){F(S,v);function S(C,T){var E;return E=v.call(this)||this,E.observer=void 0,E.config=void 0,E.observer=C,E.config=T,E}var D=S.prototype;return D.resetInitSegment=function(T,E,l){v.prototype.resetInitSegment.call(this,T,E,l),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:T,duration:l,inputTimeScale:9e4,dropped:0}},S.probe=function(T){if(!T)return!1;for(var E=U.getID3Data(T,0)||[],l=E.length,o=T.length;l<o;l++)if(k.probe(T,l))return O.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(T,E){return k.canParse(T,E)},D.appendFrame=function(T,E,l){k.initTrackConfig(T,this.observer,E,l,T.manifestCodec);var o=k.appendFrame(T,E,l,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},S}(W.default);_.minProbeByteLength=9,G.default=_},"./src/demux/adts.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"getAudioConfig",function(){return U}),A.d(G,"isHeaderPattern",function(){return F}),A.d(G,"getHeaderLength",function(){return R}),A.d(G,"getFullFrameLength",function(){return _}),A.d(G,"canGetFrameLength",function(){return v}),A.d(G,"isHeader",function(){return S}),A.d(G,"canParse",function(){return D}),A.d(G,"probe",function(){return C}),A.d(G,"initTrackConfig",function(){return T}),A.d(G,"getFrameDuration",function(){return E}),A.d(G,"parseFrameHeader",function(){return l}),A.d(G,"appendFrame",function(){return o});var W=A("./src/utils/logger.ts"),k=A("./src/errors.ts"),O=A("./src/events.ts");function U(s,u,w,m){var h,L,p,c,f=navigator.userAgent.toLowerCase(),d=m,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];h=((u[w+2]&192)>>>6)+1;var b=(u[w+2]&60)>>>2;if(b>a.length-1){s.trigger(O.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+b});return}return p=(u[w+2]&1)<<2,p|=(u[w+3]&192)>>>6,W.logger.log("manifest codec:"+m+", ADTS type:"+h+", samplingIndex:"+b),/firefox/i.test(f)?b>=6?(h=5,c=new Array(4),L=b-3):(h=2,c=new Array(2),L=b):f.indexOf("android")!==-1?(h=2,c=new Array(2),L=b):(h=5,c=new Array(4),m&&(m.indexOf("mp4a.40.29")!==-1||m.indexOf("mp4a.40.5")!==-1)||!m&&b>=6?L=b-3:((m&&m.indexOf("mp4a.40.2")!==-1&&(b>=6&&p===1||/vivaldi/i.test(f))||!m&&p===1)&&(h=2,c=new Array(2)),L=b)),c[0]=h<<3,c[0]|=(b&14)>>1,c[1]|=(b&1)<<7,c[1]|=p<<3,h===5&&(c[1]|=(L&14)>>1,c[2]=(L&1)<<7,c[2]|=2<<2,c[3]=0),{config:c,samplerate:a[b],channelCount:p,codec:"mp4a.40."+h,manifestCodec:d}}function F(s,u){return s[u]===255&&(s[u+1]&246)===240}function R(s,u){return s[u+1]&1?7:9}function _(s,u){return(s[u+3]&3)<<11|s[u+4]<<3|(s[u+5]&224)>>>5}function v(s,u){return u+5<s.length}function S(s,u){return u+1<s.length&&F(s,u)}function D(s,u){return v(s,u)&&F(s,u)&&_(s,u)<=s.length-u}function C(s,u){if(S(s,u)){var w=R(s,u);if(u+w>=s.length)return!1;var m=_(s,u);if(m<=w)return!1;var h=u+m;return h===s.length||S(s,h)}return!1}function T(s,u,w,m,h){if(!s.samplerate){var L=U(u,w,m,h);if(!L)return;s.config=L.config,s.samplerate=L.samplerate,s.channelCount=L.channelCount,s.codec=L.codec,s.manifestCodec=L.manifestCodec,W.logger.log("parsed codec:"+s.codec+", rate:"+L.samplerate+", channels:"+L.channelCount)}}function E(s){return 1024*9e4/s}function l(s,u,w,m,h){var L=R(s,u),p=_(s,u);if(p-=L,p>0){var c=w+m*h;return{headerLength:L,frameLength:p,stamp:c}}}function o(s,u,w,m,h){var L=E(s.samplerate),p=l(u,w,m,h,L);if(p){var c=p.frameLength,f=p.headerLength,d=p.stamp,a=f+c,b=Math.max(0,w+a-u.length),g;b?(g=new Uint8Array(a-f),g.set(u.subarray(w+f,u.length),0)):g=u.subarray(w+f,w+a);var x={unit:g,pts:d};return b||s.samples.push(x),{sample:x,length:a,missing:b}}}},"./src/demux/base-audio-demuxer.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"initPTSFn",function(){return _});var W=A("./src/polyfills/number.ts"),k=A("./src/demux/id3.ts"),O=A("./src/demux/dummy-demuxed-track.ts"),U=A("./src/utils/mp4-tools.ts"),F=A("./src/utils/typed-array.ts"),R=function(){function v(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var S=v.prototype;return S.resetInitSegment=function(C,T,E){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},S.resetTimeStamp=function(){},S.resetContiguity=function(){},S.canParse=function(C,T){return!1},S.appendFrame=function(C,T,E){},S.demux=function(C,T){this.cachedData&&(C=Object(U.appendUint8Array)(this.cachedData,C),this.cachedData=null);var E=k.getID3Data(C,0),l=E?E.length:0,o,s,u=this._audioTrack,w=this._id3Track,m=E?k.getTimeStamp(E):void 0,h=C.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=_(m,T)),E&&E.length>0&&w.samples.push({pts:this.initPTS,dts:this.initPTS,data:E}),s=this.initPTS;l<h;){if(this.canParse(C,l)){var L=this.appendFrame(u,C,l);L?(this.frameIndex++,s=L.sample.pts,l+=L.length,o=l):l=h}else k.canParse(C,l)?(E=k.getID3Data(C,l),w.samples.push({pts:s,dts:s,data:E}),l+=E.length,o=l):l++;if(l===h&&o!==h){var p=Object(F.sliceUint8)(C,o);this.cachedData?this.cachedData=Object(U.appendUint8Array)(this.cachedData,p):this.cachedData=p}}return{audioTrack:u,avcTrack:Object(O.dummyTrack)(),id3Track:w,textTrack:Object(O.dummyTrack)()}},S.demuxSampleAes=function(C,T,E){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},S.flush=function(C){var T=this.cachedData;return T&&(this.cachedData=null,this.demux(T,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(O.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(O.dummyTrack)()}},S.destroy=function(){},v}(),_=function(S,D){return Object(W.isFiniteNumber)(S)?S*90:D*9e4};G.default=R},"./src/demux/chunk-cache.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return W});var W=function(){function O(){this.chunks=[],this.dataLength=0}var U=O.prototype;return U.push=function(R){this.chunks.push(R),this.dataLength+=R.length},U.flush=function(){var R=this.chunks,_=this.dataLength,v;if(R.length)R.length===1?v=R[0]:v=k(R,_);else return new Uint8Array(0);return this.reset(),v},U.reset=function(){this.chunks.length=0,this.dataLength=0},O}();function k(O,U){for(var F=new Uint8Array(U),R=0,_=0;_<O.length;_++){var v=O[_];F.set(v,R),R+=v.length}return F}},"./src/demux/dummy-demuxed-track.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"dummyTrack",function(){return W});function W(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/utils/logger.ts"),k=function(){function O(F){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=F,this.bytesAvailable=F.byteLength,this.word=0,this.bitsAvailable=0}var U=O.prototype;return U.loadWord=function(){var R=this.data,_=this.bytesAvailable,v=R.byteLength-_,S=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");S.set(R.subarray(v,v+D)),this.word=new DataView(S.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},U.skipBits=function(R){var _;this.bitsAvailable>R?(this.word<<=R,this.bitsAvailable-=R):(R-=this.bitsAvailable,_=R>>3,R-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=R,this.bitsAvailable-=R)},U.readBits=function(R){var _=Math.min(this.bitsAvailable,R),v=this.word>>>32-_;return R>32&&W.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=R-_,_>0&&this.bitsAvailable?v<<_|this.readBits(_):v},U.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()},U.skipUEG=function(){this.skipBits(1+this.skipLZ())},U.skipEG=function(){this.skipBits(1+this.skipLZ())},U.readUEG=function(){var R=this.skipLZ();return this.readBits(R+1)-1},U.readEG=function(){var R=this.readUEG();return 1&R?1+R>>>1:-1*(R>>>1)},U.readBoolean=function(){return this.readBits(1)===1},U.readUByte=function(){return this.readBits(8)},U.readUShort=function(){return this.readBits(16)},U.readUInt=function(){return this.readBits(32)},U.skipScalingList=function(R){for(var _=8,v=8,S,D=0;D<R;D++)v!==0&&(S=this.readEG(),v=(_+S+256)%256),_=v===0?_:v},U.readSPS=function(){var R=0,_=0,v=0,S=0,D,C,T,E=this.readUByte.bind(this),l=this.readBits.bind(this),o=this.readUEG.bind(this),s=this.readBoolean.bind(this),u=this.skipBits.bind(this),w=this.skipEG.bind(this),m=this.skipUEG.bind(this),h=this.skipScalingList.bind(this);E();var L=E();if(l(5),u(3),E(),m(),L===100||L===110||L===122||L===244||L===44||L===83||L===86||L===118||L===128){var p=o();if(p===3&&u(1),m(),m(),u(1),s())for(C=p!==3?8:12,T=0;T<C;T++)s()&&(T<6?h(16):h(64))}m();var c=o();if(c===0)o();else if(c===1)for(u(1),w(),w(),D=o(),T=0;T<D;T++)w();m(),u(1);var f=o(),d=o(),a=l(1);a===0&&u(1),u(1),s()&&(R=o(),_=o(),v=o(),S=o());var b=[1,1];if(s()&&s()){var g=E();switch(g){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[E()<<8|E(),E()<<8|E()];break}}}return{width:Math.ceil((f+1)*16-R*2-_*2),height:(2-a)*(d+1)*16-(a?2:4)*(v+S),pixelRatio:b}},U.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},O}();G.default=k},"./src/demux/id3.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"isHeader",function(){return W}),A.d(G,"isFooter",function(){return k}),A.d(G,"getID3Data",function(){return O}),A.d(G,"canParse",function(){return F}),A.d(G,"getTimeStamp",function(){return R}),A.d(G,"isTimeStampFrame",function(){return _}),A.d(G,"getID3Frames",function(){return S}),A.d(G,"decodeFrame",function(){return D}),A.d(G,"utf8ArrayToStr",function(){return o}),A.d(G,"testables",function(){return s});var W=function(h,L){return L+10<=h.length&&(h[L]===73&&h[L+1]===68&&h[L+2]===51&&(h[L+3]<255&&h[L+4]<255&&(h[L+6]<128&&h[L+7]<128&&h[L+8]<128&&h[L+9]<128)))},k=function(h,L){return L+10<=h.length&&(h[L]===51&&h[L+1]===68&&h[L+2]===73&&(h[L+3]<255&&h[L+4]<255&&(h[L+6]<128&&h[L+7]<128&&h[L+8]<128&&h[L+9]<128)))},O=function(h,L){for(var p=L,c=0;W(h,L);){c+=10;var f=U(h,L+6);c+=f,k(h,L+10)&&(c+=10),L+=c}return c>0?h.subarray(p,p+c):void 0},U=function(h,L){var p=0;return p=(h[L]&127)<<21,p|=(h[L+1]&127)<<14,p|=(h[L+2]&127)<<7,p|=h[L+3]&127,p},F=function(h,L){return W(h,L)&&U(h,L+6)+10<=h.length-L},R=function(h){for(var L=S(h),p=0;p<L.length;p++){var c=L[p];if(_(c))return l(c)}return},_=function(h){return h&&h.key==="PRIV"&&h.info==="com.apple.streaming.transportStreamTimestamp"},v=function(h){var L=String.fromCharCode(h[0],h[1],h[2],h[3]),p=U(h,4),c=10;return{type:L,size:p,data:h.subarray(c,c+p)}},S=function(h){for(var L=0,p=[];W(h,L);){var c=U(h,L+6);L+=10;for(var f=L+c;L+8<f;){var d=v(h.subarray(L)),a=D(d);a&&p.push(a),L+=d.size+10}k(h,L)&&(L+=10)}return p},D=function(h){return h.type==="PRIV"?C(h):h.type[0]==="W"?E(h):T(h)},C=function(h){if(h.size<2)return;var L=o(h.data,!0),p=new Uint8Array(h.data.subarray(L.length+1));return{key:h.type,info:L,data:p.buffer}},T=function(h){if(h.size<2)return;if(h.type==="TXXX"){var L=1,p=o(h.data.subarray(L),!0);L+=p.length+1;var c=o(h.data.subarray(L));return{key:h.type,info:p,data:c}}var f=o(h.data.subarray(1));return{key:h.type,data:f}},E=function(h){if(h.type==="WXXX"){if(h.size<2)return;var L=1,p=o(h.data.subarray(L),!0);L+=p.length+1;var c=o(h.data.subarray(L));return{key:h.type,info:p,data:c}}var f=o(h.data);return{key:h.type,data:f}},l=function(h){if(h.data.byteLength===8){var L=new Uint8Array(h.data),p=L[3]&1,c=(L[4]<<23)+(L[5]<<15)+(L[6]<<7)+L[7];return c/=45,p&&(c+=4772185884e-2),Math.round(c)}return},o=function(h,L){L===void 0&&(L=!1);var p=w();if(p){var c=p.decode(h);if(L){var f=c.indexOf("\0");return f!==-1?c.substring(0,f):c}return c.replace(/\0/g,"")}for(var d=h.length,a,b,g,x="",P=0;P<d;){if(a=h[P++],a===0&&L)return x;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:x+=String.fromCharCode(a);break;case 12:case 13:b=h[P++],x+=String.fromCharCode((a&31)<<6|b&63);break;case 14:b=h[P++],g=h[P++],x+=String.fromCharCode((a&15)<<12|(b&63)<<6|(g&63)<<0);break;default:}}return x},s={decodeTextFrame:T},u;function w(){return!u&&typeof self.TextDecoder!="undefined"&&(u=new self.TextDecoder("utf-8")),u}},"./src/demux/mp3demuxer.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/demux/base-audio-demuxer.ts"),k=A("./src/demux/id3.ts"),O=A("./src/utils/logger.ts"),U=A("./src/demux/mpegaudio.ts");function F(v,S){v.prototype=Object.create(S.prototype),v.prototype.constructor=v,R(v,S)}function R(v,S){return R=Object.setPrototypeOf||function(C,T){return C.__proto__=T,C},R(v,S)}var _=function(v){F(S,v);function S(){return v.apply(this,arguments)||this}var D=S.prototype;return D.resetInitSegment=function(T,E,l){v.prototype.resetInitSegment.call(this,T,E,l),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:T,duration:l,inputTimeScale:9e4,dropped:0}},S.probe=function(T){if(!T)return!1;for(var E=k.getID3Data(T,0)||[],l=E.length,o=T.length;l<o;l++)if(U.probe(T,l))return O.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(T,E){return U.canParse(T,E)},D.appendFrame=function(T,E,l){return this.initPTS===null?void 0:U.appendFrame(T,E,l,this.initPTS,this.frameIndex)},S}(W.default);_.minProbeByteLength=4,G.default=_},"./src/demux/mp4demuxer.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/utils/mp4-tools.ts"),k=A("./src/demux/dummy-demuxed-track.ts"),O=function(){function U(R,_){this.remainderData=null,this.config=void 0,this.config=_}var F=U.prototype;return F.resetTimeStamp=function(){},F.resetInitSegment=function(){},F.resetContiguity=function(){},U.probe=function(_){return Object(W.findBox)({data:_,start:0,end:Math.min(_.length,16384)},["moof"]).length>0},F.demux=function(_){var v=_,S=Object(k.dummyTrack)();if(this.config.progressive){this.remainderData&&(v=Object(W.appendUint8Array)(this.remainderData,_));var D=Object(W.segmentValidRange)(v);this.remainderData=D.remainder,S.samples=D.valid||new Uint8Array}else S.samples=v;return{audioTrack:Object(k.dummyTrack)(),avcTrack:S,id3Track:Object(k.dummyTrack)(),textTrack:Object(k.dummyTrack)()}},F.flush=function(){var _=Object(k.dummyTrack)();return _.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(k.dummyTrack)(),avcTrack:_,id3Track:Object(k.dummyTrack)(),textTrack:Object(k.dummyTrack)()}},F.demuxSampleAes=function(_,v,S){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},F.destroy=function(){},U}();O.minProbeByteLength=1024,G.default=O},"./src/demux/mpegaudio.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"appendFrame",function(){return R}),A.d(G,"parseHeader",function(){return _}),A.d(G,"isHeaderPattern",function(){return v}),A.d(G,"isHeader",function(){return S}),A.d(G,"canParse",function(){return D}),A.d(G,"probe",function(){return C});var W=null,k=[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],O=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],U=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],F=[0,1,1,4];function R(T,E,l,o,s){if(l+24>E.length)return;var u=_(E,l);if(u&&l+u.frameLength<=E.length){var w=u.samplesPerFrame*9e4/u.sampleRate,m=o+s*w,h={unit:E.subarray(l,l+u.frameLength),pts:m,dts:m};return T.config=[],T.channelCount=u.channelCount,T.samplerate=u.sampleRate,T.samples.push(h),{sample:h,length:u.frameLength,missing:0}}}function _(T,E){var l=T[E+1]>>3&3,o=T[E+1]>>1&3,s=T[E+2]>>4&15,u=T[E+2]>>2&3;if(l!==1&&s!==0&&s!==15&&u!==3){var w=T[E+2]>>1&1,m=T[E+3]>>6,h=l===3?3-o:o===3?3:4,L=k[h*14+s-1]*1e3,p=l===3?0:l===2?1:2,c=O[p*3+u],f=m===3?1:2,d=U[l][o],a=F[o],b=d*8*a,g=Math.floor(d*L/c+w)*a;if(W===null){var x=navigator.userAgent||"",P=x.match(/Chrome\/(\d+)/i);W=P?parseInt(P[1]):0}var N=!!W&&W<=87;return N&&o===2&&L>=224e3&&m===0&&(T[E+3]=T[E+3]|128),{sampleRate:c,channelCount:f,frameLength:g,samplesPerFrame:b}}}function v(T,E){return T[E]===255&&(T[E+1]&224)===224&&(T[E+1]&6)!==0}function S(T,E){return E+1<T.length&&v(T,E)}function D(T,E){var l=4;return v(T,E)&&l<=T.length-E}function C(T,E){if(E+1<T.length&&v(T,E)){var l=4,o=_(T,E),s=l;o!=null&&o.frameLength&&(s=o.frameLength);var u=E+s;return u===T.length||S(T,u)}return!1}},"./src/demux/sample-aes.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/crypt/decrypter.ts"),k=A("./src/demux/tsdemuxer.ts"),O=function(){function U(R,_,v){this.keyData=void 0,this.decrypter=void 0,this.keyData=v,this.decrypter=new W.default(R,_,{removePKCS7Padding:!1})}var F=U.prototype;return F.decryptBuffer=function(_,v){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,v)},F.decryptAacSample=function(_,v,S,D){var C=_[v].unit,T=C.subarray(16,C.length-C.length%16),E=T.buffer.slice(T.byteOffset,T.byteOffset+T.length),l=this;this.decryptBuffer(E,function(o){var s=new Uint8Array(o);C.set(s,16),D||l.decryptAacSamples(_,v+1,S)})},F.decryptAacSamples=function(_,v,S){for(;;v++){if(v>=_.length){S();return}if(_[v].unit.length<32)continue;var D=this.decrypter.isSync();if(this.decryptAacSample(_,v,S,D),!D)return}},F.getAvcEncryptedData=function(_){for(var v=Math.floor((_.length-48)/160)*16+16,S=new Int8Array(v),D=0,C=32;C<=_.length-16;C+=160,D+=16)S.set(_.subarray(C,C+16),D);return S},F.getAvcDecryptedUnit=function(_,v){for(var S=new Uint8Array(v),D=0,C=32;C<=_.length-16;C+=160,D+=16)_.set(S.subarray(D,D+16),C);return _},F.decryptAvcSample=function(_,v,S,D,C,T){var E=Object(k.discardEPB)(C.data),l=this.getAvcEncryptedData(E),o=this;this.decryptBuffer(l.buffer,function(s){C.data=o.getAvcDecryptedUnit(E,s),T||o.decryptAvcSamples(_,v,S+1,D)})},F.decryptAvcSamples=function(_,v,S,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;v++,S=0){if(v>=_.length){D();return}for(var C=_[v].units;!(S>=C.length);S++){var T=C[S];if(T.data.length<=48||T.type!==1&&T.type!==5)continue;var E=this.decrypter.isSync();if(this.decryptAvcSample(_,v,S,D,T,E),!E)return}}},U}();G.default=O},"./src/demux/transmuxer-interface.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return C});var W=A("./node_modules/webworkify-webpack/index.js"),k=A.n(W),O=A("./src/events.ts"),U=A("./src/demux/transmuxer.ts"),F=A("./src/utils/logger.ts"),R=A("./src/errors.ts"),_=A("./src/utils/mediasource-helper.ts"),v=A("./node_modules/eventemitter3/index.js"),S=A.n(v),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},C=function(){function T(l,o,s,u){var w=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=l,this.id=o,this.onTransmuxComplete=s,this.onFlush=u;var m=l.config,h=function(d,a){a=a||{},a.frag=w.frag,a.id=w.id,l.trigger(d,a)};this.observer=new v.EventEmitter,this.observer.on(O.Events.FRAG_DECRYPTED,h),this.observer.on(O.Events.ERROR,h);var L={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(m.enableWorker&&typeof Worker!="undefined"){F.logger.log("demuxing in webworker");var c;try{c=this.worker=W("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),c.addEventListener("message",this.onwmsg),c.onerror=function(f){l.trigger(O.Events.ERROR,{type:R.ErrorTypes.OTHER_ERROR,details:R.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(f.message+" ("+f.filename+":"+f.lineno+")")})},c.postMessage({cmd:"init",typeSupported:L,vendor:p,id:o,config:JSON.stringify(m)})}catch(f){F.logger.warn("Error in worker:",f),F.logger.error("Error while initializing DemuxerWorker, fallback to inline"),c&&self.URL.revokeObjectURL(c.objectURL),this.transmuxer=new U.default(this.observer,L,m,p,o),this.worker=null}}else this.transmuxer=new U.default(this.observer,L,m,p,o)}var E=T.prototype;return E.destroy=function(){var o=this.worker;if(o)o.removeEventListener("message",this.onwmsg),o.terminate(),this.worker=null;else{var s=this.transmuxer;s&&(s.destroy(),this.transmuxer=null)}var u=this.observer;u&&u.removeAllListeners(),this.observer=null},E.push=function(o,s,u,w,m,h,L,p,c,f){var d=this;c.transmuxing.start=self.performance.now();var a=this.transmuxer,b=this.worker,g=h?h.start:m.start,x=m.decryptdata,P=this.frag,N=!(P&&m.cc===P.cc),H=!(P&&c.level===P.level),X=P?c.sn-P.sn:-1,B=this.part?c.part-this.part.index:1,I=!H&&(X===1||X===0&&B===1),Y=self.performance.now();(H||X||m.stats.parsing.start===0)&&(m.stats.parsing.start=Y),h&&(B||!I)&&(h.stats.parsing.start=Y);var te=new U.TransmuxState(N,I,p,H,g);if(!I||N){F.logger.log("[transmuxer-interface, "+m.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+`
|
|
discontinuity: `+N+`
|
|
trackSwitch: `+H+`
|
|
contiguous: `+I+`
|
|
accurateTimeOffset: `+p+`
|
|
timeOffset: `+g);var se=new U.TransmuxConfig(u,w,s,L,f);this.configureTransmuxer(se)}if(this.frag=m,this.part=h,b)b.postMessage({cmd:"demux",data:o,decryptdata:x,chunkMeta:c,state:te},o instanceof ArrayBuffer?[o]:[]);else if(a){var de=a.push(o,x,c,te);Object(U.isPromise)(de)?de.then(function(Se){d.handleTransmuxComplete(Se)}):this.handleTransmuxComplete(de)}},E.flush=function(o){var s=this;o.transmuxing.start=self.performance.now();var u=this.transmuxer,w=this.worker;if(w)w.postMessage({cmd:"flush",chunkMeta:o});else if(u){var m=u.flush(o);Object(U.isPromise)(m)?m.then(function(h){s.handleFlushResult(h,o)}):this.handleFlushResult(m,o)}},E.handleFlushResult=function(o,s){var u=this;o.forEach(function(w){u.handleTransmuxComplete(w)}),this.onFlush(s)},E.onWorkerMessage=function(o){var s=o.data,u=this.hls;switch(s.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(s.data);break}case"flush":{this.onFlush(s.data);break}default:{s.data=s.data||{},s.data.frag=this.frag,s.data.id=this.id,u.trigger(s.event,s.data);break}}},E.configureTransmuxer=function(o){var s=this.worker,u=this.transmuxer;s?s.postMessage({cmd:"configure",config:o}):u&&u.configure(o)},E.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},T}()},"./src/demux/transmuxer-worker.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return R});var W=A("./src/demux/transmuxer.ts"),k=A("./src/events.ts"),O=A("./src/utils/logger.ts"),U=A("./node_modules/eventemitter3/index.js"),F=A.n(U);function R(C){var T=new U.EventEmitter,E=function(o,s){C.postMessage({event:o,data:s})};T.on(k.Events.FRAG_DECRYPTED,E),T.on(k.Events.ERROR,E),C.addEventListener("message",function(l){var o=l.data;switch(o.cmd){case"init":{var s=JSON.parse(o.config);C.transmuxer=new W.default(T,o.typeSupported,s,o.vendor,o.id),Object(O.enableLogs)(s.debug),E("init",null);break}case"configure":{C.transmuxer.configure(o.config);break}case"demux":{var u=C.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(W.isPromise)(u)?u.then(function(h){_(C,h)}):_(C,u);break}case"flush":{var w=o.chunkMeta,m=C.transmuxer.flush(w);Object(W.isPromise)(m)?m.then(function(h){S(C,h,w)}):S(C,m,w);break}default:break}})}function _(C,T){if(D(T.remuxResult))return;var E=[],l=T.remuxResult,o=l.audio,s=l.video;o&&v(E,o),s&&v(E,s),C.postMessage({event:"transmuxComplete",data:T},E)}function v(C,T){T.data1&&C.push(T.data1.buffer),T.data2&&C.push(T.data2.buffer)}function S(C,T,E){T.forEach(function(l){_(C,l)}),C.postMessage({event:"flush",data:E})}function D(C){return!C.audio&&!C.video&&!C.text&&!C.id3&&!C.initSegment}},"./src/demux/transmuxer.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return s}),A.d(G,"isPromise",function(){return m}),A.d(G,"TransmuxConfig",function(){return h}),A.d(G,"TransmuxState",function(){return L});var W=A("./src/events.ts"),k=A("./src/errors.ts"),O=A("./src/crypt/decrypter.ts"),U=A("./src/demux/aacdemuxer.ts"),F=A("./src/demux/mp4demuxer.ts"),R=A("./src/demux/tsdemuxer.ts"),_=A("./src/demux/mp3demuxer.ts"),v=A("./src/remux/mp4-remuxer.ts"),S=A("./src/remux/passthrough-remuxer.ts"),D=A("./src/demux/chunk-cache.ts"),C=A("./src/utils/mp4-tools.ts"),T=A("./src/utils/logger.ts"),E;try{E=self.performance.now.bind(self.performance)}catch(p){T.logger.debug("Unable to use Performance API on this environment"),E=self.Date.now}var l=[{demux:R.default,remux:v.default},{demux:F.default,remux:S.default},{demux:U.default,remux:v.default},{demux:_.default,remux:v.default}],o=1024;l.forEach(function(p){var c=p.demux;o=Math.max(o,c.minProbeByteLength)});var s=function(){function p(f,d,a,b,g){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.cache=new D.default,this.observer=f,this.typeSupported=d,this.config=a,this.vendor=b,this.id=g}var c=p.prototype;return c.configure=function(d){this.transmuxConfig=d,this.decrypter&&this.decrypter.reset()},c.push=function(d,a,b,g){var x=this,P=b.transmuxing;P.executeStart=E();var N=new Uint8Array(d),H=this.cache,X=this.config,B=this.currentTransmuxState,I=this.transmuxConfig;g&&(this.currentTransmuxState=g);var Y=u(N,a);if(Y&&Y.method==="AES-128"){var te=this.getDecrypter();if(X.enableSoftwareAES){var se=te.softwareDecrypt(N,Y.key.buffer,Y.iv.buffer);if(!se)return P.executeEnd=E(),w(b);N=new Uint8Array(se)}else return this.decryptionPromise=te.webCryptoDecrypt(N,Y.key.buffer,Y.iv.buffer).then(function(Ce){var Me=x.push(Ce,null,b);return x.decryptionPromise=null,Me}),this.decryptionPromise}var de=g||B,Se=de.contiguous,ge=de.discontinuity,pe=de.trackSwitch,he=de.accurateTimeOffset,me=de.timeOffset,ae=I.audioCodec,ue=I.videoCodec,xe=I.defaultInitPts,Fe=I.duration,Re=I.initSegmentData;if((ge||pe)&&this.resetInitSegment(Re,ae,ue,Fe),ge&&this.resetInitialTimestamp(xe),Se||this.resetContiguity(),this.needsProbing(N,ge,pe)){if(H.dataLength){var Ie=H.flush();N=Object(C.appendUint8Array)(Ie,N)}this.configureTransmuxer(N,I)}var Ke=this.transmux(N,Y,me,he,b),De=this.currentTransmuxState;return De.contiguous=!0,De.discontinuity=!1,De.trackSwitch=!1,P.executeEnd=E(),Ke},c.flush=function(d){var a=this,b=d.transmuxing;b.executeStart=E();var g=this.decrypter,x=this.cache,P=this.currentTransmuxState,N=this.decryptionPromise;if(N)return N.then(function(){return a.flush(d)});var H=[],X=P.timeOffset;if(g){var B=g.flush();B&&H.push(this.push(B,null,d))}var I=x.dataLength;x.reset();var Y=this.demuxer,te=this.remuxer;if(!Y||!te)return I>=o&&this.observer.emit(W.Events.ERROR,W.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),b.executeEnd=E(),[w(d)];var se=Y.flush(X);return m(se)?se.then(function(de){return a.flushRemux(H,de,d),H}):(this.flushRemux(H,se,d),H)},c.flushRemux=function(d,a,b){var g=a.audioTrack,x=a.avcTrack,P=a.id3Track,N=a.textTrack,H=this.currentTransmuxState,X=H.accurateTimeOffset,B=H.timeOffset;T.logger.log("[transmuxer.ts]: Flushed fragment "+b.sn+(b.part>-1?" p: "+b.part:"")+" of level "+b.level);var I=this.remuxer.remux(g,x,P,N,B,X,!0,this.id);d.push({remuxResult:I,chunkMeta:b}),b.transmuxing.executeEnd=E()},c.resetInitialTimestamp=function(d){var a=this.demuxer,b=this.remuxer;if(!a||!b)return;a.resetTimeStamp(d),b.resetTimeStamp(d)},c.resetContiguity=function(){var d=this.demuxer,a=this.remuxer;if(!d||!a)return;d.resetContiguity(),a.resetNextTimestamp()},c.resetInitSegment=function(d,a,b,g){var x=this.demuxer,P=this.remuxer;if(!x||!P)return;x.resetInitSegment(a,b,g),P.resetInitSegment(d,a,b)},c.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},c.transmux=function(d,a,b,g,x){var P;return a&&a.method==="SAMPLE-AES"?P=this.transmuxSampleAes(d,a,b,g,x):P=this.transmuxUnencrypted(d,b,g,x),P},c.transmuxUnencrypted=function(d,a,b,g){var x=this.demuxer.demux(d,a,!1,!this.config.progressive),P=x.audioTrack,N=x.avcTrack,H=x.id3Track,X=x.textTrack,B=this.remuxer.remux(P,N,H,X,a,b,!1,this.id);return{remuxResult:B,chunkMeta:g}},c.transmuxSampleAes=function(d,a,b,g,x){var P=this;return this.demuxer.demuxSampleAes(d,a,b).then(function(N){var H=P.remuxer.remux(N.audioTrack,N.avcTrack,N.id3Track,N.textTrack,b,g,!1,P.id);return{remuxResult:H,chunkMeta:x}})},c.configureTransmuxer=function(d,a){for(var b=this.config,g=this.observer,x=this.typeSupported,P=this.vendor,N=a.audioCodec,H=a.defaultInitPts,X=a.duration,B=a.initSegmentData,I=a.videoCodec,Y,te=0,se=l.length;te<se;te++)if(l[te].demux.probe(d)){Y=l[te];break}Y||(T.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),Y={demux:F.default,remux:S.default});var de=this.demuxer,Se=this.remuxer,ge=Y.remux,pe=Y.demux;(!Se||!(Se instanceof ge))&&(this.remuxer=new ge(g,b,x,P)),(!de||!(de instanceof pe))&&(this.demuxer=new pe(g,b,x),this.probe=pe.probe),this.resetInitSegment(B,N,I,X),this.resetInitialTimestamp(H)},c.needsProbing=function(d,a,b){return!this.demuxer||!this.remuxer||a||b},c.getDecrypter=function(){var d=this.decrypter;return d||(d=this.decrypter=new O.default(this.observer,this.config)),d},p}();function u(p,c){var f=null;return p.byteLength>0&&c!=null&&c.key!=null&&c.iv!==null&&c.method!=null&&(f=c),f}var w=function(c){return{remuxResult:{},chunkMeta:c}};function m(p){return"then"in p&&p.then instanceof Function}var h=function(c,f,d,a,b){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=c,this.videoCodec=f,this.initSegmentData=d,this.duration=a,this.defaultInitPts=b},L=function(c,f,d,a,b){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=c,this.contiguous=f,this.accurateTimeOffset=d,this.trackSwitch=a,this.timeOffset=b}},"./src/demux/tsdemuxer.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"discardEPB",function(){return w});var W=A("./src/demux/adts.ts"),k=A("./src/demux/mpegaudio.ts"),O=A("./src/demux/exp-golomb.ts"),U=A("./src/demux/id3.ts"),F=A("./src/demux/sample-aes.ts"),R=A("./src/events.ts"),_=A("./src/utils/mp4-tools.ts"),v=A("./src/utils/logger.ts"),S=A("./src/errors.ts"),D={video:1,audio:2,id3:3,text:4},C=function(){function m(L,p,c){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.aacLastPTS=null,this._initPTS=null,this._initDTS=null,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=L,this.config=p,this.typeSupported=c}m.probe=function(p){var c=m.syncOffset(p);return c<0?!1:(c&&v.logger.warn("MPEG2-TS detected but first sync word found @ offset "+c+", junk ahead ?"),!0)},m.syncOffset=function(p){for(var c=Math.min(1e3,p.length-3*188),f=0;f<c;){if(p[f]===71&&p[f+188]===71&&p[f+2*188]===71)return f;f++}return-1},m.createTrack=function(p,c){return{container:p==="video"||p==="audio"?"video/mp2t":void 0,type:p,id:D[p],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:p==="audio"?c:void 0}};var h=m.prototype;return h.resetInitSegment=function(p,c,f){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=m.createTrack("video",f),this._audioTrack=m.createTrack("audio",f),this._id3Track=m.createTrack("id3",f),this._txtTrack=m.createTrack("text",f),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=p,this.videoCodec=c,this._duration=f},h.resetTimeStamp=function(){},h.resetContiguity=function(){var p=this._audioTrack,c=this._avcTrack,f=this._id3Track;p&&(p.pesData=null),c&&(c.pesData=null),f&&(f.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},h.demux=function(p,c,f,d){f===void 0&&(f=!1),d===void 0&&(d=!1),f||(this.sampleAes=null);var a,b=this._avcTrack,g=this._audioTrack,x=this._id3Track,P=b.pid,N=b.pesData,H=g.pid,X=x.pid,B=g.pesData,I=x.pesData,Y=!1,te=this.pmtParsed,se=this._pmtId,de=p.length;if(this.remainderData&&(p=Object(_.appendUint8Array)(this.remainderData,p),de=p.length,this.remainderData=null),de<188&&!d)return this.remainderData=p,{audioTrack:g,avcTrack:b,id3Track:x,textTrack:this._txtTrack};var Se=Math.max(0,m.syncOffset(p));de-=(de+Se)%188,de<p.byteLength&&!d&&(this.remainderData=new Uint8Array(p.buffer,de,p.buffer.byteLength-de));for(var ge=Se;ge<de;ge+=188)if(p[ge]===71){var pe=!!(p[ge+1]&64),he=((p[ge+1]&31)<<8)+p[ge+2],me=(p[ge+3]&48)>>4,ae=void 0;if(me>1){if(ae=ge+5+p[ge+4],ae===ge+188)continue}else ae=ge+4;switch(he){case P:pe&&(N&&(a=o(N))&&this.parseAVCPES(a,!1),N={data:[],size:0}),N&&(N.data.push(p.subarray(ae,ge+188)),N.size+=ge+188-ae);break;case H:pe&&(B&&(a=o(B))&&(g.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),B={data:[],size:0}),B&&(B.data.push(p.subarray(ae,ge+188)),B.size+=ge+188-ae);break;case X:pe&&(I&&(a=o(I))&&this.parseID3PES(a),I={data:[],size:0}),I&&(I.data.push(p.subarray(ae,ge+188)),I.size+=ge+188-ae);break;case 0:pe&&(ae+=p[ae]+1),se=this._pmtId=E(p,ae);break;case se:{pe&&(ae+=p[ae]+1);var ue=l(p,ae,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,f);P=ue.avc,P>0&&(b.pid=P),H=ue.audio,H>0&&(g.pid=H,g.isAAC=ue.isAAC),X=ue.id3,X>0&&(x.pid=X),Y&&!te&&(v.logger.log("reparse from beginning"),Y=!1,ge=Se-188),te=this.pmtParsed=!0;break}case 17:case 8191:break;default:Y=!0;break}}else this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});b.pesData=N,g.pesData=B,x.pesData=I;var xe={audioTrack:g,avcTrack:b,id3Track:x,textTrack:this._txtTrack};return d&&this.extractRemainingSamples(xe),xe},h.flush=function(){var p=this.remainderData;this.remainderData=null;var c;return p?c=this.demux(p,-1,!1,!0):c={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},h.extractRemainingSamples=function(p){var c=p.audioTrack,f=p.avcTrack,d=p.id3Track,a=f.pesData,b=c.pesData,g=d.pesData,x;a&&(x=o(a))?(this.parseAVCPES(x,!0),f.pesData=null):f.pesData=a,b&&(x=o(b))?(c.isAAC?this.parseAACPES(x):this.parseMPEGPES(x),c.pesData=null):(b!=null&&b.size&&v.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=b),g&&(x=o(g))?(this.parseID3PES(x),d.pesData=null):d.pesData=g},h.demuxSampleAes=function(p,c,f){var d=this.demux(p,f,!0,!this.config.progressive),a=this.sampleAes=new F.default(this.observer,this.config,c);return this.decrypt(d,a)},h.decrypt=function(p,c){return new Promise(function(f){var d=p.audioTrack,a=p.avcTrack;d.samples&&d.isAAC?c.decryptAacSamples(d.samples,0,function(){a.samples?c.decryptAvcSamples(a.samples,0,0,function(){f(p)}):f(p)}):a.samples&&c.decryptAvcSamples(a.samples,0,0,function(){f(p)})})},h.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},h.parseAVCPES=function(p,c){var f=this,d=this._avcTrack,a=this.parseAVCNALu(p.data),b=!1,g=this.avcSample,x,P=!1;p.data=null,g&&a.length&&!d.audFound&&(s(g,d),g=this.avcSample=T(!1,p.pts,p.dts,"")),a.forEach(function(N){switch(N.type){case 1:{x=!0,g||(g=f.avcSample=T(!0,p.pts,p.dts,"")),b&&(g.debug+="NDR "),g.frame=!0;var H=N.data;if(P&&H.length>4){var X=new O.default(H).readSliceType();(X===2||X===4||X===7||X===9)&&(g.key=!0)}break}case 5:x=!0,g||(g=f.avcSample=T(!0,p.pts,p.dts,"")),b&&(g.debug+="IDR "),g.key=!0,g.frame=!0;break;case 6:{x=!0,b&&g&&(g.debug+="SEI ");var B=new O.default(w(N.data));B.readUByte();for(var I=0,Y=0,te=!1,se=0;!te&&B.bytesAvailable>1;){I=0;do se=B.readUByte(),I+=se;while(se===255);Y=0;do se=B.readUByte(),Y+=se;while(se===255);if(I===4&&B.bytesAvailable!==0){te=!0;var de=B.readUByte();if(de===181){var Se=B.readUShort();if(Se===49){var ge=B.readUInt();if(ge===1195456820){var pe=B.readUByte();if(pe===3){for(var he=B.readUByte(),me=B.readUByte(),ae=31&he,ue=[he,me],xe=0;xe<ae;xe++)ue.push(B.readUByte()),ue.push(B.readUByte()),ue.push(B.readUByte());u(f._txtTrack.samples,{type:3,pts:p.pts,bytes:ue})}}}}}else if(I===5&&B.bytesAvailable!==0){if(te=!0,Y>16){for(var Fe=[],Re=0;Re<16;Re++)Fe.push(B.readUByte().toString(16)),(Re===3||Re===5||Re===7||Re===9)&&Fe.push("-");for(var Ie=Y-16,Ke=new Uint8Array(Ie),De=0;De<Ie;De++)Ke[De]=B.readUByte();u(f._txtTrack.samples,{pts:p.pts,payloadType:I,uuid:Fe.join(""),userData:Object(U.utf8ArrayToStr)(Ke),userDataBytes:Ke})}}else if(Y<B.bytesAvailable)for(var Ce=0;Ce<Y;Ce++)B.readUByte()}break}case 7:if(x=!0,P=!0,b&&g&&(g.debug+="SPS "),!d.sps){var Me=new O.default(N.data),Be=Me.readSPS();d.width=Be.width,d.height=Be.height,d.pixelRatio=Be.pixelRatio,d.sps=[N.data],d.duration=f._duration;for(var je=N.data.subarray(1,4),_e="avc1.",Le=0;Le<3;Le++){var $e=je[Le].toString(16);$e.length<2&&($e="0"+$e),_e+=$e}d.codec=_e}break;case 8:x=!0,b&&g&&(g.debug+="PPS "),d.pps||(d.pps=[N.data]);break;case 9:x=!1,d.audFound=!0,g&&s(g,d),g=f.avcSample=T(!1,p.pts,p.dts,b?"AUD ":"");break;case 12:x=!1;break;default:x=!1,g&&(g.debug+="unknown NAL "+N.type+" ");break}if(g&&x){var Je=g.units;Je.push(N)}}),c&&g&&(s(g,d),this.avcSample=null)},h.getLastNalUnit=function(){var p,c=this.avcSample,f;if(!c||c.units.length===0){var d=this._avcTrack.samples;c=d[d.length-1]}if((p=c)!==null&&p!==void 0&&p.units){var a=c.units;f=a[a.length-1]}return f},h.parseAVCNALu=function(p){var c=p.byteLength,f=this._avcTrack,d=f.naluState||0,a=d,b=[],g=0,x,P,N,H=-1,X=0;for(d===-1&&(H=0,X=p[0]&31,d=0,g=1);g<c;){if(x=p[g++],!d){d=x?0:1;continue}if(d===1){d=x?0:2;continue}if(!x)d=3;else if(x===1){if(H>=0){var B={data:p.subarray(H,g-d-1),type:X};b.push(B)}else{var I=this.getLastNalUnit();if(I&&(a&&g<=4-a&&(I.state&&(I.data=I.data.subarray(0,I.data.byteLength-a))),P=g-d-1,P>0)){var Y=new Uint8Array(I.data.byteLength+P);Y.set(I.data,0),Y.set(p.subarray(0,P),I.data.byteLength),I.data=Y,I.state=0}}g<c?(N=p[g]&31,H=g,X=N,d=0):d=-1}else d=0}if(H>=0&&d>=0){var te={data:p.subarray(H,c),type:X,state:d};b.push(te)}if(b.length===0){var se=this.getLastNalUnit();if(se){var de=new Uint8Array(se.data.byteLength+p.byteLength);de.set(se.data,0),de.set(p,se.data.byteLength),se.data=de}}return f.naluState=d,b},h.parseAACPES=function(p){var c=0,f=this._audioTrack,d=this.aacOverFlow,a=p.data;if(d){this.aacOverFlow=null;var b=d.sample.unit.byteLength,g=Math.min(d.missing,b),x=b-g;d.sample.unit.set(a.subarray(0,g),x),f.samples.push(d.sample),c=d.missing}var P,N;for(P=c,N=a.length;P<N-1&&!W.isHeader(a,P);P++);if(P!==c){var H,X;if(P<N-1?(H="AAC PES did not start with ADTS header,offset:"+P,X=!1):(H="no ADTS header found in AAC PES",X=!0),v.logger.warn("parsing error:"+H),this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.FRAG_PARSING_ERROR,fatal:X,reason:H}),X)return}W.initTrackConfig(f,this.observer,a,P,this.audioCodec);var B;if(p.pts!==void 0)B=p.pts;else if(d){var I=W.getFrameDuration(f.samplerate);B=d.sample.pts+I}else{v.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var Y=0;P<N;)if(W.isHeader(a,P)){if(P+5<N){var te=W.appendFrame(f,a,P,B,Y);if(te)if(te.missing)this.aacOverFlow=te;else{P+=te.length,Y++;continue}}break}else P++},h.parseMPEGPES=function(p){var c=p.data,f=c.length,d=0,a=0,b=p.pts;if(b===void 0){v.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<f;)if(k.isHeader(c,a)){var g=k.appendFrame(this._audioTrack,c,a,b,d);if(g)a+=g.length,d++;else break}else a++},h.parseID3PES=function(p){if(p.pts===void 0){v.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(p)},m}();C.minProbeByteLength=188;function T(m,h,L,p){return{key:m,frame:!1,pts:h,dts:L,units:[],debug:p,length:0}}function E(m,h){return(m[h+10]&31)<<8|m[h+11]}function l(m,h,L,p){var c={audio:-1,avc:-1,id3:-1,isAAC:!0},f=(m[h+1]&15)<<8|m[h+2],d=h+3+f-4,a=(m[h+10]&15)<<8|m[h+11];for(h+=12+a;h<d;){var b=(m[h+1]&31)<<8|m[h+2];switch(m[h]){case 207:if(!p){v.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=b);break;case 21:c.id3===-1&&(c.id3=b);break;case 219:if(!p){v.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=b);break;case 3:case 4:L?c.audio===-1&&(c.audio=b,c.isAAC=!1):v.logger.log("MPEG audio found, not supported in this browser");break;case 36:v.logger.warn("Unsupported HEVC stream type found");break;default:break}h+=((m[h+3]&15)<<8|m[h+4])+5}return c}function o(m){var h=0,L,p,c,f,d,a=m.data;if(!m||m.size===0)return null;for(;a[0].length<19&&a.length>1;){var b=new Uint8Array(a[0].length+a[1].length);b.set(a[0]),b.set(a[1],a[0].length),a[0]=b,a.splice(1,1)}L=a[0];var g=(L[0]<<16)+(L[1]<<8)+L[2];if(g===1){if(p=(L[4]<<8)+L[5],p&&p>m.size-6)return null;var x=L[7];x&192&&(f=(L[9]&14)*536870912+(L[10]&255)*4194304+(L[11]&254)*16384+(L[12]&255)*128+(L[13]&254)/2,x&64?(d=(L[14]&14)*536870912+(L[15]&255)*4194304+(L[16]&254)*16384+(L[17]&255)*128+(L[18]&254)/2,f-d>60*9e4&&(v.logger.warn(Math.round((f-d)/9e4)+"s delta between PTS and DTS, align them"),f=d)):d=f),c=L[8];var P=c+9;if(m.size<=P)return null;m.size-=P;for(var N=new Uint8Array(m.size),H=0,X=a.length;H<X;H++){L=a[H];var B=L.byteLength;if(P)if(P>B){P-=B;continue}else L=L.subarray(P),B-=P,P=0;N.set(L,h),h+=B}return p&&(p-=c+3),{data:N,pts:f,dts:d,len:p}}return null}function s(m,h){if(m.units.length&&m.frame){if(m.pts===void 0){var L=h.samples,p=L.length;if(p){var c=L[p-1];m.pts=c.pts,m.dts=c.dts}else{h.dropped++;return}}h.samples.push(m)}m.debug.length&&v.logger.log(m.pts+"/"+m.dts+":"+m.debug)}function u(m,h){var L=m.length;if(L>0){if(h.pts>=m[L-1].pts)m.push(h);else for(var p=L-1;p>=0;p--)if(h.pts<m[p].pts){m.splice(p,0,h);break}}else m.push(h)}function w(m){for(var h=m.byteLength,L=[],p=1;p<h-2;)m[p]===0&&m[p+1]===0&&m[p+2]===3?(L.push(p+2),p+=2):p++;if(L.length===0)return m;var c=h-L.length,f=new Uint8Array(c),d=0;for(p=0;p<c;d++,p++)d===L[0]&&(d++,L.shift()),f[p]=m[d];return f}G.default=C},"./src/errors.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"ErrorTypes",function(){return W}),A.d(G,"ErrorDetails",function(){return k});var W;(function(O){O.NETWORK_ERROR="networkError",O.MEDIA_ERROR="mediaError",O.KEY_SYSTEM_ERROR="keySystemError",O.MUX_ERROR="muxError",O.OTHER_ERROR="otherError"})(W||(W={}));var k;(function(O){O.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",O.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",O.KEY_SYSTEM_NO_SESSION="keySystemNoSession",O.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",O.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",O.MANIFEST_LOAD_ERROR="manifestLoadError",O.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",O.MANIFEST_PARSING_ERROR="manifestParsingError",O.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",O.LEVEL_EMPTY_ERROR="levelEmptyError",O.LEVEL_LOAD_ERROR="levelLoadError",O.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",O.LEVEL_SWITCH_ERROR="levelSwitchError",O.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",O.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",O.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",O.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",O.FRAG_LOAD_ERROR="fragLoadError",O.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",O.FRAG_DECRYPT_ERROR="fragDecryptError",O.FRAG_PARSING_ERROR="fragParsingError",O.REMUX_ALLOC_ERROR="remuxAllocError",O.KEY_LOAD_ERROR="keyLoadError",O.KEY_LOAD_TIMEOUT="keyLoadTimeOut",O.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",O.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",O.BUFFER_APPEND_ERROR="bufferAppendError",O.BUFFER_APPENDING_ERROR="bufferAppendingError",O.BUFFER_STALLED_ERROR="bufferStalledError",O.BUFFER_FULL_ERROR="bufferFullError",O.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",O.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",O.INTERNAL_EXCEPTION="internalException",O.INTERNAL_ABORTED="aborted",O.UNKNOWN="unknown"})(k||(k={}))},"./src/events.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"Events",function(){return W});var W;(function(k){k.MEDIA_ATTACHING="hlsMediaAttaching",k.MEDIA_ATTACHED="hlsMediaAttached",k.MEDIA_DETACHING="hlsMediaDetaching",k.MEDIA_DETACHED="hlsMediaDetached",k.BUFFER_RESET="hlsBufferReset",k.BUFFER_CODECS="hlsBufferCodecs",k.BUFFER_CREATED="hlsBufferCreated",k.BUFFER_APPENDING="hlsBufferAppending",k.BUFFER_APPENDED="hlsBufferAppended",k.BUFFER_EOS="hlsBufferEos",k.BUFFER_FLUSHING="hlsBufferFlushing",k.BUFFER_FLUSHED="hlsBufferFlushed",k.MANIFEST_LOADING="hlsManifestLoading",k.MANIFEST_LOADED="hlsManifestLoaded",k.MANIFEST_PARSED="hlsManifestParsed",k.LEVEL_SWITCHING="hlsLevelSwitching",k.LEVEL_SWITCHED="hlsLevelSwitched",k.LEVEL_LOADING="hlsLevelLoading",k.LEVEL_LOADED="hlsLevelLoaded",k.LEVEL_UPDATED="hlsLevelUpdated",k.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",k.LEVELS_UPDATED="hlsLevelsUpdated",k.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",k.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",k.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",k.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",k.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",k.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",k.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",k.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",k.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",k.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",k.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",k.CUES_PARSED="hlsCuesParsed",k.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",k.INIT_PTS_FOUND="hlsInitPtsFound",k.FRAG_LOADING="hlsFragLoading",k.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",k.FRAG_LOADED="hlsFragLoaded",k.FRAG_DECRYPTED="hlsFragDecrypted",k.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",k.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",k.FRAG_PARSING_METADATA="hlsFragParsingMetadata",k.FRAG_PARSED="hlsFragParsed",k.FRAG_BUFFERED="hlsFragBuffered",k.FRAG_CHANGED="hlsFragChanged",k.FPS_DROP="hlsFpsDrop",k.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",k.ERROR="hlsError",k.DESTROYING="hlsDestroying",k.KEY_LOADING="hlsKeyLoading",k.KEY_LOADED="hlsKeyLoaded",k.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",k.BACK_BUFFER_REACHED="hlsBackBufferReached"})(W||(W={}))},"./src/hls.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return m});var W=A("./node_modules/url-toolkit/src/url-toolkit.js"),k=A.n(W),O=A("./src/loader/playlist-loader.ts"),U=A("./src/loader/key-loader.ts"),F=A("./src/controller/id3-track-controller.ts"),R=A("./src/controller/latency-controller.ts"),_=A("./src/controller/level-controller.ts"),v=A("./src/controller/fragment-tracker.ts"),S=A("./src/controller/stream-controller.ts"),D=A("./src/is-supported.ts"),C=A("./src/utils/logger.ts"),T=A("./src/config.ts"),E=A("./node_modules/eventemitter3/index.js"),l=A.n(E),o=A("./src/events.ts"),s=A("./src/errors.ts");function u(h,L){for(var p=0;p<L.length;p++){var c=L[p];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(h,c.key,c)}}function w(h,L,p){return L&&u(h.prototype,L),p&&u(h,p),h}var m=function(){h.isSupported=function(){return Object(D.isSupported)()};function h(p){p===void 0&&(p={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new E.EventEmitter,this._autoLevelCapping=void 0,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 c=this.config=Object(T.mergeConfig)(h.DefaultConfig,p);this.userConfig=p,Object(C.enableLogs)(c.debug),this._autoLevelCapping=-1,c.progressive&&Object(T.enableStreamingMode)(c);var f=c.abrController,d=c.bufferController,a=c.capLevelController,b=c.fpsController,g=this.abrController=new f(this),x=this.bufferController=new d(this),P=this.capLevelController=new a(this),N=new b(this),H=new O.default(this),X=new U.default(this),B=new F.default(this),I=this.levelController=new _.default(this),Y=new v.FragmentTracker(this),te=this.streamController=new S.default(this,Y);P.setStreamController(te),N.setStreamController(te);var se=[I,te];this.networkControllers=se;var de=[H,X,g,x,P,N,B,Y];this.audioTrackController=this.createController(c.audioTrackController,null,se),this.createController(c.audioStreamController,Y,se),this.subtitleTrackController=this.createController(c.subtitleTrackController,null,se),this.createController(c.subtitleStreamController,Y,se),this.createController(c.timelineController,null,de),this.emeController=this.createController(c.emeController,null,de),this.cmcdController=this.createController(c.cmcdController,null,de),this.latencyController=this.createController(R.default,null,de),this.coreComponents=de}var L=h.prototype;return L.createController=function(c,f,d){if(c){var a=f?new c(this,f):new c(this);return d&&d.push(a),a}return null},L.on=function(c,f,d){d===void 0&&(d=this),this._emitter.on(c,f,d)},L.once=function(c,f,d){d===void 0&&(d=this),this._emitter.once(c,f,d)},L.removeAllListeners=function(c){this._emitter.removeAllListeners(c)},L.off=function(c,f,d,a){d===void 0&&(d=this),this._emitter.off(c,f,d,a)},L.listeners=function(c){return this._emitter.listeners(c)},L.emit=function(c,f,d){return this._emitter.emit(c,f,d)},L.trigger=function(c,f){if(this.config.debug)return this.emit(c,c,f);try{return this.emit(c,c,f)}catch(d){C.logger.error("An internal error happened while handling event "+c+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(o.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:c,error:d})}return!1},L.listenerCount=function(c){return this._emitter.listenerCount(c)},L.destroy=function(){C.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(c){return c.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(c){return c.destroy()}),this.coreComponents.length=0},L.attachMedia=function(c){C.logger.log("attachMedia"),this._media=c,this.trigger(o.Events.MEDIA_ATTACHING,{media:c})},L.detachMedia=function(){C.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},L.loadSource=function(c){this.stopLoad();var f=this.media,d=this.url,a=this.url=W.buildAbsoluteURL(self.location.href,c,{alwaysNormalize:!0});C.logger.log("loadSource:"+a),f&&d&&d!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(f)),this.trigger(o.Events.MANIFEST_LOADING,{url:c})},L.startLoad=function(c){c===void 0&&(c=-1),C.logger.log("startLoad("+c+")"),this.networkControllers.forEach(function(f){f.startLoad(c)})},L.stopLoad=function(){C.logger.log("stopLoad"),this.networkControllers.forEach(function(c){c.stopLoad()})},L.swapAudioCodec=function(){C.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},L.recoverMediaError=function(){C.logger.log("recoverMediaError");var c=this._media;this.detachMedia(),c&&this.attachMedia(c)},L.removeLevel=function(c,f){f===void 0&&(f=0),this.levelController.removeLevel(c,f)},w(h,[{key:"levels",get:function(){var c=this.levelController.levels;return c||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(c){C.logger.log("set currentLevel:"+c),this.loadLevel=c,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(c){C.logger.log("set nextLevel:"+c),this.levelController.manualLevel=c,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(c){C.logger.log("set loadLevel:"+c),this.levelController.manualLevel=c}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(c){this.levelController.nextLoadLevel=c}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(c){C.logger.log("set firstLevel:"+c),this.levelController.firstLevel=c}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(c){C.logger.log("set startLevel:"+c),c!==-1&&(c=Math.max(c,this.minAutoLevel)),this.levelController.startLevel=c}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(c){var f=!!c;f!==this.config.capLevelToPlayerSize&&(f?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=f)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(c){this._autoLevelCapping!==c&&(C.logger.log("set autoLevelCapping:"+c),this._autoLevelCapping=c)}},{key:"bandwidthEstimate",get:function(){var c=this.abrController.bwEstimator;return c?c.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var c=this.levels,f=this.config.minAutoBitrate;if(!c)return 0;for(var d=c.length,a=0;a<d;a++)if(c[a].maxBitrate>f)return a;return 0}},{key:"maxAutoLevel",get:function(){var c=this.levels,f=this.autoLevelCapping,d;return f===-1&&c&&c.length?d=c.length-1:d=f,d}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(c){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,c)}},{key:"audioTracks",get:function(){var c=this.audioTrackController;return c?c.audioTracks:[]}},{key:"audioTrack",get:function(){var c=this.audioTrackController;return c?c.audioTrack:-1},set:function(c){var f=this.audioTrackController;f&&(f.audioTrack=c)}},{key:"subtitleTracks",get:function(){var c=this.subtitleTrackController;return c?c.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var c=this.subtitleTrackController;return c?c.subtitleTrack:-1},set:function(c){var f=this.subtitleTrackController;f&&(f.subtitleTrack=c)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var c=this.subtitleTrackController;return c?c.subtitleDisplay:!1},set:function(c){var f=this.subtitleTrackController;f&&(f.subtitleDisplay=c)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(c){this.config.lowLatencyMode=c}},{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.1.2"}},{key:"Events",get:function(){return o.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return h.defaultConfig?h.defaultConfig:T.hlsDefaultConfig},set:function(c){h.defaultConfig=c}}]),h}();m.defaultConfig=void 0},"./src/is-supported.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"isSupported",function(){return O}),A.d(G,"changeTypeSupported",function(){return U});var W=A("./src/utils/mediasource-helper.ts");function k(){return self.SourceBuffer||self.WebKitSourceBuffer}function O(){var F=Object(W.getMediaSource)();if(!F)return!1;var R=k(),_=F&&typeof F.isTypeSupported=="function"&&F.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),v=!R||R.prototype&&typeof R.prototype.appendBuffer=="function"&&typeof R.prototype.remove=="function";return!!_&&!!v}function U(){var F,R=k();return typeof(R==null||((F=R.prototype)===null||F===void 0)?void 0:F.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return C}),A.d(G,"LoadError",function(){return E});var W=A("./src/polyfills/number.ts"),k=A("./src/errors.ts");function O(l,o){l.prototype=Object.create(o.prototype),l.prototype.constructor=l,v(l,o)}function U(l){var o=typeof Map=="function"?new Map:void 0;return U=function(u){if(u===null||!_(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(u))return o.get(u);o.set(u,w)}function w(){return F(u,arguments,S(this).constructor)}return w.prototype=Object.create(u.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),v(w,u)},U(l)}function F(l,o,s){return R()?F=Reflect.construct:F=function(w,m,h){var L=[null];L.push.apply(L,m);var p=Function.bind.apply(w,L),c=new p;return h&&v(c,h.prototype),c},F.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(l){return!1}}function _(l){return Function.toString.call(l).indexOf("[native code]")!==-1}function v(l,o){return v=Object.setPrototypeOf||function(u,w){return u.__proto__=w,u},v(l,o)}function S(l){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},S(l)}var D=Math.pow(2,17),C=function(){function l(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var o=l.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(u,w){var m=this,h=u.url;if(!h)return Promise.reject(new E({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,networkDetails:null},"Fragment does not have a "+(h?"part list":"url")));this.abort();var L=this.config,p=L.fLoader,c=L.loader;return new Promise(function(f,d){m.loader&&m.loader.destroy();var a=m.loader=u.loader=p?new p(L):new c(L),b=T(u),g={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:D};u.stats=a.stats,a.load(b,g,{onSuccess:function(P,N,H,X){m.resetLoader(u,a),f({frag:u,part:null,payload:P.data,networkDetails:X})},onError:function(P,N,H){m.resetLoader(u,a),d(new E({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,response:P,networkDetails:H}))},onAbort:function(P,N,H){m.resetLoader(u,a),d(new E({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,networkDetails:H}))},onTimeout:function(P,N,H){m.resetLoader(u,a),d(new E({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,networkDetails:H}))},onProgress:function(P,N,H,X){w&&w({frag:u,part:null,payload:H,networkDetails:X})}})})},o.loadPart=function(u,w,m){var h=this;this.abort();var L=this.config,p=L.fLoader,c=L.loader;return new Promise(function(f,d){h.loader&&h.loader.destroy();var a=h.loader=u.loader=p?new p(L):new c(L),b=T(u,w),g={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:D};w.stats=a.stats,a.load(b,g,{onSuccess:function(P,N,H,X){h.resetLoader(u,a),h.updateStatsFromPart(u,w);var B={frag:u,part:w,payload:P.data,networkDetails:X};m(B),f(B)},onError:function(P,N,H){h.resetLoader(u,a),d(new E({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:u,part:w,response:P,networkDetails:H}))},onAbort:function(P,N,H){u.stats.aborted=w.stats.aborted,h.resetLoader(u,a),d(new E({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:u,part:w,networkDetails:H}))},onTimeout:function(P,N,H){h.resetLoader(u,a),d(new E({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:u,part:w,networkDetails:H}))}})})},o.updateStatsFromPart=function(u,w){var m=u.stats,h=w.stats,L=h.total;if(m.loaded+=h.loaded,L){var p=Math.round(u.duration/w.duration),c=Math.min(Math.round(m.loaded/L),p),f=p-c,d=f*Math.round(m.loaded/c);m.total=m.loaded+d}else m.total=Math.max(m.loaded,m.total);var a=m.loading,b=h.loading;a.start?a.first+=b.first-b.start:(a.start=b.start,a.first=b.first),a.end=b.end},o.resetLoader=function(u,w){u.loader=null,this.loader===w&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),w.destroy()},l}();function T(l,o){o===void 0&&(o=null);var s=o||l,u={frag:l,part:o,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},w=s.byteRangeStartOffset,m=s.byteRangeEndOffset;return Object(W.isFiniteNumber)(w)&&Object(W.isFiniteNumber)(m)&&(u.rangeStart=w,u.rangeEnd=m),u}var E=function(l){O(o,l);function o(s){for(var u,w=arguments.length,m=new Array(w>1?w-1:0),h=1;h<w;h++)m[h-1]=arguments[h];return u=l.call.apply(l,[this].concat(m))||this,u.data=void 0,u.data=s,u}return o}(U(Error))},"./src/loader/fragment.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"ElementaryStreamTypes",function(){return C}),A.d(G,"BaseSegment",function(){return T}),A.d(G,"Fragment",function(){return E}),A.d(G,"Part",function(){return l});var W=A("./src/polyfills/number.ts"),k=A("./node_modules/url-toolkit/src/url-toolkit.js"),O=A.n(k),U=A("./src/utils/logger.ts"),F=A("./src/loader/level-key.ts"),R=A("./src/loader/load-stats.ts");function _(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,v(o,s)}function v(o,s){return v=Object.setPrototypeOf||function(w,m){return w.__proto__=m,w},v(o,s)}function S(o,s){for(var u=0;u<s.length;u++){var w=s[u];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(o,w.key,w)}}function D(o,s,u){return s&&S(o.prototype,s),u&&S(o,u),o}var C;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(C||(C={}));var T=function(){function o(u){var w;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(w={},w[C.AUDIO]=null,w[C.VIDEO]=null,w[C.AUDIOVIDEO]=null,w),this.baseurl=u}var s=o.prototype;return s.setByteRange=function(w,m){var h=w.split("@",2),L=[];h.length===1?L[0]=m?m.byteRangeEndOffset:0:L[0]=parseInt(h[1]),L[1]=parseInt(h[0])+L[0],this._byteRange=L},D(o,[{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=Object(k.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(w){this._url=w}}]),o}(),E=function(o){_(s,o);function s(w,m){var h;return h=o.call(this,m)||this,h._decryptdata=null,h.rawProgramDateTime=null,h.programDateTime=null,h.tagList=[],h.duration=0,h.sn=0,h.levelkey=void 0,h.type=void 0,h.loader=null,h.level=-1,h.cc=0,h.startPTS=void 0,h.endPTS=void 0,h.appendedPTS=void 0,h.startDTS=void 0,h.endDTS=void 0,h.start=0,h.deltaPTS=void 0,h.maxStartPTS=void 0,h.minEndPTS=void 0,h.stats=new R.LoadStats,h.urlId=0,h.data=void 0,h.bitrateTest=!1,h.title=null,h.initSegment=null,h.type=w,h}var u=s.prototype;return u.createInitializationVector=function(m){for(var h=new Uint8Array(16),L=12;L<16;L++)h[L]=m>>8*(15-L)&255;return h},u.setDecryptDataFromLevelKey=function(m,h){var L=m;return(m==null?void 0:m.method)==="AES-128"&&m.uri&&!m.iv&&(L=F.LevelKey.fromURI(m.uri),L.method=m.method,L.iv=this.createInitializationVector(h),L.keyFormat="identity"),L},u.setElementaryStreamInfo=function(m,h,L,p,c,f){f===void 0&&(f=!1);var d=this.elementaryStreams,a=d[m];if(!a){d[m]={startPTS:h,endPTS:L,startDTS:p,endDTS:c,partial:f};return}a.startPTS=Math.min(a.startPTS,h),a.endPTS=Math.max(a.endPTS,L),a.startDTS=Math.min(a.startDTS,p),a.endDTS=Math.max(a.endDTS,c)},u.clearElementaryStreamInfo=function(){var m=this.elementaryStreams;m[C.AUDIO]=null,m[C.VIDEO]=null,m[C.AUDIOVIDEO]=null},D(s,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var m=this.sn;typeof m!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&U.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),m=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,m)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(W.isFiniteNumber)(this.programDateTime))return null;var m=Object(W.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+m*1e3}},{key:"encrypted",get:function(){var m;return!!((m=this.decryptdata)!==null&&m!==void 0&&m.keyFormat&&this.decryptdata.uri)}}]),s}(T),l=function(o){_(s,o);function s(u,w,m,h,L){var p;p=o.call(this,m)||this,p.fragOffset=0,p.duration=0,p.gap=!1,p.independent=!1,p.relurl=void 0,p.fragment=void 0,p.index=void 0,p.stats=new R.LoadStats,p.duration=u.decimalFloatingPoint("DURATION"),p.gap=u.bool("GAP"),p.independent=u.bool("INDEPENDENT"),p.relurl=u.enumeratedString("URI"),p.fragment=w,p.index=h;var c=u.enumeratedString("BYTERANGE");return c&&p.setByteRange(c,L),L&&(p.fragOffset=L.fragOffset+L.duration),p}return D(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var w=this.elementaryStreams;return!!(w.audio||w.video||w.audiovideo)}}]),s}(T)},"./src/loader/key-loader.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return U});var W=A("./src/events.ts"),k=A("./src/errors.ts"),O=A("./src/utils/logger.ts"),U=function(){function F(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this._registerListeners()}var R=F.prototype;return R._registerListeners=function(){this.hls.on(W.Events.KEY_LOADING,this.onKeyLoading,this)},R._unregisterListeners=function(){this.hls.off(W.Events.KEY_LOADING,this.onKeyLoading)},R.destroy=function(){this._unregisterListeners();for(var v in this.loaders){var S=this.loaders[v];S&&S.destroy()}this.loaders={}},R.onKeyLoading=function(v,S){var D=S.frag,C=D.type,T=this.loaders[C];if(!D.decryptdata){O.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var E=D.decryptdata.uri;if(E!==this.decrypturl||this.decryptkey===null){var l=this.hls.config;if(T&&(O.logger.warn("abort previous key loader for type:"+C),T.abort()),!E){O.logger.warn("key uri is falsy");return}var o=l.loader,s=D.loader=this.loaders[C]=new o(l);this.decrypturl=E,this.decryptkey=null;var u={url:E,frag:D,responseType:"arraybuffer"},w={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(u,w,m)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(W.Events.KEY_LOADED,{frag:D}))},R.loadsuccess=function(v,S,D){var C=D.frag;if(!C.decryptdata){O.logger.error("after key load, decryptdata unset");return}this.decryptkey=C.decryptdata.key=new Uint8Array(v.data),C.loader=null,delete this.loaders[C.type],this.hls.trigger(W.Events.KEY_LOADED,{frag:C})},R.loaderror=function(v,S){var D=S.frag,C=D.loader;C&&C.abort(),delete this.loaders[D.type],this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:v})},R.loadtimeout=function(v,S){var D=S.frag,C=D.loader;C&&C.abort(),delete this.loaders[D.type],this.hls.trigger(W.Events.ERROR,{type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},F}()},"./src/loader/level-details.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"LevelDetails",function(){return F});var W=A("./src/polyfills/number.ts");function k(R,_){for(var v=0;v<_.length;v++){var S=_[v];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(R,S.key,S)}}function O(R,_,v){return _&&k(R.prototype,_),v&&k(R,v),R}var U=10,F=function(){function R(v){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.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,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.fragments=[],this.url=v}var _=R.prototype;return _.reloaded=function(S){if(!S){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-S.lastPartSn,C=this.lastPartIndex-S.lastPartIndex;this.updated=this.endSN!==S.endSN||!!C||!!D,this.advanced=this.endSN>S.endSN||D>0||D===0&&C>0,this.updated||this.advanced?this.misses=Math.floor(S.misses*.6):this.misses=S.misses+1,this.availabilityDelay=S.availabilityDelay},O(R,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(W.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||U}},{key:"drift",get:function(){var S=this.driftEndTime-this.driftStartTime;if(S>0){var D=this.driftEnd-this.driftStart;return D*1e3/S}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var S;return(S=this.partList)!==null&&S!==void 0&&S.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var S;return(S=this.fragments)!==null&&S!==void 0&&S.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 S;return(S=this.partList)!==null&&S!==void 0&&S.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var S;return(S=this.partList)!==null&&S!==void 0&&S.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),R}()},"./src/loader/level-key.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"LevelKey",function(){return F});var W=A("./node_modules/url-toolkit/src/url-toolkit.js"),k=A.n(W);function O(R,_){for(var v=0;v<_.length;v++){var S=_[v];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(R,S.key,S)}}function U(R,_,v){return _&&O(R.prototype,_),v&&O(R,v),R}var F=function(){R.fromURL=function(v,S){return new R(v,S)},R.fromURI=function(v){return new R(v)};function R(_,v){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,v?this._uri=Object(W.buildAbsoluteURL)(_,v,{alwaysNormalize:!0}):this._uri=_}return U(R,[{key:"uri",get:function(){return this._uri}}]),R}()},"./src/loader/load-stats.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"LoadStats",function(){return 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":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return s});var W=A("./src/polyfills/number.ts"),k=A("./node_modules/url-toolkit/src/url-toolkit.js"),O=A.n(k),U=A("./src/loader/fragment.ts"),F=A("./src/loader/level-details.ts"),R=A("./src/loader/level-key.ts"),_=A("./src/utils/attr-list.ts"),v=A("./src/utils/logger.ts"),S=A("./src/utils/codecs.ts"),D=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,C=/#EXT-X-MEDIA:(.*)/g,T=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),E=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),l=/\.(mp4|m4s|m4v|m4a)$/i;function o(L){var p,c;return l.test((p=(c=k.parseURL(L))===null||c===void 0?void 0:c.path)!=null?p:"")}var s=function(){function L(){}return L.findGroup=function(c,f){for(var d=0;d<c.length;d++){var a=c[d];if(a.id===f)return a}},L.convertAVC1ToAVCOTI=function(c){var f=c.split(".");if(f.length>2){var d=f.shift()+".";return d+=parseInt(f.shift()).toString(16),d+=("000"+parseInt(f.shift()).toString(16)).substr(-4),d}return c},L.resolve=function(c,f){return k.buildAbsoluteURL(f,c,{alwaysNormalize:!0})},L.parseMasterPlaylist=function(c,f){var d=[],a={},b=!1;D.lastIndex=0;for(var g;(g=D.exec(c))!=null;)if(g[1]){var x=new _.AttrList(g[1]),P={attrs:x,bitrate:x.decimalInteger("AVERAGE-BANDWIDTH")||x.decimalInteger("BANDWIDTH"),name:x.NAME,url:L.resolve(g[2],f)},N=x.decimalResolution("RESOLUTION");N&&(P.width=N.width,P.height=N.height),u((x.CODECS||"").split(/[ ,]+/).filter(function(X){return X}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=L.convertAVC1ToAVCOTI(P.videoCodec)),d.push(P)}else if(g[3]){var H=new _.AttrList(g[3]);H["DATA-ID"]&&(b=!0,a[H["DATA-ID"]]=H)}return{levels:d,sessionData:b?a:null}},L.parseMasterPlaylistMedia=function(c,f,d,a){a===void 0&&(a=[]);var b,g=[],x=0;for(C.lastIndex=0;(b=C.exec(c))!==null;){var P=new _.AttrList(b[1]);if(P.TYPE===d){var N={attrs:P,bitrate:0,id:x++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:d,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?L.resolve(P.URI,f):""};if(a.length){var H=L.findGroup(a,N.groupId)||a[0];w(N,H,"audioCodec"),w(N,H,"textCodec")}g.push(N)}}return g},L.parseLevelPlaylist=function(c,f,d,a,b){var g=new F.LevelDetails(f),x=g.fragments,P=null,N=0,H=0,X=0,B=0,I=null,Y=new U.Fragment(a,f),te,se,de,Se=-1,ge=!1;for(T.lastIndex=0,g.m3u8=c;(te=T.exec(c))!==null;){ge&&(ge=!1,Y=new U.Fragment(a,f),Y.start=X,Y.sn=N,Y.cc=B,Y.level=d,P&&(Y.initSegment=P,Y.rawProgramDateTime=P.rawProgramDateTime));var pe=te[1];if(pe){Y.duration=parseFloat(pe);var he=(" "+te[2]).slice(1);Y.title=he||null,Y.tagList.push(he?["INF",pe,he]:["INF",pe])}else if(te[3])Object(W.isFiniteNumber)(Y.duration)&&(Y.start=X,de&&(Y.levelkey=de),Y.sn=N,Y.level=d,Y.cc=B,Y.urlId=b,x.push(Y),Y.relurl=(" "+te[3]).slice(1),h(Y,I),I=Y,X+=Y.duration,N++,H=0,ge=!0);else if(te[4]){var me=(" "+te[4]).slice(1);I?Y.setByteRange(me,I):Y.setByteRange(me)}else if(te[5])Y.rawProgramDateTime=(" "+te[5]).slice(1),Y.tagList.push(["PROGRAM-DATE-TIME",Y.rawProgramDateTime]),Se===-1&&(Se=x.length);else{if(te=te[0].match(E),!te){v.logger.warn("No matches on slow regex match for level playlist!");continue}for(se=1;se<te.length&&!(typeof te[se]!="undefined");se++);var ae=(" "+te[se]).slice(1),ue=(" "+te[se+1]).slice(1),xe=te[se+2]?(" "+te[se+2]).slice(1):"";switch(ae){case"PLAYLIST-TYPE":g.type=ue.toUpperCase();break;case"MEDIA-SEQUENCE":N=g.startSN=parseInt(ue);break;case"SKIP":{var Fe=new _.AttrList(ue),Re=Fe.decimalInteger("SKIPPED-SEGMENTS");if(Object(W.isFiniteNumber)(Re)){g.skippedSegments=Re;for(var Ie=Re;Ie--;)x.unshift(null);N+=Re}var Ke=Fe.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ke&&(g.recentlyRemovedDateranges=Ke.split(" "));break}case"TARGETDURATION":g.targetduration=parseFloat(ue);break;case"VERSION":g.version=parseInt(ue);break;case"EXTM3U":break;case"ENDLIST":g.live=!1;break;case"#":(ue||xe)&&Y.tagList.push(xe?[ue,xe]:[ue]);break;case"DIS":B++;case"GAP":Y.tagList.push([ae]);break;case"BITRATE":Y.tagList.push([ae,ue]);break;case"DISCONTINUITY-SEQ":B=parseInt(ue);break;case"KEY":{var De,Ce=new _.AttrList(ue),Me=Ce.enumeratedString("METHOD"),Be=Ce.URI,je=Ce.hexadecimalInteger("IV"),_e=Ce.enumeratedString("KEYFORMATVERSIONS"),Le=Ce.enumeratedString("KEYID"),$e=(De=Ce.enumeratedString("KEYFORMAT"))!=null?De:"identity",Je=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Je.indexOf($e)>-1){v.logger.warn("Keyformat "+$e+" is not supported from the manifest");continue}else if($e!=="identity")continue;Me&&(de=R.LevelKey.fromURL(f,Be),Be&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Me)>=0&&(de.method=Me,de.keyFormat=$e,Le&&(de.keyID=Le),_e&&(de.keyFormatVersions=_e),de.iv=je));break}case"START":{var We=new _.AttrList(ue),He=We.decimalFloatingPoint("TIME-OFFSET");Object(W.isFiniteNumber)(He)&&(g.startTimeOffset=He);break}case"MAP":{var et=new _.AttrList(ue);Y.relurl=et.URI,et.BYTERANGE&&Y.setByteRange(et.BYTERANGE),Y.level=d,Y.sn="initSegment",de&&(Y.levelkey=de),Y.initSegment=null,P=Y,ge=!0;break}case"SERVER-CONTROL":{var Ye=new _.AttrList(ue);g.canBlockReload=Ye.bool("CAN-BLOCK-RELOAD"),g.canSkipUntil=Ye.optionalFloat("CAN-SKIP-UNTIL",0),g.canSkipDateRanges=g.canSkipUntil>0&&Ye.bool("CAN-SKIP-DATERANGES"),g.partHoldBack=Ye.optionalFloat("PART-HOLD-BACK",0),g.holdBack=Ye.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Ve=new _.AttrList(ue);g.partTarget=Ve.decimalFloatingPoint("PART-TARGET");break}case"PART":{var be=g.partList;be||(be=g.partList=[]);var Ze=H>0?be[be.length-1]:void 0,Ge=H++,ve=new U.Part(new _.AttrList(ue),Y,f,Ge,Ze);be.push(ve),Y.duration+=ve.duration;break}case"PRELOAD-HINT":{var Ee=new _.AttrList(ue);g.preloadHint=Ee;break}case"RENDITION-REPORT":{var oe=new _.AttrList(ue);g.renditionReports=g.renditionReports||[],g.renditionReports.push(oe);break}default:v.logger.warn("line parsed but not handled: "+te);break}}}I&&!I.relurl?(x.pop(),X-=I.duration,g.partList&&(g.fragmentHint=I)):g.partList&&(h(Y,I),Y.cc=B,g.fragmentHint=Y);var ee=x.length,re=x[0],V=x[ee-1];if(X+=g.skippedSegments*g.targetduration,X>0&&ee&&V){g.averagetargetduration=X/ee;var $=V.sn;g.endSN=$!=="initSegment"?$:0,re&&(g.startCC=re.cc,re.initSegment||g.fragments.every(function(J){return J.relurl&&o(J.relurl)})&&(v.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),Y=new U.Fragment(a,f),Y.relurl=V.relurl,Y.level=d,Y.sn="initSegment",re.initSegment=Y,g.needSidxRanges=!0))}else g.endSN=0,g.startCC=0;return g.fragmentHint&&(X+=g.fragmentHint.duration),g.totalduration=X,g.endCC=B,Se>0&&m(x,Se),g},L}();function u(L,p){["video","audio","text"].forEach(function(c){var f=L.filter(function(a){return Object(S.isCodecType)(a,c)});if(f.length){var d=f.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});p[c+"Codec"]=d.length>0?d[0]:f[0],L=L.filter(function(a){return f.indexOf(a)===-1})}}),p.unknownCodecs=L}function w(L,p,c){var f=p[c];f&&(L[c]=f)}function m(L,p){for(var c=L[p],f=p;f--;){var d=L[f];if(!d)return;d.programDateTime=c.programDateTime-d.duration*1e3,c=d}}function h(L,p){L.rawProgramDateTime?L.programDateTime=Date.parse(L.rawProgramDateTime):p!=null&&p.programDateTime&&(L.programDateTime=p.endProgramDateTime),Object(W.isFiniteNumber)(L.programDateTime)||(L.programDateTime=null,L.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/polyfills/number.ts"),k=A("./src/events.ts"),O=A("./src/errors.ts"),U=A("./src/utils/logger.ts"),F=A("./src/utils/mp4-tools.ts"),R=A("./src/loader/m3u8-parser.ts"),_=A("./src/types/loader.ts"),v=A("./src/utils/attr-list.ts");function S(T){var E=T.type;switch(E){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(T,E){var l=T.url;return(l===void 0||l.indexOf("data:")===0)&&(l=E.url),l}var C=function(){function T(l){this.hls=void 0,this.loaders=Object.create(null),this.hls=l,this.registerListeners()}var E=T.prototype;return E.registerListeners=function(){var o=this.hls;o.on(k.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(k.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(k.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(k.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.unregisterListeners=function(){var o=this.hls;o.off(k.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(k.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(k.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(k.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},E.createInternalLoader=function(o){var s=this.hls.config,u=s.pLoader,w=s.loader,m=u||w,h=new m(s);return o.loader=h,this.loaders[o.type]=h,h},E.getInternalLoader=function(o){return this.loaders[o.type]},E.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},E.destroyInternalLoaders=function(){for(var o in this.loaders){var s=this.loaders[o];s&&s.destroy(),this.resetInternalLoader(o)}},E.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},E.onManifestLoading=function(o,s){var u=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:u,deliveryDirectives:null})},E.onLevelLoading=function(o,s){var u=s.id,w=s.level,m=s.url,h=s.deliveryDirectives;this.load({id:u,groupId:null,level:w,responseType:"text",type:_.PlaylistContextType.LEVEL,url:m,deliveryDirectives:h})},E.onAudioTrackLoading=function(o,s){var u=s.id,w=s.groupId,m=s.url,h=s.deliveryDirectives;this.load({id:u,groupId:w,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:m,deliveryDirectives:h})},E.onSubtitleTrackLoading=function(o,s){var u=s.id,w=s.groupId,m=s.url,h=s.deliveryDirectives;this.load({id:u,groupId:w,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:m,deliveryDirectives:h})},E.load=function(o){var s,u=this.hls.config,w=this.getInternalLoader(o);if(w){var m=w.context;if(m&&m.url===o.url){U.logger.trace("[playlist-loader]: playlist request ongoing");return}U.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),w.abort()}var h,L,p,c;switch(o.type){case _.PlaylistContextType.MANIFEST:h=u.manifestLoadingMaxRetry,L=u.manifestLoadingTimeOut,p=u.manifestLoadingRetryDelay,c=u.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:h=0,L=u.levelLoadingTimeOut;break;default:h=u.levelLoadingMaxRetry,L=u.levelLoadingTimeOut,p=u.levelLoadingRetryDelay,c=u.levelLoadingMaxRetryTimeout;break}if(w=this.createInternalLoader(o),(s=o.deliveryDirectives)!==null&&s!==void 0&&s.part){var f;if(o.type===_.PlaylistContextType.LEVEL&&o.level!==null?f=this.hls.levels[o.level].details:o.type===_.PlaylistContextType.AUDIO_TRACK&&o.id!==null?f=this.hls.audioTracks[o.id].details:o.type===_.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(f=this.hls.subtitleTracks[o.id].details),f){var d=f.partTarget,a=f.targetduration;d&&a&&(L=Math.min(Math.max(d*3,a*.8)*1e3,L))}}var b={timeout:L,maxRetry:h,retryDelay:p,maxRetryDelay:c,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};w.load(o,b,g)},E.loadsuccess=function(o,s,u,w){if(w===void 0&&(w=null),u.isSidxRequest){this.handleSidxRequest(o,u),this.handlePlaylistLoaded(o,s,u,w);return}this.resetInternalLoader(u.type);var m=o.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,u,"no EXTM3U delimiter",w);return}s.parsing.start=performance.now(),m.indexOf("#EXTINF:")>0||m.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,s,u,w):this.handleMasterPlaylist(o,s,u,w)},E.loaderror=function(o,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!1,o)},E.loadtimeout=function(o,s,u){u===void 0&&(u=null),this.handleNetworkError(s,u,!0)},E.handleMasterPlaylist=function(o,s,u,w){var m=this.hls,h=o.data,L=D(o,u),p=R.default.parseMasterPlaylist(h,L),c=p.levels,f=p.sessionData;if(!c.length){this.handleManifestParsingError(o,u,"no level found in manifest",w);return}var d=c.map(function(N){return{id:N.attrs.AUDIO,audioCodec:N.audioCodec}}),a=c.map(function(N){return{id:N.attrs.SUBTITLES,textCodec:N.textCodec}}),b=R.default.parseMasterPlaylistMedia(h,L,"AUDIO",d),g=R.default.parseMasterPlaylistMedia(h,L,"SUBTITLES",a),x=R.default.parseMasterPlaylistMedia(h,L,"CLOSED-CAPTIONS");if(b.length){var P=b.some(function(N){return!N.url});!P&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(U.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new v.AttrList({}),bitrate:0,url:""}))}m.trigger(k.Events.MANIFEST_LOADED,{levels:c,audioTracks:b,subtitles:g,captions:x,url:L,stats:s,networkDetails:w,sessionData:f})},E.handleTrackOrLevelPlaylist=function(o,s,u,w){var m=this.hls,h=u.id,L=u.level,p=u.type,c=D(o,u),f=Object(W.isFiniteNumber)(h)?h:0,d=Object(W.isFiniteNumber)(L)?L:f,a=S(u),b=R.default.parseLevelPlaylist(o.data,c,d,a,f);if(!b.fragments.length){m.trigger(k.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:c,reason:"no fragments found in level",level:typeof u.level=="number"?u.level:void 0});return}if(p===_.PlaylistContextType.MANIFEST){var g={attrs:new v.AttrList({}),bitrate:0,details:b,name:"",url:c};m.trigger(k.Events.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:c,stats:s,networkDetails:w,sessionData:null})}if(s.parsing.end=performance.now(),b.needSidxRanges){var x,P=(x=b.fragments[0].initSegment)===null||x===void 0?void 0:x.url;this.load({url:P,isSidxRequest:!0,type:p,level:L,levelDetails:b,id:h,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}u.levelDetails=b,this.handlePlaylistLoaded(o,s,u,w)},E.handleSidxRequest=function(o,s){var u=Object(F.parseSegmentIndex)(new Uint8Array(o.data));if(!u)return;var w=u.references,m=s.levelDetails;w.forEach(function(h,L){var p=h.info,c=m.fragments[L];c.byteRange.length===0&&c.setByteRange(String(1+p.end-p.start)+"@"+String(p.start)),c.initSegment&&c.initSegment.setByteRange(String(u.moovEndOffset)+"@0")})},E.handleManifestParsingError=function(o,s,u,w){this.hls.trigger(k.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===_.PlaylistContextType.MANIFEST,url:o.url,reason:u,response:o,context:s,networkDetails:w})},E.handleNetworkError=function(o,s,u,w){u===void 0&&(u=!1),U.logger.warn("[playlist-loader]: A network "+(u?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var m=O.ErrorDetails.UNKNOWN,h=!1,L=this.getInternalLoader(o);switch(o.type){case _.PlaylistContextType.MANIFEST:m=u?O.ErrorDetails.MANIFEST_LOAD_TIMEOUT:O.ErrorDetails.MANIFEST_LOAD_ERROR,h=!0;break;case _.PlaylistContextType.LEVEL:m=u?O.ErrorDetails.LEVEL_LOAD_TIMEOUT:O.ErrorDetails.LEVEL_LOAD_ERROR,h=!1;break;case _.PlaylistContextType.AUDIO_TRACK:m=u?O.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:O.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:m=u?O.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:O.ErrorDetails.SUBTITLE_LOAD_ERROR,h=!1;break}L&&this.resetInternalLoader(o.type);var p={type:O.ErrorTypes.NETWORK_ERROR,details:m,fatal:h,url:o.url,loader:L,context:o,networkDetails:s};w&&(p.response=w),this.hls.trigger(k.Events.ERROR,p)},E.handlePlaylistLoaded=function(o,s,u,w){var m=u.type,h=u.level,L=u.id,p=u.groupId,c=u.loader,f=u.levelDetails,d=u.deliveryDirectives;if(!(f!=null&&f.targetduration)){this.handleManifestParsingError(o,u,"invalid target duration",w);return}if(!c)return;f.live&&(c.getCacheAge&&(f.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(f.ageHeader))&&(f.ageHeader=0));switch(m){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(k.Events.LEVEL_LOADED,{details:f,level:h||0,id:L||0,stats:s,networkDetails:w,deliveryDirectives:d});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(k.Events.AUDIO_TRACK_LOADED,{details:f,id:L||0,groupId:p||"",stats:s,networkDetails:w,deliveryDirectives:d});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(k.Events.SUBTITLE_TRACK_LOADED,{details:f,id:L||0,groupId:p||"",stats:s,networkDetails:w,deliveryDirectives:d});break}},T}();G.default=C},"./src/polyfills/number.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"isFiniteNumber",function(){return W}),A.d(G,"MAX_SAFE_INTEGER",function(){return k});var W=Number.isFinite||function(O){return typeof O=="number"&&isFinite(O)},k=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(Q,G,A){"use strict";A.r(G);var W=function(){function k(){}return k.getSilentFrame=function(U,F){switch(U){case"mp4a.40.2":if(F===1)return new Uint8Array([0,200,0,128,35,128]);if(F===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(F===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(F===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(F===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(F===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(F===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(F===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}return},k}();G.default=W},"./src/remux/mp4-generator.ts":function(Q,G,A){"use strict";A.r(G);var W=Math.pow(2,32)-1,k=function(){function O(){}return O.init=function(){O.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var F;for(F in O.types)O.types.hasOwnProperty(F)&&(O.types[F]=[F.charCodeAt(0),F.charCodeAt(1),F.charCodeAt(2),F.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]),_=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]);O.HDLR_TYPES={video:R,audio:_};var v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),S=new Uint8Array([0,0,0,0,0,0,0,0]);O.STTS=O.STSC=O.STCO=S,O.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),O.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),O.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),O.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),C=new Uint8Array([97,118,99,49]),T=new Uint8Array([0,0,0,1]);O.FTYP=O.box(O.types.ftyp,D,T,D,C),O.DINF=O.box(O.types.dinf,O.box(O.types.dref,v))},O.box=function(F){for(var R=8,_=arguments.length,v=new Array(_>1?_-1:0),S=1;S<_;S++)v[S-1]=arguments[S];for(var D=v.length,C=D;D--;)R+=v[D].byteLength;var T=new Uint8Array(R);for(T[0]=R>>24&255,T[1]=R>>16&255,T[2]=R>>8&255,T[3]=R&255,T.set(F,4),D=0,R=8;D<C;D++)T.set(v[D],R),R+=v[D].byteLength;return T},O.hdlr=function(F){return O.box(O.types.hdlr,O.HDLR_TYPES[F])},O.mdat=function(F){return O.box(O.types.mdat,F)},O.mdhd=function(F,R){R*=F;var _=Math.floor(R/(W+1)),v=Math.floor(R%(W+1));return O.box(O.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,_>>24,_>>16&255,_>>8&255,_&255,v>>24,v>>16&255,v>>8&255,v&255,85,196,0,0]))},O.mdia=function(F){return O.box(O.types.mdia,O.mdhd(F.timescale,F.duration),O.hdlr(F.type),O.minf(F))},O.mfhd=function(F){return O.box(O.types.mfhd,new Uint8Array([0,0,0,0,F>>24,F>>16&255,F>>8&255,F&255]))},O.minf=function(F){return F.type==="audio"?O.box(O.types.minf,O.box(O.types.smhd,O.SMHD),O.DINF,O.stbl(F)):O.box(O.types.minf,O.box(O.types.vmhd,O.VMHD),O.DINF,O.stbl(F))},O.moof=function(F,R,_){return O.box(O.types.moof,O.mfhd(F),O.traf(_,R))},O.moov=function(F){for(var R=F.length,_=[];R--;)_[R]=O.trak(F[R]);return O.box.apply(null,[O.types.moov,O.mvhd(F[0].timescale,F[0].duration)].concat(_).concat(O.mvex(F)))},O.mvex=function(F){for(var R=F.length,_=[];R--;)_[R]=O.trex(F[R]);return O.box.apply(null,[O.types.mvex].concat(_))},O.mvhd=function(F,R){R*=F;var _=Math.floor(R/(W+1)),v=Math.floor(R%(W+1)),S=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,F>>24&255,F>>16&255,F>>8&255,F&255,_>>24,_>>16&255,_>>8&255,_&255,v>>24,v>>16&255,v>>8&255,v&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 O.box(O.types.mvhd,S)},O.sdtp=function(F){var R=F.samples||[],_=new Uint8Array(4+R.length),v,S;for(v=0;v<R.length;v++)S=R[v].flags,_[v+4]=S.dependsOn<<4|S.isDependedOn<<2|S.hasRedundancy;return O.box(O.types.sdtp,_)},O.stbl=function(F){return O.box(O.types.stbl,O.stsd(F),O.box(O.types.stts,O.STTS),O.box(O.types.stsc,O.STSC),O.box(O.types.stsz,O.STSZ),O.box(O.types.stco,O.STCO))},O.avc1=function(F){var R=[],_=[],v,S,D;for(v=0;v<F.sps.length;v++)S=F.sps[v],D=S.byteLength,R.push(D>>>8&255),R.push(D&255),R=R.concat(Array.prototype.slice.call(S));for(v=0;v<F.pps.length;v++)S=F.pps[v],D=S.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(S));var C=O.box(O.types.avcC,new Uint8Array([1,R[3],R[4],R[5],252|3,224|F.sps.length].concat(R).concat([F.pps.length]).concat(_))),T=F.width,E=F.height,l=F.pixelRatio[0],o=F.pixelRatio[1];return O.box(O.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,T>>8&255,T&255,E>>8&255,E&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]),C,O.box(O.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),O.box(O.types.pasp,new Uint8Array([l>>24,l>>16&255,l>>8&255,l&255,o>>24,o>>16&255,o>>8&255,o&255])))},O.esds=function(F){var R=F.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(F.config).concat([6,1,2]))},O.mp4a=function(F){var R=F.samplerate;return O.box(O.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,R>>8&255,R&255,0,0]),O.box(O.types.esds,O.esds(F)))},O.mp3=function(F){var R=F.samplerate;return O.box(O.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,F.channelCount,0,16,0,0,0,0,R>>8&255,R&255,0,0]))},O.stsd=function(F){return F.type==="audio"?!F.isAAC&&F.codec==="mp3"?O.box(O.types.stsd,O.STSD,O.mp3(F)):O.box(O.types.stsd,O.STSD,O.mp4a(F)):O.box(O.types.stsd,O.STSD,O.avc1(F))},O.tkhd=function(F){var R=F.id,_=F.duration*F.timescale,v=F.width,S=F.height,D=Math.floor(_/(W+1)),C=Math.floor(_%(W+1));return O.box(O.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,D>>24,D>>16&255,D>>8&255,D&255,C>>24,C>>16&255,C>>8&255,C&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,v>>8&255,v&255,0,0,S>>8&255,S&255,0,0]))},O.traf=function(F,R){var _=O.sdtp(F),v=F.id,S=Math.floor(R/(W+1)),D=Math.floor(R%(W+1));return O.box(O.types.traf,O.box(O.types.tfhd,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])),O.box(O.types.tfdt,new Uint8Array([1,0,0,0,S>>24,S>>16&255,S>>8&255,S&255,D>>24,D>>16&255,D>>8&255,D&255])),O.trun(F,_.length+16+20+8+16+8+8),_)},O.trak=function(F){return F.duration=F.duration||4294967295,O.box(O.types.trak,O.tkhd(F),O.mdia(F))},O.trex=function(F){var R=F.id;return O.box(O.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]))},O.trun=function(F,R){var _=F.samples||[],v=_.length,S=12+16*v,D=new Uint8Array(S),C,T,E,l,o,s;for(R+=8+S,D.set([0,0,15,1,v>>>24&255,v>>>16&255,v>>>8&255,v&255,R>>>24&255,R>>>16&255,R>>>8&255,R&255],0),C=0;C<v;C++)T=_[C],E=T.duration,l=T.size,o=T.flags,s=T.cts,D.set([E>>>24&255,E>>>16&255,E>>>8&255,E&255,l>>>24&255,l>>>16&255,l>>>8&255,l&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,s>>>24&255,s>>>16&255,s>>>8&255,s&255],12+16*C);return O.box(O.types.trun,D)},O.initSegment=function(F){O.types||O.init();var R=O.moov(F),_=new Uint8Array(O.FTYP.byteLength+R.byteLength);return _.set(O.FTYP),_.set(R,O.FTYP.byteLength),_},O}();k.types=void 0,k.HDLR_TYPES=void 0,k.STTS=void 0,k.STSC=void 0,k.STCO=void 0,k.STSZ=void 0,k.VMHD=void 0,k.SMHD=void 0,k.STSD=void 0,k.FTYP=void 0,k.DINF=void 0,G.default=k},"./src/remux/mp4-remuxer.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return s}),A.d(G,"normalizePts",function(){return u});var W=A("./src/polyfills/number.ts"),k=A("./src/remux/aac-helper.ts"),O=A("./src/remux/mp4-generator.ts"),U=A("./src/events.ts"),F=A("./src/errors.ts"),R=A("./src/utils/logger.ts"),_=A("./src/types/loader.ts"),v=A("./src/utils/timescale-conversion.ts");function S(){return S=Object.assign||function(L){for(var p=1;p<arguments.length;p++){var c=arguments[p];for(var f in c)Object.prototype.hasOwnProperty.call(c,f)&&(L[f]=c[f])}return L},S.apply(this,arguments)}var D=10*1e3,C=1024,T=1152,E=null,l=null,o=!1,s=function(){function L(c,f,d,a){if(a===void 0&&(a=""),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.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=c,this.config=f,this.typeSupported=d,this.ISGenerated=!1,E===null){var b=navigator.userAgent||"",g=b.match(/Chrome\/(\d+)/i);E=g?parseInt(g[1]):0}if(l===null){var x=navigator.userAgent.match(/Safari\/(\d+)/i);l=x?parseInt(x[1]):0}o=!!E&&E<75||!!l&&l<600}var p=L.prototype;return p.destroy=function(){},p.resetTimeStamp=function(f){R.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},p.resetNextTimestamp=function(){R.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},p.resetInitSegment=function(){R.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},p.getVideoStartPts=function(f){var d=!1,a=f.reduce(function(b,g){var x=g.pts-b;return x<-4294967296?(d=!0,u(b,g.pts)):x>0?b:g.pts},f[0].pts);return d&&R.logger.debug("PTS rollover detected"),a},p.remux=function(f,d,a,b,g,x,P,N){var H,X,B,I,Y,te,se=g,de=g,Se=f.pid>-1,ge=d.pid>-1,pe=d.samples.length,he=f.samples.length>0,me=pe>1,ae=(!Se||he)&&(!ge||me)||this.ISGenerated||P;if(ae){this.ISGenerated||(B=this.generateIS(f,d,g));var ue=this.isVideoContiguous,xe=-1;if(me&&(xe=w(d.samples),!ue&&this.config.forceKeyFrameOnDiscontinuity))if(te=!0,xe>0){R.logger.warn("[mp4-remuxer]: Dropped "+xe+" out of "+pe+" video samples due to a missing keyframe");var Fe=this.getVideoStartPts(d.samples);d.samples=d.samples.slice(xe),d.dropped+=xe,de+=(d.samples[0].pts-Fe)/(d.timescale||9e4)}else xe===-1&&(R.logger.warn("[mp4-remuxer]: No keyframe found out of "+pe+" video samples"),te=!1);if(this.ISGenerated){if(he&&me){var Re=this.getVideoStartPts(d.samples),Ie=u(f.samples[0].pts,Re)-Re,Ke=Ie/d.inputTimeScale;se+=Math.max(0,Ke),de+=Math.max(0,-Ke)}if(he){if(f.samplerate||(R.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),B=this.generateIS(f,d,g)),X=this.remuxAudio(f,se,this.isAudioContiguous,x,ge||me||N===_.PlaylistLevelType.AUDIO?de:void 0),me){var De=X?X.endPTS-X.startPTS:0;d.inputTimeScale||(R.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),B=this.generateIS(f,d,g)),H=this.remuxVideo(d,de,ue,De)}}else me&&(H=this.remuxVideo(d,de,ue,0));H&&(H.firstKeyFrame=xe,H.independent=xe!==-1)}}return this.ISGenerated&&(a.samples.length&&(Y=this.remuxID3(a,g)),b.samples.length&&(I=this.remuxText(b,g))),{audio:X,video:H,initSegment:B,independent:te,text:I,id3:Y}},p.generateIS=function(f,d,a){var b=f.samples,g=d.samples,x=this.typeSupported,P={},N=!Object(W.isFiniteNumber)(this._initPTS),H="audio/mp4",X,B,I;if(N&&(X=B=Infinity),f.config&&b.length&&(f.timescale=f.samplerate,f.isAAC||(x.mpeg?(H="audio/mpeg",f.codec=""):x.mp3&&(f.codec="mp3")),P.audio={id:"audio",container:H,codec:f.codec,initSegment:!f.isAAC&&x.mpeg?new Uint8Array(0):O.default.initSegment([f]),metadata:{channelCount:f.channelCount}},N&&(I=f.inputTimeScale,X=B=b[0].pts-Math.round(I*a))),d.sps&&d.pps&&g.length&&(d.timescale=d.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:d.codec,initSegment:O.default.initSegment([d]),metadata:{width:d.width,height:d.height}},N)){I=d.inputTimeScale;var Y=this.getVideoStartPts(g),te=Math.round(I*a);B=Math.min(B,u(g[0].dts,Y)-te),X=Math.min(X,Y-te)}if(Object.keys(P).length)return this.ISGenerated=!0,N&&(this._initPTS=X,this._initDTS=B),{tracks:P,initPTS:X,timescale:I}},p.remuxVideo=function(f,d,a,b){var g=f.inputTimeScale,x=f.samples,P=[],N=x.length,H=this._initPTS,X=this.nextAvcDts,B=8,I,Y,te,se=Number.POSITIVE_INFINITY,de=Number.NEGATIVE_INFINITY,Se=0,ge=!1;if(!a||X===null){var pe=d*g,he=x[0].pts-u(x[0].dts,x[0].pts);X=pe-he}for(var me=0;me<N;me++){var ae=x[me];if(ae.pts=u(ae.pts-H,X),ae.dts=u(ae.dts-H,X),ae.dts>ae.pts){var ue=9e4*.2;Se=Math.max(Math.min(Se,ae.pts-ae.dts),-1*ue)}ae.dts<x[me>0?me-1:me].dts&&(ge=!0)}ge&&x.sort(function(xt,ht){var ot=xt.dts-ht.dts,Ct=xt.pts-ht.pts;return ot||Ct}),Y=x[0].dts,te=x[x.length-1].dts;var xe=Math.round((te-Y)/(N-1));if(Se<0){if(Se<xe*-2){R.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(v.toMsFromMpegTsClock)(-xe,!0)+" ms");for(var Fe=Se,Re=0;Re<N;Re++)x[Re].dts=Fe=Math.max(Fe,x[Re].pts-xe),x[Re].pts=Math.max(Fe,x[Re].pts)}else{R.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(v.toMsFromMpegTsClock)(Se,!0)+" ms to overcome this issue");for(var Ie=0;Ie<N;Ie++)x[Ie].dts=x[Ie].dts+Se}Y=x[0].dts}if(a){var Ke=Y-X,De=Ke>xe,Ce=Ke<-1;if(De||Ce){De?R.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(Ke,!0)+" ms ("+Ke+"dts) hole between fragments detected, filling it"):R.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(-Ke,!0)+" ms ("+Ke+"dts) overlapping between fragments detected"),Y=X;var Me=x[0].pts-Ke;x[0].dts=Y,x[0].pts=Me,R.logger.log("Video: First PTS/DTS adjusted: "+Object(v.toMsFromMpegTsClock)(Me,!0)+"/"+Object(v.toMsFromMpegTsClock)(Y,!0)+", delta: "+Object(v.toMsFromMpegTsClock)(Ke,!0)+" ms")}}o&&(Y=Math.max(0,Y));for(var Be=0,je=0,_e=0;_e<N;_e++){for(var Le=x[_e],$e=Le.units,Je=$e.length,We=0,He=0;He<Je;He++)We+=$e[He].data.length;je+=We,Be+=Je,Le.length=We,Le.dts=Math.max(Le.dts,Y),Le.pts=Math.max(Le.pts,Le.dts,0),se=Math.min(Le.pts,se),de=Math.max(Le.pts,de)}te=x[N-1].dts;var et=je+4*Be+8,Ye;try{Ye=new Uint8Array(et)}catch(xt){this.observer.emit(U.Events.ERROR,U.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:et,reason:"fail allocating video mdat "+et});return}var Ve=new DataView(Ye.buffer);Ve.setUint32(0,et),Ye.set(O.default.types.mdat,4);for(var be=0;be<N;be++){for(var Ze=x[be],Ge=Ze.units,ve=0,Ee=0,oe=Ge.length;Ee<oe;Ee++){var ee=Ge[Ee],re=ee.data,V=ee.data.byteLength;Ve.setUint32(B,V),B+=4,Ye.set(re,B),B+=V,ve+=4+V}if(be<N-1)I=x[be+1].dts-Ze.dts;else{var $=this.config,J=Ze.dts-x[be>0?be-1:be].dts;if($.stretchShortVideoTrack&&this.nextAudioPts!==null){var ne=Math.floor($.maxBufferHole*g),le=(b?se+b*g:this.nextAudioPts)-Ze.pts;le>ne?(I=le-J,I<0&&(I=J),R.logger.log("[mp4-remuxer]: It is approximately "+le/90+" ms to the next segment; using duration "+I/90+" ms for the last video frame.")):I=J}else I=J}var ye=Math.round(Ze.pts-Ze.dts);P.push(new m(Ze.key,I,ve,ye))}if(P.length&&E&&E<70){var we=P[0].flags;we.dependsOn=2,we.isNonSync=0}console.assert(I!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=X=te+I,this.isVideoContiguous=!0;var ze=O.default.moof(f.sequenceNumber++,Y,S({},f,{samples:P})),it="video",tt={data1:ze,data2:Ye,startPTS:se/g,endPTS:(de+I)/g,startDTS:Y/g,endDTS:X/g,type:it,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(Ye.length,"MDAT length must not be zero"),tt},p.remuxAudio=function(f,d,a,b,g){var x=f.inputTimeScale,P=f.samplerate?f.samplerate:x,N=x/P,H=f.isAAC?C:T,X=H*N,B=this._initPTS,I=!f.isAAC&&this.typeSupported.mpeg,Y=[],te=f.samples,se=I?0:8,de=this.nextAudioPts||-1,Se=d*x;if(this.isAudioContiguous=a=a||te.length&&de>0&&(b&&Math.abs(Se-de)<9e3||Math.abs(u(te[0].pts-B,Se)-de)<20*X),te.forEach(function(re){re.pts=u(re.pts-B,Se)}),!a||de<0){if(te=te.filter(function(re){return re.pts>=0}),!te.length)return;g===0?de=0:b?de=Math.max(0,Se):de=te[0].pts}if(f.isAAC)for(var ge=g!==void 0,pe=this.config.maxAudioFramesDrift,he=0,me=de;he<te.length;he++){var ae=te[he],ue=ae.pts,xe=ue-me,Fe=Math.abs(1e3*xe/x);if(xe<=-pe*X&&ge)he===0&&(R.logger.warn("Audio frame @ "+(ue/x).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*xe/x)+" ms."),this.nextAudioPts=de=me=ue);else if(xe>=pe*X&&Fe<D&&ge){var Re=Math.round(xe/X);me=ue-Re*X,me<0&&(Re--,me+=X),he===0&&(this.nextAudioPts=de=me),R.logger.warn("[mp4-remuxer]: Injecting "+Re+" audio frame @ "+(me/x).toFixed(3)+"s due to "+Math.round(1e3*xe/x)+" ms gap.");for(var Ie=0;Ie<Re;Ie++){var Ke=Math.max(me,0),De=k.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);De||(R.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),De=ae.unit.subarray()),te.splice(he,0,{unit:De,pts:Ke}),me+=X,he++}}ae.pts=me,me+=X}for(var Ce=null,Me=null,Be,je=0,_e=te.length;_e--;)je+=te[_e].unit.byteLength;for(var Le=0,$e=te.length;Le<$e;Le++){var Je=te[Le],We=Je.unit,He=Je.pts;if(Me!==null){var et=Y[Le-1];et.duration=Math.round((He-Me)/N)}else if(a&&f.isAAC&&(He=de),Ce=He,je>0){je+=se;try{Be=new Uint8Array(je)}catch(re){this.observer.emit(U.Events.ERROR,U.Events.ERROR,{type:F.ErrorTypes.MUX_ERROR,details:F.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:je,reason:"fail allocating audio mdat "+je});return}if(!I){var Ye=new DataView(Be.buffer);Ye.setUint32(0,je),Be.set(O.default.types.mdat,4)}}else return;Be.set(We,se);var Ve=We.byteLength;se+=Ve,Y.push(new m(!0,H,Ve,0)),Me=He}var be=Y.length;if(!be)return;var Ze=Y[Y.length-1];this.nextAudioPts=de=Me+N*Ze.duration;var Ge=I?new Uint8Array(0):O.default.moof(f.sequenceNumber++,Ce/N,S({},f,{samples:Y}));f.samples=[];var ve=Ce/x,Ee=de/x,oe="audio",ee={data1:Ge,data2:Be,startPTS:ve,endPTS:Ee,startDTS:ve,endDTS:Ee,type:oe,hasAudio:!0,hasVideo:!1,nb:be};return this.isAudioContiguous=!0,console.assert(Be.length,"MDAT length must not be zero"),ee},p.remuxEmptyAudio=function(f,d,a,b){var g=f.inputTimeScale,x=f.samplerate?f.samplerate:g,P=g/x,N=this.nextAudioPts,H=(N!==null?N:b.startDTS*g)+this._initDTS,X=b.endDTS*g+this._initDTS,B=P*C,I=Math.ceil((X-H)/B),Y=k.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(R.logger.warn("[mp4-remuxer]: remux empty Audio"),!Y){R.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var te=[],se=0;se<I;se++){var de=H+se*B;te.push({unit:Y,pts:de,dts:de})}return f.samples=te,this.remuxAudio(f,d,a,!1)},p.remuxID3=function(f,d){var a=f.samples.length;if(!a)return;for(var b=f.inputTimeScale,g=this._initPTS,x=this._initDTS,P=0;P<a;P++){var N=f.samples[P];N.pts=u(N.pts-g,d*b)/b,N.dts=u(N.dts-x,d*b)/b}var H=f.samples;return f.samples=[],{samples:H}},p.remuxText=function(f,d){var a=f.samples.length;if(!a)return;for(var b=f.inputTimeScale,g=this._initPTS,x=0;x<a;x++){var P=f.samples[x];P.pts=u(P.pts-g,d*b)/b}f.samples.sort(function(H,X){return H.pts-X.pts});var N=f.samples;return f.samples=[],{samples:N}},L}();function u(L,p){var c;if(p===null)return L;for(p<L?c=-8589934592:c=8589934592;Math.abs(L-p)>4294967296;)L+=c;return L}function w(L){for(var p=0;p<L.length;p++)if(L[p].key)return p;return-1}var m=function(p,c,f,d){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=c,this.size=f,this.cts=d,this.flags=new h(p)},h=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":function(Q,G,A){"use strict";A.r(G);var W=A("./src/polyfills/number.ts"),k=A("./src/utils/mp4-tools.ts"),O=A("./src/loader/fragment.ts"),U=A("./src/utils/logger.ts"),F=function(){function v(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var S=v.prototype;return S.destroy=function(){},S.resetTimeStamp=function(C){this.initPTS=C,this.lastEndDTS=null},S.resetNextTimestamp=function(){this.lastEndDTS=null},S.resetInitSegment=function(C,T,E){this.audioCodec=T,this.videoCodec=E,this.generateInitSegment(C),this.emitInitSegment=!0},S.generateInitSegment=function(C){var T=this.audioCodec,E=this.videoCodec;if(!C||!C.byteLength){this.initTracks=void 0,this.initData=void 0;return}var l=this.initData=Object(k.parseInitSegment)(C);T||(T=_(l.audio,O.ElementaryStreamTypes.AUDIO)),E||(E=_(l.video,O.ElementaryStreamTypes.VIDEO));var o={};l.audio&&l.video?o.audiovideo={container:"video/mp4",codec:T+","+E,initSegment:C,id:"main"}:l.audio?o.audio={container:"audio/mp4",codec:T,initSegment:C,id:"audio"}:l.video?o.video={container:"video/mp4",codec:E,initSegment:C,id:"main"}:U.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},S.remux=function(C,T,E,l,o){var s=this.initPTS,u=this.lastEndDTS,w={audio:void 0,video:void 0,text:l,id3:E,initSegment:void 0};Object(W.isFiniteNumber)(u)||(u=this.lastEndDTS=o||0);var m=T.samples;if(!m||!m.length)return w;var h={initPTS:void 0,timescale:1},L=this.initData;if((!L||!L.length)&&(this.generateInitSegment(m),L=this.initData),!L||!L.length)return U.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),w;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1),Object(W.isFiniteNumber)(s)||(this.initPTS=h.initPTS=s=R(L,m,u));var p=Object(k.getDuration)(m,L),c=u,f=p+c;Object(k.offsetStartDTS)(L,m,s),p>0?this.lastEndDTS=f:(U.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var d=!!L.audio,a=!!L.video,b="";d&&(b+="audio"),a&&(b+="video");var g={data1:m,startPTS:c,startDTS:c,endPTS:f,endDTS:f,type:b,hasAudio:d,hasVideo:a,nb:1,dropped:0};return w.audio=g.type==="audio"?g:void 0,w.video=g.type!=="audio"?g:void 0,w.text=l,w.id3=E,w.initSegment=h,w},v}(),R=function(S,D,C){return Object(k.getStartDTS)(S,D)-C};function _(v,S){var D=v==null?void 0:v.codec;return D&&D.length>4?D:D==="hvc1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||S===O.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}G.default=F},"./src/task-loop.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return W});var W=function(){function k(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var O=k.prototype;return O.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},O.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},O.onHandlerDestroyed=function(){},O.hasInterval=function(){return!!this._tickInterval},O.hasNextTick=function(){return!!this._tickTimer},O.setInterval=function(F){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,F),!0)},O.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},O.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},O.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},O.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},O.doTick=function(){},k}()},"./src/types/cmcd.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"CMCDVersion",function(){return W}),A.d(G,"CMCDObjectType",function(){return k}),A.d(G,"CMCDStreamingFormat",function(){return O}),A.d(G,"CMCDStreamType",function(){return U});var W=1,k;(function(F){F.MANIFEST="m",F.AUDIO="a",F.VIDEO="v",F.MUXED="av",F.INIT="i",F.CAPTION="c",F.TIMED_TEXT="tt",F.KEY="k",F.OTHER="o"})(k||(k={}));var O;(function(F){F.DASH="d",F.HLS="h",F.SMOOTH="s",F.OTHER="o"})(O||(O={}));var U;(function(F){F.VOD="v",F.LIVE="l"})(U||(U={}))},"./src/types/level.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"HlsSkip",function(){return O}),A.d(G,"getSkipValue",function(){return U}),A.d(G,"HlsUrlParameters",function(){return F}),A.d(G,"Level",function(){return R});function W(_,v){for(var S=0;S<v.length;S++){var D=v[S];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function k(_,v,S){return v&&W(_.prototype,v),S&&W(_,S),_}var O;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(O||(O={}));function U(_,v){var S=_.canSkipUntil,D=_.canSkipDateRanges,C=_.endSN,T=v!==void 0?v-C:0;return S&&T<S?D?O.v2:O.Yes:O.No}var F=function(){function _(S,D,C){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=S,this.part=D,this.skip=C}var v=_.prototype;return v.addDirectives=function(D){var C=new self.URL(D);return this.msn!==void 0&&C.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&C.searchParams.set("_HLS_part",this.part.toString()),this.skip&&C.searchParams.set("_HLS_skip",this.skip),C.toString()},_}(),R=function(){function _(v){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=[v.url],this.attrs=v.attrs,this.bitrate=v.bitrate,v.details&&(this.details=v.details),this.id=v.id||0,this.name=v.name,this.width=v.width||0,this.height=v.height||0,this.audioCodec=v.audioCodec,this.videoCodec=v.videoCodec,this.unknownCodecs=v.unknownCodecs,this.codecSet=[v.videoCodec,v.audioCodec].filter(function(S){return S}).join(",").replace(/\.[^.,]+/g,"")}return k(_,[{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(S){var D=S%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),_}()},"./src/types/loader.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"PlaylistContextType",function(){return W}),A.d(G,"PlaylistLevelType",function(){return k});var W;(function(O){O.MANIFEST="manifest",O.LEVEL="level",O.AUDIO_TRACK="audioTrack",O.SUBTITLE_TRACK="subtitleTrack"})(W||(W={}));var k;(function(O){O.MAIN="main",O.AUDIO="audio",O.SUBTITLE="subtitle"})(k||(k={}))},"./src/types/transmuxer.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"ChunkMetadata",function(){return W});var W=function(U,F,R,_,v,S){_===void 0&&(_=0),v===void 0&&(v=-1),S===void 0&&(S=!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=k(),this.buffering={audio:k(),video:k(),audiovideo:k()},this.level=U,this.sn=F,this.id=R,this.size=_,this.part=v,this.partial=S};function k(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"AttrList",function(){return O});var W=/^(\d+)x(\d+)$/,k=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,O=function(){function U(R){typeof R=="string"&&(R=U.parseAttrList(R));for(var _ in R)R.hasOwnProperty(_)&&(this[_]=R[_])}var F=U.prototype;return F.decimalInteger=function(_){var v=parseInt(this[_],10);return v>Number.MAX_SAFE_INTEGER?Infinity:v},F.hexadecimalInteger=function(_){if(this[_]){var v=(this[_]||"0x").slice(2);v=(v.length&1?"0":"")+v;for(var S=new Uint8Array(v.length/2),D=0;D<v.length/2;D++)S[D]=parseInt(v.slice(D*2,D*2+2),16);return S}else return null},F.hexadecimalIntegerAsNumber=function(_){var v=parseInt(this[_],16);return v>Number.MAX_SAFE_INTEGER?Infinity:v},F.decimalFloatingPoint=function(_){return parseFloat(this[_])},F.optionalFloat=function(_,v){var S=this[_];return S?parseFloat(S):v},F.enumeratedString=function(_){return this[_]},F.bool=function(_){return this[_]==="YES"},F.decimalResolution=function(_){var v=W.exec(this[_]);return v===null?void 0:{width:parseInt(v[1],10),height:parseInt(v[2],10)}},U.parseAttrList=function(_){var v,S={},D='"';for(k.lastIndex=0;(v=k.exec(_))!==null;){var C=v[2];C.indexOf(D)===0&&C.lastIndexOf(D)===C.length-1&&(C=C.slice(1,-1)),S[v[1]]=C}return S},U}()},"./src/utils/binary-search.ts":function(Q,G,A){"use strict";A.r(G);var W={search:function(O,U){for(var F=0,R=O.length-1,_=null,v=null;F<=R;){_=(F+R)/2|0,v=O[_];var S=U(v);if(S>0)F=_+1;else if(S<0)R=_-1;else return v}return null}};G.default=W},"./src/utils/buffer-helper.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"BufferHelper",function(){return O});var W=A("./src/utils/logger.ts"),k={length:0,start:function(){return 0},end:function(){return 0}},O=function(){function U(){}return U.isBuffered=function(R,_){try{if(R){for(var v=U.getBuffered(R),S=0;S<v.length;S++)if(_>=v.start(S)&&_<=v.end(S))return!0}}catch(D){}return!1},U.bufferInfo=function(R,_,v){try{if(R){var S=U.getBuffered(R),D=[],C;for(C=0;C<S.length;C++)D.push({start:S.start(C),end:S.end(C)});return this.bufferedInfo(D,_,v)}}catch(T){}return{len:0,start:_,end:_,nextStart:void 0}},U.bufferedInfo=function(R,_,v){_=Math.max(0,_),R.sort(function(h,L){var p=h.start-L.start;return p||L.end-h.end});var S=[];if(v)for(var D=0;D<R.length;D++){var C=S.length;if(C){var T=S[C-1].end;R[D].start-T<v?R[D].end>T&&(S[C-1].end=R[D].end):S.push(R[D])}else S.push(R[D])}else S=R;for(var E=0,l,o=_,s=_,u=0;u<S.length;u++){var w=S[u].start,m=S[u].end;if(_+v>=w&&_<m)o=w,s=m,E=s-_;else if(_+v<w){l=w;break}}return{len:E,start:o||0,end:s||0,nextStart:l}},U.getBuffered=function(R){try{return R.buffered}catch(_){return W.logger.log("failed to get media.buffered",_),k}},U}()},"./src/utils/cea-608-parser.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"Row",function(){return s}),A.d(G,"CaptionScreen",function(){return u});var W=A("./src/utils/logger.ts"),k={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},O=function(f){var d=f;return k.hasOwnProperty(f)&&(d=k[f]),String.fromCharCode(d)},U=15,F=100,R={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},v={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},S={25:2,26:4,29:6,30:8,31:10,27:13,28:15},D=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],C;(function(c){c[c.ERROR=0]="ERROR",c[c.TEXT=1]="TEXT",c[c.WARNING=2]="WARNING",c[c.INFO=2]="INFO",c[c.DEBUG=3]="DEBUG",c[c.DATA=3]="DATA"})(C||(C={}));var T=function(){function c(){this.time=null,this.verboseLevel=C.ERROR}var f=c.prototype;return f.log=function(a,b){this.verboseLevel>=a&&W.logger.log(this.time+" ["+a+"] "+b)},c}(),E=function(f){for(var d=[],a=0;a<f.length;a++)d.push(f[a].toString(16));return d},l=function(){function c(d,a,b,g,x){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=a||!1,this.italics=b||!1,this.background=g||"black",this.flash=x||!1}var f=c.prototype;return f.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},f.setStyles=function(a){for(var b=["foreground","underline","italics","background","flash"],g=0;g<b.length;g++){var x=b[g];a.hasOwnProperty(x)&&(this[x]=a[x])}},f.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},f.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},f.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},f.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},c}(),o=function(){function c(d,a,b,g,x,P){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new l(a,b,g,x,P)}var f=c.prototype;return f.reset=function(){this.uchar=" ",this.penState.reset()},f.setChar=function(a,b){this.uchar=a,this.penState.copy(b)},f.setPenState=function(a){this.penState.copy(a)},f.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},f.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},f.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},c}(),s=function(){function c(d){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var a=0;a<F;a++)this.chars.push(new o);this.logger=d,this.pos=0,this.currPenState=new l}var f=c.prototype;return f.equals=function(a){for(var b=!0,g=0;g<F;g++)if(!this.chars[g].equals(a.chars[g])){b=!1;break}return b},f.copy=function(a){for(var b=0;b<F;b++)this.chars[b].copy(a.chars[b])},f.isEmpty=function(){for(var a=!0,b=0;b<F;b++)if(!this.chars[b].isEmpty()){a=!1;break}return a},f.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(C.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>F&&(this.logger.log(C.DEBUG,"Too large cursor position "+this.pos),this.pos=F)},f.moveCursor=function(a){var b=this.pos+a;if(a>1)for(var g=this.pos+1;g<b+1;g++)this.chars[g].setPenState(this.currPenState);this.setCursor(b)},f.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},f.insertChar=function(a){a>=144&&this.backSpace();var b=O(a);if(this.pos>=F){this.logger.log(C.ERROR,"Cannot insert "+a.toString(16)+" ("+b+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(b,this.currPenState),this.moveCursor(1)},f.clearFromPos=function(a){var b;for(b=a;b<F;b++)this.chars[b].reset()},f.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},f.clearToEndOfRow=function(){this.clearFromPos(this.pos)},f.getTextString=function(){for(var a=[],b=!0,g=0;g<F;g++){var x=this.chars[g].uchar;x!==" "&&(b=!1),a.push(x)}return b?"":a.join("")},f.setPenStyles=function(a){this.currPenState.setStyles(a);var b=this.chars[this.pos];b.setPenState(this.currPenState)},c}(),u=function(){function c(d){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var a=0;a<U;a++)this.rows.push(new s(d));this.logger=d,this.currRow=U-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var f=c.prototype;return f.reset=function(){for(var a=0;a<U;a++)this.rows[a].clear();this.currRow=U-1},f.equals=function(a){for(var b=!0,g=0;g<U;g++)if(!this.rows[g].equals(a.rows[g])){b=!1;break}return b},f.copy=function(a){for(var b=0;b<U;b++)this.rows[b].copy(a.rows[b])},f.isEmpty=function(){for(var a=!0,b=0;b<U;b++)if(!this.rows[b].isEmpty()){a=!1;break}return a},f.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},f.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},f.insertChar=function(a){var b=this.rows[this.currRow];b.insertChar(a)},f.setPen=function(a){var b=this.rows[this.currRow];b.setPenStyles(a)},f.moveCursor=function(a){var b=this.rows[this.currRow];b.moveCursor(a)},f.setCursor=function(a){this.logger.log(C.INFO,"setCursor: "+a);var b=this.rows[this.currRow];b.setCursor(a)},f.setPAC=function(a){this.logger.log(C.INFO,"pacData = "+JSON.stringify(a));var b=a.row-1;if(this.nrRollUpRows&&b<this.nrRollUpRows-1&&(b=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==b){for(var g=0;g<U;g++)this.rows[g].clear();var x=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var N=P.rows[x].cueStartTime,H=this.logger.time;if(N&&H!==null&&N<H)for(var X=0;X<this.nrRollUpRows;X++)this.rows[b-this.nrRollUpRows+X+1].copy(P.rows[x+X])}}this.currRow=b;var B=this.rows[this.currRow];if(a.indent!==null){var I=a.indent,Y=Math.max(I-1,0);B.setCursor(a.indent),a.color=B.chars[Y].penState.foreground}var te={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(te)},f.setBkgData=function(a){this.logger.log(C.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},f.setRollUpRows=function(a){this.nrRollUpRows=a},f.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(C.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(C.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,b=this.rows.splice(a,1)[0];b.clear(),this.rows.splice(this.currRow,0,b),this.logger.log(C.INFO,"Rolling up")},f.getDisplayText=function(a){a=a||!1;for(var b=[],g="",x=-1,P=0;P<U;P++){var N=this.rows[P].getTextString();N&&(x=P+1,a?b.push("Row "+x+": '"+N+"'"):b.push(N.trim()))}return b.length>0&&(a?g="["+b.join(" | ")+"]":g=b.join(`
|
|
`)),g},f.getTextAndFormat=function(){return this.rows},c}(),w=function(){function c(d,a,b){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=d,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new u(b),this.nonDisplayedMemory=new u(b),this.lastOutputScreen=new u(b),this.currRollUpRow=this.displayedMemory.rows[U-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=b}var f=c.prototype;return f.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[U-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},f.getHandler=function(){return this.outputFilter},f.setHandler=function(a){this.outputFilter=a},f.setPAC=function(a){this.writeScreen.setPAC(a)},f.setBkgData=function(a){this.writeScreen.setBkgData(a)},f.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(C.INFO,"MODE="+a),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=a},f.insertChars=function(a){for(var b=0;b<a.length;b++)this.writeScreen.insertChar(a[b]);var g=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(C.INFO,g+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(C.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},f.ccRCL=function(){this.logger.log(C.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},f.ccBS=function(){if(this.logger.log(C.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},f.ccAOF=function(){},f.ccAON=function(){},f.ccDER=function(){this.logger.log(C.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},f.ccRU=function(a){this.logger.log(C.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},f.ccFON=function(){this.logger.log(C.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},f.ccRDC=function(){this.logger.log(C.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},f.ccTR=function(){this.logger.log(C.INFO,"TR"),this.setMode("MODE_TEXT")},f.ccRTD=function(){this.logger.log(C.INFO,"RTD"),this.setMode("MODE_TEXT")},f.ccEDM=function(){this.logger.log(C.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},f.ccCR=function(){this.logger.log(C.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},f.ccENM=function(){this.logger.log(C.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},f.ccEOC=function(){if(this.logger.log(C.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var a=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=a,this.writeScreen=this.nonDisplayedMemory,this.logger.log(C.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},f.ccTO=function(a){this.logger.log(C.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},f.ccMIDROW=function(a){var b={flash:!1};if(b.underline=a%2===1,b.italics=a>=46,b.italics)b.foreground="white";else{var g=Math.floor(a/2)-16,x=["white","green","blue","cyan","red","yellow","magenta"];b.foreground=x[g]}this.logger.log(C.INFO,"MIDROW: "+JSON.stringify(b)),this.writeScreen.setPen(b)},f.outputDataUpdate=function(a){a===void 0&&(a=!1);var b=this.logger.time;if(b===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=b:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,b,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:b),this.lastOutputScreen.copy(this.displayedMemory))},f.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},c}(),m=function(){function c(d,a,b){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var g=new T;this.channels=[null,new w(d,a,g),new w(d+1,b,g)],this.cmdHistory=p(),this.logger=g}var f=c.prototype;return f.getHandler=function(a){return this.channels[a].getHandler()},f.setHandler=function(a,b){this.channels[a].setHandler(b)},f.addData=function(a,b){var g,x,P,N=!1;this.logger.time=a;for(var H=0;H<b.length;H+=2){if(x=b[H]&127,P=b[H+1]&127,x===0&&P===0)continue;if(this.logger.log(C.DATA,"["+E([b[H],b[H+1]])+"] -> ("+E([x,P])+")"),g=this.parseCmd(x,P),g||(g=this.parseMidrow(x,P)),g||(g=this.parsePAC(x,P)),g||(g=this.parseBackgroundAttributes(x,P)),!g&&(N=this.parseChars(x,P),N)){var X=this.currentChannel;if(X&&X>0){var B=this.channels[X];B.insertChars(N)}else this.logger.log(C.WARNING,"No channel found yet. TEXT-MODE?")}!g&&!N&&this.logger.log(C.WARNING,"Couldn't parse cleaned data "+E([x,P])+" orig: "+E([b[H],b[H+1]]))}},f.parseCmd=function(a,b){var g=this.cmdHistory,x=(a===20||a===28||a===21||a===29)&&b>=32&&b<=47,P=(a===23||a===31)&&b>=33&&b<=35;if(!(x||P))return!1;if(L(a,b,g))return h(null,null,g),this.logger.log(C.DEBUG,"Repeated command ("+E([a,b])+") is dropped"),!0;var N=a===20||a===21||a===23?1:2,H=this.channels[N];return a===20||a===21||a===28||a===29?b===32?H.ccRCL():b===33?H.ccBS():b===34?H.ccAOF():b===35?H.ccAON():b===36?H.ccDER():b===37?H.ccRU(2):b===38?H.ccRU(3):b===39?H.ccRU(4):b===40?H.ccFON():b===41?H.ccRDC():b===42?H.ccTR():b===43?H.ccRTD():b===44?H.ccEDM():b===45?H.ccCR():b===46?H.ccENM():b===47&&H.ccEOC():H.ccTO(b-32),h(a,b,g),this.currentChannel=N,!0},f.parseMidrow=function(a,b){var g=0;if((a===17||a===25)&&b>=32&&b<=47){if(a===17?g=1:g=2,g!==this.currentChannel)return this.logger.log(C.ERROR,"Mismatch channel in midrow parsing"),!1;var x=this.channels[g];return x?(x.ccMIDROW(b),this.logger.log(C.DEBUG,"MIDROW ("+E([a,b])+")"),!0):!1}return!1},f.parsePAC=function(a,b){var g,x=this.cmdHistory,P=(a>=17&&a<=23||a>=25&&a<=31)&&b>=64&&b<=127,N=(a===16||a===24)&&b>=64&&b<=95;if(!(P||N))return!1;if(L(a,b,x))return h(null,null,x),!0;var H=a<=23?1:2;b>=64&&b<=95?g=H===1?R[a]:v[a]:g=H===1?_[a]:S[a];var X=this.channels[H];return X?(X.setPAC(this.interpretPAC(g,b)),h(a,b,x),this.currentChannel=H,!0):!1},f.interpretPAC=function(a,b){var g,x={color:null,italics:!1,indent:null,underline:!1,row:a};return b>95?g=b-96:g=b-64,x.underline=(g&1)===1,g<=13?x.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(g/2)]:g<=15?(x.italics=!0,x.color="white"):x.indent=Math.floor((g-16)/2)*4,x},f.parseChars=function(a,b){var g,x=null,P=null;if(a>=25?(g=2,P=a-8):(g=1,P=a),P>=17&&P<=19){var N;P===17?N=b+80:P===18?N=b+112:N=b+144,this.logger.log(C.INFO,"Special char '"+O(N)+"' in channel "+g),x=[N]}else a>=32&&a<=127&&(x=b===0?[a]:[a,b]);if(x){var H=E(x);this.logger.log(C.DEBUG,"Char codes = "+H.join(",")),h(a,b,this.cmdHistory)}return x},f.parseBackgroundAttributes=function(a,b){var g=(a===16||a===24)&&b>=32&&b<=47,x=(a===23||a===31)&&b>=45&&b<=47;if(!(g||x))return!1;var P,N={};a===16||a===24?(P=Math.floor((b-32)/2),N.background=D[P],b%2===1&&(N.background=N.background+"_semi")):b===45?N.background="transparent":(N.foreground="black",b===47&&(N.underline=!0));var H=a<=23?1:2,X=this.channels[H];return X.setBkgData(N),h(a,b,this.cmdHistory),!0},f.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var b=this.channels[a];b&&b.reset()}this.cmdHistory=p()},f.cueSplitAtTime=function(a){for(var b=0;b<this.channels.length;b++){var g=this.channels[b];g&&g.cueSplitAtTime(a)}},c}();function h(c,f,d){d.a=c,d.b=f}function L(c,f,d){return d.a===c&&d.b===f}function p(){return{a:null,b:null}}G.default=m},"./src/utils/codecs.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"isCodecType",function(){return k}),A.d(G,"isCodecSupportedInMp4",function(){return O});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,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,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function k(U,F){var R=W[F];return!!R&&R[U.slice(0,4)]===!0}function O(U,F){return MediaSource.isTypeSupported((F||"video")+'/mp4;codecs="'+U+'"')}},"./src/utils/cues.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/utils/vttparser.ts"),k=A("./src/utils/webvtt-parser.ts"),O=A("./src/utils/texttrack-utils.ts"),U=/\s/,F={newCue:function(_,v,S,D){for(var C=[],T,E,l,o,s,u=self.VTTCue||self.TextTrackCue,w=0;w<D.rows.length;w++)if(T=D.rows[w],l=!0,o=0,s="",!T.isEmpty()){for(var m=0;m<T.chars.length;m++)U.test(T.chars[m].uchar)&&l?o++:(s+=T.chars[m].uchar,l=!1);T.cueStartTime=v,v===S&&(S+=1e-4),o>=16?o--:o++;var h=Object(W.fixLineBreaks)(s.trim()),L=Object(k.generateCueId)(v,S,h);(!_||!_.cues||!_.cues.getCueById(L))&&(E=new u(v,S,h),E.id=L,E.line=w+1,E.align="left",E.position=10+Math.min(80,Math.floor(o*8/32)*10),C.push(E))}return _&&C.length&&(C.sort(function(p,c){return p.line==="auto"||c.line==="auto"?0:p.line>8&&c.line>8?c.line-p.line:p.line-c.line}),C.forEach(function(p){return Object(O.addCueToTrack)(_,p)})),C}};G.default=F},"./src/utils/discontinuities.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"findFirstFragWithCC",function(){return U}),A.d(G,"shouldAlignOnDiscontinuities",function(){return F}),A.d(G,"findDiscontinuousReferenceFrag",function(){return R}),A.d(G,"adjustSlidingStart",function(){return v}),A.d(G,"alignStream",function(){return S}),A.d(G,"alignPDT",function(){return C}),A.d(G,"alignFragmentByPDTDelta",function(){return T}),A.d(G,"alignMediaPlaylistByPDT",function(){return E});var W=A("./src/polyfills/number.ts"),k=A("./src/utils/logger.ts"),O=A("./src/controller/level-helper.ts");function U(l,o){for(var s=null,u=0,w=l.length;u<w;u++){var m=l[u];if(m&&m.cc===o){s=m;break}}return s}function F(l,o,s){return!!(o.details&&(s.endCC>s.startCC||l&&l.cc<s.startCC))}function R(l,o){var s=l.fragments,u=o.fragments;if(!u.length||!s.length){k.logger.log("No fragments to align");return}var w=U(s,u[0].cc);if(!w||w&&!w.startPTS){k.logger.log("No frag in previous level to align on");return}return w}function _(l,o){if(l){var s=l.start+o;l.start=l.startPTS=s,l.endPTS=s+l.duration}}function v(l,o){for(var s=o.fragments,u=0,w=s.length;u<w;u++)_(s[u],l);o.fragmentHint&&_(o.fragmentHint,l),o.alignedSliding=!0}function S(l,o,s){if(!o)return;D(l,s,o),!s.alignedSliding&&o.details&&C(s,o.details),!s.alignedSliding&&o.details&&!s.skippedSegments&&Object(O.adjustSliding)(o.details,s)}function D(l,o,s){if(F(l,s,o)){var u=R(s.details,o);u&&Object(W.isFiniteNumber)(u.start)&&(k.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),v(u.start,o))}}function C(l,o){if(!o.fragments.length||!l.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,u=l.fragments[0].programDateTime,w=(u-s)/1e3+o.fragments[0].start;w&&Object(W.isFiniteNumber)(w)&&(k.logger.log("Adjusting PTS using programDateTime delta "+(u-s)+"ms, sliding:"+w.toFixed(3)+" "+l.url+" "),v(w,l))}function T(l,o){var s=l.programDateTime;if(!s)return;var u=(s-o)/1e3;l.start=l.startPTS=u,l.endPTS=u+l.duration}function E(l,o){if(!o.fragments.length||!l.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,u=o.fragments[0].start,w=s-u*1e3;l.fragments.forEach(function(m){T(m,w)}),l.fragmentHint&&T(l.fragmentHint,w),l.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/utils/ewma.ts"),k=function(){function O(F,R,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new W.default(F),this.fast_=new W.default(R)}var U=O.prototype;return U.update=function(R,_){var v=this.slow_,S=this.fast_;this.slow_.halfLife!==R&&(this.slow_=new W.default(R,v.getEstimate(),v.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new W.default(_,S.getEstimate(),S.getTotalWeight()))},U.sample=function(R,_){R=Math.max(R,this.minDelayMs_);var v=8*_,S=R/1e3,D=v/S;this.fast_.sample(S,D),this.slow_.sample(S,D)},U.canEstimate=function(){var R=this.fast_;return R&&R.getTotalWeight()>=this.minWeight_},U.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},U.destroy=function(){},O}();G.default=k},"./src/utils/ewma.ts":function(Q,G,A){"use strict";A.r(G);var W=function(){function k(U,F,R){F===void 0&&(F=0),R===void 0&&(R=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=U,this.alpha_=U?Math.exp(Math.log(.5)/U):0,this.estimate_=F,this.totalWeight_=R}var O=k.prototype;return O.sample=function(F,R){var _=Math.pow(this.alpha_,F);this.estimate_=R*(1-_)+_*this.estimate_,this.totalWeight_+=F},O.getTotalWeight=function(){return this.totalWeight_},O.getEstimate=function(){if(this.alpha_){var F=1-Math.pow(this.alpha_,this.totalWeight_);if(F)return this.estimate_/F}return this.estimate_},k}();G.default=W},"./src/utils/fetch-loader.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"fetchSupported",function(){return T});var W=A("./src/polyfills/number.ts"),k=A("./src/loader/load-stats.ts"),O=A("./src/demux/chunk-cache.ts");function U(u,w){u.prototype=Object.create(w.prototype),u.prototype.constructor=u,S(u,w)}function F(u){var w=typeof Map=="function"?new Map:void 0;return F=function(h){if(h===null||!v(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof w!="undefined"){if(w.has(h))return w.get(h);w.set(h,L)}function L(){return R(h,arguments,D(this).constructor)}return L.prototype=Object.create(h.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),S(L,h)},F(u)}function R(u,w,m){return _()?R=Reflect.construct:R=function(L,p,c){var f=[null];f.push.apply(f,p);var d=Function.bind.apply(L,f),a=new d;return c&&S(a,c.prototype),a},R.apply(null,arguments)}function _(){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(u){return!1}}function v(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function S(u,w){return S=Object.setPrototypeOf||function(h,L){return h.__proto__=L,h},S(u,w)}function D(u){return D=Object.setPrototypeOf?Object.getPrototypeOf:function(m){return m.__proto__||Object.getPrototypeOf(m)},D(u)}function C(){return C=Object.assign||function(u){for(var w=1;w<arguments.length;w++){var m=arguments[w];for(var h in m)Object.prototype.hasOwnProperty.call(m,h)&&(u[h]=m[h])}return u},C.apply(this,arguments)}function T(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(u){}return!1}var E=function(){function u(m){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=m.fetchSetup||o,this.controller=new self.AbortController,this.stats=new k.LoadStats}var w=u.prototype;return w.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},w.abortInternal=function(){var h=this.response;(!h||!h.ok)&&(this.stats.aborted=!0,this.controller.abort())},w.abort=function(){var h;this.abortInternal(),(h=this.callbacks)!==null&&h!==void 0&&h.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},w.load=function(h,L,p){var c=this,f=this.stats;if(f.loading.start)throw new Error("Loader can only be used once.");f.loading.start=self.performance.now();var d=l(h,this.controller.signal),a=p.onProgress,b=h.responseType==="arraybuffer",g=b?"byteLength":"length";this.context=h,this.config=L,this.callbacks=p,this.request=this.fetchSetup(h,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){c.abortInternal(),p.onTimeout(f,h,c.response)},L.timeout),self.fetch(this.request).then(function(x){if(c.response=c.loader=x,!x.ok){var P=x.status,N=x.statusText;throw new s(N||"fetch, bad network response",P,x)}return f.loading.first=Math.max(self.performance.now(),f.loading.start),f.total=parseInt(x.headers.get("Content-Length")||"0"),a&&Object(W.isFiniteNumber)(L.highWaterMark)?c.loadProgressively(x,f,h,L.highWaterMark,a):b?x.arrayBuffer():x.text()}).then(function(x){var P=c.response;self.clearTimeout(c.requestTimeout),f.loading.end=Math.max(self.performance.now(),f.loading.first),f.loaded=f.total=x[g];var N={url:P.url,data:x};a&&!Object(W.isFiniteNumber)(L.highWaterMark)&&a(f,h,x,P),p.onSuccess(N,f,h,P)}).catch(function(x){if(self.clearTimeout(c.requestTimeout),f.aborted)return;var P=x.code||0;p.onError({code:P,text:x.message},h,x.details)})},w.getCacheAge=function(){var h=null;if(this.response){var L=this.response.headers.get("age");h=L?parseFloat(L):null}return h},w.loadProgressively=function(h,L,p,c,f){c===void 0&&(c=0);var d=new O.default,a=h.body.getReader(),b=function g(){return a.read().then(function(x){if(x.done)return d.dataLength&&f(L,p,d.flush(),h),Promise.resolve(new ArrayBuffer(0));var P=x.value,N=P.length;return L.loaded+=N,N<c||d.dataLength?(d.push(P),d.dataLength>=c&&f(L,p,d.flush(),h)):f(L,p,P,h),g()}).catch(function(){return Promise.reject()})};return b()},u}();function l(u,w){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:w,headers:new self.Headers(C({},u.headers))};return u.rangeEnd&&m.headers.set("Range","bytes="+u.rangeStart+"-"+String(u.rangeEnd-1)),m}function o(u,w){return new self.Request(u.url,w)}var s=function(u){U(w,u);function w(m,h,L){var p;return p=u.call(this,m)||this,p.code=void 0,p.details=void 0,p.code=h,p.details=L,p}return w}(F(Error));G.default=E},"./src/utils/imsc1-ttml-parser.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"IMSC1_CODEC",function(){return v}),A.d(G,"parseIMSC1",function(){return T});var W=A("./src/utils/mp4-tools.ts"),k=A("./src/utils/vttparser.ts"),O=A("./src/utils/vttcue.ts"),U=A("./src/demux/id3.ts"),F=A("./src/utils/timescale-conversion.ts"),R=A("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign||function(c){for(var f=1;f<arguments.length;f++){var d=arguments[f];for(var a in d)Object.prototype.hasOwnProperty.call(d,a)&&(c[a]=d[a])}return c},_.apply(this,arguments)}var v="stpp.ttml.im1t",S=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,C={left:"start",center:"center",right:"end",start:"start",end:"end"};function T(c,f,d,a,b){var g=Object(W.findBox)(new Uint8Array(c),["mdat"]);if(g.length===0){b(new Error("Could not parse IMSC1 mdat"));return}var x=g[0],P=Object(U.utf8ArrayToStr)(new Uint8Array(c,x.start,x.end-x.start)),N=Object(F.toTimescaleFromScale)(f,1,d);try{a(E(P,N))}catch(H){b(H)}}function E(c,f){var d=new DOMParser,a=d.parseFromString(c,"text/xml"),b=a.getElementsByTagName("tt")[0];if(!b)throw new Error("Invalid ttml");var g={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},x=Object.keys(g).reduce(function(B,I){return B[I]=b.getAttribute("ttp:"+I)||g[I],B},{}),P=b.getAttribute("xml:space")!=="preserve",N=o(l(b,"styling","style")),H=o(l(b,"layout","region")),X=l(b,"body","[begin]");return[].map.call(X,function(B){var I=s(B,P);if(!I||!B.hasAttribute("begin"))return null;var Y=h(B.getAttribute("begin"),x),te=h(B.getAttribute("dur"),x),se=h(B.getAttribute("end"),x);if(Y===null)throw m(B);if(se===null){if(te===null)throw m(B);se=Y+te}var de=new O.default(Y-f,se-f,I);de.id=Object(R.generateCueId)(de.startTime,de.endTime,de.text);var Se=H[B.getAttribute("region")],ge=N[B.getAttribute("style")];de.position=10,de.size=80;var pe=u(Se,ge),he=pe.textAlign;if(he){var me=C[he];me&&(de.lineAlign=me),de.align=he}return _(de,pe),de}).filter(function(B){return B!==null})}function l(c,f,d){var a=c.getElementsByTagName(f)[0];return a?[].slice.call(a.querySelectorAll(d)):[]}function o(c){return c.reduce(function(f,d){var a=d.getAttribute("xml:id");return a&&(f[a]=d),f},{})}function s(c,f){return[].slice.call(c.childNodes).reduce(function(d,a,b){var g;return a.nodeName==="br"&&b?d+`
|
|
`:(g=a.childNodes)!==null&&g!==void 0&&g.length?s(a,f):f?d+a.textContent.trim().replace(/\s+/g," "):d+a.textContent},"")}function u(c,f){var d="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(b,g){var x=w(f,d,g)||w(c,d,g);return x&&(b[g]=x),b},{})}function w(c,f,d){return c.hasAttributeNS(f,d)?c.getAttributeNS(f,d):null}function m(c){return new Error("Could not parse ttml timestamp "+c)}function h(c,f){if(!c)return null;var d=Object(k.parseTimeStamp)(c);return d===null&&(S.test(c)?d=L(c,f):D.test(c)&&(d=p(c,f))),d}function L(c,f){var d=S.exec(c),a=(d[4]|0)+(d[5]|0)/f.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+a/f.frameRate}function p(c,f){var d=D.exec(c),a=Number(d[1]),b=d[2];switch(b){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/f.frameRate;case"t":return a/f.tickRate}return a}},"./src/utils/logger.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"enableLogs",function(){return R}),A.d(G,"logger",function(){return _});var W=function(){},k={trace:W,debug:W,log:W,warn:W,info:W,error:W},O=k;function U(v){var S=self.console[v];return S?S.bind(self.console,"["+v+"] >"):W}function F(v){for(var S=arguments.length,D=new Array(S>1?S-1:0),C=1;C<S;C++)D[C-1]=arguments[C];D.forEach(function(T){O[T]=v[T]?v[T].bind(v):U(T)})}function R(v){if(self.console&&v===!0||typeof v=="object"){F(v,"debug","log","info","warn","error");try{O.log()}catch(S){O=k}}else O=k}var _=O},"./src/utils/mediakeys-helper.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"KeySystems",function(){return W}),A.d(G,"requestMediaKeySystemAccess",function(){return k});var W;(function(O){O.WIDEVINE="com.widevine.alpha",O.PLAYREADY="com.microsoft.playready"})(W||(W={}));var k=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"getMediaSource",function(){return W});function W(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"bin2str",function(){return F}),A.d(G,"readUint16",function(){return R}),A.d(G,"readUint32",function(){return _}),A.d(G,"writeUint32",function(){return v}),A.d(G,"findBox",function(){return S}),A.d(G,"parseSegmentIndex",function(){return D}),A.d(G,"parseInitSegment",function(){return C}),A.d(G,"getStartDTS",function(){return T}),A.d(G,"getDuration",function(){return E}),A.d(G,"computeRawDurationFromSamples",function(){return l}),A.d(G,"offsetStartDTS",function(){return o}),A.d(G,"segmentValidRange",function(){return s}),A.d(G,"appendUint8Array",function(){return u});var W=A("./src/utils/typed-array.ts"),k=A("./src/loader/fragment.ts"),O=Math.pow(2,32)-1,U=[].push;function F(w){return String.fromCharCode.apply(null,w)}function R(w,m){"data"in w&&(m+=w.start,w=w.data);var h=w[m]<<8|w[m+1];return h<0?65536+h:h}function _(w,m){"data"in w&&(m+=w.start,w=w.data);var h=w[m]<<24|w[m+1]<<16|w[m+2]<<8|w[m+3];return h<0?4294967296+h:h}function v(w,m,h){"data"in w&&(m+=w.start,w=w.data),w[m]=h>>24,w[m+1]=h>>16&255,w[m+2]=h>>8&255,w[m+3]=h&255}function S(w,m){var h=[];if(!m.length)return h;var L,p,c;"data"in w?(L=w.data,p=w.start,c=w.end):(L=w,p=0,c=L.byteLength);for(var f=p;f<c;){var d=_(L,f),a=F(L.subarray(f+4,f+8)),b=d>1?f+d:c;if(a===m[0])if(m.length===1)h.push({data:L,start:f+8,end:b});else{var g=S({data:L,start:f+8,end:b},m.slice(1));g.length&&U.apply(h,g)}f=b}return h}function D(w){var m=S(w,["moov"]),h=m[0],L=h?h.end:null,p=S(w,["sidx"]);if(!p||!p[0])return null;var c=[],f=p[0],d=f.data[0],a=d===0?8:16,b=_(f,a);a+=4;var g=0,x=0;d===0?a+=8:a+=16,a+=2;var P=f.end+x,N=R(f,a);a+=2;for(var H=0;H<N;H++){var X=a,B=_(f,X);X+=4;var I=B&2147483647,Y=(B&2147483648)>>>31;if(Y===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var te=_(f,X);X+=4,c.push({referenceSize:I,subsegmentDuration:te,info:{duration:te/b,start:P,end:P+I-1}}),P+=I,X+=4,a=X}return{earliestPresentationTime:g,timescale:b,version:d,referencesCount:N,references:c,moovEndOffset:L}}function C(w){for(var m=[],h=S(w,["moov","trak"]),L=0;L<h.length;L++){var p=h[L],c=S(p,["tkhd"])[0];if(c){var f=c.data[c.start],d=f===0?12:20,a=_(c,d),b=S(p,["mdia","mdhd"])[0];if(b){f=b.data[b.start],d=f===0?12:20;var g=_(b,d),x=S(p,["mdia","hdlr"])[0];if(x){var P=F(x.data.subarray(x.start+8,x.start+12)),N={soun:k.ElementaryStreamTypes.AUDIO,vide:k.ElementaryStreamTypes.VIDEO}[P];if(N){var H=S(p,["mdia","minf","stbl","stsd"])[0],X=void 0;H&&(X=F(H.data.subarray(H.start+12,H.start+16))),m[a]={timescale:g,type:N},m[N]={timescale:g,id:a,codec:X}}}}}}var B=S(w,["moov","mvex","trex"]);return B.forEach(function(I){var Y=_(I,4),te=m[Y];te&&(te.default={duration:_(I,12),flags:_(I,20)})}),m}function T(w,m){return S(m,["moof","traf"]).reduce(function(h,L){var p=S(L,["tfdt"])[0],c=p.data[p.start],f=S(L,["tfhd"]).reduce(function(d,a){var b=_(a,4),g=w[b];if(g){var x=_(p,4);c===1&&(x*=Math.pow(2,32),x+=_(p,8));var P=g.timescale||9e4,N=x/P;if(isFinite(N)&&(d===null||N<d))return N}return d},null);return f!==null&&isFinite(f)&&(h===null||f<h)?f:h},null)||0}function E(w,m){for(var h=0,L=0,p=0,c=S(w,["moof","traf"]),f=0;f<c.length;f++){var d=c[f],a=S(d,["tfhd"])[0],b=_(a,4),g=m[b];if(!g)continue;var x=g.default,P=_(a,0)|(x==null?void 0:x.flags),N=x==null?void 0:x.duration;P&8&&(P&2?N=_(a,12):N=_(a,8));for(var H=g.timescale||9e4,X=S(d,["trun"]),B=0;B<X.length;B++){if(N){var I=_(X[B],4);h=N*I}else h=l(X[B]);g.type===k.ElementaryStreamTypes.VIDEO?L+=h/H:g.type===k.ElementaryStreamTypes.AUDIO&&(p+=h/H)}}if(L===0&&p===0){var Y=D(w);if(Y!=null&&Y.references)return Y.references.reduce(function(te,se){return te+se.info.duration||0},0)}return L||p}function l(w){var m=_(w,0),h=8;m&1&&(h+=4),m&4&&(h+=4);for(var L=0,p=_(w,4),c=0;c<p;c++){if(m&256){var f=_(w,h);L+=f,h+=4}m&512&&(h+=4),m&1024&&(h+=4),m&2048&&(h+=4)}return L}function o(w,m,h){S(m,["moof","traf"]).forEach(function(L){S(L,["tfhd"]).forEach(function(p){var c=_(p,4),f=w[c];if(!f)return;var d=f.timescale||9e4;S(L,["tfdt"]).forEach(function(a){var b=a.data[a.start],g=_(a,4);if(b===0)v(a,4,g-h*d);else{g*=Math.pow(2,32),g+=_(a,8),g-=h*d,g=Math.max(g,0);var x=Math.floor(g/(O+1)),P=Math.floor(g%(O+1));v(a,4,x),v(a,8,P)}})})})}function s(w){var m={valid:null,remainder:null},h=S(w,["moof"]);if(h){if(h.length<2)return m.remainder=w,m}else return m;var L=h[h.length-1];return m.valid=Object(W.sliceUint8)(w,0,L.start-8),m.remainder=Object(W.sliceUint8)(w,L.start-8),m}function u(w,m){var h=new Uint8Array(w.length+m.length);return h.set(w),h.set(m,w.length),h}},"./src/utils/output-filter.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"default",function(){return W});var W=function(){function k(U,F){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=U,this.trackName=F}var O=k.prototype;return O.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},O.newCue=function(F,R,_){(this.startTime===null||this.startTime>F)&&(this.startTime=F),this.endTime=R,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},O.reset=function(){this.cueRanges=[]},k}()},"./src/utils/texttrack-utils.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"sendAddTrackEvent",function(){return k}),A.d(G,"addCueToTrack",function(){return O}),A.d(G,"clearCurrentCues",function(){return U}),A.d(G,"removeCuesInRange",function(){return F}),A.d(G,"getCuesInRange",function(){return _});var W=A("./src/utils/logger.ts");function k(v,S){var D;try{D=new Event("addtrack")}catch(C){D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=v,S.dispatchEvent(D)}function O(v,S){var D=v.mode;if(D==="disabled"&&(v.mode="hidden"),v.cues&&!v.cues.getCueById(S.id))try{if(v.addCue(S),!v.cues.getCueById(S.id))throw new Error("addCue is failed for: "+S)}catch(T){W.logger.debug("[texttrack-utils]: "+T);var C=new self.TextTrackCue(S.startTime,S.endTime,S.text);C.id=S.id,v.addCue(C)}D==="disabled"&&(v.mode=D)}function U(v){var S=v.mode;if(S==="disabled"&&(v.mode="hidden"),v.cues)for(var D=v.cues.length;D--;)v.removeCue(v.cues[D]);S==="disabled"&&(v.mode=S)}function F(v,S,D){var C=v.mode;if(C==="disabled"&&(v.mode="hidden"),v.cues&&v.cues.length>0)for(var T=_(v.cues,S,D),E=0;E<T.length;E++)v.removeCue(T[E]);C==="disabled"&&(v.mode=C)}function R(v,S){if(S<v[0].startTime)return 0;var D=v.length-1;if(S>v[D].endTime)return-1;for(var C=0,T=D;C<=T;){var E=Math.floor((T+C)/2);if(S<v[E].startTime)T=E-1;else if(S>v[E].startTime&&C<D)C=E+1;else return E}return v[C].startTime-S<S-v[T].startTime?C:T}function _(v,S,D){var C=[],T=R(v,S);if(T>-1)for(var E=T,l=v.length;E<l;E++){var o=v[E];if(o.startTime>=S&&o.endTime<=D)C.push(o);else if(o.startTime>D)return C}return C}},"./src/utils/time-ranges.ts":function(Q,G,A){"use strict";A.r(G);var W={toString:function(O){for(var U="",F=O.length,R=0;R<F;R++)U+="["+O.start(R).toFixed(3)+","+O.end(R).toFixed(3)+"]";return U}};G.default=W},"./src/utils/timescale-conversion.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"toTimescaleFromBase",function(){return k}),A.d(G,"toTimescaleFromScale",function(){return O}),A.d(G,"toMsFromMpegTsClock",function(){return U}),A.d(G,"toMpegTsClockFromTimescale",function(){return F});var W=9e4;function k(R,_,v,S){v===void 0&&(v=1),S===void 0&&(S=!1);var D=R*_*v;return S?Math.round(D):D}function O(R,_,v,S){return v===void 0&&(v=1),S===void 0&&(S=!1),k(R,_,1/v,S)}function U(R,_){return _===void 0&&(_=!1),k(R,1e3,1/W,_)}function F(R,_){return _===void 0&&(_=1),k(R,W,1/_)}},"./src/utils/typed-array.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"sliceUint8",function(){return W});function W(k,O,U){return Uint8Array.prototype.slice?k.slice(O,U):new Uint8Array(Array.prototype.slice.call(k,O,U))}},"./src/utils/vttcue.ts":function(Q,G,A){"use strict";A.r(G),G.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var W=["","lr","rl"],k=["start","middle","end","left","right"];function O(v,S){if(typeof S!="string")return!1;if(!Array.isArray(v))return!1;var D=S.toLowerCase();return~v.indexOf(D)?D:!1}function U(v){return O(W,v)}function F(v){return O(k,v)}function R(v){for(var S=arguments.length,D=new Array(S>1?S-1:0),C=1;C<S;C++)D[C-1]=arguments[C];for(var T=1;T<arguments.length;T++){var E=arguments[T];for(var l in E)v[l]=E[l]}return v}function _(v,S,D){var C=this,T={enumerable:!0};C.hasBeenReset=!1;var E="",l=!1,o=v,s=S,u=D,w=null,m="",h=!0,L="auto",p="start",c=50,f="middle",d=50,a="middle";Object.defineProperty(C,"id",R({},T,{get:function(){return E},set:function(g){E=""+g}})),Object.defineProperty(C,"pauseOnExit",R({},T,{get:function(){return l},set:function(g){l=!!g}})),Object.defineProperty(C,"startTime",R({},T,{get:function(){return o},set:function(g){if(typeof g!="number")throw new TypeError("Start time must be set to a number.");o=g,this.hasBeenReset=!0}})),Object.defineProperty(C,"endTime",R({},T,{get:function(){return s},set:function(g){if(typeof g!="number")throw new TypeError("End time must be set to a number.");s=g,this.hasBeenReset=!0}})),Object.defineProperty(C,"text",R({},T,{get:function(){return u},set:function(g){u=""+g,this.hasBeenReset=!0}})),Object.defineProperty(C,"region",R({},T,{get:function(){return w},set:function(g){w=g,this.hasBeenReset=!0}})),Object.defineProperty(C,"vertical",R({},T,{get:function(){return m},set:function(g){var x=U(g);if(x===!1)throw new SyntaxError("An invalid or illegal string was specified.");m=x,this.hasBeenReset=!0}})),Object.defineProperty(C,"snapToLines",R({},T,{get:function(){return h},set:function(g){h=!!g,this.hasBeenReset=!0}})),Object.defineProperty(C,"line",R({},T,{get:function(){return L},set:function(g){if(typeof g!="number"&&g!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");L=g,this.hasBeenReset=!0}})),Object.defineProperty(C,"lineAlign",R({},T,{get:function(){return p},set:function(g){var x=F(g);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");p=x,this.hasBeenReset=!0}})),Object.defineProperty(C,"position",R({},T,{get:function(){return c},set:function(g){if(g<0||g>100)throw new Error("Position must be between 0 and 100.");c=g,this.hasBeenReset=!0}})),Object.defineProperty(C,"positionAlign",R({},T,{get:function(){return f},set:function(g){var x=F(g);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");f=x,this.hasBeenReset=!0}})),Object.defineProperty(C,"size",R({},T,{get:function(){return d},set:function(g){if(g<0||g>100)throw new Error("Size must be between 0 and 100.");d=g,this.hasBeenReset=!0}})),Object.defineProperty(C,"align",R({},T,{get:function(){return a},set:function(g){var x=F(g);if(!x)throw new SyntaxError("An invalid or illegal string was specified.");a=x,this.hasBeenReset=!0}})),C.displayState=void 0}return _.prototype.getCueAsHTML=function(){var v=self.WebVTT;return v.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"parseTimeStamp",function(){return O}),A.d(G,"fixLineBreaks",function(){return S}),A.d(G,"VTTParser",function(){return D});var W=A("./src/utils/vttcue.ts"),k=function(){function C(){}var T=C.prototype;return T.decode=function(l,o){if(!l)return"";if(typeof l!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(l))},C}();function O(C){function T(l,o,s,u){return(l|0)*3600+(o|0)*60+(s|0)+parseFloat(u||0)}var E=C.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return E?parseFloat(E[2])>59?T(E[2],E[3],0,E[4]):T(E[1],E[2],E[3],E[4]):null}var U=function(){function C(){this.values=Object.create(null)}var T=C.prototype;return T.set=function(l,o){!this.get(l)&&o!==""&&(this.values[l]=o)},T.get=function(l,o,s){return s?this.has(l)?this.values[l]:o[s]:this.has(l)?this.values[l]:o},T.has=function(l){return l in this.values},T.alt=function(l,o,s){for(var u=0;u<s.length;++u)if(o===s[u]){this.set(l,o);break}},T.integer=function(l,o){/^-?\d+$/.test(o)&&this.set(l,parseInt(o,10))},T.percent=function(l,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var s=parseFloat(o);if(s>=0&&s<=100)return this.set(l,s),!0}return!1},C}();function F(C,T,E,l){var o=l?C.split(l):[C];for(var s in o){if(typeof o[s]!="string")continue;var u=o[s].split(E);if(u.length!==2)continue;var w=u[0],m=u[1];T(w,m)}}var R=new W.default(0,0,""),_=R.align==="middle"?"middle":"center";function v(C,T,E){var l=C;function o(){var w=O(C);if(w===null)throw new Error("Malformed timestamp: "+l);return C=C.replace(/^[^\sa-zA-Z-]+/,""),w}function s(w,m){var h=new U;F(w,function(c,f){var d;switch(c){case"region":for(var a=E.length-1;a>=0;a--)if(E[a].id===f){h.set(c,E[a].region);break}break;case"vertical":h.alt(c,f,["rl","lr"]);break;case"line":d=f.split(","),h.integer(c,d[0]),h.percent(c,d[0])&&h.set("snapToLines",!1),h.alt(c,d[0],["auto"]),d.length===2&&h.alt("lineAlign",d[1],["start",_,"end"]);break;case"position":d=f.split(","),h.percent(c,d[0]),d.length===2&&h.alt("positionAlign",d[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":h.percent(c,f);break;case"align":h.alt(c,f,["start",_,"end","left","right"]);break}},/:/,/\s/),m.region=h.get("region",null),m.vertical=h.get("vertical","");var L=h.get("line","auto");L==="auto"&&R.line===-1&&(L=-1),m.line=L,m.lineAlign=h.get("lineAlign","start"),m.snapToLines=h.get("snapToLines",!0),m.size=h.get("size",100),m.align=h.get("align",_);var p=h.get("position","auto");p==="auto"&&R.position===50&&(p=m.align==="start"||m.align==="left"?0:m.align==="end"||m.align==="right"?100:50),m.position=p}function u(){C=C.replace(/^\s+/,"")}if(u(),T.startTime=o(),u(),C.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+l);C=C.substr(3),u(),T.endTime=o(),u(),s(C,T)}function S(C){return C.replace(/<br(?: \/)?>/gi,`
|
|
`)}var D=function(){function C(){this.state="INITIAL",this.buffer="",this.decoder=new k,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var T=C.prototype;return T.parse=function(l){var o=this;l&&(o.buffer+=o.decoder.decode(l,{stream:!0}));function s(){var p=o.buffer,c=0;for(p=S(p);c<p.length&&p[c]!=="\r"&&p[c]!==`
|
|
`;)++c;var f=p.substr(0,c);return p[c]==="\r"&&++c,p[c]===`
|
|
`&&++c,o.buffer=p.substr(c),f}function u(p){F(p,function(c,f){},/:/)}try{var w="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;w=s();var m=w.match(/^()?WEBVTT([ \t].*)?$/);if(!m||!m[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var h=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;h?h=!1:w=s();switch(o.state){case"HEADER":/:/.test(w)?u(w):w||(o.state="ID");continue;case"NOTE":w||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(w)){o.state="NOTE";break}if(!w)continue;if(o.cue=new W.default(0,0,""),o.state="CUE",w.indexOf("-->")===-1){o.cue.id=w;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{v(w,o.cue,o.regionList)}catch(p){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var L=w.indexOf("-->")!==-1;if(!w||L&&(h=!0)){o.oncue&&o.cue&&o.oncue(o.cue),o.cue=null,o.state="ID";continue}if(o.cue===null)continue;o.cue.text&&(o.cue.text+=`
|
|
`),o.cue.text+=w}continue;case"BADCUE":w||(o.state="ID")}}}catch(p){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},T.flush=function(){var l=this;try{if((l.cue||l.state==="HEADER")&&(l.buffer+=`
|
|
|
|
`,l.parse()),l.state==="INITIAL"||l.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){l.onparsingerror&&l.onparsingerror(o)}return l.onflush&&l.onflush(),this},C}()},"./src/utils/webvtt-parser.ts":function(Q,G,A){"use strict";A.r(G),A.d(G,"generateCueId",function(){return D}),A.d(G,"parseWebVTT",function(){return T});var W=A("./src/polyfills/number.ts"),k=A("./src/utils/vttparser.ts"),O=A("./src/demux/id3.ts"),U=A("./src/utils/timescale-conversion.ts"),F=A("./src/remux/mp4-remuxer.ts"),R=/\r\n|\n\r|\n|\r/g,_=function(l,o,s){return s===void 0&&(s=0),l.substr(s,o.length)===o},v=function(l){var o=parseInt(l.substr(-3)),s=parseInt(l.substr(-6,2)),u=parseInt(l.substr(-9,2)),w=l.length>9?parseInt(l.substr(0,l.indexOf(":"))):0;if(!Object(W.isFiniteNumber)(o)||!Object(W.isFiniteNumber)(s)||!Object(W.isFiniteNumber)(u)||!Object(W.isFiniteNumber)(w))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+l);return o+=1e3*s,o+=60*1e3*u,o+=60*60*1e3*w,o},S=function(l){for(var o=5381,s=l.length;s;)o=o*33^l.charCodeAt(--s);return(o>>>0).toString()};function D(E,l,o){return S(E.toString())+S(l.toString())+S(o)}var C=function(l,o,s){var u=l[o],w=l[u.prevCC];if(!w||!w.new&&u.new){l.ccOffset=l.presentationOffset=u.start,u.new=!1;return}for(;(m=w)!==null&&m!==void 0&&m.new;){var m;l.ccOffset+=u.start-w.start,u.new=!1,u=w,w=l[u.prevCC]}l.presentationOffset=s};function T(E,l,o,s,u,w,m,h){var L=new k.VTTParser,p=Object(O.utf8ArrayToStr)(new Uint8Array(E)).trim().replace(R,`
|
|
`).split(`
|
|
`),c=[],f=Object(U.toMpegTsClockFromTimescale)(l,o),d="00:00.000",a=0,b=0,g,x=!0,P=!1;L.oncue=function(N){var H=s[u],X=s.ccOffset,B=(a-f)/9e4;if(H!=null&&H.new&&(b!==void 0?X=s.ccOffset=H.start:C(s,u,B)),B&&(X=B-s.presentationOffset),P){var I=N.endTime-N.startTime,Y=Object(F.normalizePts)((N.startTime+X-b)*9e4,w*9e4)/9e4;N.startTime=Y,N.endTime=Y+I}var te=N.text.trim();N.text=decodeURIComponent(encodeURIComponent(te)),N.id||(N.id=D(N.startTime,N.endTime,te)),N.endTime>0&&c.push(N)},L.onparsingerror=function(N){g=N},L.onflush=function(){if(g){h(g);return}m(c)},p.forEach(function(N){if(x)if(_(N,"X-TIMESTAMP-MAP=")){x=!1,P=!0,N.substr(16).split(",").forEach(function(H){_(H,"LOCAL:")?d=H.substr(6):_(H,"MPEGTS:")&&(a=parseInt(H.substr(7)))});try{b=v(d)/1e3}catch(H){P=!1,g=H}return}else N===""&&(x=!1);L.parse(N+`
|
|
`)}),L.flush()}},"./src/utils/xhr-loader.ts":function(Q,G,A){"use strict";A.r(G);var W=A("./src/utils/logger.ts"),k=A("./src/loader/load-stats.ts"),O=/^age:\s*[\d.]+\s*$/m,U=function(){function F(_){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=_?_.xhrSetup:null,this.stats=new k.LoadStats,this.retryDelay=0}var R=F.prototype;return R.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},R.abortInternal=function(){var v=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),v&&(v.onreadystatechange=null,v.onprogress=null,v.readyState!==4&&(this.stats.aborted=!0,v.abort()))},R.abort=function(){var v;this.abortInternal(),(v=this.callbacks)!==null&&v!==void 0&&v.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},R.load=function(v,S,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=v,this.config=S,this.callbacks=D,this.retryDelay=S.retryDelay,this.loadInternal()},R.loadInternal=function(){var v=this.config,S=this.context;if(!v)return;var D=this.loader=new self.XMLHttpRequest,C=this.stats;C.loading.first=0,C.loaded=0;var T=this.xhrSetup;try{if(T)try{T(D,S.url)}catch(o){D.open("GET",S.url,!0),T(D,S.url)}D.readyState||D.open("GET",S.url,!0);var E=this.context.headers;if(E)for(var l in E)D.setRequestHeader(l,E[l])}catch(o){this.callbacks.onError({code:D.status,text:o.message},S,D);return}S.rangeEnd&&D.setRequestHeader("Range","bytes="+S.rangeStart+"-"+(S.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=S.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout),D.send()},R.readystatechange=function(){var v=this.context,S=this.loader,D=this.stats;if(!v||!S)return;var C=S.readyState,T=this.config;if(D.aborted)return;if(C>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),C===4){S.onreadystatechange=null,S.onprogress=null;var E=S.status;if(E>=200&&E<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var l,o;if(v.responseType==="arraybuffer"?(l=S.response,o=l.byteLength):(l=S.responseText,o=l.length),D.loaded=D.total=o,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(D,v,l,S),!this.callbacks)return;var u={url:S.responseURL,data:l};this.callbacks.onSuccess(u,D,v,S)}else D.retry>=T.maxRetry||E>=400&&E<499?(W.logger.error(E+" while loading "+v.url),this.callbacks.onError({code:E,text:S.statusText},v,S)):(W.logger.warn(E+" while loading "+v.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,T.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),T.timeout)},R.loadtimeout=function(){W.logger.warn("timeout while loading "+this.context.url);var v=this.callbacks;v&&(this.abortInternal(),v.onTimeout(this.stats,this.context,this.loader))},R.loadprogress=function(v){var S=this.stats;S.loaded=v.loaded,v.lengthComputable&&(S.total=v.total)},R.getCacheAge=function(){var v=null;if(this.loader&&O.test(this.loader.getAllResponseHeaders())){var S=this.loader.getResponseHeader("age");v=S?parseFloat(S):null}return v},F}();G.default=U}}).default})}}]);
|