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

361 lines
898 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[269,7,8],{"+NIl":function(dt,et,le){(function(fe){fe(le("VrN/"))})(function(fe){"use strict";fe.defineMode("stex",function(J,_){"use strict";function $(A,C){A.cmdState.push(C)}function I(A){return A.cmdState.length>0?A.cmdState[A.cmdState.length-1]:null}function D(A){var C=A.cmdState.pop();C&&C.closeBracket()}function j(A){for(var C=A.cmdState,S=C.length-1;S>=0;S--){var u=C[S];if(u.name=="DEFAULT")continue;return u}return{styleIdentifier:function(){return null}}}function U(A,C,S){return function(){this.name=A,this.bracketNo=0,this.style=C,this.styles=S,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var P={};P.importmodule=U("importmodule","tag",["string","builtin"]),P.documentclass=U("documentclass","tag",["","atom"]),P.usepackage=U("usepackage","tag",["atom"]),P.begin=U("begin","tag",["atom"]),P.end=U("end","tag",["atom"]),P.label=U("label","tag",["atom"]),P.ref=U("ref","tag",["atom"]),P.eqref=U("eqref","tag",["atom"]),P.cite=U("cite","tag",["atom"]),P.bibitem=U("bibitem","tag",["atom"]),P.Bibitem=U("Bibitem","tag",["atom"]),P.RBibitem=U("RBibitem","tag",["atom"]),P.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function O(A,C){A.f=C}function v(A,C){var S;if(A.match(/^\\[a-zA-Z@]+/)){var u=A.current().slice(1);return S=P.hasOwnProperty(u)?P[u]:P.DEFAULT,S=new S,$(C,S),O(C,R),S.style}if(A.match(/^\\[$&%#{}_]/))return"tag";if(A.match(/^\\[,;!\/\\]/))return"tag";if(A.match("\\["))return O(C,function(s,l){return T(s,l,"\\]")}),"keyword";if(A.match("\\("))return O(C,function(s,l){return T(s,l,"\\)")}),"keyword";if(A.match("$$"))return O(C,function(s,l){return T(s,l,"$$")}),"keyword";if(A.match("$"))return O(C,function(s,l){return T(s,l,"$")}),"keyword";var o=A.next();if(o=="%")return A.skipToEnd(),"comment";if(o=="}"||o=="]"){if(S=I(C),S)S.closeBracket(o),O(C,R);else return"error";return"bracket"}else return o=="{"||o=="["?(S=P.DEFAULT,S=new S,$(C,S),"bracket"):/\d/.test(o)?(A.eatWhile(/[\w.%]/),"atom"):(A.eatWhile(/[\w\-_]/),S=j(C),S.name=="begin"&&(S.argument=A.current()),S.styleIdentifier())}function T(A,C,S){if(A.eatSpace())return null;if(S&&A.match(S))return O(C,v),"keyword";if(A.match(/^\\[a-zA-Z@]+/))return"tag";if(A.match(/^[a-zA-Z]+/))return"variable-2";if(A.match(/^\\[$&%#{}_]/))return"tag";if(A.match(/^\\[,;!\/]/))return"tag";if(A.match(/^[\^_&]/))return"tag";if(A.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(A.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var u=A.next();return u=="{"||u=="}"||u=="["||u=="]"||u=="("||u==")"?"bracket":u=="%"?(A.skipToEnd(),"comment"):"error"}function R(A,C){var S=A.peek(),u;return S=="{"||S=="["?(u=I(C),u.openBracket(S),A.eat(S),O(C,v),"bracket"):/[ \t\r]/.test(S)?(A.eat(S),null):(O(C,v),D(C),v(A,C))}return{startState:function(){var A=_.inMathMode?function(C,S){return T(C,S)}:v;return{cmdState:[],f:A}},copyState:function(A){return{cmdState:A.cmdState.slice(),f:A.f}},token:function(A,C){return C.f(A,C)},blankLine:function(A){A.f=v,A.cmdState.length=0},lineComment:"%"}}),fe.defineMIME("text/x-stex","stex"),fe.defineMIME("text/x-latex","stex")})},"19Vz":function(dt,et,le){(function(fe){fe(le("VrN/"))})(function(fe){fe.defineOption("placeholder","",function(U,P,O){var v=O&&O!=fe.Init;if(P&&!v)U.on("blur",I),U.on("change",D),U.on("swapDoc",D),fe.on(U.getInputField(),"compositionupdate",U.state.placeholderCompose=function(){$(U)}),D(U);else if(!P&&v){U.off("blur",I),U.off("change",D),U.off("swapDoc",D),fe.off(U.getInputField(),"compositionupdate",U.state.placeholderCompose),J(U);var T=U.getWrapperElement();T.className=T.className.replace(" CodeMirror-empty","")}P&&!U.hasFocus()&&I(U)});function J(U){U.state.placeholder&&(U.state.placeholder.parentNode.removeChild(U.state.placeholder),U.state.placeholder=null)}function _(U){J(U);var P=U.state.placeholder=document.createElement("pre");P.style.cssText="height: 0; overflow: visible",P.style.direction=U.getOption("direction"),P.className="CodeMirror-placeholder CodeMirror-line-like";var O=U.getOption("placeholder");typeof O=="string"&&(O=document.createTextNode(O)),P.appendChild(O),U.display.lineSpace.insertBefore(P,U.display.lineSpace.firstChild)}function $(U){setTimeout(function(){var P=!1,O=U.getInputField();O.nodeName=="TEXTAREA"?P=!O.value:U.lineCount()==1&&(P=!/[^\u200b]/.test(O.querySelector(".CodeMirror-line").textContent)),P?_(U):J(U)},20)}function I(U){j(U)&&_(U)}function D(U){var P=U.getWrapperElement(),O=j(U);P.className=P.className.replace(" CodeMirror-empty","")+(O?" CodeMirror-empty":""),O?_(U):J(U)}function j(U){return U.lineCount()===1&&U.getLine(0)===""}})},"1eCo":function(dt,et,le){(function(fe){fe(le("VrN/"))})(function(fe){"use strict";var J={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},_={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};fe.defineMode("xml",function($,I){var D=$.indentUnit,j={},U=I.htmlMode?J:_;for(var P in U)j[P]=U[P];for(var P in I)j[P]=I[P];var O,v;function T(a,x){function p(G){return x.tokenize=G,G(a,x)}var b=a.next();if(b=="<")return a.eat("!")?a.eat("[")?a.match("CDATA[")?p(C("atom","]]>")):null:a.match("--")?p(C("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),p(S(1))):null:a.eat("?")?(a.eatWhile(/[\w\._\-]/),x.tokenize=C("meta","?>"),"meta"):(O=a.eat("/")?"closeTag":"openTag",x.tokenize=R,"tag bracket");if(b=="&"){var M;return a.eat("#")?a.eat("x")?M=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):M=a.eatWhile(/[\d]/)&&a.eat(";"):M=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),M?"atom":"error"}else return a.eatWhile(/[^&<]/),null}T.isInText=!0;function R(a,x){var p=a.next();if(p==">"||p=="/"&&a.eat(">"))return x.tokenize=T,O=p==">"?"endTag":"selfcloseTag","tag bracket";if(p=="=")return O="equals",null;if(p=="<"){x.tokenize=T,x.state=l,x.tagName=x.tagStart=null;var b=x.tokenize(a,x);return b?b+" tag error":"tag error"}else return/[\'\"]/.test(p)?(x.tokenize=A(p),x.stringStartCol=a.column(),x.tokenize(a,x)):(a.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function A(a){var x=function(p,b){for(;!p.eol();)if(p.next()==a){b.tokenize=R;break}return"string"};return x.isInAttribute=!0,x}function C(a,x){return function(p,b){for(;!p.eol();){if(p.match(x)){b.tokenize=T;break}p.next()}return a}}function S(a){return function(x,p){for(var b;(b=x.next())!=null;){if(b=="<")return p.tokenize=S(a+1),p.tokenize(x,p);if(b==">")if(a==1){p.tokenize=T;break}else return p.tokenize=S(a-1),p.tokenize(x,p)}return"meta"}}function u(a,x,p){this.prev=a.context,this.tagName=x,this.indent=a.indented,this.startOfLine=p,(j.doNotIndent.hasOwnProperty(x)||a.context&&a.context.noIndent)&&(this.noIndent=!0)}function o(a){a.context&&(a.context=a.context.prev)}function s(a,x){for(var p;;){if(!a.context)return;if(p=a.context.tagName,!j.contextGrabbers.hasOwnProperty(p)||!j.contextGrabbers[p].hasOwnProperty(x))return;o(a)}}function l(a,x,p){return a=="openTag"?(p.tagStart=x.column(),E):a=="closeTag"?m:l}function E(a,x,p){return a=="word"?(p.tagName=x.current(),v="tag",g):j.allowMissingTagName&&a=="endTag"?(v="tag bracket",g(a,x,p)):(v="error",E)}function m(a,x,p){if(a=="word"){var b=x.current();return p.context&&p.context.tagName!=b&&j.implicitlyClosed.hasOwnProperty(p.context.tagName)&&o(p),p.context&&p.context.tagName==b||j.matchClosing===!1?(v="tag",f):(v="tag error",L)}else return j.allowMissingTagName&&a=="endTag"?(v="tag bracket",f(a,x,p)):(v="error",L)}function f(a,x,p){return a!="endTag"?(v="error",f):(o(p),l)}function L(a,x,p){return v="error",f(a,x,p)}function g(a,x,p){if(a=="word")return v="attribute",d;if(a=="endTag"||a=="selfcloseTag"){var b=p.tagName,M=p.tagStart;return p.tagName=p.tagStart=null,a=="selfcloseTag"||j.autoSelfClosers.hasOwnProperty(b)?s(p,b):(s(p,b),p.context=new u(p,b,M==p.indented)),l}return v="error",g}function d(a,x,p){return a=="equals"?c:(j.allowMissing||(v="error"),g(a,x,p))}function c(a,x,p){return a=="string"?h:a=="word"&&j.allowUnquoted?(v="string",g):(v="error",g(a,x,p))}function h(a,x,p){return a=="string"?h:g(a,x,p)}return{startState:function(a){var x={tokenize:T,state:l,indented:a||0,tagName:null,tagStart:null,context:null};return a!=null&&(x.baseIndent=a),x},token:function(a,x){if(!x.tagName&&a.sol()&&(x.indented=a.indentation()),a.eatSpace())return null;O=null;var p=x.tokenize(a,x);return(p||O)&&p!="comment"&&(v=null,x.state=x.state(O||p,a,x),v&&(p=v=="error"?p+" error":v)),p},indent:function(a,x,p){var b=a.context;if(a.tokenize.isInAttribute)return a.tagStart==a.indented?a.stringStartCol+1:a.indented+D;if(b&&b.noIndent)return fe.Pass;if(a.tokenize!=R&&a.tokenize!=T)return p?p.match(/^(\s*)/)[0].length:0;if(a.tagName)return j.multilineTagIndentPastTag!==!1?a.tagStart+a.tagName.length+2:a.tagStart+D*(j.multilineTagIndentFactor||1);if(j.alignCDATA&&/<!\[CDATA\[/.test(x))return 0;var M=x&&/^<(\/)?([\w_:\.-]*)/.exec(x);if(M&&M[1])for(;b;)if(b.tagName==M[2]){b=b.prev;break}else if(j.implicitlyClosed.hasOwnProperty(b.tagName))b=b.prev;else break;else if(M)for(;b;){var G=j.contextGrabbers[b.tagName];if(G&&G.hasOwnProperty(M[2]))b=b.prev;else break}for(;b&&b.prev&&!b.startOfLine;)b=b.prev;return b?b.indent+D:a.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:j.htmlMode?"html":"xml",helperType:j.htmlMode?"html":"xml",skipAttribute:function(a){a.state==c&&(a.state=g)},xmlCurrentTag:function(a){return a.tagName?{name:a.tagName,close:a.type=="closeTag"}:null},xmlCurrentContext:function(a){for(var x=[],p=a.context;p;p=p.prev)p.tagName&&x.push(p.tagName);return x.reverse()}}}),fe.defineMIME("text/xml","xml"),fe.defineMIME("application/xml","xml"),fe.mimeModes.hasOwnProperty("text/html")||fe.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"389U":function(dt,et,le){"use strict";le.r(et);var fe=le("+L6B"),J=le("2/Rp"),_=le("oBTY"),$=le("giR+"),I=le("fyUT"),D=le("5Dmo"),j=le("3S7+"),U=le("sRBo"),P=le("kaz8"),O=le("2qtc"),v=le("kLXV"),T=le("miYZ"),R=le("tsqr"),A=le("k1fw"),C=le("9og8"),S=le("tJVT"),u=le("PpiC"),o=le("5NDa"),s=le("5rEg"),l=le("OaEy"),E=le("2fM7"),m=le("WmNS"),f=le.n(m),L=le("q1tI"),g=le.n(L),d=le("9kvl"),c=le("Ot1p"),h=le("HBuW"),a=le("LvDl"),x=le.n(a),p=le("bNIU"),b=le.n(p),M=le("9ZNV"),G=le("fnXi"),Z=le("nuEh"),ie=le("UqFu"),z=E.a.Option,F=s.a.TextArea,ne=function(ge){var xe=ge.shixunsDetail,Me=ge.dispatch,Te=ge.match,Oe=ge.practiceSetting,Ce=Object(u.a)(ge,["shixunsDetail","dispatch","match","practiceSetting"]),we=Object(L.useState)({}),ve=Object(S.a)(we,2),W=ve[0],w=ve[1],k=Object(L.useState)([]),H=Object(S.a)(k,2),q=H[0],B=H[1],he=Object(L.useState)(!1),Ee=Object(S.a)(he,2),Le=Ee[0],Ie=Ee[1],_e=Object(L.useRef)(null),De=Object(L.useRef)({editData:null,answerList:null}),Pe=Object(L.useState)(!0),je=Object(S.a)(Pe,2),ze=je[0],Ke=je[1];Object(L.useEffect)(function(){Ve()},[]),Object(L.useEffect)(function(){Ae()},[W,q]);var Ve=function(){var ae=Object(C.a)(f.a.mark(function V(){return f.a.wrap(function(te){for(;;)switch(te.prev=te.next){case 0:return Ke(!0),te.next=3,at();case 3:return te.next=5,Xe();case 5:Ke(!1);case 6:case"end":return te.stop()}},V)}));return function(){return ae.apply(this,arguments)}}(),at=function(){var ae=Object(C.a)(f.a.mark(function V(){var Y;return f.a.wrap(function(oe){for(;;)switch(oe.prev=oe.next){case 0:return oe.next=2,Object(h.J)({id:Te.params.id,challengeId:Te.params.challengesId,tab:2});case 2:Y=oe.sent,De.current.editData=Y,Y&&w(Y);case 5:case"end":return oe.stop()}},V)}));return function(){return ae.apply(this,arguments)}}(),Xe=function(){var ae=Object(C.a)(f.a.mark(function V(){var Y,te;return f.a.wrap(function(Q){for(;;)switch(Q.prev=Q.next){case 0:return Q.next=2,Object(h.K)({id:Te.params.id,challengeId:Te.params.challengesId});case 2:Y=Q.sent,te=Y.map(function(ee){return Object(A.a)(Object(A.a)({},ee),{},{contents:Object(ie.a)(ee.contents)})}),De.current.answerList=te,Y&&B(te);case 6:case"end":return Q.stop()}},V)}));return function(){return ae.apply(this,arguments)}}(),$e=function(){var ae=Object(C.a)(f.a.mark(function V(){var Y,te,oe;return f.a.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(Ie(!0),Y=q.map(function(se){return se.score}),te=Y.reduce(function(se,ue){return se+ue},0),!(te!==100&&q!==null&&q!==void 0&&q.length)){ee.next=7;break}return Ie(!1),R.b.info("\u6D4B\u8BD5\u96C6\u7684\u8BC4\u5206\u5360\u6BD4\u4E4B\u548C\u5FC5\u987B\u7B49\u4E8E100"),ee.abrupt("return");case 7:if(q.every(function(se){return se.name})){ee.next=11;break}return Ie(!1),R.b.info("\u8BF7\u5148\u586B\u5199\u53C2\u8003\u7B54\u6848\u540D\u79F0"),ee.abrupt("return");case 11:if(q.every(function(se){return se.contents})){ee.next=15;break}return Ie(!1),R.b.info("\u8BF7\u5148\u586B\u5199\u53C2\u8003\u7B54\u6848\u5185\u5BB9"),ee.abrupt("return");case 15:return ee.next=17,Object(h.Nb)({id:Te.params.id,challengeId:Te.params.challengesId,challenge_answer:q,hide_answer:W==null?void 0:W.hide_answer,disable_copy:W==null?void 0:W.disable_copy});case 17:oe=ee.sent,Ie(!1),Me({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}}),oe!=null&&oe.message&&R.b.info(oe.message),oe.status===1&&d.d.push("/shixuns/".concat(Te.params.id,"/edit/").concat(Te.params.challengesId,"/tab=4"));case 22:case"end":return ee.stop()}},V)}));return function(){return ae.apply(this,arguments)}}(),Ae=function(){clearTimeout(_e.current),_e.current=setTimeout(rt,500)},rt=function(){!Object(a.isEqual)(De.current.editData,W)||!Object(a.isEqual)(De.current.answerList,q)?Me({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!0}}):Me({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})},Je=function(){var V,Y=function(){d.d.push("/shixuns/".concat(Te.params.id,"/challenges")),Me({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};Oe!=null&&(V=Oe.sideBar)!==null&&V!==void 0&&V.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(){Y()}}):Y()};return g.a.createElement("section",{className:b.a.bg},g.a.createElement("div",{className:b.a.formWrap},g.a.createElement(G.a,{activeIndex:2}),g.a.createElement("div",{className:b.a.check},g.a.createElement("div",null,g.a.createElement(P.a,{checked:W==null?void 0:W.hide_answer,onChange:function(V){return w(Object(A.a)(Object(A.a)({},W),{},{hide_answer:V.target.checked}))}},"\u9690\u85CF\u53C2\u8003\u7B54\u6848\u6A21\u5757")),g.a.createElement("div",null,g.a.createElement(P.a,{checked:W==null?void 0:W.disable_copy,onChange:function(V){return w(Object(A.a)(Object(A.a)({},W),{},{disable_copy:V.target.checked}))}},"\u7981\u6B62\u590D\u5236\u53C2\u8003\u7B54\u6848"))),g.a.createElement("div",{className:b.a.fieldWrap},g.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"),g.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"),g.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"),q==null?void 0:q.map(function(ae,V){return g.a.createElement("div",{key:V,className:"mt30 pb5"},g.a.createElement("div",{className:b.a.flexRow},g.a.createElement("b",{className:"font16"},"\u7EA7\u522B\uFF1A",V+1),g.a.createElement("div",{className:"tr flex1"},g.a.createElement(j.a,{placement:"bottom",title:"\u5220\u9664"},g.a.createElement("span",{className:"font14 c-red current",onClick:function(){var te=q.filter(function(ee,se){return se!==V}),oe=Math.floor(100/te.length),Q=oe+100%te.length;te=te.map(function(ee,se){return se===te.length-1?Object(A.a)(Object(A.a)({},ee),{},{score:Q}):Object(A.a)(Object(A.a)({},ee),{},{score:oe})}),B(te)}},"\u5220\xA0\u9664")))),g.a.createElement("div",{className:b.a.contentWrap},g.a.createElement("div",{className:b.a.flexRow},g.a.createElement("div",null,g.a.createElement("p",{className:"font16"},"\u540D\u79F0\uFF1A"),g.a.createElement(s.a,{bordered:!1,value:ae.name,onChange:function(te){var oe=q.map(function(Q,ee){return ee===V?Object(A.a)(Object(A.a)({},Q),{},{name:te.target.value}):Q});B(oe)}})),g.a.createElement("div",{className:"ml10"},g.a.createElement("p",{className:"font16"},"\u6263\u51CF\u5206\u503C\u5360\u6BD4\uFF1A"),g.a.createElement(I.a,{min:0,max:100,value:ae.score,onChange:function(te){var oe=q.map(function(Q,ee){return ee===V?Object(A.a)(Object(A.a)({},Q),{},{score:te}):Q});B(oe)}})))),g.a.createElement("div",{className:"mt10 mb10"},g.a.createElement("div",{className:"font16 mb20"},"\u5185\u5BB9\uFF1A"),g.a.createElement(c.a,{placeholder:"\u5EFA\u8BAE\u63D0\u4F9B\u5305\u62EC\u6587\u4EF6\u6240\u6709\u4EE3\u7801\u7684\u5B8C\u6574\u7B54\u6848",defaultValue:ae.contents,onChange:function(te){var oe=q.map(function(Q,ee){return ee===V?Object(A.a)(Object(A.a)({},Q),{},{contents:te}):Q});B(oe)}})))}),g.a.createElement("div",null,g.a.createElement(J.a,{type:"primary",size:"large",ghost:!0,style:{width:200},className:"mt10",onClick:function(){var V=[].concat(Object(_.a)(q),[{name:"\u89E3\u9898\u601D\u8DEF".concat(q.length+1),contents:"",score:0,id:null,level:null}]),Y=Math.floor(100/V.length),te=Y+100%V.length;V=V.map(function(oe,Q){return Q===V.length-1?Object(A.a)(Object(A.a)({},oe),{},{score:te}):Object(A.a)(Object(A.a)({},oe),{},{score:Y})}),B(V)}},"\u65B0\u589E\u53C2\u8003\u7B54\u6848")))),g.a.createElement(M.a,{onOk:$e,className:"customFixedButton",onCancel:Je,loading:Le}),g.a.createElement(Z.a,{loading:ze}))};et.default=Object(d.a)(function(ce){var ge=ce.shixunsDetail,xe=ce.newCourse,Me=ce.globalSetting,Te=ce.practiceSetting;return{shixunsDetail:ge,newCourse:xe,globalSetting:Me,practiceSetting:Te}})(ne)},"7Cbv":function(dt,et,le){"use strict";var fe=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),J=new Uint8Array(16);function _(){if(!fe)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return fe(J)}var $=/^(?:[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 I(R){return typeof R=="string"&&$.test(R)}for(var D=I,j=[],U=0;U<256;++U)j.push((U+256).toString(16).substr(1));function P(R){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,C=(j[R[A+0]]+j[R[A+1]]+j[R[A+2]]+j[R[A+3]]+"-"+j[R[A+4]]+j[R[A+5]]+"-"+j[R[A+6]]+j[R[A+7]]+"-"+j[R[A+8]]+j[R[A+9]]+"-"+j[R[A+10]]+j[R[A+11]]+j[R[A+12]]+j[R[A+13]]+j[R[A+14]]+j[R[A+15]]).toLowerCase();if(!D(C))throw TypeError("Stringified UUID is invalid");return C}var O=P;function v(R,A,C){R=R||{};var S=R.random||(R.rng||_)();if(S[6]=S[6]&15|64,S[8]=S[8]&63|128,A){C=C||0;for(var u=0;u<16;++u)A[C+u]=S[u];return A}return O(S)}var T=et.a=v},"7ahc":function(dt,et,le){"use strict";le.d(et,"a",function(){return E});var fe=le("k1fw"),J=le("0Owb"),_=le("+L6B"),$=le("2/Rp"),I=le("y8nQ"),D=le("Vl3Y"),j=le("tJVT"),U=le("OaEy"),P=le("2fM7"),O=le("q1tI"),v=le.n(O),T=le("VrN/"),R=le.n(T),A=le("p77/"),C=le.n(A),S=le("c5Ni"),u=le.n(S),o=P.a.Option,s={labelCol:{span:4},wrapperCol:{span:20}},l={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"]};et.b=function(m){var f=m.callback,L=m.onCancel,g=Object(O.useState)("python"),d=Object(j.a)(g,2),c=d[0],h=d[1];function a(p){h(l[p][1])}function x(p){f(p)}return v.a.createElement(D.a,Object(J.a)({},s,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:x}),v.a.createElement(D.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},v.a.createElement(P.a,{onChange:a},Object.keys(l).map(function(p){return v.a.createElement(o,{key:p,value:p},l[p][0])}))),v.a.createElement(D.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},v.a.createElement(E,{mode:c})),v.a.createElement("div",{className:"flex-container flex-end"},v.a.createElement($.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),v.a.createElement($.a,{type:"ghost",onClick:L},"\u53D6\u6D88")))};function E(m){var f=m.value,L=m.onChange,g=m.mode,d=m.options,c=d===void 0?{}:d,h=Object(O.useRef)(),a=Object(O.useState)(),x=Object(j.a)(a,2),p=x[0],b=x[1];return Object(O.useEffect)(function(){if(p){function M(G){var Z=G.getValue();L&&L(Z)}return p.on("change",M),function(){p.off("change",M)}}},[p,L]),Object(O.useEffect)(function(){p&&p.setOption("mode",g)},[p,g]),Object(O.useEffect)(function(){p&&((f!==p.getValue()||f==="")&&setTimeout(function(){p.setValue(f||" ")},300))},[p,f]),Object(O.useEffect)(function(){if(h.current&&!p){var M=R.a.fromTextArea(h.current,Object(fe.a)({mode:g,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));b(M)}},[h.current,p]),v.a.createElement("div",{className:"my-codemirror-container"},v.a.createElement("textarea",{ref:h}))}},"8EBN":function(dt,et,le){(function(fe){fe(le("VrN/"))})(function(fe){"use strict";fe.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 J=0;J<fe.modeInfo.length;J++){var _=fe.modeInfo[J];_.mimes&&(_.mime=_.mimes[0])}fe.findModeByMIME=function($){$=$.toLowerCase();for(var I=0;I<fe.modeInfo.length;I++){var D=fe.modeInfo[I];if(D.mime==$)return D;if(D.mimes){for(var j=0;j<D.mimes.length;j++)if(D.mimes[j]==$)return D}}if(/\+xml$/.test($))return fe.findModeByMIME("application/xml");if(/\+json$/.test($))return fe.findModeByMIME("application/json")},fe.findModeByExtension=function($){$=$.toLowerCase();for(var I=0;I<fe.modeInfo.length;I++){var D=fe.modeInfo[I];if(D.ext){for(var j=0;j<D.ext.length;j++)if(D.ext[j]==$)return D}}},fe.findModeByFileName=function($){for(var I=0;I<fe.modeInfo.length;I++){var D=fe.modeInfo[I];if(D.file&&D.file.test($))return D}var j=$.lastIndexOf("."),U=j>-1&&$.substring(j+1,$.length);if(U)return fe.findModeByExtension(U)},fe.findModeByName=function($){$=$.toLowerCase();for(var I=0;I<fe.modeInfo.length;I++){var D=fe.modeInfo[I];if(D.name.toLowerCase()==$)return D;if(D.alias){for(var j=0;j<D.alias.length;j++)if(D.alias[j].toLowerCase()==$)return D}}}})},"8hTe":function(dt,et,le){dt.exports={button:"button___1wy9m"}},"93VE":function(dt,et,le){},"9Bee":function(dt,et,le){"use strict";var fe=le("DYRE"),J=le("zeV3"),_=le("+L6B"),$=le("2/Rp"),I=le("k1fw"),D=le("9og8"),j=le("tJVT"),U=le("WmNS"),P=le.n(U),O=le("q1tI"),v=le.n(O),T=le("vg9a"),R=le("DlQD"),A=le.n(R),C=le("rUJ1");function S(ae,V){var Y=ae.match(/^(\s+)(?:```)/);if(Y===null)return V;var te=Y[1];return V.split(`
`).map(function(oe){var Q=oe.match(/^\s+/);if(Q===null)return oe;var ee=Object(j.a)(Q,1),se=ee[0];return se.length>=te.length?oe.slice(te.length):oe}).join(`
`)}var u=[],o=["<ul>"],s=new A.a.Renderer,l=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function E(){u.length=0,o=["<ul>"]}var m={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function f(ae,V,Y,te){if(V>=ae.length||ae[V].level<=Y)return V;var oe=ae[V];te.push("<li><a href='#"+oe.anchor+"'>"+oe.text+"</a>"),V++;var Q=[];return V=f(ae,V,oe.level,Q),Q.length>0&&(te.push("<ul>"),Q.forEach(function(ee){te.push(ee)}),te.push("</ul>")),te.push("</li>"),V=f(ae,V,Y,te),V}function L(){return f(u,0,0,o),o.push("</ul>"),o.join("")}var g={heading:function(V){var Y=l.exec(V);if(Y)return{type:"heading",raw:Y[0],depth:Y[1].length,text:Y[2]}},fences:function(V){var Y=this.rules.block.fences.exec(V);if(Y){var te=Y[0],oe=S(te,Y[3]||""),Q=Y[2]?Y[2].trim():Y[2];if(["latex","katex","math"].indexOf(Q)>=0){var ee=h(),se=oe;oe=ee,a[ee]={type:"block",expression:se}}return{type:"code",raw:te,lang:Q,text:oe}}}},d=/(?:\${2})([^\n`]+?)(?:\${2})/gi,c=0,h=function(){return"__special_katext_id_".concat(c++,"__")},a={};function x(){return a}function p(){c=0,a={}}function b(ae){return ae=ae.replace(d,function(V,Y){var te=h();return a[te]={type:"inline",expression:Y},te}),ae}var M=s.listitem;s.listitem=function(ae){return M(b(ae))};var G=s.paragraph;s.paragraph=function(ae){return G(b(ae))};var Z=s.tablecell;s.tablecell=function(ae,V){return Z(b(ae),V)},s.code=function(ae,V,Y){var te=(V||"").match(/\S*/)[0];return te?["latex","katex","math"].indexOf(te)>=0?"<p class='editormd-tex'>".concat(ae,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(V,'">').concat(Y?ae:Object(C.escape)(ae,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(Y?ae:Object(C.escape)(ae,!0))+"</code></pre>"},s.heading=function(ae,V,Y){var te=this.options.headerPrefix+Y.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return u.push({anchor:te,level:V,text:ae}),"<h"+V+' id="'+te+'">'+ae+"</h"+V+">"},A.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),A.a.use({tokenizer:g,renderer:s});var ie=A.a,z=le("SJMd"),F=le("ulZh"),ne=le.n(F),ce=le("m3rI"),ge=le("Oy/b"),xe=le("p5ED"),Me=le("ErOA"),Te=le("STEk");/* **********************************
cropro version 1.2.0
@license SEE LICENSE IN LICENSE
copyright Alan Mendelevich
see README and LICENSE for details
********************************** *//*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var Oe=function(ae,V){return(Oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Y,te){Y.__proto__=te}||function(Y,te){for(var oe in te)Object.prototype.hasOwnProperty.call(te,oe)&&(Y[oe]=te[oe])})(ae,V)};function Ce(ae,V){if(typeof V!="function"&&V!==null)throw new TypeError("Class extends value "+String(V)+" is not a constructor or null");function Y(){this.constructor=ae}Oe(ae,V),ae.prototype=V===null?Object.create(V):(Y.prototype=V.prototype,new Y)}function we(ae,V,Y,te){return new(Y||(Y=Promise))(function(oe,Q){function ee(me){try{ue(te.next(me))}catch(ye){Q(ye)}}function se(me){try{ue(te.throw(me))}catch(ye){Q(ye)}}function ue(me){var ye;me.done?oe(me.value):(ye=me.value,ye instanceof Y?ye:new Y(function(ke){ke(ye)})).then(ee,se)}ue((te=te.apply(ae,V||[])).next())})}function ve(ae,V){var Y,te,oe,Q,ee={label:0,sent:function(){if(1&oe[0])throw oe[1];return oe[1]},trys:[],ops:[]};return Q={next:se(0),throw:se(1),return:se(2)},typeof Symbol=="function"&&(Q[Symbol.iterator]=function(){return this}),Q;function se(ue){return function(me){return function(ye){if(Y)throw new TypeError("Generator is already executing.");for(;ee;)try{if(Y=1,te&&(oe=2&ye[0]?te.return:ye[0]?te.throw||((oe=te.return)&&oe.call(te),0):te.next)&&!(oe=oe.call(te,ye[1])).done)return oe;switch(te=0,oe&&(ye=[2&ye[0],oe.value]),ye[0]){case 0:case 1:oe=ye;break;case 4:return ee.label++,{value:ye[1],done:!1};case 5:ee.label++,te=ye[1],ye=[0];continue;case 7:ye=ee.ops.pop(),ee.trys.pop();continue;default:if(!(oe=ee.trys,(oe=oe.length>0&&oe[oe.length-1])||ye[0]!==6&&ye[0]!==2)){ee=0;continue}if(ye[0]===3&&(!oe||ye[1]>oe[0]&&ye[1]<oe[3])){ee.label=ye[1];break}if(ye[0]===6&&ee.label<oe[1]){ee.label=oe[1],oe=ye;break}if(oe&&ee.label<oe[2]){ee.label=oe[2],ee.ops.push(ye);break}oe[2]&&ee.ops.pop(),ee.trys.pop();continue}ye=V.call(ae,ee)}catch(ke){ye=[6,ke],te=0}finally{Y=oe=0}if(5&ye[0])throw ye[1];return{value:ye[0]?ye[1]:void 0,done:!0}}([ue,me])}}}var W=function(){function ae(){}return ae.addKey=function(V){ae.key=V},Object.defineProperty(ae,"isLicensed",{get:function(){return!!ae.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(ae.key)},enumerable:!1,configurable:!0}),ae}(),w=function(){function ae(){}return ae.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},ae.setAttributes=function(V,Y){for(var te=0,oe=Y;te<oe.length;te++){var Q=oe[te],ee=Q[0],se=Q[1];V.setAttribute(ee,se)}},ae.createRect=function(V,Y,te){var oe=document.createElementNS("http://www.w3.org/2000/svg","rect");return oe.setAttribute("width",V.toString()),oe.setAttribute("height",Y.toString()),te&&ae.setAttributes(oe,te),oe},ae.createLine=function(V,Y,te,oe,Q){var ee=document.createElementNS("http://www.w3.org/2000/svg","line");return ee.setAttribute("x1",V.toString()),ee.setAttribute("y1",Y.toString()),ee.setAttribute("x2",te.toString()),ee.setAttribute("y2",oe.toString()),Q&&ae.setAttributes(ee,Q),ee},ae.createPolygon=function(V,Y){var te=document.createElementNS("http://www.w3.org/2000/svg","polygon");return te.setAttribute("points",V),Y&&ae.setAttributes(te,Y),te},ae.createCircle=function(V,Y){var te=document.createElementNS("http://www.w3.org/2000/svg","circle");return te.setAttribute("cx",(V/2).toString()),te.setAttribute("cy",(V/2).toString()),te.setAttribute("r",V.toString()),Y&&ae.setAttributes(te,Y),te},ae.createEllipse=function(V,Y,te){var oe=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return oe.setAttribute("cx",(V/2).toString()),oe.setAttribute("cy",(Y/2).toString()),oe.setAttribute("rx",(V/2).toString()),oe.setAttribute("ry",(Y/2).toString()),te&&ae.setAttributes(oe,te),oe},ae.createGroup=function(V){var Y=document.createElementNS("http://www.w3.org/2000/svg","g");return V&&ae.setAttributes(Y,V),Y},ae.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},ae.createMarker=function(V,Y,te,oe,Q,ee,se){var ue=document.createElementNS("http://www.w3.org/2000/svg","marker");return ae.setAttributes(ue,[["id",V],["orient",Y],["markerWidth",te.toString()],["markerHeight",oe.toString()],["refX",Q.toString()],["refY",ee.toString()]]),ue.appendChild(se),ue},ae.createText=function(V){var Y=document.createElementNS("http://www.w3.org/2000/svg","text");return Y.setAttribute("x","0"),Y.setAttribute("y","0"),V&&ae.setAttributes(Y,V),Y},ae.createTSpan=function(V,Y){var te=document.createElementNS("http://www.w3.org/2000/svg","tspan");return te.textContent=V,Y&&ae.setAttributes(te,Y),te},ae.createImage=function(V){var Y=document.createElementNS("http://www.w3.org/2000/svg","image");return V&&ae.setAttributes(Y,V),Y},ae.createPoint=function(V,Y){var te=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return te.x=V,te.y=Y,te},ae.createPath=function(V,Y){var te=document.createElementNS("http://www.w3.org/2000/svg","path");return te.setAttribute("d",V),Y&&ae.setAttributes(te,Y),te},ae.createElement=function(V,Y){var te=document.createElementNS("http://www.w3.org/2000/svg",V);return Y&&ae.setAttributes(te,Y),te},ae.getHollowRectanglePath=function(V,Y,te,oe,Q,ee,se,ue){return"M"+V+","+Y+"V"+(Y+oe)+"H"+(V+te)+"V"+Y+"H"+Q+"V"+ee+"H"+(Q+se)+"V"+(ee+ue)+"H"+Q+"V"+Y+"Z"},ae}(),k=function(){function ae(V){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+V+"_"}return Object.defineProperty(ae.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#333333",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarBackgroundActiveColor:"#282828",toolbarColor:"#eeeeee",cropShadeColor:"#ffffff",cropFrameColor:"#ffffff",gripColor:"#333333",gripFillColor:"#cccccc",toolbarHeight:40}},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),ae.prototype.addClass=function(V){return this.styleSheet===void 0&&this.addStyleSheet(),V.name=""+this.classNamePrefix+V.localName,this.classes.push(V),this.styleSheet.sheet.insertRule("."+V.name+" {"+V.style+"}",this.styleSheet.sheet.cssRules.length),V},ae.prototype.addRule=function(V){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(V),this.styleSheet.sheet.insertRule(V.selector+" {"+V.style+"}",this.styleSheet.sheet.cssRules.length)},ae.prototype.addStyleSheet=function(){var V;this.styleSheet=document.createElement("style"),((V=this.styleSheetRoot)!==null&&V!==void 0?V:document.head).appendChild(this.styleSheet),this.addRule(new H("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new H("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new H("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new q("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new q("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},ae.prototype.removeStyleSheet=function(){var V;this.styleSheet&&(((V=this.styleSheetRoot)!==null&&V!==void 0?V:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},ae}(),H=function(ae,V){this.selector=ae,this.style=V},q=function(ae,V){this.localName=ae,this.style=V},B=function(){function ae(){this.blocks=[],this.display=""}return ae.prototype.addButtonBlock=function(V){V.className=this.blockClassName,V.buttonClassName=this.buttonClassName,V.buttonColorsClassName=this.buttonColorsClassName,V.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(V)},ae.prototype.addElementBlock=function(V){V.className===void 0&&(V.className=this.blockClassName),this.blocks.push(V)},ae.prototype.getUI=function(){var V=document.createElement("div");return V.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,V.style.display=this.display,this.blocks.forEach(function(Y){return V.appendChild(Y.getUI())}),V},ae}(),he=function(){function ae(){}return ae.prototype.getUI=function(){var V=document.createElement("div");if(V.className=this.className,this.minWidth!==void 0&&(V.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":V.style.justifyContent="flex-start";break;case"center":V.style.justifyContent="center";break;case"end":V.style.justifyContent="flex-end"}return V.style.whiteSpace="nowrap",V},ae}(),Ee=function(ae){function V(){var Y=ae!==null&&ae.apply(this,arguments)||this;return Y.buttons=[],Y}return Ce(V,ae),V.prototype.addButton=function(Y){Y.className=this.buttonClassName,Y.colorsClassName=this.buttonColorsClassName,Y.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(Y)},V.prototype.getUI=function(){var Y=ae.prototype.getUI.call(this);return this.buttons.forEach(function(te){return Y.appendChild(te.getUI())}),Y},V}(he),Le=function(){function ae(V,Y){this._isActive=!1,this._isHidden=!1,this._icon=V,this.title=Y,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(ae.prototype,"icon",{get:function(){return this._icon},set:function(V){this._icon=V,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isActive",{get:function(){return this._isActive},set:function(V){this._isActive=V,this.adjustClassName()},enumerable:!1,configurable:!0}),ae.prototype.getUI=function(){var V=this;return this.buttonContainer=document.createElement("div"),this.buttonContainer.title=this.title,this.buttonContainer.className=this.className+" "+this.colorsClassName,this.adjustClassName(),this.buttonContainer.innerHTML=this._icon,this.onClick&&this.buttonContainer.addEventListener("click",function(){return V.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},ae.prototype.adjustClassName=function(){this.activeColorsClassName&&(this._isActive&&this.buttonContainer.className.indexOf(this.activeColorsClassName)<0?this.buttonContainer.className+=" "+this.activeColorsClassName:this._isActive||(this.buttonContainer.className=this.buttonContainer.className.replace(this.activeColorsClassName,"")))},ae.prototype.hide=function(){this._isHidden=!0},ae}(),Ie=function(ae){function V(){var Y=ae!==null&&ae.apply(this,arguments)||this;return Y.elements=[],Y}return Ce(V,ae),V.prototype.addElement=function(Y){this.elements.push(Y)},V.prototype.getUI=function(){var Y=ae.prototype.getUI.call(this);return this.elements.forEach(function(te){return Y.appendChild(te)}),Y},V}(he),_e=function(){function ae(V,Y){this.horizontal=V,this.vertical=Y}return Object.defineProperty(ae.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),ae.prototype.getVerticalLength=function(V){return V/this.ratio},ae.prototype.getHorizontalLength=function(V){return V*this.ratio},ae}(),De=function(){function ae(){}return ae.getIcon=function(V,Y){if(V>0&&Y>0){var te=new _e(V,Y),oe=te.ratio>=1?20:te.getHorizontalLength(20),Q=te.ratio<1?20:te.getVerticalLength(20),ee=document.createElementNS("http://www.w3.org/2000/svg","svg");ee.setAttribute("xmlns","http://www.w3.org/2000/svg"),ee.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(ee);var se=w.createDefs();ee.appendChild(se);var ue=w.createElement("clipPath",[["id","text-bg-clip"]]);se.appendChild(ue);var me=w.createPath(w.getHollowRectanglePath((24-oe)/2,(24-Q)/2,oe,Q,(24-oe)/2+2,(24-Q)/2+2,oe-4,Q-4));ee.appendChild(me);var ye=w.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);ye.appendChild(w.createTSpan(V+":"+Y)),ee.appendChild(ye);var ke=ye.getBBox();w.setAttributes(ye,[["x",((24-ke.width)/2).toString()],["y",((24-ke.height)/2-ke.y).toString()]]);var We=w.createPath(w.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(ke.width))/2,(24-Math.ceil(ke.height))/2,Math.ceil(ke.width),Math.ceil(ke.height)));return ue.appendChild(We),w.setAttributes(me,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(ee),ee.outerHTML}return'<svg viewBox="0 0 24 24"><path d="M19 12h-2v3h-3v2h5v-5M7 9h3V7H5v5h2V9m14-6H3a2 2 0 00-2 2v14a2 2 0 002 2h18a2 2 0 002-2V5a2 2 0 00-2-2m0 16H3V5h18v14z"/></svg>'},ae}(),Pe=function(ae){function V(Y,te,oe){var Q=ae.call(this,Y,te)||this;return Q.isDropdownOpen=!1,Q.onClick=Q.dropdownButtonClicked,Q.dropdownButtons=oe,Q}return Ce(V,ae),V.prototype.setupDropdown=function(){var Y=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(te){te.className=Y.className,te.colorsClassName=Y.colorsClassName,Y.dropdownBlock.appendChild(te.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},V.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},V.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},V.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},V.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},V.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},V}(Le),je=function(){function ae(V,Y){this.GRIP_SIZE=10,this.color=V,this.fillColor=Y,this.visual=w.createGroup(),this.visual.appendChild(w.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(w.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return ae.prototype.ownsTarget=function(V){return V===this.visual||V===this.visual.childNodes[0]||V===this.visual.childNodes[1]},ae.prototype.setCenter=function(V,Y){this.visual.childNodes.forEach(function(te){return w.setAttributes(te,[["cx",V.toString()],["cy",Y.toString()]])})},ae}(),ze=function(){function ae(V,Y,te,oe){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=V,this.canvasHeight=Y,this.margin=te,this.container=oe,this.attachEvents=this.attachEvents.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.resize=this.resize.bind(this),this.adjustCropRect=this.adjustCropRect.bind(this),this.scaleCanvas=this.scaleCanvas.bind(this),this.getRescaledRect=this.getRescaledRect.bind(this)}return Object.defineProperty(ae.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(V){this._aspectRatio=V,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(V){this._isGridVisible=V,this.gridContainer&&w.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(V){this._zoomFactor=V,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),ae.prototype.open=function(){var V=this;this.cropShadeElement=w.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=w.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var Y=0;Y<this.numberOfGridLines;Y++)this.horizontalGridLines.push(w.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(w.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(te){return V.gridContainer.appendChild(te)}),this.verticalGridLines.forEach(function(te){return V.gridContainer.appendChild(te)}),this.cropRectElement=w.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new je(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new je(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new je(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new je(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},ae.prototype.setCropRectangle=function(V){this.cropRect=V;var Y=Object.assign({},this.cropRect);this.zoomFactor!==1&&(Y.width=this.cropRect.width*this.zoomFactor,Y.height=this.cropRect.height*this.zoomFactor,Y.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-Y.width/2,Y.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-Y.height/2),w.setAttributes(this.cropRectElement,[["x",Y.x.toString()],["y",Y.y.toString()],["width",Y.width.toString()],["height",Y.height.toString()]]);var te=Y.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(Q,ee){var se=Y.y+te*(ee+1);w.setAttributes(Q,[["x1",""+Y.x],["y1",""+se],["x2",""+(Y.x+Y.width)],["y2",""+se]])});var oe=Y.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(Q,ee){var se=Y.x+oe*(ee+1);w.setAttributes(Q,[["x1",""+se],["y1",""+Y.y],["x2",""+se],["y2",""+(Y.y+Y.height)]])}),w.setAttributes(this.cropShadeElement,[["d",w.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,Y.x,Y.y,Y.width,Y.height)]]),this.topLeftGrip.setCenter(Y.x,Y.y),this.topRightGrip.setCenter(Y.x+Y.width,Y.y),this.bottomLeftGrip.setCenter(Y.x,Y.y+Y.height),this.bottomRightGrip.setCenter(Y.x+Y.width,Y.y+Y.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},ae.prototype.attachEvents=function(){this.container.style.touchAction="none",this.container.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp)},ae.prototype.clientToLocalCoordinates=function(V,Y){var te=this.container.getBoundingClientRect();return{x:V-te.left+this.margin,y:Y-te.top+this.margin}},ae.prototype.onPointerDown=function(V){this.container.setPointerCapture(V.pointerId),this.previousPoint=this.clientToLocalCoordinates(V.clientX,V.clientY),this.cropRectElement===V.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(V.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(V.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(V.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(V.target)&&(this.activeGrip=this.bottomRightGrip)},ae.prototype.onPointerMove=function(V){if(this.isMoving)this.move(this.clientToLocalCoordinates(V.clientX,V.clientY));else if(this.activeGrip){var Y=this.clientToLocalCoordinates(V.clientX,V.clientY);this.resize(Y)}V.preventDefault()},ae.prototype.onPointerUp=function(V){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(V.pointerId)},ae.prototype.move=function(V){var Y=V.x-this.previousPoint.x,te=V.y-this.previousPoint.y;this.zoomFactor!==1&&(Y=-Y/this.zoomFactor,te=-te/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+Y),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+te),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=V},ae.prototype.resize=function(V){var Y=Object.assign({},this.cropRect),te=V.x-this.previousPoint.x,oe=V.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:Y.x+te<this.margin&&(te=this.margin-Y.x),Y.x+=te,Y.width=this.cropRect.x+this.cropRect.width-Y.x;break;case this.bottomRightGrip:case this.topRightGrip:Y.width+te>this.canvasWidth*this.zoomFactor&&(te=this.canvasWidth*this.zoomFactor-Y.width),Y.width+=te}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(Y.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(te),Y.height=this.aspectRatio.getVerticalLength(Y.width)):(Y.y+=oe,Y.height=this.cropRect.y+this.cropRect.height-Y.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?Y.height=this.aspectRatio.getVerticalLength(Y.width):Y.height+=oe}Y.width<10&&(Y.x=this.cropRect.x,Y.width=10),Y.height<10&&(Y.y=this.cropRect.y,Y.height=10),this.previousPoint=V,Y.x>=this.margin&&Y.y>=this.margin&&Y.x-this.margin+Y.width<=this.canvasWidth&&Y.y-this.margin+Y.height<=this.canvasHeight&&(this.cropRect=Y,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},ae.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var V=this.cropRect.x+this.cropRect.width/2,Y=this.cropRect.y+this.cropRect.height/2,te=this.aspectRatio.getHorizontalLength(this.cropRect.height),oe=this.aspectRatio.getVerticalLength(this.cropRect.width);te/this.canvasWidth<oe/this.canvasHeight?this.cropRect.width=te:this.cropRect.height=oe,this.cropRect.width>this.canvasWidth&&(this.cropRect.height/=this.cropRect.width/this.canvasWidth,this.cropRect.width=this.canvasWidth),this.cropRect.height>this.canvasHeight&&(this.cropRect.width/=this.cropRect.height/this.canvasHeight,this.cropRect.height=this.canvasHeight),this.cropRect.x=V-this.cropRect.width/2,this.cropRect.y=Y-this.cropRect.height/2,this.cropRect.x+this.cropRect.width>this.margin+this.canvasWidth&&(this.cropRect.x=this.margin+this.canvasWidth-this.cropRect.width),this.cropRect.y+this.cropRect.height>this.margin+this.canvasHeight&&(this.cropRect.y=this.margin+this.canvasHeight-this.cropRect.height),this.cropRect.x=Math.max(this.cropRect.x,this.margin),this.cropRect.y=Math.max(this.cropRect.y,this.margin)}},ae.prototype.getRescaledRect=function(V,Y,te,oe,Q,ee){var se=te/V,ue=oe/Y;return{x:(Q.x-ee)*se+ee,y:(Q.y-ee)*ue+ee,width:Q.width*se,height:Q.height*ue}},ae.prototype.scaleCanvas=function(V,Y){var te=this.getRescaledRect(this.canvasWidth,this.canvasHeight,V,Y,this.cropRect,this.margin);this.canvasWidth=V,this.canvasHeight=Y,this.onCropChange&&this.onCropChange(te),this.setCropRectangle(te)},ae}(),Ke=function(){function ae(V){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=V,this.uiContainer=document.createElement("div"),this.getUI=this.getUI.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.setAngleLabel=this.setAngleLabel.bind(this),this.positionScaleShape=this.positionScaleShape.bind(this)}return Object.defineProperty(ae.prototype,"angle",{get:function(){return this._angle},set:function(V){this._angle=V,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),ae.prototype.getUI=function(){return this.controlContainer=document.createElement("div"),this.controlContainer.title=this.title,this.controlContainer.className=this.className+" "+this.colorsClassName,this.controlContainer.appendChild(this.getVisual()),this.controlContainer.addEventListener("pointerdown",this.onPointerDown),this.controlContainer.addEventListener("pointermove",this.onPointerMove),this.controlContainer.addEventListener("pointerup",this.onPointerUp),this.uiContainer.appendChild(this.controlContainer),this.uiContainer.style.display="inline-block",this.uiContainer.style.touchAction="none",this.setAngleLabel(),this.positionScaleShape(),this.uiContainer},ae.prototype.onPointerDown=function(V){this.controlContainer.setPointerCapture(V.pointerId),this.isDragging=!0,this.previousPoint={x:V.clientX,y:V.clientY}},ae.prototype.onPointerMove=function(V){this.isDragging&&(this.onAngleChange&&this.onAngleChange((V.clientX-this.previousPoint.x)/5),this.previousPoint.x=V.clientX)},ae.prototype.onPointerUp=function(V){this.isDragging&&this.onAngleChange&&this.onAngleChange((V.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(V.pointerId)},ae.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var V=this.angleLabelText.getBBox();w.setAttributes(this.angleLabelElement,[["x",((this.width-V.width)/2).toString()],["y",(this.height/2).toString()]])}},ae.prototype.positionScaleShape=function(){if(this.scaleShape){var V=this.scaleShape.transform.baseVal.getItem(0);V.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(V,0)}},ae.prototype.getVisual=function(){var V=document.createElementNS("http://www.w3.org/2000/svg","svg");V.setAttribute("xmlns","http://www.w3.org/2000/svg"),V.setAttribute("width",this.width+"px"),V.setAttribute("height",this.height+"px"),V.setAttribute("viewBox","0 0 "+this.width+" "+this.height),V.style.flexShrink="0",document.body.appendChild(V);for(var Y="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,te=1;te<=this.width/5+10;te++){var oe=te%5==0?this.height/3:this.height/6;Y+="h4v"+-oe+"h1v"+oe}Y+="v1H0Z",this.scaleShape=w.createPath(Y);var Q=w.createTransform();this.scaleShape.transform.baseVal.appendItem(Q),V.appendChild(this.scaleShape),this.angleLabelElement=w.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=w.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var ee=w.createTSpan("");return ee.innerHTML="&deg;",this.angleLabelElement.appendChild(ee),V.appendChild(this.angleLabelElement),document.body.removeChild(V),V},ae}(),Ve=function(){function ae(){this.naturalSize=!1,this.imageType="image/png"}return ae.prototype.rasterize=function(V,Y,te,oe,Q,ee,se){var ue=this;return new Promise(function(me){var ye=document.createElement("canvas");ye.width=V.width.baseVal.value-2*oe,ye.height=V.height.baseVal.value-2*oe;var ke=1,We=1;ue.naturalSize===!0?(ke=Y.naturalWidth/(V.width.baseVal.value-2*oe)/ee,We=Y.naturalHeight/(V.height.baseVal.value-2*oe)/se,ye.width=Y.naturalWidth/ee,ye.height=Y.naturalHeight/se):ue.width!==void 0&&ue.height!==void 0&&(ke=ue.width/te.width,We=ue.height/te.height,ye.width*=ke,ye.height*=We);var Qe=ye.getContext("2d");Qe.translate(ye.width/2,ye.height/2),Qe.rotate(Q*Math.PI/180),Qe.scale(ee,se),Qe.translate(-ye.width/2,-ye.height/2),Qe.drawImage(Y,0,0,ye.width,ye.height);var tt=document.createElement("canvas");tt.width=te.width*ke,tt.height=te.height*We,tt.getContext("2d").putImageData(Qe.getImageData((te.x-oe)*ke,(te.y-oe)*We,te.width*ke,te.height*We),0,0),me(tt.toDataURL(ue.imageType,ue.imageQuality))})},ae}(),at=function(){function ae(V){this._zoomToCropEnabled=!0,this.zoomFactor=1,this.flippedHorizontally=!1,this.flippedVertically=!1,this._isGridVisible=!0,this._gridLines=2,this._rotationAngle=0,this.scaleFactor=1,this.renderEventListeners=[],this.closeEventListeners=[],this._isOpen=!1,this.CANVAS_MARGIN=20,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.displayMode="inline",this.popupMargin=30,this.toolbarHeight=40,this.aspectRatios=[{horizontal:0,vertical:0},{horizontal:4,vertical:3},{horizontal:3,vertical:2},{horizontal:16,vertical:9},{horizontal:1,vertical:1},{horizontal:3,vertical:4},{horizontal:2,vertical:3},{horizontal:9,vertical:16}],this._instanceNo=ae.instanceCounter++,this.styles=new k(this.instanceNo),this.target=V,this.targetRoot=document.body,this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.rotateBy=this.rotateBy.bind(this),this.applyRotation=this.applyRotation.bind(this),this.cropRectChanged=this.cropRectChanged.bind(this),this.zoomToCrop=this.zoomToCrop.bind(this),this.unzoomFromCrop=this.unzoomFromCrop.bind(this),this.rotateLeftButtonClicked=this.rotateLeftButtonClicked.bind(this),this.rotateRightButtonClicked=this.rotateRightButtonClicked.bind(this),this.flipHorizontallyButtonClicked=this.flipHorizontallyButtonClicked.bind(this),this.flipVerticallyButtonClicked=this.flipVerticallyButtonClicked.bind(this),this.applyFlip=this.applyFlip.bind(this),this.startRenderAndClose=this.startRenderAndClose.bind(this),this.render=this.render.bind(this),this.onPopupResize=this.onPopupResize.bind(this),this.applyAspectRatio=this.applyAspectRatio.bind(this)}return Object.defineProperty(ae.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(V){this._zoomToCropEnabled=V,V?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(V){this._isGridVisible=V,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"gridLines",{get:function(){return this._gridLines},set:function(V){this._gridLines=V,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(V){this._rotationAngle=V,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"aspectRatio",{get:function(){var V;return(V=this._aspectRatio)!==null&&V!==void 0?V:this.aspectRatios[0]},set:function(V){this._aspectRatio=V},enumerable:!1,configurable:!0}),ae.prototype.open=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.setupResizeObserver(),this.initCropCanvas(),this.setEditingTarget(),this.setTopLeft(),this.initCropLayer(),this.attachEvents(),this.applyAspectRatio(),this.displayMode==="popup"&&this.onPopupResize(),this._isOpen=!0},ae.prototype.show=function(){this.showUI(),this.open()},ae.prototype.close=function(V){V===void 0&&(V=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),V||this.closeEventListeners.forEach(function(Y){return Y()}),this._isOpen=!1)},ae.prototype.addRenderEventListener=function(V){this.renderEventListeners.push(V)},ae.prototype.removeRenderEventListener=function(V){this.renderEventListeners.indexOf(V)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(V),1)},ae.prototype.addCloseEventListener=function(V){this.closeEventListeners.push(V)},ae.prototype.removeCloseEventListener=function(V){this.closeEventListeners.indexOf(V)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(V),1)},ae.prototype.setupResizeObserver=function(){var V=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){V.resize(V.target.clientWidth,V.target.clientHeight)}),this.targetObserver.observe(this.target)):this.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(this.onPopupResize),this.targetObserver.observe(this.contentDiv)),window.addEventListener("resize",this.setWindowHeight))},ae.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var V=1*this.target.clientWidth/this.target.clientHeight,Y=this.contentDiv.clientWidth/V>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*V:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,te=Y+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/V;this.resize(Y,te)}},ae.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},ae.prototype.setEditingTargetSize=function(){this.editorCanvas.style.width=this.imageWidth+2*this.CANVAS_MARGIN+"px",this.editorCanvas.style.height=this.imageHeight+2*this.CANVAS_MARGIN+"px",w.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},ae.prototype.resize=function(V,Y){this.imageWidth=Math.round(V),this.imageHeight=Math.round(Y),this.setEditingTargetSize(),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.displayMode!=="popup"?this.coverDiv.style.width=this.paddedImageWidth+"px":(this.setTopLeft(),this.positionCropImage()),this.cropLayer.scaleCanvas(this.imageWidth,this.imageHeight),this.applyRotation()},ae.prototype.setEditingTarget=function(){var V=document.createElement("canvas");V.width=this.target.naturalWidth,V.height=this.target.naturalHeight,V.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var Y=V.toDataURL();w.setAttributes(this.editingTarget,[["href",Y]]),this.setEditingTargetSize()},ae.prototype.setTopLeft=function(){var V=this.target.getBoundingClientRect(),Y=this.editorCanvas.getBoundingClientRect();this.left=V.left-Y.left-this.CANVAS_MARGIN,this.top=V.top-Y.top-this.CANVAS_MARGIN},ae.prototype.initCropCanvas=function(){this.cropImageHolder=document.createElement("div"),this.cropImageHolder.style.setProperty("touch-action","none"),this.cropImageHolder.style.setProperty("-ms-touch-action","none"),this.cropImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.cropImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.cropImage.setAttribute("width",this.paddedImageWidth.toString()),this.cropImage.setAttribute("height",this.paddedImageHeight.toString()),this.cropImage.setAttribute("viewBox","0 0 "+this.paddedImageWidth.toString()+" "+this.paddedImageHeight.toString()),this.cropImage.style.pointerEvents="auto",this.cropImageHolder.style.width=this.paddedImageWidth+"px",this.cropImageHolder.style.height=this.paddedImageHeight+"px",this.cropImageHolder.style.transformOrigin="top left",this.positionCropImage(),this.defs=w.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=w.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=w.createGroup(),this.editingTargetRotationScaleContainer=w.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var V=w.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(V);var Y=w.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(Y),this.editingTargetContainer=w.createGroup(),this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px)",this.editingTargetContainer.appendChild(this.editingTargetRotationContainer),this.cropImage.appendChild(this.editingTargetContainer),this.cropImageHolder.appendChild(this.cropImage),this.editorCanvas.appendChild(this.cropImageHolder)},ae.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},ae.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=w.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new ze(this.imageWidth,this.imageHeight,this.CANVAS_MARGIN,this.cropLayerContainer),this.cropLayer.onCropChange=this.cropRectChanged,this.cropLayer.numberOfGridLines=this.gridLines,this.cropLayer.isGridVisible=this.isGridVisible,this.cropLayer.cropShadeColor=this.styles.settings.cropShadeColor,this.cropLayer.cropFrameColor=this.styles.settings.cropFrameColor,this.cropLayer.gripColor=this.styles.settings.gripColor,this.cropLayer.gripFillColor=this.styles.settings.gripFillColor,this.cropLayer.open(),this.cropLayer.setCropRectangle(this.cropRect),this.zoomToCropEnabled&&this.zoomToCrop()},ae.prototype.zoomToCrop=function(){if(this.cropRect){var V=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,Y=this.cropRect.y-this.CANVAS_MARGIN+this.cropRect.height/2;this.zoomFactor=Math.min(this.imageWidth/this.cropRect.width,this.imageHeight/this.cropRect.height),this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin=V+"px "+Y+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-V+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-Y+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},ae.prototype.unzoomFromCrop=function(){this.zoomFactor=1,this.editingTargetContainer&&this.cropLayer&&(this.editingTargetContainer.style.transformOrigin="center",this.editingTargetContainer.style.transform="translate("+this.CANVAS_MARGIN+"px, "+this.CANVAS_MARGIN+"px) scale(1)",this.cropLayer.zoomFactor=this.zoomFactor)},ae.prototype.cropRectChanged=function(V){this.cropRect=V,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},ae.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},ae.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},ae.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},ae.prototype.showUI=function(){switch(this.addStyles(),this.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.displayMode){case"inline":this.coverDiv.style.position="absolute";var V=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,Y=this.target.offsetTop>V+this.CANVAS_MARGIN?this.target.offsetTop-(V+this.CANVAS_MARGIN):0;this.coverDiv.style.top=Y+"px",this.coverDiv.style.left=(this.target.offsetLeft>this.CANVAS_MARGIN?this.target.offsetLeft-this.CANVAS_MARGIN:0)+"px",this.coverDiv.style.width=this.target.offsetWidth+this.CANVAS_MARGIN+"px",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.styles.settings.zIndex!==void 0?this.styles.settings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.displayMode==="popup"?this.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.addToolbars(),this.uiDiv.appendChild(this.topToolbar.getUI()),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.alignItems="center",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.contentDiv.style.overflow="hidden",this.contentDiv.style.backgroundColor=this.styles.settings.canvasBackgroundColor,this.displayMode==="popup"&&(this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.popupMargin+"px)"),this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.contentDiv.appendChild(this.editorCanvas),this.uiDiv.appendChild(this.bottomToolbar.getUI()),this.straightener.angle=this.rotationAngle},ae.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},ae.prototype.addTopToolbar=function(){var V=this;this.topToolbar=new B,this.topToolbar.display=this.styles.settings.hideTopToolbar?"none":"",this.topToolbar.className=this.toolbarStyleClass.name,this.topToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.topToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.topToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.topToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.topToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.topToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var Y=new Ee;Y.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(Y);var te=[];this.aspectRatios.forEach(function(We){var Qe=new Le(De.getIcon(We.horizontal,We.vertical),We.horizontal===0&&We.vertical===0?"FREE":We.horizontal+":"+We.vertical);Qe.onClick=function(){return V.ratioButtonClicked(We)},te.push(Qe)}),this.aspectRatioButton=new Pe(De.getIcon(0,0),"Aspect ratio",te),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,Y.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var oe=new Le('<svg viewBox="0 0 24 24"><path d="M10 4v4h4V4h-4m6 0v4h4V4h-4m0 6v4h4v-4h-4m0 6v4h4v-4h-4m-2 4v-4h-4v4h4m-6 0v-4H4v4h4m0-6v-4H4v4h4m0-6V4H4v4h4m2 6h4v-4h-4v4M4 2h16a2 2 0 012 2v16a2 2 0 01-2 2H4c-1.08 0-2-.9-2-2V4a2 2 0 012-2z"/></svg>',"Toggle grid");oe.isActive=this.isGridVisible,oe.onClick=function(){V.isGridVisible=!V.isGridVisible,oe.isActive=V.isGridVisible},Y.addButton(oe);var Q=new Le('<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"Zoom to selection");if(Q.isActive=this.zoomToCropEnabled,Q.onClick=function(){V.zoomToCropEnabled=!V.zoomToCropEnabled,Q.isActive=V.zoomToCropEnabled},Y.addButton(Q),!W.isLicensed){var ee=new Ie;this.topToolbar.addElementBlock(ee);var se=document.createElement("div");se.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var ue=document.createElement("a");ue.style.color="currentColor",ue.href="https://markerjs.com/products/cropro",ue.target="_blank",ue.innerHTML='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><path d="M16.326 14.895c0 1.126-.558 1.688-1.673 1.688H9.931c-1.116 0-1.674-.562-1.674-1.688V3.733c0-1.126.558-1.688 1.674-1.688h4.722c1.115 0 1.673.562 1.673 1.688v2.899h-1.957V3.793h-4.124v11.042h4.124v-3.242h1.957v3.302z" fill="currentColor"/><path d="M15.94 7.364a.783.783 0 00-1.065-.304l-11.01 6.126a.783.783 0 00-.303 1.065l4.498 8.085a.783.783 0 001.065.304l11.01-6.126a.783.783 0 00.303-1.065L15.94 7.364zM5.311 14.173l3.737 6.718 9.641-5.364-3.737-6.718-9.641 5.364z" fill="#eef762"/></svg>',se.appendChild(ue),ee.addElement(se)}var me=new Ee;me.minWidth=3*this.toolbarHeight+"px",me.contentAlign="end",this.topToolbar.addButtonBlock(me);var ye=new Le('<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"OK");ye.onClick=this.startRenderAndClose,me.addButton(ye),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(ye.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var ke=new Le('<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"Close");ke.onClick=this.close,me.addButton(ke),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(ke.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},ae.prototype.addBottomToolbar=function(){var V=this;this.bottomToolbar=new B,this.bottomToolbar.display=this.styles.settings.hideBottomToolbar?"none":"",this.bottomToolbar.className=this.toolbarStyleClass.name,this.bottomToolbar.colorsClassName=this.styles.settings.toolbarStyleColorsClassName?this.styles.settings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name,this.bottomToolbar.fadeInClassName=this.styles.fadeInAnimationClassName,this.bottomToolbar.blockClassName=this.toolbarBlockStyleClass.name,this.bottomToolbar.buttonClassName=this.toolbarButtonStyleClass.name,this.bottomToolbar.buttonColorsClassName=this.styles.settings.toolbarButtonStyleColorsClassName?this.styles.settings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,this.bottomToolbar.buttonActiveColorsClassName=this.styles.settings.toolbarActiveButtonStyleColorsClassName?this.styles.settings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name;var Y=new Ee;Y.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(Y);var te=new Le('<svg viewBox="0 0 24 24"><path d="M13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93M7.1 18.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32M6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47m1.02-4.47L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47z"/></svg>',"Rotate left");te.onClick=this.rotateLeftButtonClicked,Y.addButton(te);var oe=new Le('<svg viewBox="0 0 24 24"><path d="M16.89 15.5l1.42 1.39c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.5M13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03m6.93-6.9a7.906 7.906 0 00-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47m-2.36-5.45L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45z"/></svg>',"Rotate right");oe.onClick=this.rotateRightButtonClicked,Y.addButton(oe);var Q=new Ie;Q.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(Q),this.straightener=new Ke("Straighten"),this.straightener.className=this.toolbarStraightenerStyleClass.name,this.straightener.colorsClassName=this.styles.settings.toolbarStraightenerColorsClassName?this.styles.settings.toolbarStraightenerColorsClassName:this.toolbarStraightenerStyleColorsClass.name,this.straightener.onAngleChange=function(me){V.rotateBy(me),V.straightener.angle=V.rotationAngle},Q.addElement(this.straightener.getUI());var ee=new Ee;ee.minWidth=2*this.toolbarHeight+"px",ee.contentAlign="end",this.bottomToolbar.addButtonBlock(ee);var se=new Le('<svg viewBox="0 0 24 24"><path d="M15 21h2v-2h-2m4-10h2V7h-2M3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2m16-2v2h2c0-1.1-.9-2-2-2m-8 20h2V1h-2m8 16h2v-2h-2M15 5h2V3h-2m4 10h2v-2h-2m0 10c1.1 0 2-.9 2-2h-2z"/></svg>',"Flip horizontal");se.onClick=this.flipHorizontallyButtonClicked,ee.addButton(se);var ue=new Le('<svg viewBox="0 0 24 24"><path d="M3 15v2h2v-2m10 4v2h2v-2m2-16H5c-1.1 0-2 .9-2 2v4h2V5h14v4h2V5c0-1.1-.9-2-2-2m2 16h-2v2c1.1 0 2-.9 2-2M1 11v2h22v-2M7 19v2h2v-2m10-4v2h2v-2m-10 4v2h2v-2M3 19c0 1.1.9 2 2 2v-2z"/></svg>',"Flip vertical");ue.onClick=this.flipVerticallyButtonClicked,ee.addButton(ue)},ae.prototype.ratioButtonClicked=function(V){this.aspectRatio=V,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},ae.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=De.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},ae.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new _e(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},ae.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},ae.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},ae.prototype.restoreState=function(V){if(V){var Y=this.cropLayer.getRescaledRect(V.width,V.height,this.imageWidth,this.imageHeight,V.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(Y),this.cropRectChanged(Y),this.flippedHorizontally=V.flippedHorizontally,this.flippedVertically=V.flippedVertically,this.applyFlip(),this.rotationAngle=V.rotationAngle,this.applyRotation()}},ae.prototype.clientToLocalCoordinates=function(V,Y){var te=this.cropImage.getBoundingClientRect();return{x:V-te.left,y:Y-te.top}},ae.prototype.onWindowResize=function(){this.positionUI()},ae.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var V=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=V+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight="calc(100vh - "+(2*this.popupMargin+2*this.toolbarHeight)+"px)"}this.positionCropImage()},ae.prototype.rotateLeftButtonClicked=function(){var V=this.rotationAngle-90;this.rotationAngle%90!=0&&(V+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(V)},ae.prototype.rotateRightButtonClicked=function(){var V=this.rotationAngle+90;this.rotationAngle%90!=0&&(V-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(V)},ae.prototype.rotateTo=function(V){V=(V=V>180?V-360:V)<=-180?V+360:V,this.rotationAngle=V,this.applyRotation()},ae.prototype.rotateBy=function(V){this.rotateTo((this.rotationAngle+V)%360)},ae.prototype.applyRotation=function(){var V=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var Y=this.editingTargetRotationContainer.transform.baseVal.getItem(0);Y.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(Y,0);var te=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/te.width,this.imageHeight/te.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=V},ae.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},ae.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},ae.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},ae.prototype.startRenderAndClose=function(){return we(this,void 0,void 0,function(){var V,Y;return ve(this,function(te){switch(te.label){case 0:return[4,this.render()];case 1:return V=te.sent(),Y=this.getState(),this.renderEventListeners.forEach(function(oe){return oe(V,Y)}),this.close(!0),[2]}})})},ae.prototype.render=function(){return we(this,void 0,void 0,function(){var V;return ve(this,function(Y){switch(Y.label){case 0:return(V=new Ve).naturalSize=this.renderAtNaturalSize,V.imageType=this.renderImageType,V.imageQuality=this.renderImageQuality,V.width=this.renderWidth,V.height=this.renderHeight,this.unzoomFromCrop(),w.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,V.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 1:return Y.sent(),[4,V.rasterize(this.cropImage,this.target,{x:this.cropRect.x,y:this.cropRect.y,width:this.cropRect.width,height:this.cropRect.height},this.CANVAS_MARGIN,this.rotationAngle,this.scaleFactor*(this.flippedHorizontally?-1:1),this.scaleFactor*(this.flippedVertically?-1:1))];case 2:return[2,Y.sent()]}})})},ae.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new q("toolbar",`
width: `+(this.displayMode==="inline"?"100%":"calc(100vw - "+2*this.popupMargin+"px)")+`;
flex-shrink: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
height: `+this.toolbarHeight+`px;
box-sizing: content-box;
overflow: hidden;
line-height: 0px;
`)),this.toolbarStyleColorsClass=this.styles.addClass(new q("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new q("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var V=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new q("toolbar_button",`
display: inline-block;
width: `+(this.toolbarHeight-2*V)+`px;
height: `+(this.toolbarHeight-2*V)+`px;
padding: `+V+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new q("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new q("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new H("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new H("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new q("toolbar_dropdown",`
position: absolute;
max-width: `+4*this.toolbarHeight+`px;
z-index: 20;
white-space: normal;
box-sizing: content-box;
box-shadow: 3px 3px rgba(33, 33, 33, 0.1);
margin: `+(this.displayMode==="inline"?"0":this.popupMargin)+`px;
line-height: 0px;
`)),this.toolbarDropdownStyleColorsClass=this.styles.addClass(new q("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new q("toolbar_straightener_block",`
display: flex;
overflow: hidden;
justify-content: center;
-webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 30%, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%);
`)),this.toolbarStraightenerStyleClass=this.styles.addClass(new q("toolbar_straightener",`
display: flex;
overflow: hidden;
justify-content: center;
height: `+(this.toolbarHeight-2*V)+`px;
padding: `+V+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new q("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},ae.instanceCounter=0,ae}(),Xe=le("8hTe"),$e=le.n(Xe),Ae=/<pre[^>]*>/g;function rt(ae){var V=document.createElement("div");return V.innerHTML=ae,V.childNodes.length===0?"":V.childNodes[0].nodeValue}var Je=et.a=function(ae){var V=ae.value,Y=V===void 0?"":V,te=ae.edit,oe=te===void 0?!1:te,Q=ae.className,ee=ae.showTextOnly,se=ae.showLines,ue=ae.replaces,me=ae.zoomImg,ye=ae.hasMask,ke=ae.style,We=ke===void 0?{}:ke,Qe=ae.stylesPrev,tt=Qe===void 0?{}:Qe,vt=String(Y),ot=Object(O.useRef)(),it=Object(O.useRef)(),wt=Object(O.useState)(""),xt=Object(j.a)(wt,2),It=xt[0],Ot=xt[1],Et=Object(O.useState)("office"),mr=Object(j.a)(Et,2),Tr=mr[0],Yt=mr[1],gr=function(){var Tt=new at(it.current);Tt.displayMode="popup",Tt.addRenderEventListener(function(){var Zt=Object(D.a)(P.a.mark(function mt(pt){var At;return P.a.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:return ot.current.style.display="none",Ut.next=3,Object(Me.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:pt}});case 3:At=Ut.sent,At!=null&&At.id&&ue(it.current.getAttribute("src").replace(ce.a.API_SERVER,""),"/api/attachments/".concat(At==null?void 0:At.id,"?type=").concat(At.content_type));case 5:case"end":return Ut.stop()}},mt)}));return function(mt){return Zt.apply(this,arguments)}}()),Tt.show()},cr=function(){var Tt=new Te.a(it.current);Tt.settings.displayMode="popup",Tt.addEventListener("render",function(){var Zt=Object(D.a)(P.a.mark(function mt(pt){var At;return P.a.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:if(ot.current.style.display="none",!it.current){Ut.next=6;break}return Ut.next=4,Object(Me.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:pt.dataUrl}});case 4:At=Ut.sent,At!=null&&At.id&&ue(it.current.getAttribute("src").replace(ce.a.API_SERVER,""),"/api/attachments/".concat(At==null?void 0:At.id,"?type=").concat(At.content_type));case 6:case"end":return Ut.stop()}},mt)}));return function(mt){return Zt.apply(this,arguments)}}()),Tt.show(),window.markerArea=Tt},zr=Object(O.useMemo)(function(){ot.current&&(ot.current.style.zIndex=-1);try{var Ye=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Tt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,Zt=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;vt=vt.replace(Ye,"("+ce.a.API_SERVER+"/api/attachments/").replace(Tt,'"'+ce.a.API_SERVER+"/api/attachments/").replace(Zt,'"'+ce.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(vr){}var mt=ie(vt),pt=x();if(vt.match(/\[TOC\]/)&&(mt=mt.replace("<p>[TOC]</p>",L()),E()),mt=mt.replace(/(__special_katext_id_\d+__)/g,function(vr,Ut){var Be=pt[Ut],ht=Be.type,ri=Be.expression;return Object(ge.renderToString)(rt(ri)||"",{displayMode:ht==="block",throwOnError:!1,output:"html"})}),mt=mt.replace(/▁/g,"\u2581\u2581\u2581"),p(),ee){var At=document.createElement("div");return At.innerHTML=mt,At.innerText}return setTimeout(function(){return ti()},500),mt},[vt]),$t=Object(O.useRef)();m.WebkitLineClamp=se,se&&(We=Object(I.a)(Object(I.a)({},We),m));function Nr(Ye){var Tt=Ye.target;if(Tt.tagName.toUpperCase()==="IMG"){if(me){var Zt=Tt.getAttribute("src");Ot(Zt),Yt("image")}}else if(Tt.tagName.toUpperCase()==="A"){var mt=Tt.getAttribute("href");if(mt.indexOf("office")>-1)Ye.preventDefault(),Ot(mt),Yt("office");else if(mt.indexOf("application/pdf")>-1)Ye.preventDefault(),Ot(mt),Yt("pdf");else if(mt.indexOf("text/html")>-1)Ye.preventDefault(),Ot(mt),Yt("html");else if(mt.startsWith("#")){Ye.preventDefault();var pt=document.getElementById(mt.replace("#",""));pt&&pt.scrollIntoView(!0)}}}var ti=function(){var Tt,Zt=(Tt=$t.current)===null||Tt===void 0?void 0:Tt.querySelectorAll("video");Zt==null||Zt.forEach(function(mt){if(mt.oncontextmenu=function(){return!1},mt.src.indexOf(".m3u8")>-1&&!mt.canPlayType("application/vnd.apple.mpegurl")){if(ne.a.isSupported()){var pt=new ne.a;pt.loadSource(mt.src),pt.attachMedia(mt)}}})};Object(O.useEffect)(function(){if($t.current&&zr&&(zr.match(Ae)&&window.PR.prettyPrint()),$t.current)return $t.current.addEventListener("click",Nr),function(){$t.current.removeEventListener("click",Nr),p(),E()}},[zr,$t.current,Nr]);var Pt=function(Tt){if(!oe)return;Tt.target.nodeName==="IMG"?(ot.current.style.zIndex=1,ot.current.style.display="flex",ot.current.style.width=Tt.target.clientWidth+"px",ot.current.style.height=Tt.target.clientHeight+"px",ot.current.style.top=Tt.target.offsetTop+"px",ot.current.style.left=Tt.target.offsetLeft+"px",it.current.src=Tt.target.getAttribute("src")):ot.current.style.display="none"};return v.a.createElement("div",{style:{position:"relative"}},v.a.createElement("div",{ref:$t,style:Object(I.a)({},We),className:"".concat(Q||""," markdown-body ").concat($e.a.mdBody),onMouseOver:Pt,dangerouslySetInnerHTML:{__html:zr}}),v.a.createElement("div",{ref:ot,className:$e.a.button},v.a.createElement(J.a,null,v.a.createElement($.a,{onClick:function(){return gr()}},"\u88C1\u526A"),v.a.createElement($.a,{onClick:function(){return cr()}},"\u7F16\u8F91"))),v.a.createElement("img",{ref:it,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1}}),v.a.createElement(xe.a,{close:!0,data:It,type:It!=null&&It.length?Tr:"",style:Object(I.a)({},tt),onClose:function(){return Ot("")}}))}},"9VGf":function(dt,et,le){"use strict";le.d(et,"a",function(){return _});var fe=le("q1tI"),J=le.n(fe);function _($,I){var D=Object(fe.useRef)();Object(fe.useEffect)(function(){D.current=$}),Object(fe.useEffect)(function(){function j(){D.current()}if(I!==null){var U=setInterval(j,I);return function(){return clearInterval(U)}}},[I])}},"9ZNV":function(dt,et,le){"use strict";le.d(et,"a",function(){return O});var fe=le("0Owb"),J=le("+L6B"),_=le("2/Rp"),$=le("q1tI"),I=le.n($),D=le("UUDw"),j=le.n(D),U=le("TSYQ"),P=le.n(U),O=function(T){var R=T.cancelText,A=R===void 0?"\u53D6\u6D88":R,C=T.okText,S=C===void 0?"\u786E\u5B9A":C,u=T.loading,o=u===void 0?!1:u,s=T.hasOkBtn,l=s===void 0?!0:s,E=T.okButtonProps,m=E===void 0?{}:E,f=T.onCancel,L=f===void 0?function(){}:f,g=T.onOk,d=g===void 0?function(){}:g,c=T.className,h=c===void 0?"":c;return I.a.createElement("div",{className:P()(j.a.buttonFixed,h)},I.a.createElement("div",{className:j.a.buttonWrap},I.a.createElement(_.a,{size:"large",className:"".concat(j.a.button," mr20"),onClick:L},A),l&&I.a.createElement(_.a,Object(fe.a)({size:"large",type:"primary",className:"".concat(j.a.button," mr20"),loading:o,onClick:d},m),S)))}},Bd2K:function(dt,et,le){(function(fe){fe(le("VrN/"),le("osHv"))})(function(fe){fe.defineOption("autoCloseTags",!1,function(P,O,v){if(v!=fe.Init&&v&&P.removeKeyMap("autoCloseTags"),!O)return;var T={name:"autoCloseTags"};(typeof O!="object"||O.whenClosing!==!1)&&(T["'/'"]=function(R){return D(R)}),(typeof O!="object"||O.whenOpening!==!1)&&(T["'>'"]=function(R){return $(R)}),P.addKeyMap(T)});var J=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],_=["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 $(P){if(P.getOption("disableInput"))return fe.Pass;for(var O=P.listSelections(),v=[],T=P.getOption("autoCloseTags"),R=0;R<O.length;R++){if(!O[R].empty())return fe.Pass;var A=O[R].head,C=P.getTokenAt(A),S=fe.innerMode(P.getMode(),C.state),u=S.state,o=S.mode.xmlCurrentTag&&S.mode.xmlCurrentTag(u),s=o&&o.name;if(!s)return fe.Pass;var l=S.mode.configuration=="html",E=typeof T=="object"&&T.dontCloseTags||l&&J,m=typeof T=="object"&&T.indentTags||l&&_;C.end>A.ch&&(s=s.slice(0,s.length-C.end+A.ch));var f=s.toLowerCase();if(!s||C.type=="string"&&(C.end!=A.ch||!/[\"\']/.test(C.string.charAt(C.string.length-1))||C.string.length==1)||C.type=="tag"&&o.close||C.string.indexOf("/")==A.ch-C.start-1||E&&j(E,f)>-1||U(P,S.mode.xmlCurrentContext&&S.mode.xmlCurrentContext(u)||[],s,A,!0))return fe.Pass;var L=typeof T=="object"&&T.emptyTags;if(L&&j(L,s)>-1){v[R]={text:"/>",newPos:fe.Pos(A.line,A.ch+2)};continue}var g=m&&j(m,f)>-1;v[R]={indent:g,text:">"+(g?`
`:"")+"</"+s+">",newPos:g?fe.Pos(A.line+1,0):fe.Pos(A.line,A.ch+1)}}for(var d=typeof T=="object"&&T.dontIndentOnAutoClose,R=O.length-1;R>=0;R--){var c=v[R];P.replaceRange(c.text,O[R].head,O[R].anchor,"+insert");var h=P.listSelections().slice(0);h[R]={head:c.newPos,anchor:c.newPos},P.setSelections(h),!d&&c.indent&&(P.indentLine(c.newPos.line,null,!0),P.indentLine(c.newPos.line+1,null,!0))}}function I(P,O){for(var v=P.listSelections(),T=[],R=O?"/":"</",A=P.getOption("autoCloseTags"),C=typeof A=="object"&&A.dontIndentOnSlash,S=0;S<v.length;S++){if(!v[S].empty())return fe.Pass;var u=v[S].head,o=P.getTokenAt(u),s=fe.innerMode(P.getMode(),o.state),l=s.state;if(O&&(o.type=="string"||o.string.charAt(0)!="<"||o.start!=u.ch-1))return fe.Pass;var E,m=s.mode.name!="xml"&&P.getMode().name=="htmlmixed";if(m&&s.mode.name=="javascript")E=R+"script";else if(m&&s.mode.name=="css")E=R+"style";else{var f=s.mode.xmlCurrentContext&&s.mode.xmlCurrentContext(l);if(!f||f.length&&U(P,f,f[f.length-1],u))return fe.Pass;E=R+f[f.length-1]}P.getLine(u.line).charAt(o.end)!=">"&&(E+=">"),T[S]=E}if(P.replaceSelections(T),v=P.listSelections(),!C)for(var S=0;S<v.length;S++)(S==v.length-1||v[S].head.line<v[S+1].head.line)&&P.indentLine(v[S].head.line)}function D(P){return P.getOption("disableInput")?fe.Pass:I(P,!0)}fe.commands.closeTag=function(P){return I(P)};function j(P,O){if(P.indexOf)return P.indexOf(O);for(var v=0,T=P.length;v<T;++v)if(P[v]==O)return v;return-1}function U(P,O,v,T,R){if(!fe.scanForClosingTag)return!1;var A=Math.min(P.lastLine()+1,T.line+500),C=fe.scanForClosingTag(P,T,null,A);if(!C||C.tag!=v)return!1;for(var S=R?1:0,u=O.length-1;u>=0&&O[u]==v;u--)++S;T=C.to;for(var u=1;u<S;u++){var o=fe.scanForClosingTag(P,T,null,A);if(!o||o.tag!=v)return!1;T=o.to}return!0}})},BjJ7:function(dt,et,le){"use strict";le.d(et,"d",function(){return J}),le.d(et,"c",function(){return _}),le.d(et,"e",function(){return $}),le.d(et,"b",function(){return I}),le.d(et,"a",function(){return j});var fe=le("m3rI");function J(U){var P=!0;if(U.length>0){for(var O=0;O<U.length;O++)if(U[O].compile_success==0||!U[O].compile_success){P=!1;break}}else P=!1;return P}function _(U){for(var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",O=[],v=0;v<U.length;v++){var T=U[v],R=P?"".concat(P,"/").concat(T.name):"".concat(T.name);O.push({title:T.name,isLeaf:!(T.type==="tree"),key:R})}return O}function $(U,P,O){for(var v=0;v<U.length;v++){var T=U[v];if(T.key===P){T.children=O;break}T.children&&$(T.children,P,O)}return U}function I(U,P,O){var v;return function(){var T=this,R=arguments,A=function(){v=null,O||U.apply(T,R)},C=O&&!v;clearTimeout(v),v=setTimeout(A,P),C&&U.apply(T,R)}}var D=!0,j=fe.a.API_SERVER},"C+DQ":function(dt,et,le){},DlQD:function(dt,et,le){(function(fe,J){dt.exports=J()})(this,function(){"use strict";function fe(Y,te){for(var oe=0;oe<te.length;oe++){var Q=te[oe];Q.enumerable=Q.enumerable||!1,Q.configurable=!0,"value"in Q&&(Q.writable=!0),Object.defineProperty(Y,Q.key,Q)}}function J(Y,te,oe){return te&&fe(Y.prototype,te),oe&&fe(Y,oe),Y}function _(Y,te){if(!Y)return;if(typeof Y=="string")return $(Y,te);var oe=Object.prototype.toString.call(Y).slice(8,-1);if(oe==="Object"&&Y.constructor&&(oe=Y.constructor.name),oe==="Map"||oe==="Set")return Array.from(Y);if(oe==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(oe))return $(Y,te)}function $(Y,te){(te==null||te>Y.length)&&(te=Y.length);for(var oe=0,Q=new Array(te);oe<te;oe++)Q[oe]=Y[oe];return Q}function I(Y,te){var oe;if(typeof Symbol=="undefined"||Y[Symbol.iterator]==null){if(Array.isArray(Y)||(oe=_(Y))||te&&Y&&typeof Y.length=="number"){oe&&(Y=oe);var Q=0;return function(){return Q>=Y.length?{done:!0}:{done:!1,value:Y[Q++]}}}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 oe=Y[Symbol.iterator](),oe.next.bind(oe)}function D(Y,te){return te={exports:{}},Y(te,te.exports),te.exports}var j=D(function(Y){function te(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}function oe(Q){Y.exports.defaults=Q}Y.exports={defaults:te(),getDefaults:te,changeDefaults:oe}}),U=j.defaults,P=j.getDefaults,O=j.changeDefaults,v=/[&<>"']/,T=/[&<>"']/g,R=/[<>"']|&(?!#?\w+;)/,A=/[<>"']|&(?!#?\w+;)/g,C={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},S=function(te){return C[te]};function u(Y,te){if(te){if(v.test(Y))return Y.replace(T,S)}else if(R.test(Y))return Y.replace(A,S);return Y}var o=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function s(Y){return Y.replace(o,function(te,oe){return oe=oe.toLowerCase(),oe==="colon"?":":oe.charAt(0)==="#"?oe.charAt(1)==="x"?String.fromCharCode(parseInt(oe.substring(2),16)):String.fromCharCode(+oe.substring(1)):""})}var l=/(^|[^\[])\^/g;function E(Y,te){Y=Y.source||Y,te=te||"";var oe={replace:function(ee,se){return se=se.source||se,se=se.replace(l,"$1"),Y=Y.replace(ee,se),oe},getRegex:function(){return new RegExp(Y,te)}};return oe}var m=/[^\w:]/g,f=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function L(Y,te,oe){if(Y){var Q;try{Q=decodeURIComponent(s(oe)).replace(m,"").toLowerCase()}catch(ee){return null}if(Q.indexOf("javascript:")===0||Q.indexOf("vbscript:")===0||Q.indexOf("data:")===0)return null}te&&!f.test(oe)&&(oe=a(te,oe));try{oe=encodeURI(oe).replace(/%25/g,"%")}catch(ee){return null}return oe}var g={},d=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,h=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(Y,te){g[" "+Y]||(d.test(Y)?g[" "+Y]=Y+"/":g[" "+Y]=M(Y,"/",!0)),Y=g[" "+Y];var oe=Y.indexOf(":")===-1;return te.substring(0,2)==="//"?oe?te:Y.replace(c,"$1")+te:te.charAt(0)==="/"?oe?te:Y.replace(h,"$1")+te:Y+te}var x={exec:function(){}};function p(Y){for(var te=1,oe,Q;te<arguments.length;te++){oe=arguments[te];for(Q in oe)Object.prototype.hasOwnProperty.call(oe,Q)&&(Y[Q]=oe[Q])}return Y}function b(Y,te){var oe=Y.replace(/\|/g,function(se,ue,me){for(var ye=!1,ke=ue;--ke>=0&&me[ke]==="\\";)ye=!ye;return ye?"|":" |"}),Q=oe.split(/ \|/),ee=0;if(Q.length>te)Q.splice(te);else for(;Q.length<te;)Q.push("");for(;ee<Q.length;ee++)Q[ee]=Q[ee].trim().replace(/\\\|/g,"|");return Q}function M(Y,te,oe){var Q=Y.length;if(Q===0)return"";for(var ee=0;ee<Q;){var se=Y.charAt(Q-ee-1);if(se===te&&!oe)ee++;else if(se!==te&&oe)ee++;else break}return Y.substr(0,Q-ee)}function G(Y,te){if(Y.indexOf(te[1])===-1)return-1;for(var oe=Y.length,Q=0,ee=0;ee<oe;ee++)if(Y[ee]==="\\")ee++;else if(Y[ee]===te[0])Q++;else if(Y[ee]===te[1]&&(Q--,Q<0))return ee;return-1}function Z(Y){Y&&Y.sanitize&&!Y.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 ie={escape:u,unescape:s,edit:E,cleanUrl:L,resolveUrl:a,noopTest:x,merge:p,splitCells:b,rtrim:M,findClosingBracket:G,checkSanitizeDeprecation:Z},z=j.defaults,F=ie.rtrim,ne=ie.splitCells,ce=ie.escape,ge=ie.findClosingBracket;function xe(Y,te,oe){var Q=te.href,ee=te.title?ce(te.title):null,se=Y[1].replace(/\\([\[\]])/g,"$1");return Y[0].charAt(0)!=="!"?{type:"link",raw:oe,href:Q,title:ee,text:se}:{type:"image",raw:oe,href:Q,title:ee,text:ce(se)}}function Me(Y,te){var oe=Y.match(/^(\s+)(?:```)/);if(oe===null)return te;var Q=oe[1];return te.split(`
`).map(function(ee){var se=ee.match(/^\s+/);if(se===null)return ee;var ue=se[0];return ue.length>=Q.length?ee.slice(Q.length):ee}).join(`
`)}var Te=function(){function Y(oe){this.options=oe||z}var te=Y.prototype;return te.space=function(Q){var ee=this.rules.block.newline.exec(Q);if(ee)return ee[0].length>1?{type:"space",raw:ee[0]}:{raw:`
`}},te.code=function(Q,ee){var se=this.rules.block.code.exec(Q);if(se){var ue=ee[ee.length-1];if(ue&&ue.type==="paragraph")return{raw:se[0],text:se[0].trimRight()};var me=se[0].replace(/^ {4}/gm,"");return{type:"code",raw:se[0],codeBlockStyle:"indented",text:this.options.pedantic?me:F(me,`
`)}}},te.fences=function(Q){var ee=this.rules.block.fences.exec(Q);if(ee){var se=ee[0],ue=Me(se,ee[3]||"");return{type:"code",raw:se,lang:ee[2]?ee[2].trim():ee[2],text:ue}}},te.heading=function(Q){var ee=this.rules.block.heading.exec(Q);if(ee)return{type:"heading",raw:ee[0],depth:ee[1].length,text:ee[2]}},te.nptable=function(Q){var ee=this.rules.block.nptable.exec(Q);if(ee){var se={type:"table",header:ne(ee[1].replace(/^ *| *\| *$/g,"")),align:ee[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ee[3]?ee[3].replace(/\n$/,"").split(`
`):[],raw:ee[0]};if(se.header.length===se.align.length){var ue=se.align.length,me;for(me=0;me<ue;me++)/^ *-+: *$/.test(se.align[me])?se.align[me]="right":/^ *:-+: *$/.test(se.align[me])?se.align[me]="center":/^ *:-+ *$/.test(se.align[me])?se.align[me]="left":se.align[me]=null;for(ue=se.cells.length,me=0;me<ue;me++)se.cells[me]=ne(se.cells[me],se.header.length);return se}}},te.hr=function(Q){var ee=this.rules.block.hr.exec(Q);if(ee)return{type:"hr",raw:ee[0]}},te.blockquote=function(Q){var ee=this.rules.block.blockquote.exec(Q);if(ee){var se=ee[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:ee[0],text:se}}},te.list=function(Q){var ee=this.rules.block.list.exec(Q);if(ee){for(var se=ee[0],ue=ee[2],me=ue.length>1,ye=ue[ue.length-1]===")",ke={type:"list",raw:se,ordered:me,start:me?+ue.slice(0,-1):"",loose:!1,items:[]},We=ee[0].match(this.rules.block.item),Qe=!1,tt,vt,ot,it,wt,xt,It,Ot=We.length,Et=0;Et<Ot;Et++)tt=We[Et],se=tt,vt=tt.length,tt=tt.replace(/^ *([*+-]|\d+[.)]) */,""),~tt.indexOf(`
`)&&(vt-=tt.length,tt=this.options.pedantic?tt.replace(/^ {1,4}/gm,""):tt.replace(new RegExp("^ {1,"+vt+"}","gm"),"")),Et!==Ot-1&&(ot=this.rules.block.bullet.exec(We[Et+1])[0],(me?ot.length===1||!ye&&ot[ot.length-1]===")":ot.length>1||this.options.smartLists&&ot!==ue)&&(it=We.slice(Et+1).join(`
`),ke.raw=ke.raw.substring(0,ke.raw.length-it.length),Et=Ot-1)),wt=Qe||/\n\n(?!\s*$)/.test(tt),Et!==Ot-1&&(Qe=tt.charAt(tt.length-1)===`
`,wt||(wt=Qe)),wt&&(ke.loose=!0),xt=/^\[[ xX]\] /.test(tt),It=void 0,xt&&(It=tt[1]!==" ",tt=tt.replace(/^\[[ xX]\] +/,"")),ke.items.push({type:"list_item",raw:se,task:xt,checked:It,loose:wt,text:tt});return ke}},te.html=function(Q){var ee=this.rules.block.html.exec(Q);if(ee)return{type:this.options.sanitize?"paragraph":"html",raw:ee[0],pre:!this.options.sanitizer&&(ee[1]==="pre"||ee[1]==="script"||ee[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ee[0]):ce(ee[0]):ee[0]}},te.def=function(Q){var ee=this.rules.block.def.exec(Q);if(ee){ee[3]&&(ee[3]=ee[3].substring(1,ee[3].length-1));var se=ee[1].toLowerCase().replace(/\s+/g," ");return{tag:se,raw:ee[0],href:ee[2],title:ee[3]}}},te.table=function(Q){var ee=this.rules.block.table.exec(Q);if(ee){var se={type:"table",header:ne(ee[1].replace(/^ *| *\| *$/g,"")),align:ee[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:ee[3]?ee[3].replace(/\n$/,"").split(`
`):[]};if(se.header.length===se.align.length){se.raw=ee[0];var ue=se.align.length,me;for(me=0;me<ue;me++)/^ *-+: *$/.test(se.align[me])?se.align[me]="right":/^ *:-+: *$/.test(se.align[me])?se.align[me]="center":/^ *:-+ *$/.test(se.align[me])?se.align[me]="left":se.align[me]=null;for(ue=se.cells.length,me=0;me<ue;me++)se.cells[me]=ne(se.cells[me].replace(/^ *\| *| *\| *$/g,""),se.header.length);return se}}},te.lheading=function(Q){var ee=this.rules.block.lheading.exec(Q);if(ee)return{type:"heading",raw:ee[0],depth:ee[2].charAt(0)==="="?1:2,text:ee[1]}},te.paragraph=function(Q){var ee=this.rules.block.paragraph.exec(Q);if(ee)return{type:"paragraph",raw:ee[0],text:ee[1].charAt(ee[1].length-1)===`
`?ee[1].slice(0,-1):ee[1]}},te.text=function(Q,ee){var se=this.rules.block.text.exec(Q);if(se){var ue=ee[ee.length-1];return ue&&ue.type==="text"?{raw:se[0],text:se[0]}:{type:"text",raw:se[0],text:se[0]}}},te.escape=function(Q){var ee=this.rules.inline.escape.exec(Q);if(ee)return{type:"escape",raw:ee[0],text:ce(ee[1])}},te.tag=function(Q,ee,se){var ue=this.rules.inline.tag.exec(Q);if(ue)return!ee&&/^<a /i.test(ue[0])?ee=!0:ee&&/^<\/a>/i.test(ue[0])&&(ee=!1),!se&&/^<(pre|code|kbd|script)(\s|>)/i.test(ue[0])?se=!0:se&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ue[0])&&(se=!1),{type:this.options.sanitize?"text":"html",raw:ue[0],inLink:ee,inRawBlock:se,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ce(ue[0]):ue[0]}},te.link=function(Q){var ee=this.rules.inline.link.exec(Q);if(ee){var se=ge(ee[2],"()");if(se>-1){var ue=ee[0].indexOf("!")===0?5:4,me=ue+ee[1].length+se;ee[2]=ee[2].substring(0,se),ee[0]=ee[0].substring(0,me).trim(),ee[3]=""}var ye=ee[2],ke="";if(this.options.pedantic){var We=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(ye);We?(ye=We[1],ke=We[3]):ke=""}else ke=ee[3]?ee[3].slice(1,-1):"";ye=ye.trim().replace(/^<([\s\S]*)>$/,"$1");var Qe=xe(ee,{href:ye&&ye.replace(this.rules.inline._escapes,"$1"),title:ke&&ke.replace(this.rules.inline._escapes,"$1")},ee[0]);return Qe}},te.reflink=function(Q,ee){var se;if((se=this.rules.inline.reflink.exec(Q))||(se=this.rules.inline.nolink.exec(Q))){var ue=(se[2]||se[1]).replace(/\s+/g," ");if(ue=ee[ue.toLowerCase()],!ue||!ue.href){var me=se[0].charAt(0);return{type:"text",raw:me,text:me}}var ye=xe(se,ue,se[0]);return ye}},te.strong=function(Q,ee,se){se===void 0&&(se="");var ue=this.rules.inline.strong.start.exec(Q);if(ue&&(!ue[1]||ue[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){ee=ee.slice(-1*Q.length);var me=ue[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;me.lastIndex=0;for(var ye;(ue=me.exec(ee))!=null;)if(ye=this.rules.inline.strong.middle.exec(ee.slice(0,ue.index+3)),ye)return{type:"strong",raw:Q.slice(0,ye[0].length),text:Q.slice(2,ye[0].length-2)}}},te.em=function(Q,ee,se){se===void 0&&(se="");var ue=this.rules.inline.em.start.exec(Q);if(ue&&(!ue[1]||ue[1]&&(se===""||this.rules.inline.punctuation.exec(se)))){ee=ee.slice(-1*Q.length);var me=ue[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;me.lastIndex=0;for(var ye;(ue=me.exec(ee))!=null;)if(ye=this.rules.inline.em.middle.exec(ee.slice(0,ue.index+2)),ye)return{type:"em",raw:Q.slice(0,ye[0].length),text:Q.slice(1,ye[0].length-1)}}},te.codespan=function(Q){var ee=this.rules.inline.code.exec(Q);if(ee){var se=ee[2].replace(/\n/g," "),ue=/[^ ]/.test(se),me=se.startsWith(" ")&&se.endsWith(" ");return ue&&me&&(se=se.substring(1,se.length-1)),se=ce(se,!0),{type:"codespan",raw:ee[0],text:se}}},te.br=function(Q){var ee=this.rules.inline.br.exec(Q);if(ee)return{type:"br",raw:ee[0]}},te.del=function(Q){var ee=this.rules.inline.del.exec(Q);if(ee)return{type:"del",raw:ee[0],text:ee[1]}},te.autolink=function(Q,ee){var se=this.rules.inline.autolink.exec(Q);if(se){var ue,me;return se[2]==="@"?(ue=ce(this.options.mangle?ee(se[1]):se[1]),me="mailto:"+ue):(ue=ce(se[1]),me=ue),{type:"link",raw:se[0],text:ue,href:me,tokens:[{type:"text",raw:ue,text:ue}]}}},te.url=function(Q,ee){var se;if(se=this.rules.inline.url.exec(Q)){var ue,me;if(se[2]==="@")ue=ce(this.options.mangle?ee(se[0]):se[0]),me="mailto:"+ue;else{var ye;do ye=se[0],se[0]=this.rules.inline._backpedal.exec(se[0])[0];while(ye!==se[0]);ue=ce(se[0]),se[1]==="www."?me="http://"+ue:me=ue}return{type:"link",raw:se[0],text:ue,href:me,tokens:[{type:"text",raw:ue,text:ue}]}}},te.inlineText=function(Q,ee,se){var ue=this.rules.inline.text.exec(Q);if(ue){var me;return ee?me=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ue[0]):ce(ue[0]):ue[0]:me=ce(this.options.smartypants?se(ue[0]):ue[0]),{type:"text",raw:ue[0],text:me}}},Y}(),Oe=ie.noopTest,Ce=ie.edit,we=ie.merge,ve={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:Oe,table:Oe,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};ve._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,ve._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,ve.def=Ce(ve.def).replace("label",ve._label).replace("title",ve._title).getRegex(),ve.bullet=/(?:[*+-]|\d{1,9}[.)])/,ve.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,ve.item=Ce(ve.item,"gm").replace(/bull/g,ve.bullet).getRegex(),ve.list=Ce(ve.list).replace(/bull/g,ve.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ve.def.source+")").getRegex(),ve._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",ve._comment=/<!--(?!-?>)[\s\S]*?-->/,ve.html=Ce(ve.html,"i").replace("comment",ve._comment).replace("tag",ve._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ve.paragraph=Ce(ve._paragraph).replace("hr",ve.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",ve._tag).getRegex(),ve.blockquote=Ce(ve.blockquote).replace("paragraph",ve.paragraph).getRegex(),ve.normal=we({},ve),ve.gfm=we({},ve.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*|$)"}),ve.gfm.nptable=Ce(ve.gfm.nptable).replace("hr",ve.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",ve._tag).getRegex(),ve.gfm.table=Ce(ve.gfm.table).replace("hr",ve.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",ve._tag).getRegex(),ve.pedantic=we({},ve.normal,{html:Ce(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ve._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:Oe,paragraph:Ce(ve.normal._paragraph).replace("hr",ve.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",ve.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var W={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Oe,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:Oe,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};W._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",W.punctuation=Ce(W.punctuation).replace(/punctuation/g,W._punctuation).getRegex(),W._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",W._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",W.em.start=Ce(W.em.start).replace(/punctuation/g,W._punctuation).getRegex(),W.em.middle=Ce(W.em.middle).replace(/punctuation/g,W._punctuation).replace(/overlapSkip/g,W._overlapSkip).getRegex(),W.em.endAst=Ce(W.em.endAst,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.em.endUnd=Ce(W.em.endUnd,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.strong.start=Ce(W.strong.start).replace(/punctuation/g,W._punctuation).getRegex(),W.strong.middle=Ce(W.strong.middle).replace(/punctuation/g,W._punctuation).replace(/blockSkip/g,W._blockSkip).getRegex(),W.strong.endAst=Ce(W.strong.endAst,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.strong.endUnd=Ce(W.strong.endUnd,"g").replace(/punctuation/g,W._punctuation).getRegex(),W.blockSkip=Ce(W._blockSkip,"g").getRegex(),W.overlapSkip=Ce(W._overlapSkip,"g").getRegex(),W._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,W._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,W._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])?)+(?![-_])/,W.autolink=Ce(W.autolink).replace("scheme",W._scheme).replace("email",W._email).getRegex(),W._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,W.tag=Ce(W.tag).replace("comment",ve._comment).replace("attribute",W._attribute).getRegex(),W._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,W._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,W._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,W.link=Ce(W.link).replace("label",W._label).replace("href",W._href).replace("title",W._title).getRegex(),W.reflink=Ce(W.reflink).replace("label",W._label).getRegex(),W.reflinkSearch=Ce(W.reflinkSearch,"g").replace("reflink",W.reflink).replace("nolink",W.nolink).getRegex(),W.normal=we({},W),W.pedantic=we({},W.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:Ce(/^!?\[(label)\]\((.*?)\)/).replace("label",W._label).getRegex(),reflink:Ce(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",W._label).getRegex()}),W.gfm=we({},W.normal,{escape:Ce(W.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),W.gfm.url=Ce(W.gfm.url,"i").replace("email",W.gfm._extended_email).getRegex(),W.breaks=we({},W.gfm,{br:Ce(W.br).replace("{2,}","*").getRegex(),text:Ce(W.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var w={block:ve,inline:W},k=j.defaults,H=w.block,q=w.inline;function B(Y){return Y.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 he(Y){var te="",oe,Q,ee=Y.length;for(oe=0;oe<ee;oe++)Q=Y.charCodeAt(oe),Math.random()>.5&&(Q="x"+Q.toString(16)),te+="&#"+Q+";";return te}var Ee=function(){function Y(oe){this.tokens=[],this.tokens.links=Object.create(null),this.options=oe||k,this.options.tokenizer=this.options.tokenizer||new Te,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var Q={block:H.normal,inline:q.normal};this.options.pedantic?(Q.block=H.pedantic,Q.inline=q.pedantic):this.options.gfm&&(Q.block=H.gfm,this.options.breaks?Q.inline=q.breaks:Q.inline=q.gfm),this.tokenizer.rules=Q}Y.lex=function(Q,ee){var se=new Y(ee);return se.lex(Q)};var te=Y.prototype;return te.lex=function(Q){return Q=Q.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(Q,this.tokens,!0),this.inline(this.tokens),this.tokens},te.blockTokens=function(Q,ee,se){ee===void 0&&(ee=[]),se===void 0&&(se=!0),Q=Q.replace(/^ +$/gm,"");for(var ue,me,ye,ke;Q;){if(ue=this.tokenizer.space(Q)){Q=Q.substring(ue.raw.length),ue.type&&ee.push(ue);continue}if(ue=this.tokenizer.code(Q,ee)){Q=Q.substring(ue.raw.length),ue.type?ee.push(ue):(ke=ee[ee.length-1],ke.raw+=`
`+ue.raw,ke.text+=`
`+ue.text);continue}if(ue=this.tokenizer.fences(Q)){Q=Q.substring(ue.raw.length),ee.push(ue);continue}if(ue=this.tokenizer.heading(Q)){Q=Q.substring(ue.raw.length),ee.push(ue);continue}if(ue=this.tokenizer.nptable(Q)){Q=Q.substring(ue.raw.length),ee.push(ue);continue}if(ue=this.tokenizer.hr(Q)){Q=Q.substring(ue.raw.length),ee.push(ue);continue}if(ue=this.tokenizer.blockquote(Q)){Q=Q.substring(ue.raw.length),ue.tokens=this.blockTokens(ue.text,[],se),ee.push(ue);continue}if(ue=this.tokenizer.list(Q)){for(Q=Q.substring(ue.raw.length),ye=ue.items.length,me=0;me<ye;me++)ue.items[me].tokens=this.blockTokens(ue.items[me].text,[],!1);ee.push(ue);continue}if(ue=this.tokenizer.html(Q)){Q=Q.substring(ue.raw.length),ee.push(ue);continue}if(se&&(ue=this.tokenizer.def(Q))){Q=Q.substring(ue.raw.length),this.tokens.links[ue.tag]||(this.tokens.links[ue.tag]={href:ue.href,title:ue.title});continue}if(ue=this.tokenizer.table(Q)){Q=Q.substring(ue.raw.length),ee.push(ue);continue}if(ue=this.tokenizer.lheading(Q)){Q=Q.substring(ue.raw.length),ee.push(ue);continue}if(se&&(ue=this.tokenizer.paragraph(Q))){Q=Q.substring(ue.raw.length),ee.push(ue);continue}if(ue=this.tokenizer.text(Q,ee)){Q=Q.substring(ue.raw.length),ue.type?ee.push(ue):(ke=ee[ee.length-1],ke.raw+=`
`+ue.raw,ke.text+=`
`+ue.text);continue}if(Q){var We="Infinite loop on byte: "+Q.charCodeAt(0);if(this.options.silent){console.error(We);break}else throw new Error(We)}}return ee},te.inline=function(Q){var ee,se,ue,me,ye,ke,We=Q.length;for(ee=0;ee<We;ee++){ke=Q[ee];switch(ke.type){case"paragraph":case"text":case"heading":{ke.tokens=[],this.inlineTokens(ke.text,ke.tokens);break}case"table":{for(ke.tokens={header:[],cells:[]},me=ke.header.length,se=0;se<me;se++)ke.tokens.header[se]=[],this.inlineTokens(ke.header[se],ke.tokens.header[se]);for(me=ke.cells.length,se=0;se<me;se++)for(ye=ke.cells[se],ke.tokens.cells[se]=[],ue=0;ue<ye.length;ue++)ke.tokens.cells[se][ue]=[],this.inlineTokens(ye[ue],ke.tokens.cells[se][ue]);break}case"blockquote":{this.inline(ke.tokens);break}case"list":{for(me=ke.items.length,se=0;se<me;se++)this.inline(ke.items[se].tokens);break}}}return Q},te.inlineTokens=function(Q,ee,se,ue,me){ee===void 0&&(ee=[]),se===void 0&&(se=!1),ue===void 0&&(ue=!1),me===void 0&&(me="");var ye,ke=Q,We;if(this.tokens.links){var Qe=Object.keys(this.tokens.links);if(Qe.length>0)for(;(We=this.tokenizer.rules.inline.reflinkSearch.exec(ke))!=null;)Qe.includes(We[0].slice(We[0].lastIndexOf("[")+1,-1))&&(ke=ke.slice(0,We.index)+"["+"a".repeat(We[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(We=this.tokenizer.rules.inline.blockSkip.exec(ke))!=null;)ke=ke.slice(0,We.index)+"["+"a".repeat(We[0].length-2)+"]"+ke.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;Q;){if(ye=this.tokenizer.escape(Q)){Q=Q.substring(ye.raw.length),ee.push(ye);continue}if(ye=this.tokenizer.tag(Q,se,ue)){Q=Q.substring(ye.raw.length),se=ye.inLink,ue=ye.inRawBlock,ee.push(ye);continue}if(ye=this.tokenizer.link(Q)){Q=Q.substring(ye.raw.length),ye.type==="link"&&(ye.tokens=this.inlineTokens(ye.text,[],!0,ue)),ee.push(ye);continue}if(ye=this.tokenizer.reflink(Q,this.tokens.links)){Q=Q.substring(ye.raw.length),ye.type==="link"&&(ye.tokens=this.inlineTokens(ye.text,[],!0,ue)),ee.push(ye);continue}if(ye=this.tokenizer.strong(Q,ke,me)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,ue),ee.push(ye);continue}if(ye=this.tokenizer.em(Q,ke,me)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,ue),ee.push(ye);continue}if(ye=this.tokenizer.codespan(Q)){Q=Q.substring(ye.raw.length),ee.push(ye);continue}if(ye=this.tokenizer.br(Q)){Q=Q.substring(ye.raw.length),ee.push(ye);continue}if(ye=this.tokenizer.del(Q)){Q=Q.substring(ye.raw.length),ye.tokens=this.inlineTokens(ye.text,[],se,ue),ee.push(ye);continue}if(ye=this.tokenizer.autolink(Q,he)){Q=Q.substring(ye.raw.length),ee.push(ye);continue}if(!se&&(ye=this.tokenizer.url(Q,he))){Q=Q.substring(ye.raw.length),ee.push(ye);continue}if(ye=this.tokenizer.inlineText(Q,ue,B)){Q=Q.substring(ye.raw.length),me=ye.raw.slice(-1),ee.push(ye);continue}if(Q){var tt="Infinite loop on byte: "+Q.charCodeAt(0);if(this.options.silent){console.error(tt);break}else throw new Error(tt)}}return ee},J(Y,null,[{key:"rules",get:function(){return{block:H,inline:q}}}]),Y}(),Le=j.defaults,Ie=ie.cleanUrl,_e=ie.escape,De=function(){function Y(oe){this.options=oe||Le}var te=Y.prototype;return te.code=function(Q,ee,se){var ue=(ee||"").match(/\S*/)[0];if(this.options.highlight){var me=this.options.highlight(Q,ue);me!=null&&me!==Q&&(se=!0,Q=me)}return ue?'<pre><code class="'+this.options.langPrefix+_e(ue,!0)+'">'+(se?Q:_e(Q,!0))+`</code></pre>
`:"<pre><code>"+(se?Q:_e(Q,!0))+`</code></pre>
`},te.blockquote=function(Q){return`<blockquote>
`+Q+`</blockquote>
`},te.html=function(Q){return Q},te.heading=function(Q,ee,se,ue){return this.options.headerIds?"<h"+ee+' id="'+this.options.headerPrefix+ue.slug(se)+'">'+Q+"</h"+ee+`>
`:"<h"+ee+">"+Q+"</h"+ee+`>
`},te.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},te.list=function(Q,ee,se){var ue=ee?"ol":"ul",me=ee&&se!==1?' start="'+se+'"':"";return"<"+ue+me+`>
`+Q+"</"+ue+`>
`},te.listitem=function(Q){return"<li>"+Q+`</li>
`},te.checkbox=function(Q){return"<input "+(Q?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},te.paragraph=function(Q){return"<p>"+Q+`</p>
`},te.table=function(Q,ee){return ee&&(ee="<tbody>"+ee+"</tbody>"),`<table>
<thead>
`+Q+`</thead>
`+ee+`</table>
`},te.tablerow=function(Q){return`<tr>
`+Q+`</tr>
`},te.tablecell=function(Q,ee){var se=ee.header?"th":"td",ue=ee.align?"<"+se+' align="'+ee.align+'">':"<"+se+">";return ue+Q+"</"+se+`>
`},te.strong=function(Q){return"<strong>"+Q+"</strong>"},te.em=function(Q){return"<em>"+Q+"</em>"},te.codespan=function(Q){return"<code>"+Q+"</code>"},te.br=function(){return this.options.xhtml?"<br/>":"<br>"},te.del=function(Q){return"<del>"+Q+"</del>"},te.link=function(Q,ee,se){if(Q=Ie(this.options.sanitize,this.options.baseUrl,Q),Q===null)return se;var ue='<a href="'+_e(Q)+'"';return ee&&(ue+=' title="'+ee+'"'),ue+=">"+se+"</a>",ue},te.image=function(Q,ee,se){if(Q=Ie(this.options.sanitize,this.options.baseUrl,Q),Q===null)return se;var ue='<img src="'+Q+'" alt="'+se+'"';return ee&&(ue+=' title="'+ee+'"'),ue+=this.options.xhtml?"/>":">",ue},te.text=function(Q){return Q},Y}(),Pe=function(){function Y(){}var te=Y.prototype;return te.strong=function(Q){return Q},te.em=function(Q){return Q},te.codespan=function(Q){return Q},te.del=function(Q){return Q},te.html=function(Q){return Q},te.text=function(Q){return Q},te.link=function(Q,ee,se){return""+se},te.image=function(Q,ee,se){return""+se},te.br=function(){return""},Y}(),je=function(){function Y(){this.seen={}}var te=Y.prototype;return te.slug=function(Q){var ee=Q.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(ee)){var se=ee;do this.seen[se]++,ee=se+"-"+this.seen[se];while(this.seen.hasOwnProperty(ee))}return this.seen[ee]=0,ee},Y}(),ze=j.defaults,Ke=ie.unescape,Ve=function(){function Y(oe){this.options=oe||ze,this.options.renderer=this.options.renderer||new De,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new Pe,this.slugger=new je}Y.parse=function(Q,ee){var se=new Y(ee);return se.parse(Q)};var te=Y.prototype;return te.parse=function(Q,ee){ee===void 0&&(ee=!0);var se="",ue,me,ye,ke,We,Qe,tt,vt,ot,it,wt,xt,It,Ot,Et,mr,Tr,Yt,gr=Q.length;for(ue=0;ue<gr;ue++){it=Q[ue];switch(it.type){case"space":continue;case"hr":{se+=this.renderer.hr();continue}case"heading":{se+=this.renderer.heading(this.parseInline(it.tokens),it.depth,Ke(this.parseInline(it.tokens,this.textRenderer)),this.slugger);continue}case"code":{se+=this.renderer.code(it.text,it.lang,it.escaped);continue}case"table":{for(vt="",tt="",ke=it.header.length,me=0;me<ke;me++)tt+=this.renderer.tablecell(this.parseInline(it.tokens.header[me]),{header:!0,align:it.align[me]});for(vt+=this.renderer.tablerow(tt),ot="",ke=it.cells.length,me=0;me<ke;me++){for(Qe=it.tokens.cells[me],tt="",We=Qe.length,ye=0;ye<We;ye++)tt+=this.renderer.tablecell(this.parseInline(Qe[ye]),{header:!1,align:it.align[ye]});ot+=this.renderer.tablerow(tt)}se+=this.renderer.table(vt,ot);continue}case"blockquote":{ot=this.parse(it.tokens),se+=this.renderer.blockquote(ot);continue}case"list":{for(wt=it.ordered,xt=it.start,It=it.loose,ke=it.items.length,ot="",me=0;me<ke;me++)Et=it.items[me],mr=Et.checked,Tr=Et.task,Ot="",Et.task&&(Yt=this.renderer.checkbox(mr),It?Et.tokens.length>0&&Et.tokens[0].type==="text"?(Et.tokens[0].text=Yt+" "+Et.tokens[0].text,Et.tokens[0].tokens&&Et.tokens[0].tokens.length>0&&Et.tokens[0].tokens[0].type==="text"&&(Et.tokens[0].tokens[0].text=Yt+" "+Et.tokens[0].tokens[0].text)):Et.tokens.unshift({type:"text",text:Yt}):Ot+=Yt),Ot+=this.parse(Et.tokens,It),ot+=this.renderer.listitem(Ot,Tr,mr);se+=this.renderer.list(ot,wt,xt);continue}case"html":{se+=this.renderer.html(it.text);continue}case"paragraph":{se+=this.renderer.paragraph(this.parseInline(it.tokens));continue}case"text":{for(ot=it.tokens?this.parseInline(it.tokens):it.text;ue+1<gr&&Q[ue+1].type==="text";)it=Q[++ue],ot+=`
`+(it.tokens?this.parseInline(it.tokens):it.text);se+=ee?this.renderer.paragraph(ot):ot;continue}default:{var cr='Token with "'+it.type+'" type was not found.';if(this.options.silent){console.error(cr);return}else throw new Error(cr)}}}return se},te.parseInline=function(Q,ee){ee=ee||this.renderer;var se="",ue,me,ye=Q.length;for(ue=0;ue<ye;ue++){me=Q[ue];switch(me.type){case"escape":{se+=ee.text(me.text);break}case"html":{se+=ee.html(me.text);break}case"link":{se+=ee.link(me.href,me.title,this.parseInline(me.tokens,ee));break}case"image":{se+=ee.image(me.href,me.title,me.text);break}case"strong":{se+=ee.strong(this.parseInline(me.tokens,ee));break}case"em":{se+=ee.em(this.parseInline(me.tokens,ee));break}case"codespan":{se+=ee.codespan(me.text);break}case"br":{se+=ee.br();break}case"del":{se+=ee.del(this.parseInline(me.tokens,ee));break}case"text":{se+=ee.text(me.text);break}default:{var ke='Token with "'+me.type+'" type was not found.';if(this.options.silent){console.error(ke);return}else throw new Error(ke)}}}return se},Y}(),at=ie.merge,Xe=ie.checkSanitizeDeprecation,$e=ie.escape,Ae=j.getDefaults,rt=j.changeDefaults,Je=j.defaults;function ae(Y,te,oe){if(typeof Y=="undefined"||Y===null)throw new Error("marked(): input parameter is undefined or null");if(typeof Y!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(Y)+", string expected");if(typeof te=="function"&&(oe=te,te=null),te=at({},ae.defaults,te||{}),Xe(te),oe){var Q=te.highlight,ee;try{ee=Ee.lex(Y,te)}catch(ye){return oe(ye)}var se=function(ke){var We;if(!ke)try{We=Ve.parse(ee,te)}catch(Qe){ke=Qe}return te.highlight=Q,ke?oe(ke):oe(null,We)};if(!Q||Q.length<3)return se();if(delete te.highlight,!ee.length)return se();var ue=0;ae.walkTokens(ee,function(ye){ye.type==="code"&&(ue++,setTimeout(function(){Q(ye.text,ye.lang,function(ke,We){if(ke)return se(ke);We!=null&&We!==ye.text&&(ye.text=We,ye.escaped=!0),ue--,ue===0&&se()})},0))}),ue===0&&se();return}try{var me=Ee.lex(Y,te);return te.walkTokens&&ae.walkTokens(me,te.walkTokens),Ve.parse(me,te)}catch(ye){if(ye.message+=`
Please report this to https://github.com/markedjs/marked.`,te.silent)return"<p>An error occurred:</p><pre>"+$e(ye.message+"",!0)+"</pre>";throw ye}}ae.options=ae.setOptions=function(Y){return at(ae.defaults,Y),rt(ae.defaults),ae},ae.getDefaults=Ae,ae.defaults=Je,ae.use=function(Y){var te=at({},Y);if(Y.renderer&&function(){var Q=ae.defaults.renderer||new De,ee=function(me){var ye=Q[me];Q[me]=function(){for(var ke=arguments.length,We=new Array(ke),Qe=0;Qe<ke;Qe++)We[Qe]=arguments[Qe];var tt=Y.renderer[me].apply(Q,We);return tt===!1&&(tt=ye.apply(Q,We)),tt}};for(var se in Y.renderer)ee(se);te.renderer=Q}(),Y.tokenizer&&function(){var Q=ae.defaults.tokenizer||new Te,ee=function(me){var ye=Q[me];Q[me]=function(){for(var ke=arguments.length,We=new Array(ke),Qe=0;Qe<ke;Qe++)We[Qe]=arguments[Qe];var tt=Y.tokenizer[me].apply(Q,We);return tt===!1&&(tt=ye.apply(Q,We)),tt}};for(var se in Y.tokenizer)ee(se);te.tokenizer=Q}(),Y.walkTokens){var oe=ae.defaults.walkTokens;te.walkTokens=function(Q){Y.walkTokens(Q),oe&&oe(Q)}}ae.setOptions(te)},ae.walkTokens=function(Y,te){for(var oe=I(Y),Q;!(Q=oe()).done;){var ee=Q.value;te(ee);switch(ee.type){case"table":{for(var se=I(ee.tokens.header),ue;!(ue=se()).done;){var me=ue.value;ae.walkTokens(me,te)}for(var ye=I(ee.tokens.cells),ke;!(ke=ye()).done;)for(var We=ke.value,Qe=I(We),tt;!(tt=Qe()).done;){var vt=tt.value;ae.walkTokens(vt,te)}break}case"list":{ae.walkTokens(ee.items,te);break}default:ee.tokens&&ae.walkTokens(ee.tokens,te)}}},ae.Parser=Ve,ae.parser=Ve.parse,ae.Renderer=De,ae.TextRenderer=Pe,ae.Lexer=Ee,ae.lexer=Ee.lex,ae.Tokenizer=Te,ae.Slugger=je,ae.parse=ae;var V=ae;return V})},ELLl:function(dt,et,le){(function(fe){fe(le("VrN/"))})(function(fe){var J={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},_=fe.Pos;fe.defineOption("autoCloseBrackets",!1,function(C,S,u){u&&u!=fe.Init&&(C.removeKeyMap(I),C.state.closeBrackets=null),S&&(D($(S,"pairs")),C.state.closeBrackets=S,C.addKeyMap(I))});function $(C,S){return S=="pairs"&&typeof C=="string"?C:typeof C=="object"&&C[S]!=null?C[S]:J[S]}var I={Backspace:P,Enter:O};function D(C){for(var S=0;S<C.length;S++){var u=C.charAt(S),o="'"+u+"'";I[o]||(I[o]=j(u))}}D(J.pairs+"`");function j(C){return function(S){return T(S,C)}}function U(C){var S=C.state.closeBrackets;if(!S||S.override)return S;var u=C.getModeAt(C.getCursor());return u.closeBrackets||S}function P(C){var S=U(C);if(!S||C.getOption("disableInput"))return fe.Pass;for(var u=$(S,"pairs"),o=C.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return fe.Pass;var l=R(C,o[s].head);if(!l||u.indexOf(l)%2!=0)return fe.Pass}for(var s=o.length-1;s>=0;s--){var E=o[s].head;C.replaceRange("",_(E.line,E.ch-1),_(E.line,E.ch+1),"+delete")}}function O(C){var S=U(C),u=S&&$(S,"explode");if(!u||C.getOption("disableInput"))return fe.Pass;for(var o=C.listSelections(),s=0;s<o.length;s++){if(!o[s].empty())return fe.Pass;var l=R(C,o[s].head);if(!l||u.indexOf(l)%2!=0)return fe.Pass}C.operation(function(){var E=C.lineSeparator()||`
`;C.replaceSelection(E+E,null),C.execCommand("goCharLeft"),o=C.listSelections();for(var m=0;m<o.length;m++){var f=o[m].head.line;C.indentLine(f,null,!0),C.indentLine(f+1,null,!0)}})}function v(C){var S=fe.cmpPos(C.anchor,C.head)>0;return{anchor:new _(C.anchor.line,C.anchor.ch+(S?-1:1)),head:new _(C.head.line,C.head.ch+(S?1:-1))}}function T(C,S){var u=U(C);if(!u||C.getOption("disableInput"))return fe.Pass;var o=$(u,"pairs"),s=o.indexOf(S);if(s==-1)return fe.Pass;for(var l=$(u,"closeBefore"),E=$(u,"triples"),m=o.charAt(s+1)==S,f=C.listSelections(),L=s%2==0,g,d=0;d<f.length;d++){var c=f[d],h=c.head,a,x=C.getRange(h,_(h.line,h.ch+1));if(L&&!c.empty())a="surround";else if((m||!L)&&x==S)m&&A(C,h)?a="both":E.indexOf(S)>=0&&C.getRange(h,_(h.line,h.ch+3))==S+S+S?a="skipThree":a="skip";else if(m&&h.ch>1&&E.indexOf(S)>=0&&C.getRange(_(h.line,h.ch-2),h)==S+S){if(h.ch>2&&/\bstring/.test(C.getTokenTypeAt(_(h.line,h.ch-2))))return fe.Pass;a="addFour"}else if(m){var p=h.ch==0?" ":C.getRange(_(h.line,h.ch-1),h);if(!fe.isWordChar(x)&&p!=S&&!fe.isWordChar(p))a="both";else return fe.Pass}else if(L&&(x.length===0||/\s/.test(x)||l.indexOf(x)>-1))a="both";else return fe.Pass;if(!g)g=a;else if(g!=a)return fe.Pass}var b=s%2?o.charAt(s-1):S,M=s%2?S:o.charAt(s+1);C.operation(function(){if(g=="skip")C.execCommand("goCharRight");else if(g=="skipThree")for(var G=0;G<3;G++)C.execCommand("goCharRight");else if(g=="surround"){for(var Z=C.getSelections(),G=0;G<Z.length;G++)Z[G]=b+Z[G]+M;C.replaceSelections(Z,"around"),Z=C.listSelections().slice();for(var G=0;G<Z.length;G++)Z[G]=v(Z[G]);C.setSelections(Z)}else g=="both"?(C.replaceSelection(b+M,null),C.triggerElectric(b+M),C.execCommand("goCharLeft")):g=="addFour"&&(C.replaceSelection(b+b+b+b,"before"),C.execCommand("goCharRight"))})}function R(C,S){var u=C.getRange(_(S.line,S.ch-1),_(S.line,S.ch+1));return u.length==2?u:null}function A(C,S){var u=C.getTokenAt(_(S.line,S.ch+1));return/\bstring/.test(u.type)&&u.start==S.ch&&(S.ch==0||!/\bstring/.test(C.getTokenTypeAt(S)))}})},F8wB:function(dt,et,le){dt.exports={loading:"loading___1SIOG"}},HmJG:function(dt,et,le){},LdHM:function(dt,et,le){"use strict";le.d(et,"b",function(){return l}),le.d(et,"a",function(){return m});var fe=le("1OyB"),J=le("vuIU"),_=le("Ji7U"),$=le("LK+K"),I=le("q1tI"),D=le("rePB"),j=le("Ff2n"),U=le("ODXe"),P=le("4IlW"),O=le("bX4T"),v=le("YrtM"),T=le("TSYQ"),R=le.n(T),A=le("+nKL"),C=le("8OUc"),S=function(ne,ce){var ge=ne.prefixCls,xe=ne.id,Me=ne.flattenOptions,Te=ne.childrenAsData,Oe=ne.values,Ce=ne.searchValue,we=ne.multiple,ve=ne.defaultActiveFirstOption,W=ne.height,w=ne.itemHeight,k=ne.notFoundContent,H=ne.open,q=ne.menuItemSelectedIcon,B=ne.virtual,he=ne.onSelect,Ee=ne.onToggleOpen,Le=ne.onActiveValue,Ie=ne.onScroll,_e=ne.onMouseEnter,De="".concat(ge,"-item"),Pe=Object(v.a)(function(){return Me},[H,Me],function(V,Y){return Y[0]&&V[1]!==Y[1]}),je=I.useRef(null),ze=function(Y){Y.preventDefault()},Ke=function(Y){je.current&&je.current.scrollTo({index:Y})},Ve=function(Y){for(var te=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,oe=Pe.length,Q=0;Q<oe;Q+=1){var ee=(Y+Q*te+oe)%oe,se=Pe[ee],ue=se.group,me=se.data;if(!ue&&!me.disabled)return ee}return-1},at=I.useState(function(){return Ve(0)}),Xe=Object(U.a)(at,2),$e=Xe[0],Ae=Xe[1],rt=function(Y){Ae(Y);var te=Pe[Y];if(!te){Le(null,-1);return}Le(te.data.value,Y)};I.useEffect(function(){rt(ve!==!1?Ve(0):-1)},[Pe.length,Ce]),I.useEffect(function(){var V=setTimeout(function(){if(!we&&H&&Oe.size===1){var Y=Array.from(Oe)[0],te=Pe.findIndex(function(oe){var Q=oe.data;return Q.value===Y});rt(te),Ke(te)}});return function(){return clearTimeout(V)}},[H]);var Je=function(Y){Y!==void 0&&he(Y,{selected:!Oe.has(Y)}),we||Ee(!1)};if(I.useImperativeHandle(ce,function(){return{onKeyDown:function(Y){var te=Y.which;switch(te){case P.a.UP:case P.a.DOWN:{var oe=0;if(te===P.a.UP?oe=-1:te===P.a.DOWN&&(oe=1),oe!==0){var Q=Ve($e+oe,oe);Ke(Q),rt(Q)}break}case P.a.ENTER:{var ee=Pe[$e];ee&&!ee.data.disabled?Je(ee.data.value):Je(void 0),H&&Y.preventDefault();break}case P.a.ESC:Ee(!1)}},onKeyUp:function(){},scrollTo:function(Y){Ke(Y)}}}),Pe.length===0)return I.createElement("div",{role:"listbox",id:"".concat(xe,"_list"),className:"".concat(De,"-empty"),onMouseDown:ze},k);function ae(V){var Y=Pe[V];if(!Y)return null;var te=Y.data||{},oe=te.value,Q=te.label,ee=te.children,se=Object(O.a)(te,!0),ue=Te?ee:Q;return Y?I.createElement("div",Object.assign({"aria-label":typeof ue=="string"?ue:null},se,{key:V,role:"option",id:"".concat(xe,"_list_").concat(V),"aria-selected":Oe.has(oe)}),oe):null}return I.createElement(I.Fragment,null,I.createElement("div",{role:"listbox",id:"".concat(xe,"_list"),style:{height:0,width:0,overflow:"hidden"}},ae($e-1),ae($e),ae($e+1)),I.createElement(A.a,{itemKey:"key",ref:je,data:Pe,height:W,itemHeight:w,fullHeight:!1,onMouseDown:ze,onScroll:Ie,virtual:B,onMouseEnter:_e},function(V,Y){var te,oe=V.group,Q=V.groupOption,ee=V.data,se=ee.label,ue=ee.key;if(oe)return I.createElement("div",{className:R()(De,"".concat(De,"-group"))},se!==void 0?se:ue);var me=ee.disabled,ye=ee.value,ke=ee.title,We=ee.children,Qe=ee.style,tt=ee.className,vt=Object(j.a)(ee,["disabled","value","title","children","style","className"]),ot=Oe.has(ye),it="".concat(De,"-option"),wt=R()(De,it,tt,(te={},Object(D.a)(te,"".concat(it,"-grouped"),Q),Object(D.a)(te,"".concat(it,"-active"),$e===Y&&!me),Object(D.a)(te,"".concat(it,"-disabled"),me),Object(D.a)(te,"".concat(it,"-selected"),ot),te)),xt=Te?We:se,It=!q||typeof q=="function"||ot;return I.createElement("div",Object.assign({},vt,{"aria-selected":ot,className:wt,title:ke,onMouseMove:function(){if($e===Y||me)return;rt(Y)},onClick:function(){me||Je(ye)},style:Qe}),I.createElement("div",{className:"".concat(it,"-content")},xt||ye),I.isValidElement(q)||ot,It&&I.createElement(C.a,{className:"".concat(De,"-option-state"),customizeIcon:q,customizeIconProps:{isSelected:ot}},ot?"\u2713":null))}))},u=I.forwardRef(S);u.displayName="OptionList";var o=u,s=function(){return null};s.isSelectOption=!0;var l=s,E=function(){return null};E.isSelectOptGroup=!0;var m=E,f=le("VTBJ"),L=le("Zm9Q");function g(F){var ne=F.key,ce=F.props,ge=ce.children,xe=ce.value,Me=Object(j.a)(ce,["children","value"]);return Object(f.a)({key:ne,value:xe!==void 0?xe:ne,children:ge},Me)}function d(F){var ne=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(L.a)(F).map(function(ce,ge){if(!I.isValidElement(ce)||!ce.type)return null;var xe=ce.type.isSelectOptGroup,Me=ce.key,Te=ce.props,Oe=Te.children,Ce=Object(j.a)(Te,["children"]);return ne||!xe?g(ce):Object(f.a)(Object(f.a)({key:"__RC_SELECT_GRP__".concat(Me===null?ge:Me,"__"),label:Me},Ce),{},{options:d(Oe)})}).filter(function(ce){return ce})}var c=le("2Qr1"),h=le("qNPg"),a=le("U8pU"),x=le("Kwbf"),p=le("WKfj");function b(F){var ne=F.mode,ce=F.options,ge=F.children,xe=F.backfill,Me=F.allowClear,Te=F.placeholder,Oe=F.getInputElement,Ce=F.showSearch,we=F.onSearch,ve=F.defaultOpen,W=F.autoFocus,w=F.labelInValue,k=F.value,H=F.inputValue,q=F.optionLabelProp,B=ne==="multiple"||ne==="tags",he=Ce!==void 0?Ce:B||ne==="combobox",Ee=ce||d(ge);if(Object(x.a)(ne!=="tags"||Ee.every(function(De){return!De.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),ne==="tags"||ne==="combobox"){var Le=Ee.some(function(De){return De.options?De.options.some(function(Pe){return typeof("value"in Pe?Pe.value:Pe.key)=="number"}):typeof("value"in De?De.value:De.key)=="number"});Object(x.a)(!Le,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(x.a)(ne!=="combobox"||!q,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(x.a)(ne==="combobox"||!xe,"`backfill` only works with `combobox` mode."),Object(x.a)(ne==="combobox"||!Oe,"`getInputElement` only work with `combobox` mode."),Object(x.b)(ne!=="combobox"||!Oe||!Me||!Te,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),we&&!he&&ne!=="combobox"&&ne!=="tags"&&Object(x.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(x.b)(!ve||W,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),k!=null){var Ie=Object(p.d)(k);Object(x.a)(!w||Ie.every(function(De){return Object(a.a)(De)==="object"&&("key"in De||"value"in De)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(x.a)(!B||Array.isArray(k),"`value` should be array when `mode` is `multiple` or `tags`")}if(ge){var _e=null;Object(L.a)(ge).some(function(De){if(!I.isValidElement(De)||!De.type)return!1;var Pe=De.type;if(Pe.isSelectOption)return!1;if(Pe.isSelectOptGroup){var je=Object(L.a)(De.props.children).every(function(ze){return!I.isValidElement(ze)||!De.type||ze.type.isSelectOption?!0:(_e=ze.type,!1)});return!je}return _e=Pe,!0}),_e&&Object(x.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(_e.displayName||_e.name||_e,"`.")),Object(x.a)(H===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var M=b,G=Object(h.a)({prefixCls:"rc-select",components:{optionList:o},convertChildrenToData:d,flattenOptions:c.d,getLabeledValue:c.e,filterOptions:c.b,isValueDisabled:c.g,findValueOption:c.c,warningProps:M,fillOptionsWithMissingValue:c.a}),Z=function(F){Object(_.a)(ce,F);var ne=Object($.a)(ce);function ce(){var ge;return Object(fe.a)(this,ce),ge=ne.apply(this,arguments),ge.selectRef=I.createRef(),ge.focus=function(){ge.selectRef.current.focus()},ge.blur=function(){ge.selectRef.current.blur()},ge}return Object(J.a)(ce,[{key:"render",value:function(){return I.createElement(G,Object.assign({ref:this.selectRef},this.props))}}]),ce}(I.Component);Z.Option=l,Z.OptGroup=m;var ie=Z,z=et.c=ie},M8RZ:function(dt,et,le){"use strict";le.d(et,"a",function(){return P});var fe=le("fWQN"),J=le("mtLc"),_=le("yKVA"),$=le("879j"),I=le("q1tI"),D=le.n(I),j=le("i8i4"),U=le.n(j),P=function(O){Object(_.a)(T,O);var v=Object($.a)(T);function T(R){var A;Object(fe.a)(this,T),A=v.call(this,R);var C=window.document;return A.node=C.createElement("div"),C.body.appendChild(A.node),A}return Object(J.a)(T,[{key:"render",value:function(){var A=this.props.children;return Object(j.createPortal)(A,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),T}(D.a.Component)},Ot1p:function(dt,et,le){"use strict";var fe=le("2qtc"),J=le("kLXV"),_=le("rAM+"),$=le("miYZ"),I=le("tsqr"),D=le("9og8"),j=le("tJVT"),U=le("jrin"),P=le("WmNS"),O=le.n(P),v=le("q1tI"),T=le.n(v),R=le("VrN/"),A=le.n(R),C=le("bdgK"),S=le("p77/"),u=le("Bd2K"),o=le("ELLl"),s=le("19Vz"),l=le("lZu9"),E=le("+NIl"),m=le("kSUc"),f=le("9Bee"),L=function(me){var ye=me.value,ke=ye===void 0?"":ye,We=me.className,Qe=me.showTextOnly,tt=me.showLines,vt=me.style,ot=vt===void 0?{}:vt,it=Object(v.useMemo)(function(){return""},[ke]);return T.a.createElement(T.a.Fragment,null,T.a.createElement("div",{dangerouslySetInnerHTML:{__html:it}}))},g=le("0Owb"),d=le("dejd"),c=le("C+DQ"),h=le("1vsH"),a=le("m3rI"),x=[{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 p(me){var ye=me.onActionCallback,ke=me.title,We=me.icon,Qe=me.actionName,tt=me.className,vt=tt===void 0?"":tt,ot=me.children;function it(){ye(Qe)}return T.a.createElement("a",{title:ke,className:vt,onClick:it},T.a.createElement("i",{className:"md-iconfont ".concat(We)}),ot)}var b=function(me){var ye=me.watch,ke=me.showNullButton,We=me.onActionCallback,Qe=me.fullScreen,tt=me.insertTemp,vt=me.hidetoolBar,ot=me.uuid,it=me.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(h.F)("_educoder_session_login"),"&_educoder_session=").concat(Object(h.F)("_educoder_session"),"&key=").concat(ot,"&api=").concat(encodeURIComponent(a.a.PROXY_SERVER)));var wt=[].concat(x,[{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 T.a.createElement("ul",{className:"markdown-toolbar-container"},!vt&&wt.map(function(xt,It){return T.a.createElement("li",{key:It},xt.actionName?T.a.createElement(p,Object(g.a)({},xt,{onActionCallback:We})):T.a.createElement("span",{className:"v-line"}))}),ke?T.a.createElement("li",null,T.a.createElement(p,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:We},T.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,tt&&T.a.createElement("li",null,T.a.createElement(p,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(tt),onActionCallback:We},T.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),T.a.createElement("li",{className:"btn-full-screen"},T.a.createElement(p,{icon:"".concat(Qe?"icon-shrink":"icon-enlarge"),title:Qe?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:We})))},M=le("M8RZ"),G=le("+L6B"),Z=le("2/Rp"),ie=le("y8nQ"),z=le("Vl3Y"),F=le("5NDa"),ne=le("5rEg"),ce={labelCol:{span:4},wrapperCol:{span:20}},ge=function(me){var ye=me.callback,ke=me.onCancel;function We(Qe){ye(Qe)}return T.a.createElement(z.a,Object(g.a)({},ce,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:We}),T.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},T.a.createElement(ne.a,null)),T.a.createElement(z.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},T.a.createElement(ne.a,null)),T.a.createElement("div",{className:"flex-container flex-end"},T.a.createElement(Z.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement(Z.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))},xe=le("7ahc"),Me=le("HmJG"),Te=le("BjJ7"),Oe=z.a.useForm,Ce={width:280,marginRight:10},we={labelCol:{span:5},wrapperCol:{span:19}},ve=function(me){var ye=me.callback,ke=me.onCancel,We=Oe(),Qe=Object(j.a)(We,1),tt=Qe[0];function vt(wt){ye(wt)}function ot(wt,xt){if(wt.status===-1){I.b.error(wt.message);return}tt.setFieldsValue({src:"/api/attachments/".concat(wt.id),type:xt.type})}function it(wt){var xt=wt.target.files[0];w(xt,ot)}return T.a.createElement(z.a,Object(g.a)({form:tt},we,{className:"upload-image-panel",onFinish:vt}),T.a.createElement(z.a.Item,{label:"\u56FE\u7247\u5730\u5740",required:!0},T.a.createElement("div",{className:"flex-container"},T.a.createElement(z.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740"}]},T.a.createElement(ne.a,{style:Ce})),T.a.createElement(W,{onFileChange:it}))),T.a.createElement(z.a.Item,{label:"\u56FE\u7247\u63CF\u8FF0",name:"alt"},T.a.createElement(ne.a,{style:{width:264}})),T.a.createElement(z.a.Item,{style:{textAlign:"right"}},T.a.createElement(Z.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement(Z.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))};function W(me){var ye=me.onFileChange;return T.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",T.a.createElement("input",{type:"file",onChange:ye}))}function w(me,ye){if(!me)throw new String("\u6CA1\u6709\u6587\u4EF6");var ke=new FormData;ke.append("editormd-image-file",me),ke.append("file_param_name","editormd-image-file"),ke.append("byxhr","true");var We=new window.XMLHttpRequest;We.withCredentials=!0,We.addEventListener("load",function(Qe){ye(JSON.parse(Qe.target.responseText),me)},!1),We.addEventListener("error",function(Qe){console.error(Qe)},!1),We.open("POST","".concat(Te.a,"/api/attachments.json")),We.send(ke)}var k=le("giR+"),H=le("fyUT"),q=le("7Kak"),B=le("9yH6"),he=B.a.Group,Ee={margin:"0 8px"},Le=function(me){var ye=me.callback,ke=me.onCancel;function We(Qe){ye(Qe)}return T.a.createElement(z.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:We},T.a.createElement("div",{className:"flex-container",style:{alignItems:"baseline"}},T.a.createElement("span",{style:Ee},"\u5355\u5143\u683C\u6570\uFF1A"),T.a.createElement("span",{style:Ee},"\u884C\u6570"),T.a.createElement(z.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},T.a.createElement(H.a,null)),T.a.createElement("span",{style:Ee},"\u5217\u6570"),T.a.createElement(z.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},T.a.createElement(H.a,null))),T.a.createElement("div",{className:"flex-container",style:{marginTop:12,alignItems:"baseline"}},T.a.createElement("span",{style:Ee},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),T.a.createElement(z.a.Item,{name:"align"},T.a.createElement(he,null,T.a.createElement(B.a,{value:"default"},T.a.createElement("i",{className:"fa fa-align-justify"})),T.a.createElement(B.a,{value:"left"},T.a.createElement("i",{className:"fa fa-align-left"})),T.a.createElement(B.a,{value:"center"},T.a.createElement("i",{className:"fa fa-align-center"})),T.a.createElement(B.a,{value:"right"},T.a.createElement("i",{className:"fa fa-align-right"}))))),T.a.createElement("div",{className:"flex-container flex-end"},T.a.createElement(Z.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),T.a.createElement(Z.a,{type:"ghost",onClick:ke},"\u53D6\u6D88")))},Ie=le("ErOA"),_e=le("7Cbv"),De="link",Pe="upload-image",je="code-block",ze="add-table",Ke="------------",Ve={default:Ke,left:":".concat(Ke),center:":".concat(Ke,":"),right:"".concat(Ke,":")},at=le("9VGf"),Xe,$e;function Ae(){}var rt=0,Je=1e4,ae="\u2581",V=`
**\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 Y(me){return/^\d+$/.test(me)?"".concat(me,"px"):me}var te=navigator.platform.toUpperCase().indexOf("MAC")>=0,oe=te?"Cmd":"Ctrl",Q=["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"],ee=(Xe={},Object(U.a)(Xe,oe+"-B","bold"),Object(U.a)(Xe,oe+"-I","italic"),Xe),se=($e={},Object(U.a)($e,De,"\u6DFB\u52A0\u94FE\u63A5"),Object(U.a)($e,je,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(U.a)($e,Pe,"\u6DFB\u52A0\u6587\u4EF6"),Object(U.a)($e,ze,"\u6DFB\u52A0\u8868\u683C"),$e),ue=et.a=function(me){var ye=me.defaultValue,ke=ye===void 0?"":ye,We=me.onChange,Qe=me.width,tt=Qe===void 0?"100%":Qe,vt=me.height,ot=vt===void 0?400:vt,it=me.miniToolbar,wt=it===void 0?!1:it,xt=me.isFocus,It=xt===void 0?!1:xt,Ot=me.watch,Et=me.insertTemp,mr=me.mode,Tr=mr===void 0?"markdown":mr,Yt=me.id,gr=Yt===void 0?"markdown-editor-id":Yt,cr=me.showResizeBar,zr=cr===void 0?!1:cr,$t=me.noStorage,Nr=$t===void 0?!1:$t,ti=me.showNullButton,Pt=ti===void 0?!1:ti,Ye=me.hidetoolBar,Tt=Ye===void 0?!1:Ye,Zt=me.fullScreen,mt=Zt===void 0?!1:Zt,pt=me.onBlur,At=me.onCMBeforeChange,vr=me.onFullScreen,Ut=me.className,Be=Ut===void 0?"":Ut,ht=me.disablePaste,ri=ht===void 0?!1:ht,bi=me.placeholder,xi=bi===void 0?"":bi,ii=me.values,Ei=ii===void 0?"":ii,ft=Object(v.useState)(null),Ln=Object(j.a)(ft,2),Fe=Ln[0],Si=Ln[1],Er=Object(v.useState)(ke),Ki=Object(j.a)(Er,2),ni=Ki[0],Cr=Ki[1],Vi=Object(v.useState)(Ot),Xi=Object(j.a)(Vi,2),wr=Xi[0],Yi=Xi[1],kn=Object(v.useState)(mt),$i=Object(j.a)(kn,2),Ar=$i[0],_n=$i[1],aa=Object(v.useState)(""),Zi=Object(j.a)(aa,2),rr=Zi[0],Kr=Zi[1],oa=Object(v.useState)(0),ai=Object(j.a)(oa,2),Lr=ai[0],Ji=ai[1],sa=Object(v.useState)(ot),Dn=Object(j.a)(sa,2),Rn=Dn[0],Ti=Dn[1],On=Object(v.useState)(!1),Pn=Object(j.a)(On,2),la=Pn[0],Ci=Pn[1],oi=Object(v.useRef)(Object(_e.a)()),si=Object(v.useRef)(!1),wi=Object(v.useRef)(),Br=Object(v.useRef)(),Fr=Object(v.useRef)(),Ur=Object(v.useRef)(),Ai=Object(v.useRef)(),Mn=function(){var nt=Object(D.a)(O.a.mark(function ct(){var lt,yt;return O.a.wrap(function(Dt){for(;;)switch(Dt.prev=Dt.next){case 0:return Dt.next=2,Object(Ie.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:oi.current}});case 2:yt=Dt.sent,yt!=null&&(lt=yt.attachments)!==null&&lt!==void 0&&lt.length&&(console.log("cm:",Fe,Br),yt.attachments.map(function(St){St.content_type.indexOf("image")>-1?Fe.replaceSelection("![,](/api/attachments/".concat(St.id,"?type=").concat(St.content_type,")")):St.content_type.indexOf("video")>-1?Fe.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):St.content_type.indexOf("pdf")>-1?Fe.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,"?type=").concat(St.content_type,'&disposition=inline" target="_blank">').concat(St.name,"</a>")):Fe.replaceSelection("[".concat(St.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(St.id,"?type=").concat(St.content_type,")"))}));case 4:case"end":return Dt.stop()}},ct)}));return function(){return nt.apply(this,arguments)}}();Object(v.useEffect)(function(){Cr(Ei),Fe==null||Fe.setValue(Ei)},[Ei]),Object(v.useEffect)(function(){vr==null||vr(Ar)},[Ar]),Object(v.useEffect)(function(){if(Br.current){var nt=A.a.fromTextArea(Br.current,{mode:Tr,lineNumbers:!wt,lineWrapping:!0,value:ke,autoCloseTags:!0,autoCloseBrackets:!0});It&&nt.focus();function ct(lt,yt){if(ri){yt.preventDefault();return}var Ct=yt.clipboardData;if(Ct){var Dt=Ct.types.toString(),St=Ct.items;if(Dt==="Files"||Ct.types.indexOf("Files")>-1){if(yt.preventDefault(),Tr=="stex")return;try{var Ht,ar=St[1];((Ht=St[0])===null||Ht===void 0?void 0:Ht.kind)==="file"&&(ar=St[0]);var bt=ar.getAsFile(),Wr=bt.name.split(".").pop();w(bt,function(Lt){if(Lt.id){var or,qt,Sr;(bt==null||((or=bt.type)===null||or===void 0)?void 0:or.indexOf("image"))>-1?nt.replaceSelection("![,](/api/attachments/".concat(Lt.id,"?type=").concat(Lt.content_type,")")):(bt==null||((qt=bt.type)===null||qt===void 0)?void 0:qt.indexOf("video"))>-1?nt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Lt.id,'"></video>')):(bt==null||((Sr=bt.type)===null||Sr===void 0)?void 0:Sr.indexOf("pdf"))>-1?nt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Lt.id,"?type=").concat(bt.type,'&disposition=inline" target="_blank">').concat(bt.name,"</a>")):Q.includes(Wr)?nt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Lt.id,'?type=office&disposition=inline" target="_blank">').concat(bt.name,"</a>")):nt.replaceSelection("[".concat(bt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Lt.id,"?type=").concat(Lt.content_type,")"))}else(Lt==null?void 0:Lt.status)===401&&(document.location.href="/user/login")})}catch(Lt){I.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(lt,yt){Fr.current.classList.remove("mouse-hover-md")}),nt.on("dragover",function(lt,yt){Fr.current.classList.add("mouse-hover-md")}),nt.on("drop",function(lt,yt){Fr.current.classList.add("mouse-hover-md");var Ct;if(Ct=yt.dataTransfer.files,Ct.length>0){yt.preventDefault(),yt.stopPropagation();for(var Dt=function(ar){var bt=Ct[ar],Wr=bt.name.split(".").pop();w(bt,function(Lt){if(Lt.id){var or,qt,Sr;(bt==null||((or=bt.type)===null||or===void 0)?void 0:or.indexOf("image"))>-1?nt.replaceSelection("![,](/api/attachments/".concat(Lt.id,"?type=").concat(Lt.content_type,")")):(bt==null||((qt=bt.type)===null||qt===void 0)?void 0:qt.indexOf("video"))>-1?nt.replaceSelection('<video width="100%" controls src="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Lt.id,'"></video>')):(bt==null||((Sr=bt.type)===null||Sr===void 0)?void 0:Sr.indexOf("pdf"))>-1?nt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Lt.id,"?type=").concat(bt.type,'&disposition=inline" target="_blank">').concat(bt.name,"</a>")):Q.includes(Wr)?nt.replaceSelection('<a href="'.concat(a.a.API_SERVER,"/api/attachments/").concat(Lt.id,'?type=office&disposition=inline" target="_blank">').concat(bt.name,"</a>")):nt.replaceSelection("[".concat(bt.name,"](").concat(a.a.API_SERVER,"/api/attachments/").concat(Lt.id,"?type=").concat(Lt.content_type,")"))}else(Lt==null?void 0:Lt.status)===401&&(document.location.href="/user/login")})},St=0;St<Ct.length;St++)Dt(St)}}),Si(nt),function(){nt.off("paste",ct)}}},[]);var yr=Object(v.useCallback)(function(){if(Fr.current)try{}catch(nt){console.log(nt,"---- to set md editor body height")}},[Rn,Fr,Ar]);Object(v.useEffect)(function(){function nt(){var lt=new C.default(function(yt){var Ct=Object(_.a)(yt),Dt;try{for(Ct.s();!(Dt=Ct.n()).done;){var St=Dt.value;(St.target.offsetHeight>0||St.target.offsetWidth>0)&&(yr(),Fe.setSize("100%","100%"),Fe.refresh())}}catch(Ht){Ct.e(Ht)}finally{Ct.f()}});return lt.observe(Br.current.parentElement),lt}if(Fe){var ct=nt();return function(){ct.unobserve(Br.current.parentElement)}}},[Fe,yr]),Object(v.useEffect)(function(){if(Fe){for(var nt=[],ct=function(){var St=yt[lt];Ct=Object(j.a)(St,2);var Ht=Ct[0],ar=Ct[1],bt=Object(U.a)({},Ht,function(){In(ar)});nt.push(bt),Fe.addKeyMap(bt)},lt=0,yt=Object.entries(ee);lt<yt.length;lt++){var Ct;ct()}return wi.current=setInterval(function(){si.current&&Mn()},4e3),function(){clearInterval(wi.current);var Dt=Object(_.a)(nt),St;try{for(Dt.s();!(St=Dt.n()).done;){var Ht=St.value;Fe.removeKeyMap(Ht)}}catch(ar){Dt.e(ar)}finally{Dt.f()}}}},[Fe]),Object(v.useEffect)(function(){mt!==Ar&&_n(mt)},[mt]),Object(at.a)(function(){if(!Nr&&Lr>0){var nt=new Date().getTime(),ct=window.sessionStorage.getItem(gr);nt>=Lr+Je&&(!ct||ct!==ni)&&(window.sessionStorage.setItem(gr,ni),Ci(!0))}},Je),Object(v.useEffect)(function(){Yi(Ot)},[Fe,Ot]),Object(v.useEffect)(function(){Fe&&(It&&Fe.focus())},[Fe,It]),Object(v.useEffect)(function(){if(wr&&Fe){var nt=Fe.getScrollerElement();function ct(lt){var yt=lt.target;if(Ai.current){var Ct=yt.scrollTop/yt.scrollHeight;Ai.current.scrollTop=Ai.current.scrollHeight*Ct}}return nt.addEventListener("scroll",ct),function(){nt.removeEventListener("scroll",ct)}}},[Fe,wr]),Object(v.useEffect)(function(){if(Fe&&At){function nt(ct,lt){At(ct,lt)}return Fe.on("beforeChange",nt),function(){Fe.off("beforeChange",nt)}}},[Fe,At]),Object(v.useEffect)(function(){if(Fe&&pt){function nt(){pt(Fe.getValue())}return Fe.on("blur",nt),function(){Fe.off("blur",nt)}}},[Fe,pt]),Object(v.useEffect)(function(){if(Fe){function nt(ct){var lt=ct.getValue();Cr(lt),Ji(new Date().getTime()),ct.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),We&&We(lt)}return Fe.on("change",nt),function(){Fe.off("change",nt)}}},[Fe,We]),Object(v.useEffect)(function(){Fe&&(ke==null?(Fe.setValue(""),Cr("")):ke!==Fe.getValue()&&(Fe.setValue(ke),Cr(ke),Fe.setCursor(Fe.lineCount(),0)))},[Fe,ke]);var In=Object(v.useCallback)(function(nt){var ct=Fe.getCursor(),lt=Fe.getSelection(),yt=lt.split(`
`);switch(nt){case"bold":return Fe.replaceSelection("**"+lt+"**"),lt===""&&Fe.setCursor(ct.line,ct.ch+2),Fe.focus();case"italic":return Fe.replaceSelection("*"+lt+"*"),lt===""&&Fe.setCursor(ct.line,ct.ch+1),Fe.focus();case"code":return Fe.replaceSelection("`"+lt+"`"),lt===""&&Fe.setCursor(ct.line,ct.ch+1),Fe.focus();case"inline-latex":return Fe.replaceSelection("`$$"+lt+"$$`"),lt===""&&Fe.setCursor(ct.line,ct.ch+3),Fe.focus();case"latex":return Fe.replaceSelection("```latex\n"+lt+"\n```"),Fe.setCursor(ct.line+1,lt.length+1),Fe.focus();case"line-break":return Fe.replaceSelection(`<br/>
`),Fe.focus();case"list-ul":return lt===""?Fe.replaceSelection("- "+lt):Fe.replaceSelection(yt.map(function(Ct){return Ct===""?"":"- ".concat(Ct)}).join(`
`)),Fe.focus();case"list-ol":return lt===""?Fe.replaceSelection("1. "+lt):Fe.replaceSelection(yt.map(function(Ct,Dt){return Ct===""?"":"".concat(Dt+1,". ").concat(Ct)}).join(`
`)),Fe.focus();case"add-null-ch":return lt===""&&Fe.setCursor(ct.line,ct.ch+1),Fe.replaceSelection(ae),Fe.focus();case"inster-template-1":return lt===""&&Fe.setCursor(ct.line,ct.ch),Fe.replaceSelection(V),Fe.focus();case"eraser":return Fe.setValue(""),Fe.focus();case"trigger-watch":return Yi(!wr),Fe.focus();case"trigger-full-screen":return _n(!Ar),Fe.focus();case De:Kr(De);return;case je:Kr(je);return;case Pe:Kr(Pe);return;case ze:Kr(ze);return;default:throw new Error}},[Fe,wr,Ar]),Li=Object(v.useCallback)(function(nt){Kr("");switch(rr){case De:var ct=nt.title,lt=nt.link;return Fe.replaceSelection("[".concat(ct,"](").concat(lt,")")),Fe.focus();case je:var yt=nt.language,Ct=nt.content;return Fe.replaceSelection(["```"+yt,Ct,"```"].join(`
`)),Fe.focus();case Pe:var Dt=nt.src,St=nt.alt;return St?Fe.replaceSelection("![ ".concat(St," ]( ").concat(Dt,' "').concat(St,'" )')):Fe.replaceSelection("![,](".concat(Dt,")")),Fe.focus();case ze:for(var Ht=nt.row,ar=nt.col,bt=nt.align,Wr=`
`,Lt=0;Lt<Ht;Lt++){for(var or=[],qt=[],Sr=0;Sr<ar;Sr++)Lt===1&&qt.push(Ve[bt]),or.push(" ");Lt===1&&(Wr+="| ".concat(qt.join(" | "),` |
`)),Wr+="| ".concat(or.join(ar===1?"":" | "),` |
`)}return Fe.replaceSelection(Wr+`
`),Fe.focus();default:throw new Error}},[Fe,rr]),Qi=Object(v.useMemo)(function(){switch(rr){case De:return T.a.createElement(ge,{callback:Li,onCancel:Vr});case je:return T.a.createElement(xe.b,{callback:Li,onCancel:Vr});case Pe:return T.a.createElement(ve,{callback:Li,onCancel:Vr});case ze:return T.a.createElement(Le,{callback:Li,onCancel:Vr});default:return null}},[rr]);function Vr(){Kr("")}Object(v.useEffect)(function(){if(Ur.current){var nt=Ur.current,ct=!1,lt=0;function yt(St){ct=!0,lt=St.pageY}function Ct(){ct=!1}function Dt(St){if(ct){var Ht=St.pageY-lt;Ht<0&&(Ht=0),Ht>300&&(Ht=300);var ar=ot+Ht+"px";Ti(ar)}}return nt.addEventListener("mousedown",yt),document.addEventListener("mousemove",Dt),document.addEventListener("mouseup",Ct),function(){nt.removeEventListener("mousedown",yt),document.removeEventListener("mousemove",Dt),document.removeEventListener("mouseup",Ct)}}},[Fe,Ur]),Object(v.useEffect)(function(){Ti(ot)},[ot]);var Or=Y(tt),qi=Y(Rn),kr={width:Or,height:qi},en=Object(v.useMemo)(function(){if(Lr){var nt=new Date(Lr),ct=nt.getHours(),lt=nt.getMinutes(),yt=nt.getSeconds();return ct=ct<10?"0"+ct:ct,lt=lt<10?"0"+lt:lt,yt=yt<10?"0"+yt:yt,"".concat(ct,":").concat(lt,":").concat(yt)}return 0},[Lr]);function Nn(){window.sessionStorage.removeItem(gr),Ci(!1),Ji(0)}function li(){Ci(!1),Ji(0),Fe.setValue(window.sessionStorage.getItem(gr))}function ua(nt,ct){var lt=Fe.getValue();lt=lt.replace(nt,ct),Cr(lt),Fe==null||Fe.setValue(lt)}return T.a.createElement(v.Fragment,null,T.a.createElement("div",{className:"markdown-editor-wrapper",ref:Fr},T.a.createElement("div",{className:"markdown-editor-container ".concat(Be," ").concat(wr?"on-preview":""," ").concat(wt?"mini":""," ").concat(Ar?"full-screen":""),style:kr},T.a.createElement(b,{insertTemp:Et,watch:wr,fullScreen:Ar,showNullButton:Pt,onActionCallback:In,hidetoolBar:Tt,uuid:oi.current,setOpenPhones:function(){si.current=!0}}),T.a.createElement("div",{className:"markdown-editor-body"},T.a.createElement("div",{className:"codemirror-container"},T.a.createElement("textarea",{ref:Br,placeholder:xi})),wr?T.a.createElement("div",{ref:Ai,className:"preview-container"},Tr==="stex"&&T.a.createElement(L,{value:ni}),Tr!=="stex"&&T.a.createElement(f.a,{edit:!0,value:ni,replaces:ua})):null))),zr?T.a.createElement("a",{ref:Ur,className:"editor-resize"}):null,T.a.createElement(M.a,null,se[rr]?T.a.createElement(J.a,{centered:!0,title:se[rr],visible:!0,onCancel:Vr,footer:null,className:"markdown-popup-form"},Qi):null))}},SJMd:function(dt,et){/**
* @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 le,fe,J,_=!1,$,I;window.PR_SHOULD_USE_CONTINUATION=!0;var D,j;(function(){var U=window,P=["break,continue,do,else,for,if,return,while"],O=[P,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],v=[O,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],T=[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"],R=[v,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],A=[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"],C="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",S=[v,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],u="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=[P,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],s=[P,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],l=[P,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],E=[T,A,R,S,u,o,s,l],m=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,f="str",L="kwd",g="com",d="typ",c="lit",h="pun",a="pln",x="tag",p="dec",b="src",M="atn",G="atv",Z="nocode",ie="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function z(he){for(var Ee=0,Le=!1,Ie=!1,_e=0,De=he.length;_e<De;++_e){var Pe=he[_e];if(Pe.ignoreCase)Ie=!0;else if(/[a-z]/i.test(Pe.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){Le=!0,Ie=!1;break}}var je={b:8,t:9,n:10,v:11,f:12,r:13};function ze($e){var Ae=$e.charCodeAt(0);if(Ae!==92)return Ae;var rt=$e.charAt(1);return Ae=je[rt],Ae||("0"<=rt&&rt<="7"?parseInt($e.substring(1),8):rt==="u"||rt==="x"?parseInt($e.substring(2),16):$e.charCodeAt(1))}function Ke($e){if($e<32)return($e<16?"\\x0":"\\x")+$e.toString(16);var Ae=String.fromCharCode($e);return Ae==="\\"||Ae==="-"||Ae==="]"||Ae==="^"?"\\"+Ae:Ae}function Ve($e){var Ae=$e.substring(1,$e.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")),rt=[],Je=Ae[0]==="^",ae=["["];Je&&ae.push("^");for(var V=Je?1:0,Y=Ae.length;V<Y;++V){var te=Ae[V];if(/\\[bdsw]/i.test(te))ae.push(te);else{var oe=ze(te),Q;V+2<Y&&Ae[V+1]==="-"?(Q=ze(Ae[V+2]),V+=2):Q=oe,rt.push([oe,Q]),Q<65||oe>122||(Q<65||oe>90||rt.push([Math.max(65,oe)|32,Math.min(Q,90)|32]),Q<97||oe>122||rt.push([Math.max(97,oe)&~32,Math.min(Q,122)&~32]))}}rt.sort(function(me,ye){return me[0]-ye[0]||ye[1]-me[1]});for(var ee=[],se=[],V=0;V<rt.length;++V){var ue=rt[V];ue[0]<=se[1]+1?se[1]=Math.max(se[1],ue[1]):ee.push(se=ue)}for(var V=0;V<ee.length;++V){var ue=ee[V];ae.push(Ke(ue[0])),ue[1]>ue[0]&&(ue[1]+1>ue[0]&&ae.push("-"),ae.push(Ke(ue[1])))}return ae.push("]"),ae.join("")}function at($e){for(var Ae=$e.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")),rt=Ae.length,Je=[],ae=0,V=0;ae<rt;++ae){var Y=Ae[ae];if(Y==="(")++V;else if(Y.charAt(0)==="\\"){var te=+Y.substring(1);te&&(te<=V?Je[te]=-1:Ae[ae]=Ke(te))}}for(var ae=1;ae<Je.length;++ae)Je[ae]===-1&&(Je[ae]=++Ee);for(var ae=0,V=0;ae<rt;++ae){var Y=Ae[ae];if(Y==="(")++V,Je[V]||(Ae[ae]="(?:");else if(Y.charAt(0)==="\\"){var te=+Y.substring(1);te&&te<=V&&(Ae[ae]="\\"+Je[te])}}for(var ae=0;ae<rt;++ae)Ae[ae]==="^"&&Ae[ae+1]!=="^"&&(Ae[ae]="");if($e.ignoreCase&&Le)for(var ae=0;ae<rt;++ae){var Y=Ae[ae],oe=Y.charAt(0);Y.length>=2&&oe==="["?Ae[ae]=Ve(Y):oe!=="\\"&&(Ae[ae]=Y.replace(/[a-zA-Z]/g,function(se){var ue=se.charCodeAt(0);return"["+String.fromCharCode(ue&~32,ue|32)+"]"}))}return Ae.join("")}for(var Xe=[],_e=0,De=he.length;_e<De;++_e){var Pe=he[_e];if(Pe.global||Pe.multiline)throw new Error(""+Pe);Xe.push("(?:"+at(Pe)+")")}return new RegExp(Xe.join("|"),Ie?"gi":"g")}function F(he,Ee){var Le=/(?:^|\s)nocode(?:\s|$)/,Ie=[],_e=0,De=[],Pe=0;function je(ze){var Ke=ze.nodeType;if(Ke==1){if(Le.test(ze.className))return;for(var Ve=ze.firstChild;Ve;Ve=Ve.nextSibling)je(Ve);var at=ze.nodeName.toLowerCase();(at==="br"||at==="li")&&(Ie[Pe]=`
`,De[Pe<<1]=_e++,De[Pe++<<1|1]=ze)}else if(Ke==3||Ke==4){var Xe=ze.nodeValue;Xe.length&&(Ee?Xe=Xe.replace(/\r\n?/g,`
`):Xe=Xe.replace(/[ \t\r\n]+/g," "),Ie[Pe]=Xe,De[Pe<<1]=_e,_e+=Xe.length,De[Pe++<<1|1]=ze)}}return je(he),{sourceCode:Ie.join("").replace(/\n$/,""),spans:De}}function ne(he,Ee,Le,Ie,_e){if(!Le)return;var De={sourceNode:he,pre:1,langExtension:null,numberLines:null,sourceCode:Le,spans:null,basePos:Ee,decorations:null};Ie(De),_e.push.apply(_e,De.decorations)}var ce=/\S/;function ge(he){for(var Ee=void 0,Le=he.firstChild;Le;Le=Le.nextSibling){var Ie=Le.nodeType;Ee=Ie===1?Ee?he:Le:Ie===3&&ce.test(Le.nodeValue)?he:Ee}return Ee===he?void 0:Ee}function xe(he,Ee){var Le={},Ie;(function(){for(var Pe=he.concat(Ee),je=[],ze={},Ke=0,Ve=Pe.length;Ke<Ve;++Ke){var at=Pe[Ke],Xe=at[3];if(Xe)for(var $e=Xe.length;--$e>=0;)Le[Xe.charAt($e)]=at;var Ae=at[1],rt=""+Ae;ze.hasOwnProperty(rt)||(je.push(Ae),ze[rt]=null)}je.push(/[\0-\uffff]/),Ie=z(je)})();var _e=Ee.length,De=function(Pe){for(var je=Pe.sourceCode,ze=Pe.basePos,Ke=Pe.sourceNode,Ve=[ze,a],at=0,Xe=je.match(Ie)||[],$e={},Ae=0,rt=Xe.length;Ae<rt;++Ae){var Je=Xe[Ae],ae=$e[Je],V=void 0,Y;if(typeof ae=="string")Y=!1;else{var te=Le[Je.charAt(0)];if(te)V=Je.match(te[1]),ae=te[0];else{for(var oe=0;oe<_e;++oe)if(te=Ee[oe],V=Je.match(te[1]),V){ae=te[0];break}V||(ae=a)}Y=ae.length>=5&&ae.substring(0,5)==="lang-",Y&&!(V&&typeof V[1]=="string")&&(Y=!1,ae=b),Y||($e[Je]=ae)}var Q=at;if(at+=Je.length,!Y)Ve.push(ze+Q,ae);else{var ee=V[1],se=Je.indexOf(ee),ue=se+ee.length;V[2]&&(ue=Je.length-V[2].length,se=ue-ee.length);var me=ae.substring(5);ne(Ke,ze+Q,Je.substring(0,se),De,Ve),ne(Ke,ze+Q+se,ee,W(me,ee),Ve),ne(Ke,ze+Q+ue,Je.substring(ue),De,Ve)}}Pe.decorations=Ve};return De}function Me(he){var Ee=[],Le=[];he.tripleQuotedStrings?Ee.push([f,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):he.multiLineStrings?Ee.push([f,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):Ee.push([f,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),he.verbatimStrings&&Le.push([f,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var Ie=he.hashComments;Ie&&(he.cStyleComments?(Ie>1?Ee.push([g,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):Ee.push([g,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),Le.push([f,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):Ee.push([g,/^#[^\r\n]*/,null,"#"])),he.cStyleComments&&(Le.push([g,/^\/\/[^\r\n]*/,null]),Le.push([g,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var _e=he.regexLiterals;if(_e){var De=_e>1?"":`
\r`,Pe=De?".":"[\\S\\s]",je="/(?=[^/*"+De+"])(?:[^/\\x5B\\x5C"+De+"]|\\x5C"+Pe+"|\\x5B(?:[^\\x5C\\x5D"+De+"]|\\x5C"+Pe+")*(?:\\x5D|$))+/";Le.push(["lang-regex",RegExp("^"+ie+"("+je+")")])}var ze=he.types;ze&&Le.push([d,ze]);var Ke=(""+he.keywords).replace(/^ | $/g,"");Ke.length&&Le.push([L,new RegExp("^(?:"+Ke.replace(/[\s,]+/g,"|")+")\\b"),null]),Ee.push([a,/^\s+/,null,` \r
\xA0`]);var Ve="^.[^\\s\\w.$@'\"`/\\\\]*";return he.regexLiterals&&(Ve+="(?!s*/)"),Le.push([c,/^@[a-z_$][a-z_$@0-9]*/i,null],[d,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[a,/^[a-z_$][a-z_$@0-9]*/i,null],[c,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[a,/^\\[\s\S]?/,null],[h,new RegExp(Ve),null]),xe(Ee,Le)}var Te=Me({keywords:E,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Oe(he,Ee,Le){for(var Ie=/(?:^|\s)nocode(?:\s|$)/,_e=/\r\n?|\n/,De=he.ownerDocument,Pe=De.createElement("li");he.firstChild;)Pe.appendChild(he.firstChild);var je=[Pe];function ze(Ae){var rt=Ae.nodeType;if(rt==1&&!Ie.test(Ae.className))if(Ae.nodeName==="br")Ke(Ae),Ae.parentNode&&Ae.parentNode.removeChild(Ae);else for(var Je=Ae.firstChild;Je;Je=Je.nextSibling)ze(Je);else if((rt==3||rt==4)&&Le){var ae=Ae.nodeValue,V=ae.match(_e);if(V){var Y=ae.substring(0,V.index);Ae.nodeValue=Y;var te=ae.substring(V.index+V[0].length);if(te){var oe=Ae.parentNode;oe.insertBefore(De.createTextNode(te),Ae.nextSibling)}Ke(Ae),Y||Ae.parentNode.removeChild(Ae)}}}function Ke(Ae){for(;!Ae.nextSibling;)if(Ae=Ae.parentNode,!Ae)return;function rt(V,Y){var te=Y?V.cloneNode(!1):V,oe=V.parentNode;if(oe){var Q=rt(oe,1),ee=V.nextSibling;Q.appendChild(te);for(var se=ee;se;se=ee)ee=se.nextSibling,Q.appendChild(se)}return te}for(var Je=rt(Ae.nextSibling,0),ae;(ae=Je.parentNode)&&ae.nodeType===1;)Je=ae;je.push(Je)}for(var Ve=0;Ve<je.length;++Ve)ze(je[Ve]);Ee===(Ee|0)&&je[0].setAttribute("value",Ee);var at=De.createElement("ol");at.className="linenums";for(var Xe=Math.max(0,Ee-1|0)||0,Ve=0,$e=je.length;Ve<$e;++Ve)Pe=je[Ve],Pe.className="L"+(Ve+Xe)%10,Pe.firstChild||Pe.appendChild(De.createTextNode("\xA0")),at.appendChild(Pe);he.appendChild(at)}function Ce(he){var Ee=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Ee=Ee&&+Ee[1]<=8;var Le=/\n/g,Ie=he.sourceCode,_e=Ie.length,De=0,Pe=he.spans,je=Pe.length,ze=0,Ke=he.decorations,Ve=Ke.length,at=0;Ke[Ve]=_e;var Xe,$e;for($e=Xe=0;$e<Ve;)Ke[$e]!==Ke[$e+2]?(Ke[Xe++]=Ke[$e++],Ke[Xe++]=Ke[$e++]):$e+=2;for(Ve=Xe,$e=Xe=0;$e<Ve;){for(var Ae=Ke[$e],rt=Ke[$e+1],Je=$e+2;Je+2<=Ve&&Ke[Je+1]===rt;)Je+=2;Ke[Xe++]=Ae,Ke[Xe++]=rt,$e=Je}Ve=Ke.length=Xe;var ae=he.sourceNode,V="";ae&&(V=ae.style.display,ae.style.display="none");try{for(var Y=null;ze<je;){var te=Pe[ze],oe=Pe[ze+2]||_e,Q=Ke[at+2]||_e,Je=Math.min(oe,Q),ee=Pe[ze+1],se;if(ee.nodeType!==1&&(se=Ie.substring(De,Je))){Ee&&(se=se.replace(Le,"\r")),ee.nodeValue=se;var ue=ee.ownerDocument,me=ue.createElement("span");me.className=Ke[at+1];var ye=ee.parentNode;ye.replaceChild(me,ee),me.appendChild(ee),De<oe&&(Pe[ze+1]=ee=ue.createTextNode(Ie.substring(Je,oe)),ye.insertBefore(ee,me.nextSibling))}De=Je,De>=oe&&(ze+=2),De>=Q&&(at+=2)}}finally{ae&&(ae.style.display=V)}}var we={};function ve(he,Ee){for(var Le=Ee.length;--Le>=0;){var Ie=Ee[Le];we.hasOwnProperty(Ie)?U.console&&console.warn("cannot override language handler %s",Ie):we[Ie]=he}}function W(he,Ee){return he&&we.hasOwnProperty(he)||(he=/^\s*</.test(Ee)?"default-markup":"default-code"),we[he]}ve(Te,["default-code"]),ve(xe([],[[a,/^[^<?]+/],[p,/^<!\w[^>]*(?:>|$)/],[g,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[h,/^(?:<[%?]|[%?]>)/],["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"]),ve(xe([[a,/^[\s]+/,null,` \r
`],[G,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[x,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[M,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[h,/^[=<>\/]+/],["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"]),ve(xe([],[[G,/^[\s\S]+/]]),["uq.val"]),ve(Me({keywords:T,hashComments:!0,cStyleComments:!0,types:m}),["c","cc","cpp","cxx","cyc","m"]),ve(Me({keywords:"null,true,false"}),["json"]),ve(Me({keywords:A,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:m}),["cs"]),ve(Me({keywords:R,cStyleComments:!0}),["java"]),ve(Me({keywords:l,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),ve(Me({keywords:o,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),ve(Me({keywords:u,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),ve(Me({keywords:s,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),ve(Me({keywords:S,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),ve(Me({keywords:C,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),ve(xe([],[[f,/^[\s\S]+/]]),["regex"]);function w(he){var Ee=he.langExtension;try{var Le=F(he.sourceNode,he.pre),Ie=Le.sourceCode;he.sourceCode=Ie,he.spans=Le.spans,he.basePos=0,W(Ee,Ie)(he),Ce(he)}catch(_e){U.console&&console.log(_e&&_e.stack||_e)}}function k(he,Ee,Le){var Ie=Le||!1,_e=Ee||null,De=document.createElement("div");De.innerHTML="<pre>"+he+"</pre>",De=De.firstChild,Ie&&Oe(De,Ie,!0);var Pe={langExtension:_e,numberLines:Ie,sourceNode:De,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return w(Pe),De.innerHTML}function H(he,Ee){var Le=Ee||document.body,Ie=Le.ownerDocument||document;function _e(te){return Le.getElementsByTagName(te)}for(var De=[_e("pre"),_e("code"),_e("xmp")],Pe=[],je=0;je<De.length;++je)for(var ze=0,Ke=De[je].length;ze<Ke;++ze)Pe.push(De[je][ze]);De=null;var Ve=Date;Ve.now||(Ve={now:function(){return+new Date}});var at=0,Xe=/\blang(?:uage)?-([\w.]+)(?!\S)/,$e=/\bprettyprint\b/,Ae=/\bprettyprinted\b/,rt=/pre|xmp/i,Je=/^code$/i,ae=/^(?:pre|code|xmp)$/i,V={};function Y(){for(var te=U.PR_SHOULD_USE_CONTINUATION?Ve.now()+250:Infinity;at<Pe.length&&Ve.now()<te;at++){for(var oe=Pe[at],Q=V,ee=oe;ee=ee.previousSibling;){var se=ee.nodeType,ue=(se===7||se===8)&&ee.nodeValue;if(ue?!/^\??prettify\b/.test(ue):se!==3||/\S/.test(ee.nodeValue))break;if(ue){Q={},ue.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Ot,Et,mr){Q[Et]=mr});break}}var me=oe.className;if((Q!==V||$e.test(me))&&!Ae.test(me)){for(var ye=!1,ke=oe.parentNode;ke;ke=ke.parentNode){var We=ke.tagName;if(ae.test(We)&&ke.className&&$e.test(ke.className)){ye=!0;break}}if(!ye){oe.className+=" prettyprinted";var Qe=Q.lang;if(!Qe){Qe=me.match(Xe);var tt;!Qe&&(tt=ge(oe))&&Je.test(tt.tagName)&&(Qe=tt.className.match(Xe)),Qe&&(Qe=Qe[1])}var vt;if(rt.test(oe.tagName))vt=1;else{var ot=oe.currentStyle,it=Ie.defaultView,wt=ot?ot.whiteSpace:it&&it.getComputedStyle?it.getComputedStyle(oe,null).getPropertyValue("white-space"):0;vt=wt&&wt.substring(0,3)==="pre"}var xt=Q.linenums;(xt=xt==="true"||+xt)||(xt=me.match(/\blinenums\b(?::(\d+))?/),xt=xt?xt[1]&&xt[1].length?+xt[1]:!0:!1),xt&&Oe(oe,xt,vt);var It={langExtension:Qe,sourceNode:oe,numberLines:xt,pre:vt,sourceCode:null,basePos:null,spans:null,decorations:null};w(It)}}}at<Pe.length?U.setTimeout(Y,250):typeof he=="function"&&he()}Y()}var q=U.PR={createSimpleLexer:xe,registerLangHandler:ve,sourceDecorator:Me,PR_ATTRIB_NAME:M,PR_ATTRIB_VALUE:G,PR_COMMENT:g,PR_DECLARATION:p,PR_KEYWORD:L,PR_LITERAL:c,PR_NOCODE:Z,PR_PLAIN:a,PR_PUNCTUATION:h,PR_SOURCE:b,PR_STRING:f,PR_TAG:x,PR_TYPE:d,prettyPrintOne:_?U.prettyPrintOne=k:D=k,prettyPrint:j=_?U.prettyPrint=H:j=H},B=U.define;typeof B=="function"&&B.amd&&B("google-code-prettify",[],function(){return q})})()},STEk:function(dt,et,le){"use strict";le.d(et,"a",function(){return ve});/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var fe=function(W,w){return(fe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(k,H){k.__proto__=H}||function(k,H){for(var q in H)Object.prototype.hasOwnProperty.call(H,q)&&(k[q]=H[q])})(W,w)};function J(W,w){function k(){this.constructor=W}fe(W,w),W.prototype=w===null?Object.create(w):(k.prototype=w.prototype,new k)}function _(W,w,k,H){return new(k||(k=Promise))(function(q,B){function he(Ie){try{Le(H.next(Ie))}catch(_e){B(_e)}}function Ee(Ie){try{Le(H.throw(Ie))}catch(_e){B(_e)}}function Le(Ie){var _e;Ie.done?q(Ie.value):(_e=Ie.value,_e instanceof k?_e:new k(function(De){De(_e)})).then(he,Ee)}Le((H=H.apply(W,w||[])).next())})}function $(W,w){var k,H,q,B,he={label:0,sent:function(){if(1&q[0])throw q[1];return q[1]},trys:[],ops:[]};return B={next:Ee(0),throw:Ee(1),return:Ee(2)},typeof Symbol=="function"&&(B[Symbol.iterator]=function(){return this}),B;function Ee(Le){return function(Ie){return function(_e){if(k)throw new TypeError("Generator is already executing.");for(;he;)try{if(k=1,H&&(q=2&_e[0]?H.return:_e[0]?H.throw||((q=H.return)&&q.call(H),0):H.next)&&!(q=q.call(H,_e[1])).done)return q;switch(H=0,q&&(_e=[2&_e[0],q.value]),_e[0]){case 0:case 1:q=_e;break;case 4:return he.label++,{value:_e[1],done:!1};case 5:he.label++,H=_e[1],_e=[0];continue;case 7:_e=he.ops.pop(),he.trys.pop();continue;default:if(!(q=he.trys,(q=q.length>0&&q[q.length-1])||_e[0]!==6&&_e[0]!==2)){he=0;continue}if(_e[0]===3&&(!q||_e[1]>q[0]&&_e[1]<q[3])){he.label=_e[1];break}if(_e[0]===6&&he.label<q[1]){he.label=q[1],q=_e;break}if(q&&he.label<q[2]){he.label=q[2],he.ops.push(_e);break}q[2]&&he.ops.pop(),he.trys.pop();continue}_e=w.call(W,he)}catch(De){_e=[6,De],H=0}finally{k=q=0}if(5&_e[0])throw _e[1];return{value:_e[0]?_e[1]:void 0,done:!0}}([Le,Ie])}}}function I(){for(var W=0,w=0,k=arguments.length;w<k;w++)W+=arguments[w].length;var H=Array(W),q=0;for(w=0;w<k;w++)for(var B=arguments[w],he=0,Ee=B.length;he<Ee;he++,q++)H[q]=B[he];return H}var D=function(){function W(){}return W.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},W.setAttributes=function(w,k){for(var H=0,q=k;H<q.length;H++){var B=q[H],he=B[0],Ee=B[1];w.setAttribute(he,Ee)}},W.createRect=function(w,k,H){var q=document.createElementNS("http://www.w3.org/2000/svg","rect");return q.setAttribute("width",w.toString()),q.setAttribute("height",k.toString()),H&&W.setAttributes(q,H),q},W.createLine=function(w,k,H,q,B){var he=document.createElementNS("http://www.w3.org/2000/svg","line");return he.setAttribute("x1",w.toString()),he.setAttribute("y1",k.toString()),he.setAttribute("x2",H.toString()),he.setAttribute("y2",q.toString()),B&&W.setAttributes(he,B),he},W.createPolygon=function(w,k){var H=document.createElementNS("http://www.w3.org/2000/svg","polygon");return H.setAttribute("points",w),k&&W.setAttributes(H,k),H},W.createCircle=function(w,k){var H=document.createElementNS("http://www.w3.org/2000/svg","circle");return H.setAttribute("cx",(w/2).toString()),H.setAttribute("cy",(w/2).toString()),H.setAttribute("r",w.toString()),k&&W.setAttributes(H,k),H},W.createEllipse=function(w,k,H){var q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return q.setAttribute("cx",(w/2).toString()),q.setAttribute("cy",(k/2).toString()),q.setAttribute("rx",(w/2).toString()),q.setAttribute("ry",(k/2).toString()),H&&W.setAttributes(q,H),q},W.createGroup=function(w){var k=document.createElementNS("http://www.w3.org/2000/svg","g");return w&&W.setAttributes(k,w),k},W.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},W.createMarker=function(w,k,H,q,B,he,Ee){var Le=document.createElementNS("http://www.w3.org/2000/svg","marker");return W.setAttributes(Le,[["id",w],["orient",k],["markerWidth",H.toString()],["markerHeight",q.toString()],["refX",B.toString()],["refY",he.toString()]]),Le.appendChild(Ee),Le},W.createText=function(w){var k=document.createElementNS("http://www.w3.org/2000/svg","text");return k.setAttribute("x","0"),k.setAttribute("y","0"),w&&W.setAttributes(k,w),k},W.createTSpan=function(w,k){var H=document.createElementNS("http://www.w3.org/2000/svg","tspan");return H.textContent=w,k&&W.setAttributes(H,k),H},W.createImage=function(w){var k=document.createElementNS("http://www.w3.org/2000/svg","image");return w&&W.setAttributes(k,w),k},W.createPoint=function(w,k){var H=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return H.x=w,H.y=k,H},W.createPath=function(w,k){var H=document.createElementNS("http://www.w3.org/2000/svg","path");return H.setAttribute("d",w),k&&W.setAttributes(H,k),H},W}(),j=function(){function W(){}return W.addKey=function(w){W.key=w},Object.defineProperty(W,"isLicensed",{get:function(){return!!W.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(W.key)},enumerable:!1,configurable:!0}),W}(),U=function(){function W(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return W.prototype.rasterize=function(w,k,H){var q=this;return new Promise(function(B){var he=H!==void 0?H:document.createElement("canvas");w===null&&(q.markersOnly=!0,q.naturalSize=!1);var Ee=document.createElementNS("http://www.w3.org/2000/svg","svg");Ee.setAttribute("xmlns","http://www.w3.org/2000/svg"),Ee.setAttribute("width",k.width.baseVal.valueAsString),Ee.setAttribute("height",k.height.baseVal.valueAsString),Ee.setAttribute("viewBox","0 0 "+k.viewBox.baseVal.width.toString()+" "+k.viewBox.baseVal.height.toString()),Ee.innerHTML=k.innerHTML,q.naturalSize===!0?(Ee.width.baseVal.value=w.naturalWidth,Ee.height.baseVal.value=w.naturalHeight):q.width!==void 0&&q.height!==void 0&&(Ee.width.baseVal.value=q.width,Ee.height.baseVal.value=q.height),he.width=Ee.width.baseVal.value,he.height=Ee.height.baseVal.value;var Le=Ee.outerHTML,Ie=he.getContext("2d");q.markersOnly!==!0&&Ie.drawImage(w,0,0,he.width,he.height);var _e=window.URL,De=new Image(he.width,he.height);De.setAttribute("crossOrigin","anonymous");var Pe=new Blob([Le],{type:"image/svg+xml"}),je=_e.createObjectURL(Pe);De.onload=function(){Ie.drawImage(De,0,0),_e.revokeObjectURL(je);var ze=he.toDataURL(q.imageType,q.imageQuality);B(ze)},De.src=je})},W}(),P=function(){},O=function(){function W(w){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+w+"_"}return Object.defineProperty(W.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"defaultSettings",{get:function(){return{canvasBackgroundColor:"#ffffff",toolbarBackgroundColor:"#111111",toolbarBackgroundHoverColor:"#333333",toolbarColor:"#eeeeee",toolbarHeight:40,toolboxColor:"#eeeeee",toolboxAccentColor:"#3080c3",undoButtonVisible:!0,redoButtonVisible:!1,zoomButtonVisible:!1,zoomOutButtonVisible:!1,clearButtonVisible:!1,resultButtonBlockVisible:!0,logoPosition:"left"}},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),W.prototype.addClass=function(w){return this.styleSheet===void 0&&this.addStyleSheet(),w.name=""+this.classNamePrefix+w.localName,this.classes.push(w),this.styleSheet.sheet.insertRule("."+w.name+" {"+w.style+"}",this.styleSheet.sheet.cssRules.length),w},W.prototype.addRule=function(w){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(w),this.styleSheet.sheet.insertRule(w.selector+" {"+w.style+"}",this.styleSheet.sheet.cssRules.length)},W.prototype.addStyleSheet=function(){var w;this.styleSheet=document.createElement("style"),((w=this.styleSheetRoot)!==null&&w!==void 0?w:document.head).appendChild(this.styleSheet),this.addRule(new v("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new v("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new v("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new T("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new T("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},W.prototype.removeStyleSheet=function(){var w;this.styleSheet&&(((w=this.styleSheetRoot)!==null&&w!==void 0?w:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},W}(),v=function(W,w){this.selector=W,this.style=w},T=function(W,w){this.localName=W,this.style=w},R=function(){function W(w,k,H,q,B){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=w,this.displayMode=k,this.markerItems=H,this.uiStyleSettings=q,this.styles=B,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return W.prototype.show=function(w){var k=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=w,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var H=document.createElement("div");H.className=this.toolbarBlockStyleClass.name,H.style.whiteSpace="nowrap",this.uiContainer.appendChild(H),this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M10.07 14.27a.997.997 0 011.33.48l2.3 4.99 1.8-.85-2.31-4.98c-.24-.5-.02-1.1.48-1.33l.28-.08 2.3-.45L8 5.12V15.9l1.82-1.47.25-.16m3.57 7.7a.99.99 0 01-1.33-.47l-2.18-4.74-2.51 2.02c-.17.14-.38.22-.62.22a1 1 0 01-1-1V3a1 1 0 011-1c.24 0 .47.09.64.23l.01-.01 11.49 9.64a1.001 1.001 0 01-.44 1.75l-3.16.62 2.2 4.73c.26.5.02 1.09-.48 1.32l-3.62 1.69z"/></svg>',"select"),this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M9 3v1H4v2h1v13a2 2 0 002 2h10a2 2 0 002-2V6h1V4h-5V3H9M7 6h10v13H7V6m2 2v9h2V8H9m4 0v9h2V8h-2z"/></svg>',"delete"),this.uiStyleSettings.clearButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M19.36 2.72l1.42 1.42-5.72 5.71c1.07 1.54 1.22 3.39.32 4.59L9.06 8.12c1.2-.9 3.05-.75 4.59.32l5.71-5.72M5.93 17.57c-2.01-2.01-3.24-4.41-3.58-6.65l4.88-2.09 7.44 7.44-2.09 4.88c-2.24-.34-4.64-1.57-6.65-3.58z"/></svg>',"clear"),this.uiStyleSettings.undoButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',"undo"),this.uiStyleSettings.redoButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M18.4 10.6C16.55 9 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 017.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',"redo"),this.uiStyleSettings.zoomButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M15.5 14l5 5-1.5 1.5-5-5v-.79l-.27-.28A6.471 6.471 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3 6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.57 4.23l.28.27h.79m-6 0C12 14 14 12 14 9.5S12 5 9.5 5 5 7 5 9.5 7 14 9.5 14m2.5-4h-2v2H9v-2H7V9h2V7h1v2h2v1z"/></svg>',"zoom"),this.uiStyleSettings.zoomButtonVisible&&this.uiStyleSettings.zoomOutButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 009.5 3 6.5 6.5 0 003 9.5 6.5 6.5 0 009.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 5 1.5-1.5-5-5m-6 0C7 14 5 12 5 9.5S7 5 9.5 5 14 7 14 9.5 12 14 9.5 14M7 9h5v1H7V9z"/></svg>',"zoom-out"),this.uiStyleSettings.notesButtonVisible&&this.addActionButton(H,'<svg viewBox="0 0 24 24"><path d="M18.13 12l1.26-1.26c.44-.44 1-.68 1.61-.74V9l-6-6H5c-1.11 0-2 .89-2 2v14a2 2 0 002 2h6v-1.87l.13-.13H5V5h7v7h6.13M14 4.5l5.5 5.5H14V4.5m5.13 9.33l2.04 2.04L15.04 22H13v-2.04l6.13-6.13m3.72.36l-.98.98-2.04-2.04.98-.98c.19-.2.52-.2.72 0l1.32 1.32c.2.2.2.53 0 .72z"/></svg>',"notes"),this.markerButtonBlock=document.createElement("div"),this.markerButtonBlock.className=this.toolbarBlockStyleClass.name,this.markerButtonBlock.style.flexGrow="2",this.markerButtonBlock.style.textAlign="center",this.uiContainer.appendChild(this.markerButtonBlock),this.markerButtonOverflowBlock=document.createElement("div"),this.markerButtonOverflowBlock.className=this.toolbarOverflowBlockStyleClass.name+" "+(this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName?this.uiStyleSettings.toolbarOverflowBlockStyleColorsClassName:this.toolbarOverflowBlockStyleColorsClass.name),this.markerButtonOverflowBlock.style.display="none",this.uiContainer.appendChild(this.markerButtonOverflowBlock),this.markerItems&&(this.markerItems.forEach(function(B){var he=document.createElement("div");he.className=""+k.toolbarButtonStyleClass.name,he.setAttribute("data-type-name",B.typeName),he.innerHTML=B.icon,he.addEventListener("click",function(){k.markerToolbarButtonClicked(he,B)}),k.buttons.push(he),k.markerButtons.push(he)}),this.overflowButton=document.createElement("div"),this.overflowButton.className=this.toolbarButtonStyleClass.name+" "+(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name),this.overflowButton.innerHTML='<svg viewBox="0 0 24 24"><path d="M12 16a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2m0-6a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2z"/></svg>',this.overflowButton.addEventListener("click",this.overflowButtonClicked),this.markerButtonBlock.appendChild(this.overflowButton));var q=document.createElement("div");q.className=this.toolbarBlockStyleClass.name,q.style.whiteSpace="nowrap",q.style.display=this.uiStyleSettings.resultButtonBlockVisible!==!1?"":"none",this.uiContainer.appendChild(q),this.addActionButton(q,'<svg viewBox="0 0 24 24"><path d="M9 20.42l-6.21-6.21 2.83-2.83L9 14.77l9.88-9.89 2.83 2.83L9 20.42z"/></svg>',"render"),this.addActionButton(q,'<svg viewBox="0 0 24 24"><path d="M20 6.91L17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12 20 6.91z"/></svg>',"close"),this.markerjsContainer.appendChild(this.uiContainer),this.setSelectMode(),this.setCurrentMarker(),this.adjustLayout()},W.prototype.addButtonClickListener=function(w){this.buttonClickListeners.push(w)},W.prototype.removeButtonClickListener=function(w){this.buttonClickListeners.indexOf(w)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(w),1)},W.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},W.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var w=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var k=0;k<this.markerButtons.length;k++)k<w||k===w&&this.markerButtons.length-1===w?this.markerButtonBlock.appendChild(this.markerButtons[k]):(k===w&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[k]))}},W.prototype.overflowButtonClicked=function(){this.markerButtonOverflowBlock.style.display!=="none"?(this.markerButtonOverflowBlock.className=this.markerButtonOverflowBlock.className.replace(this.styles.fadeInAnimationClassName,""),this.markerButtonOverflowBlock.style.display="none"):(this.markerButtonOverflowBlock.className+=" "+this.styles.fadeInAnimationClassName,this.markerButtonOverflowBlock.style.top=this.uiContainer.offsetTop+this.overflowButton.offsetHeight+"px",this.markerButtonOverflowBlock.style.right=this.uiContainer.offsetWidth-this.overflowButton.offsetLeft-this.overflowButton.offsetWidth+2*this.uiContainer.offsetLeft+"px",this.markerButtonOverflowBlock.style.display="inline-block")},W.prototype.resetButtonStyles=function(){var w=this;this.buttons.forEach(function(k){k.className=k.className.replace(w.uiStyleSettings.toolbarButtonStyleColorsClassName?w.uiStyleSettings.toolbarButtonStyleColorsClassName:w.toolbarButtonStyleColorsClass.name,"").trim(),k.className=k.className.replace(w.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?w.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:w.toolbarActiveButtonStyleColorsClass.name,"").trim(),k.className+=" "+(w.uiStyleSettings.toolbarButtonStyleColorsClassName?w.uiStyleSettings.toolbarButtonStyleColorsClassName:w.toolbarButtonStyleColorsClass.name)})},W.prototype.addActionButton=function(w,k,H){var q=this,B=document.createElement("div");switch(B.className=""+this.toolbarButtonStyleClass.name,B.innerHTML=k,B.setAttribute("data-action",H),B.addEventListener("click",function(){q.actionToolbarButtonClicked(B,H)}),H){case"select":B.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":B.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":B.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":B.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":B.style.fill=this.uiStyleSettings.closeButtonColor}w.appendChild(B),this.buttons.push(B)},W.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new T("toolbar",`
width: 100%;
flex-shrink: 0;
display: flex;
flex-direction: row;
justify-content: space-between;
height: `+this.uiStyleSettings.toolbarHeight+`px;
box-sizing: content-box;
`+(this.displayMode==="inline"?"border-top-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
`+(this.displayMode==="inline"?"border-top-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
overflow: hidden;
`)),this.toolbarStyleColorsClass=this.styles.addClass(new T("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new T("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new T("toolbar-overflow-block",`
position: absolute;
top: `+this.uiStyleSettings.toolbarHeight+`px;
max-width: `+2*this.uiStyleSettings.toolbarHeight+`px;
z-index: 10;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleColorsClass=this.styles.addClass(new T("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var w=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new T("toolbar_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*w)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*w)+`px;
padding: `+w+`px;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new T("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new T("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new v("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new v("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},W.prototype.markerToolbarButtonClicked=function(w,k){this.setActiveButton(w),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(H){return H("marker",k)}),this.markerButtonOverflowBlock.style.display="none"},W.prototype.actionToolbarButtonClicked=function(w,k){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(H){return H("action",k)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},W.prototype.setActiveButton=function(w){this.resetButtonStyles(),w.className=w.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),w.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},W.prototype.setActiveMarkerButton=function(w){var k=this.markerButtons.find(function(H){return H.getAttribute("data-type-name")===w});k&&this.setActiveButton(k)},W.prototype.setCurrentMarker=function(w){var k=this;this.currentMarker=w,this.buttons.filter(function(H){return/delete|notes/.test(H.getAttribute("data-action"))}).forEach(function(H){k.currentMarker===void 0?(H.style.fillOpacity="0.4",H.style.pointerEvents="none"):(H.style.fillOpacity="1",H.style.pointerEvents="all")})},W}(),A=function(){function W(w,k,H,q){this.panels=[],this.panelButtons=[],this.markerjsContainer=w,this.displayMode=k,this.uiStyleSettings=H,this.styles=q,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return W.prototype.addStyles=function(){var w;this.toolboxStyleClass=this.styles.addClass(new T("toolbox",`
width: 100%;
flex-shrink: 0;
display: flex;
flex-direction: column;
font-family: sans-serif;
`+(this.displayMode==="popup"?"height:"+2.5*this.uiStyleSettings.toolbarHeight+"px;":"")+`
box-sizing: content-box;
`+(this.displayMode==="popup"?"background-color: "+this.uiStyleSettings.canvasBackgroundColor+";":"")+`
`+(this.displayMode==="inline"?"border-bottom-left-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
`+(this.displayMode==="inline"?"border-bottom-right-radius: "+Math.round(this.uiStyleSettings.toolbarHeight/10)+"px;":"")+`
overflow: hidden;
`)),this.toolboxStyleColorsClass=this.styles.addClass(new T("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var k=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new T("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new T("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new T("toolbox-panel-row",`
display: flex;
`+(this.displayMode==="inline"?"position: absolute;":"")+`
`+(this.displayMode==="inline"?"bottom: "+this.uiStyleSettings.toolbarHeight+"px;":"")+`
cursor: default;
height: `+1.5*this.uiStyleSettings.toolbarHeight+`px;
`+(this.displayMode==="inline"?"width: 100%;":"")+`
box-sizing: content-box;
`)),this.toolboxPanelRowStyleColorsClass=this.styles.addClass(new T("toolbox-panel-row_colors",`
background-color: `+((w=this.uiStyleSettings.toolboxBackgroundColor)!==null&&w!==void 0?w:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new T("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*k)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*k)+`px;
padding: `+k+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new T("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new T("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new v("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new v("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},W.prototype.show=function(w){var k;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=w,this.uiContainer.className=this.toolboxStyleClass.name+" "+((k=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&k!==void 0?k:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},W.prototype.setPanelButtons=function(w){var k,H,q=this;this.panels=w,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((k=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&k!==void 0?k:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((H=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&H!==void 0?H:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(B){var he;B.uiStyleSettings=q.uiStyleSettings;var Ee=document.createElement("div");Ee.className=q.toolboxButtonStyleClass.name+" "+((he=q.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&he!==void 0?he:q.toolboxButtonStyleColorsClass.name),Ee.innerHTML=B.icon,Ee.title=B.title,Ee.addEventListener("click",function(){q.panelButtonClick(B)}),q.panelButtons.push(Ee),q.buttonRow.appendChild(Ee)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},W.prototype.panelButtonClick=function(w){var k=this,H=-1;if(w!==this.activePanel){H=this.panels.indexOf(w),this.panelRow.innerHTML="";var q=w.getUi();q.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.panelRow.appendChild(q),this.panelRow.style.display="flex",this.panelRow.style.visibility="visible",this.panelRow.className=this.panelRow.className.replace(this.styles.fadeOutAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeInAnimationClassName,this.activePanel=w}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){k.displayMode==="inline"?k.panelRow.style.display="none":k.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(B,he){var Ee,Le;B.className=k.toolboxButtonStyleClass.name+" "+(he===H?""+((Ee=k.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Ee!==void 0?Ee:k.toolboxActiveButtonStyleColorsClass.name):""+((Le=k.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Le!==void 0?Le:k.toolboxButtonStyleColorsClass.name))})},W}(),C=function(W,w){this.title=W,this.icon=w},S=function(W){function w(k,H,q,B){var he=W.call(this,k,B||'<svg viewBox="0 0 24 24"><path d="M17.5 12a1.5 1.5 0 01-1.5-1.5A1.5 1.5 0 0117.5 9a1.5 1.5 0 011.5 1.5 1.5 1.5 0 01-1.5 1.5m-3-4A1.5 1.5 0 0113 6.5 1.5 1.5 0 0114.5 5 1.5 1.5 0 0116 6.5 1.5 1.5 0 0114.5 8m-5 0A1.5 1.5 0 018 6.5 1.5 1.5 0 019.5 5 1.5 1.5 0 0111 6.5 1.5 1.5 0 019.5 8m-3 4A1.5 1.5 0 015 10.5 1.5 1.5 0 016.5 9 1.5 1.5 0 018 10.5 1.5 1.5 0 016.5 12M12 3a9 9 0 00-9 9 9 9 0 009 9 1.5 1.5 0 001.5-1.5c0-.39-.15-.74-.39-1-.23-.27-.38-.62-.38-1a1.5 1.5 0 011.5-1.5H16a5 5 0 005-5c0-4.42-4.03-8-9-8z"/></svg>')||this;return he.colors=[],he.addTransparent=!1,he.colorBoxes=[],he.colors=H,he.currentColor=q,he.setCurrentColor=he.setCurrentColor.bind(he),he.getColorBox=he.getColorBox.bind(he),he}return J(w,W),w.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.overflow="hidden",H.style.whiteSpace="nowrap",this.colors.forEach(function(q){var B=k.getColorBox(q);H.appendChild(B),k.colorBoxes.push(B)}),H},w.prototype.getColorBox=function(k){var H=this,q=this.uiStyleSettings.toolbarHeight/4,B=this.uiStyleSettings.toolbarHeight-q,he=document.createElement("div");he.style.display="inline-block",he.style.boxSizing="content-box",he.style.width=B-2+"px",he.style.height=B-2+"px",he.style.padding="1px",he.style.marginRight="2px",he.style.marginBottom="2px",he.style.borderWidth="2px",he.style.borderStyle="solid",he.style.borderRadius=(B+2)/2+"px",he.style.borderColor=k===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",he.addEventListener("click",function(){H.setCurrentColor(k,he)});var Ee=document.createElement("div");return Ee.style.display="inline-block",Ee.style.width=B-2+"px",Ee.style.height=B-2+"px",Ee.style.backgroundColor=k,Ee.style.borderRadius=B/2+"px",k==="transparent"&&(Ee.style.fill=this.uiStyleSettings.toolboxAccentColor,Ee.innerHTML=`<svg viewBox="0 0 24 24">
<path d="M2,5.27L3.28,4L20,20.72L18.73,22L15.65,18.92C14.5,19.3 13.28,19.5 12,19.5C7,19.5 2.73,16.39 1,12C1.69,10.24 2.79,8.69 4.19,7.46L2,5.27M12,9A3,3 0 0,1 15,12C15,12.35 14.94,12.69 14.83,13L11,9.17C11.31,9.06 11.65,9 12,9M12,4.5C17,4.5 21.27,7.61 23,12C22.18,14.08 20.79,15.88 19,17.19L17.58,15.76C18.94,14.82 20.06,13.54 20.82,12C19.17,8.64 15.76,6.5 12,6.5C10.91,6.5 9.84,6.68 8.84,7L7.3,5.47C8.74,4.85 10.33,4.5 12,4.5M3.18,12C4.83,15.36 8.24,17.5 12,17.5C12.69,17.5 13.37,17.43 14,17.29L11.72,15C10.29,14.85 9.15,13.71 9,12.28L5.6,8.87C4.61,9.72 3.78,10.78 3.18,12Z" />
</svg>`),he.appendChild(Ee),he},w.prototype.setCurrentColor=function(k,H){var q=this;this.currentColor=k,this.colorBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(k)},w}(C),u=function(){function W(w,k,H){this._state="new",this._isSelected=!1,this._container=w,this._overlayContainer=k,this.globalSettings=H,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(W.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),W.prototype.ownsTarget=function(w){return!1},Object.defineProperty(W.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),W.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},W.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},W.prototype.pointerDown=function(w,k){},W.prototype.dblClick=function(w,k){},W.prototype.manipulate=function(w){},W.prototype.pointerUp=function(w){this.stateChanged()},W.prototype.dispose=function(){},W.prototype.addMarkerVisualToContainer=function(w){this.container.childNodes.length>0?this.container.insertBefore(w,this.container.childNodes[0]):this.container.appendChild(w)},W.prototype.getState=function(){return{typeName:W.typeName,state:this.state,notes:this.notes}},W.prototype.restoreState=function(w){this._state=w.state,this.notes=w.notes},W.prototype.scale=function(w,k){},W.prototype.colorChanged=function(w){this.onColorChanged&&this.onColorChanged(w),this.stateChanged()},W.prototype.fillColorChanged=function(w){this.onFillColorChanged&&this.onFillColorChanged(w),this.stateChanged()},W.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var w=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),w.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(w)&&this.onStateChanged(this)}},W.typeName="MarkerBase",W}(),o=function(){function W(){this.findGripByVisual=this.findGripByVisual.bind(this)}return W.prototype.findGripByVisual=function(w){return this.topLeft.ownsTarget(w)?this.topLeft:this.topCenter.ownsTarget(w)?this.topCenter:this.topRight.ownsTarget(w)?this.topRight:this.centerLeft.ownsTarget(w)?this.centerLeft:this.centerRight.ownsTarget(w)?this.centerRight:this.bottomLeft.ownsTarget(w)?this.bottomLeft:this.bottomCenter.ownsTarget(w)?this.bottomCenter:this.bottomRight.ownsTarget(w)?this.bottomRight:void 0},W}(),s=function(){function W(){this.GRIP_SIZE=10,this.visual=D.createGroup(),this.visual.appendChild(D.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(D.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return W.prototype.ownsTarget=function(w){return w===this.visual||w===this.visual.childNodes[0]||w===this.visual.childNodes[1]},W}(),l=function(){function W(){}return W.toITransformMatrix=function(w){return{a:w.a,b:w.b,c:w.c,d:w.d,e:w.e,f:w.f}},W.toSVGMatrix=function(w,k){return w.a=k.a,w.b=k.b,w.c=k.c,w.d=k.d,w.e=k.e,w.f=k.f,w},W}(),E=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.left=0,B.top=0,B.width=0,B.height=0,B.defaultSize={x:50,y:20},B.offsetX=0,B.offsetY=0,B.rotationAngle=0,B.CB_DISTANCE=10,B._suppressMarkerCreateEvent=!1,B.container.transform.baseVal.appendItem(D.createTransform()),B.setupControlBox(),B}return J(w,W),Object.defineProperty(w.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"visual",{get:function(){return this._visual},set:function(k){this._visual=k;var H=D.createTransform();this._visual.transform.baseVal.appendItem(H)},enumerable:!1,configurable:!0}),w.prototype.ownsTarget=function(k){return!!W.prototype.ownsTarget.call(this,k)||!!(this.controlGrips.findGripByVisual(k)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(k))},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.left=k.x,this.top=k.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var q=this.unrotatePoint(k);if(this.manipulationStartX=q.x,this.manipulationStartY=q.y,this.offsetX=q.x-this.left,this.offsetY=q.y-this.top,this.state!=="new")if(this.select(),this.activeGrip=this.controlGrips.findGripByVisual(H),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(H)){this.activeGrip=this.rotatorGrip;var B=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=B.x-this.width/2,this.top=B.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var he=this.container.transform.baseVal.getItem(0);he.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(he,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},w.prototype.pointerUp=function(k){var H=this.state;W.prototype.pointerUp.call(this,k),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(k),this._state="select",H==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},w.prototype.moveVisual=function(k){this.visual.style.transform="translate("+k.x+"px, "+k.y+"px)"},w.prototype.manipulate=function(k){var H=this.unrotatePoint(k);this.state==="creating"?this.resize(k):this.state==="move"?(this.left=this.manipulationStartLeft+(H.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(H.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(H):this.state==="rotate"&&this.rotate(k)},w.prototype.resize=function(k){var H=this.manipulationStartLeft,q=this.manipulationStartWidth,B=this.manipulationStartTop,he=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:H=this.manipulationStartLeft+k.x-this.manipulationStartX,q=this.manipulationStartWidth+this.manipulationStartLeft-H;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:q=this.manipulationStartWidth+k.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:B=this.manipulationStartTop+k.y-this.manipulationStartY,he=this.manipulationStartHeight+this.manipulationStartTop-B;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:he=this.manipulationStartHeight+k.y-this.manipulationStartY}q>=0?(this.left=H,this.width=q):(this.left=H+q,this.width=-q),he>=0?(this.top=B,this.height=he):(this.top=B+he,this.height=-he),this.setSize()},w.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},w.prototype.rotate=function(k){if(Math.abs(k.x-this.centerX)>.1){var H=Math.sign(k.x-this.centerX);this.rotationAngle=180*Math.atan((k.y-this.centerY)/(k.x-this.centerX))/Math.PI+90*H,this.applyRotation()}},w.prototype.applyRotation=function(){var k=this.container.transform.baseVal.getItem(0);k.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(k,0)},w.prototype.rotatePoint=function(k){if(this.rotationAngle===0)return k;var H=this.container.getCTM(),q=D.createPoint(k.x,k.y);return{x:(q=q.matrixTransform(H)).x,y:q.y}},w.prototype.unrotatePoint=function(k){if(this.rotationAngle===0)return k;var H=this.container.getCTM();H=H.inverse();var q=D.createPoint(k.x,k.y);return{x:(q=q.matrixTransform(H)).x,y:q.y}},w.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},w.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},w.prototype.setupControlBox=function(){this.controlBox=D.createGroup();var k=D.createTransform();k.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(k),this.container.appendChild(this.controlBox),this.controlRect=D.createRect(this.width+this.CB_DISTANCE,this.height+this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"],["fill","transparent"],["pointer-events","none"]]),this.controlBox.appendChild(this.controlRect),this.globalSettings.disableRotation!==!0&&(this.rotatorGripLine=D.createLine((this.width+2*this.CB_DISTANCE)/2,this.top-this.CB_DISTANCE,(this.width+2*this.CB_DISTANCE)/2,this.top-3*this.CB_DISTANCE,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.appendChild(this.rotatorGripLine)),this.controlGrips=new o,this.addControlGrips(),this.controlBox.style.display="none"},w.prototype.adjustControlBox=function(){var k=this.controlBox.transform.baseVal.getItem(0);k.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(k,0),this.controlRect.setAttribute("width",(this.width+this.CB_DISTANCE).toString()),this.controlRect.setAttribute("height",(this.height+this.CB_DISTANCE).toString()),this.rotatorGripLine!==void 0&&(this.rotatorGripLine.setAttribute("x1",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y1",(-this.CB_DISTANCE/2).toString()),this.rotatorGripLine.setAttribute("x2",((this.width+this.CB_DISTANCE)/2).toString()),this.rotatorGripLine.setAttribute("y2",(3*-this.CB_DISTANCE).toString())),this.positionGrips()},w.prototype.addControlGrips=function(){this.controlGrips.topLeft=this.createGrip(),this.controlGrips.topCenter=this.createGrip(),this.controlGrips.topRight=this.createGrip(),this.controlGrips.centerLeft=this.createGrip(),this.controlGrips.centerRight=this.createGrip(),this.controlGrips.bottomLeft=this.createGrip(),this.controlGrips.bottomCenter=this.createGrip(),this.controlGrips.bottomRight=this.createGrip(),this.globalSettings.disableRotation!==!0&&(this.rotatorGrip=this.createGrip()),this.positionGrips()},w.prototype.createGrip=function(){var k=new s;return k.visual.transform.baseVal.appendItem(D.createTransform()),this.controlBox.appendChild(k.visual),k},w.prototype.positionGrips=function(){var k=this.controlGrips.topLeft.GRIP_SIZE,H=-k/2,q=H,B=(this.width+this.CB_DISTANCE)/2-k/2,he=(this.height+this.CB_DISTANCE)/2-k/2,Ee=this.height+this.CB_DISTANCE-k/2,Le=this.width+this.CB_DISTANCE-k/2;this.positionGrip(this.controlGrips.topLeft.visual,H,q),this.positionGrip(this.controlGrips.topCenter.visual,B,q),this.positionGrip(this.controlGrips.topRight.visual,Le,q),this.positionGrip(this.controlGrips.centerLeft.visual,H,he),this.positionGrip(this.controlGrips.centerRight.visual,Le,he),this.positionGrip(this.controlGrips.bottomLeft.visual,H,Ee),this.positionGrip(this.controlGrips.bottomCenter.visual,B,Ee),this.positionGrip(this.controlGrips.bottomRight.visual,Le,Ee),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,B,q-3*this.CB_DISTANCE)},w.prototype.positionGrip=function(k,H,q){var B=k.transform.baseVal.getItem(0);B.setTranslate(H,q),k.transform.baseVal.replaceItem(B,0)},w.prototype.hideControlBox=function(){this.controlBox.style.display="none"},w.prototype.showControlBox=function(){this.controlBox.style.display=""},w.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:l.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:l.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},W.prototype.getState.call(this))},w.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.left=H.left,this.top=H.top,this.width=H.width,this.height=H.height,this.rotationAngle=H.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(l.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,H.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(l.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,H.containerTransformMatrix))},w.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H);var q=this.rotatePoint({x:this.left,y:this.top}),B=this.unrotatePoint({x:q.x*k,y:q.y*H});this.left=B.x,this.top=B.y,this.width=this.width*k,this.height=this.height*H,this.adjustControlBox()},w}(u),m=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.fillColor="transparent",B.strokeColor="transparent",B.strokeWidth=0,B.strokeDasharray="",B.opacity=1,B.setStrokeColor=B.setStrokeColor.bind(B),B.setFillColor=B.setFillColor.bind(B),B.setStrokeWidth=B.setStrokeWidth.bind(B),B.setStrokeDasharray=B.setStrokeDasharray.bind(B),B.createVisual=B.createVisual.bind(B),B}return J(w,W),w.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual)},w.prototype.createVisual=function(){this.visual=D.createRect(1,1,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},w.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k)},w.prototype.resize=function(k){W.prototype.resize.call(this,k),this.setSize()},w.prototype.setSize=function(){W.prototype.setSize.call(this),D.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},w.prototype.pointerUp=function(k){W.prototype.pointerUp.call(this,k),this.setSize()},w.prototype.setStrokeColor=function(k){this.strokeColor=k,this.visual&&D.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(k),this.stateChanged()},w.prototype.setFillColor=function(k){this.fillColor=k,this.visual&&D.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},w.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.visual&&D.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},w.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.visual&&D.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},w.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this))},w.prototype.restoreState=function(k){var H=k;this.fillColor=H.fillColor,this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.opacity=H.opacity,this.createVisual(),W.prototype.restoreState.call(this,k),this.setSize()},w.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize()},w.title="Rectangle marker",w}(E),f=function(W){function w(k,H,q,B){var he=W.call(this,k,B||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return he.widths=[],he.widthBoxes=[],he.widths=H,he.currentWidth=q,he.setCurrentWidth=he.setCurrentWidth.bind(he),he}return J(w,W),w.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",this.widths.forEach(function(q){var B=document.createElement("div");B.style.display="flex",B.style.flexGrow="2",B.style.alignItems="center",B.style.justifyContent="space-between",B.style.padding="5px",B.style.borderWidth="2px",B.style.borderStyle="solid",B.style.borderColor=q===k.currentWidth?k.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){k.setCurrentWidth(q,B)}),H.appendChild(B);var he=document.createElement("div");he.innerText=q.toString(),he.style.marginRight="5px",B.appendChild(he);var Ee=document.createElement("div");Ee.style.minHeight="20px",Ee.style.flexGrow="2",Ee.style.display="flex",Ee.style.alignItems="center";var Le=document.createElement("hr");Le.style.minWidth="20px",Le.style.border="0px",Le.style.borderTop=q+"px solid "+k.uiStyleSettings.toolboxColor,Le.style.flexGrow="2",Ee.appendChild(Le),B.appendChild(Ee),k.widthBoxes.push(B)}),H},w.prototype.setCurrentWidth=function(k,H){var q=this;this.currentWidth=k,this.widthBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},w}(C),L=function(W){function w(k,H,q,B){var he=W.call(this,k,B||'<svg viewBox="0 0 24 24"><path d="M3 16h5v-2H3v2m6.5 0h5v-2h-5v2m6.5 0h5v-2h-5v2M3 20h2v-2H3v2m4 0h2v-2H7v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2m4 0h2v-2h-2v2M3 12h8v-2H3v2m10 0h8v-2h-8v2M3 4v4h18V4H3z"/></svg>')||this;return he.styles=[],he.styleBoxes=[],he.styles=H,he.currentStyle=q,he.setCurrentStyle=he.setCurrentStyle.bind(he),he}return J(w,W),w.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",this.styles.forEach(function(q){var B=document.createElement("div");B.style.display="flex",B.style.alignItems="center",B.style.justifyContent="space-between",B.style.padding="5px",B.style.borderWidth="2px",B.style.borderStyle="solid",B.style.overflow="hidden",B.style.maxWidth=100/k.styles.length-5+"%",B.style.borderColor=q===k.currentStyle?k.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){k.setCurrentStyle(q,B)}),H.appendChild(B);var he=document.createElement("div");he.style.minHeight="20px",he.style.flexGrow="2",he.style.overflow="hidden";var Ee=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+k.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(q!==""?'stroke-dasharray="'+q+'"':"")+` />
</svg>`;he.innerHTML=Ee,B.appendChild(he),k.styleBoxes.push(B)}),H},w.prototype.setCurrentStyle=function(k,H){var q=this;this.currentStyle=k,this.styleBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},w}(C),g=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.strokeColor=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.strokePanel=new S("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new L("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return J(w,W),Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=w.typeName,k},w.typeName="FrameMarker",w.title="Frame marker",w.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',w}(m),d=function(){this.defaultColorSet=["#EF4444","#10B981","#2563EB","#FFFF00","#7C3AED","#F472B6","#000000","#FFFFFF"],this.defaultColor=this.defaultColorSet[0],this.defaultFillColor=this.defaultColorSet[0],this.defaultStrokeColor=this.defaultColorSet[7],this.defaultHighlightColor=this.defaultColorSet[3],this.defaultStrokeWidth=3,this.defaultStrokeDasharray="",this.defaultHighlightOpacity=.5,this.defaultFontFamily="Helvetica, Arial, sans-serif",this.defaultStrokeWidths=[1,2,3,5,10],this.defaultStrokeDasharrays=["","3","12 3","9 6 3 6"],this.defaultOpacitySteps=[.1,.25,.5,.75,1],this.displayMode="inline",this.defaultFontFamilies=['Times, "Times New Roman", serif',"Helvetica, Arial, sans-serif",'Courier, "Courier New", monospace',"cursive","fantasy"],this.popupMargin=30,this.newFreehandMarkerOnPointerUp=!1,this.defaultColorsFollowCurrentColors=!1,this.freehandPixelRatio=1,this.disableRotation=!1},c=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.x1=0,B.y1=0,B.x2=0,B.y2=0,B.defaultLength=50,B.manipulationStartX=0,B.manipulationStartY=0,B.manipulationStartX1=0,B.manipulationStartY1=0,B.manipulationStartX2=0,B.manipulationStartY2=0,B.setupControlBox(),B}return J(w,W),w.prototype.ownsTarget=function(k){return!!W.prototype.ownsTarget.call(this,k)||!(!this.grip1.ownsTarget(k)&&!this.grip2.ownsTarget(k))},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.manipulationStartX=k.x,this.manipulationStartY=k.y,this.state==="new"&&(this.x1=k.x,this.y1=k.y,this.x2=k.x,this.y2=k.y),this.manipulationStartX1=this.x1,this.manipulationStartY1=this.y1,this.manipulationStartX2=this.x2,this.manipulationStartY2=this.y2,this.state!=="new"&&(this.select(),this.grip1.ownsTarget(H)?this.activeGrip=this.grip1:this.grip2.ownsTarget(H)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},w.prototype.pointerUp=function(k){var H=this.state;W.prototype.pointerUp.call(this,k),this.state==="creating"&&Math.abs(this.x1-this.x2)<10&&Math.abs(this.y1-this.y2)<10?(this.x2=this.x1+this.defaultLength,this.adjustVisual(),this.adjustControlBox()):this.manipulate(k),this._state="select",H==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},w.prototype.adjustVisual=function(){},w.prototype.manipulate=function(k){this.state==="creating"?this.resize(k):this.state==="move"?(this.x1=this.manipulationStartX1+k.x-this.manipulationStartX,this.y1=this.manipulationStartY1+k.y-this.manipulationStartY,this.x2=this.manipulationStartX2+k.x-this.manipulationStartX,this.y2=this.manipulationStartY2+k.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(k)},w.prototype.resize=function(k){switch(this.activeGrip){case this.grip1:this.x1=k.x,this.y1=k.y;break;case this.grip2:case void 0:this.x2=k.x,this.y2=k.y}this.adjustVisual(),this.adjustControlBox()},w.prototype.select=function(){W.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},w.prototype.deselect=function(){W.prototype.deselect.call(this),this.controlBox.style.display="none"},w.prototype.setupControlBox=function(){this.controlBox=D.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},w.prototype.adjustControlBox=function(){this.positionGrips()},w.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},w.prototype.createGrip=function(){var k=new s;return k.visual.transform.baseVal.appendItem(D.createTransform()),this.controlBox.appendChild(k.visual),k},w.prototype.positionGrips=function(){var k=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-k/2,this.y1-k/2),this.positionGrip(this.grip2.visual,this.x2-k/2,this.y2-k/2)},w.prototype.positionGrip=function(k,H,q){var B=k.transform.baseVal.getItem(0);B.setTranslate(H,q),k.transform.baseVal.replaceItem(B,0)},w.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},W.prototype.getState.call(this))},w.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.x1=H.x1,this.y1=H.y1,this.x2=H.x2,this.y2=H.y2},w.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.x1=this.x1*k,this.y1=this.y1*H,this.x2=this.x2*k,this.y2=this.y2*H,this.adjustVisual(),this.adjustControlBox()},w}(u),h=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.strokeColor="transparent",B.strokeWidth=0,B.strokeDasharray="",B.setStrokeColor=B.setStrokeColor.bind(B),B.setStrokeWidth=B.setStrokeWidth.bind(B),B.setStrokeDasharray=B.setStrokeDasharray.bind(B),B.strokeColor=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.strokePanel=new S("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new L("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return J(w,W),w.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.selectorLine&&k!==this.visibleLine)},w.prototype.createVisual=function(){this.visual=D.createGroup(),this.selectorLine=D.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=D.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.visual.appendChild(this.selectorLine),this.visual.appendChild(this.visibleLine),this.addMarkerVisualToContainer(this.visual)},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},w.prototype.adjustVisual=function(){this.selectorLine&&this.visibleLine&&(this.selectorLine.setAttribute("x1",this.x1.toString()),this.selectorLine.setAttribute("y1",this.y1.toString()),this.selectorLine.setAttribute("x2",this.x2.toString()),this.selectorLine.setAttribute("y2",this.y2.toString()),this.visibleLine.setAttribute("x1",this.x1.toString()),this.visibleLine.setAttribute("y1",this.y1.toString()),this.visibleLine.setAttribute("x2",this.x2.toString()),this.visibleLine.setAttribute("y2",this.y2.toString()),D.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),D.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),D.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},w.prototype.setStrokeColor=function(k){this.strokeColor=k,this.adjustVisual(),this.colorChanged(k)},w.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.adjustVisual()},w.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.adjustVisual(),this.stateChanged()},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},W.prototype.getState.call(this));return k.typeName=w.typeName,k},w.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.createVisual(),this.adjustVisual()},w.typeName="LineMarker",w.title="Line marker",w.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',w}(c),a=function(W){function w(k,H,q,B){var he=W.call(this,k,B||'<svg viewBox="0 0 24 24"><path d="M17 8h3v12h1v1h-4v-1h1v-3h-4l-1.5 3H14v1h-4v-1h1l6-12m1 1l-3.5 7H18V9M5 3h5c1.11 0 2 .89 2 2v11H9v-5H6v5H3V5c0-1.11.89-2 2-2m1 2v4h3V5H6z"/></svg>')||this;return he.fonts=[],he.fontBoxes=[],he.fonts=H,he.currentFont=q,he.setCurrentFont=he.setCurrentFont.bind(he),he}return J(w,W),w.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.overflow="hidden",H.style.flexGrow="2",this.fonts.forEach(function(q){var B=document.createElement("div");B.style.display="inline-block",B.style.alignItems="center",B.style.justifyContent="space-between",B.style.padding="5px",B.style.borderWidth="2px",B.style.borderStyle="solid",B.style.overflow="hidden",B.style.maxWidth=100/k.fonts.length-5+"%",B.style.borderColor=q===k.currentFont?k.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){k.setCurrentFont(q,B)}),H.appendChild(B);var he=document.createElement("div");he.style.display="flex",he.style.minHeight="20px",he.style.flexGrow="2",he.style.fontFamily=q,he.style.overflow="hidden";var Ee=document.createElement("div");Ee.style.whiteSpace="nowrap",Ee.style.overflow="hidden",Ee.style.textOverflow="ellipsis",Ee.innerHTML="The quick brown fox jumps over the lazy dog",he.appendChild(Ee),B.appendChild(he),k.fontBoxes.push(B)}),H},w.prototype.setCurrentFont=function(k,H){var q=this;this.currentFont=k,this.fontBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},w}(C),x=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.color="transparent",B.padding=5,B.DEFAULT_TEXT="your text here",B.text=B.DEFAULT_TEXT,B.isMoved=!1,B.color=q.defaultColor,B.fontFamily=q.defaultFontFamily,B.defaultSize={x:100,y:30},B.setColor=B.setColor.bind(B),B.setFont=B.setFont.bind(B),B.renderText=B.renderText.bind(B),B.sizeText=B.sizeText.bind(B),B.textEditDivClicked=B.textEditDivClicked.bind(B),B.showTextEditor=B.showTextEditor.bind(B),B.setSize=B.setSize.bind(B),B.positionTextEditor=B.positionTextEditor.bind(B),B.colorPanel=new S("Color",q.defaultColorSet,q.defaultColor),B.colorPanel.onColorChanged=B.setColor,B.fontFamilyPanel=new a("Font",q.defaultFontFamilies,q.defaultFontFamily),B.fontFamilyPanel.onFontChanged=B.setFont,B}return J(w,W),w.prototype.ownsTarget=function(k){if(W.prototype.ownsTarget.call(this,k)||k===this.visual||k===this.textElement||k===this.bgRectangle)return!0;var H=!1;return this.textElement.childNodes.forEach(function(q){q===k&&(H=!0)}),H},w.prototype.createVisual=function(){this.visual=D.createGroup(),this.bgRectangle=D.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=D.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(D.createTransform()),this.textElement.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.isMoved=!1,this.pointerDownPoint=k,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},w.prototype.renderText=function(){var k=this;if(this.textElement){for(;this.textElement.lastChild;)this.textElement.removeChild(this.textElement.lastChild);this.text.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/).forEach(function(H){k.textElement.appendChild(D.createTSpan(H.trim()===""?" ":H.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},w.prototype.getTextScale=function(){var k=this.textElement.getBBox(),H=1;if(k.width>0&&k.height>0){var q=(1*this.width-this.width*this.padding*2/100)/k.width,B=(1*this.height-this.height*this.padding*2/100)/k.height;H=Math.min(q,B)}return H},w.prototype.getTextPosition=function(k){var H=this.textElement.getBBox(),q=0,B=0;return H.width>0&&H.height>0&&(q=(this.width-H.width*k)/2,B=this.height/2-H.height*k/2),{x:q,y:B}},w.prototype.sizeText=function(){var k=this.textElement.getBBox(),H=this.getTextScale(),q=this.getTextPosition(H);q.y-=k.y*H,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+q.x+"px, "+q.y+"px) scale("+H+", "+H+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(q.x,q.y),this.textElement.transform.baseVal.getItem(1).setScale(H,H))},w.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(k.x-this.pointerDownPoint.x)>5||Math.abs(k.y-this.pointerDownPoint.y)>5)},w.prototype.resize=function(k){W.prototype.resize.call(this,k),this.isMoved=!0,this.setSize(),this.sizeText()},w.prototype.setSize=function(){W.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(D.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),D.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},w.prototype.pointerUp=function(k){var H=this.state;H==="creating"&&(this._suppressMarkerCreateEvent=!0),W.prototype.pointerUp.call(this,k),this.setSize(),(H==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},w.prototype.showTextEditor=function(){var k=this;this._state="edit",this.overlayContainer.innerHTML="",this.textEditDiv=document.createElement("div"),this.textEditDiv.style.flexGrow="2",this.textEditDiv.style.alignItems="center",this.textEditDiv.style.justifyContent="center",this.textEditDiv.style.pointerEvents="auto",this.textEditDiv.style.overflow="hidden",this.textEditor=document.createElement("div"),this.textEditor.style.position="absolute",this.textEditor.style.fontFamily=this.fontFamily,this.textEditor.style.lineHeight="1em",this.textEditor.innerText=this.text,this.textEditor.contentEditable="true",this.textEditor.style.color=this.color,this.textEditor.style.whiteSpace="pre",this.positionTextEditor(),this.textEditor.addEventListener("pointerup",function(H){H.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var H=Number.parseFloat(k.textEditor.style.fontSize);k.textEditor.clientWidth>=Number.parseInt(k.textEditor.style.maxWidth)&&H>.9;)H-=.1,k.textEditor.style.fontSize=Math.max(H,.9)+"em"}),this.textEditor.addEventListener("keyup",function(H){H.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(H){if(H.clipboardData){var q=H.clipboardData.getData("text"),B=window.getSelection();if(!B.rangeCount)return!1;B.deleteFromDocument(),B.getRangeAt(0).insertNode(document.createTextNode(q)),H.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){k.textEditDivClicked(k.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},w.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var k=this.getTextScale(),H=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),q=this.textElement.getBBox(),B={x:q.width*k,y:q.height*k};H.x-=B.x/2,H.y-=B.y/2,this.textEditor.style.top=H.y+"px",this.textEditor.style.left=H.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-H.x+"px",this.textEditor.style.fontSize=Math.max(16*k,12)+"px",this.textElement.style.display="none"}},w.prototype.textEditDivClicked=function(k){this.text=k.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},w.prototype.select=function(){W.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},w.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),W.prototype.deselect.call(this)},w.prototype.dblClick=function(k,H){W.prototype.dblClick.call(this,k,H),this.showTextEditor()},w.prototype.setColor=function(k){this.textElement&&D.setAttributes(this.textElement,[["fill",k]]),this.color=k,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(k)},w.prototype.setFont=function(k){this.textElement&&D.setAttributes(this.textElement,[["font-family",k]]),this.fontFamily=k,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},w.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},w.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},W.prototype.getState.call(this));return k.typeName=w.typeName,k},w.prototype.restoreState=function(k){var H=k;this.color=H.color,this.fontFamily=H.fontFamily,this.padding=H.padding,this.text=H.text,this.createVisual(),W.prototype.restoreState.call(this,k),this.setSize()},w.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize(),this.sizeText(),this.positionTextEditor()},w.typeName="TextMarker",w.title="Text marker",w.icon='<svg viewBox="0 0 24 24"><path d="M9.6 14L12 7.7l2.4 6.3M11 5L5.5 19h2.2l1.1-3H15l1.1 3h2.2L13 5h-2z"/></svg>',w}(E),p=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.color="transparent",B.lineWidth=3,B.drawing=!1,B.pixelRatio=1,B.color=q.defaultColor,B.lineWidth=q.defaultStrokeWidth,B.pixelRatio=q.freehandPixelRatio,B.setColor=B.setColor.bind(B),B.addCanvas=B.addCanvas.bind(B),B.finishCreation=B.finishCreation.bind(B),B.setLineWidth=B.setLineWidth.bind(B),B.colorPanel=new S("Color",q.defaultColorSet,q.defaultColor),B.colorPanel.onColorChanged=B.setColor,B.lineWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.lineWidthPanel.onWidthChanged=B.setLineWidth,B}return J(w,W),w.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.drawingImage)},w.prototype.createVisual=function(){this.visual=D.createGroup(),this.drawingImage=D.createImage(),this.visual.appendChild(this.drawingImage);var k=D.createTransform();this.visual.transform.baseVal.appendItem(k),this.addMarkerVisualToContainer(this.visual)},w.prototype.pointerDown=function(k,H){this.state==="new"&&(this.addCanvas(),this.createVisual(),this._state="creating"),this.state==="creating"?(this.canvasContext.strokeStyle=this.color,this.canvasContext.lineWidth=this.lineWidth,this.canvasContext.beginPath(),this.canvasContext.moveTo(k.x,k.y),this.drawing=!0):W.prototype.pointerDown.call(this,k,H)},w.prototype.manipulate=function(k){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(k.x,k.y),this.canvasContext.stroke()):W.prototype.manipulate.call(this,k)},w.prototype.resize=function(k){W.prototype.resize.call(this,k),D.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),D.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},w.prototype.pointerUp=function(k){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):W.prototype.pointerUp.call(this,k)},w.prototype.addCanvas=function(){this.overlayContainer.innerHTML="",this.canvasElement=document.createElement("canvas"),this.canvasElement.width=this.overlayContainer.clientWidth*this.pixelRatio,this.canvasElement.height=this.overlayContainer.clientHeight*this.pixelRatio,this.canvasContext=this.canvasElement.getContext("2d"),this.canvasContext.scale(this.pixelRatio,this.pixelRatio),this.overlayContainer.appendChild(this.canvasElement)},w.prototype.select=function(){this.state==="creating"&&this.finishCreation(),W.prototype.select.call(this)},w.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),W.prototype.deselect.call(this)},w.prototype.finishCreation=function(){for(var k=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),H=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],q=H[0],B=H[1],he=H[2],Ee=H[3],Le=!1,Ie=0;Ie<this.canvasElement.height;Ie++)for(var _e=0;_e<this.canvasElement.width;_e++)k.data[Ie*this.canvasElement.width*4+4*_e+3]>0&&(Le=!0,Ie<B&&(B=Ie),_e<q&&(q=_e),Ie>Ee&&(Ee=Ie),_e>he&&(he=_e));if(Le){this.left=q/this.pixelRatio,this.top=B/this.pixelRatio,this.width=(he-q)/this.pixelRatio,this.height=(Ee-B)/this.pixelRatio;var De=document.createElement("canvas");De.width=he-q,De.height=Ee-B,De.getContext("2d").putImageData(this.canvasContext.getImageData(q,B,he-q,Ee-B),0,0),this.drawingImgUrl=De.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},w.prototype.setDrawingImage=function(){D.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),D.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},w.prototype.setColor=function(k){this.color=k,this.colorChanged(k)},w.prototype.setLineWidth=function(k){this.lineWidth=k},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=Object.assign({drawingImgUrl:this.drawingImgUrl},W.prototype.getState.call(this));return k.typeName=w.typeName,k},w.prototype.restoreState=function(k){this.createVisual(),W.prototype.restoreState.call(this,k),this.drawingImgUrl=k.drawingImgUrl,this.setDrawingImage()},w.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setDrawingImage()},w.typeName="FreehandMarker",w.title="Freehand marker",w.icon='<svg viewBox="0 0 24 24"><path d="M9.75 20.85c1.78-.7 1.39-2.63.49-3.85-.89-1.25-2.12-2.11-3.36-2.94A9.817 9.817 0 014.54 12c-.28-.33-.85-.94-.27-1.06.59-.12 1.61.46 2.13.68.91.38 1.81.82 2.65 1.34l1.01-1.7C8.5 10.23 6.5 9.32 4.64 9.05c-1.06-.16-2.18.06-2.54 1.21-.32.99.19 1.99.77 2.77 1.37 1.83 3.5 2.71 5.09 4.29.34.33.75.72.95 1.18.21.44.16.47-.31.47-1.24 0-2.79-.97-3.8-1.61l-1.01 1.7c1.53.94 4.09 2.41 5.96 1.79m11.09-15.6c.22-.22.22-.58 0-.79l-1.3-1.3a.562.562 0 00-.78 0l-1.02 1.02 2.08 2.08M11 10.92V13h2.08l6.15-6.15-2.08-2.08L11 10.92z"/></svg>',w}(E),b=function(W){function w(k,H,q){var B=W.call(this,k,q||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return B.typeBoxes=[],B.currentType=H,B.setCurrentType=B.setCurrentType.bind(B),B}return J(w,W),w.prototype.getUi=function(){var k=this,H=document.createElement("div");H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2";for(var q=function(Ee){var Le="both";switch(Ee){case 0:Le="both";break;case 1:Le="start";break;case 2:Le="end";break;case 3:Le="none"}var Ie=document.createElement("div");if(Ie.style.display="flex",Ie.style.flexGrow="2",Ie.style.alignItems="center",Ie.style.justifyContent="space-between",Ie.style.padding="5px",Ie.style.borderWidth="2px",Ie.style.borderStyle="solid",Ie.style.borderColor=Le===B.currentType?B.uiStyleSettings.toolboxAccentColor:"transparent",Ie.addEventListener("click",function(){k.setCurrentType(Le,Ie)}),H.appendChild(Ie),Le==="both"||Le==="start"){var _e=document.createElement("div");_e.style.display="flex",_e.style.alignItems="center",_e.style.minHeight="20px",_e.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,5 10,0 10,10" fill="`+(B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,_e.style.marginLeft="5px",Ie.appendChild(_e)}var De=document.createElement("div");De.style.display="flex",De.style.alignItems="center",De.style.minHeight="20px",De.style.flexGrow="2";var Pe=document.createElement("hr");if(Pe.style.minWidth="20px",Pe.style.border="0px",Pe.style.borderTop="3px solid "+(B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxColor:"#eeeeee"),Pe.style.flexGrow="2",De.appendChild(Pe),Ie.appendChild(De),Le==="both"||Le==="end"){var je=document.createElement("div");je.style.display="flex",je.style.alignItems="center",je.style.minHeight="20px",je.innerHTML=`<svg viewBox="0 0 10 10" width="10" height="10" xmlns="http://www.w3.org/2000/svg">
<polygon points="0,0 10,5 0,10" fill="`+(B.uiStyleSettings!==void 0?B.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,je.style.marginRight="5px",Ie.appendChild(je)}B.typeBoxes.push(Ie)},B=this,he=0;he<4;he++)q(he);return H},w.prototype.setCurrentType=function(k,H){var q=this;this.currentType=k,this.typeBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings!==void 0?q.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},w}(C),M=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.arrowType="end",B.arrowBaseHeight=10,B.arrowBaseWidth=10,B.getArrowPoints=B.getArrowPoints.bind(B),B.setArrowType=B.setArrowType.bind(B),B.arrowTypePanel=new b("Arrow type","end"),B.arrowTypePanel.onArrowTypeChanged=B.setArrowType,B}return J(w,W),w.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.arrow1&&k!==this.arrow2)},w.prototype.getArrowPoints=function(k,H){var q=this.arrowBaseWidth+2*this.strokeWidth,B=this.arrowBaseHeight+2*this.strokeWidth;return k-q/2+","+(H+B/2)+" "+k+","+(H-B/2)+" "+(k+q/2)+","+(H+B/2)},w.prototype.createTips=function(){this.arrow1=D.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=D.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.arrow2)},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="creating"&&this.createTips()},w.prototype.adjustVisual=function(){if(W.prototype.adjustVisual.call(this),this.arrow1&&this.arrow2&&(this.arrow1.style.display=this.arrowType==="both"||this.arrowType==="start"?"":"none",this.arrow2.style.display=this.arrowType==="both"||this.arrowType==="end"?"":"none",D.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),D.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var k=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),H=this.arrow1.transform.baseVal.getItem(0);H.setRotate(k,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(H,0);var q=this.arrow2.transform.baseVal.getItem(0);q.setRotate(k+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(q,0)}},w.prototype.setArrowType=function(k){this.arrowType=k,this.adjustVisual(),this.stateChanged()},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=Object.assign({arrowType:this.arrowType},W.prototype.getState.call(this));return k.typeName=w.typeName,k},w.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.arrowType=H.arrowType,this.createTips(),this.adjustVisual()},w.typeName="ArrowMarker",w.title="Arrow marker",w.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',w}(h),G=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.fillColor=q.defaultFillColor,B.strokeWidth=0,B.fillPanel=new S("Color",q.defaultColorSet,q.defaultFillColor),B.fillPanel.onColorChanged=B.setFillColor,B}return J(w,W),Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=w.typeName,k},w.typeName="CoverMarker",w.title="Cover marker",w.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',w}(m),Z=function(W){function w(k,H,q,B){var he=W.call(this,k,B||'<svg viewBox="0 0 24 24"><path d="M17.66 8L12 2.35 6.34 8A8.02 8.02 0 004 13.64c0 2 .78 4.11 2.34 5.67a7.99 7.99 0 0011.32 0c1.56-1.56 2.34-3.67 2.34-5.67S19.22 9.56 17.66 8M6 14c0-2 .62-3.27 1.76-4.4L12 5.27l4.24 4.38C17.38 10.77 18 12 18 14H6z"/></svg>')||this;return he.opacities=[],he.opacityBoxes=[],he.opacities=H,he.currentOpacity=q,he.setCurrentOpacity=he.setCurrentOpacity.bind(he),he}return J(w,W),w.prototype.getUi=function(){var k=this,H=document.createElement("div");return H.style.display="flex",H.style.overflow="hidden",H.style.flexGrow="2",H.style.justifyContent="space-between",this.opacities.forEach(function(q){var B=document.createElement("div");B.style.display="flex",B.style.alignItems="center",B.style.justifyContent="center",B.style.padding="5px",B.style.borderWidth="2px",B.style.borderStyle="solid",B.style.borderColor=q===k.currentOpacity?k.uiStyleSettings.toolboxAccentColor:"transparent",B.addEventListener("click",function(){k.setCurrentOpacity(q,B)}),H.appendChild(B);var he=document.createElement("div");he.innerText=100*q+"%",B.appendChild(he),k.opacityBoxes.push(B)}),H},w.prototype.setCurrentOpacity=function(k,H){var q=this;this.currentOpacity=k,this.opacityBoxes.forEach(function(B){B.style.borderColor=B===H?q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},w}(C),ie=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.setOpacity=B.setOpacity.bind(B),B.fillColor=q.defaultHighlightColor,B.strokeWidth=0,B.opacity=q.defaultHighlightOpacity,B.fillPanel=new S("Color",q.defaultColorSet,B.fillColor),B.fillPanel.onColorChanged=B.setFillColor,B.opacityPanel=new Z("Opacity",q.defaultOpacitySteps,B.opacity),B.opacityPanel.onOpacityChanged=B.setOpacity,B}return J(w,W),w.prototype.setOpacity=function(k){this.opacity=k,this.visual&&D.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=w.typeName,k},w.typeName="HighlightMarker",w.title="Highlight marker",w.icon='<svg viewBox="0 0 24 24"><path d="M18.5 1.15c-.53 0-1.04.19-1.43.58l-5.81 5.82 5.65 5.65 5.82-5.81c.77-.78.77-2.04 0-2.83l-2.84-2.83c-.39-.39-.89-.58-1.39-.58M10.3 8.5l-5.96 5.96c-.78.78-.78 2.04.02 2.85C3.14 18.54 1.9 19.77.67 21h5.66l.86-.86c.78.76 2.03.75 2.81-.02l5.95-5.96"/></svg>',w}(G),z='<svg viewBox="0 0 24 24"><path d="M19 11.5s-2 2.17-2 3.5a2 2 0 002 2 2 2 0 002-2c0-1.33-2-3.5-2-3.5M5.21 10L10 5.21 14.79 10m1.77-1.06L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.56-.59 1.53 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.59.59-1.56 0-2.12z"/></svg>',F=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.bgColor="transparent",B.tipPosition={x:0,y:0},B.tipBase1Position={x:0,y:0},B.tipBase2Position={x:0,y:0},B.tipMoving=!1,B.color=q.defaultStrokeColor,B.bgColor=q.defaultFillColor,B.fontFamily=q.defaultFontFamily,B.defaultSize={x:100,y:30},B.setBgColor=B.setBgColor.bind(B),B.getTipPoints=B.getTipPoints.bind(B),B.positionTip=B.positionTip.bind(B),B.setTipPoints=B.setTipPoints.bind(B),B.colorPanel=new S("Text color",q.defaultColorSet,B.color,'<svg viewBox="0 0 24 24"><path d="M9.62 12L12 5.67 14.37 12M11 3L5.5 17h2.25l1.12-3h6.25l1.13 3h2.25L13 3h-2z"/></svg>'),B.colorPanel.onColorChanged=B.setColor,B.bgColorPanel=new S("Fill color",q.defaultColorSet,B.bgColor,z),B.bgColorPanel.onColorChanged=B.setBgColor,B.fontFamilyPanel=new a("Font",q.defaultFontFamilies,q.defaultFontFamily),B.fontFamilyPanel.onFontChanged=B.setFont,B.tipGrip=new s,B.tipGrip.visual.transform.baseVal.appendItem(D.createTransform()),B.controlBox.appendChild(B.tipGrip.visual),B}return J(w,W),w.prototype.ownsTarget=function(k){return W.prototype.ownsTarget.call(this,k)||this.tipGrip.ownsTarget(k)||this.tip===k},w.prototype.createTip=function(){D.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=D.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},w.prototype.pointerDown=function(k,H){this.state==="new"&&W.prototype.pointerDown.call(this,k,H),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(H)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):W.prototype.pointerDown.call(this,k,H)},w.prototype.pointerUp=function(k){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,W.prototype.pointerUp.call(this,k);else{var H=this.state==="creating";W.prototype.pointerUp.call(this,k),this.setTipPoints(H),this.positionTip()}},w.prototype.manipulate=function(k){if(this.tipMoving){var H=this.unrotatePoint(k);this.tipPosition={x:H.x-this.manipulationStartLeft,y:H.y-this.manipulationStartTop},this.positionTip()}else W.prototype.manipulate.call(this,k)},w.prototype.setBgColor=function(k){this.bgRectangle&&this.tip&&(D.setAttributes(this.bgRectangle,[["fill",k]]),D.setAttributes(this.tip,[["fill",k]])),this.bgColor=k,this.fillColorChanged(k)},w.prototype.getTipPoints=function(){return this.setTipPoints(this.state==="creating"),this.tipBase1Position.x+","+this.tipBase1Position.y+" "+this.tipBase2Position.x+","+this.tipBase2Position.y+" "+this.tipPosition.x+","+this.tipPosition.y},w.prototype.setTipPoints=function(k){k===void 0&&(k=!1);var H=Math.min(this.height/2,15),q=this.height/5;k&&(this.tipPosition={x:H+q/2,y:this.height+20});var B=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?B<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(q=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:H,y:0},this.tipBase2Position={x:H+q,y:0}):(this.tipBase1Position={x:0,y:H},this.tipBase2Position={x:0,y:H+q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?B<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(q=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-H-q,y:0},this.tipBase2Position={x:this.width-H,y:0}):(this.tipBase1Position={x:this.width,y:H},this.tipBase2Position={x:this.width,y:H+q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?B<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(q=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-H-q,y:this.height},this.tipBase2Position={x:this.width-H,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-H-q},this.tipBase2Position={x:this.width,y:this.height-H}):B<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(q=this.width/5,H=Math.min(this.width/2,15),this.tipBase1Position={x:H,y:this.height},this.tipBase2Position={x:H+q,y:this.height}):(this.tipBase1Position={x:0,y:this.height-H},this.tipBase2Position={x:0,y:this.height-H-q})},w.prototype.resize=function(k){W.prototype.resize.call(this,k),this.positionTip()},w.prototype.positionTip=function(){D.setAttributes(this.tip,[["points",this.getTipPoints()]]);var k=this.tipGrip.visual.transform.baseVal.getItem(0);k.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(k,0)},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),w.prototype.select=function(){this.positionTip(),W.prototype.select.call(this)},w.prototype.getState=function(){var k=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},W.prototype.getState.call(this));return k.typeName=w.typeName,k},w.prototype.restoreState=function(k){var H=k;this.bgColor=H.bgColor,this.tipPosition=H.tipPosition,W.prototype.restoreState.call(this,k),this.createTip(),this.setTipPoints()},w.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.tipPosition={x:this.tipPosition.x*k,y:this.tipPosition.y*H},this.positionTip()},w.typeName="CalloutMarker",w.title="Callout marker",w.icon='<svg viewBox="0 0 24 24"><path d="M4 2h16a2 2 0 012 2v12a2 2 0 01-2 2h-4l-4 4-4-4H4a2 2 0 01-2-2V4a2 2 0 012-2m0 2v12h4.83L12 19.17 15.17 16H20V4H4m2 3h12v2H6V7m0 4h10v2H6v-2z"/></svg>',w}(x),ne=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.fillColor="transparent",B.strokeColor="transparent",B.strokeWidth=0,B.strokeDasharray="",B.opacity=1,B.strokeColor=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.fillColor=q.defaultFillColor,B.setStrokeColor=B.setStrokeColor.bind(B),B.setFillColor=B.setFillColor.bind(B),B.setStrokeWidth=B.setStrokeWidth.bind(B),B.setStrokeDasharray=B.setStrokeDasharray.bind(B),B.setOpacity=B.setOpacity.bind(B),B.createVisual=B.createVisual.bind(B),B.strokePanel=new S("Line color",I(q.defaultColorSet,["transparent"]),q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.fillPanel=new S("Fill color",I(q.defaultColorSet,["transparent"]),B.fillColor,z),B.fillPanel.onColorChanged=B.setFillColor,B.strokeWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new L("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B.opacityPanel=new Z("Opacity",q.defaultOpacitySteps,B.opacity),B.opacityPanel.onOpacityChanged=B.setOpacity,B}return J(w,W),w.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual)},w.prototype.createVisual=function(){this.visual=D.createEllipse(this.width/2,this.height/2,[["fill",this.fillColor],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["stroke-dasharray",this.strokeDasharray],["opacity",this.opacity.toString()]]),this.addMarkerVisualToContainer(this.visual)},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="new"&&(this.createVisual(),this.moveVisual(k),this._state="creating")},w.prototype.manipulate=function(k){W.prototype.manipulate.call(this,k)},w.prototype.resize=function(k){W.prototype.resize.call(this,k),this.setSize()},w.prototype.setSize=function(){W.prototype.setSize.call(this),D.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},w.prototype.pointerUp=function(k){W.prototype.pointerUp.call(this,k),this.setSize()},w.prototype.setStrokeColor=function(k){this.strokeColor=k,this.visual&&D.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(k),this.stateChanged()},w.prototype.setFillColor=function(k){this.fillColor=k,this.visual&&D.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(k),this.stateChanged()},w.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.visual&&D.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},w.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.visual&&D.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},w.prototype.setOpacity=function(k){this.opacity=k,this.visual&&D.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},W.prototype.getState.call(this));return k.typeName=w.typeName,k},w.prototype.restoreState=function(k){var H=k;this.fillColor=H.fillColor,this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.opacity=H.opacity,this.createVisual(),W.prototype.restoreState.call(this,k),this.setSize()},w.prototype.scale=function(k,H){W.prototype.scale.call(this,k,H),this.setSize()},w.typeName="EllipseMarker",w.title="Ellipse marker",w.icon='<svg viewBox="0 0 24 24"><path d="M12 4C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',w}(E),ce=function(W){function w(k,H,q){return W.call(this,k,H,q)||this}return J(w,W),Object.defineProperty(w.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),w.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.tip1&&k!==this.tip2)},w.prototype.createTips=function(){this.tip1=D.createLine(this.x1-this.tipLength/2,this.y1,this.x1+this.tipLength/2,this.y1,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip1.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.tip1),this.tip2=D.createLine(this.x2-this.tipLength/2,this.y2,this.x2+this.tipLength/2,this.y2,[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),this.tip2.transform.baseVal.appendItem(D.createTransform()),this.visual.appendChild(this.tip2)},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.state==="creating"&&this.createTips()},w.prototype.adjustVisual=function(){if(W.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(D.setAttributes(this.tip1,[["x1",(this.x1-this.tipLength/2).toString()],["y1",this.y1.toString()],["x2",(this.x1+this.tipLength/2).toString()],["y2",this.y1.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),D.setAttributes(this.tip2,[["x1",(this.x2-this.tipLength/2).toString()],["y1",this.y2.toString()],["x2",(this.x2+this.tipLength/2).toString()],["y2",this.y2.toString()],["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()]]),Math.abs(this.x1-this.x2)>.1)){var k=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),H=this.tip1.transform.baseVal.getItem(0);H.setRotate(k,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(H,0);var q=this.tip2.transform.baseVal.getItem(0);q.setRotate(k+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(q,0)}},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=w.typeName,k},w.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k),this.createTips(),this.adjustVisual()},w.typeName="MeasurementMarker",w.title="Measurement marker",w.icon='<svg viewBox="0 0 24 24"><path d="M1.39 18.36l1.77-1.76L4.58 18l1.06-1.05-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.42 1.41L10.59 12l-1.42-1.41 1.42-1.42 2.47 2.48 1.06-1.06-2.47-2.48 1.41-1.41 1.41 1.41 1.07-1.06-1.42-1.41 1.42-1.42L18 6.7l1.07-1.06-2.47-2.48 1.76-1.77 4.25 4.25L5.64 22.61l-4.25-4.25z"/></svg>',w}(h),ge=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.strokePanel.colors=q.defaultColorSet,B.fillColor="transparent",B}return J(w,W),Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=W.prototype.getState.call(this);return k.typeName=w.typeName,k},w.typeName="EllipseFrameMarker",w.title="Ellipse frame marker",w.icon='<svg viewBox="0 0 24 24"><path d="M12 6c4.41 0 8 2.69 8 6s-3.59 6-8 6-8-2.69-8-6 3.59-6 8-6m0-2C6.5 4 2 7.58 2 12s4.5 8 10 8 10-3.58 10-8-4.5-8-10-8z"/></svg>',w}(ne),xe=function(){function W(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(W.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),W.prototype.addUndoStep=function(w){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(w)||(this.undoStack.push(w),JSON.stringify(this.lastRedoStep)!==JSON.stringify(w)&&this.redoStack.splice(0,this.redoStack.length))},W.prototype.replaceLastUndoStep=function(w){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=w)},W.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},W.prototype.undo=function(){if(this.undoStack.length>1){var w=this.undoStack.pop();return w!==void 0&&this.redoStack.push(w),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},W.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},W}(),Me=function(W){function w(k,H,q){var B=W.call(this,k,H,q)||this;return B.strokeColor="transparent",B.strokeWidth=0,B.strokeDasharray="",B.curveX=0,B.curveY=0,B.manipulationStartCurveX=0,B.manipulationStartCurveY=0,B.setStrokeColor=B.setStrokeColor.bind(B),B.setStrokeWidth=B.setStrokeWidth.bind(B),B.setStrokeDasharray=B.setStrokeDasharray.bind(B),B.positionGrips=B.positionGrips.bind(B),B.addControlGrips=B.addControlGrips.bind(B),B.adjustVisual=B.adjustVisual.bind(B),B.setupControlBox=B.setupControlBox.bind(B),B.resize=B.resize.bind(B),B.strokeColor=q.defaultColor,B.strokeWidth=q.defaultStrokeWidth,B.strokeDasharray=q.defaultStrokeDasharray,B.strokePanel=new S("Line color",q.defaultColorSet,q.defaultColor),B.strokePanel.onColorChanged=B.setStrokeColor,B.strokeWidthPanel=new f("Line width",q.defaultStrokeWidths,q.defaultStrokeWidth),B.strokeWidthPanel.onWidthChanged=B.setStrokeWidth,B.strokeStylePanel=new L("Line style",q.defaultStrokeDasharrays,q.defaultStrokeDasharray),B.strokeStylePanel.onStyleChanged=B.setStrokeDasharray,B}return J(w,W),w.prototype.ownsTarget=function(k){return!(!W.prototype.ownsTarget.call(this,k)&&k!==this.visual&&k!==this.selectorCurve&&k!==this.visibleCurve&&!this.curveGrip.ownsTarget(k))},w.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},w.prototype.createVisual=function(){this.visual=D.createGroup(),this.selectorCurve=D.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=D.createPath(this.getPathD(),[["stroke",this.strokeColor],["stroke-width",this.strokeWidth.toString()],["fill","transparent"]]),this.visual.appendChild(this.selectorCurve),this.visual.appendChild(this.visibleCurve),this.addMarkerVisualToContainer(this.visual)},w.prototype.pointerDown=function(k,H){W.prototype.pointerDown.call(this,k,H),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=k.x,this.curveY=k.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(H)&&(this.activeGrip=this.curveGrip,this._state="resize")},w.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),D.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),D.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),D.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},w.prototype.setupControlBox=function(){W.prototype.setupControlBox.call(this),this.curveControlLine1=D.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=D.createLine(this.x2,this.y2,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.controlBox.insertBefore(this.curveControlLine1,this.controlBox.firstChild),this.controlBox.insertBefore(this.curveControlLine2,this.controlBox.firstChild)},w.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,W.prototype.addControlGrips.call(this)},w.prototype.positionGrips=function(){W.prototype.positionGrips.call(this);var k=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-k/2,this.curveY-k/2),this.curveControlLine1&&this.curveControlLine2&&(this.curveControlLine1.setAttribute("x1",this.x1.toString()),this.curveControlLine1.setAttribute("y1",this.y1.toString()),this.curveControlLine1.setAttribute("x2",this.curveX.toString()),this.curveControlLine1.setAttribute("y2",this.curveY.toString()),this.curveControlLine2.setAttribute("x1",this.x2.toString()),this.curveControlLine2.setAttribute("y1",this.y2.toString()),this.curveControlLine2.setAttribute("x2",this.curveX.toString()),this.curveControlLine2.setAttribute("y2",this.curveY.toString()))},w.prototype.manipulate=function(k){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+k.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+k.y-this.manipulationStartY),W.prototype.manipulate.call(this,k)},w.prototype.resize=function(k){this.activeGrip===this.curveGrip&&(this.curveX=k.x,this.curveY=k.y),W.prototype.resize.call(this,k),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},w.prototype.setStrokeColor=function(k){this.strokeColor=k,this.adjustVisual(),this.colorChanged(k)},w.prototype.setStrokeWidth=function(k){this.strokeWidth=k,this.adjustVisual()},w.prototype.setStrokeDasharray=function(k){this.strokeDasharray=k,this.adjustVisual()},w.prototype.scale=function(k,H){this.curveX=this.curveX*k,this.curveY=this.curveY*H,W.prototype.scale.call(this,k,H)},Object.defineProperty(w.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),w.prototype.getState=function(){var k=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},W.prototype.getState.call(this));return k.typeName=w.typeName,k},w.prototype.restoreState=function(k){W.prototype.restoreState.call(this,k);var H=k;this.strokeColor=H.strokeColor,this.strokeWidth=H.strokeWidth,this.strokeDasharray=H.strokeDasharray,this.curveX=H.curveX,this.curveY=H.curveY,this.createVisual(),this.adjustVisual()},w.typeName="CurveMarker",w.title="Curve marker",w.icon='<svg viewBox="0 0 24 24"><path d="M18.5 2A1.5 1.5 0 0120 3.5 1.5 1.5 0 0118.5 5c-.23 0-.45-.05-.65-.15l-3.69 3.7.34.45c2.19-1.26 4.76-2 7.5-2l1 .03v2.01L22 9c-2.58 0-5 .75-7 2.04A3.96 3.96 0 0111.04 15C9.75 17 9 19.42 9 22l.04 1H7.03L7 22c0-2.74.74-5.31 2-7.5l-.45-.34-3.7 3.69c.1.2.15.42.15.65A1.5 1.5 0 013.5 20 1.5 1.5 0 012 18.5 1.5 1.5 0 013.5 17c.23 0 .45.05.65.15l3.69-3.7C7.31 12.78 7 11.92 7 11a4 4 0 014-4c.92 0 1.78.31 2.45.84l3.7-3.69c-.1-.2-.15-.42-.15-.65A1.5 1.5 0 0118.5 2M11 9a2 2 0 00-2 2 2 2 0 002 2 2 2 0 002-2 2 2 0 00-2-2z"/></svg>',w}(c),Te=function(){function W(w,k){k===void 0&&(k=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=w,this.cancelable=k}return Object.defineProperty(W.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),W.prototype.preventDefault=function(){this._defaultPrevented=!0},W}(),Oe=function(W){function w(k,H,q){var B=W.call(this,k,!1)||this;return B.dataUrl=H,B.state=q,B}return J(w,W),w}(Te),Ce=function(W){function w(k,H,q){q===void 0&&(q=!1);var B=W.call(this,k,q)||this;return B.marker=H,B}return J(w,W),w}(Te),we=function(){function W(){this.render=[],this.beforeclose=[],this.close=[],this.show=[],this.restorestate=[],this.statechange=[],this.markerselect=[],this.markerdeselect=[],this.markercreating=[],this.markercreate=[],this.markerbeforedelete=[],this.markerdelete=[],this.markerchange=[],this.focus=[],this.blur=[]}return W.prototype.addEventListener=function(w,k){this[w].push(k)},W.prototype.removeEventListener=function(w,k){var H=this[w].indexOf(k);H>-1&&this[w].splice(H,1)},W}(),ve=function(){function W(w){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new d,this._isOpen=!1,this.undoRedoManager=new xe,this.renderAtNaturalSize=!1,this.renderImageType="image/png",this.renderMarkersOnly=!1,this.zoomSteps=[1,1.5,2,4],this._zoomLevel=1,this._isResizing=!1,this.prevPanPoint={x:0,y:0},this.eventListeners=new we,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=W.instanceCounter++,this.styles=new O(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=w,this.targetRoot=document.body,this.width=w.clientWidth,this.height=w.clientHeight,this.styles.removeStyleSheet(),this.open=this.open.bind(this),this.setTopLeft=this.setTopLeft.bind(this),this.toolbarButtonClicked=this.toolbarButtonClicked.bind(this),this.createNewMarker=this.createNewMarker.bind(this),this.addNewMarker=this.addNewMarker.bind(this),this.markerCreated=this.markerCreated.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.onDblClick=this.onDblClick.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.overrideOverflow=this.overrideOverflow.bind(this),this.restoreOverflow=this.restoreOverflow.bind(this),this.close=this.close.bind(this),this.closeUI=this.closeUI.bind(this),this.addCloseEventListener=this.addCloseEventListener.bind(this),this.removeCloseEventListener=this.removeCloseEventListener.bind(this),this.addRenderEventListener=this.addRenderEventListener.bind(this),this.removeRenderEventListener=this.removeRenderEventListener.bind(this),this.clientToLocalCoordinates=this.clientToLocalCoordinates.bind(this),this.onWindowResize=this.onWindowResize.bind(this),this.deleteSelectedMarker=this.deleteSelectedMarker.bind(this),this.setWindowHeight=this.setWindowHeight.bind(this),this.removeMarker=this.removeMarker.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this),this.onPopupTargetResize=this.onPopupTargetResize.bind(this),this.showNotesEditor=this.showNotesEditor.bind(this),this.hideNotesEditor=this.hideNotesEditor.bind(this),this.stepZoom=this.stepZoom.bind(this),this.focus=this.focus.bind(this),this.blur=this.blur.bind(this),this.markerStateChanged=this.markerStateChanged.bind(this),this.switchToSelectMode=this.switchToSelectMode.bind(this),this.addDefs=this.addDefs.bind(this),this.addDefsToImage=this.addDefsToImage.bind(this)}return Object.defineProperty(W.prototype,"ALL_MARKER_TYPES",{get:function(){return[g,p,M,x,ge,ne,ie,F,ce,G,h,Me]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[g,p,M,x,ne,ie,F]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"BASIC_MARKER_TYPES",{get:function(){return[g,p,M,x,ie]},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(w){var k=this;this._availableMarkerTypes.splice(0),w.forEach(function(H){if(typeof H=="string"){var q=k.ALL_MARKER_TYPES.find(function(B){return B.typeName===H});q!==void 0&&k._availableMarkerTypes.push(q)}else k._availableMarkerTypes.push(H)})},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(w){this._zoomLevel=w,this.editorCanvas&&this.contentDiv&&(this.editorCanvas.style.transform="scale("+this._zoomLevel+")",this.contentDiv.scrollTo({left:(this.editorCanvas.clientWidth*this._zoomLevel-this.contentDiv.clientWidth)/2,top:(this.editorCanvas.clientHeight*this._zoomLevel-this.contentDiv.clientHeight)/2}))},enumerable:!1,configurable:!0}),Object.defineProperty(W.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),W.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),j.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},W.prototype.show=function(){var w=this;this.styles.styleSheetRoot===void 0&&P.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=P.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(k){return k(new Te(w))})},W.prototype.render=function(){return _(this,void 0,void 0,function(){var w;return $(this,function(k){switch(k.label){case 0:return this.setCurrentMarker(),(w=new U).naturalSize=this.renderAtNaturalSize,w.imageType=this.renderImageType,w.imageQuality=this.renderImageQuality,w.markersOnly=this.renderMarkersOnly,w.width=this.renderWidth,w.height=this.renderHeight,[4,w.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return k.sent(),[4,w.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,k.sent()]}})})},W.prototype.close=function(w){var k=this;if(w===void 0&&(w=!1),this.isOpen){var H=!1;w||this.eventListeners.beforeclose.forEach(function(q){var B=new Te(k,!0);q(B),B.defaultPrevented&&(H=!0)}),H||(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.settings.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),this.eventListeners.close.forEach(function(q){return q(new Te(k))}),this.detachEvents(),this._isOpen=!1)}},W.prototype.addMarkersToToolbar=function(){for(var w,k=[],H=0;H<arguments.length;H++)k[H]=arguments[H];(w=this._availableMarkerTypes).push.apply(w,k)},W.prototype.addRenderEventListener=function(w){this.addEventListener("render",function(k){w(k.dataUrl,k.state)})},W.prototype.removeRenderEventListener=function(w){},W.prototype.addCloseEventListener=function(w){this.addEventListener("close",function(){w()})},W.prototype.removeCloseEventListener=function(w){},W.prototype.setupResizeObserver=function(){var w=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){w.resize(w.target.clientWidth,w.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return w.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},W.prototype.onPopupTargetResize=function(){var w=1*this.target.clientWidth/this.target.clientHeight,k=this.editorCanvas.clientWidth/w>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*w:this.editorCanvas.clientWidth,H=k<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/w;this.resize(k,H)},W.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},W.prototype.resize=function(w,k){this._isResizing=!0;var H=w/this.imageWidth,q=k/this.imageHeight;this.imageWidth=Math.round(w),this.imageHeight=Math.round(k),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px",this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.settings.displayMode!=="popup"?this.coverDiv.style.width=this.imageWidth.toString()+"px":(this.setTopLeft(),this.positionMarkerImage()),this.toolbar!==void 0&&this.toolbar.adjustLayout(),this.positionLogo(),this.scaleMarkers(H,q),this._isResizing=!1},W.prototype.scaleMarkers=function(w,k){var H,q=this;this._currentMarker&&this._currentMarker instanceof x?this._currentMarker.scale(w,k):(H=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(B){B!==q._currentMarker&&B.scale(w,k)}),H!==void 0&&this.setCurrentMarker(H)},W.prototype.setEditingTarget=function(){this.imageWidth=Math.round(this.target.clientWidth),this.imageHeight=Math.round(this.target.clientHeight),this.target instanceof HTMLImageElement&&this.editingTarget instanceof HTMLImageElement&&(this.editingTarget.src=this.target.src),this.editingTarget.width=this.imageWidth,this.editingTarget.height=this.imageHeight,this.editingTarget.style.width=this.imageWidth+"px",this.editingTarget.style.height=this.imageHeight+"px"},W.prototype.setTopLeft=function(){var w=this.editingTarget.getBoundingClientRect(),k=this.editorCanvas.getBoundingClientRect();this.left=w.left-k.left,this.top=w.top-k.top},W.prototype.initMarkerCanvas=function(){this.markerImageHolder=document.createElement("div"),this.markerImageHolder.style.setProperty("touch-action","pinch-zoom"),this.markerImage=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.markerImage.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.markerImage.setAttribute("width",this.imageWidth.toString()),this.markerImage.setAttribute("height",this.imageHeight.toString()),this.markerImage.setAttribute("viewBox","0 0 "+this.imageWidth.toString()+" "+this.imageHeight.toString()),this.markerImage.style.pointerEvents="auto",this.markerImageHolder.style.position="absolute",this.markerImageHolder.style.width=this.imageWidth+"px",this.markerImageHolder.style.height=this.imageHeight+"px",this.markerImageHolder.style.transformOrigin="top left",this.positionMarkerImage(),this.markerImageHolder.appendChild(this.markerImage),this.editorCanvas.appendChild(this.markerImageHolder)},W.prototype.addDefs=function(){for(var w,k=[],H=0;H<arguments.length;H++)k[H]=arguments[H];this.defs=D.createDefs(),this.addDefsToImage(),(w=this.defs).append.apply(w,k)},W.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},W.prototype.initOverlay=function(){this.overlayContainer=document.createElement("div"),this.overlayContainer.style.position="absolute",this.overlayContainer.style.left="0px",this.overlayContainer.style.top="0px",this.overlayContainer.style.width=this.imageWidth+"px",this.overlayContainer.style.height=this.imageHeight+"px",this.overlayContainer.style.display="flex",this.markerImageHolder.appendChild(this.overlayContainer)},W.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},W.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},W.prototype.attachWindowEvents=function(){window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("pointerout",this.onPointerOut),window.addEventListener("pointerleave",this.onPointerUp),window.addEventListener("resize",this.onWindowResize),window.addEventListener("keyup",this.onKeyUp)},W.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},W.prototype.detachWindowEvents=function(){window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("pointerout",this.onPointerOut),window.removeEventListener("pointerleave",this.onPointerUp),window.removeEventListener("resize",this.onWindowResize),window.removeEventListener("keyup",this.onKeyUp)},W.prototype.addLogo=function(){this.logoUI=document.createElement("div"),this.logoUI.style.display="inline-block",this.logoUI.style.margin="0px",this.logoUI.style.padding="0px",this.logoUI.style.fill="#333333";var w=document.createElement("a");w.href="https://markerjs.com/",w.target="_blank",w.innerHTML='<svg viewBox="0 0 112 96" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path fill="#e5f20d" fill-opacity=".647" d="M0 40.386h111.96V95.62H0z"/><path d="M93.61 61.452c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.591 1.048-1.481 0-2.222-.74-2.222-2.22 0-16.617-.533-29.347-1.604-38.192-1.068-8.842-2.92-13.265-5.552-13.265-4.443 0-10.94 15.509-19.497 46.52v.124c0 .987-.328 1.831-.987 2.53-.657.7-1.52 1.048-2.592 1.048-1.48 0-2.22-.74-2.22-2.22 0-3.29.165-8.392.493-15.302.33-7.732.494-13.82.494-18.262 0-6.17-.186-10.55-.556-13.142-.37-2.591-1.172-3.887-2.406-3.887-2.796 0-6.333 5.12-10.612 15.363C38.494 34.367 34.01 46.44 29.32 60.34l-1.11 3.209a5.714 5.714 0 01-1.42 2.097c-.617.578-1.295.864-2.036.864-.987 0-1.644-.081-1.974-.247-.328-.162-.533-.656-.617-1.48-.41-4.03-.74-9.418-.987-16.165-.163-1.728-.329-4.566-.494-8.515-.822-13.901-1.562-23.3-2.221-28.196-.657-4.893-.987-7.628-.987-8.205 0-.657.33-1.44.987-2.345.659-.903 1.276-1.357 1.85-1.357 1.319 0 2.387.947 3.21 2.838.411.906.863 4.526 1.357 10.859.493 6.335.905 14.19 1.233 23.568l.617 18.88c4.527-13.983 9.216-26.673 14.068-38.068C45.65 6.686 50.093.988 54.123.988c2.715 0 4.566 1.974 5.553 5.923.987 3.949 1.481 9.667 1.481 17.152 0 3.949-.081 9.625-.247 17.029l-.123 5.676c3.373-11.762 6.725-21.634 10.057-29.615 3.331-7.979 6.685-11.97 10.056-11.97 8.475 0 12.71 18.757 12.71 56.269z" fill-rule="nonzero"/></svg>',w.title="Powered by marker.js",w.style.display="grid",w.style.alignItems="center",w.style.justifyItems="center",w.style.padding="3px",w.style.width="20px",w.style.height="20px",this.logoUI.appendChild(w),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},W.prototype.positionLogo=function(){this.logoUI&&(this.uiStyleSettings.logoPosition!=="right"?this.logoUI.style.left=this.markerImageHolder.offsetLeft+10+"px":this.logoUI.style.left=this.markerImageHolder.offsetLeft+this.markerImageHolder.offsetWidth-this.logoUI.clientWidth-10+"px",this.logoUI.style.top=this.markerImageHolder.offsetTop+this.markerImageHolder.offsetHeight-this.logoUI.clientHeight-10+"px")},W.prototype.overrideOverflow=function(){this.scrollXState=window.scrollX,this.scrollYState=window.scrollY,this.bodyOverflowState=document.body.style.overflow,window.scroll({top:0,left:0}),document.body.style.overflow="hidden"},W.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},W.prototype.showUI=function(){switch(this.settings.displayMode==="popup"&&this.overrideOverflow(),this.coverDiv=document.createElement("div"),this.coverDiv.style.visibility=this._silentRenderMode?"hidden":"visible",this.coverDiv.className=this.styles.classNamePrefixBase+" "+this.styles.classNamePrefix,this.coverDiv.style.fontSize="16px",this.coverDiv.style.userSelect="none",this.settings.displayMode){case"inline":this.coverDiv.style.position="absolute";var w=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=w+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px",this.coverDiv.style.width=this.target.offsetWidth.toString()+"px",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"5";break;case"popup":this.coverDiv.style.position="absolute",this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=window.innerHeight+"px",this.coverDiv.style.backgroundColor="rgba(0, 0, 0, 0.75)",this.coverDiv.style.zIndex=this.uiStyleSettings.zIndex!==void 0?this.uiStyleSettings.zIndex:"1000",this.coverDiv.style.display="flex"}this.targetRoot.appendChild(this.coverDiv),this.uiDiv=document.createElement("div"),this.uiDiv.style.display="flex",this.uiDiv.style.flexDirection="column",this.uiDiv.style.flexGrow="2",this.uiDiv.style.margin=this.settings.displayMode==="popup"?this.settings.popupMargin+"px":"0px",this.uiDiv.style.border="0px",this.coverDiv.appendChild(this.uiDiv),this.toolbar=new R(this.uiDiv,this.settings.displayMode,this._availableMarkerTypes,this.uiStyleSettings,this.styles),this.toolbar.addButtonClickListener(this.toolbarButtonClicked),this.toolbar.show(this._silentRenderMode||this.uiStyleSettings.hideToolbar?"hidden":"visible"),this.contentDiv=document.createElement("div"),this.contentDiv.style.display="flex",this.contentDiv.style.flexDirection="row",this.contentDiv.style.flexGrow="2",this.contentDiv.style.flexShrink="1",this.settings.displayMode==="popup"&&(this.contentDiv.style.backgroundColor=this.uiStyleSettings.canvasBackgroundColor,this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.uiStyleSettings.toolbarHeight+"px",this.contentDiv.style.maxWidth="calc(100vw - "+2*this.settings.popupMargin+"px)"),this.contentDiv.style.overflow="auto",this.uiDiv.appendChild(this.contentDiv),this.editorCanvas=document.createElement("div"),this.editorCanvas.style.flexGrow="2",this.editorCanvas.style.flexShrink="1",this.editorCanvas.style.position="relative",this.editorCanvas.style.overflow="hidden",this.editorCanvas.style.display="flex",this.settings.displayMode==="popup"&&(this.editorCanvas.style.alignItems="center",this.editorCanvas.style.justifyContent="center"),this.editorCanvas.style.pointerEvents="none",this.editorCanvas.style.transformOrigin="left top",this.editorCanvas.style.transform="scale("+this.zoomLevel+")",this.contentDiv.appendChild(this.editorCanvas),this.editingTarget=this.target instanceof HTMLImageElement?document.createElement("img"):document.createElement("canvas"),this.target.getClientRects().item(0).y<this.styles.settings.toolbarHeight&&(this.editingTarget.style.marginTop=this.target.offsetTop-this.styles.settings.toolbarHeight+"px"),this.editorCanvas.appendChild(this.editingTarget),this.toolbox=new A(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},W.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},W.prototype.removeMarker=function(w){this.markerImage.removeChild(w.container),this.markers.indexOf(w)>-1&&this.markers.splice(this.markers.indexOf(w),1),w.dispose()},W.prototype.switchToSelectMode=function(){this.mode="select",this.hideNotesEditor(),this._currentMarker!==void 0&&(this._currentMarker.state!=="new"?this._currentMarker.select():(this.removeMarker(this._currentMarker),this.setCurrentMarker(),this.markerImage.style.cursor="default"),this.addUndoStep())},W.prototype.toolbarButtonClicked=function(w,k){if(w==="marker"&&k!==void 0)this.createNewMarker(k);else if(w==="action")switch(k){case"select":this.switchToSelectMode(),this.switchToSelectMode();break;case"delete":this.deleteSelectedMarker();break;case"clear":this.clear();break;case"undo":this.undo();break;case"redo":this.redo();break;case"zoom":this.stepZoom();break;case"zoom-out":this.zoomLevel=1;break;case"notes":this.notesArea===void 0?(this.switchToSelectMode(),this.zoomLevel=1,this.showNotesEditor()):this.switchToSelectMode();break;case"close":this.close();break;case"render":this.switchToSelectMode(),this.startRenderAndClose()}},W.prototype.deleteSelectedMarker=function(){var w=this;if(this._currentMarker!==void 0){var k=!1;if(this.eventListeners.markerbeforedelete.forEach(function(q){var B=new Ce(w,w._currentMarker,!0);q(B),B.defaultPrevented&&(k=!0)}),!k){var H=this._currentMarker;this._currentMarker.dispose(),this.markerImage.removeChild(this._currentMarker.container),this.markers.splice(this.markers.indexOf(this._currentMarker),1),this.setCurrentMarker(),this.addUndoStep(),this.eventListeners.markerdelete.forEach(function(q){return q(new Ce(w,H))})}}},W.prototype.clear=function(){var w=this,k=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(he){var Ee=new Ce(w,void 0,!0);he(Ee),Ee.defaultPrevented&&(k=!0)}),!k)){this.setCurrentMarker();for(var H=function(he){var Ee=q.markers[he];q.setCurrentMarker(q.markers[he]),q._currentMarker.dispose(),q.markerImage.removeChild(q._currentMarker.container),q.markers.splice(q.markers.indexOf(q._currentMarker),1),q.eventListeners.markerdelete.forEach(function(Le){return Le(new Ce(w,Ee))})},q=this,B=this.markers.length-1;B>=0;B--)H(B);this.addUndoStep()}},Object.defineProperty(W.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),W.prototype.showNotesEditor=function(){var w;this._currentMarker!==void 0&&(this.overlayContainer.innerHTML="",this.notesArea=document.createElement("textarea"),this.notesArea.className=this.uiStyleSettings.notesAreaStyleClassName,this.notesArea.style.pointerEvents="auto",this.notesArea.style.alignSelf="stretch",this.notesArea.style.width="100%",this.notesArea.style.margin=this.uiStyleSettings.toolbarHeight/4+"px",this.notesArea.value=(w=this._currentMarker.notes)!==null&&w!==void 0?w:"",this.overlayContainer.appendChild(this.notesArea))},W.prototype.hideNotesEditor=function(){this.isNotesAreaOpen&&(this._currentMarker!==void 0&&(this._currentMarker.notes=this.notesArea.value.trim()!==""?this.notesArea.value:void 0),this.overlayContainer.removeChild(this.notesArea),this.notesArea=void 0)},W.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},W.prototype.addUndoStep=function(){var w=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var k=this.getState(),H=this.undoRedoManager.getLastUndoStep();if(!H||H.width===k.width&&H.height===k.height){var q=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(k),q<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(B){return B(new Te(w))})}else this.undoRedoManager.replaceLastUndoStep(k),this.eventListeners.statechange.forEach(function(B){return B(new Te(w))})}},W.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},W.prototype.undoStep=function(){var w=this,k=this.undoRedoManager.undo();k!==void 0&&(this.restoreState(k),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(H){return H(new Te(w))}))},W.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},W.prototype.redoStep=function(){var w=this,k=this.undoRedoManager.redo();k!==void 0&&(this.restoreState(k),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(H){return H(new Te(w))}))},W.prototype.stepZoom=function(){var w=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=w<this.zoomSteps.length-1?this.zoomSteps[w+1]:this.zoomSteps[0]},W.prototype.panTo=function(w){this.contentDiv.scrollBy({left:this.prevPanPoint.x-w.x,top:this.prevPanPoint.y-w.y}),this.prevPanPoint=w},W.prototype.startRenderAndClose=function(){return _(this,void 0,void 0,function(){var w,k,H=this;return $(this,function(q){switch(q.label){case 0:return[4,this.render()];case 1:return w=q.sent(),k=this.getState(),this.eventListeners.render.forEach(function(B){return B(new Oe(H,w,k))}),this.close(!0),[2]}})})},W.prototype.getState=function(w){w===!0&&this.setCurrentMarker();var k={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(H){return k.markers.push(H.getState())}),k},W.prototype.restoreState=function(w){var k=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);w.markers.forEach(function(H){var q=k._availableMarkerTypes.find(function(he){return he.typeName===H.typeName});if(q!==void 0){var B=k.addNewMarker(q);B.restoreState(H),k.markers.push(B)}}),w.width&&w.height&&(w.width!==this.imageWidth||w.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/w.width,this.imageHeight/w.height),this.eventListeners.restorestate.forEach(function(H){return H(new Te(k))})},W.prototype.addNewMarker=function(w){var k=D.createGroup();return this.markerImage.appendChild(k),new w(k,this.overlayContainer,this.settings)},W.prototype.createNewMarker=function(w){var k,H=this;(k=typeof w=="string"?this._availableMarkerTypes.find(function(q){return q.typeName===w}):w)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(k),this._currentMarker.onMarkerCreated=this.markerCreated,this._currentMarker.onColorChanged=this.colorChanged,this._currentMarker.onFillColorChanged=this.fillColorChanged,this._currentMarker.onStateChanged=this.markerStateChanged,this.markerImage.style.cursor="crosshair",this.toolbar.setActiveMarkerButton(k.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(q){return q(new Ce(H,H._currentMarker))}))},W.prototype.markerCreated=function(w){var k=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(w),this.setCurrentMarker(w),w instanceof p&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(p):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(H){return H(new Ce(k,k._currentMarker))})},W.prototype.colorChanged=function(w){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=w,this.settings.defaultStrokeColor=w)},W.prototype.fillColorChanged=function(w){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=w)},W.prototype.markerStateChanged=function(w){var k=this;this.eventListeners.markerchange.forEach(function(H){return H(new Ce(k,w))})},W.prototype.setCurrentMarker=function(w){var k=this;this._currentMarker!==w&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(H){return H(new Ce(k,k._currentMarker))})),this._currentMarker=w,this._currentMarker===void 0||this._currentMarker.isSelected||(this._currentMarker.state!=="new"&&this._currentMarker.select(),this.toolbar.setCurrentMarker(this._currentMarker),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this._isResizing||this.eventListeners.markerselect.forEach(function(H){return H(new Ce(k,k._currentMarker))}))},W.prototype.onPointerDown=function(w){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||w.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var k=this.markers.find(function(H){return H.ownsTarget(w.target)});k!==void 0?(this.setCurrentMarker(k),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(w.clientX,w.clientY),w.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:w.clientX,y:w.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(w.clientX,w.clientY))},W.prototype.onDblClick=function(w){if(this._isFocused||this.focus(),this.mode==="select"){var k=this.markers.find(function(H){return H.ownsTarget(w.target)});k!==void 0&&k!==this._currentMarker&&this.setCurrentMarker(k),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(w.clientX,w.clientY),w.target):this.setCurrentMarker()}},W.prototype.onPointerMove=function(w){this.touchPoints!==1&&w.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||w.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(w.clientX,w.clientY)):this.zoomLevel>1&&this.panTo({x:w.clientX,y:w.clientY}))},W.prototype.onPointerUp=function(w){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(w.clientX,w.clientY)),this.isDragging=!1,this.addUndoStep()},W.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},W.prototype.onKeyUp=function(w){this._currentMarker===void 0||this.notesArea!==void 0||w.key!=="Delete"&&w.key!=="Backspace"||this.deleteSelectedMarker()},W.prototype.clientToLocalCoordinates=function(w,k){var H=this.markerImage.getBoundingClientRect();return{x:(w-H.left)/this.zoomLevel,y:(k-H.top)/this.zoomLevel}},W.prototype.onWindowResize=function(){this.positionUI()},W.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var w=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=w+"px",this.coverDiv.style.left=this.target.offsetLeft.toString()+"px";break;case"popup":this.coverDiv.style.top="0px",this.coverDiv.style.left="0px",this.coverDiv.style.width="100vw",this.coverDiv.style.height=this.windowHeight+"px",this.contentDiv.style.maxHeight=this.windowHeight-2*this.settings.popupMargin-3.5*this.styles.settings.toolbarHeight+"px"}this.positionMarkerImage(),this.positionLogo()},W.prototype.addLicenseKey=function(w){j.addKey(w)},W.prototype.addEventListener=function(w,k){this.eventListeners.addEventListener(w,k)},W.prototype.removeEventListener=function(w,k){this.eventListeners.removeEventListener(w,k)},W.prototype.renderState=function(w){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(w),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(W.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),W.prototype.focus=function(){var w=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(k){return k(new Te(w))}))},W.prototype.blur=function(){var w=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(k){return k(new Te(w))}))},W.instanceCounter=0,W}()},UUDw:function(dt,et,le){dt.exports={buttonFixed:"buttonFixed___2zLVJ",button:"button___-JgFH",buttonWrap:"buttonWrap___aZhhk"}},UqFu:function(dt,et,le){"use strict";le.d(et,"a",function(){return fe});var fe=function(_){var $=document.createElement("textarea");return $.value=_,$.value}},"VrN/":function(dt,et,le){(function(fe,J){dt.exports=J()})(this,function(){"use strict";var fe=navigator.userAgent,J=navigator.platform,_=/gecko\/\d/i.test(fe),$=/MSIE \d/.test(fe),I=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fe),D=/Edge\/(\d+)/.exec(fe),j=$||I||D,U=j&&($?document.documentMode||6:+(D||I)[1]),P=!D&&/WebKit\//.test(fe),O=P&&/Qt\/\d+\.\d+/.test(fe),v=!D&&/Chrome\//.test(fe),T=/Opera\//.test(fe),R=/Apple Computer/.test(navigator.vendor),A=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(fe),C=/PhantomJS/.test(fe),S=!D&&/AppleWebKit/.test(fe)&&/Mobile\/\w+/.test(fe),u=/Android/.test(fe),o=S||u||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(fe),s=S||/Mac/.test(J),l=/\bCrOS\b/.test(fe),E=/win/i.test(J),m=T&&fe.match(/Version\/(\d*\.\d*)/);m&&(m=Number(m[1])),m&&m>=15&&(T=!1,P=!0);var f=s&&(O||T&&(m==null||m<12.11)),L=_||j&&U>=9;function g(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var d=function(e,t){var i=e.className,r=g(t).exec(i);if(r){var n=i.slice(r.index+r[0].length);e.className=i.slice(0,r.index)+(n?r[1]+n:"")}};function c(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function h(e,t){return c(e).appendChild(t)}function a(e,t,i,r){var n=document.createElement(e);if(i&&(n.className=i),r&&(n.style.cssText=r),typeof t=="string")n.appendChild(document.createTextNode(t));else if(t)for(var y=0;y<t.length;++y)n.appendChild(t[y]);return n}function x(e,t,i,r){var n=a(e,t,i,r);return n.setAttribute("role","presentation"),n}var p;document.createRange?p=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:p=function(e,t,i){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(n){return r}return r.collapse(!0),r.moveEnd("character",i),r.moveStart("character",t),r};function b(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 M(){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 G(e,t){var i=e.className;g(t).test(i)||(e.className+=(i?" ":"")+t)}function Z(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!g(i[r]).test(t)&&(t+=" "+i[r]);return t}var ie=function(e){e.select()};S?ie=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:j&&(ie=function(e){try{e.select()}catch(t){}});function z(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function F(e,t,i){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(i!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function ne(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var y=r||0,N=n||0;;){var K=e.indexOf(" ",y);if(K<0||K>=t)return N+(t-y);N+=K-y,N+=i-N%i,y=K+1}}var ce=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};ce.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},ce.prototype.set=function(e,t){this.f=t;var i=+new Date+e;(!this.id||i<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=i)};function ge(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var xe=50,Me={toString:function(){return"CodeMirror.Pass"}},Te={scroll:!1},Oe={origin:"*mouse"},Ce={origin:"+move"};function we(e,t,i){for(var r=0,n=0;;){var y=e.indexOf(" ",r);y==-1&&(y=e.length);var N=y-r;if(y==e.length||n+N>=t)return r+Math.min(N,t-n);if(n+=y-r,n+=i-n%i,r=y+1,n>=t)return r}}var ve=[""];function W(e){for(;ve.length<=e;)ve.push(w(ve)+" ");return ve[e]}function w(e){return e[e.length-1]}function k(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function H(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function q(){}function B(e,t){var i;return Object.create?i=Object.create(e):(q.prototype=e,i=new q),t&&F(t,i),i}var he=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function Ee(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||he.test(e))}function Le(e,t){return t?t.source.indexOf("\\w")>-1&&Ee(e)?!0:t.test(e):Ee(e)}function Ie(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var _e=/[\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 De(e){return e.charCodeAt(0)>=768&&_e.test(e)}function Pe(e,t,i){for(;(i<0?t>0:t<e.length)&&De(e.charAt(t));)t+=i;return t}function je(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,y=r<0?Math.ceil(n):Math.floor(n);if(y==t)return e(y)?t:i;e(y)?i=y:t=y+r}}function ze(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,y=0;y<e.length;++y){var N=e[y];(N.from<i&&N.to>t||t==i&&N.to==t)&&(r(Math.max(N.from,t),Math.min(N.to,i),N.level==1?"rtl":"ltr",y),n=!0)}n||r(t,i,"ltr")}var Ke=null;function Ve(e,t,i){var r;Ke=null;for(var n=0;n<e.length;++n){var y=e[n];if(y.from<t&&y.to>t)return n;y.to==t&&(y.from!=y.to&&i=="before"?r=n:Ke=n),y.from==t&&(y.from!=y.to&&i!="before"?r=n:Ke=n)}return r!=null?r:Ke}var at=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(re){return re<=247?e.charAt(re):1424<=re&&re<=1524?"R":1536<=re&&re<=1785?t.charAt(re-1536):1774<=re&&re<=2220?"r":8192<=re&&re<=8203?"w":re==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,y=/[LRr]/,N=/[Lb1n]/,K=/[1n]/;function X(re,de,pe){this.level=re,this.from=de,this.to=pe}return function(re,de){var pe=de=="ltr"?"L":"R";if(re.length==0||de=="ltr"&&!r.test(re))return!1;for(var Se=re.length,be=[],Re=0;Re<Se;++Re)be.push(i(re.charCodeAt(Re)));for(var Ne=0,Ue=pe;Ne<Se;++Ne){var He=be[Ne];He=="m"?be[Ne]=Ue:Ue=He}for(var Ze=0,Ge=pe;Ze<Se;++Ze){var qe=be[Ze];qe=="1"&&Ge=="r"?be[Ze]="n":y.test(qe)&&(Ge=qe,qe=="r"&&(be[Ze]="R"))}for(var ut=1,st=be[0];ut<Se-1;++ut){var gt=be[ut];gt=="+"&&st=="1"&&be[ut+1]=="1"?be[ut]="1":gt==","&&st==be[ut+1]&&(st=="1"||st=="n")&&(be[ut]=st),st=gt}for(var Rt=0;Rt<Se;++Rt){var Vt=be[Rt];if(Vt==",")be[Rt]="N";else if(Vt=="%"){var Nt=void 0;for(Nt=Rt+1;Nt<Se&&be[Nt]=="%";++Nt);for(var pr=Rt&&be[Rt-1]=="!"||Nt<Se&&be[Nt]=="1"?"1":"N",ur=Rt;ur<Nt;++ur)be[ur]=pr;Rt=Nt-1}}for(var Wt=0,hr=pe;Wt<Se;++Wt){var Qt=be[Wt];hr=="L"&&Qt=="1"?be[Wt]="L":y.test(Qt)&&(hr=Qt)}for(var Gt=0;Gt<Se;++Gt)if(n.test(be[Gt])){var jt=void 0;for(jt=Gt+1;jt<Se&&n.test(be[jt]);++jt);for(var Bt=(Gt?be[Gt-1]:pe)=="L",dr=(jt<Se?be[jt]:pe)=="L",Gi=Bt==dr?Bt?"L":"R":pe,ei=Gt;ei<jt;++ei)be[ei]=Gi;Gt=jt-1}for(var tr=[],Ir,Xt=0;Xt<Se;)if(N.test(be[Xt])){var Va=Xt;for(++Xt;Xt<Se&&N.test(be[Xt]);++Xt);tr.push(new X(0,Va,Xt))}else{var Gr=Xt,vi=tr.length,yi=de=="rtl"?1:0;for(++Xt;Xt<Se&&be[Xt]!="L";++Xt);for(var nr=Gr;nr<Xt;)if(K.test(be[nr])){Gr<nr&&(tr.splice(vi,0,new X(1,Gr,nr)),vi+=yi);var zi=nr;for(++nr;nr<Xt&&K.test(be[nr]);++nr);tr.splice(vi,0,new X(2,zi,nr)),vi+=yi,Gr=nr}else++nr;Gr<Xt&&tr.splice(vi,0,new X(1,Gr,Xt))}return de=="ltr"&&(tr[0].level==1&&(Ir=re.match(/^\s+/))&&(tr[0].from=Ir[0].length,tr.unshift(new X(0,0,Ir[0].length))),w(tr).level==1&&(Ir=re.match(/\s+$/))&&(w(tr).to-=Ir[0].length,tr.push(new X(0,Se-Ir[0].length,Se)))),de=="rtl"?tr.reverse():tr}}();function Xe(e,t){var i=e.order;return i==null&&(i=e.order=at(e.text,t)),i}var $e=[],Ae=function(e,t,i){if(e.addEventListener)e.addEventListener(t,i,!1);else if(e.attachEvent)e.attachEvent("on"+t,i);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||$e).concat(i)}};function rt(e,t){return e._handlers&&e._handlers[t]||$e}function Je(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var r=e._handlers,n=r&&r[t];if(n){var y=ge(n,i);y>-1&&(r[t]=n.slice(0,y).concat(n.slice(y+1)))}}}function ae(e,t){var i=rt(e,t);if(!i.length)return;for(var r=Array.prototype.slice.call(arguments,2),n=0;n<i.length;++n)i[n].apply(null,r)}function V(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),ae(e,i||t.type,e,t),se(t)||t.codemirrorIgnore}function Y(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;for(var i=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)ge(i,t[r])==-1&&i.push(t[r])}function te(e,t){return rt(e,t).length>0}function oe(e){e.prototype.on=function(t,i){Ae(this,t,i)},e.prototype.off=function(t,i){Je(this,t,i)}}function Q(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function ee(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function se(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ue(e){Q(e),ee(e)}function me(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 ke=function(){if(j&&U<9)return!1;var e=a("div");return"draggable"in e||"dragDrop"in e}(),We;function Qe(e){if(We==null){var t=a("span","\u200B");h(e,a("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(We=t.offsetWidth<=1&&t.offsetHeight>2&&!(j&&U<8))}var i=We?a("span","\u200B"):a("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var tt;function vt(e){if(tt!=null)return tt;var t=h(e,document.createTextNode("A\u062EA")),i=p(t,0,1).getBoundingClientRect(),r=p(t,1,2).getBoundingClientRect();return c(e),!i||i.left==i.right?!1:tt=r.right-i.right<3}var ot=`
b`.split(/\n/).length!=3?function(e){for(var t=0,i=[],r=e.length;t<=r;){var n=e.indexOf(`
`,t);n==-1&&(n=e.length);var y=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),N=y.indexOf("\r");N!=-1?(i.push(y.slice(0,N)),t+=N+1):(i.push(y),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},it=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(i){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},wt=function(){var e=a("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),xt=null;function It(e){if(xt!=null)return xt;var t=h(e,a("span","x")),i=t.getBoundingClientRect(),r=p(t,0,1).getBoundingClientRect();return xt=Math.abs(i.left-r.left)>1}var Ot={},Et={};function mr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ot[e]=t}function Tr(e,t){Et[e]=t}function Yt(e){if(typeof e=="string"&&Et.hasOwnProperty(e))e=Et[e];else if(e&&typeof e.name=="string"&&Et.hasOwnProperty(e.name)){var t=Et[e.name];typeof t=="string"&&(t={name:t}),e=B(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Yt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Yt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function gr(e,t){t=Yt(t);var i=Ot[t.name];if(!i)return gr(e,"text/plain");var r=i(e,t);if(cr.hasOwnProperty(t.name)){var n=cr[t.name];for(var y in n){if(!n.hasOwnProperty(y))continue;r.hasOwnProperty(y)&&(r["_"+y]=r[y]),r[y]=n[y]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var N in t.modeProps)r[N]=t.modeProps[N];return r}var cr={};function zr(e,t){var i=cr.hasOwnProperty(e)?cr[e]:cr[e]={};F(t,i)}function $t(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var i={};for(var r in t){var n=t[r];n instanceof Array&&(n=n.concat([])),i[r]=n}return i}function Nr(e,t){for(var i;e.innerMode&&!(i=e.innerMode(t),!i||i.mode==e);)t=i.state,e=i.mode;return i||{mode:e,state:t}}function ti(e,t,i){return e.startState?e.startState(t,i):!0}var Pt=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i};Pt.prototype.eol=function(){return this.pos>=this.string.length},Pt.prototype.sol=function(){return this.pos==this.lineStart},Pt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Pt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Pt.prototype.eat=function(e){var t=this.string.charAt(this.pos),i;if(typeof e=="string"?i=t==e:i=t&&(e.test?e.test(t):e(t)),i)return++this.pos,t},Pt.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Pt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Pt.prototype.skipToEnd=function(){this.pos=this.string.length},Pt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Pt.prototype.backUp=function(e){this.pos-=e},Pt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ne(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?ne(this.string,this.lineStart,this.tabSize):0)},Pt.prototype.indentation=function(){return ne(this.string,null,this.tabSize)-(this.lineStart?ne(this.string,this.lineStart,this.tabSize):0)},Pt.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(N){return i?N.toLowerCase():N},n=this.string.substr(this.pos,e.length);if(r(n)==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)}},Pt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Pt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Pt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Pt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function Ye(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 i=e;!i.lines;)for(var r=0;;++r){var n=i.children[r],y=n.chunkSize();if(t<y){i=n;break}t-=y}return i.lines[t]}function Tt(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(y){var N=y.text;n==i.line&&(N=N.slice(0,i.ch)),n==t.line&&(N=N.slice(t.ch)),r.push(N),++n}),r}function Zt(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function mt(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function pt(e){if(e.parent==null)return null;for(var t=e.parent,i=ge(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var n=0;!(r.children[n]==t);++n)i+=r.children[n].chunkSize();return i+t.first}function At(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],y=n.height;if(t<y){e=n;continue e}t-=y,i+=n.chunkSize()}return i}while(!e.lines);for(var N=0;N<e.lines.length;++N){var K=e.lines[N],X=K.height;if(t<X)break;t-=X}return i+N}function vr(e,t){return t>=e.first&&t<e.first+e.size}function Ut(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Be(e,t,i){if(i===void 0&&(i=null),!(this instanceof Be))return new Be(e,t,i);this.line=e,this.ch=t,this.sticky=i}function ht(e,t){return e.line-t.line||e.ch-t.ch}function ri(e,t){return e.sticky==t.sticky&&ht(e,t)==0}function bi(e){return Be(e.line,e.ch)}function xi(e,t){return ht(e,t)<0?t:e}function ii(e,t){return ht(e,t)<0?e:t}function Ei(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 Be(e.first,0);var i=e.first+e.size-1;return t.line>i?Be(i,Ye(e,i).text.length):Ln(t,Ye(e,t.line).text.length)}function Ln(e,t){var i=e.ch;return i==null||i>t?Be(e.line,t):i<0?Be(e.line,0):e}function Fe(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=ft(e,t[r]);return i}var Si=function(e,t){this.state=e,this.lookAhead=t},Er=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};Er.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Er.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}},Er.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Er.fromSaved=function(e,t,i){return t instanceof Si?new Er(e,$t(e.mode,t.state),i,t.lookAhead):new Er(e,$t(e.mode,t),i)},Er.prototype.save=function(e){var t=e!==!1?$t(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Si(t,this.maxLookAhead):t};function Ki(e,t,i,r){var n=[e.state.modeGen],y={};Ar(e,t.text,e.doc.mode,i,function(re,de){return n.push(re,de)},y,r);for(var N=i.state,K=function(re){i.baseTokens=n;var de=e.state.overlays[re],pe=1,Se=0;i.state=!0,Ar(e,t.text,de.mode,i,function(be,Re){for(var Ne=pe;Se<be;){var Ue=n[pe];Ue>be&&n.splice(pe,1,be,n[pe+1],Ue),pe+=2,Se=Math.min(be,Ue)}if(!Re)return;if(de.opaque)n.splice(Ne,pe-Ne,be,"overlay "+Re),pe=Ne+2;else for(;Ne<pe;Ne+=2){var He=n[Ne+1];n[Ne+1]=(He?He+" ":"")+"overlay "+Re}},y),i.state=N,i.baseTokens=null,i.baseTokenPos=1},X=0;X<e.state.overlays.length;++X)K(X);return{styles:n,classes:y.bgClass||y.textClass?y:null}}function ni(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Cr(e,pt(t)),n=t.text.length>e.options.maxHighlightLength&&$t(e.doc.mode,r.state),y=Ki(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=y.styles,y.classes?t.styleClasses=y.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function Cr(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new Er(r,!0,t);var y=_n(e,t,i),N=y>r.first&&Ye(r,y-1).stateAfter,K=N?Er.fromSaved(r,N,y):new Er(r,ti(r.mode),y);return r.iter(y,t,function(X){Vi(e,X.text,K);var re=K.line;X.stateAfter=re==t-1||re%5==0||re>=n.viewFrom&&re<n.viewTo?K.save():null,K.nextLine()}),i&&(r.modeFrontier=K.line),K}function Vi(e,t,i,r){var n=e.doc.mode,y=new Pt(t,e.options.tabSize,i);for(y.start=y.pos=r||0,t==""&&Xi(n,i.state);!y.eol();)wr(n,y,i.state),y.start=y.pos}function Xi(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=Nr(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function wr(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=Nr(e,i).mode);var y=e.token(t,i);if(t.pos>t.start)return y}throw new Error("Mode "+e.name+" failed to advance stream.")}var Yi=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function kn(e,t,i,r){var n=e.doc,y=n.mode,N;t=ft(n,t);var K=Ye(n,t.line),X=Cr(e,t.line,i),re=new Pt(K.text,e.options.tabSize,X),de;for(r&&(de=[]);(r||re.pos<t.ch)&&!re.eol();)re.start=re.pos,N=wr(y,re,X.state),r&&de.push(new Yi(re,N,$t(n.mode,X.state)));return r?de:new Yi(re,N,X.state)}function $i(e,t){if(e)for(;;){var i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i)break;e=e.slice(0,i.index)+e.slice(i.index+i[0].length);var r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|\\s)"+i[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+i[2])}return e}function Ar(e,t,i,r,n,y,N){var K=i.flattenSpans;K==null&&(K=e.options.flattenSpans);var X=0,re=null,de=new Pt(t,e.options.tabSize,r),pe,Se=e.options.addModeClass&&[null];for(t==""&&$i(Xi(i,r.state),y);!de.eol();){if(de.pos>e.options.maxHighlightLength?(K=!1,N&&Vi(e,t,r,de.pos),de.pos=t.length,pe=null):pe=$i(wr(i,de,r.state,Se),y),Se){var be=Se[0].name;be&&(pe="m-"+(pe?be+" "+pe:be))}if(!K||re!=pe){for(;X<de.start;)X=Math.min(de.start,X+5e3),n(X,re);re=pe}de.start=de.pos}for(;X<de.pos;){var Re=Math.min(de.pos,X+5e3);n(Re,re),X=Re}}function _n(e,t,i){for(var r,n,y=e.doc,N=i?-1:t-(e.doc.mode.innerMode?1e3:100),K=t;K>N;--K){if(K<=y.first)return y.first;var X=Ye(y,K-1),re=X.stateAfter;if(re&&(!i||K+(re instanceof Si?re.lookAhead:0)<=y.modeFrontier))return K;var de=ne(X.text,null,e.options.tabSize);(n==null||r>de)&&(n=K-1,r=de)}return n}function aa(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),e.highlightFrontier<t-10)return;for(var i=e.first,r=t-1;r>i;r--){var n=Ye(e,r).stateAfter;if(n&&(!(n instanceof Si)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Zi=!1,rr=!1;function Kr(){Zi=!0}function oa(){rr=!0}function ai(e,t,i){this.marker=e,this.from=t,this.to=i}function Lr(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function Ji(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function sa(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Dn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var y=e[n],N=y.marker,K=y.from==null||(N.inclusiveLeft?y.from<=t:y.from<t);if(K||y.from==t&&N.type=="bookmark"&&(!i||!y.marker.insertLeft)){var X=y.to==null||(N.inclusiveRight?y.to>=t:y.to>t);(r||(r=[])).push(new ai(N,y.from,X?null:y.to))}}return r}function Rn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var y=e[n],N=y.marker,K=y.to==null||(N.inclusiveRight?y.to>=t:y.to>t);if(K||y.from==t&&N.type=="bookmark"&&(!i||y.marker.insertLeft)){var X=y.from==null||(N.inclusiveLeft?y.from<=t:y.from<t);(r||(r=[])).push(new ai(N,X?null:y.from-t,y.to==null?null:y.to-t))}}return r}function Ti(e,t){if(t.full)return null;var i=vr(e,t.from.line)&&Ye(e,t.from.line).markedSpans,r=vr(e,t.to.line)&&Ye(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,y=t.to.ch,N=ht(t.from,t.to)==0,K=Dn(i,n,N),X=Rn(r,y,N),re=t.text.length==1,de=w(t.text).length+(re?n:0);if(K)for(var pe=0;pe<K.length;++pe){var Se=K[pe];if(Se.to==null){var be=Lr(X,Se.marker);be?re&&(Se.to=be.to==null?null:be.to+de):Se.to=n}}if(X)for(var Re=0;Re<X.length;++Re){var Ne=X[Re];if(Ne.to!=null&&(Ne.to+=de),Ne.from==null){var Ue=Lr(K,Ne.marker);Ue||(Ne.from=de,re&&(K||(K=[])).push(Ne))}else Ne.from+=de,re&&(K||(K=[])).push(Ne)}K&&(K=On(K)),X&&X!=K&&(X=On(X));var He=[K];if(!re){var Ze=t.text.length-2,Ge;if(Ze>0&&K)for(var qe=0;qe<K.length;++qe)K[qe].to==null&&(Ge||(Ge=[])).push(new ai(K[qe].marker,null,null));for(var ut=0;ut<Ze;++ut)He.push(Ge);He.push(X)}return He}function On(e){for(var t=0;t<e.length;++t){var i=e[t];i.from!=null&&i.from==i.to&&i.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Pn(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(be){if(be.markedSpans)for(var Re=0;Re<be.markedSpans.length;++Re){var Ne=be.markedSpans[Re].marker;Ne.readOnly&&(!r||ge(r,Ne)==-1)&&(r||(r=[])).push(Ne)}}),!r)return null;for(var n=[{from:t,to:i}],y=0;y<r.length;++y)for(var N=r[y],K=N.find(0),X=0;X<n.length;++X){var re=n[X];if(ht(re.to,K.from)<0||ht(re.from,K.to)>0)continue;var de=[X,1],pe=ht(re.from,K.from),Se=ht(re.to,K.to);(pe<0||!N.inclusiveLeft&&!pe)&&de.push({from:re.from,to:K.from}),(Se>0||!N.inclusiveRight&&!Se)&&de.push({from:K.to,to:re.to}),n.splice.apply(n,de),X+=de.length-3}return n}function la(e){var t=e.markedSpans;if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.detachLine(e);e.markedSpans=null}function Ci(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function oi(e){return e.inclusiveLeft?-1:0}function si(e){return e.inclusiveRight?1:0}function wi(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),y=ht(r.from,n.from)||oi(e)-oi(t);if(y)return-y;var N=ht(r.to,n.to)||si(e)-si(t);return N||t.id-e.id}function Br(e,t){var i=rr&&e.markedSpans,r;if(i)for(var n=void 0,y=0;y<i.length;++y)n=i[y],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||wi(r,n.marker)<0)&&(r=n.marker);return r}function Fr(e){return Br(e,!0)}function Ur(e){return Br(e,!1)}function Ai(e,t){var i=rr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var y=i[n];y.marker.collapsed&&(y.from==null||y.from<t)&&(y.to==null||y.to>t)&&(!r||wi(r,y.marker)<0)&&(r=y.marker)}return r}function Mn(e,t,i,r,n){var y=Ye(e,t),N=rr&&y.markedSpans;if(N)for(var K=0;K<N.length;++K){var X=N[K];if(!X.marker.collapsed)continue;var re=X.marker.find(0),de=ht(re.from,i)||oi(X.marker)-oi(n),pe=ht(re.to,r)||si(X.marker)-si(n);if(de>=0&&pe<=0||de<=0&&pe>=0)continue;if(de<=0&&(X.marker.inclusiveRight&&n.inclusiveLeft?ht(re.to,i)>=0:ht(re.to,i)>0)||de>=0&&(X.marker.inclusiveRight&&n.inclusiveLeft?ht(re.from,r)<=0:ht(re.from,r)<0))return!0}}function yr(e){for(var t;t=Fr(e);)e=t.find(-1,!0).line;return e}function In(e){for(var t;t=Ur(e);)e=t.find(1,!0).line;return e}function Li(e){for(var t,i;t=Ur(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function Qi(e,t){var i=Ye(e,t),r=yr(i);return i==r?t:pt(r)}function Vr(e,t){if(t>e.lastLine())return t;var i=Ye(e,t),r;if(!Or(e,i))return t;for(;r=Ur(i);)i=r.find(1,!0).line;return pt(i)+1}function Or(e,t){var i=rr&&t.markedSpans;if(i)for(var r=void 0,n=0;n<i.length;++n){if(r=i[n],!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&qi(e,t,r))return!0}}function qi(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return qi(e,r.line,Lr(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,y=0;y<t.markedSpans.length;++y)if(n=t.markedSpans[y],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&qi(e,t,n))return!0}function kr(e){e=yr(e);for(var t=0,i=e.parent,r=0;r<i.lines.length;++r){var n=i.lines[r];if(n==e)break;t+=n.height}for(var y=i.parent;y;i=y,y=i.parent)for(var N=0;N<y.children.length;++N){var K=y.children[N];if(K==i)break;t+=K.height}return t}function en(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=Fr(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Ur(r);){var y=i.find(0,!0);t-=r.text.length-y.from.ch,r=y.to.line,t+=r.text.length-y.to.ch}return t}function Nn(e){var t=e.display,i=e.doc;t.maxLine=Ye(i,i.first),t.maxLineLength=en(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=en(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var li=function(e,t,i){this.text=e,Ci(this,t),this.height=i?i(this):1};li.prototype.lineNo=function(){return pt(this)},oe(li);function ua(e,t,i,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),la(e),Ci(e,i);var n=r?r(e):1;n!=e.height&&mt(e,n)}function nt(e){e.parent=null,la(e)}var ct={},lt={};function yt(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?lt:ct;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function Ct(e,t){var i=x("span",null,null,P?"padding-right: .1px":null),r={pre:x("pre",[i],"CodeMirror-line"),content:i,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var n=0;n<=(t.rest?t.rest.length:0);n++){var y=n?t.rest[n-1]:t.line,N=void 0;r.pos=0,r.addToken=St,vt(e.display.measure)&&(N=Xe(y,e.doc.direction))&&(r.addToken=ar(r.addToken,N)),r.map=[];var K=t!=e.display.externalMeasured&&pt(y);Wr(y,r,ni(e,y,K)),y.styleClasses&&(y.styleClasses.bgClass&&(r.bgClass=Z(y.styleClasses.bgClass,r.bgClass||"")),y.styleClasses.textClass&&(r.textClass=Z(y.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(Qe(e.display.measure))),n==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(P){var X=r.content.lastChild;(/\bcm-tab\b/.test(X.className)||X.querySelector&&X.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=Z(r.pre.className,r.textClass||"")),r}function Dt(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 St(e,t,i,r,n,y,N){if(!t)return;var K=e.splitSpaces?Ht(t,e.trailingSpace):t,X=e.cm.state.specialChars,re=!1,de;if(!X.test(t))e.col+=t.length,de=document.createTextNode(K),e.map.push(e.pos,e.pos+t.length,de),j&&U<9&&(re=!0),e.pos+=t.length;else{de=document.createDocumentFragment();for(var pe=0;;){X.lastIndex=pe;var Se=X.exec(t),be=Se?Se.index-pe:t.length-pe;if(be){var Re=document.createTextNode(K.slice(pe,pe+be));j&&U<9?de.appendChild(a("span",[Re])):de.appendChild(Re),e.map.push(e.pos,e.pos+be,Re),e.col+=be,e.pos+=be}if(!Se)break;pe+=be+1;var Ne=void 0;if(Se[0]==" "){var Ue=e.cm.options.tabSize,He=Ue-e.col%Ue;Ne=de.appendChild(a("span",W(He),"cm-tab")),Ne.setAttribute("role","presentation"),Ne.setAttribute("cm-text"," "),e.col+=He}else Se[0]=="\r"||Se[0]==`
`?(Ne=de.appendChild(a("span",Se[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Ne.setAttribute("cm-text",Se[0]),e.col+=1):(Ne=e.cm.options.specialCharPlaceholder(Se[0]),Ne.setAttribute("cm-text",Se[0]),j&&U<9?de.appendChild(a("span",[Ne])):de.appendChild(Ne),e.col+=1);e.map.push(e.pos,e.pos+1,Ne),e.pos++}}if(e.trailingSpace=K.charCodeAt(t.length-1)==32,i||r||n||re||y||N){var Ze=i||"";r&&(Ze+=r),n&&(Ze+=n);var Ge=a("span",[de],Ze,y);if(N)for(var qe in N)N.hasOwnProperty(qe)&&qe!="style"&&qe!="class"&&Ge.setAttribute(qe,N[qe]);return e.content.appendChild(Ge)}e.content.appendChild(de)}function Ht(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var y=e.charAt(n);y==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(y="\xA0"),r+=y,i=y==" "}return r}function ar(e,t){return function(i,r,n,y,N,K,X){n=n?n+" cm-force-border":"cm-force-border";for(var re=i.pos,de=re+r.length;;){for(var pe=void 0,Se=0;Se<t.length&&!(pe=t[Se],pe.to>re&&pe.from<=re);Se++);if(pe.to>=de)return e(i,r,n,y,N,K,X);e(i,r.slice(0,pe.to-re),n,y,null,K,X),y=null,r=r.slice(pe.to-re),re=pe.to}}}function bt(e,t,i,r){var n=!r&&i.widgetNode;n&&e.map.push(e.pos,e.pos+t,n),!r&&e.cm.display.input.needsContentAttribute&&(n||(n=e.content.appendChild(document.createElement("span"))),n.setAttribute("cm-marker",i.id)),n&&(e.cm.display.input.setUneditable(n),e.content.appendChild(n)),e.pos+=t,e.trailingSpace=!1}function Wr(e,t,i){var r=e.markedSpans,n=e.text,y=0;if(!r){for(var N=1;N<i.length;N+=2)t.addToken(t,n.slice(y,y=i[N]),yt(i[N+1],t.cm.options));return}for(var K=n.length,X=0,re=1,de="",pe,Se,be=0,Re,Ne,Ue,He,Ze;;){if(be==X){Re=Ne=Ue=Se="",Ze=null,He=null,be=Infinity;for(var Ge=[],qe=void 0,ut=0;ut<r.length;++ut){var st=r[ut],gt=st.marker;if(gt.type=="bookmark"&&st.from==X&&gt.widgetNode)Ge.push(gt);else if(st.from<=X&&(st.to==null||st.to>X||gt.collapsed&&st.to==X&&st.from==X)){if(st.to!=null&&st.to!=X&&be>st.to&&(be=st.to,Ne=""),gt.className&&(Re+=" "+gt.className),gt.css&&(Se=(Se?Se+";":"")+gt.css),gt.startStyle&&st.from==X&&(Ue+=" "+gt.startStyle),gt.endStyle&&st.to==be&&(qe||(qe=[])).push(gt.endStyle,st.to),gt.title&&((Ze||(Ze={})).title=gt.title),gt.attributes)for(var Rt in gt.attributes)(Ze||(Ze={}))[Rt]=gt.attributes[Rt];gt.collapsed&&(!He||wi(He.marker,gt)<0)&&(He=st)}else st.from>X&&be>st.from&&(be=st.from)}if(qe)for(var Vt=0;Vt<qe.length;Vt+=2)qe[Vt+1]==be&&(Ne+=" "+qe[Vt]);if(!He||He.from==X)for(var Nt=0;Nt<Ge.length;++Nt)bt(t,0,Ge[Nt]);if(He&&(He.from||0)==X){if(bt(t,(He.to==null?K+1:He.to)-X,He.marker,He.from==null),He.to==null)return;He.to==X&&(He=!1)}}if(X>=K)break;for(var pr=Math.min(K,be);;){if(de){var ur=X+de.length;if(!He){var Wt=ur>pr?de.slice(0,pr-X):de;t.addToken(t,Wt,pe?pe+Re:Re,Ue,X+Wt.length==be?Ne:"",Se,Ze)}if(ur>=pr){de=de.slice(pr-X),X=pr;break}X=ur,Ue=""}de=n.slice(y,y=i[re++]),pe=yt(i[re++],t.cm.options)}}}function Lt(e,t,i){this.line=t,this.rest=Li(t),this.size=this.rest?pt(w(this.rest))-i+1:1,this.node=this.text=null,this.hidden=Or(e,t)}function or(e,t,i){for(var r=[],n,y=t;y<i;y=n){var N=new Lt(e.doc,Ye(e.doc,y),y);n=y+N.size,r.push(N)}return r}var qt=null;function Sr(e){qt?qt.ops.push(e):e.ownsGroup=qt={ops:[e],delayedCallbacks:[]}}function Ds(e){var t=e.delayedCallbacks,i=0;do{for(;i<t.length;i++)t[i].call(null);for(var r=0;r<e.ops.length;r++){var n=e.ops[r];if(n.cursorActivityHandlers)for(;n.cursorActivityCalled<n.cursorActivityHandlers.length;)n.cursorActivityHandlers[n.cursorActivityCalled++].call(null,n.cm)}}while(i<t.length)}function Rs(e,t){var i=e.ownsGroup;if(!i)return;try{Ds(i)}finally{qt=null,t(i)}}var tn=null;function Jt(e,t){var i=rt(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;qt?n=qt.delayedCallbacks:tn?n=tn:(n=tn=[],setTimeout(Os,0));for(var y=function(K){n.push(function(){return i[K].apply(null,r)})},N=0;N<i.length;++N)y(N)}function Os(){var e=tn;tn=null;for(var t=0;t<e.length;++t)e[t]()}function Ya(e,t,i,r){for(var n=0;n<t.changes.length;n++){var y=t.changes[n];y=="text"?Ms(e,t):y=="gutter"?Za(e,t,i,r):y=="class"?ha(e,t):y=="widget"&&Is(e,t,r)}t.changes=null}function rn(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),j&&U<8&&(e.node.style.zIndex=2)),e.node}function Ps(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var r=rn(t);t.background=r.insertBefore(a("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function $a(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):Ct(e,t)}function Ms(e,t){var i=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,ha(e,t)):i&&(t.text.className=i)}function ha(e,t){Ps(e,t),t.line.wrapClass?rn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Za(e,t,i,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 n=rn(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),n.insertBefore(t.gutterBackground,t.text)}var y=t.line.gutterMarkers;if(e.options.lineNumbers||y){var N=rn(t),K=t.gutter=a("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(K),N.insertBefore(K,t.text),t.line.gutterClass&&(K.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!y||!y["CodeMirror-linenumbers"])&&(t.lineNumber=K.appendChild(a("div",Ut(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),y)for(var X=0;X<e.display.gutterSpecs.length;++X){var re=e.display.gutterSpecs[X].className,de=y.hasOwnProperty(re)&&y[re];de&&K.appendChild(a("div",[de],"CodeMirror-gutter-elt","left: "+r.gutterLeft[re]+"px; width: "+r.gutterWidth[re]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=g("CodeMirror-linewidget"),n=t.node.firstChild,y=void 0;n;n=y)y=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);Ja(e,t,i)}function Ns(e,t,i,r){var n=$a(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),ha(e,t),Za(e,t,i,r),Ja(e,t,r),t.node}function Ja(e,t,i){if(Qa(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)Qa(e,t.rest[r],t,i,!1)}function Qa(e,t,i,r,n){if(!t.widgets)return;for(var y=rn(i),N=0,K=t.widgets;N<K.length;++N){var X=K[N],re=a("div",[X.node],"CodeMirror-linewidget"+(X.className?" "+X.className:""));X.handleMouseEvents||re.setAttribute("cm-ignore-events","true"),Bs(X,re,i,r),e.display.input.setUneditable(re),n&&X.above?y.insertBefore(re,i.gutter||i.text):y.appendChild(re),Jt(X,"redraw")}}function Bs(e,t,i,r){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var n=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(n-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=n+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function nn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!b(document.body,e.node)){var i="position: relative;";e.coverGutter&&(i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(i+="width: "+t.display.wrapper.clientWidth+"px;"),h(t.display.measure,a("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function jr(e,t){for(var i=me(t);i!=e.wrapper;i=i.parentNode)if(!i||i.nodeType==1&&i.getAttribute("cm-ignore-events")=="true"||i.parentNode==e.sizer&&i!=e.mover)return!0}function Bn(e){return e.lineSpace.offsetTop}function da(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function qa(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=h(e.measure,a("pre","x","CodeMirror-line-like")),i=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(i.paddingLeft),right:parseInt(i.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function Pr(e){return xe-e.display.nativeBarWidth}function ui(e){return e.display.scroller.clientWidth-Pr(e)-e.display.barWidth}function ca(e){return e.display.scroller.clientHeight-Pr(e)-e.display.barHeight}function Fs(e,t,i){var r=e.options.lineWrapping,n=r&&ui(e);if(!t.measure.heights||r&&t.measure.width!=n){var y=t.measure.heights=[];if(r){t.measure.width=n;for(var N=t.text.firstChild.getClientRects(),K=0;K<N.length-1;K++){var X=N[K],re=N[K+1];Math.abs(X.bottom-re.bottom)>2&&y.push((X.bottom+re.top)/2-i.top)}}y.push(i.bottom-i.top)}}function eo(e,t,i){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 n=0;n<e.rest.length;n++)if(pt(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Us(e,t){t=yr(t);var i=pt(t),r=e.display.externalMeasured=new Lt(e.doc,t,i);r.lineN=i;var n=r.built=Ct(e,r);return r.text=n.pre,h(e.display.lineMeasure,n.pre),r}function to(e,t,i,r){return Mr(e,ki(e,t),i,r)}function fa(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[ci(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function ki(e,t){var i=pt(t),r=fa(e,i);r&&!r.text?r=null:r&&r.changes&&(Ya(e,r,i,ba(e)),e.curOp.forceUpdate=!0),r||(r=Us(e,t));var n=eo(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function Mr(e,t,i,r,n){t.before&&(i=-1);var y=i+(r||""),N;return t.cache.hasOwnProperty(y)?N=t.cache[y]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Fs(e,t.view,t.rect),t.hasHeights=!0),N=js(e,t,i,r),N.bogus||(t.cache[y]=N)),{left:N.left,right:N.right,top:n?N.rtop:N.top,bottom:n?N.rbottom:N.bottom}}var ro={left:0,right:0,top:0,bottom:0};function io(e,t,i){for(var r,n,y,N,K,X,re=0;re<e.length;re+=3)if(K=e[re],X=e[re+1],t<K?(n=0,y=1,N="left"):t<X?(n=t-K,y=n+1):(re==e.length-3||t==X&&e[re+3]>t)&&(y=X-K,n=y-1,t>=X&&(N="right")),n!=null){if(r=e[re+2],K==X&&i==(r.insertLeft?"left":"right")&&(N=i),i=="left"&&n==0)for(;re&&e[re-2]==e[re-3]&&e[re-1].insertLeft;)r=e[(re-=3)+2],N="left";if(i=="right"&&n==X-K)for(;re<e.length-3&&e[re+3]==e[re+4]&&!e[re+5].insertLeft;)r=e[(re+=3)+2],N="right";break}return{node:r,start:n,end:y,collapse:N,coverStart:K,coverEnd:X}}function Ws(e,t){var i=ro;if(t=="left")for(var r=0;r<e.length&&!((i=e[r]).left!=i.right);r++);else for(var n=e.length-1;n>=0&&!((i=e[n]).left!=i.right);n--);return i}function js(e,t,i,r){var n=io(t.map,i,r),y=n.node,N=n.start,K=n.end,X=n.collapse,re;if(y.nodeType==3){for(var de=0;de<4;de++){for(;N&&De(t.line.text.charAt(n.coverStart+N));)--N;for(;n.coverStart+K<n.coverEnd&&De(t.line.text.charAt(n.coverStart+K));)++K;if(j&&U<9&&N==0&&K==n.coverEnd-n.coverStart?re=y.parentNode.getBoundingClientRect():re=Ws(p(y,N,K).getClientRects(),r),re.left||re.right||N==0)break;K=N,N=N-1,X="right"}j&&U<11&&(re=Hs(e.display.measure,re))}else{N>0&&(X=r="right");var pe;e.options.lineWrapping&&(pe=y.getClientRects()).length>1?re=pe[r=="right"?pe.length-1:0]:re=y.getBoundingClientRect()}if(j&&U<9&&!N&&(!re||!re.left&&!re.right)){var Se=y.parentNode.getClientRects()[0];Se?re={left:Se.left,right:Se.left+Di(e.display),top:Se.top,bottom:Se.bottom}:re=ro}for(var be=re.top-t.rect.top,Re=re.bottom-t.rect.top,Ne=(be+Re)/2,Ue=t.view.measure.heights,He=0;He<Ue.length-1&&!(Ne<Ue[He]);He++);var Ze=He?Ue[He-1]:0,Ge=Ue[He],qe={left:(X=="right"?re.right:re.left)-t.rect.left,right:(X=="left"?re.left:re.right)-t.rect.left,top:Ze,bottom:Ge};return!re.left&&!re.right&&(qe.bogus=!0),e.options.singleCursorHeightPerLine||(qe.rtop=be,qe.rbottom=Re),qe}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!It(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*r,bottom:t.bottom*r}}function no(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,c(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)no(e.display.view[t])}function an(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&&u?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function so(){return v&&u?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function pa(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=nn(e.widgets[i]));return t}function Fn(e,t,i,r,n){if(!n){var y=pa(t);i.top+=y,i.bottom+=y}if(r=="line")return i;r||(r="local");var N=kr(t);if(r=="local"?N+=Bn(e.display):N-=e.display.viewOffset,r=="page"||r=="window"){var K=e.display.lineSpace.getBoundingClientRect();N+=K.top+(r=="window"?0:so());var X=K.left+(r=="window"?0:oo());i.left+=X,i.right+=X}return i.top+=N,i.bottom+=N,i}function lo(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=oo(),n-=so();else if(i=="local"||!i){var y=e.display.sizer.getBoundingClientRect();r+=y.left,n+=y.top}var N=e.display.lineSpace.getBoundingClientRect();return{left:r-N.left,top:n-N.top}}function ma(e,t,i,r,n){return r||(r=Ye(e.doc,t.line)),Fn(e,r,to(e,r,t.ch,n),i)}function _r(e,t,i,r,n,y){r=r||Ye(e.doc,t.line),n||(n=ki(e,r));function N(Re,Ne){var Ue=Mr(e,n,Re,Ne?"right":"left",y);return Ne?Ue.left=Ue.right:Ue.right=Ue.left,Fn(e,r,Ue,i)}var K=Xe(r,e.doc.direction),X=t.ch,re=t.sticky;if(X>=r.text.length?(X=r.text.length,re="before"):X<=0&&(X=0,re="after"),!K)return N(re=="before"?X-1:X,re=="before");function de(Re,Ne,Ue){var He=K[Ne],Ze=He.level==1;return N(Ue?Re-1:Re,Ze!=Ue)}var pe=Ve(K,X,re),Se=Ke,be=de(X,pe,re=="before");return Se!=null&&(be.other=de(X,Se,re!="before")),be}function uo(e,t){var i=0;t=ft(e.doc,t),e.options.lineWrapping||(i=Di(e.display)*t.ch);var r=Ye(e.doc,t.line),n=kr(r)+Bn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ga(e,t,i,r,n){var y=Be(e,t,i);return y.xRel=n,r&&(y.outside=r),y}function va(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ga(r.first,0,null,-1,-1);var n=At(r,i),y=r.first+r.size-1;if(n>y)return ga(r.first+r.size-1,Ye(r,y).text.length,null,1,1);t<0&&(t=0);for(var N=Ye(r,n);;){var K=Gs(e,N,n,t,i),X=Ai(N,K.ch+(K.xRel>0||K.outside>0?1:0));if(!X)return K;var re=X.find(1);if(re.line==n)return re;N=Ye(r,n=re.line)}}function ho(e,t,i,r){r-=pa(t);var n=t.text.length,y=je(function(N){return Mr(e,i,N-1).bottom<=r},n,0);return n=je(function(N){return Mr(e,i,N).top>r},y,n),{begin:y,end:n}}function co(e,t,i,r){i||(i=ki(e,t));var n=Fn(e,t,Mr(e,i,r),"line").top;return ho(e,t,i,n)}function ya(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function Gs(e,t,i,r,n){n-=kr(t);var y=ki(e,t),N=pa(t),K=0,X=t.text.length,re=!0,de=Xe(t,e.doc.direction);if(de){var pe=(e.options.lineWrapping?Ks:zs)(e,t,i,y,de,r,n);re=pe.level!=1,K=re?pe.from:pe.to-1,X=re?pe.to:pe.from-1}var Se=null,be=null,Re=je(function(ut){var st=Mr(e,y,ut);return st.top+=N,st.bottom+=N,ya(st,r,n,!1)?(st.top<=n&&st.left<=r&&(Se=ut,be=st),!0):!1},K,X),Ne,Ue,He=!1;if(be){var Ze=r-be.left<be.right-r,Ge=Ze==re;Re=Se+(Ge?0:1),Ue=Ge?"after":"before",Ne=Ze?be.left:be.right}else{!re&&(Re==X||Re==K)&&Re++,Ue=Re==0?"after":Re==t.text.length?"before":Mr(e,y,Re-(re?1:0)).bottom+N<=n==re?"after":"before";var qe=_r(e,Be(i,Re,Ue),"line",t,y);Ne=qe.left,He=n<qe.top?-1:n>=qe.bottom?1:0}return Re=Pe(t.text,Re,1),ga(i,Re,Ue,He,r-Ne)}function zs(e,t,i,r,n,y,N){var K=je(function(pe){var Se=n[pe],be=Se.level!=1;return ya(_r(e,Be(i,be?Se.to:Se.from,be?"before":"after"),"line",t,r),y,N,!0)},0,n.length-1),X=n[K];if(K>0){var re=X.level!=1,de=_r(e,Be(i,re?X.from:X.to,re?"after":"before"),"line",t,r);ya(de,y,N,!0)&&de.top>N&&(X=n[K-1])}return X}function Ks(e,t,i,r,n,y,N){var K=ho(e,t,r,N),X=K.begin,re=K.end;/\s/.test(t.text.charAt(re-1))&&re--;for(var de=null,pe=null,Se=0;Se<n.length;Se++){var be=n[Se];if(be.from>=re||be.to<=X)continue;var Re=be.level!=1,Ne=Mr(e,r,Re?Math.min(re,be.to)-1:Math.max(X,be.from)).right,Ue=Ne<y?y-Ne+1e9:Ne-y;(!de||pe>Ue)&&(de=be,pe=Ue)}return de||(de=n[n.length-1]),de.from<X&&(de={from:X,to:de.to,level:de.level}),de.to>re&&(de={from:de.from,to:re,level:de.level}),de}var hi;function _i(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(hi==null){hi=a("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)hi.appendChild(document.createTextNode("x")),hi.appendChild(a("br"));hi.appendChild(document.createTextNode("x"))}h(e.measure,hi);var i=hi.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),c(e.measure),i||1}function Di(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=a("span","xxxxxxxxxx"),i=a("pre",[t],"CodeMirror-line-like");h(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function ba(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,y=t.gutters.firstChild,N=0;y;y=y.nextSibling,++N){var K=e.display.gutterSpecs[N].className;i[K]=y.offsetLeft+y.clientLeft+n,r[K]=y.clientWidth}return{fixedPos:xa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function xa(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function fo(e){var t=_i(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/Di(e.display)-3);return function(n){if(Or(e.doc,n))return 0;var y=0;if(n.widgets)for(var N=0;N<n.widgets.length;N++)n.widgets[N].height&&(y+=n.widgets[N].height);return i?y+(Math.ceil(n.text.length/r)||1)*t:y+t}}function Ea(e){var t=e.doc,i=fo(e);t.iter(function(r){var n=i(r);n!=r.height&&mt(r,n)})}function di(e,t,i,r){var n=e.display;if(!i&&me(t).getAttribute("cm-not-content")=="true")return null;var y,N,K=n.lineSpace.getBoundingClientRect();try{y=t.clientX-K.left,N=t.clientY-K.top}catch(pe){return null}var X=va(e,y,N),re;if(r&&X.xRel>0&&(re=Ye(e.doc,X.line).text).length==X.ch){var de=ne(re,re.length,e.options.tabSize)-re.length;X=Be(X.line,Math.max(0,Math.round((y-qa(e.display).left)/Di(e.display))-de))}return X}function ci(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var i=e.display.view,r=0;r<i.length;r++)if(t-=i[r].size,t<0)return r}function sr(e,t,i,r){t==null&&(t=e.doc.first),i==null&&(i=e.doc.first+e.doc.size),r||(r=0);var n=e.display;if(r&&i<n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>t)&&(n.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=n.viewTo)rr&&Qi(e.doc,t)<n.viewTo&&Yr(e);else if(i<=n.viewFrom)rr&&Vr(e.doc,i+r)>n.viewFrom?Yr(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Yr(e);else if(t<=n.viewFrom){var y=Un(e,i,i+r,1);y?(n.view=n.view.slice(y.index),n.viewFrom=y.lineN,n.viewTo+=r):Yr(e)}else if(i>=n.viewTo){var N=Un(e,t,t,-1);N?(n.view=n.view.slice(0,N.index),n.viewTo=N.lineN):Yr(e)}else{var K=Un(e,t,t,-1),X=Un(e,i,i+r,1);K&&X?(n.view=n.view.slice(0,K.index).concat(or(e,K.lineN,X.lineN)).concat(n.view.slice(X.index)),n.viewTo+=r):Yr(e)}var re=n.externalMeasured;re&&(i<re.lineN?re.lineN+=r:t<re.lineN+re.size&&(n.externalMeasured=null))}function Xr(e,t,i){e.curOp.viewChanged=!0;var r=e.display,n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size&&(r.externalMeasured=null),t<r.viewFrom||t>=r.viewTo)return;var y=r.view[ci(e,t)];if(y.node==null)return;var N=y.changes||(y.changes=[]);ge(N,i)==-1&&N.push(i)}function Yr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Un(e,t,i,r){var n=ci(e,t),y,N=e.display.view;if(!rr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var K=e.display.viewFrom,X=0;X<n;X++)K+=N[X].size;if(K!=t){if(r>0){if(n==N.length-1)return null;y=K+N[n].size-t,n++}else y=K-t;t+=y,i+=y}for(;Qi(e.doc,i)!=i;){if(n==(r<0?0:N.length-1))return null;i+=r*N[n-(r<0?1:0)].size,n+=r}return{index:n,lineN:i}}function Vs(e,t,i){var r=e.display,n=r.view;n.length==0||t>=r.viewTo||i<=r.viewFrom?(r.view=or(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=or(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(ci(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(or(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,ci(e,i)))),r.viewTo=i}function po(e){for(var t=e.display.view,i=0,r=0;r<t.length;r++){var n=t[r];!n.hidden&&(!n.node||n.changes)&&++i}return i}function on(e){e.display.input.showSelection(e.display.input.prepareSelection())}function mo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),y=r.selection=document.createDocumentFragment(),N=0;N<i.sel.ranges.length;N++){if(!t&&N==i.sel.primIndex)continue;var K=i.sel.ranges[N];if(K.from().line>=e.display.viewTo||K.to().line<e.display.viewFrom)continue;var X=K.empty();(X||e.options.showCursorWhenSelecting)&&go(e,K.head,n),X||Xs(e,K,y)}return r}function go(e,t,i){var r=_r(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(a("div","\xA0","CodeMirror-cursor"));if(n.style.left=r.left+"px",n.style.top=r.top+"px",n.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var y=i.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 Wn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,y=document.createDocumentFragment(),N=qa(e.display),K=N.left,X=Math.max(r.sizerWidth,ui(e)-r.sizer.offsetLeft)-N.right,re=n.direction=="ltr";function de(Ge,qe,ut,st){qe<0&&(qe=0),qe=Math.round(qe),st=Math.round(st),y.appendChild(a("div",null,"CodeMirror-selected","position: absolute; left: "+Ge+`px;
top: `+qe+"px; width: "+(ut==null?X-Ge:ut)+`px;
height: `+(st-qe)+"px"))}function pe(Ge,qe,ut){var st=Ye(n,Ge),gt=st.text.length,Rt,Vt;function Nt(Wt,hr){return ma(e,Be(Ge,Wt),"div",st,hr)}function pr(Wt,hr,Qt){var Gt=co(e,st,null,Wt),jt=hr=="ltr"==(Qt=="after")?"left":"right",Bt=Qt=="after"?Gt.begin:Gt.end-(/\s/.test(st.text.charAt(Gt.end-1))?2:1);return Nt(Bt,jt)[jt]}var ur=Xe(st,n.direction);return ze(ur,qe||0,ut==null?gt:ut,function(Wt,hr,Qt,Gt){var jt=Qt=="ltr",Bt=Nt(Wt,jt?"left":"right"),dr=Nt(hr-1,jt?"right":"left"),Gi=qe==null&&Wt==0,ei=ut==null&&hr==gt,tr=Gt==0,Ir=!ur||Gt==ur.length-1;if(dr.top-Bt.top<=3){var Xt=(re?Gi:ei)&&tr,Va=(re?ei:Gi)&&Ir,Gr=Xt?K:(jt?Bt:dr).left,vi=Va?X:(jt?dr:Bt).right;de(Gr,Bt.top,vi-Gr,Bt.bottom)}else{var yi,nr,zi,Xa;jt?(yi=re&&Gi&&tr?K:Bt.left,nr=re?X:pr(Wt,Qt,"before"),zi=re?K:pr(hr,Qt,"after"),Xa=re&&ei&&Ir?X:dr.right):(yi=re?pr(Wt,Qt,"before"):K,nr=!re&&Gi&&tr?X:Bt.right,zi=!re&&ei&&Ir?K:dr.left,Xa=re?pr(hr,Qt,"after"):X),de(yi,Bt.top,nr-yi,Bt.bottom),Bt.bottom<dr.top&&de(K,Bt.bottom,null,dr.top),de(zi,dr.top,Xa-zi,dr.bottom)}(!Rt||Wn(Bt,Rt)<0)&&(Rt=Bt),Wn(dr,Rt)<0&&(Rt=dr),(!Vt||Wn(Bt,Vt)<0)&&(Vt=Bt),Wn(dr,Vt)<0&&(Vt=dr)}),{start:Rt,end:Vt}}var Se=t.from(),be=t.to();if(Se.line==be.line)pe(Se.line,Se.ch,be.ch);else{var Re=Ye(n,Se.line),Ne=Ye(n,be.line),Ue=yr(Re)==yr(Ne),He=pe(Se.line,Se.ch,Ue?Re.text.length+1:null).end,Ze=pe(be.line,Ue?0:null,be.ch).start;Ue&&(He.top<Ze.top-2?(de(He.right,He.top,null,He.bottom),de(K,Ze.top,Ze.left,Ze.bottom)):de(He.right,He.top,Ze.left-He.right,He.bottom)),He.bottom<Ze.top&&de(K,He.bottom,null,Ze.top)}i.appendChild(y)}function Sa(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||Ri(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function vo(e){e.state.focused||(e.display.input.focus(),Ta(e))}function yo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Ri(e))},100)}function Ta(e,t){if(e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),e.options.readOnly=="nocursor")return;e.state.focused||(ae(e,"focus",e,t),e.state.focused=!0,G(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),P&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Sa(e)}function Ri(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(ae(e,"blur",e,t),e.state.focused=!1,d(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function jn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],y=e.options.lineWrapping,N=void 0,K=0;if(n.hidden)continue;if(j&&U<8){var X=n.node.offsetTop+n.node.offsetHeight;N=X-i,i=X}else{var re=n.node.getBoundingClientRect();N=re.bottom-re.top,!y&&n.text.firstChild&&(K=n.text.firstChild.getBoundingClientRect().right-re.left-1)}var de=n.line.height-N;if((de>.005||de<-.005)&&(mt(n.line,N),bo(n.line),n.rest))for(var pe=0;pe<n.rest.length;pe++)bo(n.rest[pe]);if(K>e.display.sizerWidth){var Se=Math.ceil(K/Di(e.display));Se>e.display.maxLineLength&&(e.display.maxLineLength=Se,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function bo(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var i=e.widgets[t],r=i.node.parentNode;r&&(i.height=r.offsetHeight)}}function Hn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Bn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,y=At(t,r),N=At(t,n);if(i&&i.ensure){var K=i.ensure.from.line,X=i.ensure.to.line;K<y?(y=K,N=At(t,kr(Ye(t,K))+e.wrapper.clientHeight)):Math.min(X,t.lastLine())>=N&&(y=At(t,kr(Ye(t,X))-e.wrapper.clientHeight),N=X)}return{from:y,to:Math.max(N,y+1)}}function Ys(e,t){if(V(e,"scrollCursorIntoView"))return;var i=e.display,r=i.sizer.getBoundingClientRect(),n=null;if(t.top+r.top<0?n=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(n=!1),n!=null&&!C){var y=a("div","\u200B",null,`position: absolute;
top: `+(t.top-i.viewOffset-Bn(e.display))+`px;
height: `+(t.bottom-t.top+Pr(e)+i.barHeight)+`px;
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(y),y.scrollIntoView(n),e.display.lineSpace.removeChild(y)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?Be(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?Be(t.line,t.ch+1,"before"):t);for(var y=0;y<5;y++){var N=!1,K=_r(e,t),X=!i||i==t?K:_r(e,i);n={left:Math.min(K.left,X.left),top:Math.min(K.top,X.top)-r,right:Math.max(K.left,X.left),bottom:Math.max(K.bottom,X.bottom)+r};var re=Ca(e,n),de=e.doc.scrollTop,pe=e.doc.scrollLeft;if(re.scrollTop!=null&&(ln(e,re.scrollTop),Math.abs(e.doc.scrollTop-de)>1&&(N=!0)),re.scrollLeft!=null&&(fi(e,re.scrollLeft),Math.abs(e.doc.scrollLeft-pe)>1&&(N=!0)),!N)break}return n}function Zs(e,t){var i=Ca(e,t);i.scrollTop!=null&&ln(e,i.scrollTop),i.scrollLeft!=null&&fi(e,i.scrollLeft)}function Ca(e,t){var i=e.display,r=_i(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,y=ca(e),N={};t.bottom-t.top>y&&(t.bottom=t.top+y);var K=e.doc.height+da(i),X=t.top<r,re=t.bottom>K-r;if(t.top<n)N.scrollTop=X?0:t.top;else if(t.bottom>n+y){var de=Math.min(t.top,(re?K:t.bottom)-y);de!=n&&(N.scrollTop=de)}var pe=e.options.fixedGutter?0:i.gutters.offsetWidth,Se=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-pe,be=ui(e)-i.gutters.offsetWidth,Re=t.right-t.left>be;return Re&&(t.right=t.left+be),t.left<10?N.scrollLeft=0:t.left<Se?N.scrollLeft=Math.max(0,t.left+pe-(Re?0:10)):t.right>be+Se-3&&(N.scrollLeft=t.right+(Re?0:10)-be),N}function wa(e,t){if(t==null)return;Gn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function Oi(e){Gn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function sn(e,t,i){(t!=null||i!=null)&&Gn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Gn(e),e.curOp.scrollToPos=t}function Gn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=uo(e,t.from),r=uo(e,t.to);xo(e,i,r,t.margin)}}function xo(e,t,i,r){var n=Ca(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-r,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+r});sn(e,n.scrollLeft,n.scrollTop)}function ln(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;_||La(e,{top:t}),Eo(e,t,!0),_&&La(e),dn(e,100)}function Eo(e,t,i){if(t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!i)return;e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t)}function fi(e,t,i,r){if(t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(i?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r)return;e.doc.scrollLeft=t,Ao(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function un(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+da(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?i:0,docHeight:r,scrollHeight:r+Pr(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var pi=function(e,t,i){this.cm=i;var r=this.vert=a("div",[a("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=a("div",[a("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),Ae(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ae(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,j&&U<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};pi.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var n=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+n)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var y=e.viewWidth-e.barLeft-(i?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:i?r:0,bottom:t?r:0}},pi.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},pi.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},pi.prototype.zeroWidthHack=function(){var e=s&&!A?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new ce,this.disableVert=new ce},pi.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),y=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);y!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},pi.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var hn=function(){};hn.prototype.update=function(){return{bottom:0,right:0}},hn.prototype.setScrollLeft=function(){},hn.prototype.setScrollTop=function(){},hn.prototype.clear=function(){};function Pi(e,t){t||(t=un(e));var i=e.display.barWidth,r=e.display.barHeight;So(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&jn(e),So(e,un(e)),i=e.display.barWidth,r=e.display.barHeight}function So(e,t){var i=e.display,r=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=r.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=r.bottom)+"px",i.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=r.bottom+"px",i.scrollbarFiller.style.width=r.right+"px"):i.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=r.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}var To={native:pi,null:hn};function Co(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&d(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new To[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Ae(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){i=="horizontal"?fi(e,t):ln(e,t)},e),e.display.scrollbars.addClass&&G(e.display.wrapper,e.display.scrollbars.addClass)}var Qs=0;function mi(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:++Qs},Sr(e.curOp)}function gi(e){var t=e.curOp;t&&Rs(t,function(i){for(var r=0;r<i.ops.length;r++)i.ops[r].cm.curOp=null;qs(i)})}function qs(e){for(var t=e.ops,i=0;i<t.length;i++)el(t[i]);for(var r=0;r<t.length;r++)tl(t[r]);for(var n=0;n<t.length;n++)rl(t[n]);for(var y=0;y<t.length;y++)il(t[y]);for(var N=0;N<t.length;N++)nl(t[N])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&Nn(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new zn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&Aa(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&jn(t),e.barMeasure=un(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=to(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+Pr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-ui(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function il(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&fi(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var i=e.focus&&e.focus==M();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&Pi(t,e.barMeasure),e.updatedDisplay&&_a(t,e.barMeasure),e.selectionChanged&&Sa(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&vo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&wo(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&Eo(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&fi(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,ft(r,e.scrollToPos.from),ft(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var y=e.maybeHiddenMarkers,N=e.maybeUnhiddenMarkers;if(y)for(var K=0;K<y.length;++K)y[K].lines.length||ae(y[K],"hide");if(N)for(var X=0;X<N.length;++X)N[X].lines.length&&ae(N[X],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function fr(e,t){if(e.curOp)return t();mi(e);try{return t()}finally{gi(e)}}function zt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);mi(e);try{return t.apply(e,arguments)}finally{gi(e)}}}function ir(e){return function(){if(this.curOp)return e.apply(this,arguments);mi(this);try{return e.apply(this,arguments)}finally{gi(this)}}}function Kt(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);mi(t);try{return e.apply(this,arguments)}finally{gi(t)}}}function dn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,z(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Cr(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(y){if(r.line>=e.display.viewFrom){var N=y.styles,K=y.text.length>e.options.maxHighlightLength?$t(t.mode,r.state):null,X=Ki(e,y,r,!0);K&&(r.state=K),y.styles=X.styles;var re=y.styleClasses,de=X.classes;de?y.styleClasses=de:re&&(y.styleClasses=null);for(var pe=!N||N.length!=y.styles.length||re!=de&&(!re||!de||re.bgClass!=de.bgClass||re.textClass!=de.textClass),Se=0;!pe&&Se<N.length;++Se)pe=N[Se]!=y.styles[Se];pe&&n.push(r.line),y.stateAfter=r.save(),r.nextLine()}else y.text.length<=e.options.maxHighlightLength&&Vi(e,y.text,r),y.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return dn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&fr(e,function(){for(var y=0;y<n.length;y++)Xr(e,n[y],"text")})}var zn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Hn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=ui(e),this.force=i,this.dims=ba(e),this.events=[]};zn.prototype.signal=function(e,t){te(e,t)&&this.events.push(arguments)},zn.prototype.finish=function(){for(var e=0;e<this.events.length;e++)ae.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=Pr(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Pr(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=M();if(!t||!b(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&b(e.display.lineDiv,r.anchorNode)&&(i.anchorNode=r.anchorNode,i.anchorOffset=r.anchorOffset,i.focusNode=r.focusNode,i.focusOffset=r.focusOffset)}return i}function ll(e){if(!e||!e.activeElt||e.activeElt==M())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&b(document.body,e.anchorNode)&&b(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset),i.collapse(!1),t.removeAllRanges(),t.addRange(i),t.extend(e.focusNode,e.focusOffset)}}function Aa(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Yr(e),!1;if(!t.force&&t.visible.from>=i.viewFrom&&t.visible.to<=i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&po(e)==0)return!1;Lo(e)&&(Yr(e),t.dims=ba(e));var n=r.first+r.size,y=Math.max(t.visible.from-e.options.viewportMargin,r.first),N=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<y&&y-i.viewFrom<20&&(y=Math.max(r.first,i.viewFrom)),i.viewTo>N&&i.viewTo-N<20&&(N=Math.min(n,i.viewTo)),rr&&(y=Qi(e.doc,y),N=Vr(e.doc,N));var K=y!=i.viewFrom||N!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,y,N),i.viewOffset=kr(Ye(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var X=po(e);if(!K&&X==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var re=sl(e);return X>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),X>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(re),c(i.cursorDiv),c(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,K&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,dn(e,400)),i.updateLineNumbers=null,!0}function wo(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==ui(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+da(e.display)-ca(e),i.top)}),t.visible=Hn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Hn(e.display,e.doc,i));if(!Aa(e,t))break;jn(e);var n=un(e);on(e),Pi(e,n),_a(e,n),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 La(e,t){var i=new zn(e,t);if(Aa(e,i)){jn(e),wo(e,i);var r=un(e);on(e),Pi(e,r),_a(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,y=r.lineDiv,N=y.firstChild;function K(Re){var Ne=Re.nextSibling;return P&&s&&e.display.currentWheelTarget==Re?Re.style.display="none":Re.parentNode.removeChild(Re),Ne}for(var X=r.view,re=r.viewFrom,de=0;de<X.length;de++){var pe=X[de];if(!pe.hidden)if(!pe.node||pe.node.parentNode!=y){var Se=Ns(e,pe,re,i);y.insertBefore(Se,N)}else{for(;N!=pe.node;)N=K(N);var be=n&&t!=null&&t<=re&&pe.lineNumber;pe.changes&&(ge(pe.changes,"gutter")>-1&&(be=!1),Ya(e,pe,re,i)),be&&(c(pe.lineNumber),pe.lineNumber.appendChild(document.createTextNode(Ut(e.options,re)))),N=pe.node.nextSibling}re+=pe.size}for(;N;)N=K(N)}function ka(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+Pr(e)+"px"}function Ao(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=xa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,y=r+"px",N=0;N<i.length;N++)if(!i[N].hidden){e.options.fixedGutter&&(i[N].gutter&&(i[N].gutter.style.left=y),i[N].gutterBackground&&(i[N].gutterBackground.style.left=y));var K=i[N].alignable;if(K)for(var X=0;X<K.length;X++)K[X].style.left=y}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Lo(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=Ut(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(a("div",[a("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),y=n.firstChild.offsetWidth,N=n.offsetWidth-y;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(y,r.lineGutter.offsetWidth-N)+1,r.lineNumWidth=r.lineNumInnerWidth+N,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",ka(e.display),!0}return!1}function Da(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var y=e[n],N=null;if(typeof y!="string"&&(N=y.style,y=y.className),y=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:y,style:N})}return t&&!r&&i.push({className:"CodeMirror-linenumbers",style:null}),i}function ko(e){var t=e.gutters,i=e.gutterSpecs;c(t),e.lineGutter=null;for(var r=0;r<i.length;++r){var n=i[r],y=n.className,N=n.style,K=t.appendChild(a("div",null,"CodeMirror-gutter "+y));N&&(K.style.cssText=N),y=="CodeMirror-linenumbers"&&(e.lineGutter=K,K.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",ka(e)}function cn(e){ko(e.display),sr(e),Ao(e)}function hl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=a("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=a("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=x("div",null,"CodeMirror-code"),n.selectionDiv=a("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=a("div",null,"CodeMirror-cursors"),n.measure=a("div",null,"CodeMirror-measure"),n.lineMeasure=a("div",null,"CodeMirror-measure"),n.lineSpace=x("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var y=x("div",[n.lineSpace],"CodeMirror-lines");n.mover=a("div",[y],null,"position: relative"),n.sizer=a("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=a("div",null,null,"position: absolute; height: "+xe+"px; width: 1px;"),n.gutters=a("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=a("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=a("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),j&&U<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!P&&!(_&&o)&&(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,n.gutterSpecs=Da(r.gutters,r.lineNumbers),ko(n),i.init(n)}var Kn=0,br=null;j?br=-.53:_?br=15:v?br=-.7:R&&(br=-1/3);function _o(e){var t=e.wheelDeltaX,i=e.wheelDeltaY;return t==null&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),i==null&&e.detail&&e.axis==e.VERTICAL_AXIS?i=e.detail:i==null&&(i=e.wheelDelta),{x:t,y:i}}function dl(e){var t=_o(e);return t.x*=br,t.y*=br,t}function Do(e,t){var i=_o(t),r=i.x,n=i.y,y=e.display,N=y.scroller,K=N.scrollWidth>N.clientWidth,X=N.scrollHeight>N.clientHeight;if(!(r&&K||n&&X))return;if(n&&s&&P){e:for(var re=t.target,de=y.view;re!=N;re=re.parentNode)for(var pe=0;pe<de.length;pe++)if(de[pe].node==re){e.display.currentWheelTarget=re;break e}}if(r&&!_&&!T&&br!=null){n&&X&&ln(e,Math.max(0,N.scrollTop+n*br)),fi(e,Math.max(0,N.scrollLeft+r*br)),(!n||n&&X)&&Q(t),y.wheelStartX=null;return}if(n&&br!=null){var Se=n*br,be=e.doc.scrollTop,Re=be+y.wrapper.clientHeight;Se<0?be=Math.max(0,be+Se-50):Re=Math.min(e.doc.height,Re+Se+50),La(e,{top:be,bottom:Re})}Kn<20&&(y.wheelStartX==null?(y.wheelStartX=N.scrollLeft,y.wheelStartY=N.scrollTop,y.wheelDX=r,y.wheelDY=n,setTimeout(function(){if(y.wheelStartX==null)return;var Ne=N.scrollLeft-y.wheelStartX,Ue=N.scrollTop-y.wheelStartY,He=Ue&&y.wheelDY&&Ue/y.wheelDY||Ne&&y.wheelDX&&Ne/y.wheelDX;if(y.wheelStartX=y.wheelStartY=null,!He)return;br=(br*Kn+He)/(Kn+1),++Kn},200)):(y.wheelDX+=r,y.wheelDY+=n))}var xr=function(e,t){this.ranges=e,this.primIndex=t};xr.prototype.primary=function(){return this.ranges[this.primIndex]},xr.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 i=this.ranges[t],r=e.ranges[t];if(!ri(i.anchor,r.anchor)||!ri(i.head,r.head))return!1}return!0},xr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new kt(bi(this.ranges[t].anchor),bi(this.ranges[t].head));return new xr(e,this.primIndex)},xr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},xr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(ht(t,r.from())>=0&&ht(e,r.to())<=0)return i}return-1};var kt=function(e,t){this.anchor=e,this.head=t};kt.prototype.from=function(){return ii(this.anchor,this.head)},kt.prototype.to=function(){return xi(this.anchor,this.head)},kt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Dr(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(Se,be){return ht(Se.from(),be.from())}),i=ge(t,n);for(var y=1;y<t.length;y++){var N=t[y],K=t[y-1],X=ht(K.to(),N.from());if(r&&!N.empty()?X>0:X>=0){var re=ii(K.from(),N.from()),de=xi(K.to(),N.to()),pe=K.empty()?N.from()==N.head:K.from()==K.head;y<=i&&--i,t.splice(--y,2,new kt(pe?de:re,pe?re:de))}}return new xr(t,i)}function $r(e,t){return new xr([new kt(e,t||e)],0)}function Zr(e){return e.text?Be(e.from.line+e.text.length-1,w(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Ro(e,t){if(ht(e,t.from)<0)return e;if(ht(e,t.to)<=0)return Zr(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Zr(t).ch-t.to.ch),Be(i,r)}function Ra(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new kt(Ro(n.anchor,t),Ro(n.head,t)))}return Dr(e.cm,i,e.sel.primIndex)}function Oo(e,t,i){return e.line==t.line?Be(i.line,e.ch-t.ch+i.ch):Be(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=Be(e.first,0),y=n,N=0;N<t.length;N++){var K=t[N],X=Oo(K.from,n,y),re=Oo(Zr(K),n,y);if(n=K.to,y=re,i=="around"){var de=e.sel.ranges[N],pe=ht(de.head,de.anchor)<0;r[N]=new kt(pe?re:X,pe?X:re)}else r[N]=new kt(X,X)}return new xr(r,e.sel.primIndex)}function Oa(e){e.doc.mode=gr(e.options,e.doc.modeOption),fn(e)}function fn(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,dn(e,100),e.state.modeGen++,e.curOp&&sr(e)}function Po(e,t){return t.from.ch==0&&t.to.ch==0&&w(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Pa(e,t,i,r){function n(Ze){return i?i[Ze]:null}function y(Ze,Ge,qe){ua(Ze,Ge,qe,r),Jt(Ze,"change",Ze,t)}function N(Ze,Ge){for(var qe=[],ut=Ze;ut<Ge;++ut)qe.push(new li(re[ut],n(ut),r));return qe}var K=t.from,X=t.to,re=t.text,de=Ye(e,K.line),pe=Ye(e,X.line),Se=w(re),be=n(re.length-1),Re=X.line-K.line;if(t.full)e.insert(0,N(0,re.length)),e.remove(re.length,e.size-re.length);else if(Po(e,t)){var Ne=N(0,re.length-1);y(pe,pe.text,be),Re&&e.remove(K.line,Re),Ne.length&&e.insert(K.line,Ne)}else if(de==pe)if(re.length==1)y(de,de.text.slice(0,K.ch)+Se+de.text.slice(X.ch),be);else{var Ue=N(1,re.length-1);Ue.push(new li(Se+de.text.slice(X.ch),be,r)),y(de,de.text.slice(0,K.ch)+re[0],n(0)),e.insert(K.line+1,Ue)}else if(re.length==1)y(de,de.text.slice(0,K.ch)+re[0]+pe.text.slice(X.ch),n(0)),e.remove(K.line+1,Re);else{y(de,de.text.slice(0,K.ch)+re[0],n(0)),y(pe,Se+pe.text.slice(X.ch),be);var He=N(1,re.length-1);Re>1&&e.remove(K.line+1,Re-1),e.insert(K.line+1,He)}Jt(e,"change",e,t)}function Jr(e,t,i){function r(n,y,N){if(n.linked)for(var K=0;K<n.linked.length;++K){var X=n.linked[K];if(X.doc==y)continue;var re=N&&X.sharedHist;if(i&&!re)continue;t(X.doc,re),r(X.doc,n,re)}}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,Ea(e),Oa(e),Io(e),e.options.lineWrapping||Nn(e),e.options.mode=t.modeOption,sr(e)}function Io(e){(e.doc.direction=="rtl"?G:d)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){fr(e,function(){Io(e),sr(e)})}function Vn(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 i={from:bi(t.from),to:Zr(t),text:Tt(e,t.from,t.to)};return Fo(e,i,t.from.line,t.to.line+1),Jr(e,function(r){return Fo(r,i,t.from.line,t.to.line+1)},!0),i}function No(e){for(;e.length;){var t=w(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return No(e.done),w(e.done);if(e.done.length&&!w(e.done).ranges)return w(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),w(e.done)}function Bo(e,t,i,r){var n=e.history;n.undone.length=0;var y=+new Date,N,K;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>y-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(N=pl(n,n.lastOp==r)))K=w(N.changes),ht(t.from,t.to)==0&&ht(t.from,K.to)==0?K.to=Zr(t):N.changes.push(Ma(e,t));else{var X=w(n.done);for((!X||!X.ranges)&&Xn(e.sel,n.done),N={changes:[Ma(e,t)],generation:n.generation},n.done.push(N);n.done.length>n.undoDepth;)n.done.shift(),n.done[0].ranges||n.done.shift()}n.done.push(i),n.generation=++n.maxGeneration,n.lastModTime=n.lastSelTime=y,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,K||ae(e,"historyAdded")}function ml(e,t,i,r){var n=t.charAt(0);return n=="*"||n=="+"&&i.ranges.length==r.ranges.length&&i.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function gl(e,t,i,r){var n=e.history,y=r&&r.origin;i==n.lastSelOp||y&&n.lastSelOrigin==y&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==y||ml(e,y,w(n.done),t))?n.done[n.done.length-1]=t:Xn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=y,n.lastSelOp=i,r&&r.clearRedo!==!1&&No(n.undone)}function Xn(e,t){var i=w(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Fo(e,t,i,r){var n=t["spans_"+e.id],y=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(N){N.markedSpans&&((n||(n=t["spans_"+e.id]={}))[y]=N.markedSpans),++y})}function vl(e){if(!e)return null;for(var t,i=0;i<e.length;++i)e[i].marker.explicitlyCleared?t||(t=e.slice(0,i)):t&&t.push(e[i]);return t?t.length?t:null:e}function yl(e,t){var i=t["spans_"+e.id];if(!i)return null;for(var r=[],n=0;n<t.text.length;++n)r.push(vl(i[n]));return r}function Uo(e,t){var i=yl(e,t),r=Ti(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var y=i[n],N=r[n];if(y&&N){e:for(var K=0;K<N.length;++K){for(var X=N[K],re=0;re<y.length;++re)if(y[re].marker==X.marker)continue e;y.push(X)}}else N&&(i[n]=N)}return i}function Mi(e,t,i){for(var r=[],n=0;n<e.length;++n){var y=e[n];if(y.ranges){r.push(i?xr.prototype.deepCopy.call(y):y);continue}var N=y.changes,K=[];r.push({changes:K});for(var X=0;X<N.length;++X){var re=N[X],de=void 0;if(K.push({from:re.from,to:re.to,text:re.text}),t)for(var pe in re)(de=pe.match(/^spans_(\d+)$/))&&(ge(t,Number(de[1]))>-1&&(w(K)[pe]=re[pe],delete re[pe]))}}return r}function Ia(e,t,i,r){if(r){var n=e.anchor;if(i){var y=ht(t,n)<0;y!=ht(i,n)<0?(n=t,t=i):y!=ht(t,i)<0&&(t=i)}return new kt(n,t)}else return new kt(i||t,t)}function Yn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),er(e,new xr([Ia(e.sel.primary(),t,i,n)],0),r)}function Wo(e,t,i){for(var r=[],n=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,n);var N=Dr(e.cm,r,e.sel.primIndex);er(e,N,i)}function Na(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,er(e,Dr(e.cm,n,e.sel.primIndex),r)}function jo(e,t,i,r){er(e,$r(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var y=0;y<n.length;y++)this.ranges[y]=new kt(ft(e,n[y].anchor),ft(e,n[y].head))},origin:i&&i.origin};return ae(e,"beforeSelectionChange",e,r),e.cm&&ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?Dr(e.cm,r.ranges,r.ranges.length-1):t}function Ho(e,t,i){var r=e.history.done,n=w(r);n&&n.ranges?(r[r.length-1]=t,$n(e,t,i)):er(e,t,i)}function er(e,t,i){$n(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function $n(e,t,i){(te(e,"beforeSelectionChange")||e.cm&&te(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(ht(t.primary().head,e.sel.primary().head)<0?-1:1);Go(e,Ko(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&Oi(e.cm)}function Go(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,Y(e.cm)),Jt(e,"cursorActivity",e)}function zo(e){Go(e,Ko(e,e.sel,null,!1))}function Ko(e,t,i,r){for(var n,y=0;y<t.ranges.length;y++){var N=t.ranges[y],K=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[y],X=Zn(e,N.anchor,K&&K.anchor,i,r),re=Zn(e,N.head,K&&K.head,i,r);(n||X!=N.anchor||re!=N.head)&&(n||(n=t.ranges.slice(0,y)),n[y]=new kt(X,re))}return n?Dr(e.cm,n,t.primIndex):t}function Ii(e,t,i,r,n){var y=Ye(e,t.line);if(y.markedSpans)for(var N=0;N<y.markedSpans.length;++N){var K=y.markedSpans[N],X=K.marker,re="selectLeft"in X?!X.selectLeft:X.inclusiveLeft,de="selectRight"in X?!X.selectRight:X.inclusiveRight;if((K.from==null||(re?K.from<=t.ch:K.from<t.ch))&&(K.to==null||(de?K.to>=t.ch:K.to>t.ch))){if(n&&(ae(X,"beforeCursorEnter"),X.explicitlyCleared))if(y.markedSpans){--N;continue}else break;if(!X.atomic)continue;if(i){var pe=X.find(r<0?1:-1),Se=void 0;if((r<0?de:re)&&(pe=Vo(e,pe,-r,pe&&pe.line==t.line?y:null)),pe&&pe.line==t.line&&(Se=ht(pe,i))&&(r<0?Se<0:Se>0))return Ii(e,pe,t,r,n)}var be=X.find(r<0?-1:1);return(r<0?re:de)&&(be=Vo(e,be,r,be.line==t.line?y:null)),be?Ii(e,be,t,r,n):null}}return t}function Zn(e,t,i,r,n){var y=r||1,N=Ii(e,t,i,y,n)||!n&&Ii(e,t,i,y,!0)||Ii(e,t,i,-y,n)||!n&&Ii(e,t,i,-y,!0);return N||(e.cantEdit=!0,Be(e.first,0))}function Vo(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?ft(e,Be(t.line-1)):null:i>0&&t.ch==(r||Ye(e,t.line)).text.length?t.line<e.first+e.size-1?Be(t.line+1,0):null:new Be(t.line,t.ch+i)}function Xo(e){e.setSelection(Be(e.firstLine(),0),Be(e.lastLine()),Te)}function Yo(e,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return i&&(r.update=function(n,y,N,K){n&&(r.from=ft(e,n)),y&&(r.to=ft(e,y)),N&&(r.text=N),K!==void 0&&(r.origin=K)}),ae(e,"beforeChange",e,r),e.cm&&ae(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 Ni(e,t,i){if(e.cm){if(!e.cm.curOp)return zt(e.cm,Ni)(e,t,i);if(e.cm.state.suppressEdits)return}if((te(e,"beforeChange")||e.cm&&te(e.cm,"beforeChange"))&&(t=Yo(e,t,!0),!t))return;var r=Zi&&!i&&Pn(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)$o(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else $o(e,t)}function $o(e,t){if(t.text.length==1&&t.text[0]==""&&ht(t.from,t.to)==0)return;var i=Ra(e,t);Bo(e,t,i,e.cm?e.cm.curOp.id:NaN),pn(e,t,i,Ti(e,t));var r=[];Jr(e,function(n,y){!y&&ge(r,n.history)==-1&&(qo(n.history,t),r.push(n.history)),pn(n,t,null,Ti(n,t))})}function Jn(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,y,N=e.sel,K=t=="undo"?n.done:n.undone,X=t=="undo"?n.undone:n.done,re=0;re<K.length&&!(y=K[re],i?y.ranges&&!y.equals(e.sel):!y.ranges);re++);if(re==K.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(y=K.pop(),y.ranges){if(Xn(y,X),i&&!y.equals(e.sel)){er(e,y,{clearRedo:!1});return}N=y}else if(r){K.push(y);return}else break;var de=[];Xn(N,X),X.push({changes:de,generation:n.generation}),n.generation=y.generation||++n.maxGeneration;for(var pe=te(e,"beforeChange")||e.cm&&te(e.cm,"beforeChange"),Se=function(Ne){var Ue=y.changes[Ne];if(Ue.origin=t,pe&&!Yo(e,Ue,!1))return K.length=0,{};de.push(Ma(e,Ue));var He=Ne?Ra(e,Ue):w(K);pn(e,Ue,He,Uo(e,Ue)),!Ne&&e.cm&&e.cm.scrollIntoView({from:Ue.from,to:Zr(Ue)});var Ze=[];Jr(e,function(Ge,qe){!qe&&ge(Ze,Ge.history)==-1&&(qo(Ge.history,Ue),Ze.push(Ge.history)),pn(Ge,Ue,null,Uo(Ge,Ue))})},be=y.changes.length-1;be>=0;--be){var Re=Se(be);if(Re)return Re.v}}function Zo(e,t){if(t==0)return;if(e.first+=t,e.sel=new xr(k(e.sel.ranges,function(n){return new kt(Be(n.anchor.line+t,n.anchor.ch),Be(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){sr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Xr(e.cm,r,"gutter")}}function pn(e,t,i,r){if(e.cm&&!e.cm.curOp)return zt(e.cm,pn)(e,t,i,r);if(t.to.line<e.first){Zo(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 n=t.text.length-1-(e.first-t.from.line);Zo(e,n),t={from:Be(e.first,0),to:Be(t.to.line+n,t.to.ch),text:[w(t.text)],origin:t.origin}}var y=e.lastLine();t.to.line>y&&(t={from:t.from,to:Be(y,Ye(e,y).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Tt(e,t.from,t.to),i||(i=Ra(e,t)),e.cm?xl(e.cm,t,r):Pa(e,t,r),$n(e,i,Te),e.cantEdit&&Zn(e,Be(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,y=t.from,N=t.to,K=!1,X=y.line;e.options.lineWrapping||(X=pt(yr(Ye(r,y.line))),r.iter(X,N.line+1,function(be){if(be==n.maxLine)return K=!0,!0})),r.sel.contains(t.from,t.to)>-1&&Y(e),Pa(r,t,i,fo(e)),e.options.lineWrapping||(r.iter(X,y.line+t.text.length,function(be){var Re=en(be);Re>n.maxLineLength&&(n.maxLine=be,n.maxLineLength=Re,n.maxLineChanged=!0,K=!1)}),K&&(e.curOp.updateMaxLine=!0)),aa(r,y.line),dn(e,400);var re=t.text.length-(N.line-y.line)-1;t.full?sr(e):y.line==N.line&&t.text.length==1&&!Po(e.doc,t)?Xr(e,y.line,"text"):sr(e,y.line,N.line+1,re);var de=te(e,"changes"),pe=te(e,"change");if(pe||de){var Se={from:y,to:N,text:t.text,removed:t.removed,origin:t.origin};pe&&Jt(e,"change",e,Se),de&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(Se)}e.display.selForContextMenu=null}function Bi(e,t,i,r,n){var y;r||(r=i),ht(r,i)<0&&(y=[r,i],i=y[0],r=y[1]),typeof t=="string"&&(t=e.splitLines(t)),Ni(e,{from:i,to:r,text:t,origin:n})}function Jo(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function Qo(e,t,i,r){for(var n=0;n<e.length;++n){var y=e[n],N=!0;if(y.ranges){y.copied||(y=e[n]=y.deepCopy(),y.copied=!0);for(var K=0;K<y.ranges.length;K++)Jo(y.ranges[K].anchor,t,i,r),Jo(y.ranges[K].head,t,i,r);continue}for(var X=0;X<y.changes.length;++X){var re=y.changes[X];if(i<re.from.line)re.from=Be(re.from.line+r,re.from.ch),re.to=Be(re.to.line+r,re.to.ch);else if(t<=re.to.line){N=!1;break}}N||(e.splice(0,n+1),n=0)}}function qo(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;Qo(e.done,i,r,n),Qo(e.undone,i,r,n)}function mn(e,t,i,r){var n=t,y=t;return typeof t=="number"?y=Ye(e,Ei(e,t)):n=pt(t),n==null?null:(r(y,n)&&e.cm&&Xr(e.cm,n,i),y)}function gn(e){this.lines=e,this.parent=null;for(var t=0,i=0;i<e.length;++i)e[i].parent=this,t+=e[i].height;this.height=t}gn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var i=e,r=e+t;i<r;++i){var n=this.lines[i];this.height-=n.height,nt(n),Jt(n,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,i){this.height+=i,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,i){for(var r=e+t;e<r;++e)if(i(this.lines[e]))return!0}};function vn(e){this.children=e;for(var t=0,i=0,r=0;r<e.length;++r){var n=e[r];t+=n.chunkSize(),i+=n.height,n.parent=this}this.size=t,this.height=i,this.parent=null}vn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var i=0;i<this.children.length;++i){var r=this.children[i],n=r.chunkSize();if(e<n){var y=Math.min(t,n-e),N=r.height;if(r.removeInner(e,y),this.height-=N-r.height,n==y&&(this.children.splice(i--,1),r.parent=null),(t-=y)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof gn))){var K=[];this.collapse(K),this.children=[new gn(K)],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,i){this.size+=t.length,this.height+=i;for(var r=0;r<this.children.length;++r){var n=this.children[r],y=n.chunkSize();if(e<=y){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var N=n.lines.length%25+25,K=N;K<n.lines.length;){var X=new gn(n.lines.slice(K,K+=25));n.height-=X.height,this.children.splice(++r,0,X),X.parent=this}n.lines=n.lines.slice(0,N),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),i=new vn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=ge(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new vn(e.children);r.parent=e,e.children=[r,i],e=r}i.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,i){for(var r=0;r<this.children.length;++r){var n=this.children[r],y=n.chunkSize();if(e<y){var N=Math.min(t,y-e);if(n.iterN(e,N,i))return!0;if((t-=N)==0)break;e=0}else e-=y}}};var yn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};yn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=pt(i);if(r==null||!t)return;for(var n=0;n<t.length;++n)t[n]==this&&t.splice(n--,1);t.length||(i.widgets=null);var y=nn(this);mt(i,Math.max(0,i.height-y)),e&&(fr(e,function(){es(e,i,-y),Xr(e,r,"widget")}),Jt(e,"lineWidgetCleared",e,this,r))},yn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=nn(this)-t;if(!n)return;Or(this.doc,r)||mt(r,r.height+n),i&&fr(i,function(){i.curOp.forceUpdate=!0,es(i,r,n),Jt(i,"lineWidgetChanged",i,e,pt(r))})},oe(yn);function es(e,t,i){kr(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&wa(e,i)}function El(e,t,i,r){var n=new yn(e,i,r),y=e.cm;return y&&n.noHScroll&&(y.display.alignWidgets=!0),mn(e,t,"widget",function(N){var K=N.widgets||(N.widgets=[]);if(n.insertAt==null?K.push(n):K.splice(Math.min(K.length-1,Math.max(0,n.insertAt)),0,n),n.line=N,y&&!Or(e,N)){var X=kr(N)<e.scrollTop;mt(N,N.height+nn(n)),X&&wa(y,n.height),y.curOp.forceUpdate=!0}return!0}),y&&Jt(y,"lineWidgetAdded",y,n,typeof t=="number"?t:pt(t)),n}var ts=0,Qr=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ts};Qr.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&mi(e),te(this,"clear")){var i=this.find();i&&Jt(this,"clear",i.from,i.to)}for(var r=null,n=null,y=0;y<this.lines.length;++y){var N=this.lines[y],K=Lr(N.markedSpans,this);e&&!this.collapsed?Xr(e,pt(N),"text"):e&&(K.to!=null&&(n=pt(N)),K.from!=null&&(r=pt(N))),N.markedSpans=Ji(N.markedSpans,K),K.from==null&&this.collapsed&&!Or(this.doc,N)&&e&&mt(N,_i(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var X=0;X<this.lines.length;++X){var re=yr(this.lines[X]),de=en(re);de>e.display.maxLineLength&&(e.display.maxLine=re,e.display.maxLineLength=de,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&sr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&zo(e.doc)),e&&Jt(e,"markerCleared",e,this,r,n),t&&gi(e),this.parent&&this.parent.clear()},Qr.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var y=this.lines[n],N=Lr(y.markedSpans,this);if(N.from!=null&&(i=Be(t?y:pt(y),N.from),e==-1))return i;if(N.to!=null&&(r=Be(t?y:pt(y),N.to),e==1))return r}return i&&{from:i,to:r}},Qr.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;fr(r,function(){var n=t.line,y=pt(t.line),N=fa(r,y);if(N&&(no(N),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Or(i.doc,n)&&i.height!=null){var K=i.height;i.height=null;var X=nn(i)-K;X&&mt(n,n.height+X)}Jt(r,"markerChanged",r,e)})},Qr.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||ge(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Qr.prototype.detachLine=function(e){if(this.lines.splice(ge(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},oe(Qr);function Fi(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return zt(e.cm,Fi)(e,t,i,r,n);var y=new Qr(e,n),N=ht(t,i);if(r&&F(r,y,!1),N>0||N==0&&y.clearWhenEmpty!==!1)return y;if(y.replacedWith&&(y.collapsed=!0,y.widgetNode=x("span",[y.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||y.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(y.widgetNode.insertLeft=!0)),y.collapsed){if(Mn(e,t.line,t,i,y)||t.line!=i.line&&Mn(e,i.line,t,i,y))throw new Error("Inserting collapsed marker partially overlapping an existing one");oa()}y.addToHistory&&Bo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var K=t.line,X=e.cm,re;if(e.iter(K,i.line+1,function(pe){X&&y.collapsed&&!X.options.lineWrapping&&yr(pe)==X.display.maxLine&&(re=!0),y.collapsed&&K!=t.line&&mt(pe,0),sa(pe,new ai(y,K==t.line?t.ch:null,K==i.line?i.ch:null)),++K}),y.collapsed&&e.iter(t.line,i.line+1,function(pe){Or(e,pe)&&mt(pe,0)}),y.clearOnEnter&&Ae(y,"beforeCursorEnter",function(){return y.clear()}),y.readOnly&&(Kr(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),y.collapsed&&(y.id=++ts,y.atomic=!0),X){if(re&&(X.curOp.updateMaxLine=!0),y.collapsed)sr(X,t.line,i.line+1);else if(y.className||y.startStyle||y.endStyle||y.css||y.attributes||y.title)for(var de=t.line;de<=i.line;de++)Xr(X,de,"text");y.atomic&&zo(X.doc),Jt(X,"markerAdded",X,y)}return y}var bn=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};bn.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Jt(this,"clear")},bn.prototype.find=function(e,t){return this.primary.find(e,t)},oe(bn);function Sl(e,t,i,r,n){r=F(r),r.shared=!1;var y=[Fi(e,t,i,r,n)],N=y[0],K=r.widgetNode;return Jr(e,function(X){K&&(r.widgetNode=K.cloneNode(!0)),y.push(Fi(X,ft(X,t),ft(X,i),r,n));for(var re=0;re<X.linked.length;++re)if(X.linked[re].isParent)return;N=w(y)}),new bn(y,N)}function rs(e){return e.findMarks(Be(e.first,0),e.clipPos(Be(e.lastLine())),function(t){return t.parent})}function Tl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),y=e.clipPos(n.from),N=e.clipPos(n.to);if(ht(y,N)){var K=Fi(e,y,N,r.primary,r.primary.type);r.markers.push(K),K.parent=r}}}function Cl(e){for(var t=function(r){var n=e[r],y=[n.primary.doc];Jr(n.primary.doc,function(X){return y.push(X)});for(var N=0;N<n.markers.length;N++){var K=n.markers[N];ge(y,K.doc)==-1&&(K.parent=null,n.markers.splice(N--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,lr=function(e,t,i,r,n){if(!(this instanceof lr))return new lr(e,t,i,r,n);i==null&&(i=0),vn.call(this,[new gn([new li("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var y=Be(i,0);this.sel=$r(y),this.history=new Vn(null),this.id=++wl,this.modeOption=t,this.lineSep=r,this.direction=n=="rtl"?"rtl":"ltr",this.extend=!1,typeof e=="string"&&(e=this.splitLines(e)),Pa(this,{from:y,to:y,text:e}),er(this,$r(y),Te)};lr.prototype=B(vn.prototype,{constructor:lr,iter:function(e,t,i){i?this.iterN(e-this.first,t-e,i):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var i=0,r=0;r<t.length;++r)i+=t[r].height;this.insertInner(e-this.first,t,i)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Zt(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:Kt(function(e){var t=Be(this.first,0),i=this.first+this.size-1;Ni(this,{from:t,to:Be(i,Ye(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&sn(this.cm,0,0),er(this,$r(t),Te)}),replaceRange:function(e,t,i,r){t=ft(this,t),i=i?ft(this,i):t,Bi(this,e,t,i,r)},getRange:function(e,t,i){var r=Tt(this,ft(this,e),ft(this,t));return i===!1?r:r.join(i||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(vr(this,e))return Ye(this,e)},getLineNumber:function(e){return pt(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=Ye(this,e)),yr(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(),i;return e==null||e=="head"?i=t.head:e=="anchor"?i=t.anchor:e=="end"||e=="to"||e===!1?i=t.to():i=t.from(),i},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Kt(function(e,t,i){jo(this,ft(this,typeof e=="number"?Be(e,t||0):e),null,i)}),setSelection:Kt(function(e,t,i){jo(this,ft(this,e),ft(this,t||e),i)}),extendSelection:Kt(function(e,t,i){Yn(this,ft(this,e),t&&ft(this,t),i)}),extendSelections:Kt(function(e,t){Wo(this,Fe(this,e),t)}),extendSelectionsBy:Kt(function(e,t){var i=k(this.sel.ranges,e);Wo(this,Fe(this,i),t)}),setSelections:Kt(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new kt(ft(this,e[n].anchor),ft(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),er(this,Dr(this.cm,r,t),i)}),addSelection:Kt(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new kt(ft(this,e),ft(this,t||e))),er(this,Dr(this.cm,r,r.length-1),i)}),getSelection:function(e){for(var t=this.sel.ranges,i,r=0;r<t.length;r++){var n=Tt(this,t[r].from(),t[r].to());i=i?i.concat(n):n}return e===!1?i:i.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],i=this.sel.ranges,r=0;r<i.length;r++){var n=Tt(this,i[r].from(),i[r].to());e!==!1&&(n=n.join(e||this.lineSeparator())),t[r]=n}return t},replaceSelection:function(e,t,i){for(var r=[],n=0;n<this.sel.ranges.length;n++)r[n]=e;this.replaceSelections(r,t,i||"+input")},replaceSelections:Kt(function(e,t,i){for(var r=[],n=this.sel,y=0;y<n.ranges.length;y++){var N=n.ranges[y];r[y]={from:N.from(),to:N.to(),text:this.splitLines(e[y]),origin:i}}for(var K=t&&t!="end"&&cl(this,r,t),X=r.length-1;X>=0;X--)Ni(this,r[X]);K?Ho(this,K):this.cm&&Oi(this.cm)}),undo:Kt(function(){Jn(this,"undo")}),redo:Kt(function(){Jn(this,"redo")}),undoSelection:Kt(function(){Jn(this,"undo",!0)}),redoSelection:Kt(function(){Jn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,i=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++i;return{undo:t,redo:i}},clearHistory:function(){var e=this;this.history=new Vn(this.history.maxGeneration),Jr(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:Mi(this.history.done),undone:Mi(this.history.undone)}},setHistory:function(e){var t=this.history=new Vn(this.history.maxGeneration);t.done=Mi(e.done.slice(0),null,!0),t.undone=Mi(e.undone.slice(0),null,!0)},setGutterMarker:Kt(function(e,t,i){return mn(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&Ie(n)&&(r.gutterMarkers=null),!0})}),clearGutter:Kt(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&mn(t,i,"gutter",function(){return i.gutterMarkers[e]=null,Ie(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!vr(this,e))return null;if(t=e,e=Ye(this,e),!e)return null}else if(t=pt(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:Kt(function(e,t,i){return mn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!r[n])r[n]=i;else{if(g(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:Kt(function(e,t,i){return mn(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",y=r[n];if(y)if(i==null)r[n]=null;else{var N=y.match(g(i));if(!N)return!1;var K=N.index+N[0].length;r[n]=y.slice(0,N.index)+(!N.index||K==y.length?"":" ")+y.slice(K)||null}else return!1;return!0})}),addLineWidget:Kt(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return Fi(this,ft(this,e),ft(this,t),i,i&&i.type||"range")},setBookmark:function(e,t){var i={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),Fi(this,e,e,i,"bookmark")},findMarksAt:function(e){e=ft(this,e);var t=[],i=Ye(this,e.line).markedSpans;if(i)for(var r=0;r<i.length;++r){var n=i[r];(n.from==null||n.from<=e.ch)&&(n.to==null||n.to>=e.ch)&&t.push(n.marker.parent||n.marker)}return t},findMarks:function(e,t,i){e=ft(this,e),t=ft(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(y){var N=y.markedSpans;if(N)for(var K=0;K<N.length;K++){var X=N[K];!(X.to!=null&&n==e.line&&e.ch>=X.to||X.from==null&&n!=e.line||X.from!=null&&n==t.line&&X.from>=t.ch)&&(!i||i(X.marker))&&r.push(X.marker.parent||X.marker)}++n}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var i=t.markedSpans;if(i)for(var r=0;r<i.length;++r)i[r].from!=null&&e.push(i[r].marker)}),e},posFromIndex:function(e){var t,i=this.first,r=this.lineSeparator().length;return this.iter(function(n){var y=n.text.length+r;if(y>e)return t=e,!0;e-=y,++i}),ft(this,Be(i,t))},indexFromPos:function(e){e=ft(this,e);var t=e.ch;if(e.line<this.first||e.ch<0)return 0;var i=this.lineSeparator().length;return this.iter(this.first,e.line,function(r){t+=r.text.length+i}),t},copy:function(e){var t=new lr(Zt(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,i=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<i&&(i=e.to);var r=new lr(Zt(this,t,i),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}],Tl(r,rs(this)),r},unlinkDoc:function(e){if(e instanceof Mt&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){var i=this.linked[t];if(i.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Cl(rs(this));break}if(e.history==this.history){var r=[e.id];Jr(e,function(n){return r.push(n.id)},!0),e.history=new Vn(null),e.history.done=Mi(this.history.done,r),e.history.undone=Mi(this.history.undone,r)}},iterLinkedDocs:function(e){Jr(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):ot(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:Kt(function(e){if(e!="rtl"&&(e="ltr"),e==this.direction)return;this.direction=e,this.iter(function(t){return t.order=null}),this.cm&&fl(this.cm)})}),lr.prototype.eachLine=lr.prototype.iter;var is=0;function Al(e){var t=this;if(ns(t),V(t,e)||jr(t.display,e))return;Q(e),j&&(is=+new Date);var i=di(t,e,!0),r=e.dataTransfer.files;if(!i||t.isReadOnly())return;if(r&&r.length&&window.FileReader&&window.File)for(var n=r.length,y=Array(n),N=0,K=function(){++N==n&&zt(t,function(){i=ft(t.doc,i);var be={from:i,to:i,text:t.doc.splitLines(y.filter(function(Re){return Re!=null}).join(t.doc.lineSeparator())),origin:"paste"};Ni(t.doc,be),Ho(t.doc,$r(ft(t.doc,i),ft(t.doc,Zr(be))))})()},X=function(be,Re){if(t.options.allowDropFileTypes&&ge(t.options.allowDropFileTypes,be.type)==-1){K();return}var Ne=new FileReader;Ne.onerror=function(){return K()},Ne.onload=function(){var Ue=Ne.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Ue)){K();return}y[Re]=Ue,K()},Ne.readAsText(be)},re=0;re<r.length;re++)X(r[re],re);else{if(t.state.draggingText&&t.doc.sel.contains(i)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var de=e.dataTransfer.getData("Text");if(de){var pe;if(t.state.draggingText&&!t.state.draggingText.copy&&(pe=t.listSelections()),$n(t.doc,$r(i,i)),pe)for(var Se=0;Se<pe.length;++Se)Bi(t.doc,"",pe[Se].anchor,pe[Se].head,"drag");t.replaceSelection(de,"around","paste"),t.display.input.focus()}}catch(be){}}}function Ll(e,t){if(j&&(!e.state.draggingText||+new Date-is<100)){ue(t);return}if(V(e,t)||jr(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!R){var i=a("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",T&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),T&&i.parentNode.removeChild(i)}}function kl(e,t){var i=di(e,t);if(!i)return;var r=document.createDocumentFragment();go(e,i,r),e.display.dragCursor||(e.display.dragCursor=a("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),h(e.display.dragCursor,r)}function ns(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"),i=[],r=0;r<t.length;r++){var n=t[r].CodeMirror;n&&i.push(n)}i.length&&i[0].operation(function(){for(var y=0;y<i.length;y++)e(i[y])})}var os=!1;function _l(){if(os)return;Dl(),os=!0}function Dl(){var e;Ae(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,as(Rl)},100))}),Ae(window,"blur",function(){return as(Ri)})}function Rl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var qr={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"},xn=0;xn<10;xn++)qr[xn+48]=qr[xn+96]=String(xn);for(var Qn=65;Qn<=90;Qn++)qr[Qn]=String.fromCharCode(Qn);for(var En=1;En<=12;En++)qr[En+111]=qr[En+63235]="F"+En;var Hr={};Hr.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"},Hr.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"},Hr.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"},Hr.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"]},Hr.default=s?Hr.macDefault:Hr.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,y,N=0;N<t.length-1;N++){var K=t[N];if(/^(cmd|meta|m)$/i.test(K))y=!0;else if(/^a(lt)?$/i.test(K))i=!0;else if(/^(c|ctrl|control)$/i.test(K))r=!0;else if(/^s(hift)?$/i.test(K))n=!0;else throw new Error("Unrecognized modifier name: "+K)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),y&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Pl(e){var t={};for(var i in e)if(e.hasOwnProperty(i)){var r=e[i];if(/^(name|fallthrough|(de|at)tach)$/.test(i))continue;if(r=="..."){delete e[i];continue}for(var n=k(i.split(" "),Ol),y=0;y<n.length;y++){var N=void 0,K=void 0;y==n.length-1?(K=n.join(" "),N=r):(K=n.slice(0,y+1).join(" "),N="...");var X=t[K];if(!X)t[K]=N;else if(X!=N)throw new Error("Inconsistent bindings for "+K)}delete e[i]}for(var re in t)e[re]=t[re];return e}function Ui(e,t,i,r){t=qn(t);var n=t.call?t.call(e,r):t[e];if(n===!1)return"nothing";if(n==="...")return"multi";if(n!=null&&i(n))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return Ui(e,t.fallthrough,i,r);for(var y=0;y<t.fallthrough.length;y++){var N=Ui(e,t.fallthrough[y],i,r);if(N)return N}}}function ss(e){var t=typeof e=="string"?e:qr[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function ls(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(f?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(f?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function us(e,t){if(T&&e.keyCode==34&&e.char)return!1;var i=qr[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),ls(i,e,t))}function qn(e){return typeof e=="string"?Hr[e]:e}function Wi(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var y=t(i[n]);r.length&&ht(y.from,w(r).to)<=0;){var N=r.pop();if(ht(N.from,y.from)<0){y.from=N.from;break}}r.push(y)}fr(e,function(){for(var K=r.length-1;K>=0;K--)Bi(e.doc,"",r[K].from,r[K].to,"+delete");Oi(e)})}function Ba(e,t,i){var r=Pe(e.text,t+i,i);return r<0||r>e.text.length?null:r}function Fa(e,t,i){var r=Ba(e,t.ch,i);return r==null?null:new Be(t.line,r,i<0?"after":"before")}function Ua(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var y=Xe(i,t.doc.direction);if(y){var N=n<0?w(y):y[0],K=n<0==(N.level==1),X=K?"after":"before",re;if(N.level>0||t.doc.direction=="rtl"){var de=ki(t,i);re=n<0?i.text.length-1:0;var pe=Mr(t,de,re).top;re=je(function(Se){return Mr(t,de,Se).top==pe},n<0==(N.level==1)?N.from:N.to-1,re),X=="before"&&(re=Ba(i,re,1))}else re=n<0?N.to:N.from;return new Be(r,re,X)}}return new Be(r,n<0?i.text.length:0,n<0?"before":"after")}function Ml(e,t,i,r){var n=Xe(t,e.doc.direction);if(!n)return Fa(t,i,r);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):i.ch<=0&&(i.ch=0,i.sticky="after");var y=Ve(n,i.ch,i.sticky),N=n[y];if(e.doc.direction=="ltr"&&N.level%2==0&&(r>0?N.to>i.ch:N.from<i.ch))return Fa(t,i,r);var K=function(He,Ze){return Ba(t,He instanceof Be?He.ch:He,Ze)},X,re=function(He){return e.options.lineWrapping?(X=X||ki(e,t),co(e,t,X,He)):{begin:0,end:t.text.length}},de=re(i.sticky=="before"?K(i,-1):i.ch);if(e.doc.direction=="rtl"||N.level==1){var pe=N.level==1==r<0,Se=K(i,pe?1:-1);if(Se!=null&&(pe?Se<=N.to&&Se<=de.end:Se>=N.from&&Se>=de.begin)){var be=pe?"before":"after";return new Be(i.line,Se,be)}}var Re=function(He,Ze,Ge){for(var qe=function(Rt,Vt){return Vt?new Be(i.line,K(Rt,1),"before"):new Be(i.line,Rt,"after")};He>=0&&He<n.length;He+=Ze){var ut=n[He],st=Ze>0==(ut.level!=1),gt=st?Ge.begin:K(Ge.end,-1);if(ut.from<=gt&&gt<ut.to)return qe(gt,st);if(gt=st?ut.from:K(ut.to,-1),Ge.begin<=gt&&gt<Ge.end)return qe(gt,st)}},Ne=Re(y+r,r,de);if(Ne)return Ne;var Ue=r>0?de.end:K(de.begin,-1);return Ue!=null&&!(r>0&&Ue==t.text.length)&&(Ne=Re(r>0?0:n.length-1,r,re(Ue)),Ne)?Ne:null}var Sn={selectAll:Xo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Te)},killLine:function(e){return Wi(e,function(t){if(t.empty()){var i=Ye(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:Be(t.head.line+1,0)}:{from:t.head,to:Be(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return Wi(e,function(t){return{from:Be(t.from().line,0),to:ft(e.doc,Be(t.to().line+1,0))}})},delLineLeft:function(e){return Wi(e,function(t){return{from:Be(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return Wi(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){return Wi(e,function(t){var i=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"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(Be(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Be(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return hs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ds(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 i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Ce)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},Ce)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:i},"div");return r.ch<e.getLine(r.line).search(/\S/)?ds(e,t.head):r},Ce)},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=[],i=e.listSelections(),r=e.options.tabSize,n=0;n<i.length;n++){var y=i[n].from(),N=ne(e.getLine(y.line),y.ch,r);t.push(W(r-N%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return fr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,y=Ye(e.doc,n.line).text;if(y){if(n.ch==y.length&&(n=new Be(n.line,n.ch-1)),n.ch>0)n=new Be(n.line,n.ch+1),e.replaceRange(y.charAt(n.ch-1)+y.charAt(n.ch-2),Be(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var N=Ye(e.doc,n.line-1).text;N&&(n=new Be(n.line,1),e.replaceRange(y.charAt(0)+e.doc.lineSeparator()+N.charAt(N.length-1),Be(n.line-1,N.length-1),n,"+transpose"))}}i.push(new kt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return fr(e,function(){for(var t=e.listSelections(),i=t.length-1;i>=0;i--)e.replaceRange(e.doc.lineSeparator(),t[i].anchor,t[i].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);Oi(e)})},openLine:function(e){return e.replaceSelection(`
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function hs(e,t){var i=Ye(e.doc,t),r=yr(i);return r!=i&&(t=pt(r)),Ua(!0,e,r,t,1)}function Il(e,t){var i=Ye(e.doc,t),r=In(i);return r!=i&&(t=pt(r)),Ua(!0,e,i,t,-1)}function ds(e,t){var i=hs(e,t.line),r=Ye(e.doc,i.line),n=Xe(r,e.doc.direction);if(!n||n[0].level==0){var y=Math.max(i.ch,r.text.search(/\S/)),N=t.line==i.line&&t.ch<=y&&t.ch;return Be(i.line,N?0:y,i.sticky)}return i}function ea(e,t,i){if(typeof t=="string"&&(t=Sn[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i&&(e.display.shift=!1),n=t(e)!=Me}finally{e.display.shift=r,e.state.suppressEdits=!1}return n}function Nl(e,t,i){for(var r=0;r<e.state.keyMaps.length;r++){var n=Ui(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&Ui(t,e.options.extraKeys,i,e)||Ui(t,e.options.keyMap,i,e)}var Bl=new ce;function Tn(e,t,i,r){var n=e.state.keySeq;if(n){if(ss(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Bl.set(50,function(){e.state.keySeq==n&&(e.state.keySeq=null,e.display.input.reset())}),cs(e,n+" "+t,i,r))return!0}return cs(e,t,i,r)}function cs(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&Jt(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(Q(i),Sa(e)),!!n}function fs(e,t){var i=us(t,!0);return i?t.shiftKey&&!e.state.keySeq?Tn(e,"Shift-"+i,t,function(r){return ea(e,r,!0)})||Tn(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return ea(e,r)}):Tn(e,i,t,function(r){return ea(e,r)}):!1}function Fl(e,t,i){return Tn(e,"'"+i+"'",t,function(r){return ea(e,r,!0)})}var Wa=null;function ps(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=M(),V(t,e))return;j&&U<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=fs(t,e);T&&(Wa=r?i:null,!r&&i==88&&!wt&&(s?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),_&&!s&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Ul(t)}function Ul(e){var t=e.display.lineDiv;G(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(d(t,"CodeMirror-crosshair"),Je(document,"keyup",i),Je(document,"mouseover",i))}Ae(document,"keyup",i),Ae(document,"mouseover",i)}function ms(e){e.keyCode==16&&(this.doc.sel.shift=!1),V(this,e)}function gs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(jr(t.display,e)||V(t,e)||e.ctrlKey&&!e.altKey||s&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(T&&i==Wa){Wa=null,Q(e);return}if(T&&(!e.which||e.which<10)&&fs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Fl(t,e,n))return;t.display.input.onKeyPress(e)}var Wl=400,ja=function(e,t,i){this.time=e,this.pos=t,this.button=i};ja.prototype.compare=function(e,t,i){return this.time+Wl>e&&ht(t,this.pos)==0&&i==this.button};var Cn,wn;function jl(e,t){var i=+new Date;return wn&&wn.compare(i,e,t)?(Cn=wn=null,"triple"):Cn&&Cn.compare(i,e,t)?(wn=new ja(i,e,t),Cn=null,"double"):(Cn=new ja(i,e,t),wn=null,"single")}function vs(e){var t=this,i=t.display;if(V(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,jr(i,e)){P||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ha(t,e))return;var r=di(t,e),n=ye(e),y=r?jl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,y,e))return;n==1?r?zl(t,r,y,e):me(e)==i.scroller&&Q(e):n==2?(r&&Yn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(L?t.display.input.onContextMenu(e):yo(t))}function Hl(e,t,i,r,n){var y="Click";return r=="double"?y="Double"+y:r=="triple"&&(y="Triple"+y),y=(t==1?"Left":t==2?"Middle":"Right")+y,Tn(e,ls(y,n),n,function(N){if(typeof N=="string"&&(N=Sn[N]),!N)return!1;var K=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),K=N(e,i)!=Me}finally{e.state.suppressEdits=!1}return K})}function Gl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var y=l?i.shiftKey&&i.metaKey:i.altKey;n.unit=y?"rectangle":t=="single"?"char":t=="double"?"word":"line"}return(n.extend==null||e.doc.extend)&&(n.extend=e.doc.extend||i.shiftKey),n.addNew==null&&(n.addNew=s?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(s?i.altKey:i.ctrlKey)),n}function zl(e,t,i,r){j?setTimeout(z(vo,e),0):e.curOp.focus=M();var n=Gl(e,i,r),y=e.doc.sel,N;e.options.dragDrop&&ke&&!e.isReadOnly()&&i=="single"&&(N=y.contains(t))>-1&&(ht((N=y.ranges[N]).from(),t)<0||t.xRel>0)&&(ht(N.to(),t)>0||t.xRel<0)?Kl(e,r,t,n):Vl(e,r,t,n)}function Kl(e,t,i,r){var n=e.display,y=!1,N=zt(e,function(re){P&&(n.scroller.draggable=!1),e.state.draggingText=!1,Je(n.wrapper.ownerDocument,"mouseup",N),Je(n.wrapper.ownerDocument,"mousemove",K),Je(n.scroller,"dragstart",X),Je(n.scroller,"drop",N),y||(Q(re),r.addNew||Yn(e.doc,i,null,null,r.extend),P&&!R||j&&U==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),K=function(re){y=y||Math.abs(t.clientX-re.clientX)+Math.abs(t.clientY-re.clientY)>=10},X=function(){return y=!0};P&&(n.scroller.draggable=!0),e.state.draggingText=N,N.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),Ae(n.wrapper.ownerDocument,"mouseup",N),Ae(n.wrapper.ownerDocument,"mousemove",K),Ae(n.scroller,"dragstart",X),Ae(n.scroller,"drop",N),yo(e),setTimeout(function(){return n.input.focus()},20)}function ys(e,t,i){if(i=="char")return new kt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new kt(Be(t.line,0),ft(e.doc,Be(t.line+1,0)));var r=i(e,t);return new kt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,y=e.doc;Q(t);var N,K,X=y.sel,re=X.ranges;if(r.addNew&&!r.extend?(K=y.sel.contains(i),K>-1?N=re[K]:N=new kt(i,i)):(N=y.sel.primary(),K=y.sel.primIndex),r.unit=="rectangle")r.addNew||(N=new kt(i,i)),i=di(e,t,!0,!0),K=-1;else{var de=ys(e,i,r.unit);r.extend?N=Ia(N,de.anchor,de.head,r.extend):N=de}r.addNew?K==-1?(K=re.length,er(y,Dr(e,re.concat([N]),K),{scroll:!1,origin:"*mouse"})):re.length>1&&re[K].empty()&&r.unit=="char"&&!r.extend?(er(y,Dr(e,re.slice(0,K).concat(re.slice(K+1)),0),{scroll:!1,origin:"*mouse"}),X=y.sel):Na(y,K,N,Oe):(K=0,er(y,new xr([N],0),Oe),X=y.sel);var pe=i;function Se(Ge){if(ht(pe,Ge)==0)return;if(pe=Ge,r.unit=="rectangle"){for(var qe=[],ut=e.options.tabSize,st=ne(Ye(y,i.line).text,i.ch,ut),gt=ne(Ye(y,Ge.line).text,Ge.ch,ut),Rt=Math.min(st,gt),Vt=Math.max(st,gt),Nt=Math.min(i.line,Ge.line),pr=Math.min(e.lastLine(),Math.max(i.line,Ge.line));Nt<=pr;Nt++){var ur=Ye(y,Nt).text,Wt=we(ur,Rt,ut);Rt==Vt?qe.push(new kt(Be(Nt,Wt),Be(Nt,Wt))):ur.length>Wt&&qe.push(new kt(Be(Nt,Wt),Be(Nt,we(ur,Vt,ut))))}qe.length||qe.push(new kt(i,i)),er(y,Dr(e,X.ranges.slice(0,K).concat(qe),K),{origin:"*mouse",scroll:!1}),e.scrollIntoView(Ge)}else{var hr=N,Qt=ys(e,Ge,r.unit),Gt=hr.anchor,jt;ht(Qt.anchor,Gt)>0?(jt=Qt.head,Gt=ii(hr.from(),Qt.anchor)):(jt=Qt.anchor,Gt=xi(hr.to(),Qt.head));var Bt=X.ranges.slice(0);Bt[K]=Xl(e,new kt(ft(y,Gt),jt)),er(y,Dr(e,Bt,K),Oe)}}var be=n.wrapper.getBoundingClientRect(),Re=0;function Ne(Ge){var qe=++Re,ut=di(e,Ge,!0,r.unit=="rectangle");if(!ut)return;if(ht(ut,pe)!=0){e.curOp.focus=M(),Se(ut);var st=Hn(n,y);(ut.line>=st.to||ut.line<st.from)&&setTimeout(zt(e,function(){Re==qe&&Ne(Ge)}),150)}else{var gt=Ge.clientY<be.top?-20:Ge.clientY>be.bottom?20:0;gt&&setTimeout(zt(e,function(){if(Re!=qe)return;n.scroller.scrollTop+=gt,Ne(Ge)}),50)}}function Ue(Ge){e.state.selectingText=!1,Re=Infinity,Ge&&(Q(Ge),n.input.focus()),Je(n.wrapper.ownerDocument,"mousemove",He),Je(n.wrapper.ownerDocument,"mouseup",Ze),y.history.lastSelOrigin=null}var He=zt(e,function(Ge){Ge.buttons===0||!ye(Ge)?Ue(Ge):Ne(Ge)}),Ze=zt(e,Ue);e.state.selectingText=Ze,Ae(n.wrapper.ownerDocument,"mousemove",He),Ae(n.wrapper.ownerDocument,"mouseup",Ze)}function Xl(e,t){var i=t.anchor,r=t.head,n=Ye(e.doc,i.line);if(ht(i,r)==0&&i.sticky==r.sticky)return t;var y=Xe(n);if(!y)return t;var N=Ve(y,i.ch,i.sticky),K=y[N];if(K.from!=i.ch&&K.to!=i.ch)return t;var X=N+(K.from==i.ch==(K.level!=1)?0:1);if(X==0||X==y.length)return t;var re;if(r.line!=i.line)re=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var de=Ve(y,r.ch,r.sticky),pe=de-N||(r.ch-i.ch)*(K.level==1?-1:1);de==X-1||de==X?re=pe<0:re=pe>0}var Se=y[X+(re?-1:0)],be=re==(Se.level==1),Re=be?Se.from:Se.to,Ne=be?"after":"before";return i.ch==Re&&i.sticky==Ne?t:new kt(new Be(i.line,Re,Ne),r)}function bs(e,t,i,r){var n,y;if(t.touches)n=t.touches[0].clientX,y=t.touches[0].clientY;else try{n=t.clientX,y=t.clientY}catch(Se){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Q(t);var N=e.display,K=N.lineDiv.getBoundingClientRect();if(y>K.bottom||!te(e,i))return se(t);y-=K.top-N.viewOffset;for(var X=0;X<e.display.gutterSpecs.length;++X){var re=N.gutters.childNodes[X];if(re&&re.getBoundingClientRect().right>=n){var de=At(e.doc,y),pe=e.display.gutterSpecs[X];return ae(e,i,e,de,pe.className,t),se(t)}}}function Ha(e,t){return bs(e,t,"gutterClick",!0)}function xs(e,t){if(jr(e.display,t)||Yl(e,t))return;if(V(e,t,"contextmenu"))return;L||e.display.input.onContextMenu(t)}function Yl(e,t){return te(e,"gutterContextMenu")?bs(e,t,"gutterContextMenu",!1):!1}function Es(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),an(e)}var ji={toString:function(){return"CodeMirror.Init"}},Ss={},ta={};function $l(e){var t=e.optionHandlers;function i(r,n,y,N){e.defaults[r]=n,y&&(t[r]=N?function(K,X,re){re!=ji&&y(K,X,re)}:y)}e.defineOption=i,e.Init=ji,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,Oa(r)},!0),i("indentUnit",2,Oa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){fn(r),an(r),sr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var y=[],N=r.doc.first;r.doc.iter(function(X){for(var re=0;;){var de=X.text.indexOf(n,re);if(de==-1)break;re=de+n.length,y.push(Be(N,de))}N++});for(var K=y.length-1;K>=0;K--)Bi(r.doc,n,y[K],Be(y[K].line,y[K].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,y){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),y!=ji&&r.refresh()}),i("specialCharPlaceholder",Dt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",o?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),i("spellcheck",!1,function(r,n){return r.getInputField().spellcheck=n},!0),i("autocorrect",!1,function(r,n){return r.getInputField().autocorrect=n},!0),i("autocapitalize",!1,function(r,n){return r.getInputField().autocapitalize=n},!0),i("rtlMoveVisually",!E),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Es(r),cn(r)},!0),i("keyMap","default",function(r,n,y){var N=qn(n),K=y!=ji&&qn(y);K&&K.detach&&K.detach(r,N),N.attach&&N.attach(r,K||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=Da(n,r.options.lineNumbers),cn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?xa(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return Pi(r)},!0),i("scrollbarStyle","native",function(r){Co(r),Pi(r),r.display.scrollbars.setScrollTop(r.doc.scrollTop),r.display.scrollbars.setScrollLeft(r.doc.scrollLeft)},!0),i("lineNumbers",!1,function(r,n){r.display.gutterSpecs=Da(r.options.gutters,n),cn(r)},!0),i("firstLineNumber",1,cn,!0),i("lineNumberFormatter",function(r){return r},cn,!0),i("showCursorWhenSelecting",!1,on,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Ri(r),r.display.input.blur()),r.display.input.readOnlyChanged(n)}),i("screenReaderLabel",null,function(r,n){n=n===""?null:n,r.display.input.screenReaderLabelChanged(n)}),i("disableInput",!1,function(r,n){n||r.display.input.reset()},!0),i("dragDrop",!0,Zl),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,on,!0),i("singleCursorHeightPerLine",!0,on,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,fn,!0),i("addModeClass",!1,fn,!0),i("pollInterval",100),i("undoDepth",200,function(r,n){return r.doc.history.undoDepth=n}),i("historyEventDelay",1250),i("viewportMargin",10,function(r){return r.refresh()},!0),i("maxHighlightLength",1e4,fn,!0),i("moveInputWithCursor",!0,function(r,n){n||r.display.input.resetPosition()}),i("tabindex",null,function(r,n){return r.display.input.getField().tabIndex=n||""}),i("autofocus",null),i("direction","ltr",function(r,n){return r.doc.setDirection(n)},!0),i("phrases",null)}function Zl(e,t,i){var r=i&&i!=ji;if(!t!=!r){var n=e.display.dragFunctions,y=t?Ae:Je;y(e.display.scroller,"dragstart",n.start),y(e.display.scroller,"dragenter",n.enter),y(e.display.scroller,"dragover",n.over),y(e.display.scroller,"dragleave",n.leave),y(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(G(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(d(e.display.wrapper,"CodeMirror-wrap"),Nn(e)),Ea(e),sr(e),an(e),setTimeout(function(){return Pi(e)},100)}function Mt(e,t){var i=this;if(!(this instanceof Mt))return new Mt(e,t);this.options=t=t?F(t):{},F(Ss,t,!1);var r=t.value;typeof r=="string"?r=new lr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new Mt.inputStyles[t.inputStyle](this),y=this.display=new hl(e,r,n,t);y.wrapper.CodeMirror=this,Es(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Co(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 ce,keySeq:null,specialChars:null},t.autofocus&&!o&&y.input.focus(),j&&U<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Ql(this),_l(),mi(this),this.curOp.forceUpdate=!0,Mo(this,r),t.autofocus&&!o||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&Ta(i)},20):Ri(this);for(var N in ta)ta.hasOwnProperty(N)&&ta[N](this,t[N],ji);Lo(this),t.finishInit&&t.finishInit(this);for(var K=0;K<Ga.length;++K)Ga[K](this);gi(this),P&&t.lineWrapping&&getComputedStyle(y.lineDiv).textRendering=="optimizelegibility"&&(y.lineDiv.style.textRendering="auto")}Mt.defaults=Ss,Mt.optionHandlers=ta;function Ql(e){var t=e.display;Ae(t.scroller,"mousedown",zt(e,vs)),j&&U<11?Ae(t.scroller,"dblclick",zt(e,function(X){if(V(e,X))return;var re=di(e,X);if(!re||Ha(e,X)||jr(e.display,X))return;Q(X);var de=e.findWordAt(re);Yn(e.doc,de.anchor,de.head)})):Ae(t.scroller,"dblclick",function(X){return V(e,X)||Q(X)}),Ae(t.scroller,"contextmenu",function(X){return xs(e,X)}),Ae(t.input.getField(),"contextmenu",function(X){t.scroller.contains(X.target)||xs(e,X)});var i,r={end:0};function n(){t.activeTouch&&(i=setTimeout(function(){return t.activeTouch=null},1e3),r=t.activeTouch,r.end=+new Date)}function y(X){if(X.touches.length!=1)return!1;var re=X.touches[0];return re.radiusX<=1&&re.radiusY<=1}function N(X,re){if(re.left==null)return!0;var de=re.left-X.left,pe=re.top-X.top;return de*de+pe*pe>20*20}Ae(t.scroller,"touchstart",function(X){if(!V(e,X)&&!y(X)&&!Ha(e,X)){t.input.ensurePolled(),clearTimeout(i);var re=+new Date;t.activeTouch={start:re,moved:!1,prev:re-r.end<=300?r:null},X.touches.length==1&&(t.activeTouch.left=X.touches[0].pageX,t.activeTouch.top=X.touches[0].pageY)}}),Ae(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Ae(t.scroller,"touchend",function(X){var re=t.activeTouch;if(re&&!jr(t,X)&&re.left!=null&&!re.moved&&new Date-re.start<300){var de=e.coordsChar(t.activeTouch,"page"),pe;!re.prev||N(re,re.prev)?pe=new kt(de,de):!re.prev.prev||N(re,re.prev.prev)?pe=e.findWordAt(de):pe=new kt(Be(de.line,0),ft(e.doc,Be(de.line+1,0))),e.setSelection(pe.anchor,pe.head),e.focus(),Q(X)}n()}),Ae(t.scroller,"touchcancel",n),Ae(t.scroller,"scroll",function(){t.scroller.clientHeight&&(ln(e,t.scroller.scrollTop),fi(e,t.scroller.scrollLeft,!0),ae(e,"scroll",e))}),Ae(t.scroller,"mousewheel",function(X){return Do(e,X)}),Ae(t.scroller,"DOMMouseScroll",function(X){return Do(e,X)}),Ae(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(X){V(e,X)||ue(X)},over:function(X){V(e,X)||(kl(e,X),ue(X))},start:function(X){return Ll(e,X)},drop:zt(e,Al),leave:function(X){V(e,X)||ns(e)}};var K=t.input.getField();Ae(K,"keyup",function(X){return ms.call(e,X)}),Ae(K,"keydown",zt(e,ps)),Ae(K,"keypress",zt(e,gs)),Ae(K,"focus",function(X){return Ta(e,X)}),Ae(K,"blur",function(X){return Ri(e,X)})}var Ga=[];Mt.defineInitHook=function(e){return Ga.push(e)};function An(e,t,i,r){var n=e.doc,y;i==null&&(i="add"),i=="smart"&&(n.mode.indent?y=Cr(e,t).state:i="prev");var N=e.options.tabSize,K=Ye(n,t),X=ne(K.text,null,N);K.stateAfter&&(K.stateAfter=null);var re=K.text.match(/^\s*/)[0],de;if(!r&&!/\S/.test(K.text))de=0,i="not";else if(i=="smart"&&(de=n.mode.indent(y,K.text.slice(re.length),K.text),de==Me||de>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?de=ne(Ye(n,t-1).text,null,N):de=0:i=="add"?de=X+e.options.indentUnit:i=="subtract"?de=X-e.options.indentUnit:typeof i=="number"&&(de=X+i),de=Math.max(0,de);var pe="",Se=0;if(e.options.indentWithTabs)for(var be=Math.floor(de/N);be;--be)Se+=N,pe+=" ";if(Se<de&&(pe+=W(de-Se)),pe!=re)return Bi(n,pe,Be(t,0),Be(t,re.length),"+input"),K.stateAfter=null,!0;for(var Re=0;Re<n.sel.ranges.length;Re++){var Ne=n.sel.ranges[Re];if(Ne.head.line==t&&Ne.head.ch<re.length){var Ue=Be(t,re.length);Na(n,Re,new kt(Ue,Ue));break}}}var Rr=null;function ra(e){Rr=e}function za(e,t,i,r,n){var y=e.doc;e.display.shift=!1,r||(r=y.sel);var N=+new Date-200,K=n=="paste"||e.state.pasteIncoming>N,X=ot(t),re=null;if(K&&r.ranges.length>1)if(Rr&&Rr.text.join(`
`)==t){if(r.ranges.length%Rr.text.length==0){re=[];for(var de=0;de<Rr.text.length;de++)re.push(y.splitLines(Rr.text[de]))}}else X.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(re=k(X,function(He){return[He]}));for(var pe=e.curOp.updateInput,Se=r.ranges.length-1;Se>=0;Se--){var be=r.ranges[Se],Re=be.from(),Ne=be.to();be.empty()&&(i&&i>0?Re=Be(Re.line,Re.ch-i):e.state.overwrite&&!K?Ne=Be(Ne.line,Math.min(Ye(y,Ne.line).text.length,Ne.ch+w(X).length)):K&&Rr&&Rr.lineWise&&Rr.text.join(`
`)==X.join(`
`)&&(Re=Ne=Be(Re.line,0)));var Ue={from:Re,to:Ne,text:re?re[Se%re.length]:X,origin:n||(K?"paste":e.state.cutIncoming>N?"cut":"+input")};Ni(e.doc,Ue),Jt(e,"inputRead",e,Ue)}t&&!K&&Cs(e,t),Oi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=pe),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ts(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&fr(t,function(){return za(t,i,0,null,"paste")}),!0}function Cs(e,t){if(!e.options.electricChars||!e.options.smartIndent)return;for(var i=e.doc.sel,r=i.ranges.length-1;r>=0;r--){var n=i.ranges[r];if(n.head.ch>100||r&&i.ranges[r-1].head.line==n.head.line)continue;var y=e.getModeAt(n.head),N=!1;if(y.electricChars){for(var K=0;K<y.electricChars.length;K++)if(t.indexOf(y.electricChars.charAt(K))>-1){N=An(e,n.head.line,"smart");break}}else y.electricInput&&(y.electricInput.test(Ye(e.doc,n.head.line).text.slice(0,n.head.ch))&&(N=An(e,n.head.line,"smart")));N&&Jt(e,"electricInput",e,n.head.line)}}function ws(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,y={anchor:Be(n,0),head:Be(n+1,0)};i.push(y),t.push(e.getRange(y.anchor,y.head))}return{text:t,ranges:i}}function As(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Ls(){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 P?e.style.width="1000px":e.setAttribute("wrap","off"),S&&(e.style.border="1px solid black"),As(e),t}function ql(e){var t=e.optionHandlers,i=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(r,n){var y=this.options,N=y[r];if(y[r]==n&&r!="mode")return;y[r]=n,t.hasOwnProperty(r)&&zt(this,t[r])(this,n,N),ae(this,"optionChange",this,r)},getOption:function(r){return this.options[r]},getDoc:function(){return this.doc},addKeyMap:function(r,n){this.state.keyMaps[n?"push":"unshift"](qn(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,y=0;y<n.length;++y)if(n[y]==r||n[y].name==r)return n.splice(y,1),!0},addOverlay:ir(function(r,n){var y=r.token?r:e.getMode(this.options,r);if(y.startState)throw new Error("Overlays may not be stateful.");H(this.state.overlays,{mode:y,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(N){return N.priority}),this.state.modeGen++,sr(this)}),removeOverlay:ir(function(r){for(var n=this.state.overlays,y=0;y<n.length;++y){var N=n[y].modeSpec;if(N==r||typeof r=="string"&&N.name==r){n.splice(y,1),this.state.modeGen++,sr(this);return}}}),indentLine:ir(function(r,n,y){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),vr(this.doc,r)&&An(this,r,n,y)}),indentSelection:ir(function(r){for(var n=this.doc.sel.ranges,y=-1,N=0;N<n.length;N++){var K=n[N];if(K.empty())K.head.line>y&&(An(this,K.head.line,r,!0),y=K.head.line,N==this.doc.sel.primIndex&&Oi(this));else{var X=K.from(),re=K.to(),de=Math.max(y,X.line);y=Math.min(this.lastLine(),re.line-(re.ch?0:1))+1;for(var pe=de;pe<y;++pe)An(this,pe,r);var Se=this.doc.sel.ranges;X.ch==0&&n.length==Se.length&&Se[N].from().ch>0&&Na(this.doc,N,new kt(X,Se[N].to()),Te)}}}),getTokenAt:function(r,n){return kn(this,r,n)},getLineTokens:function(r,n){return kn(this,Be(r),n,!0)},getTokenTypeAt:function(r){r=ft(this.doc,r);var n=ni(this,Ye(this.doc,r.line)),y=0,N=(n.length-1)/2,K=r.ch,X;if(K==0)X=n[2];else for(;;){var re=y+N>>1;if((re?n[re*2-1]:0)>=K)N=re;else if(n[re*2+1]<K)y=re+1;else{X=n[re*2+2];break}}var de=X?X.indexOf("overlay "):-1;return de<0?X:de==0?null:X.slice(0,de-1)},getModeAt:function(r){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(r).state).mode:n},getHelper:function(r,n){return this.getHelpers(r,n)[0]},getHelpers:function(r,n){var y=[];if(!i.hasOwnProperty(n))return y;var N=i[n],K=this.getModeAt(r);if(typeof K[n]=="string")N[K[n]]&&y.push(N[K[n]]);else if(K[n])for(var X=0;X<K[n].length;X++){var re=N[K[n][X]];re&&y.push(re)}else K.helperType&&N[K.helperType]?y.push(N[K.helperType]):N[K.name]&&y.push(N[K.name]);for(var de=0;de<N._global.length;de++){var pe=N._global[de];pe.pred(K,this)&&ge(y,pe.val)==-1&&y.push(pe.val)}return y},getStateAfter:function(r,n){var y=this.doc;return r=Ei(y,r==null?y.first+y.size-1:r),Cr(this,r+1,n).state},cursorCoords:function(r,n){var y,N=this.doc.sel.primary();return r==null?y=N.head:typeof r=="object"?y=ft(this.doc,r):y=r?N.from():N.to(),_r(this,y,n||"page")},charCoords:function(r,n){return ma(this,ft(this.doc,r),n||"page")},coordsChar:function(r,n){return r=lo(this,r,n||"page"),va(this,r.left,r.top)},lineAtHeight:function(r,n){return r=lo(this,{top:r,left:0},n||"page").top,At(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,y){var N=!1,K;if(typeof r=="number"){var X=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>X&&(r=X,N=!0),K=Ye(this.doc,r)}else K=r;return Fn(this,K,{top:0,left:0},n||"page",y||N).top+(N?this.doc.height-kr(K):0)},defaultTextHeight:function(){return _i(this.display)},defaultCharWidth:function(){return Di(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,y,N,K){var X=this.display;r=_r(this,ft(this.doc,r));var re=r.bottom,de=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),X.sizer.appendChild(n),N=="over")re=r.top;else if(N=="above"||N=="near"){var pe=Math.max(X.wrapper.clientHeight,this.doc.height),Se=Math.max(X.sizer.clientWidth,X.lineSpace.clientWidth);(N=="above"||r.bottom+n.offsetHeight>pe)&&r.top>n.offsetHeight?re=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=pe&&(re=r.bottom),de+n.offsetWidth>Se&&(de=Se-n.offsetWidth)}n.style.top=re+"px",n.style.left=n.style.right="",K=="right"?(de=X.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(K=="left"?de=0:K=="middle"&&(de=(X.sizer.clientWidth-n.offsetWidth)/2),n.style.left=de+"px"),y&&Zs(this,{left:de,top:re,right:de+n.offsetWidth,bottom:re+n.offsetHeight})},triggerOnKeyDown:ir(ps),triggerOnKeyPress:ir(gs),triggerOnKeyUp:ms,triggerOnMouseDown:ir(vs),execCommand:function(r){if(Sn.hasOwnProperty(r))return Sn[r].call(null,this)},triggerElectric:ir(function(r){Cs(this,r)}),findPosH:function(r,n,y,N){var K=1;n<0&&(K=-1,n=-n);for(var X=ft(this.doc,r),re=0;re<n&&!(X=Ka(this.doc,X,K,y,N),X.hitSide);++re);return X},moveH:ir(function(r,n){var y=this;this.extendSelectionsBy(function(N){return y.display.shift||y.doc.extend||N.empty()?Ka(y.doc,N.head,r,n,y.options.rtlMoveVisually):r<0?N.from():N.to()},Ce)}),deleteH:ir(function(r,n){var y=this.doc.sel,N=this.doc;y.somethingSelected()?N.replaceSelection("",null,"+delete"):Wi(this,function(K){var X=Ka(N,K.head,r,n,!1);return r<0?{from:X,to:K.head}:{from:K.head,to:X}})}),findPosV:function(r,n,y,N){var K=1,X=N;n<0&&(K=-1,n=-n);for(var re=ft(this.doc,r),de=0;de<n;++de){var pe=_r(this,re,"div");if(X==null?X=pe.left:pe.left=X,re=ks(this,pe,K,y),re.hitSide)break}return re},moveV:ir(function(r,n){var y=this,N=this.doc,K=[],X=!this.display.shift&&!N.extend&&N.sel.somethingSelected();if(N.extendSelectionsBy(function(de){if(X)return r<0?de.from():de.to();var pe=_r(y,de.head,"div");de.goalColumn!=null&&(pe.left=de.goalColumn),K.push(pe.left);var Se=ks(y,pe,r,n);return n=="page"&&de==N.sel.primary()&&wa(y,ma(y,Se,"div").top-pe.top),Se},Ce),K.length)for(var re=0;re<N.sel.ranges.length;re++)N.sel.ranges[re].goalColumn=K[re]}),findWordAt:function(r){var n=this.doc,y=Ye(n,r.line).text,N=r.ch,K=r.ch;if(y){var X=this.getHelper(r,"wordChars");(r.sticky=="before"||K==y.length)&&N?--N:++K;for(var re=y.charAt(N),de=Le(re,X)?function(pe){return Le(pe,X)}:/\s/.test(re)?function(pe){return/\s/.test(pe)}:function(pe){return!/\s/.test(pe)&&!Le(pe)};N>0&&de(y.charAt(N-1));)--N;for(;K<y.length&&de(y.charAt(K));)++K}return new kt(Be(r.line,N),Be(r.line,K))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?G(this.display.cursorDiv,"CodeMirror-overwrite"):d(this.display.cursorDiv,"CodeMirror-overwrite"),ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==M()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:ir(function(r,n){sn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-Pr(this)-this.display.barHeight,width:r.scrollWidth-Pr(this)-this.display.barWidth,clientHeight:ca(this),clientWidth:ui(this)}},scrollIntoView:ir(function(r,n){r==null?(r={from:this.doc.sel.primary().head,to:null},n==null&&(n=this.options.cursorScrollMargin)):typeof r=="number"?r={from:Be(r,0),to:null}:r.from==null&&(r={from:r,to:null}),r.to||(r.to=r.from),r.margin=n||0,r.from.line!=null?Js(this,r):xo(this,r.from,r.to,r.margin)}),setSize:ir(function(r,n){var y=this,N=function(X){return typeof X=="number"||/^\d+$/.test(String(X))?X+"px":X};r!=null&&(this.display.wrapper.style.width=N(r)),n!=null&&(this.display.wrapper.style.height=N(n)),this.options.lineWrapping&&ao(this);var K=this.display.viewFrom;this.doc.iter(K,this.display.viewTo,function(X){if(X.widgets){for(var re=0;re<X.widgets.length;re++)if(X.widgets[re].noHScroll){Xr(y,K,"widget");break}}++K}),this.curOp.forceUpdate=!0,ae(this,"refresh",this)}),operation:function(r){return fr(this,r)},startOperation:function(){return mi(this)},endOperation:function(){return gi(this)},refresh:ir(function(){var r=this.display.cachedTextHeight;sr(this),this.curOp.forceUpdate=!0,an(this),sn(this,this.doc.scrollLeft,this.doc.scrollTop),ka(this.display),(r==null||Math.abs(r-_i(this.display))>.5||this.options.lineWrapping)&&Ea(this),ae(this,"refresh",this)}),swapDoc:ir(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Mo(this,r),an(this),this.display.input.reset(),sn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Jt(this,"swapDoc",this,n),n}),phrase:function(r){var n=this.options.phrases;return n&&Object.prototype.hasOwnProperty.call(n,r)?n[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}},oe(e),e.registerHelper=function(r,n,y){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=y},e.registerGlobalHelper=function(r,n,y,N){e.registerHelper(r,n,N),i[r]._global.push({pred:y,val:N})}}function Ka(e,t,i,r,n){var y=t,N=i,K=Ye(e,t.line),X=n&&e.direction=="rtl"?-i:i;function re(){var Ze=t.line+X;return Ze<e.first||Ze>=e.first+e.size?!1:(t=new Be(Ze,t.ch,t.sticky),K=Ye(e,Ze))}function de(Ze){var Ge;if(r=="codepoint"){var qe=K.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(qe)?Ge=null:Ge=new Be(t.line,Math.max(0,Math.min(K.text.length,t.ch+i*(qe>=55296&&qe<56320?2:1))),-i)}else n?Ge=Ml(e.cm,K,t,i):Ge=Fa(K,t,i);if(Ge==null)if(!Ze&&re())t=Ua(n,e.cm,K,t.line,X);else return!1;else t=Ge;return!0}if(r=="char"||r=="codepoint")de();else if(r=="column")de(!0);else if(r=="word"||r=="group")for(var pe=null,Se=r=="group",be=e.cm&&e.cm.getHelper(t,"wordChars"),Re=!0;!(i<0&&!de(!Re));Re=!1){var Ne=K.text.charAt(t.ch)||`
`,Ue=Le(Ne,be)?"w":Se&&Ne==`
`?"n":!Se||/\s/.test(Ne)?null:"p";if(Se&&!Re&&!Ue&&(Ue="s"),pe&&pe!=Ue){i<0&&(i=1,de(),t.sticky="after");break}if(Ue&&(pe=Ue),i>0&&!de(!Re))break}var He=Zn(e,t,y,N,!0);return ri(y,He)&&(He.hitSide=!0),He}function ks(e,t,i,r){var n=e.doc,y=t.left,N;if(r=="page"){var K=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),X=Math.max(K-.5*_i(e.display),3);N=(i>0?t.bottom:t.top)+i*X}else r=="line"&&(N=i>0?t.bottom+3:t.top-3);for(var re;!(re=va(e,y,N),!re.outside);){if(i<0?N<=0:N>=n.height){re.hitSide=!0;break}N+=i*5}return re}var _t=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new ce,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};_t.prototype.init=function(e){var t=this,i=this,r=i.cm,n=i.div=e.lineDiv;As(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function y(K){for(var X=K.target;X;X=X.parentNode){if(X==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(X.className))break}return!1}Ae(n,"paste",function(K){if(!y(K)||V(r,K)||Ts(K,r))return;U<=11&&setTimeout(zt(r,function(){return t.updateFromDOM()}),20)}),Ae(n,"compositionstart",function(K){t.composing={data:K.data,done:!1}}),Ae(n,"compositionupdate",function(K){t.composing||(t.composing={data:K.data,done:!1})}),Ae(n,"compositionend",function(K){t.composing&&(K.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),Ae(n,"touchstart",function(){return i.forceCompositionEnd()}),Ae(n,"input",function(){t.composing||t.readFromDOMSoon()});function N(K){if(!y(K)||V(r,K))return;if(r.somethingSelected())ra({lineWise:!1,text:r.getSelections()}),K.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var X=ws(r);ra({lineWise:!0,text:X.text}),K.type=="cut"&&r.operation(function(){r.setSelections(X.ranges,0,Te),r.replaceSelection("",null,"cut")})}else return;if(K.clipboardData){K.clipboardData.clearData();var re=Rr.text.join(`
`);if(K.clipboardData.setData("Text",re),K.clipboardData.getData("Text")==re){K.preventDefault();return}}var de=Ls(),pe=de.firstChild;r.display.lineSpace.insertBefore(de,r.display.lineSpace.firstChild),pe.value=Rr.text.join(`
`);var Se=document.activeElement;ie(pe),setTimeout(function(){r.display.lineSpace.removeChild(de),Se.focus(),Se==n&&i.showPrimarySelection()},50)}Ae(n,"copy",N),Ae(n,"cut",N)},_t.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},_t.prototype.prepareSelection=function(){var e=mo(this.cm,!1);return e.focus=document.activeElement==this.div,e},_t.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length)return;(e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e)},_t.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},_t.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),r=i.from(),n=i.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||n.line<t.display.viewFrom){e.removeAllRanges();return}var y=ia(t,e.anchorNode,e.anchorOffset),N=ia(t,e.focusNode,e.focusOffset);if(y&&!y.bad&&N&&!N.bad&&ht(ii(y,N),r)==0&&ht(xi(y,N),n)==0)return;var K=t.display.view,X=r.line>=t.display.viewFrom&&_s(t,r)||{node:K[0].measure.map[2],offset:0},re=n.line<t.display.viewTo&&_s(t,n);if(!re){var de=K[K.length-1].measure,pe=de.maps?de.maps[de.maps.length-1]:de.map;re={node:pe[pe.length-1],offset:pe[pe.length-2]-pe[pe.length-3]}}if(!X||!re){e.removeAllRanges();return}var Se=e.rangeCount&&e.getRangeAt(0),be;try{be=p(X.node,X.offset,re.offset,re.node)}catch(Re){}be&&(!_&&t.state.focused?(e.collapse(X.node,X.offset),be.collapsed||(e.removeAllRanges(),e.addRange(be))):(e.removeAllRanges(),e.addRange(be)),Se&&e.anchorNode==null?e.addRange(Se):_&&this.startGracePeriod()),this.rememberSelection()},_t.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)},_t.prototype.showMultipleSelections=function(e){h(this.cm.display.cursorDiv,e.cursors),h(this.cm.display.selectionDiv,e.selection)},_t.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},_t.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return b(this.div,t)},_t.prototype.focus=function(){this.cm.options.readOnly!="nocursor"&&((!this.selectionInEditor()||document.activeElement!=this.div)&&this.showSelection(this.prepareSelection(),!0),this.div.focus())},_t.prototype.blur=function(){this.div.blur()},_t.prototype.getField=function(){return this.div},_t.prototype.supportsTouch=function(){return!0},_t.prototype.receivedFocus=function(){var e=this;this.selectionInEditor()?this.pollSelection():fr(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)},_t.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},_t.prototype.pollSelection=function(){if(this.readDOMTimeout!=null||this.gracePeriod||!this.selectionChanged())return;var e=this.getSelection(),t=this.cm;if(u&&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 i=ia(t,e.anchorNode,e.anchorOffset),r=ia(t,e.focusNode,e.focusOffset);i&&r&&fr(t,function(){er(t.doc,$r(i,r),Te),(i.bad||r.bad)&&(t.curOp.selectionChanged=!0)})},_t.prototype.pollContent=function(){this.readDOMTimeout!=null&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e=this.cm,t=e.display,i=e.doc.sel.primary(),r=i.from(),n=i.to();if(r.ch==0&&r.line>e.firstLine()&&(r=Be(r.line-1,Ye(e.doc,r.line-1).length)),n.ch==Ye(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=Be(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var y,N,K;r.line==t.viewFrom||(y=ci(e,r.line))==0?(N=pt(t.view[0].line),K=t.view[0].node):(N=pt(t.view[y].line),K=t.view[y-1].node.nextSibling);var X=ci(e,n.line),re,de;if(X==t.view.length-1?(re=t.viewTo-1,de=t.lineDiv.lastChild):(re=pt(t.view[X+1].line)-1,de=t.view[X+1].node.previousSibling),!K)return!1;for(var pe=e.doc.splitLines(tu(e,K,de,N,re)),Se=Tt(e.doc,Be(N,0),Be(re,Ye(e.doc,re).text.length));pe.length>1&&Se.length>1;)if(w(pe)==w(Se))pe.pop(),Se.pop(),re--;else if(pe[0]==Se[0])pe.shift(),Se.shift(),N++;else break;for(var be=0,Re=0,Ne=pe[0],Ue=Se[0],He=Math.min(Ne.length,Ue.length);be<He&&Ne.charCodeAt(be)==Ue.charCodeAt(be);)++be;for(var Ze=w(pe),Ge=w(Se),qe=Math.min(Ze.length-(pe.length==1?be:0),Ge.length-(Se.length==1?be:0));Re<qe&&Ze.charCodeAt(Ze.length-Re-1)==Ge.charCodeAt(Ge.length-Re-1);)++Re;if(pe.length==1&&Se.length==1&&N==r.line)for(;be&&be>r.ch&&Ze.charCodeAt(Ze.length-Re-1)==Ge.charCodeAt(Ge.length-Re-1);)be--,Re++;pe[pe.length-1]=Ze.slice(0,Ze.length-Re).replace(/^\u200b+/,""),pe[0]=pe[0].slice(be).replace(/\u200b+$/,"");var ut=Be(N,be),st=Be(re,Se.length?w(Se).length-Re:0);if(pe.length>1||pe[0]||ht(ut,st))return Bi(e.doc,pe,ut,st,"+input"),!0},_t.prototype.ensurePolled=function(){this.forceCompositionEnd()},_t.prototype.reset=function(){this.forceCompositionEnd()},_t.prototype.forceCompositionEnd=function(){if(!this.composing)return;clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus()},_t.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)},_t.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&fr(this.cm,function(){return sr(e.cm)})},_t.prototype.setUneditable=function(e){e.contentEditable="false"},_t.prototype.onKeyPress=function(e){if(e.charCode==0||this.composing)return;e.preventDefault(),this.cm.isReadOnly()||zt(this.cm,za)(this.cm,String.fromCharCode(e.charCode==null?e.keyCode:e.charCode),0)},_t.prototype.readOnlyChanged=function(e){this.div.contentEditable=String(e!="nocursor")},_t.prototype.onContextMenu=function(){},_t.prototype.resetPosition=function(){},_t.prototype.needsContentAttribute=!0;function _s(e,t){var i=fa(e,t.line);if(!i||i.hidden)return null;var r=Ye(e.doc,t.line),n=eo(i,r,t.line),y=Xe(r,e.doc.direction),N="left";if(y){var K=Ve(y,t.ch);N=K%2?"right":"left"}var X=io(n.map,t.ch,N);return X.offset=X.collapse=="right"?X.end:X.start,X}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function Hi(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var y="",N=!1,K=e.doc.lineSeparator(),X=!1;function re(be){return function(Re){return Re.id==be}}function de(){N&&(y+=K,X&&(y+=K),N=X=!1)}function pe(be){be&&(de(),y+=be)}function Se(be){if(be.nodeType==1){var Re=be.getAttribute("cm-text");if(Re){pe(Re);return}var Ne=be.getAttribute("cm-marker"),Ue;if(Ne){var He=e.findMarks(Be(r,0),Be(n+1,0),re(+Ne));He.length&&(Ue=He[0].find(0))&&pe(Tt(e.doc,Ue.from,Ue.to).join(K));return}if(be.getAttribute("contenteditable")=="false")return;var Ze=/^(pre|div|p|li|table|br)$/i.test(be.nodeName);if(!/^br$/i.test(be.nodeName)&&be.textContent.length==0)return;Ze&&de();for(var Ge=0;Ge<be.childNodes.length;Ge++)Se(be.childNodes[Ge]);/^(pre|p)$/i.test(be.nodeName)&&(X=!0),Ze&&(N=!0)}else be.nodeType==3&&pe(be.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(Se(t),t==i);)t=t.nextSibling,X=!1;return y}function ia(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return Hi(e.clipPos(Be(e.display.viewTo-1)),!0);t=null,i=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 n=0;n<e.display.view.length;n++){var y=e.display.view[n];if(y.node==r)return ru(y,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!b(r,t))return Hi(Be(pt(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var y=e.rest?w(e.rest):e.line;return Hi(Be(pt(y),y.text.length),n)}var N=t.nodeType==3?t:null,K=t;for(!N&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(N=t.firstChild,i&&(i=N.nodeValue.length));K.parentNode!=r;)K=K.parentNode;var X=e.measure,re=X.maps;function de(Ue,He,Ze){for(var Ge=-1;Ge<(re?re.length:0);Ge++)for(var qe=Ge<0?X.map:re[Ge],ut=0;ut<qe.length;ut+=3){var st=qe[ut+2];if(st==Ue||st==He){var gt=pt(Ge<0?e.line:e.rest[Ge]),Rt=qe[ut]+Ze;return(Ze<0||st!=Ue)&&(Rt=qe[ut+(Ze?1:0)]),Be(gt,Rt)}}}var pe=de(N,K,i);if(pe)return Hi(pe,n);for(var Se=K.nextSibling,be=N?N.nodeValue.length-i:0;Se;Se=Se.nextSibling){if(pe=de(Se,Se.firstChild,0),pe)return Hi(Be(pe.line,pe.ch-be),n);be+=Se.textContent.length}for(var Re=K.previousSibling,Ne=i;Re;Re=Re.previousSibling){if(pe=de(Re,Re.firstChild,-1),pe)return Hi(Be(pe.line,pe.ch+Ne),n);Ne+=Re.textContent.length}}var Ft=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new ce,this.hasSelection=!1,this.composing=null};Ft.prototype.init=function(e){var t=this,i=this,r=this.cm;this.createField(e);var n=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),S&&(n.style.width="0px"),Ae(n,"input",function(){j&&U>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),Ae(n,"paste",function(N){if(V(r,N)||Ts(N,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function y(N){if(V(r,N))return;if(r.somethingSelected())ra({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var K=ws(r);ra({lineWise:!0,text:K.text}),N.type=="cut"?r.setSelections(K.ranges,null,Te):(i.prevInput="",n.value=K.text.join(`
`),ie(n))}else return;N.type=="cut"&&(r.state.cutIncoming=+new Date)}Ae(n,"cut",y),Ae(n,"copy",y),Ae(e.scroller,"paste",function(N){if(jr(e,N)||V(r,N))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var K=new Event("paste");K.clipboardData=N.clipboardData,n.dispatchEvent(K)}),Ae(e.lineSpace,"selectstart",function(N){jr(e,N)||Q(N)}),Ae(n,"compositionstart",function(){var N=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:N,range:r.markText(N,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ae(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},Ft.prototype.createField=function(e){this.wrapper=Ls(),this.textarea=this.wrapper.firstChild},Ft.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Ft.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=mo(e);if(e.options.moveInputWithCursor){var n=_r(e,i.sel.primary().head,"div"),y=t.wrapper.getBoundingClientRect(),N=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+N.top-y.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+N.left-y.left))}return r},Ft.prototype.showSelection=function(e){var t=this.cm,i=t.display;h(i.cursorDiv,e.cursors),h(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Ft.prototype.reset=function(e){if(this.contextMenuPending||this.composing)return;var t=this.cm;if(t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i,t.state.focused&&ie(this.textarea),j&&U>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",j&&U>=9&&(this.hasSelection=null))},Ft.prototype.getField=function(){return this.textarea},Ft.prototype.supportsTouch=function(){return!1},Ft.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!o||M()!=this.textarea))try{this.textarea.focus()}catch(e){}},Ft.prototype.blur=function(){this.textarea.blur()},Ft.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Ft.prototype.receivedFocus=function(){this.slowPoll()},Ft.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()})},Ft.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;function i(){var r=t.poll();!r&&!e?(e=!0,t.polling.set(60,i)):(t.pollingFast=!1,t.slowPoll())}t.polling.set(20,i)},Ft.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||it(i)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var n=i.value;if(n==r&&!t.somethingSelected())return!1;if(j&&U>=9&&this.hasSelection===n||s&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var y=n.charCodeAt(0);if(y==8203&&!r&&(r="\u200B"),y==8666)return this.reset(),this.cm.execCommand("undo")}for(var N=0,K=Math.min(r.length,n.length);N<K&&r.charCodeAt(N)==n.charCodeAt(N);)++N;return fr(t,function(){za(t,n.slice(N),r.length-N,null,e.composing?"*compose":null),n.length>1e3||n.indexOf(`
`)>-1?i.value=e.prevInput="":e.prevInput=n,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Ft.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Ft.prototype.onKeyPress=function(){j&&U>=9&&(this.hasSelection=null),this.fastPoll()},Ft.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var y=di(i,e),N=r.scroller.scrollTop;if(!y||T)return;var K=i.options.resetSelectionOnContextMenu;K&&i.doc.sel.contains(y)==-1&&zt(i,er)(i.doc,$r(y),Te);var X=n.style.cssText,re=t.wrapper.style.cssText,de=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-de.top-5)+"px; left: "+(e.clientX-de.left-5)+`px;
z-index: 1000; background: `+(j?"rgba(255, 255, 255, .05)":"transparent")+`;
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var pe;P&&(pe=window.scrollY),r.input.focus(),P&&window.scrollTo(null,pe),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=be,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function Se(){if(n.selectionStart!=null){var Ne=i.somethingSelected(),Ue="\u200B"+(Ne?n.value:"");n.value="\u21DA",n.value=Ue,t.prevInput=Ne?"":"\u200B",n.selectionStart=1,n.selectionEnd=Ue.length,r.selForContextMenu=i.doc.sel}}function be(){if(t.contextMenuPending!=be)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=re,n.style.cssText=X,j&&U<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=N),n.selectionStart!=null){(!j||j&&U<9)&&Se();var Ne=0,Ue=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?zt(i,Xo)(i):Ne++<10?r.detectingSelectAll=setTimeout(Ue,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Ue,200)}}if(j&&U>=9&&Se(),L){ue(e);var Re=function(){Je(window,"mouseup",Re),setTimeout(be,20)};Ae(window,"mouseup",Re)}else setTimeout(be,50)},Ft.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},Ft.prototype.setUneditable=function(){},Ft.prototype.needsContentAttribute=!1;function iu(e,t){if(t=t?F(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 i=M();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=K.getValue()}var n;if(e.form&&(Ae(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var y=e.form;n=y.submit;try{var N=y.submit=function(){r(),y.submit=n,y.submit(),y.submit=N}}catch(X){}}t.finishInit=function(X){X.save=r,X.getTextArea=function(){return e},X.toTextArea=function(){X.toTextArea=isNaN,r(),e.parentNode.removeChild(X.getWrapperElement()),e.style.display="",e.form&&(Je(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var K=Mt(function(X){return e.parentNode.insertBefore(X,e.nextSibling)},t);return K}function nu(e){e.off=Je,e.on=Ae,e.wheelEventPixels=dl,e.Doc=lr,e.splitLines=ot,e.countColumn=ne,e.findColumn=we,e.isWordChar=Ee,e.Pass=Me,e.signal=ae,e.Line=li,e.changeEnd=Zr,e.scrollbarModel=To,e.Pos=Be,e.cmpPos=ht,e.modes=Ot,e.mimeModes=Et,e.resolveMode=Yt,e.getMode=gr,e.modeExtensions=cr,e.extendMode=zr,e.copyState=$t,e.startState=ti,e.innerMode=Nr,e.commands=Sn,e.keyMap=Hr,e.keyName=us,e.isModifierKey=ss,e.lookupKey=Ui,e.normalizeKeyMap=Pl,e.StringStream=Pt,e.SharedTextMarker=bn,e.TextMarker=Qr,e.LineWidget=yn,e.e_preventDefault=Q,e.e_stopPropagation=ee,e.e_stop=ue,e.addClass=G,e.contains=b,e.rmClass=d,e.keyNames=qr}$l(Mt),ql(Mt);var au="iter insert remove copy getEditor constructor".split(" ");for(var na in lr.prototype)lr.prototype.hasOwnProperty(na)&&ge(au,na)<0&&(Mt.prototype[na]=function(e){return function(){return e.apply(this.doc,arguments)}}(lr.prototype[na]));return oe(lr),Mt.inputStyles={textarea:Ft,contenteditable:_t},Mt.defineMode=function(e){!Mt.defaults.mode&&e!="null"&&(Mt.defaults.mode=e),mr.apply(this,arguments)},Mt.defineMIME=Tr,Mt.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Mt.defineMIME("text/plain","null"),Mt.defineExtension=function(e,t){Mt.prototype[e]=t},Mt.defineDocExtension=function(e,t){lr.prototype[e]=t},Mt.fromTextArea=iu,nu(Mt),Mt.version="5.58.2",Mt})},Y1PL:function(dt,et,le){"use strict";le.r(et),le.d(et,"ResizableTextArea",function(){return ge});var fe=le("wx14"),J=le("1OyB"),_=le("vuIU"),$=le("Ji7U"),I=le("LK+K"),D=le("q1tI"),j=le("VTBJ"),U=le("rePB"),P=le("Zm9Q"),O=le("Kwbf"),v=le("c+Xe"),T=le("m+aA"),R=le("bdgK"),A=new Map;function C(Te){Te.forEach(function(Oe){var Ce,we=Oe.target;(Ce=A.get(we))===null||Ce===void 0||Ce.forEach(function(ve){return ve(we)})})}var S=new R.default(C),u=null,o=null;function s(Te,Oe){A.has(Te)||(A.set(Te,new Set),S.observe(Te)),A.get(Te).add(Oe)}function l(Te,Oe){A.has(Te)&&(A.get(Te).delete(Oe),A.get(Te).size||(S.unobserve(Te),A.delete(Te)))}var E=function(Te){Object($.a)(Ce,Te);var Oe=Object(I.a)(Ce);function Ce(){return Object(J.a)(this,Ce),Oe.apply(this,arguments)}return Object(_.a)(Ce,[{key:"render",value:function(){return this.props.children}}]),Ce}(D.Component),m=D.createContext(null);function f(Te){var Oe=Te.children,Ce=Te.onBatchResize,we=D.useRef(0),ve=D.useRef([]),W=D.useContext(m),w=D.useCallback(function(k,H,q){we.current+=1;var B=we.current;ve.current.push({size:k,element:H,data:q}),Promise.resolve().then(function(){B===we.current&&(Ce==null||Ce(ve.current),ve.current=[])}),W==null||W(k,H,q)},[Ce,W]);return D.createElement(m.Provider,{value:w},Oe)}function L(Te){var Oe=Te.children,Ce=Te.disabled,we=D.useRef(null),ve=D.useRef(null),W=D.useContext(m),w=D.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),k=D.isValidElement(Oe)&&Object(v.c)(Oe),H=k?Oe.ref:null,q=D.useMemo(function(){return Object(v.a)(H,we)},[H,we]),B=D.useRef(Te);B.current=Te;var he=D.useCallback(function(Ee){var Le=B.current,Ie=Le.onResize,_e=Le.data,De=Ee.getBoundingClientRect(),Pe=De.width,je=De.height,ze=Ee.offsetWidth,Ke=Ee.offsetHeight,Ve=Math.floor(Pe),at=Math.floor(je);if(w.current.width!==Ve||w.current.height!==at||w.current.offsetWidth!==ze||w.current.offsetHeight!==Ke){var Xe={width:Ve,height:at,offsetWidth:ze,offsetHeight:Ke};w.current=Xe;var $e=ze===Math.round(Pe)?Pe:ze,Ae=Ke===Math.round(je)?je:Ke,rt=Object(j.a)(Object(j.a)({},Xe),{},{offsetWidth:$e,offsetHeight:Ae});W==null||W(rt,Ee,_e),Ie&&Promise.resolve().then(function(){Ie(rt,Ee)})}},[]);return D.useEffect(function(){var Ee=Object(T.a)(we.current)||Object(T.a)(ve.current);return Ee&&!Ce&&s(Ee,he),function(){return l(Ee,he)}},[we.current,Ce]),D.createElement(E,{ref:ve},k?D.cloneElement(Oe,{ref:q}):Oe)}var g="rc-observer-key";function d(Te){var Oe=Te.children,Ce=Object(P.a)(Oe);return Ce.map(function(we,ve){var W=(we==null?void 0:we.key)||"".concat(g,"-").concat(ve);return D.createElement(L,Object(fe.a)({},Te,{key:W}),we)})}d.Collection=f;var c=d,h=le("bT9E"),a=le("TSYQ"),x=le.n(a),p=`
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
`,b=["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"],M={},G;function Z(Te){var Oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ce=Te.getAttribute("id")||Te.getAttribute("data-reactid")||Te.getAttribute("name");if(Oe&&M[Ce])return M[Ce];var we=window.getComputedStyle(Te),ve=we.getPropertyValue("box-sizing")||we.getPropertyValue("-moz-box-sizing")||we.getPropertyValue("-webkit-box-sizing"),W=parseFloat(we.getPropertyValue("padding-bottom"))+parseFloat(we.getPropertyValue("padding-top")),w=parseFloat(we.getPropertyValue("border-bottom-width"))+parseFloat(we.getPropertyValue("border-top-width")),k=b.map(function(q){return"".concat(q,":").concat(we.getPropertyValue(q))}).join(";"),H={sizingStyle:k,paddingSize:W,borderSize:w,boxSizing:ve};return Oe&&Ce&&(M[Ce]=H),H}function ie(Te){var Oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Ce=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,we=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;G||(G=document.createElement("textarea"),G.setAttribute("tab-index","-1"),G.setAttribute("aria-hidden","true"),document.body.appendChild(G)),Te.getAttribute("wrap")?G.setAttribute("wrap",Te.getAttribute("wrap")):G.removeAttribute("wrap");var ve=Z(Te,Oe),W=ve.paddingSize,w=ve.borderSize,k=ve.boxSizing,H=ve.sizingStyle;G.setAttribute("style","".concat(H,";").concat(p)),G.value=Te.value||Te.placeholder||"";var q=Number.MIN_SAFE_INTEGER,B=Number.MAX_SAFE_INTEGER,he=G.scrollHeight,Ee;if(k==="border-box"?he+=w:k==="content-box"&&(he-=W),Ce!==null||we!==null){G.value=" ";var Le=G.scrollHeight-W;Ce!==null&&(q=Le*Ce,k==="border-box"&&(q=q+W+w),he=Math.max(q,he)),we!==null&&(B=Le*we,k==="border-box"&&(B=B+W+w),Ee=he>B?"":"hidden",he=Math.min(B,he))}return{height:he,minHeight:q,maxHeight:B,overflowY:Ee,resize:"none"}}var z=le("Gytx"),F=le.n(z),ne;(function(Te){Te[Te.NONE=0]="NONE",Te[Te.RESIZING=1]="RESIZING",Te[Te.RESIZED=2]="RESIZED"})(ne||(ne={}));var ce=function(Te){Object($.a)(Ce,Te);var Oe=Object(I.a)(Ce);function Ce(we){var ve;return Object(J.a)(this,Ce),ve=Oe.call(this,we),ve.nextFrameActionId=void 0,ve.resizeFrameId=void 0,ve.textArea=void 0,ve.saveTextArea=function(W){ve.textArea=W},ve.handleResize=function(W){var w=ve.state.resizeStatus,k=ve.props,H=k.autoSize,q=k.onResize;if(w!==ne.NONE)return;typeof q=="function"&&q(W),H&&ve.resizeOnNextFrame()},ve.resizeOnNextFrame=function(){cancelAnimationFrame(ve.nextFrameActionId),ve.nextFrameActionId=requestAnimationFrame(ve.resizeTextarea)},ve.resizeTextarea=function(){var W=ve.props.autoSize;if(!W||!ve.textArea)return;var w=W.minRows,k=W.maxRows,H=ie(ve.textArea,!1,w,k);ve.setState({textareaStyles:H,resizeStatus:ne.RESIZING},function(){cancelAnimationFrame(ve.resizeFrameId),ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:ne.RESIZED},function(){ve.resizeFrameId=requestAnimationFrame(function(){ve.setState({resizeStatus:ne.NONE}),ve.fixFirefoxAutoScroll()})})})})},ve.renderTextArea=function(){var W=ve.props,w=W.prefixCls,k=w===void 0?"rc-textarea":w,H=W.autoSize,q=W.onResize,B=W.className,he=W.disabled,Ee=ve.state,Le=Ee.textareaStyles,Ie=Ee.resizeStatus,_e=Object(h.a)(ve.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),De=x()(k,B,Object(U.a)({},"".concat(k,"-disabled"),he));"value"in _e&&(_e.value=_e.value||"");var Pe=Object(j.a)(Object(j.a)(Object(j.a)({},ve.props.style),Le),Ie===ne.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return D.createElement(c,{onResize:ve.handleResize,disabled:!(H||q)},D.createElement("textarea",Object(fe.a)({},_e,{className:De,style:Pe,ref:ve.saveTextArea})))},ve.state={textareaStyles:{},resizeStatus:ne.NONE},ve}return Object(_.a)(Ce,[{key:"componentDidUpdate",value:function(ve){(ve.value!==this.props.value||!F()(ve.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 ve=this.textArea.selectionStart,W=this.textArea.selectionEnd;this.textArea.setSelectionRange(ve,W)}}catch(w){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Ce}(D.Component),ge=ce,xe=function(Te){Object($.a)(Ce,Te);var Oe=Object(I.a)(Ce);function Ce(we){var ve;Object(J.a)(this,Ce),ve=Oe.call(this,we),ve.resizableTextArea=void 0,ve.focus=function(){ve.resizableTextArea.textArea.focus()},ve.saveTextArea=function(w){ve.resizableTextArea=w},ve.handleChange=function(w){var k=ve.props.onChange;ve.setValue(w.target.value,function(){ve.resizableTextArea.resizeTextarea()}),k&&k(w)},ve.handleKeyDown=function(w){var k=ve.props,H=k.onPressEnter,q=k.onKeyDown;w.keyCode===13&&H&&H(w),q&&q(w)};var W=typeof we.value=="undefined"||we.value===null?we.defaultValue:we.value;return ve.state={value:W},ve}return Object(_.a)(Ce,[{key:"setValue",value:function(ve,W){"value"in this.props||this.setState({value:ve},W)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return D.createElement(ge,Object(fe.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(ve){return"value"in ve?{value:ve.value}:null}}]),Ce}(D.Component),Me=et.default=xe},bNIU:function(dt,et,le){dt.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(dt,et,le){"use strict";le.d(et,"a",function(){return J});var fe=le("VTBJ");function J(_,$){var I=Object(fe.a)({},_);return Array.isArray($)&&$.forEach(function(D){delete I[D]}),I}},c5Ni:function(dt,et,le){},dejd:function(dt,et,le){},dmUQ:function(dt,et,le){"use strict";var fe=le("Ff2n"),J=le("rePB"),_=le("1OyB"),$=le("vuIU"),I=le("Ji7U"),D=le("md7G"),j=le("foSv"),U=le("q1tI"),P=le.n(U),O=le("TSYQ"),v=le.n(O),T=le("4IlW");function R(h,a){var x=Object.keys(h);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(h);a&&(p=p.filter(function(b){return Object.getOwnPropertyDescriptor(h,b).enumerable})),x.push.apply(x,p)}return x}function A(h){for(var a=1;a<arguments.length;a++){var x=arguments[a]!=null?arguments[a]:{};a%2?R(Object(x),!0).forEach(function(p){Object(J.a)(h,p,x[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(x)):R(Object(x)).forEach(function(p){Object.defineProperty(h,p,Object.getOwnPropertyDescriptor(x,p))})}return h}function C(h){var a=S();return function(){var p=Object(j.a)(h),b;if(a){var M=Object(j.a)(this).constructor;b=Reflect.construct(p,arguments,M)}else b=p.apply(this,arguments);return Object(D.a)(this,b)}}function S(){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(h){return!1}}function u(){}function o(h){h.preventDefault()}var s=function(a){return a.replace(/[^\w.-]+/g,"")},l=200,E=600,m=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,f=function(a){return a!=null},L=function(a,x){return x===a||typeof x=="number"&&typeof a=="number"&&isNaN(x)&&isNaN(a)},g=function(h){Object(I.a)(x,h);var a=C(x);function x(p){var b;Object(_.a)(this,x),b=a.call(this,p),b.onKeyDown=function(Z){var ie=b.props,z=ie.onKeyDown,F=ie.onPressEnter;if(Z.keyCode===T.a.UP){var ne=b.getRatio(Z);b.up(Z,ne,null),b.stop()}else if(Z.keyCode===T.a.DOWN){var ce=b.getRatio(Z);b.down(Z,ce,null),b.stop()}else Z.keyCode===T.a.ENTER&&F&&F(Z);if(b.recordCursorPosition(),b.lastKeyCode=Z.keyCode,z){for(var ge=arguments.length,xe=new Array(ge>1?ge-1:0),Me=1;Me<ge;Me++)xe[Me-1]=arguments[Me];z.apply(void 0,[Z].concat(xe))}},b.onKeyUp=function(Z){var ie=b.props.onKeyUp;if(b.stop(),b.recordCursorPosition(),ie){for(var z=arguments.length,F=new Array(z>1?z-1:0),ne=1;ne<z;ne++)F[ne-1]=arguments[ne];ie.apply(void 0,[Z].concat(F))}},b.onChange=function(Z){var ie=b.props.onChange;b.state.focused&&(b.inputting=!0),b.rawInput=b.props.parser(b.getValueFromEvent(Z)),b.setState({inputValue:b.rawInput}),ie(b.toNumber(b.rawInput))},b.onMouseUp=function(){var Z=b.props.onMouseUp;b.recordCursorPosition(),Z&&Z.apply(void 0,arguments)},b.onFocus=function(){var Z;b.setState({focused:!0}),(Z=b.props).onFocus.apply(Z,arguments)},b.onBlur=function(){var Z=b.props.onBlur;b.inputting=!1,b.setState({focused:!1});var ie=b.getCurrentValidValue(b.state.inputValue),z=b.setValue(ie,u);if(Z){var F=b.input.value,ne=b.getInputDisplayValue({focus:!1,value:z});b.input.value=ne&&Number(ne),Z.apply(void 0,arguments),b.input.value=F}},b.getRatio=function(Z){var ie=1;return Z.metaKey||Z.ctrlKey?ie=.1:Z.shiftKey&&(ie=10),ie},b.getFullNum=function(Z){return isNaN(Z)?Z:/e/i.test(String(Z))?Number(Z).toFixed(18).replace(/\.?0+$/,""):Z},b.getPrecision=function(Z){if(f(b.props.precision))return b.props.precision;var ie=String(Z);if(ie.indexOf("e-")>=0)return parseInt(ie.slice(ie.indexOf("e-")+2),10);var z=0;return ie.indexOf(".")>=0&&(z=ie.length-ie.indexOf(".")-1),z},b.getInputDisplayValue=function(Z){var ie=Z||b.state,z=ie.focused,F=ie.inputValue,ne=ie.value,ce;z?ce=F:ce=b.toPrecisionAsStep(ne),ce==null&&(ce="");var ge=b.formatWrapper(ce);return f(b.props.decimalSeparator)&&(ge=ge.toString().replace(".",b.props.decimalSeparator)),ge},b.recordCursorPosition=function(){try{b.cursorStart=b.input.selectionStart,b.cursorEnd=b.input.selectionEnd,b.currentValue=b.input.value,b.cursorBefore=b.input.value.substring(0,b.cursorStart),b.cursorAfter=b.input.value.substring(b.cursorEnd)}catch(Z){}},b.restoreByAfter=function(Z){if(Z===void 0)return!1;var ie=b.input.value,z=ie.lastIndexOf(Z);if(z===-1)return!1;var F=b.cursorBefore.length;return b.lastKeyCode===T.a.DELETE&&b.cursorBefore.charAt(F-1)===Z[0]?(b.fixCaret(F,F),!0):z+Z.length===ie.length?(b.fixCaret(z,z),!0):!1},b.partRestoreByAfter=function(Z){return Z===void 0?!1:Array.prototype.some.call(Z,function(ie,z){var F=Z.substring(z);return b.restoreByAfter(F)})},b.isNotCompleteNumber=function(Z){return isNaN(Z)||Z===""||Z===null||Z&&Z.toString().indexOf(".")===Z.toString().length-1},b.stop=function(){b.autoStepTimer&&clearTimeout(b.autoStepTimer)},b.down=function(Z,ie,z){b.pressingUpOrDown=!0,b.step("down",Z,ie,z)},b.up=function(Z,ie,z){b.pressingUpOrDown=!0,b.step("up",Z,ie,z)},b.saveInput=function(Z){b.input=Z};var M=p.value;M===void 0&&(M=p.defaultValue),b.state={focused:p.autoFocus};var G=b.getValidValue(b.toNumber(M));return b.state=A(A({},b.state),{},{inputValue:b.toPrecisionAsStep(G),value:G}),b}return Object($.a)(x,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(b){var M=this.props,G=M.value,Z=M.onChange,ie=M.max,z=M.min,F=this.state.focused;if(b){if(!L(b.value,G)||!L(b.max,ie)||!L(b.min,z)){var ne=F?G:this.getValidValue(G),ce;this.pressingUpOrDown?ce=ne:this.inputting?ce=this.rawInput:ce=this.toPrecisionAsStep(ne),this.setState({value:ne,inputValue:ce})}var ge="value"in this.props?G:this.state.value;"max"in this.props&&b.max!==ie&&typeof ge=="number"&&ge>ie&&Z&&Z(ie),"min"in this.props&&b.min!==z&&typeof ge=="number"&&ge<z&&Z&&Z(z)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var xe=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===T.a.BACKSPACE?xe=this.cursorStart-1:this.lastKeyCode===T.a.DELETE&&(xe=this.cursorStart):xe=this.input.value.length,this.fixCaret(xe,xe)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case T.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case T.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(Me){}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(b){var M=b;return M===""?M="":this.isNotCompleteNumber(parseFloat(M))?M=this.state.value:M=this.getValidValue(M),this.toNumber(M)}},{key:"getValueFromEvent",value:function(b){var M=b.target.value.trim().replace(/。/g,".");return f(this.props.decimalSeparator)&&(M=M.replace(this.props.decimalSeparator,".")),M}},{key:"getValidValue",value:function(b){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,Z=parseFloat(b);return isNaN(Z)?b:(Z<M&&(Z=M),Z>G&&(Z=G),Z)}},{key:"setValue",value:function(b,M){var G=this.props.precision,Z=this.isNotCompleteNumber(parseFloat(b))?null:parseFloat(b),ie=this.state.value,z=ie===void 0?null:ie,F=this.state.inputValue,ne=F===void 0?null:F,ce=typeof Z=="number"?Z.toFixed(G):"".concat(Z),ge=Z!==z||ce!=="".concat(ne);return"value"in this.props?(ne=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:ne},M)):this.setState({value:Z,inputValue:this.toPrecisionAsStep(b)},M),ge&&this.props.onChange(Z),Z}},{key:"getMaxPrecision",value:function(b){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.props,Z=G.precision,ie=G.step;if(f(Z))return Z;var z=this.getPrecision(M),F=this.getPrecision(ie),ne=this.getPrecision(b);return b?Math.max(ne,z+F):z+F}},{key:"getPrecisionFactor",value:function(b){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=this.getMaxPrecision(b,M);return Math.pow(10,G)}},{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(b){return this.props.formatter?this.props.formatter(b):b}},{key:"toPrecisionAsStep",value:function(b){if(this.isNotCompleteNumber(b)||b==="")return b;var M=Math.abs(this.getMaxPrecision(b));return isNaN(M)?b.toString():Number(b).toFixed(M)}},{key:"toNumber",value:function(b){var M=this.props.precision,G=this.state.focused,Z=b&&b.length>16&&G;return this.isNotCompleteNumber(b)||Z?b:f(M)?Math.round(b*Math.pow(10,M))/Math.pow(10,M):Number(b)}},{key:"upStep",value:function(b,M){var G=this.props.step,Z=this.getPrecisionFactor(b,M),ie=Math.abs(this.getMaxPrecision(b,M)),z=((Z*b+Z*G*M)/Z).toFixed(ie);return this.toNumber(z)}},{key:"downStep",value:function(b,M){var G=this.props.step,Z=this.getPrecisionFactor(b,M),ie=Math.abs(this.getMaxPrecision(b,M)),z=((Z*b-Z*G*M)/Z).toFixed(ie);return this.toNumber(z)}},{key:"step",value:function(b,M){var G=this,Z=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,ie=arguments.length>3?arguments[3]:void 0;this.stop(),M&&(M.persist(),M.preventDefault());var z=this.props;if(z.disabled)return;var F=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(F))return;var ne=this["".concat(b,"Step")](F,Z),ce=ne>z.max||ne<z.min;if(ne>z.max?ne=z.max:ne<z.min&&(ne=z.min),this.setValue(ne,null),this.setState({focused:!0},function(){G.pressingUpOrDown=!1}),ce)return;this.autoStepTimer=setTimeout(function(){G[b](M,Z,!0)},ie?l:E)}},{key:"fixCaret",value:function(b,M){if(b===void 0||M===void 0||!this.input||!this.input.value)return;try{var G=this.input.selectionStart,Z=this.input.selectionEnd;(b!==G||M!==Z)&&this.input.setSelectionRange(b,M)}catch(ie){}}},{key:"render",value:function(){var b,M=this.props,G=M.prefixCls,Z=M.disabled,ie=M.readOnly,z=M.useTouch,F=M.autoComplete,ne=M.upHandler,ce=M.downHandler,ge=M.className,xe=M.max,Me=M.min,Te=M.style,Oe=M.title,Ce=M.onMouseEnter,we=M.onMouseLeave,ve=M.onMouseOver,W=M.onMouseOut,w=M.required,k=M.onClick,H=M.tabIndex,q=M.type,B=M.placeholder,he=M.id,Ee=M.inputMode,Le=M.pattern,Ie=M.step,_e=M.maxLength,De=M.autoFocus,Pe=M.name,je=M.onPaste,ze=M.onInput,Ke=Object(fe.a)(M,["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"]),Ve=this.state,at=Ve.value,Xe=Ve.focused,$e=v()(G,(b={},Object(J.a)(b,ge,!!ge),Object(J.a)(b,"".concat(G,"-disabled"),Z),Object(J.a)(b,"".concat(G,"-focused"),Xe),b)),Ae={};Object.keys(Ke).forEach(function(ue){(ue.substr(0,5)==="data-"||ue.substr(0,5)==="aria-"||ue==="role")&&(Ae[ue]=Ke[ue])});var rt=!ie&&!Z,Je=this.getInputDisplayValue(null),ae=(at||at===0)&&(isNaN(at)||Number(at)>=xe),V=(at||at===0)&&(isNaN(at)||Number(at)<=Me),Y=ae||Z||ie,te=V||Z||ie,oe=v()("".concat(G,"-handler"),"".concat(G,"-handler-up"),Object(J.a)({},"".concat(G,"-handler-up-disabled"),Y)),Q=v()("".concat(G,"-handler"),"".concat(G,"-handler-down"),Object(J.a)({},"".concat(G,"-handler-down-disabled"),te)),ee=z?{onTouchStart:Y?u:this.up,onTouchEnd:this.stop}:{onMouseDown:Y?u:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},se=z?{onTouchStart:te?u:this.down,onTouchEnd:this.stop}:{onMouseDown:te?u:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return P.a.createElement("div",{className:$e,style:Te,title:Oe,onMouseEnter:Ce,onMouseLeave:we,onMouseOver:ve,onMouseOut:W,onFocus:function(){return null},onBlur:function(){return null}},P.a.createElement("div",{className:"".concat(G,"-handler-wrap")},P.a.createElement("span",Object.assign({unselectable:"on"},ee,{role:"button","aria-label":"Increase Value","aria-disabled":Y,className:oe}),ne||P.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-up-inner"),onClick:o})),P.a.createElement("span",Object.assign({unselectable:"on"},se,{role:"button","aria-label":"Decrease Value","aria-disabled":te,className:Q}),ce||P.a.createElement("span",{unselectable:"on",className:"".concat(G,"-handler-down-inner"),onClick:o}))),P.a.createElement("div",{className:"".concat(G,"-input-wrap")},P.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":Me,"aria-valuemax":xe,"aria-valuenow":at,required:w,type:q,placeholder:B,onPaste:je,onClick:k,onMouseUp:this.onMouseUp,className:"".concat(G,"-input"),tabIndex:H,autoComplete:F,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:rt?this.onKeyDown:u,onKeyUp:rt?this.onKeyUp:u,autoFocus:De,maxLength:_e,readOnly:ie,disabled:Z,max:xe,min:Me,step:Ie,name:Pe,title:Oe,id:he,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(Je),pattern:Le,inputMode:Ee,onInput:ze},Ae))))}}]),x}(P.a.Component);g.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:m,min:-m,step:1,style:{},onChange:u,onKeyDown:u,onPressEnter:u,onFocus:u,onBlur:u,parser:s,required:!1,autoComplete:"off"};var d=g,c=et.a=d},fnXi:function(dt,et,le){"use strict";var fe=le("2qtc"),J=le("kLXV"),_=le("q1tI"),$=le.n(_),I=le("Ty5D"),D=le("9kvl"),j=le("93VE"),U=le.n(j),P=function(v){var T=v.activeIndex,R=v.isEdit,A=R===void 0?!0:R,C=v.dispatch,S=v.practiceSetting,u=Object(I.i)(),o=u.id,s=u.challengesId,l=Object(_.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]),E=function(f){var L,g=function(){D.d.push(f),C({type:"practiceSetting/setSideBarTabs",payload:{confirmLeave:!1}})};S!=null&&(L=S.sideBar)!==null&&L!==void 0&&L.confirmLeave?J.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(){g()}}):g()};return $.a.createElement("ul",{className:"challenge-nav"},A?l.map(function(m,f){return T===f?$.a.createElement("li",{key:m.url}," ",$.a.createElement("a",{className:"active"},m.name)," "):$.a.createElement("li",{key:m.url}," ",$.a.createElement("a",{onClick:function(){return E(m.url)}},m.name)," ")}):$.a.createElement("li",{key:l[0].url}," ",$.a.createElement("a",{className:"active"},l[0].name)," "))};et.a=Object(D.a)(function(O){var v=O.globalSetting,T=O.practiceSetting;return{globalSetting:v,practiceSetting:T}})(P)},kSUc:function(dt,et,le){},lZu9:function(dt,et,le){(function(fe){fe(le("VrN/"),le("1eCo"),le("8EBN"))})(function(fe){"use strict";fe.defineMode("markdown",function(J,_){var $=fe.getMode(J,"text/html"),I=$.name=="null";function D(z){if(fe.findModeByName){var F=fe.findModeByName(z);F&&(z=F.mime||F.mimes[0])}var ne=fe.getMode(J,z);return ne.name=="null"?null:ne}_.highlightFormatting===void 0&&(_.highlightFormatting=!1),_.maxBlockquoteDepth===void 0&&(_.maxBlockquoteDepth=0),_.taskLists===void 0&&(_.taskLists=!1),_.strikethrough===void 0&&(_.strikethrough=!1),_.emoji===void 0&&(_.emoji=!1),_.fencedCodeBlockHighlighting===void 0&&(_.fencedCodeBlockHighlighting=!0),_.fencedCodeBlockDefaultMode===void 0&&(_.fencedCodeBlockDefaultMode="text/plain"),_.xml===void 0&&(_.xml=!0),_.tokenTypeOverrides===void 0&&(_.tokenTypeOverrides={});var j={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 U in j)j.hasOwnProperty(U)&&_.tokenTypeOverrides[U]&&(j[U]=_.tokenTypeOverrides[U]);var P=/^([*\-_])(?:\s*\1){2,}\s*$/,O=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,v=/^\[(x| )\](?=\s)/i,T=_.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,R=/^ {0,3}(?:\={1,}|-{2,})\s*$/,A=/^[^#!\[\]*_\\<>` "'(~:]+/,C=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,S=/^\s*\[[^\]]+?\]:.*$/,u=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\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(z,F,ne){return F.f=F.inline=ne,ne(z,F)}function l(z,F,ne){return F.f=F.block=ne,ne(z,F)}function E(z){return!z||!/\S/.test(z.string)}function m(z){if(z.linkTitle=!1,z.linkHref=!1,z.linkText=!1,z.em=!1,z.strong=!1,z.strikethrough=!1,z.quote=0,z.indentedCode=!1,z.f==L){var F=I;if(!F){var ne=fe.innerMode($,z.htmlState);F=ne.mode.name=="xml"&&ne.state.tagStart===null&&!ne.state.context&&ne.state.tokenize.isInText}F&&(z.f=h,z.block=f,z.htmlState=null)}return z.trailingSpace=0,z.trailingSpaceNewLine=!1,z.prevLine=z.thisLine,z.thisLine={stream:null},null}function f(z,F){var ne=z.column()===F.indentation,ce=E(F.prevLine.stream),ge=F.indentedCode,xe=F.prevLine.hr,Me=F.list!==!1,Te=(F.listStack[F.listStack.length-1]||0)+3;F.indentedCode=!1;var Oe=F.indentation;if(F.indentationDiff===null&&(F.indentationDiff=F.indentation,Me)){for(F.list=null;Oe<F.listStack[F.listStack.length-1];)F.listStack.pop(),F.listStack.length?F.indentation=F.listStack[F.listStack.length-1]:F.list=!1;F.list!==!1&&(F.indentationDiff=Oe-F.listStack[F.listStack.length-1])}var Ce=!ce&&!xe&&!F.prevLine.header&&(!Me||!ge)&&!F.prevLine.fencedCodeEnd,we=(F.list===!1||xe||ce)&&F.indentation<=Te&&z.match(P),ve=null;if(F.indentationDiff>=4&&(ge||F.prevLine.fencedCodeEnd||F.prevLine.header||ce))return z.skipToEnd(),F.indentedCode=!0,j.code;if(z.eatSpace())return null;if(ne&&F.indentation<=Te&&(ve=z.match(T))&&ve[1].length<=6)return F.quote=0,F.header=ve[1].length,F.thisLine.header=!0,_.highlightFormatting&&(F.formatting="header"),F.f=F.inline,d(F);if(F.indentation<=Te&&z.eat(">"))return F.quote=ne?1:F.quote+1,_.highlightFormatting&&(F.formatting="quote"),z.eatSpace(),d(F);if(!we&&!F.setext&&ne&&F.indentation<=Te&&(ve=z.match(O))){var W=ve[1]?"ol":"ul";return F.indentation=Oe+z.current().length,F.list=!0,F.quote=0,F.listStack.push(F.indentation),F.em=!1,F.strong=!1,F.code=!1,F.strikethrough=!1,_.taskLists&&z.match(v,!1)&&(F.taskList=!0),F.f=F.inline,_.highlightFormatting&&(F.formatting=["list","list-"+W]),d(F)}else{if(ne&&F.indentation<=Te&&(ve=z.match(C,!0)))return F.quote=0,F.fencedEndRE=new RegExp(ve[1]+"+ *$"),F.localMode=_.fencedCodeBlockHighlighting&&D(ve[2]||_.fencedCodeBlockDefaultMode),F.localMode&&(F.localState=fe.startState(F.localMode)),F.f=F.block=g,_.highlightFormatting&&(F.formatting="code-block"),F.code=-1,d(F);if(F.setext||(!Ce||!Me)&&!F.quote&&F.list===!1&&!F.code&&!we&&!S.test(z.string)&&(ve=z.lookAhead(1))&&(ve=ve.match(R)))return F.setext?(F.header=F.setext,F.setext=0,z.skipToEnd(),_.highlightFormatting&&(F.formatting="header")):(F.header=ve[0].charAt(0)=="="?1:2,F.setext=F.header),F.thisLine.header=!0,F.f=F.inline,d(F);if(we)return z.skipToEnd(),F.hr=!0,F.thisLine.hr=!0,j.hr;if(z.peek()==="[")return s(z,F,M)}return s(z,F,F.inline)}function L(z,F){var ne=$.token(z,F.htmlState);if(!I){var ce=fe.innerMode($,F.htmlState);(ce.mode.name=="xml"&&ce.state.tagStart===null&&!ce.state.context&&ce.state.tokenize.isInText||F.md_inside&&z.current().indexOf(">")>-1)&&(F.f=h,F.block=f,F.htmlState=null)}return ne}function g(z,F){var ne=F.listStack[F.listStack.length-1]||0,ce=F.indentation<ne,ge=ne+3;if(F.fencedEndRE&&F.indentation<=ge&&(ce||z.match(F.fencedEndRE))){_.highlightFormatting&&(F.formatting="code-block");var xe;return ce||(xe=d(F)),F.localMode=F.localState=null,F.block=f,F.f=h,F.fencedEndRE=null,F.code=0,F.thisLine.fencedCodeEnd=!0,ce?l(z,F,F.block):xe}else return F.localMode?F.localMode.token(z,F.localState):(z.skipToEnd(),j.code)}function d(z){var F=[];if(z.formatting){F.push(j.formatting),typeof z.formatting=="string"&&(z.formatting=[z.formatting]);for(var ne=0;ne<z.formatting.length;ne++)F.push(j.formatting+"-"+z.formatting[ne]),z.formatting[ne]==="header"&&F.push(j.formatting+"-"+z.formatting[ne]+"-"+z.header),z.formatting[ne]==="quote"&&(!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=z.quote?F.push(j.formatting+"-"+z.formatting[ne]+"-"+z.quote):F.push("error"))}if(z.taskOpen)return F.push("meta"),F.length?F.join(" "):null;if(z.taskClosed)return F.push("property"),F.length?F.join(" "):null;if(z.linkHref?F.push(j.linkHref,"url"):(z.strong&&F.push(j.strong),z.em&&F.push(j.em),z.strikethrough&&F.push(j.strikethrough),z.emoji&&F.push(j.emoji),z.linkText&&F.push(j.linkText),z.code&&F.push(j.code),z.image&&F.push(j.image),z.imageAltText&&F.push(j.imageAltText,"link"),z.imageMarker&&F.push(j.imageMarker)),z.header&&F.push(j.header,j.header+"-"+z.header),z.quote&&(F.push(j.quote),!_.maxBlockquoteDepth||_.maxBlockquoteDepth>=z.quote?F.push(j.quote+"-"+z.quote):F.push(j.quote+"-"+_.maxBlockquoteDepth)),z.list!==!1){var ce=(z.listStack.length-1)%3;ce?ce===1?F.push(j.list2):F.push(j.list3):F.push(j.list1)}return z.trailingSpaceNewLine?F.push("trailing-space-new-line"):z.trailingSpace&&F.push("trailing-space-"+(z.trailingSpace%2?"a":"b")),F.length?F.join(" "):null}function c(z,F){return z.match(A,!0)?d(F):void 0}function h(z,F){var ne=F.text(z,F);if(typeof ne!="undefined")return ne;if(F.list)return F.list=null,d(F);if(F.taskList){var ce=z.match(v,!0)[1]===" ";return ce?F.taskOpen=!0:F.taskClosed=!0,_.highlightFormatting&&(F.formatting="task"),F.taskList=!1,d(F)}if(F.taskOpen=!1,F.taskClosed=!1,F.header&&z.match(/^#+$/,!0))return _.highlightFormatting&&(F.formatting="header"),d(F);var ge=z.next();if(F.linkTitle){F.linkTitle=!1;var xe=ge;ge==="("&&(xe=")"),xe=(xe+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var Me="^\\s*(?:[^"+xe+"\\\\]+|\\\\\\\\|\\\\.)"+xe;if(z.match(new RegExp(Me),!0))return j.linkHref}if(ge==="`"){var Te=F.formatting;_.highlightFormatting&&(F.formatting="code"),z.eatWhile("`");var Oe=z.current().length;if(F.code==0&&(!F.quote||Oe==1))return F.code=Oe,d(F);if(Oe==F.code){var Ce=d(F);return F.code=0,Ce}else return F.formatting=Te,d(F)}else if(F.code)return d(F);if(ge==="\\"&&(z.next(),_.highlightFormatting)){var we=d(F),ve=j.formatting+"-escape";return we?we+" "+ve:ve}if(ge==="!"&&z.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return F.imageMarker=!0,F.image=!0,_.highlightFormatting&&(F.formatting="image"),d(F);if(ge==="["&&F.imageMarker&&z.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return F.imageMarker=!1,F.imageAltText=!0,_.highlightFormatting&&(F.formatting="image"),d(F);if(ge==="]"&&F.imageAltText){_.highlightFormatting&&(F.formatting="image");var we=d(F);return F.imageAltText=!1,F.image=!1,F.inline=F.f=x,we}if(ge==="["&&!F.image)return F.linkText&&z.match(/^.*?\]/)||(F.linkText=!0,_.highlightFormatting&&(F.formatting="link")),d(F);if(ge==="]"&&F.linkText){_.highlightFormatting&&(F.formatting="link");var we=d(F);return F.linkText=!1,F.inline=F.f=z.match(/\(.*?\)| ?\[.*?\]/,!1)?x:h,we}if(ge==="<"&&z.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){F.f=F.inline=a,_.highlightFormatting&&(F.formatting="link");var we=d(F);return we?we+=" ":we="",we+j.linkInline}if(ge==="<"&&z.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){F.f=F.inline=a,_.highlightFormatting&&(F.formatting="link");var we=d(F);return we?we+=" ":we="",we+j.linkEmail}if(_.xml&&ge==="<"&&z.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var W=z.string.indexOf(">",z.pos);if(W!=-1){var w=z.string.substring(z.start,W);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(w)&&(F.md_inside=!0)}return z.backUp(1),F.htmlState=fe.startState($),l(z,F,L)}if(_.xml&&ge==="<"&&z.match(/^\/\w*?>/))return F.md_inside=!1,"tag";if(ge==="*"||ge==="_"){for(var k=1,H=z.pos==1?" ":z.string.charAt(z.pos-2);k<3&&z.eat(ge);)k++;var q=z.peek()||" ",B=!/\s/.test(q)&&(!u.test(q)||/\s/.test(H)||u.test(H)),he=!/\s/.test(H)&&(!u.test(H)||/\s/.test(q)||u.test(q)),Ee=null,Le=null;if(k%2&&(!F.em&&B&&(ge==="*"||!he||u.test(H))?Ee=!0:F.em==ge&&he&&(ge==="*"||!B||u.test(q))&&(Ee=!1)),k>1&&(!F.strong&&B&&(ge==="*"||!he||u.test(H))?Le=!0:F.strong==ge&&he&&(ge==="*"||!B||u.test(q))&&(Le=!1)),Le!=null||Ee!=null){_.highlightFormatting&&(F.formatting=Ee==null?"strong":Le==null?"em":"strong em"),Ee===!0&&(F.em=ge),Le===!0&&(F.strong=ge);var Ce=d(F);return Ee===!1&&(F.em=!1),Le===!1&&(F.strong=!1),Ce}}else if(ge===" "&&(z.eat("*")||z.eat("_"))){if(z.peek()===" ")return d(F);z.backUp(1)}if(_.strikethrough){if(ge==="~"&&z.eatWhile(ge)){if(F.strikethrough){_.highlightFormatting&&(F.formatting="strikethrough");var Ce=d(F);return F.strikethrough=!1,Ce}else if(z.match(/^[^\s]/,!1))return F.strikethrough=!0,_.highlightFormatting&&(F.formatting="strikethrough"),d(F)}else if(ge===" "&&z.match(/^~~/,!0)){if(z.peek()===" ")return d(F);z.backUp(2)}}if(_.emoji&&ge===":"&&z.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){F.emoji=!0,_.highlightFormatting&&(F.formatting="emoji");var Ie=d(F);return F.emoji=!1,Ie}return ge===" "&&(z.match(/^ +$/,!1)?F.trailingSpace++:F.trailingSpace&&(F.trailingSpaceNewLine=!0)),d(F)}function a(z,F){var ne=z.next();if(ne===">"){F.f=F.inline=h,_.highlightFormatting&&(F.formatting="link");var ce=d(F);return ce?ce+=" ":ce="",ce+j.linkInline}return z.match(/^[^>]+/,!0),j.linkInline}function x(z,F){if(z.eatSpace())return null;var ne=z.next();return ne==="("||ne==="["?(F.f=F.inline=b(ne==="("?")":"]"),_.highlightFormatting&&(F.formatting="link-string"),F.linkHref=!0,d(F)):"error"}var p={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function b(z){return function(F,ne){var ce=F.next();if(ce===z){ne.f=ne.inline=h,_.highlightFormatting&&(ne.formatting="link-string");var ge=d(ne);return ne.linkHref=!1,ge}return F.match(p[z]),ne.linkHref=!0,d(ne)}}function M(z,F){return z.match(/^([^\]\\]|\\.)*\]:/,!1)?(F.f=G,z.next(),_.highlightFormatting&&(F.formatting="link"),F.linkText=!0,d(F)):s(z,F,h)}function G(z,F){if(z.match(/^\]:/,!0)){F.f=F.inline=Z,_.highlightFormatting&&(F.formatting="link");var ne=d(F);return F.linkText=!1,ne}return z.match(/^([^\]\\]|\\.)+/,!0),j.linkText}function Z(z,F){return z.eatSpace()?null:(z.match(/^[^\s]+/,!0),z.peek()===void 0?F.linkTitle=!0:z.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),F.f=F.inline=h,j.linkHref+" url")}var ie={startState:function(){return{f,prevLine:{stream:null},thisLine:{stream:null},block:f,htmlState:null,indentation:0,inline:h,text:c,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(z){return{f:z.f,prevLine:z.prevLine,thisLine:z.thisLine,block:z.block,htmlState:z.htmlState&&fe.copyState($,z.htmlState),indentation:z.indentation,localMode:z.localMode,localState:z.localMode?fe.copyState(z.localMode,z.localState):null,inline:z.inline,text:z.text,formatting:!1,linkText:z.linkText,linkTitle:z.linkTitle,linkHref:z.linkHref,code:z.code,em:z.em,strong:z.strong,strikethrough:z.strikethrough,emoji:z.emoji,header:z.header,setext:z.setext,hr:z.hr,taskList:z.taskList,list:z.list,listStack:z.listStack.slice(0),quote:z.quote,indentedCode:z.indentedCode,trailingSpace:z.trailingSpace,trailingSpaceNewLine:z.trailingSpaceNewLine,md_inside:z.md_inside,fencedEndRE:z.fencedEndRE}},token:function(z,F){if(F.formatting=!1,z!=F.thisLine.stream){if(F.header=0,F.hr=!1,z.match(/^\s*$/,!0))return m(F),null;if(F.prevLine=F.thisLine,F.thisLine={stream:z},F.taskList=!1,F.trailingSpace=0,F.trailingSpaceNewLine=!1,!F.localState&&(F.f=F.block,F.f!=L)){var ne=z.match(/^\s*/,!0)[0].replace(/\t/g,o).length;if(F.indentation=ne,F.indentationDiff=null,ne>0)return null}}return F.f(z,F)},innerMode:function(z){return z.block==L?{state:z.htmlState,mode:$}:z.localState?{state:z.localState,mode:z.localMode}:{state:z,mode:ie}},indent:function(z,F,ne){return z.block==L&&$.indent?$.indent(z.htmlState,F,ne):z.localState&&z.localMode.indent?z.localMode.indent(z.localState,F,ne):fe.Pass},blankLine:m,getType:d,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return ie},"xml"),fe.defineMIME("text/markdown","markdown"),fe.defineMIME("text/x-markdown","markdown")})},nuEh:function(dt,et,le){"use strict";var fe=le("T2oS"),J=le("W9HT"),_=le("q1tI"),$=le.n(_),I=le("F8wB"),D=le.n(I),j=function(P){var O=P.loading;return O?$.a.createElement("div",{className:D.a.loading},$.a.createElement(J.a,null)):$.a.createElement($.a.Fragment,null)};et.a=j},osHv:function(dt,et,le){(function(fe){fe(le("VrN/"))})(function(fe){"use strict";var J=fe.Pos;function _(u,o){return u.line-o.line||u.ch-o.ch}var $="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",I=$+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",D=new RegExp("<(/?)(["+$+"]["+I+"]*)","g");function j(u,o,s,l){this.line=o,this.ch=s,this.cm=u,this.text=u.getLine(o),this.min=l?Math.max(l.from,u.firstLine()):u.firstLine(),this.max=l?Math.min(l.to-1,u.lastLine()):u.lastLine()}function U(u,o){var s=u.cm.getTokenTypeAt(J(u.line,o));return s&&/\btag\b/.test(s)}function P(u){return u.line>=u.max?void 0:(u.ch=0,u.text=u.cm.getLine(++u.line),!0)}function O(u){return u.line<=u.min?void 0:(u.text=u.cm.getLine(--u.line),u.ch=u.text.length,!0)}function v(u){for(;;){var o=u.text.indexOf(">",u.ch);if(o==-1){if(P(u))continue;return}if(!U(u,o+1)){u.ch=o+1;continue}var s=u.text.lastIndexOf("/",o),l=s>-1&&!/\S/.test(u.text.slice(s+1,o));return u.ch=o+1,l?"selfClose":"regular"}}function T(u){for(;;){var o=u.ch?u.text.lastIndexOf("<",u.ch-1):-1;if(o==-1){if(O(u))continue;return}if(!U(u,o+1)){u.ch=o;continue}D.lastIndex=o,u.ch=o;var s=D.exec(u.text);if(s&&s.index==o)return s}}function R(u){for(;;){D.lastIndex=u.ch;var o=D.exec(u.text);if(!o){if(P(u))continue;return}if(!U(u,o.index+1)){u.ch=o.index+1;continue}return u.ch=o.index+o[0].length,o}}function A(u){for(;;){var o=u.ch?u.text.lastIndexOf(">",u.ch-1):-1;if(o==-1){if(O(u))continue;return}if(!U(u,o+1)){u.ch=o;continue}var s=u.text.lastIndexOf("/",o),l=s>-1&&!/\S/.test(u.text.slice(s+1,o));return u.ch=o+1,l?"selfClose":"regular"}}function C(u,o){for(var s=[];;){var l=R(u),E,m=u.line,f=u.ch-(l?l[0].length:0);if(!l||!(E=v(u)))return;if(E=="selfClose")continue;if(l[1]){for(var L=s.length-1;L>=0;--L)if(s[L]==l[2]){s.length=L;break}if(L<0&&(!o||o==l[2]))return{tag:l[2],from:J(m,f),to:J(u.line,u.ch)}}else s.push(l[2])}}function S(u,o){for(var s=[];;){var l=A(u);if(!l)return;if(l=="selfClose"){T(u);continue}var E=u.line,m=u.ch,f=T(u);if(!f)return;if(f[1])s.push(f[2]);else{for(var L=s.length-1;L>=0;--L)if(s[L]==f[2]){s.length=L;break}if(L<0&&(!o||o==f[2]))return{tag:f[2],from:J(u.line,u.ch),to:J(E,m)}}}}fe.registerHelper("fold","xml",function(u,o){for(var s=new j(u,o.line,0);;){var l=R(s);if(!l||s.line!=o.line)return;var E=v(s);if(!E)return;if(!l[1]&&E!="selfClose"){var m=J(s.line,s.ch),f=C(s,l[2]);return f&&_(f.from,m)>0?{from:m,to:f.from}:null}}}),fe.findMatchingTag=function(u,o,s){var l=new j(u,o.line,o.ch,s);if(l.text.indexOf(">")==-1&&l.text.indexOf("<")==-1)return;var E=v(l),m=E&&J(l.line,l.ch),f=E&&T(l);if(!E||!f||_(l,o)>0)return;var L={from:J(l.line,l.ch),to:m,tag:f[2]};return E=="selfClose"?{open:L,close:null,at:"open"}:f[1]?{open:S(l,f[2]),close:L,at:"close"}:(l=new j(u,m.line,m.ch,s),{open:L,close:C(l,f[2]),at:"open"})},fe.findEnclosingTag=function(u,o,s,l){for(var E=new j(u,o.line,o.ch,s);;){var m=S(E,l);if(!m)break;var f=new j(u,o.line,o.ch,s),L=C(f,m.tag);if(L)return{open:m,close:L}}},fe.scanForClosingTag=function(u,o,s,l){var E=new j(u,o.line,o.ch,l?{from:0,to:l}:null);return C(E,s)}})},p5ED:function(dt,et,le){"use strict";var fe=le("+L6B"),J=le("2/Rp"),_=le("5Dmo"),$=le("3S7+"),I=le("k1fw"),D=le("9og8"),j=le("tJVT"),U=le("WmNS"),P=le.n(U),O=le("q1tI"),v=le.n(O),T=le("vHTk"),R=le.n(T),A=le("yEEn"),C=le("ZW9T"),S=le("1vsH"),u=le("V0Rq"),o=le("m3rI");et.a=function(s){var l,E,m,f,L,g,d,c=s.editOffice,h=c===void 0?"view":c,a=s.data,x=s.theme,p=s.type,b=s.filename,M=s.monacoEditor,G=s.className,Z=s.style,ie=s.close,z=s.onClose,F=s.hasMask,ne=s.disabledDownload,ce=Object(O.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),ge=Object(j.a)(ce,2),xe=ge[0],Me=ge[1],Te=Object(O.useState)(""),Oe=Object(j.a)(Te,2),Ce=Oe[0],we=Oe[1],ve=Object(O.useState)(),W=Object(j.a)(ve,2),w=W[0],k=W[1],H=window.ENV==="build"?"/react/build":"",q=o.a.PROXY_SERVER||location.origin,B,he=1024*1024,Ee=10*he,Le=Object(O.useRef)();(l=a)!==null&&l!==void 0&&l.startsWith("/api")&&p!=="txt"&&(a=(o.a.API_SERVER||location.origin)+a),p==="office"&&(B=Object(S.T)(a).filesize,B>Ee&&(p="other")),b&&M&&(M.filename=b),Object(O.useEffect)(function(){var Pe,je,ze=(Pe=document.cookie)===null||Pe===void 0||((je=Pe.replace(/\s/g,""))===null||je===void 0)?void 0:je.split(";");ze==null||ze.map(function(Ke){var Ve=Ke.split("=");Ve[0]==="_educoder_session"&&we(Ve[1])})},[]),Object(O.useEffect)(function(){p==="office"&&Ie()},[p,a]);var Ie=function(){var Pe=Object(D.a)(P.a.mark(function je(){var ze,Ke,Ve;return P.a.wrap(function(Xe){for(;;)switch(Xe.prev=Xe.next){case 0:return console.log("data:",a),ze=a,a.startsWith("http")||(ze=location.origin+ze),Ke=new URL(ze).pathname.split("/").pop(),Xe.next=6,Object(u.V)({attachment_id:Ke});case 6:Ve=Xe.sent,k(Ve);case 8:case"end":return Xe.stop()}},je)}));return function(){return Pe.apply(this,arguments)}}(),_e=function(){if(a.startsWith("http")||a.startsWith("blob:")){De();return}Object(S.z)(b||"educoder",a,b)},De=function(){Object(S.x)(b||"educoder",decodeURIComponent(a))};return v.a.createElement("div",{style:Object(I.a)({},Z||{}),className:"".concat(F&&R.a.bgBlack," ").concat(p?R.a.wrp:"hide")},ie&&v.a.createElement("div",{className:R.a.close,ref:Le},!ne&&v.a.createElement($.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return Le.current}},v.a.createElement("span",{onClick:De},v.a.createElement("i",{className:"icon-quxiaozhiding"}))),v.a.createElement($.a,{title:"\u5173\u95ED",getPopupContainer:function(){return Le.current}},v.a.createElement("span",{className:"",onClick:z},v.a.createElement("i",{className:"icon-guanbi1"})))),v.a.createElement("div",{className:"".concat(R.a[G]," ").concat(G," ").concat(R.a.monaco," ").concat(p==="txt"?"show":"hide")},p==="txt"&&v.a.createElement(C.b,M)),p==="audio"&&v.a.createElement("audio",{src:"".concat(((E=a)===null||E===void 0?void 0:E.indexOf("http://"))>-1||((m=a)===null||m===void 0?void 0:m.indexOf("https://"))>-1?"":"data:audio/mp3;base64,").concat(a),autoPlay:!0}),p==="video"&&v.a.createElement(v.a.Fragment,null,((f=a)===null||f===void 0?void 0:f.indexOf("http"))>-1?v.a.createElement("video",{controls:!0,src:"".concat(a),autoPlay:!0}):v.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(a),autoPlay:!0})),p==="office"&&w&&v.a.createElement("iframe",{src:"".concat(H,"/office.html?key=").concat(w.key,"&url=").concat(q+w.url,"&callbackUrl=").concat(q+w.callbackUrl,"&fileType=").concat(w.fileType,"&title=").concat(w.title,"&model=").concat(h,"&officeServer=").concat(o.a.OFFICE_SERVER,"&disabledDownload=").concat(!!ne)}),p==="html"&&v.a.createElement("iframe",{src:a+"&disposition=inline"}),p==="pdf"&&v.a.createElement("iframe",{src:"".concat(H,"/js/pdfview/index.html?url=").concat(a,"&disabledDownload=").concat(!!ne)}),p==="image"&&v.a.createElement("img",{src:"".concat(((L=a)===null||L===void 0?void 0:L.indexOf("http://"))>-1||((g=a)===null||g===void 0?void 0:g.indexOf("https://"))>-1||(d=a)!==null&&d!==void 0&&d.startsWith("/api")?"":"data:image/png;base64,").concat(a)}),p==="other"&&v.a.createElement("div",null,v.a.createElement(J.a,{type:"primary",size:"large",onClick:_e},v.a.createElement(A.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),p==="download"&&v.a.createElement(J.a,{type:"primary",size:"large",onClick:_e},v.a.createElement(A.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(dt,et,le){},rUJ1:function(dt,et){const le=/[&<>"']/,fe=/[&<>"']/g,J=/[<>"']|&(?!#?\w+;)/,_=/[<>"']|&(?!#?\w+;)/g,$={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},I=g=>$[g];function D(g,d){if(d){if(le.test(g))return g.replace(fe,I)}else if(J.test(g))return g.replace(_,I);return g}const j=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function U(g){return g.replace(j,(d,c)=>(c=c.toLowerCase(),c==="colon"?":":c.charAt(0)==="#"?c.charAt(1)==="x"?String.fromCharCode(parseInt(c.substring(2),16)):String.fromCharCode(+c.substring(1)):""))}const P=/(^|[^\[])\^/g;function O(g,d){g=g.source||g,d=d||"";const c={replace:(h,a)=>(a=a.source||a,a=a.replace(P,"$1"),g=g.replace(h,a),c),getRegex:()=>new RegExp(g,d)};return c}const v=/[^\w:]/g,T=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(g,d,c){if(g){let h;try{h=decodeURIComponent(U(c)).replace(v,"").toLowerCase()}catch(a){return null}if(h.indexOf("javascript:")===0||h.indexOf("vbscript:")===0||h.indexOf("data:")===0)return null}d&&!T.test(c)&&(c=o(d,c));try{c=encodeURI(c).replace(/%25/g,"%")}catch(h){return null}return c}const A={},C=/^[^:]+:\/*[^/]*$/,S=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(g,d){A[" "+g]||(C.test(g)?A[" "+g]=g+"/":A[" "+g]=m(g,"/",!0)),g=A[" "+g];const c=g.indexOf(":")===-1;return d.substring(0,2)==="//"?c?d:g.replace(S,"$1")+d:d.charAt(0)==="/"?c?d:g.replace(u,"$1")+d:g+d}const s={exec:function(){}};function l(g){let d=1,c,h;for(;d<arguments.length;d++){c=arguments[d];for(h in c)Object.prototype.hasOwnProperty.call(c,h)&&(g[h]=c[h])}return g}function E(g,d){const c=g.replace(/\|/g,(x,p,b)=>{let M=!1,G=p;for(;--G>=0&&b[G]==="\\";)M=!M;return M?"|":" |"}),h=c.split(/ \|/);let a=0;if(h.length>d)h.splice(d);else for(;h.length<d;)h.push("");for(;a<h.length;a++)h[a]=h[a].trim().replace(/\\\|/g,"|");return h}function m(g,d,c){const h=g.length;if(h===0)return"";let a=0;for(;a<h;){const x=g.charAt(h-a-1);if(x===d&&!c)a++;else if(x!==d&&c)a++;else break}return g.substr(0,h-a)}function f(g,d){if(g.indexOf(d[1])===-1)return-1;const c=g.length;let h=0,a=0;for(;a<c;a++)if(g[a]==="\\")a++;else if(g[a]===d[0])h++;else if(g[a]===d[1]&&(h--,h<0))return a;return-1}function L(g){g&&g.sanitize&&!g.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")}dt.exports={escape:D,unescape:U,edit:O,cleanUrl:R,resolveUrl:o,noopTest:s,merge:l,splitCells:E,rtrim:m,findClosingBracket:f,checkSanitizeDeprecation:L}},ulZh:function(dt,et,le){typeof window!="undefined"&&function(J,_){dt.exports=_()}(this,function(){return function(fe){var J={};function _($){if(J[$])return J[$].exports;var I=J[$]={i:$,l:!1,exports:{}};return fe[$].call(I.exports,I,I.exports,_),I.l=!0,I.exports}return _.m=fe,_.c=J,_.d=function($,I,D){_.o($,I)||Object.defineProperty($,I,{enumerable:!0,get:D})},_.r=function($){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty($,Symbol.toStringTag,{value:"Module"}),Object.defineProperty($,"__esModule",{value:!0})},_.t=function($,I){if(I&1&&($=_($)),I&8)return $;if(I&4&&typeof $=="object"&&$&&$.__esModule)return $;var D=Object.create(null);if(_.r(D),Object.defineProperty(D,"default",{enumerable:!0,value:$}),I&2&&typeof $!="string")for(var j in $)_.d(D,j,function(U){return $[U]}.bind(null,j));return D},_.n=function($){var I=$&&$.__esModule?function(){return $.default}:function(){return $};return _.d(I,"a",I),I},_.o=function($,I){return Object.prototype.hasOwnProperty.call($,I)},_.p="/dist/",_(_.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(fe,J,_){"use strict";var $=Object.prototype.hasOwnProperty,I="~";function D(){}Object.create&&(D.prototype=Object.create(null),new D().__proto__||(I=!1));function j(v,T,R){this.fn=v,this.context=T,this.once=R||!1}function U(v,T,R,A,C){if(typeof R!="function")throw new TypeError("The listener must be a function");var S=new j(R,A||v,C),u=I?I+T:T;return v._events[u]?v._events[u].fn?v._events[u]=[v._events[u],S]:v._events[u].push(S):(v._events[u]=S,v._eventsCount++),v}function P(v,T){--v._eventsCount===0?v._events=new D:delete v._events[T]}function O(){this._events=new D,this._eventsCount=0}O.prototype.eventNames=function(){var T=[],R,A;if(this._eventsCount===0)return T;for(A in R=this._events)$.call(R,A)&&T.push(I?A.slice(1):A);return Object.getOwnPropertySymbols?T.concat(Object.getOwnPropertySymbols(R)):T},O.prototype.listeners=function(T){var R=I?I+T:T,A=this._events[R];if(!A)return[];if(A.fn)return[A.fn];for(var C=0,S=A.length,u=new Array(S);C<S;C++)u[C]=A[C].fn;return u},O.prototype.listenerCount=function(T){var R=I?I+T:T,A=this._events[R];return A?A.fn?1:A.length:0},O.prototype.emit=function(T,R,A,C,S,u){var o=I?I+T:T;if(!this._events[o])return!1;var s=this._events[o],l=arguments.length,E,m;if(s.fn){s.once&&this.removeListener(T,s.fn,void 0,!0);switch(l){case 1:return s.fn.call(s.context),!0;case 2:return s.fn.call(s.context,R),!0;case 3:return s.fn.call(s.context,R,A),!0;case 4:return s.fn.call(s.context,R,A,C),!0;case 5:return s.fn.call(s.context,R,A,C,S),!0;case 6:return s.fn.call(s.context,R,A,C,S,u),!0}for(m=1,E=new Array(l-1);m<l;m++)E[m-1]=arguments[m];s.fn.apply(s.context,E)}else{var f=s.length,L;for(m=0;m<f;m++){s[m].once&&this.removeListener(T,s[m].fn,void 0,!0);switch(l){case 1:s[m].fn.call(s[m].context);break;case 2:s[m].fn.call(s[m].context,R);break;case 3:s[m].fn.call(s[m].context,R,A);break;case 4:s[m].fn.call(s[m].context,R,A,C);break;default:if(!E)for(L=1,E=new Array(l-1);L<l;L++)E[L-1]=arguments[L];s[m].fn.apply(s[m].context,E)}}}return!0},O.prototype.on=function(T,R,A){return U(this,T,R,A,!1)},O.prototype.once=function(T,R,A){return U(this,T,R,A,!0)},O.prototype.removeListener=function(T,R,A,C){var S=I?I+T:T;if(!this._events[S])return this;if(!R)return P(this,S),this;var u=this._events[S];if(u.fn)u.fn===R&&(!C||u.once)&&(!A||u.context===A)&&P(this,S);else{for(var o=0,s=[],l=u.length;o<l;o++)(u[o].fn!==R||C&&!u[o].once||A&&u[o].context!==A)&&s.push(u[o]);s.length?this._events[S]=s.length===1?s[0]:s:P(this,S)}return this},O.prototype.removeAllListeners=function(T){var R;return T?(R=I?I+T:T,this._events[R]&&P(this,R)):(this._events=new D,this._eventsCount=0),this},O.prototype.off=O.prototype.removeListener,O.prototype.addListener=O.prototype.on,O.prefixed=I,O.EventEmitter=O,fe.exports=O},"./node_modules/url-toolkit/src/url-toolkit.js":function(fe,J,_){(function($){var I=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,D=/^([^\/?#]*)([^]*)$/,j=/(?:\/|^)\.(?=\/)/g,U=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(O,v,T){if(T=T||{},O=O.trim(),v=v.trim(),!v){if(!T.alwaysNormalize)return O;var R=P.parseURL(O);if(!R)throw new Error("Error trying to parse base URL.");return R.path=P.normalizePath(R.path),P.buildURLFromParts(R)}var A=P.parseURL(v);if(!A)throw new Error("Error trying to parse relative URL.");if(A.scheme)return T.alwaysNormalize?(A.path=P.normalizePath(A.path),P.buildURLFromParts(A)):v;var C=P.parseURL(O);if(!C)throw new Error("Error trying to parse base URL.");if(!C.netLoc&&C.path&&C.path[0]!=="/"){var S=D.exec(C.path);C.netLoc=S[1],C.path=S[2]}C.netLoc&&!C.path&&(C.path="/");var u={scheme:C.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(u.netLoc=C.netLoc,A.path[0]!=="/"))if(!A.path)u.path=C.path,A.params||(u.params=C.params,A.query||(u.query=C.query));else{var o=C.path,s=o.substring(0,o.lastIndexOf("/")+1)+A.path;u.path=P.normalizePath(s)}return u.path===null&&(u.path=T.alwaysNormalize?P.normalizePath(A.path):A.path),P.buildURLFromParts(u)},parseURL:function(O){var v=I.exec(O);return v?{scheme:v[1]||"",netLoc:v[2]||"",path:v[3]||"",params:v[4]||"",query:v[5]||"",fragment:v[6]||""}:null},normalizePath:function(O){for(O=O.split("").reverse().join("").replace(j,"");O.length!==(O=O.replace(U,"")).length;);return O.split("").reverse().join("")},buildURLFromParts:function(O){return O.scheme+O.netLoc+O.path+O.params+O.query+O.fragment}};fe.exports=P})(this)},"./node_modules/webworkify-webpack/index.js":function(fe,J,_){function $(T){var R={};function A(S){if(R[S])return R[S].exports;var u=R[S]={i:S,l:!1,exports:{}};return T[S].call(u.exports,u,u.exports,A),u.l=!0,u.exports}A.m=T,A.c=R,A.i=function(S){return S},A.d=function(S,u,o){A.o(S,u)||Object.defineProperty(S,u,{configurable:!1,enumerable:!0,get:o})},A.r=function(S){Object.defineProperty(S,"__esModule",{value:!0})},A.n=function(S){var u=S&&S.__esModule?function(){return S.default}:function(){return S};return A.d(u,"a",u),u},A.o=function(S,u){return Object.prototype.hasOwnProperty.call(S,u)},A.p="/",A.oe=function(S){throw console.error(S),S};var C=A(A.s=ENTRY_MODULE);return C.default||C}var I="[\\.|\\-|\\+|\\w|/|@]+",D="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+I+").*?\\)";function j(T){return(T+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function U(T){return!isNaN(1*T)}function P(T,R,A){var C={};C[A]=[];var S=R.toString(),u=S.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return C;for(var o=u[1],s=new RegExp("(\\\\n|\\W)"+j(o)+D,"g"),l;l=s.exec(S);){if(l[3]==="dll-reference")continue;C[A].push(l[3])}for(s=new RegExp("\\("+j(o)+'\\("(dll-reference\\s('+I+'))"\\)\\)'+D,"g");l=s.exec(S);)T[l[2]]||(C[A].push(l[1]),T[l[2]]=_(l[1]).m),C[l[2]]=C[l[2]]||[],C[l[2]].push(l[4]);for(var E=Object.keys(C),m=0;m<E.length;m++)for(var f=0;f<C[E[m]].length;f++)U(C[E[m]][f])&&(C[E[m]][f]=1*C[E[m]][f]);return C}function O(T){var R=Object.keys(T);return R.reduce(function(A,C){return A||T[C].length>0},!1)}function v(T,R){for(var A={main:[R]},C={main:[]},S={main:{}};O(A);)for(var u=Object.keys(A),o=0;o<u.length;o++){var s=u[o],l=A[s],E=l.pop();if(S[s]=S[s]||{},S[s][E]||!T[s][E])continue;S[s][E]=!0,C[s]=C[s]||[],C[s].push(E);for(var m=P(T,T[s][E],s),f=Object.keys(m),L=0;L<f.length;L++)A[f[L]]=A[f[L]]||[],A[f[L]]=A[f[L]].concat(m[f[L]])}return C}fe.exports=function(T,R){R=R||{};var A={main:_.m},C=R.all?{main:Object.keys(A.main)}:v(A,T),S="";Object.keys(C).filter(function(E){return E!=="main"}).forEach(function(E){for(var m=0;C[E][m];)m++;C[E].push(m),A[E][m]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",S=S+"var "+E+" = ("+$.toString().replace("ENTRY_MODULE",JSON.stringify(m))+")({"+C[E].map(function(f){return""+JSON.stringify(f)+": "+A[E][f].toString()}).join(",")+`});
`}),S=S+"new (("+$.toString().replace("ENTRY_MODULE",JSON.stringify(T))+")({"+C.main.map(function(E){return""+JSON.stringify(E)+": "+A.main[E].toString()}).join(",")+"}))(self);";var u=new window.Blob([S],{type:"text/javascript"});if(R.bare)return u;var o=window.URL||window.webkitURL||window.mozURL||window.msURL,s=o.createObjectURL(u),l=new window.Worker(s);return l.objectURL=s,l}},"./src/config.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"hlsDefaultConfig",function(){return L}),_.d(J,"mergeConfig",function(){return d}),_.d(J,"enableStreamingMode",function(){return c});var $=_("./src/controller/abr-controller.ts"),I=_("./src/controller/audio-stream-controller.ts"),D=_("./src/controller/audio-track-controller.ts"),j=_("./src/controller/subtitle-stream-controller.ts"),U=_("./src/controller/subtitle-track-controller.ts"),P=_("./src/controller/buffer-controller.ts"),O=_("./src/controller/timeline-controller.ts"),v=_("./src/controller/cap-level-controller.ts"),T=_("./src/controller/fps-controller.ts"),R=_("./src/controller/eme-controller.ts"),A=_("./src/controller/cmcd-controller.ts"),C=_("./src/utils/xhr-loader.ts"),S=_("./src/utils/fetch-loader.ts"),u=_("./src/utils/cues.ts"),o=_("./src/utils/mediakeys-helper.ts"),s=_("./src/utils/logger.ts");function l(){return l=Object.assign||function(h){for(var a=1;a<arguments.length;a++){var x=arguments[a];for(var p in x)Object.prototype.hasOwnProperty.call(x,p)&&(h[p]=x[p])}return h},l.apply(this,arguments)}function E(h,a){var x=Object.keys(h);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(h);a&&(p=p.filter(function(b){return Object.getOwnPropertyDescriptor(h,b).enumerable})),x.push.apply(x,p)}return x}function m(h){for(var a=1;a<arguments.length;a++){var x=arguments[a]!=null?arguments[a]:{};a%2?E(Object(x),!0).forEach(function(p){f(h,p,x[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(x)):E(Object(x)).forEach(function(p){Object.defineProperty(h,p,Object.getOwnPropertyDescriptor(x,p))})}return h}function f(h,a,x){return a in h?Object.defineProperty(h,a,{value:x,enumerable:!0,configurable:!0,writable:!0}):h[a]=x,h}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:C.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:$.default,bufferController:P.default,capLevelController:v.default,fpsController:T.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},g()),{},{subtitleStreamController:j.SubtitleStreamController,subtitleTrackController:U.default,timelineController:O.TimelineController,audioStreamController:I.default,audioTrackController:D.default,emeController:R.default,cmcdController:A.default});function g(){return{cueHandler:u.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 d(h,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 l({},h,a)}function c(h){var a=h.loader;if(a!==S.default&&a!==C.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),h.progressive=!1;else{var x=Object(S.fetchSupported)();x&&(h.loader=S.default,h.progressive=!0,h.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/polyfills/number.ts"),I=_("./src/utils/ewma-bandwidth-estimator.ts"),D=_("./src/events.ts"),j=_("./src/utils/buffer-helper.ts"),U=_("./src/errors.ts"),P=_("./src/types/loader.ts"),O=_("./src/utils/logger.ts");function v(A,C){for(var S=0;S<C.length;S++){var u=C[S];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(A,u.key,u)}}function T(A,C,S){return C&&v(A.prototype,C),S&&v(A,S),A}var R=function(){function A(S){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=S;var u=S.config;this.bwEstimator=new I.default(u.abrEwmaSlowVoD,u.abrEwmaFastVoD,u.abrEwmaDefaultEstimate),this.registerListeners()}var C=A.prototype;return C.registerListeners=function(){var u=this.hls;u.on(D.Events.FRAG_LOADING,this.onFragLoading,this),u.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(D.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var u=this.hls;u.off(D.Events.FRAG_LOADING,this.onFragLoading,this),u.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this),u.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(D.Events.ERROR,this.onError,this)},C.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},C.onFragLoading=function(u,o){var s=o.frag;if(s.type===P.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=s,this.partCurrent=(l=o.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},C.onLevelLoaded=function(u,o){var s=this.hls.config;o.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)},C._abandonRulesCheck=function(){var u=this.fragCurrent,o=this.partCurrent,s=this.hls,l=s.autoLevelEnabled,E=s.config,m=s.media;if(!u||!m)return;var f=o?o.stats:u.stats,L=o?o.duration:u.duration;if(f.aborted){O.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!l||m.paused||!m.playbackRate||!m.readyState)return;var g=performance.now()-f.loading.start,d=Math.abs(m.playbackRate);if(g<=500*L/d)return;var c=s.levels,h=s.minAutoLevel,a=c[u.level],x=f.total||Math.max(f.loaded,Math.round(L*a.maxBitrate/8)),p=Math.max(1,f.bwEstimate?f.bwEstimate/8:f.loaded*1e3/g),b=(x-f.loaded)/p,M=m.currentTime,G=(j.BufferHelper.bufferInfo(m,M,E.maxBufferHole).end-M)/d;if(G>=2*L/d||b<=G)return;var Z=Number.POSITIVE_INFINITY,ie;for(ie=u.level-1;ie>h;ie--){var z=c[ie].maxBitrate;if(Z=L*z/(8*.8*p),Z<G)break}if(Z>=b)return;var F=this.bwEstimator.getEstimate();O.logger.warn("Fragment "+u.sn+(o?" part "+o.index:"")+" of level "+u.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+ie+`
Current BW estimate: `+(Object($.isFiniteNumber)(F)?(F/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+b.toFixed(3)+` s
Estimated load time for the next fragment: `+Z.toFixed(3)+` s
Time to underbuffer: `+G.toFixed(3)+" s"),s.nextLoadLevel=ie,this.bwEstimator.sample(g,f.loaded),this.clearTimer(),u.loader&&(this.fragCurrent=this.partCurrent=null,u.loader.abort()),s.trigger(D.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:u,part:o,stats:f})},C.onFragLoaded=function(u,o){var s=o.frag,l=o.part;if(s.type===P.PlaylistLevelType.MAIN&&Object($.isFiniteNumber)(s.sn)){var E=l?l.stats:s.stats,m=l?l.duration:s.duration;if(this.clearTimer(),this.lastLoadedFragLevel=s.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var f=this.hls.levels[s.level],L=(f.loaded?f.loaded.bytes:0)+E.loaded,g=(f.loaded?f.loaded.duration:0)+m;f.loaded={bytes:L,duration:g},f.realBitrate=Math.round(8*L/g)}if(s.bitrateTest){var d={stats:E,frag:s,part:l,id:s.type};this.onFragBuffered(D.Events.FRAG_BUFFERED,d),s.bitrateTest=!1}}},C.onFragBuffered=function(u,o){var s=o.frag,l=o.part,E=l?l.stats:s.stats;if(E.aborted)return;if(s.type!==P.PlaylistLevelType.MAIN||s.sn==="initSegment")return;var m=E.parsing.end-E.loading.start;this.bwEstimator.sample(m,E.loaded),E.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=m/1e3:this.bitrateTestDelay=0},C.onError=function(u,o){switch(o.details){case U.ErrorDetails.FRAG_LOAD_ERROR:case U.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},C.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},C.getNextABRAutoLevel=function(){var u=this.fragCurrent,o=this.partCurrent,s=this.hls,l=s.maxAutoLevel,E=s.config,m=s.minAutoLevel,f=s.media,L=o?o.duration:u?u.duration:0,g=f?f.currentTime:0,d=f&&f.playbackRate!==0?Math.abs(f.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():E.abrEwmaDefaultEstimate,h=(j.BufferHelper.bufferInfo(f,g,E.maxBufferHole).end-g)/d,a=this.findBestLevel(c,m,l,h,E.abrBandWidthFactor,E.abrBandWidthUpFactor);if(a>=0)return a;O.logger.trace((h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var x=L?Math.min(L,E.maxStarvationDelay):E.maxStarvationDelay,p=E.abrBandWidthFactor,b=E.abrBandWidthUpFactor;if(!h){var M=this.bitrateTestDelay;if(M){var G=L?Math.min(L,E.maxLoadingDelay):E.maxLoadingDelay;x=G-M,O.logger.trace("bitrate test took "+Math.round(1e3*M)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*x)+" ms"),p=b=1}}return a=this.findBestLevel(c,m,l,h+x,p,b),Math.max(a,0)},C.findBestLevel=function(u,o,s,l,E,m){for(var f,L=this.fragCurrent,g=this.partCurrent,d=this.lastLoadedFragLevel,c=this.hls.levels,h=c[d],a=!!(h!=null&&(f=h.details)!==null&&f!==void 0&&f.live),x=h==null?void 0:h.codecSet,p=g?g.duration:L?L.duration:0,b=s;b>=o;b--){var M=c[b];if(!M||x&&M.codecSet!==x)continue;var G=M.details,Z=(g?G==null?void 0:G.partTarget:G==null?void 0:G.averagetargetduration)||p,ie=void 0;b<=d?ie=E*u:ie=m*u;var z=c[b].maxBitrate,F=z*Z/ie;if(O.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+b+"/"+Math.round(ie)+"/"+z+"/"+Z+"/"+l+"/"+F),ie>z&&(!F||a&&!this.bitrateTestDelay||F<l))return b}return-1},T(A,[{key:"nextAutoLevel",get:function(){var u=this._nextAutoLevel,o=this.bwEstimator;if(u!==-1&&(!o||!o.canEstimate()))return u;var s=this.getNextABRAutoLevel();return u!==-1&&(s=Math.min(u,s)),s},set:function(u){this._nextAutoLevel=u}}]),A}();J.default=R},"./src/controller/audio-stream-controller.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/polyfills/number.ts"),I=_("./src/controller/base-stream-controller.ts"),D=_("./src/events.ts"),j=_("./src/utils/buffer-helper.ts"),U=_("./src/controller/fragment-tracker.ts"),P=_("./src/types/level.ts"),O=_("./src/types/loader.ts"),v=_("./src/loader/fragment.ts"),T=_("./src/demux/chunk-cache.ts"),R=_("./src/demux/transmuxer-interface.ts"),A=_("./src/types/transmuxer.ts"),C=_("./src/controller/fragment-finders.ts"),S=_("./src/utils/discontinuities.ts"),u=_("./src/errors.ts"),o=_("./src/utils/logger.ts");function s(){return s=Object.assign||function(L){for(var g=1;g<arguments.length;g++){var d=arguments[g];for(var c in d)Object.prototype.hasOwnProperty.call(d,c)&&(L[c]=d[c])}return L},s.apply(this,arguments)}function l(L,g){L.prototype=Object.create(g.prototype),L.prototype.constructor=L,E(L,g)}function E(L,g){return E=Object.setPrototypeOf||function(c,h){return c.__proto__=h,c},E(L,g)}var m=100,f=function(L){l(g,L);function g(c,h){var a;return a=L.call(this,c,h,"[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 d=g.prototype;return d.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},d._registerListeners=function(){var h=this.hls;h.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.on(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.on(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(D.Events.ERROR,this.onError,this),h.on(D.Events.BUFFER_RESET,this.onBufferReset,this),h.on(D.Events.BUFFER_CREATED,this.onBufferCreated,this),h.on(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.on(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d._unregisterListeners=function(){var h=this.hls;h.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(D.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.off(D.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.off(D.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(D.Events.ERROR,this.onError,this),h.off(D.Events.BUFFER_RESET,this.onBufferReset,this),h.off(D.Events.BUFFER_CREATED,this.onBufferCreated,this),h.off(D.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(D.Events.FRAG_BUFFERED,this.onFragBuffered,this)},d.onInitPtsFound=function(h,a){var x=a.frag,p=a.id,b=a.initPTS;if(p==="main"){var M=x.cc;this.initPTS[x.cc]=b,this.log("InitPTS for cc: "+M+" found from main: "+b),this.videoTrackCC=M,this.state===I.State.WAITING_INIT_PTS&&this.tick()}},d.startLoad=function(h){if(!this.levels){this.startPosition=h,this.state=I.State.STOPPED;return}var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(m),this.fragLoadError=0,a>0&&h===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),this.state=I.State.IDLE):(this.loadedmetadata=!1,this.state=I.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=h,this.tick()},d.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_TRACK:{var h,a=this.levels,x=this.trackId,p=a==null||((h=a[x])===null||h===void 0)?void 0:h.details;if(p){if(this.waitForCdnTuneIn(p))break;this.state=I.State.WAITING_INIT_PTS}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var b,M=performance.now(),G=this.retryDate;(!G||M>=G||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=I.State.IDLE);break}case I.State.WAITING_INIT_PTS:{var Z=this.waitingData;if(Z){var ie=Z.frag,z=Z.part,F=Z.cache,ne=Z.complete;if(this.initPTS[ie.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.FRAG_LOADING;var ce=F.flush(),ge={frag:ie,part:z,payload:ce,networkDetails:null};this._handleFragmentLoadProgress(ge),ne&&L.prototype._handleFragmentLoadComplete.call(this,ge)}else if(this.videoTrackCC!==this.waitingVideoCC)o.logger.log("Waiting fragment cc ("+ie.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var xe=this.getLoadPosition(),Me=j.BufferHelper.bufferInfo(this.mediaBuffer,xe,this.config.maxBufferHole),Te=Object(C.fragmentWithinToleranceTest)(Me.end,this.config.maxFragLookUpTolerance,ie);Te<0&&(o.logger.log("Waiting fragment cc ("+ie.cc+") @ "+ie.start+" cancelled because another fragment at "+Me.end+" is needed"),this.clearWaitingFragment())}}else this.state=I.State.IDLE}}this.onTickEnd()},d.clearWaitingFragment=function(){var h=this.waitingData;h&&(this.fragmentTracker.removeFragment(h.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.IDLE)},d.onTickEnd=function(){var h=this.media;if(!h||!h.readyState)return;var a=this.mediaBuffer?this.mediaBuffer:h,x=a.buffered;!this.loadedmetadata&&x.length&&(this.loadedmetadata=!0),this.lastCurrentTime=h.currentTime},d.doTickIdle=function(){var h,a,x=this.hls,p=this.levels,b=this.media,M=this.trackId,G=x.config;if(!p||!p[M])return;if(!b&&(this.startFragRequested||!G.startFragPrefetch))return;var Z=p[M],ie=Z.details;if(!ie||ie.live&&this.levelLastLoaded!==M||this.waitForCdnTuneIn(ie)){this.state=I.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,v.ElementaryStreamTypes.AUDIO,O.PlaylistLevelType.AUDIO));var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,O.PlaylistLevelType.AUDIO);if(z===null)return;var F=z.len,ne=this.getMaxBufferLength(),ce=this.audioSwitch;if(F>=ne&&!ce)return;if(!ce&&this._streamEnded(z,ie)){x.trigger(D.Events.BUFFER_EOS,{type:"audio"}),this.state=I.State.ENDED;return}var ge=ie.fragments,xe=ge[0].start,Me=z.end;if(ce){var Te=this.getLoadPosition();Me=Te,ie.PTSKnown&&Te<xe&&((z.end>xe||z.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),b.currentTime=xe+.05))}var Oe=this.getNextFragment(Me,ie);if(!Oe){this.bufferFlushed=!0;return}((h=Oe.decryptdata)===null||h===void 0?void 0:h.keyFormat)==="identity"&&!((a=Oe.decryptdata)!==null&&a!==void 0&&a.key)?this.loadKey(Oe,ie):this.loadFragment(Oe,ie,Me)},d.getMaxBufferLength=function(){var h=L.prototype.getMaxBufferLength.call(this),a=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,O.PlaylistLevelType.MAIN);return a===null?h:Math.max(h,a.len)},d.onMediaDetaching=function(){this.videoBuffer=null,L.prototype.onMediaDetaching.call(this)},d.onAudioTracksUpdated=function(h,a){var x=a.audioTracks;this.resetTransmuxer(),this.levels=x.map(function(p){return new P.Level(p)})},d.onAudioTrackSwitching=function(h,a){var x=!!a.url;this.trackId=a.id;var p=this.fragCurrent;p!=null&&p.loader&&p.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),x?this.setInterval(m):this.resetTransmuxer(),x?(this.audioSwitch=!0,this.state=I.State.IDLE):this.state=I.State.STOPPED,this.tick()},d.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},d.onLevelLoaded=function(h,a){this.mainDetails=a.details},d.onAudioTrackLoaded=function(h,a){var x,p=this.levels,b=a.details,M=a.id;if(!p){this.warn("Audio tracks were reset while loading level "+M);return}this.log("Track "+M+" loaded ["+b.startSN+","+b.endSN+"],duration:"+b.totalduration);var G=p[M],Z=0;if(b.live||(x=G.details)!==null&&x!==void 0&&x.live){var ie=this.mainDetails;if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed||!ie)return;!G.details&&b.hasProgramDateTime&&ie.hasProgramDateTime?(Object(S.alignMediaPlaylistByPDT)(b,ie),Z=b.fragments[0].start):Z=this.alignPlaylists(b,G.details)}G.details=b,this.levelLastLoaded=M,!this.startFragRequested&&(this.mainDetails||!b.live)&&this.setStartPosition(G.details,Z),this.state===I.State.WAITING_TRACK&&!this.waitForCdnTuneIn(b)&&(this.state=I.State.IDLE),this.tick()},d._handleFragmentLoadProgress=function(h){var a,x=h.frag,p=h.part,b=h.payload,M=this.config,G=this.trackId,Z=this.levels;if(!Z){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+x.sn+" of level "+x.level+" will not be buffered");return}var ie=Z[G];console.assert(ie,"Audio track is defined on fragment load progress");var z=ie.details;console.assert(z,"Audio track details are defined on fragment load progress");var F=M.defaultAudioCodec||ie.audioCodec||"mp4a.40.2",ne=this.transmuxer;ne||(ne=this.transmuxer=new R.default(this.hls,O.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var ce=this.initPTS[x.cc],ge=(a=x.initSegment)===null||a===void 0?void 0:a.data;if(ce!==void 0){var xe=!1,Me=p?p.index:-1,Te=Me!==-1,Oe=new A.ChunkMetadata(x.level,x.sn,x.stats.chunkCount,b.byteLength,Me,Te);ne.push(b,ge,F,"",x,p,z.totalduration,xe,Oe,ce)}else{o.logger.log("Unknown video PTS for cc "+x.cc+", waiting for video PTS before demuxing audio frag "+x.sn+" of ["+z.startSN+" ,"+z.endSN+"],track "+G);var Ce=this.waitingData=this.waitingData||{frag:x,part:p,cache:new T.default,complete:!1},we=Ce.cache;we.push(new Uint8Array(b)),this.waitingVideoCC=this.videoTrackCC,this.state=I.State.WAITING_INIT_PTS}},d._handleFragmentLoadComplete=function(h){if(this.waitingData){this.waitingData.complete=!0;return}L.prototype._handleFragmentLoadComplete.call(this,h)},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(h,a){var x=a.tracks.audio;x&&(this.mediaBuffer=x.buffer),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer)},d.onFragBuffered=function(h,a){var x=a.frag,p=a.part;if(x.type!==O.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(x)){this.warn("Fragment "+x.sn+(p?" p: "+p.index:"")+" of level "+x.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}x.sn!=="initSegment"&&(this.fragPrevious=x,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(x,p)},d.onError=function(h,a){switch(a.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.AUDIO,a);break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==I.State.ERROR&&this.state!==I.State.STOPPED&&(this.state=a.fatal?I.State.ERROR:I.State.IDLE,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var x=!0,p=this.getFwdBufferInfo(this.mediaBuffer,O.PlaylistLevelType.AUDIO);p&&p.len>.5&&(x=!this.reduceMaxBufferLength(p.len)),x&&(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}},d.onBufferFlushed=function(h,a){var x=a.type;x===v.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},d._handleTransmuxComplete=function(h){var a,x="audio",p=this.hls,b=h.remuxResult,M=h.chunkMeta,G=this.getCurrentContext(M);if(!G){this.warn("The loading context changed while buffering fragment "+M.sn+" of level "+M.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(M.level);return}var Z=G.frag,ie=G.part,z=b.audio,F=b.text,ne=b.id3,ce=b.initSegment;if(this.fragContextChanged(Z))return;if(this.state=I.State.PARSING,this.audioSwitch&&z&&this.completeAudioSwitch(),ce!=null&&ce.tracks&&(this._bufferInitSegment(ce.tracks,Z,M),p.trigger(D.Events.FRAG_PARSING_INIT_SEGMENT,{frag:Z,id:x,tracks:ce.tracks})),z){var ge=z.startPTS,xe=z.endPTS,Me=z.startDTS,Te=z.endDTS;ie&&(ie.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:ge,endPTS:xe,startDTS:Me,endDTS:Te}),Z.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,ge,xe,Me,Te),this.bufferFragmentData(z,Z,ie,M)}if(ne!=null&&(a=ne.samples)!==null&&a!==void 0&&a.length){var Oe=s({frag:Z,id:x},ne);p.trigger(D.Events.FRAG_PARSING_METADATA,Oe)}if(F){var Ce=s({frag:Z,id:x},F);p.trigger(D.Events.FRAG_PARSING_USERDATA,Ce)}},d._bufferInitSegment=function(h,a,x){if(this.state!==I.State.PARSING)return;h.video&&delete h.video;var p=h.audio;if(!p)return;p.levelCodec=p.codec,p.id="audio",this.log("Init audio buffer, container:"+p.container+", codecs[parsed]=["+p.codec+"]"),this.hls.trigger(D.Events.BUFFER_CODECS,h);var b=p.initSegment;if(b!=null&&b.byteLength){var M={type:"audio",frag:a,part:null,chunkMeta:x,parent:a.type,data:b};this.hls.trigger(D.Events.BUFFER_APPENDING,M)}this.tick()},d.loadFragment=function(h,a,x){var p=this.fragmentTracker.getState(h);this.fragCurrent=h,(this.audioSwitch||p===U.FragmentState.NOT_LOADED||p===U.FragmentState.PARTIAL)&&(h.sn==="initSegment"?this._loadInitSegment(h):a.live&&!Object($.isFiniteNumber)(this.initPTS[h.cc])?(this.log("Waiting for video PTS in continuity counter "+h.cc+" of live stream before loading audio fragment "+h.sn+" of level "+this.trackId),this.state=I.State.WAITING_INIT_PTS):(this.startFragRequested=!0,L.prototype.loadFragment.call(this,h,a,x)))},d.completeAudioSwitch=function(){var h=this.hls,a=this.media,x=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),L.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,h.trigger(D.Events.AUDIO_TRACK_SWITCHED,{id:x})},g}(I.default);J.default=f},"./src/controller/audio-track-controller.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/events.ts"),I=_("./src/errors.ts"),D=_("./src/controller/base-playlist-controller.ts"),j=_("./src/types/loader.ts");function U(R,A){for(var C=0;C<A.length;C++){var S=A[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(R,S.key,S)}}function P(R,A,C){return A&&U(R.prototype,A),C&&U(R,C),R}function O(R,A){R.prototype=Object.create(A.prototype),R.prototype.constructor=R,v(R,A)}function v(R,A){return v=Object.setPrototypeOf||function(S,u){return S.__proto__=u,S},v(R,A)}var T=function(R){O(A,R);function A(S){var u;return u=R.call(this,S,"[audio-track-controller]")||this,u.tracks=[],u.groupId=null,u.tracksInGroup=[],u.trackId=-1,u.trackName="",u.selectDefaultTrack=!0,u.registerListeners(),u}var C=A.prototype;return C.registerListeners=function(){var u=this.hls;u.on($.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on($.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on($.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on($.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.on($.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on($.Events.ERROR,this.onError,this)},C.unregisterListeners=function(){var u=this.hls;u.off($.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off($.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off($.Events.LEVEL_LOADING,this.onLevelLoading,this),u.off($.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),u.off($.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off($.Events.ERROR,this.onError,this)},C.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,R.prototype.destroy.call(this)},C.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},C.onManifestParsed=function(u,o){this.tracks=o.audioTracks||[]},C.onAudioTrackLoaded=function(u,o){var s=o.id,l=o.details,E=this.tracksInGroup[s];if(!E){this.warn("Invalid audio track id "+s);return}var m=E.details;E.details=o.details,this.log("audioTrack "+s+" loaded ["+l.startSN+"-"+l.endSN+"]"),s===this.trackId&&(this.retryCount=0,this.playlistLoaded(s,o,m))},C.onLevelLoading=function(u,o){this.switchLevel(o.level)},C.onLevelSwitching=function(u,o){this.switchLevel(o.level)},C.switchLevel=function(u){var o=this.hls.levels[u];if(!(o!=null&&o.audioGroupIds))return;var s=o.audioGroupIds[o.urlId];if(this.groupId!==s){this.groupId=s;var l=this.tracks.filter(function(m){return!s||m.groupId===s});this.selectDefaultTrack&&!l.some(function(m){return m.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=l;var E={audioTracks:l};this.log("Updating audio tracks, "+l.length+' track(s) found in "'+s+'" group-id'),this.hls.trigger($.Events.AUDIO_TRACKS_UPDATED,E),this.selectInitialTrack()}},C.onError=function(u,o){if(R.prototype.onError.call(this,u,o),o.fatal||!o.context)return;o.context.type===j.PlaylistContextType.AUDIO_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},C.setAudioTrack=function(u){var o=this.tracksInGroup;if(u<0||u>=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 "+u);var l=o[u],E=l.id,m=l.groupId,f=m===void 0?"":m,L=l.name,g=l.type,d=l.url;if(this.trackId=u,this.trackName=L,this.selectDefaultTrack=!1,this.hls.trigger($.Events.AUDIO_TRACK_SWITCHING,{id:E,groupId:f,name:L,type:g,url:d}),l.details&&!l.details.live)return;var c=this.switchParams(l.url,s==null?void 0:s.details);this.loadPlaylist(c)},C.selectInitialTrack=function(){var u=this.tracksInGroup;console.assert(u.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($.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},C.findTrackId=function(u){for(var o=this.tracksInGroup,s=0;s<o.length;s++){var l=o[s];if((!this.selectDefaultTrack||l.default)&&(!u||u===l.name))return l.id}return-1},C.loadPlaylist=function(u){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var s=o.id,l=o.groupId,E=o.url;if(u)try{E=u.addDirectives(E)}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($.Events.AUDIO_TRACK_LOADING,{url:E,id:s,groupId:l,deliveryDirectives:u||null})}},P(A,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(u){this.selectDefaultTrack=!1,this.setAudioTrack(u)}}]),A}(D.default);J.default=T},"./src/controller/base-playlist-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return P});var $=_("./src/polyfills/number.ts"),I=_("./src/types/level.ts"),D=_("./src/controller/level-helper.ts"),j=_("./src/utils/logger.ts"),U=_("./src/errors.ts"),P=function(){function O(T,R){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=j.logger.log.bind(j.logger,R+":"),this.warn=j.logger.warn.bind(j.logger,R+":"),this.hls=T}var v=O.prototype;return v.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},v.onError=function(R,A){A.fatal&&A.type===U.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(R,A){var C=A==null?void 0:A.renditionReports;if(C)for(var S=0;S<C.length;S++){var u=C[S],o=""+u.URI;if(o===R.substr(-o.length)){var s=parseInt(u["LAST-MSN"]),l=parseInt(u["LAST-PART"]);if(A&&this.hls.config.lowLatencyMode){var E=Math.min(A.age-A.partTarget,A.targetduration);l!==void 0&&E>A.partTarget&&(l+=1)}if(Object($.isFiniteNumber)(s))return new I.HlsUrlParameters(s,Object($.isFiniteNumber)(l)?l:void 0,I.HlsSkip.No)}}},v.loadPlaylist=function(R){},v.shouldLoadTrack=function(R){return this.canLoad&&R&&!!R.url&&(!R.details||R.details.live)},v.playlistLoaded=function(R,A,C){var S=this,u=A.details,o=A.stats,s=o.loading.end?Math.max(0,self.performance.now()-o.loading.end):0;if(u.advancedDateTime=Date.now()-s,u.live||C!=null&&C.live){if(u.reloaded(C),C&&this.log("live playlist "+R+" "+(u.advanced?"REFRESHED "+u.lastPartSn+"-"+u.lastPartIndex:"MISSED")),C&&u.fragments.length>0&&Object(D.mergeDetails)(C,u),!this.canLoad||!u.live)return;var l,E=void 0,m=void 0;if(u.canBlockReload&&u.endSN&&u.advanced){var f=this.hls.config.lowLatencyMode,L=u.lastPartSn,g=u.endSN,d=u.lastPartIndex,c=d!==-1,h=L===g,a=f?0:d;c?(E=h?g+1:L,m=h?a:d+1):E=g+1;var x=u.age,p=x+u.ageHeader,b=Math.min(p-u.partTarget,u.targetduration*1.5);if(b>0){if(C&&b>C.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+C.tuneInGoal+" to: "+b+" with playlist age: "+u.age),b=0;else{var M=Math.floor(b/u.targetduration);if(E+=M,m!==void 0){var G=Math.round(b%u.targetduration/u.partTarget);m+=G}this.log("CDN Tune-in age: "+u.ageHeader+"s last advanced "+x.toFixed(2)+"s goal: "+b+" skip sn "+M+" to part "+m)}u.tuneInGoal=b}if(l=this.getDeliveryDirectives(u,A.deliveryDirectives,E,m),f||!h){this.loadPlaylist(l);return}}else l=this.getDeliveryDirectives(u,A.deliveryDirectives,E,m);var Z=Object(D.computeReloadInterval)(u,o);E!==void 0&&u.canBlockReload&&(Z-=u.partTarget||1),this.log("reload live playlist "+R+" in "+Math.round(Z)+" ms"),this.timer=self.setTimeout(function(){return S.loadPlaylist(l)},Z)}else this.clearTimer()},v.getDeliveryDirectives=function(R,A,C,S){var u=Object(I.getSkipValue)(R,C);return A!=null&&A.skip&&R.deltaUpdateFailed&&(C=A.msn,S=A.part,u=I.HlsSkip.No),new I.HlsUrlParameters(C,S,u)},v.retryLoadingOrFail=function(R){var A=this,C=this.hls.config,S=this.retryCount<C.levelLoadingMaxRetry;if(S){var u;if(this.retryCount++,R.details.indexOf("LoadTimeOut")>-1&&(u=R.context)!==null&&u!==void 0&&u.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+R.details+'"'),this.loadPlaylist();else{var o=Math.min(Math.pow(2,this.retryCount)*C.levelLoadingRetryDelay,C.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return A.loadPlaylist()},o),this.warn("retry playlist loading #"+this.retryCount+" in "+o+' ms after "'+R.details+'"')}}else this.warn('cannot recover from error "'+R.details+'"'),this.clearTimer(),R.fatal=!0;return S},O}()},"./src/controller/base-stream-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"State",function(){return g}),_.d(J,"default",function(){return d});var $=_("./src/polyfills/number.ts"),I=_("./src/task-loop.ts"),D=_("./src/controller/fragment-tracker.ts"),j=_("./src/utils/buffer-helper.ts"),U=_("./src/utils/logger.ts"),P=_("./src/events.ts"),O=_("./src/errors.ts"),v=_("./src/types/transmuxer.ts"),T=_("./src/utils/mp4-tools.ts"),R=_("./src/utils/discontinuities.ts"),A=_("./src/controller/fragment-finders.ts"),C=_("./src/controller/level-helper.ts"),S=_("./src/loader/fragment-loader.ts"),u=_("./src/crypt/decrypter.ts"),o=_("./src/utils/time-ranges.ts"),s=_("./src/types/loader.ts");function l(c,h){for(var a=0;a<h.length;a++){var x=h[a];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(c,x.key,x)}}function E(c,h,a){return h&&l(c.prototype,h),a&&l(c,a),c}function m(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function f(c,h){c.prototype=Object.create(h.prototype),c.prototype.constructor=c,L(c,h)}function L(c,h){return L=Object.setPrototypeOf||function(x,p){return x.__proto__=p,x},L(c,h)}var g={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"},d=function(c){f(h,c);function h(x,p,b){var M;return M=c.call(this)||this,M.hls=void 0,M.fragPrevious=null,M.fragCurrent=null,M.fragmentTracker=void 0,M.transmuxer=null,M._state=g.STOPPED,M.media=void 0,M.mediaBuffer=void 0,M.config=void 0,M.bitrateTest=!1,M.lastCurrentTime=0,M.nextLoadPosition=0,M.startPosition=0,M.loadedmetadata=!1,M.fragLoadError=0,M.retryDate=0,M.levels=null,M.fragmentLoader=void 0,M.levelLastLoaded=null,M.startFragRequested=!1,M.decrypter=void 0,M.initPTS=[],M.onvseeking=null,M.onvended=null,M.logPrefix="",M.log=void 0,M.warn=void 0,M.logPrefix=b,M.log=U.logger.log.bind(U.logger,b+":"),M.warn=U.logger.warn.bind(U.logger,b+":"),M.hls=x,M.fragmentLoader=new S.default(x.config),M.fragmentTracker=p,M.config=x.config,M.decrypter=new u.default(x,x.config),x.on(P.Events.KEY_LOADED,M.onKeyLoaded,m(M)),M}var a=h.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(p){},a.stopLoad=function(){this.fragmentLoader.abort();var p=this.fragCurrent;p&&this.fragmentTracker.removeFragment(p),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=g.STOPPED},a._streamEnded=function(p,b){var M=this.fragCurrent,G=this.fragmentTracker;if(!b.live&&M&&M.sn===b.endSN&&!p.nextStart){var Z=G.getState(M);return Z===D.FragmentState.PARTIAL||Z===D.FragmentState.OK}return!1},a.onMediaAttached=function(p,b){var M=this.media=this.mediaBuffer=b.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),M.addEventListener("seeking",this.onvseeking),M.addEventListener("ended",this.onvended);var G=this.config;this.levels&&G.autoStartLoad&&this.state===g.STOPPED&&this.startLoad(G.startPosition)},a.onMediaDetaching=function(){var p=this.media;p!=null&&p.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),p&&(p.removeEventListener("seeking",this.onvseeking),p.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 p=this.config,b=this.fragCurrent,M=this.media,G=this.mediaBuffer,Z=this.state,ie=M?M.currentTime:0,z=j.BufferHelper.bufferInfo(G||M,ie,p.maxBufferHole);if(this.log("media seeking to "+(Object($.isFiniteNumber)(ie)?ie.toFixed(3):ie)+", state: "+Z),Z===g.ENDED)this.resetLoadingState();else if(b&&!z.len){var F=p.maxFragLookUpTolerance,ne=b.start-F,ce=b.start+b.duration+F,ge=ie>ce;(ie<ne||ge)&&(ge&&b.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),b.loader.abort()),this.resetLoadingState())}M&&(this.lastCurrentTime=ie),!this.loadedmetadata&&!z.len&&(this.nextLoadPosition=this.startPosition=ie),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onKeyLoaded=function(p,b){if(this.state!==g.KEY_LOADING||b.frag!==this.fragCurrent||!this.levels)return;this.state=g.IDLE;var M=this.levels[b.frag.level].details;M&&this.loadFragment(b.frag,M,b.frag.start)},a.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=g.STOPPED,this.hls.off(P.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,c.prototype.onHandlerDestroyed.call(this)},a.loadKey=function(p,b){this.log("Loading key for "+p.sn+" of ["+b.startSN+"-"+b.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+p.level),this.state=g.KEY_LOADING,this.fragCurrent=p,this.hls.trigger(P.Events.KEY_LOADING,{frag:p})},a.loadFragment=function(p,b,M){this._loadFragForPlayback(p,b,M)},a._loadFragForPlayback=function(p,b,M){var G=this,Z=function(z){if(G.fragContextChanged(p)){G.warn("Fragment "+p.sn+(z.part?" p: "+z.part.index:"")+" of level "+p.level+" was dropped during download."),G.fragmentTracker.removeFragment(p);return}p.stats.chunkCount++,G._handleFragmentLoadProgress(z)};this._doFragLoad(p,b,M,Z).then(function(ie){if(!ie)return;G.fragLoadError=0;var z=G.state;if(G.fragContextChanged(p)){(z===g.FRAG_LOADING||z===g.BACKTRACKING||!G.fragCurrent&&z===g.PARSING)&&(G.fragmentTracker.removeFragment(p),G.state=g.IDLE);return}if("payload"in ie&&(G.log("Loaded fragment "+p.sn+" of level "+p.level),G.hls.trigger(P.Events.FRAG_LOADED,ie),G.state===g.BACKTRACKING)){G.fragmentTracker.backtrack(p,ie),G.resetFragmentLoading(p);return}G._handleFragmentLoadComplete(ie)}).catch(function(ie){G.warn(ie),G.resetFragmentLoading(p)})},a.flushMainBuffer=function(p,b,M){if(M===void 0&&(M=null),!(p-b))return;var G={startOffset:p,endOffset:b,type:M};this.fragLoadError=0,this.hls.trigger(P.Events.BUFFER_FLUSHING,G)},a._loadInitSegment=function(p){var b=this;this._doFragLoad(p).then(function(M){if(!M||b.fragContextChanged(p)||!b.levels)throw new Error("init load aborted");return M}).then(function(M){var G=b.hls,Z=M.payload,ie=p.decryptdata;if(Z&&Z.byteLength>0&&ie&&ie.key&&ie.iv&&ie.method==="AES-128"){var z=self.performance.now();return b.decrypter.webCryptoDecrypt(new Uint8Array(Z),ie.key.buffer,ie.iv.buffer).then(function(F){var ne=self.performance.now();return G.trigger(P.Events.FRAG_DECRYPTED,{frag:p,payload:F,stats:{tstart:z,tdecrypt:ne}}),M.payload=F,M})}return M}).then(function(M){var G=b.fragCurrent,Z=b.hls,ie=b.levels;if(!ie)throw new Error("init load aborted, missing levels");var z=ie[p.level].details;console.assert(z,"Level details are defined when init segment is loaded");var F=p.stats;b.state=g.IDLE,b.fragLoadError=0,p.data=new Uint8Array(M.payload),F.parsing.start=F.buffering.start=self.performance.now(),F.parsing.end=F.buffering.end=self.performance.now(),M.frag===G&&Z.trigger(P.Events.FRAG_BUFFERED,{stats:F,frag:G,part:null,id:p.type}),b.tick()}).catch(function(M){b.warn(M),b.resetFragmentLoading(p)})},a.fragContextChanged=function(p){var b=this.fragCurrent;return!p||!b||p.level!==b.level||p.sn!==b.sn||p.urlId!==b.urlId},a.fragBufferedComplete=function(p,b){var M=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+p.type+" sn: "+p.sn+(b?" part: "+b.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+p.level+" "+o.default.toString(j.BufferHelper.getBuffered(M))),this.state=g.IDLE,this.tick()},a._handleFragmentLoadComplete=function(p){var b=this.transmuxer;if(!b)return;var M=p.frag,G=p.part,Z=p.partsLoaded,ie=!Z||Z.length===0||Z.some(function(F){return!F}),z=new v.ChunkMetadata(M.level,M.sn,M.stats.chunkCount+1,0,G?G.index:-1,!ie);b.flush(z)},a._handleFragmentLoadProgress=function(p){},a._doFragLoad=function(p,b,M,G){var Z=this;if(M===void 0&&(M=null),!this.levels)throw new Error("frag load aborted, missing levels");if(M=Math.max(p.start,M||0),this.config.lowLatencyMode&&b){var ie=b.partList;if(ie&&G){M>p.end&&b.fragmentHint&&(p=b.fragmentHint);var z=this.getNextPart(ie,p,M);if(z>-1){var F=ie[z];return this.log("Loading part sn: "+p.sn+" p: "+F.index+" cc: "+p.cc+" of playlist ["+b.startSN+"-"+b.endSN+"] parts [0-"+z+"-"+(ie.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+p.level+", target: "+parseFloat(M.toFixed(3))),this.nextLoadPosition=F.start+F.duration,this.state=g.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:p,part:ie[z],targetBufferTime:M}),this.doFragPartsLoad(p,ie,z,G).catch(function(ne){return Z.handleFragLoadError(ne)})}else if(!p.url||this.loadedEndOfParts(ie,M))return Promise.resolve(null)}}return this.log("Loading fragment "+p.sn+" cc: "+p.cc+" "+(b?"of ["+b.startSN+"-"+b.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+p.level+", target: "+parseFloat(M.toFixed(3))),Object($.isFiniteNumber)(p.sn)&&!this.bitrateTest&&(this.nextLoadPosition=p.start+p.duration),this.state=g.FRAG_LOADING,this.hls.trigger(P.Events.FRAG_LOADING,{frag:p,targetBufferTime:M}),this.fragmentLoader.load(p,G).catch(function(ne){return Z.handleFragLoadError(ne)})},a.doFragPartsLoad=function(p,b,M,G){var Z=this;return new Promise(function(ie,z){var F=[],ne=function ce(ge){var xe=b[ge];Z.fragmentLoader.loadPart(p,xe,G).then(function(Me){F[xe.index]=Me;var Te=Me.part;Z.hls.trigger(P.Events.FRAG_LOADED,Me);var Oe=b[ge+1];if(Oe&&Oe.fragment===p)ce(ge+1);else return ie({frag:p,part:Te,partsLoaded:F})}).catch(z)};ne(M)})},a.handleFragLoadError=function(p){var b=p.data;return b&&b.details===O.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(b.frag,b.part):this.hls.trigger(P.Events.ERROR,b),null},a._handleTransmuxerFlush=function(p){var b=this.getCurrentContext(p);if(!b||this.state!==g.PARSING){this.fragCurrent||(this.state=g.IDLE);return}var M=b.frag,G=b.part,Z=b.level,ie=self.performance.now();M.stats.parsing.end=ie,G&&(G.stats.parsing.end=ie),this.updateLevelTiming(M,G,Z,p.partial)},a.getCurrentContext=function(p){var b=this.levels,M=p.level,G=p.sn,Z=p.part;if(!b||!b[M])return this.warn("Levels object was unset while buffering fragment "+G+" of level "+M+". The current chunk will not be buffered."),null;var ie=b[M],z=Z>-1?Object(C.getPartWith)(ie,G,Z):null,F=z?z.fragment:Object(C.getFragmentWithSN)(ie,G,this.fragCurrent);return F?{frag:F,part:z,level:ie}:null},a.bufferFragmentData=function(p,b,M,G){if(!p||this.state!==g.PARSING)return;var Z=p.data1,ie=p.data2,z=Z;if(Z&&ie&&(z=Object(T.appendUint8Array)(Z,ie)),!z||!z.length)return;var F={type:p.type,frag:b,part:M,chunkMeta:G,parent:b.type,data:z};this.hls.trigger(P.Events.BUFFER_APPENDING,F),p.dropped&&p.independent&&!M&&this.flushBufferGap(b)},a.flushBufferGap=function(p){var b=this.media;if(!b)return;if(!j.BufferHelper.isBuffered(b,b.currentTime)){this.flushMainBuffer(0,p.start);return}var M=b.currentTime,G=j.BufferHelper.bufferInfo(b,M,0),Z=p.duration,ie=Math.min(this.config.maxFragLookUpTolerance*2,Z*.25),z=Math.max(Math.min(p.start-ie,G.end-ie),M+ie);p.start-z>ie&&this.flushMainBuffer(z,p.start)},a.getFwdBufferInfo=function(p,b){var M=this.config,G=this.getLoadPosition();if(!Object($.isFiniteNumber)(G))return null;var Z=j.BufferHelper.bufferInfo(p,G,M.maxBufferHole);if(Z.len===0&&Z.nextStart!==void 0){var ie=this.fragmentTracker.getBufferedFrag(G,b);if(ie&&Z.nextStart<ie.end)return j.BufferHelper.bufferInfo(p,G,Math.max(Z.nextStart,M.maxBufferHole))}return Z},a.getMaxBufferLength=function(p){var b=this.config,M;return p?M=Math.max(8*b.maxBufferSize/p,b.maxBufferLength):M=b.maxBufferLength,Math.min(M,b.maxMaxBufferLength)},a.reduceMaxBufferLength=function(p){var b=this.config,M=p||b.maxBufferLength;return b.maxMaxBufferLength>=M?(b.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+b.maxMaxBufferLength+"s"),!0):!1},a.getNextFragment=function(p,b){var M,G,Z=b.fragments,ie=Z.length;if(!ie)return null;var z=this.config,F=Z[0].start,ne;if(b.live){var ce=z.initialLiveManifestSize;if(ie<ce)return this.warn("Not enough fragments to start playback (have: "+ie+", need: "+ce+")"),null;!b.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(ne=this.getInitialLiveFragment(b,Z),this.startPosition=ne?this.hls.liveSyncPosition||ne.start:p)}else p<=F&&(ne=Z[0]);if(!ne){var ge=z.lowLatencyMode?b.partEnd:b.fragmentEnd;ne=this.getFragmentAtPosition(p,ge,b)}return(M=ne)!==null&&M!==void 0&&M.initSegment&&!((G=ne)!==null&&G!==void 0&&G.initSegment.data)&&!this.bitrateTest&&(ne=ne.initSegment),ne},a.getNextPart=function(p,b,M){for(var G=-1,Z=!1,ie=!0,z=0,F=p.length;z<F;z++){var ne=p[z];if(ie=ie&&!ne.independent,G>-1&&M<ne.start)break;var ce=ne.loaded;!ce&&(Z||ne.independent||ie)&&ne.fragment===b&&(G=z),Z=ce}return G},a.loadedEndOfParts=function(p,b){var M=p[p.length-1];return M&&b>M.start&&M.loaded},a.getInitialLiveFragment=function(p,b){var M=this.fragPrevious,G=null;if(M){if(p.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+M.programDateTime),G=Object(A.findFragmentByPDT)(b,M.endProgramDateTime,this.config.maxFragLookUpTolerance)),!G){var Z=M.sn+1;if(Z>=p.startSN&&Z<=p.endSN){var ie=b[Z-p.startSN];M.cc===ie.cc&&(G=ie,this.log("Live playlist, switching playlist, load frag with next SN: "+G.sn))}G||(G=Object(A.findFragWithCC)(b,M.cc),G&&this.log("Live playlist, switching playlist, load frag with same CC: "+G.sn))}}else{var z=this.hls.liveSyncPosition;z!==null&&(G=this.getFragmentAtPosition(z,this.bitrateTest?p.fragmentEnd:p.edge,p))}return G},a.getFragmentAtPosition=function(p,b,M){var G=this.config,Z=this.fragPrevious,ie=M.fragments,z=M.endSN,F=M.fragmentHint,ne=G.maxFragLookUpTolerance,ce=!!(G.lowLatencyMode&&M.partList&&F);ce&&F&&!this.bitrateTest&&(ie=ie.concat(F),z=F.sn);var ge;if(p<b){var xe=p>b-ne?0:ne;ge=Object(A.findFragmentByPTS)(Z,ie,p,xe)}else ge=ie[ie.length-1];if(ge){var Me=ge.sn-M.startSN,Te=Z&&ge.level===Z.level,Oe=ie[Me+1],Ce=this.fragmentTracker.getState(ge);if(Ce===D.FragmentState.BACKTRACKED){ge=null;for(var we=Me;ie[we]&&this.fragmentTracker.getState(ie[we])===D.FragmentState.BACKTRACKED;)Z?ge=ie[we--]:ge=ie[--we];ge||(ge=Oe)}else Z&&ge.sn===Z.sn&&!ce&&(Te&&(ge.sn<z&&this.fragmentTracker.getState(Oe)!==D.FragmentState.OK?(this.log("SN "+ge.sn+" just loaded, load next one: "+Oe.sn),ge=Oe):ge=null))}return ge},a.synchronizeToLiveEdge=function(p){var b=this.config,M=this.media;if(!M)return;var G=this.hls.liveSyncPosition,Z=M.currentTime,ie=p.fragments[0].start,z=p.edge,F=Z>=ie-b.maxFragLookUpTolerance&&Z<=z;if(G!==null&&M.duration>G&&(Z<G||!F)){var ne=b.liveMaxLatencyDuration!==void 0?b.liveMaxLatencyDuration:b.liveMaxLatencyDurationCount*p.targetduration;(!F&&M.readyState<4||Z<z-ne)&&(this.loadedmetadata||(this.nextLoadPosition=G),M.readyState&&(this.warn("Playback: "+Z.toFixed(3)+" is located too far from the end of live sliding playlist: "+z+", reset currentTime to : "+G.toFixed(3)),M.currentTime=G))}},a.alignPlaylists=function(p,b){var M=this.levels,G=this.levelLastLoaded,Z=this.fragPrevious,ie=G!==null?M[G]:null,z=p.fragments.length;if(!z)return this.warn("No fragments in live playlist"),0;var F=p.fragments[0].start,ne=!b,ce=p.alignedSliding&&Object($.isFiniteNumber)(F);if(ne||!ce&&!F){Object(R.alignStream)(Z,ie,p);var ge=p.fragments[0].start;return this.log("Live playlist sliding: "+ge.toFixed(2)+" start-sn: "+(b?b.startSN:"na")+"->"+p.startSN+" prev-sn: "+(Z?Z.sn:"na")+" fragments: "+z),ge}return F},a.waitForCdnTuneIn=function(p){var b=3;return p.live&&p.canBlockReload&&p.tuneInGoal>Math.max(p.partHoldBack,p.partTarget*b)},a.setStartPosition=function(p,b){var M=this.startPosition;if(M<b&&(M=-1),M===-1||this.lastCurrentTime===-1){var G=p.startTimeOffset;Object($.isFiniteNumber)(G)?(M=b+G,G<0&&(M+=p.totalduration),M=Math.min(Math.max(b,M),b+p.totalduration),this.log("Start time offset "+G+" found in playlist, adjust startPosition to "+M),this.startPosition=M):p.live?M=this.hls.liveSyncPosition||b:this.startPosition=M=0,this.lastCurrentTime=M}this.nextLoadPosition=M},a.getLoadPosition=function(){var p=this.media,b=0;return this.loadedmetadata&&p?b=p.currentTime:this.nextLoadPosition&&(b=this.nextLoadPosition),b},a.handleFragLoadAborted=function(p,b){this.transmuxer&&p.sn!=="initSegment"&&p.stats.aborted&&(this.warn("Fragment "+p.sn+(b?" part"+b.index:"")+" of level "+p.level+" was aborted"),this.resetFragmentLoading(p))},a.resetFragmentLoading=function(p){(!this.fragCurrent||!this.fragContextChanged(p))&&(this.state=g.IDLE)},a.onFragmentOrKeyLoadError=function(p,b){if(b.fatal)return;var M=b.frag;if(!M||M.type!==p)return;var G=this.fragCurrent;console.assert(G&&M.sn===G.sn&&M.level===G.level&&M.urlId===G.urlId,"Frag load error must match current frag to retry");var Z=this.config;if(this.fragLoadError+1<=Z.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(M.level))return;var ie=Math.min(Math.pow(2,this.fragLoadError)*Z.fragLoadingRetryDelay,Z.fragLoadingMaxRetryTimeout);this.warn("Fragment "+M.sn+" of "+p+" "+M.level+" failed to load, retrying in "+ie+"ms"),this.retryDate=self.performance.now()+ie,this.fragLoadError++,this.state=g.FRAG_LOADING_WAITING_RETRY}else b.levelRetry?(p===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=g.IDLE):(U.logger.error(b.details+" reaches max retry, redispatch as fatal ..."),b.fatal=!0,this.hls.stopLoad(),this.state=g.ERROR)},a.afterBufferFlushed=function(p,b,M){if(!p)return;var G=j.BufferHelper.getBuffered(p);this.fragmentTracker.detectEvictedFragments(b,G,M),this.state===g.ENDED&&this.resetLoadingState()},a.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=g.IDLE},a.resetLiveStartWhenNotLoaded=function(p){if(!this.loadedmetadata){this.startFragRequested=!1;var b=this.levels?this.levels[p].details:null;if(b!=null&&b.live)return this.startPosition=-1,this.setStartPosition(b,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},a.updateLevelTiming=function(p,b,M,G){var Z=this,ie=M.details;console.assert(!!ie,"level.details must be defined");var z=Object.keys(p.elementaryStreams).reduce(function(F,ne){var ce=p.elementaryStreams[ne];if(ce){var ge=ce.endPTS-ce.startPTS;if(ge<=0)return Z.warn("Could not parse fragment "+p.sn+" "+ne+" duration reliably ("+ge+") resetting transmuxer to fallback to playlist timing"),Z.resetTransmuxer(),F||!1;var xe=G?0:Object(C.updateFragPTSDTS)(ie,p,ce.startPTS,ce.endPTS,ce.startDTS,ce.endDTS);return Z.hls.trigger(P.Events.LEVEL_PTS_UPDATED,{details:ie,level:M,drift:xe,type:ne,frag:p,start:ce.startPTS,end:ce.endPTS}),!0}return F},!1);z?(this.state=g.PARSED,this.hls.trigger(P.Events.FRAG_PARSED,{frag:p,part:b})):this.resetLoadingState()},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},E(h,[{key:"state",get:function(){return this._state},set:function(p){var b=this._state;b!==p&&(this._state=p,this.log(b+"->"+p))}}]),h}(I.default)},"./src/controller/buffer-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return A});var $=_("./src/polyfills/number.ts"),I=_("./src/events.ts"),D=_("./src/utils/logger.ts"),j=_("./src/errors.ts"),U=_("./src/utils/buffer-helper.ts"),P=_("./src/utils/mediasource-helper.ts"),O=_("./src/loader/fragment.ts"),v=_("./src/controller/buffer-operation-queue.ts"),T=Object(P.getMediaSource)(),R=/([ha]vc.)(?:\.[^.,]+)+/,A=function(){function C(u){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,l=o.media,E=o.mediaSource;D.logger.log("[buffer-controller]: Media source opened"),l&&(o.updateMediaElementDuration(),s.trigger(I.Events.MEDIA_ATTACHED,{media:l})),E&&E.removeEventListener("sourceopen",o._onMediaSourceOpen),o.checkPendingTracks()},this._onMediaSourceClose=function(){D.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){D.logger.log("[buffer-controller]: Media source ended")},this.hls=u,this._initSourceBuffer(),this.registerListeners()}var S=C.prototype;return S.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},S.destroy=function(){this.unregisterListeners(),this.details=null},S.registerListeners=function(){var o=this.hls;o.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on(I.Events.BUFFER_RESET,this.onBufferReset,this),o.on(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.on(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.on(I.Events.BUFFER_EOS,this.onBufferEos,this),o.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.on(I.Events.FRAG_PARSED,this.onFragParsed,this),o.on(I.Events.FRAG_CHANGED,this.onFragChanged,this)},S.unregisterListeners=function(){var o=this.hls;o.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),o.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off(I.Events.BUFFER_RESET,this.onBufferReset,this),o.off(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),o.off(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),o.off(I.Events.BUFFER_EOS,this.onBufferEos,this),o.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),o.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),o.off(I.Events.FRAG_PARSED,this.onFragParsed,this),o.off(I.Events.FRAG_CHANGED,this.onFragChanged,this)},S._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new v.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},S.onManifestParsed=function(o,s){var l=2;(s.audio&&!s.video||!s.altAudio)&&(l=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=l,this.details=null,D.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},S.onMediaAttaching=function(o,s){var l=this.media=s.media;if(l&&T){var E=this.mediaSource=new T;E.addEventListener("sourceopen",this._onMediaSourceOpen),E.addEventListener("sourceended",this._onMediaSourceEnded),E.addEventListener("sourceclose",this._onMediaSourceClose),l.src=self.URL.createObjectURL(E),this._objectUrl=l.src}},S.onMediaDetaching=function(){var o=this.media,s=this.mediaSource,l=this._objectUrl;if(s){if(D.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(E){D.logger.warn("[buffer-controller]: onMediaDetaching: "+E.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),o&&(l&&self.URL.revokeObjectURL(l),o.src===l?(o.removeAttribute("src"),o.load()):D.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(I.Events.MEDIA_DETACHED,void 0)},S.onBufferReset=function(){var o=this;this.getSourceBufferTypes().forEach(function(s){var l=o.sourceBuffer[s];try{l&&(o.removeBufferListeners(s),o.mediaSource&&o.mediaSource.removeSourceBuffer(l),o.sourceBuffer[s]=void 0)}catch(E){D.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",E)}}),this._initSourceBuffer()},S.onBufferCodecs=function(o,s){var l=this,E=this.getSourceBufferTypes().length;if(Object.keys(s).forEach(function(m){if(E){var f=l.tracks[m];if(f&&typeof f.buffer.changeType=="function"){var L=s[m],g=L.codec,d=L.levelCodec,c=L.container,h=(f.levelCodec||f.codec).replace(R,"$1"),a=(d||g).replace(R,"$1");if(h!==a){var x=c+";codecs="+(d||g);l.appendChangeType(m,x)}}}else l.pendingTracks[m]=s[m]}),E)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},S.appendChangeType=function(o,s){var l=this,E=this.operationQueue,m={execute:function(){var L=l.sourceBuffer[o];L&&(D.logger.log("[buffer-controller]: changing "+o+" sourceBuffer type to "+s),L.changeType(s)),E.shiftAndExecuteNext(o)},onStart:function(){},onComplete:function(){},onError:function(L){D.logger.warn("[buffer-controller]: Failed to change "+o+" SourceBuffer type",L)}};E.append(m,o)},S.onBufferAppending=function(o,s){var l=this,E=this.hls,m=this.operationQueue,f=this.tracks,L=s.data,g=s.type,d=s.frag,c=s.part,h=s.chunkMeta,a=h.buffering[g],x=self.performance.now();a.start=x;var p=d.stats.buffering,b=c?c.stats.buffering:null;p.start===0&&(p.start=x),b&&b.start===0&&(b.start=x);var M=f.audio,G=g==="audio"&&h.id===1&&(M==null?void 0:M.container)==="audio/mpeg",Z={execute:function(){if(a.executeStart=self.performance.now(),G){var z=l.sourceBuffer[g];if(z){var F=d.start-z.timestampOffset;Math.abs(F)>=.1&&(D.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+d.start+" (delta: "+F+") sn: "+d.sn+")"),z.timestampOffset=d.start)}}l.appendExecutor(L,g)},onStart:function(){},onComplete:function(){var z=self.performance.now();a.executeEnd=a.end=z,p.first===0&&(p.first=z),b&&b.first===0&&(b.first=z);var F=l.sourceBuffer,ne={};for(var ce in F)ne[ce]=U.BufferHelper.getBuffered(F[ce]);l.appendError=0,l.hls.trigger(I.Events.BUFFER_APPENDED,{type:g,frag:d,part:c,chunkMeta:h,parent:d.type,timeRanges:ne})},onError:function(z){D.logger.error("[buffer-controller]: Error encountered while trying to append to the "+g+" SourceBuffer",z);var F={type:j.ErrorTypes.MEDIA_ERROR,parent:d.type,details:j.ErrorDetails.BUFFER_APPEND_ERROR,err:z,fatal:!1};z.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=j.ErrorDetails.BUFFER_FULL_ERROR:(l.appendError++,F.details=j.ErrorDetails.BUFFER_APPEND_ERROR,l.appendError>E.config.appendErrorMaxRetry&&(D.logger.error("[buffer-controller]: Failed "+E.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),F.fatal=!0)),E.trigger(I.Events.ERROR,F)}};m.append(Z,g)},S.onBufferFlushing=function(o,s){var l=this,E=this.operationQueue,m=function(L){return{execute:l.removeExecutor.bind(l,L,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){l.hls.trigger(I.Events.BUFFER_FLUSHED,{type:L})},onError:function(d){D.logger.warn("[buffer-controller]: Failed to remove from "+L+" SourceBuffer",d)}}};s.type?E.append(m(s.type),s.type):this.getSourceBufferTypes().forEach(function(f){E.append(m(f),f)})},S.onFragParsed=function(o,s){var l=this,E=s.frag,m=s.part,f=[],L=m?m.elementaryStreams:E.elementaryStreams;L[O.ElementaryStreamTypes.AUDIOVIDEO]?f.push("audiovideo"):(L[O.ElementaryStreamTypes.AUDIO]&&f.push("audio"),L[O.ElementaryStreamTypes.VIDEO]&&f.push("video"));var g=function(){var c=self.performance.now();E.stats.buffering.end=c,m&&(m.stats.buffering.end=c);var h=m?m.stats:E.stats;l.hls.trigger(I.Events.FRAG_BUFFERED,{frag:E,part:m,stats:h,id:E.type})};f.length===0&&D.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+E.type+" level: "+E.level+" sn: "+E.sn),this.blockBuffers(g,f)},S.onFragChanged=function(o,s){this.flushBackBuffer()},S.onBufferEos=function(o,s){var l=this,E=this.getSourceBufferTypes().reduce(function(m,f){var L=l.sourceBuffer[f];return(!s.type||s.type===f)&&(L&&!L.ended&&(L.ended=!0,D.logger.log("[buffer-controller]: "+f+" sourceBuffer now EOS"))),m&&!!(!L||L.ended)},!0);E&&this.blockBuffers(function(){var m=l.mediaSource;if(!m||m.readyState!=="open")return;m.endOfStream()})},S.onLevelUpdated=function(o,s){var l=s.details;if(!l.fragments.length)return;this.details=l,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},S.flushBackBuffer=function(){var o=this.hls,s=this.details,l=this.media,E=this.sourceBuffer;if(!l||s===null)return;var m=this.getSourceBufferTypes();if(!m.length)return;var f=s.live&&o.config.liveBackBufferLength!==null?o.config.liveBackBufferLength:o.config.backBufferLength;if(!Object($.isFiniteNumber)(f)||f<0)return;var L=l.currentTime,g=s.levelTargetDuration,d=Math.max(f,g),c=Math.floor(L/g)*g-d;m.forEach(function(h){var a=E[h];if(a){var x=U.BufferHelper.getBuffered(a);x.length>0&&c>x.start(0)&&(o.trigger(I.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),s.live&&o.trigger(I.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),o.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:h}))}})},S.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var o=this.details,s=this.hls,l=this.media,E=this.mediaSource,m=o.fragments[0].start+o.totalduration,f=l.duration,L=Object($.isFiniteNumber)(E.duration)?E.duration:0;o.live&&s.config.liveDurationInfinity?(D.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),E.duration=Infinity,this.updateSeekableRange(o)):(m>L&&m>f||!Object($.isFiniteNumber)(f))&&(D.logger.log("[buffer-controller]: Updating Media Source duration to "+m.toFixed(3)),E.duration=m)},S.updateSeekableRange=function(o){var s=this.mediaSource,l=o.fragments,E=l.length;if(E&&o.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var m=Math.max(0,l[0].start),f=Math.max(m,m+o.totalduration);s.setLiveSeekableRange(m,f)}},S.checkPendingTracks=function(){var o=this.bufferCodecEventsExpected,s=this.operationQueue,l=this.pendingTracks,E=Object.keys(l).length;if(E&&!o||E===2){this.createSourceBuffers(l),this.pendingTracks={};var m=this.getSourceBufferTypes();if(m.length===0){this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}m.forEach(function(f){s.executeNext(f)})}},S.createSourceBuffers=function(o){var s=this.sourceBuffer,l=this.mediaSource;if(!l)throw Error("createSourceBuffers called when mediaSource was null");var E=0;for(var m in o)if(!s[m]){var f=o[m];if(!f)throw Error("source buffer exists for track "+m+", however track does not");var L=f.levelCodec||f.codec,g=f.container+";codecs="+L;D.logger.log("[buffer-controller]: creating sourceBuffer("+g+")");try{var d=s[m]=l.addSourceBuffer(g),c=m;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[m]={buffer:d,codec:L,container:f.container,levelCodec:f.levelCodec,id:f.id},E++}catch(h){D.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+h.message),this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,mimeType:g})}}E&&this.hls.trigger(I.Events.BUFFER_CREATED,{tracks:this.tracks})},S._onSBUpdateStart=function(o){var s=this.operationQueue,l=s.current(o);l.onStart()},S._onSBUpdateEnd=function(o){var s=this.operationQueue,l=s.current(o);l.onComplete(),s.shiftAndExecuteNext(o)},S._onSBUpdateError=function(o,s){D.logger.error("[buffer-controller]: "+o+" SourceBuffer error",s),this.hls.trigger(I.Events.ERROR,{type:j.ErrorTypes.MEDIA_ERROR,details:j.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var l=this.operationQueue.current(o);l&&l.onError(s)},S.removeExecutor=function(o,s,l){var E=this.media,m=this.mediaSource,f=this.operationQueue,L=this.sourceBuffer,g=L[o];if(!E||!m||!g){D.logger.warn("[buffer-controller]: Attempting to remove from the "+o+" SourceBuffer, but it does not exist"),f.shiftAndExecuteNext(o);return}var d=Object($.isFiniteNumber)(E.duration)?E.duration:Infinity,c=Object($.isFiniteNumber)(m.duration)?m.duration:Infinity,h=Math.max(0,s),a=Math.min(l,d,c);a>h?(D.logger.log("[buffer-controller]: Removing ["+h+","+a+"] from the "+o+" SourceBuffer"),console.assert(!g.updating,o+" sourceBuffer must not be updating"),g.remove(h,a)):f.shiftAndExecuteNext(o)},S.appendExecutor=function(o,s){var l=this.operationQueue,E=this.sourceBuffer,m=E[s];if(!m){D.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),l.shiftAndExecuteNext(s);return}m.ended=!1,console.assert(!m.updating,s+" sourceBuffer must not be updating"),m.appendBuffer(o)},S.blockBuffers=function(o,s){var l=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){D.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(o);return}var E=this.operationQueue,m=s.map(function(f){return E.appendBlocker(f)});Promise.all(m).then(function(){o(),s.forEach(function(f){var L=l.sourceBuffer[f];(!L||!L.updating)&&E.shiftAndExecuteNext(f)})})},S.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},S.addBufferListener=function(o,s,l){var E=this.sourceBuffer[o];if(!E)return;var m=l.bind(this,o);this.listeners[o].push({event:s,listener:m}),E.addEventListener(s,m)},S.removeBufferListeners=function(o){var s=this.sourceBuffer[o];if(!s)return;this.listeners[o].forEach(function(l){s.removeEventListener(l.event,l.listener)})},C}()},"./src/controller/buffer-operation-queue.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return I});var $=_("./src/utils/logger.ts"),I=function(){function D(U){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=U}var j=D.prototype;return j.append=function(P,O){var v=this.queues[O];v.push(P),v.length===1&&this.buffers[O]&&this.executeNext(O)},j.insertAbort=function(P,O){var v=this.queues[O];v.unshift(P),this.executeNext(O)},j.appendBlocker=function(P){var O,v=new Promise(function(R){O=R}),T={execute:O,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,P),v},j.executeNext=function(P){var O=this.buffers,v=this.queues,T=O[P],R=v[P];if(R.length){var A=R[0];try{A.execute()}catch(C){$.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),A.onError(C),(!T||!T.updating)&&(R.shift(),this.executeNext(P))}}},j.shiftAndExecuteNext=function(P){this.queues[P].shift(),this.executeNext(P)},j.current=function(P){return this.queues[P][0]},D}()},"./src/controller/cap-level-controller.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/events.ts");function I(U,P){for(var O=0;O<P.length;O++){var v=P[O];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(U,v.key,v)}}function D(U,P,O){return P&&I(U.prototype,P),O&&I(U,O),U}var j=function(){function U(O){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=O,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var P=U.prototype;return P.setStreamController=function(v){this.streamController=v},P.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},P.registerListeners=function(){var v=this.hls;v.on($.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.on($.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.on($.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on($.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.on($.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.unregisterListener=function(){var v=this.hls;v.off($.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),v.off($.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off($.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off($.Events.BUFFER_CODECS,this.onBufferCodecs,this),v.off($.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},P.onFpsDropLevelCapping=function(v,T){U.isLevelAllowed(T.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(T.droppedLevel)},P.onMediaAttaching=function(v,T){this.media=T.media instanceof HTMLVideoElement?T.media:null},P.onManifestParsed=function(v,T){var R=this.hls;this.restrictedLevels=[],this.firstLevel=T.firstLevel,R.config.capLevelToPlayerSize&&T.video&&this.startCapping()},P.onBufferCodecs=function(v,T){var R=this.hls;R.config.capLevelToPlayerSize&&T.video&&this.startCapping()},P.onMediaDetaching=function(){this.stopCapping()},P.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var v=this.hls.levels;if(v.length){var T=this.hls;T.autoLevelCapping=this.getMaxLevel(v.length-1),T.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=T.autoLevelCapping}}},P.getMaxLevel=function(v){var T=this,R=this.hls.levels;if(!R.length)return-1;var A=R.filter(function(C,S){return U.isLevelAllowed(S,T.restrictedLevels)&&S<=v});return this.clientRect=null,U.getMaxLevelByMediaSize(A,this.mediaWidth,this.mediaHeight)},P.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()},P.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},P.getDimensions=function(){if(this.clientRect)return this.clientRect;var v=this.media,T={width:0,height:0};if(v){var R=v.getBoundingClientRect();T.width=R.width,T.height=R.height,!T.width&&!T.height&&(T.width=R.right-R.left||v.width||0,T.height=R.bottom-R.top||v.height||0)}return this.clientRect=T,T},U.isLevelAllowed=function(v,T){return T===void 0&&(T=[]),T.indexOf(v)===-1},U.getMaxLevelByMediaSize=function(v,T,R){if(!v||!v.length)return-1;for(var A=function(s,l){return l?s.width!==l.width||s.height!==l.height:!0},C=v.length-1,S=0;S<v.length;S+=1){var u=v[S];if((u.width>=T||u.height>=R)&&A(u,v[S+1])){C=S;break}}return C},D(U,[{key:"mediaWidth",get:function(){return this.getDimensions().width*U.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*U.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var v=1;try{v=self.devicePixelRatio}catch(T){}return v}}]),U}();J.default=j},"./src/controller/cmcd-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return A});var $=_("./src/events.ts"),I=_("./src/types/cmcd.ts"),D=_("./src/utils/buffer-helper.ts"),j=_("./src/utils/logger.ts");function U(C,S){for(var u=0;u<S.length;u++){var o=S[u];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(C,o.key,o)}}function P(C,S,u){return S&&U(C.prototype,S),u&&U(C,u),C}function O(C,S){var u=typeof Symbol!="undefined"&&C[Symbol.iterator]||C["@@iterator"];if(u)return(u=u.call(C)).next.bind(u);if(Array.isArray(C)||(u=v(C))||S&&C&&typeof C.length=="number"){u&&(C=u);var o=0;return function(){return o>=C.length?{done:!0}:{done:!1,value:C[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(C,S){if(!C)return;if(typeof C=="string")return T(C,S);var u=Object.prototype.toString.call(C).slice(8,-1);if(u==="Object"&&C.constructor&&(u=C.constructor.name),u==="Map"||u==="Set")return Array.from(C);if(u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u))return T(C,S)}function T(C,S){(S==null||S>C.length)&&(S=C.length);for(var u=0,o=new Array(S);u<S;u++)o[u]=C[u];return o}function R(){return R=Object.assign||function(C){for(var S=1;S<arguments.length;S++){var u=arguments[S];for(var o in u)Object.prototype.hasOwnProperty.call(u,o)&&(C[o]=u[o])}return C},R.apply(this,arguments)}var A=function(){function C(u){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(E){try{o.apply(E,{ot:I.CMCDObjectType.MANIFEST,su:!o.initialized})}catch(m){j.logger.warn("Could not generate manifest CMCD data.",m)}},this.applyFragmentData=function(E){try{var m=E.frag,f=o.hls.levels[m.level],L=o.getObjectType(m),g={d:m.duration*1e3,ot:L};(L===I.CMCDObjectType.VIDEO||L===I.CMCDObjectType.AUDIO||L==I.CMCDObjectType.MUXED)&&(g.br=f.bitrate/1e3,g.tb=o.getTopBandwidth(L),g.bl=o.getBufferLength(L)),o.apply(E,g)}catch(d){j.logger.warn("Could not generate segment CMCD data.",d)}},this.hls=u;var s=this.config=u.config,l=s.cmcd;l!=null&&(s.pLoader=this.createPlaylistLoader(),s.fLoader=this.createFragmentLoader(),this.sid=l.sessionId||C.uuid(),this.cid=l.contentId,this.useHeaders=l.useHeaders===!0,this.registerListeners())}var S=C.prototype;return S.registerListeners=function(){var o=this.hls;o.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on($.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.on($.Events.BUFFER_CREATED,this.onBufferCreated,this)},S.unregisterListeners=function(){var o=this.hls;o.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off($.Events.MEDIA_DETACHED,this.onMediaDetached,this),o.off($.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},S.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},S.onMediaAttached=function(o,s){this.media=s.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},S.onMediaDetached=function(){if(!this.media)return;this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null},S.onBufferCreated=function(o,s){var l,E;this.audioBuffer=(l=s.tracks.audio)===null||l===void 0?void 0:l.buffer,this.videoBuffer=(E=s.tracks.video)===null||E===void 0?void 0:E.buffer},S.createData=function(){var o;return{v:I.CMCDVersion,sf:I.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}},S.apply=function(o,s){s===void 0&&(s={}),R(s,this.createData());var l=s.ot===I.CMCDObjectType.INIT||s.ot===I.CMCDObjectType.VIDEO||s.ot===I.CMCDObjectType.MUXED;if(this.starved&&l&&(s.bs=!0,s.su=!0,this.starved=!1),s.su==null&&(s.su=this.buffering),this.useHeaders){var E=C.toHeaders(s);if(!Object.keys(E).length)return;o.headers||(o.headers={}),R(o.headers,E)}else{var m=C.toQuery(s);if(!m)return;o.url=C.appendQueryToUri(o.url,m)}},S.getObjectType=function(o){var s=o.type;return s==="subtitle"?I.CMCDObjectType.TIMED_TEXT:o.sn==="initSegment"?I.CMCDObjectType.INIT:s==="audio"?I.CMCDObjectType.AUDIO:s==="main"?this.hls.audioTracks.length?I.CMCDObjectType.VIDEO:I.CMCDObjectType.MUXED:void 0},S.getTopBandwidth=function(o){for(var s=0,l=o===I.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,E=O(l),m;!(m=E()).done;){var f=m.value;f.bitrate>s&&(s=f.bitrate)}return s>0?s:NaN},S.getBufferLength=function(o){var s=this.hls.media,l=o===I.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!l||!s)return NaN;var E=D.BufferHelper.bufferInfo(l,s.currentTime,this.config.maxBufferHole);return E.len*1e3},S.createPlaylistLoader=function(){var o=this.config.pLoader,s=this.applyPlaylistData,l=o||this.config.loader;return function(){function E(f){this.loader=void 0,this.loader=new l(f)}var m=E.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(L,g,d){s(L),this.loader.load(L,g,d)},P(E,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),E}()},S.createFragmentLoader=function(){var o=this.config.fLoader,s=this.applyFragmentData,l=o||this.config.loader;return function(){function E(f){this.loader=void 0,this.loader=new l(f)}var m=E.prototype;return m.destroy=function(){this.loader.destroy()},m.abort=function(){this.loader.abort()},m.load=function(L,g,d){s(L),this.loader.load(L,g,d)},P(E,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),E}()},C.uuid=function(){var o=URL.createObjectURL(new Blob),s=o.toString();return URL.revokeObjectURL(o),s.substr(s.lastIndexOf("/")+1)},C.serialize=function(o){for(var s=[],l=function(G){return!Number.isNaN(G)&&G!=null&&G!==""&&G!==!1},E=function(G){return Math.round(G)},m=function(G){return E(G/100)*100},f=function(G){return encodeURIComponent(G)},L={br:E,d:E,bl:m,dl:m,mtp:m,nor:f,rtp:m,tb:E},g=Object.keys(o||{}).sort(),d=O(g),c;!(c=d()).done;){var h=c.value,a=o[h];if(!l(a))continue;if(h==="v"&&a===1)continue;if(h=="pr"&&a===1)continue;var x=L[h];x&&(a=x(a));var p=typeof a,b=void 0;h==="ot"||h==="sf"||h==="st"?b=h+"="+a:p==="boolean"?b=h:p==="number"?b=h+"="+a:b=h+"="+JSON.stringify(a),s.push(b)}return s.join(",")},C.toHeaders=function(o){for(var s=Object.keys(o),l={},E=["Object","Request","Session","Status"],m=[{},{},{},{}],f={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,g=s;L<g.length;L++){var d=g[L],c=f[d]!=null?f[d]:1;m[c][d]=o[d]}for(var h=0;h<m.length;h++){var a=C.serialize(m[h]);a&&(l["CMCD-"+E[h]]=a)}return l},C.toQuery=function(o){return"CMCD="+encodeURIComponent(C.serialize(o))},C.appendQueryToUri=function(o,s){if(!s)return o;var l=o.includes("?")?"&":"?";return""+o+l+s},C}()},"./src/controller/eme-controller.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/events.ts"),I=_("./src/errors.ts"),D=_("./src/utils/logger.ts"),j=_("./src/utils/mediakeys-helper.ts");function U(A,C){for(var S=0;S<C.length;S++){var u=C[S];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(A,u.key,u)}}function P(A,C,S){return C&&U(A.prototype,C),S&&U(A,S),A}var O=3,v=function(C,S,u){var o={audioCapabilities:[],videoCapabilities:[]};return C.forEach(function(s){o.audioCapabilities.push({contentType:'audio/mp4; codecs="'+s+'"',robustness:u.audioRobustness||""})}),S.forEach(function(s){o.videoCapabilities.push({contentType:'video/mp4; codecs="'+s+'"',robustness:u.videoRobustness||""})}),[o]},T=function(C,S,u,o){switch(C){case j.KeySystems.WIDEVINE:return v(S,u,o);default:throw new Error("Unknown key-system: "+C)}},R=function(){function A(S){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=S,this._config=S.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 C=A.prototype;return C.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},C._registerListeners=function(){this.hls.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on($.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on($.Events.MANIFEST_PARSED,this.onManifestParsed,this)},C._unregisterListeners=function(){this.hls.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off($.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off($.Events.MANIFEST_PARSED,this.onManifestParsed,this)},C.getLicenseServerUrl=function(u){switch(u){case j.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+u+'"')},C._attemptKeySystemAccess=function(u,o,s){var l=this,E=T(u,o,s,this._drmSystemOptions);D.logger.log("Requesting encrypted media key-system access");var m=this.requestMediaKeySystemAccess(u,E);this.mediaKeysPromise=m.then(function(f){return l._onMediaKeySystemAccessObtained(u,f)}),m.catch(function(f){D.logger.error('Failed to obtain key-system "'+u+'" access:',f)})},C._onMediaKeySystemAccessObtained=function(u,o){var s=this;D.logger.log('Access for key-system "'+u+'" obtained');var l={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:o,mediaKeySystemDomain:u};this._mediaKeysList.push(l);var E=Promise.resolve().then(function(){return o.createMediaKeys()}).then(function(m){return l.mediaKeys=m,D.logger.log('Media-keys created for key-system "'+u+'"'),s._onMediaKeysCreated(),m});return E.catch(function(m){D.logger.error("Failed to create media-keys:",m)}),E},C._onMediaKeysCreated=function(){var u=this;this._mediaKeysList.forEach(function(o){o.mediaKeysSession||(o.mediaKeysSession=o.mediaKeys.createSession(),u._onNewMediaKeySession(o.mediaKeysSession))})},C._onNewMediaKeySession=function(u){var o=this;D.logger.log("New key-system session "+u.sessionId),u.addEventListener("message",function(s){o._onKeySessionMessage(u,s.message)},!1)},C._onKeySessionMessage=function(u,o){D.logger.log("Got EME message event, creating license request"),this._requestLicense(o,function(s){D.logger.log("Received license data (length: "+(s&&s.byteLength)+"), updating key-session"),u.update(s)})},C.onMediaEncrypted=function(u){var o=this;if(D.logger.log('Media is encrypted using "'+u.initDataType+'" init data type'),!this.mediaKeysPromise){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var s=function(E){if(!o._media)return;o._attemptSetMediaKeys(E),o._generateRequestWithPreferredKeySession(u.initDataType,u.initData)};this.mediaKeysPromise.then(s).catch(s)},C._attemptSetMediaKeys=function(u){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){D.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}D.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(o.mediaKeys),this._hasSetMediaKeys=!0}},C._generateRequestWithPreferredKeySession=function(u,o){var s=this,l=this._mediaKeysList[0];if(!l){D.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(l.mediaKeysSessionInitialized){D.logger.warn("Key-Session already initialized but requested again");return}var E=l.mediaKeysSession;if(!E){D.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!o){D.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}D.logger.log('Generating key-session request for "'+u+'" init data type'),l.mediaKeysSessionInitialized=!0,E.generateRequest(u,o).then(function(){D.logger.debug("Key-session generation succeeded")}).catch(function(m){D.logger.error("Error generating key-session request:",m),s.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},C._createLicenseXhr=function(u,o,s){var l=new XMLHttpRequest;l.responseType="arraybuffer",l.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,l,u,o,s);var E=this._licenseXhrSetup;if(E)try{E.call(this.hls,l,u),E=void 0}catch(m){D.logger.error(m)}try{l.readyState||l.open("POST",u,!0),E&&E.call(this.hls,l,u)}catch(m){throw new Error("issue setting up KeySystem license XHR "+m)}return l},C._onLicenseRequestReadyStageChange=function(u,o,s,l){switch(u.readyState){case 4:if(u.status===200){this._requestLicenseFailureCount=0,D.logger.log("License request succeeded");var E=u.response,m=this._licenseResponseCallback;if(m)try{E=m.call(this.hls,u,o)}catch(L){D.logger.error(L)}l(E)}else{if(D.logger.error("License Request XHR failed ("+o+"). Status: "+u.status+" ("+u.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>O){this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var f=O-this._requestLicenseFailureCount+1;D.logger.warn("Retrying license request, "+f+" attempts left"),this._requestLicense(s,l)}break}},C._generateLicenseRequestChallenge=function(u,o){switch(u.mediaKeySystemDomain){case j.KeySystems.WIDEVINE:return o}throw new Error("unsupported key-system: "+u.mediaKeySystemDomain)},C._requestLicense=function(u,o){D.logger.log("Requesting content license for key-system");var s=this._mediaKeysList[0];if(!s){D.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var l=this.getLicenseServerUrl(s.mediaKeySystemDomain),E=this._createLicenseXhr(l,u,o);D.logger.log("Sending license request to URL: "+l);var m=this._generateLicenseRequestChallenge(s,u);E.send(m)}catch(f){D.logger.error("Failure requesting DRM license: "+f),this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},C.onMediaAttached=function(u,o){if(!this._emeEnabled)return;var s=o.media;this._media=s,s.addEventListener("encrypted",this._onMediaEncrypted)},C.onMediaDetached=function(){var u=this._media,o=this._mediaKeysList;if(!u)return;u.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 u.setMediaKeys(null)}).catch(function(){})},C.onManifestParsed=function(u,o){if(!this._emeEnabled)return;var s=o.levels.map(function(E){return E.audioCodec}).filter(function(E){return!!E}),l=o.levels.map(function(E){return E.videoCodec}).filter(function(E){return!!E});this._attemptKeySystemAccess(j.KeySystems.WIDEVINE,s,l)},P(A,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),A}();J.default=R},"./src/controller/fps-controller.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/events.ts"),I=_("./src/utils/logger.ts"),D=function(){function j(P){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=P,this.registerListeners()}var U=j.prototype;return U.setStreamController=function(O){this.streamController=O},U.registerListeners=function(){this.hls.on($.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},U.unregisterListeners=function(){this.hls.off($.Events.MEDIA_ATTACHING,this.onMediaAttaching)},U.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},U.onMediaAttaching=function(O,v){var T=this.hls.config;if(T.capLevelOnFPSDrop){var R=v.media instanceof self.HTMLVideoElement?v.media:null;this.media=R,R&&typeof R.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),T.fpsDroppedMonitoringPeriod)}},U.checkFPS=function(O,v,T){var R=performance.now();if(v){if(this.lastTime){var A=R-this.lastTime,C=T-this.lastDroppedFrames,S=v-this.lastDecodedFrames,u=1e3*C/A,o=this.hls;if(o.trigger($.Events.FPS_DROP,{currentDropped:C,currentDecoded:S,totalDroppedFrames:T}),u>0&&C>o.config.fpsDroppedMonitoringThreshold*S){var s=o.currentLevel;I.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($.Events.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:o.currentLevel}),o.autoLevelCapping=s,this.streamController.nextLevelSwitch())}}this.lastTime=R,this.lastDroppedFrames=T,this.lastDecodedFrames=v}},U.checkFPSInterval=function(){var O=this.media;if(O)if(this.isVideoPlaybackQualityAvailable){var v=O.getVideoPlaybackQuality();this.checkFPS(O,v.totalVideoFrames,v.droppedVideoFrames)}else this.checkFPS(O,O.webkitDecodedFrameCount,O.webkitDroppedFrameCount)},j}();J.default=D},"./src/controller/fragment-finders.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"findFragmentByPDT",function(){return D}),_.d(J,"findFragmentByPTS",function(){return j}),_.d(J,"fragmentWithinToleranceTest",function(){return U}),_.d(J,"pdtWithinToleranceTest",function(){return P}),_.d(J,"findFragWithCC",function(){return O});var $=_("./src/polyfills/number.ts"),I=_("./src/utils/binary-search.ts");function D(v,T,R){if(T===null||!Array.isArray(v)||!v.length||!Object($.isFiniteNumber)(T))return null;var A=v[0].programDateTime;if(T<(A||0))return null;var C=v[v.length-1].endProgramDateTime;if(T>=(C||0))return null;R=R||0;for(var S=0;S<v.length;++S){var u=v[S];if(P(T,R,u))return u}return null}function j(v,T,R,A){R===void 0&&(R=0),A===void 0&&(A=0);var C=null;if(v?C=T[v.sn-T[0].sn+1]||null:R===0&&T[0].start===0&&(C=T[0]),C&&U(R,A,C)===0)return C;var S=I.default.search(T,U.bind(null,R,A));return S||C}function U(v,T,R){v===void 0&&(v=0),T===void 0&&(T=0);var A=Math.min(T,R.duration+(R.deltaPTS?R.deltaPTS:0));return R.start+R.duration-A<=v?1:R.start-A>v&&R.start?-1:0}function P(v,T,R){var A=Math.min(T,R.duration+(R.deltaPTS?R.deltaPTS:0))*1e3,C=R.endProgramDateTime||0;return C-A>v}function O(v,T){return I.default.search(v,function(R){return R.cc<T?1:R.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"FragmentState",function(){return D}),_.d(J,"FragmentTracker",function(){return j});var $=_("./src/events.ts"),I=_("./src/types/loader.ts"),D;(function(O){O.NOT_LOADED="NOT_LOADED",O.BACKTRACKED="BACKTRACKED",O.APPENDING="APPENDING",O.PARTIAL="PARTIAL",O.OK="OK"})(D||(D={}));var j=function(){function O(T){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=T,this._registerListeners()}var v=O.prototype;return v._registerListeners=function(){var R=this.hls;R.on($.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.on($.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.on($.Events.FRAG_LOADED,this.onFragLoaded,this)},v._unregisterListeners=function(){var R=this.hls;R.off($.Events.BUFFER_APPENDED,this.onBufferAppended,this),R.off($.Events.FRAG_BUFFERED,this.onFragBuffered,this),R.off($.Events.FRAG_LOADED,this.onFragLoaded,this)},v.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},v.getAppendedFrag=function(R,A){if(A===I.PlaylistLevelType.MAIN){var C=this.activeFragment,S=this.activeParts;if(!C)return null;if(S)for(var u=S.length;u--;){var o=S[u],s=o?o.end:C.appendedPTS;if(o.start<=R&&s!==void 0&&R<=s)return u>9&&(this.activeParts=S.slice(u-9)),o}else if(C.start<=R&&C.appendedPTS!==void 0&&R<=C.appendedPTS)return C}return this.getBufferedFrag(R,A)},v.getBufferedFrag=function(R,A){for(var C=this.fragments,S=Object.keys(C),u=S.length;u--;){var o=C[S[u]];if((o==null?void 0:o.body.type)===A&&o.buffered){var s=o.body;if(s.start<=R&&R<=s.end)return s}}return null},v.detectEvictedFragments=function(R,A,C){var S=this;Object.keys(this.fragments).forEach(function(u){var o=S.fragments[u];if(!o)return;if(!o.buffered){o.body.type===C&&S.removeFragment(o.body);return}var s=o.range[R];if(!s)return;s.time.some(function(l){var E=!S.isTimeBuffered(l.startPTS,l.endPTS,A);return E&&S.removeFragment(o.body),E})})},v.detectPartialFragments=function(R){var A=this,C=this.timeRanges,S=R.frag,u=R.part;if(!C||S.sn==="initSegment")return;var o=P(S),s=this.fragments[o];if(!s)return;Object.keys(C).forEach(function(l){var E=S.elementaryStreams[l];if(!E)return;var m=C[l],f=u!==null||E.partial===!0;s.range[l]=A.getBufferedTimes(S,u,f,m)}),s.backtrack=s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body)},v.fragBuffered=function(R){var A=P(R),C=this.fragments[A];C&&(C.backtrack=C.loaded=null,C.buffered=!0)},v.getBufferedTimes=function(R,A,C,S){for(var u={time:[],partial:C},o=A?A.start:R.start,s=A?A.end:R.end,l=R.minEndPTS||s,E=R.maxStartPTS||o,m=0;m<S.length;m++){var f=S.start(m)-this.bufferPadding,L=S.end(m)+this.bufferPadding;if(E>=f&&l<=L){u.time.push({startPTS:Math.max(o,S.start(m)),endPTS:Math.min(s,S.end(m))});break}else if(o<L&&s>f)u.partial=!0,u.time.push({startPTS:Math.max(o,S.start(m)),endPTS:Math.min(s,S.end(m))});else if(s<=f)break}return u},v.getPartialFragment=function(R){var A=null,C,S,u,o=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach(function(E){var m=l[E];if(!m)return;U(m)&&(S=m.body.start-s,u=m.body.end+s,R>=S&&R<=u&&(C=Math.min(R-S,u-R),o<=C&&(A=m.body,o=C)))}),A},v.getState=function(R){var A=P(R),C=this.fragments[A];return C?C.buffered?U(C)?D.PARTIAL:D.OK:C.backtrack?D.BACKTRACKED:D.APPENDING:D.NOT_LOADED},v.backtrack=function(R,A){var C=P(R),S=this.fragments[C];if(!S||S.backtrack)return null;var u=S.backtrack=A||S.loaded;return S.loaded=null,u},v.getBacktrackData=function(R){var A=P(R),C=this.fragments[A];if(C){var S,u=C.backtrack;if(u!=null&&(S=u.payload)!==null&&S!==void 0&&S.byteLength)return u;this.removeFragment(R)}return null},v.isTimeBuffered=function(R,A,C){for(var S,u,o=0;o<C.length;o++){if(S=C.start(o)-this.bufferPadding,u=C.end(o)+this.bufferPadding,R>=S&&A<=u)return!0;if(A<=S)return!1}return!1},v.onFragLoaded=function(R,A){var C=A.frag,S=A.part;if(C.sn==="initSegment"||C.bitrateTest||S)return;var u=P(C);this.fragments[u]={body:C,loaded:A,backtrack:null,buffered:!1,range:Object.create(null)}},v.onBufferAppended=function(R,A){var C=this,S=A.frag,u=A.part,o=A.timeRanges;if(S.type===I.PlaylistLevelType.MAIN)if(this.activeFragment=S,u){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(u)}else this.activeParts=null;this.timeRanges=o,Object.keys(o).forEach(function(l){var E=o[l];if(C.detectEvictedFragments(l,E),!u)for(var m=0;m<E.length;m++)S.appendedPTS=Math.max(E.end(m),S.appendedPTS||0)})},v.onFragBuffered=function(R,A){this.detectPartialFragments(A)},v.hasFragment=function(R){var A=P(R);return!!this.fragments[A]},v.removeFragmentsInRange=function(R,A,C){var S=this;Object.keys(this.fragments).forEach(function(u){var o=S.fragments[u];if(!o)return;if(o.buffered){var s=o.body;s.type===C&&s.start<A&&s.end>R&&S.removeFragment(s)}})},v.removeFragment=function(R){var A=P(R);R.stats.loaded=0,R.clearElementaryStreamInfo(),delete this.fragments[A]},v.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},O}();function U(O){var v,T;return O.buffered&&(((v=O.range.video)===null||v===void 0?void 0:v.partial)||((T=O.range.audio)===null||T===void 0?void 0:T.partial))}function P(O){return O.type+"_"+O.level+"_"+O.urlId+"_"+O.sn}},"./src/controller/gap-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"STALL_MINIMUM_DURATION_MS",function(){return U}),_.d(J,"MAX_START_GAP_JUMP",function(){return P}),_.d(J,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return O}),_.d(J,"SKIP_BUFFER_RANGE_START",function(){return v}),_.d(J,"default",function(){return T});var $=_("./src/utils/buffer-helper.ts"),I=_("./src/errors.ts"),D=_("./src/events.ts"),j=_("./src/utils/logger.ts"),U=250,P=2,O=.1,v=.05,T=function(){function R(C,S,u,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=C,this.media=S,this.fragmentTracker=u,this.hls=o}var A=R.prototype;return A.destroy=function(){this.hls=this.fragmentTracker=this.media=null},A.poll=function(S){var u=this.config,o=this.media,s=this.stalled,l=o.currentTime,E=o.seeking,m=this.seeking&&!E,f=!this.seeking&&E;if(this.seeking=E,l!==S){if(this.moved=!0,s!==null){if(this.stallReported){var L=self.performance.now()-s;j.logger.warn("playback not stuck anymore @"+l+", after "+Math.round(L)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((f||m)&&(this.stalled=null),o.paused||o.ended||o.playbackRate===0||!$.BufferHelper.getBuffered(o).length)return;var g=$.BufferHelper.bufferInfo(o,l,0),d=g.len>0,c=g.nextStart||0;if(!d&&!c)return;if(E){var h=g.len>P,a=!c||c-l>P&&!this.fragmentTracker.getPartialFragment(l);if(h||a)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var x,p=Math.max(c,g.start||0)-l,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=b==null||((x=b.details)===null||x===void 0)?void 0:x.live,G=M?b.details.targetduration*2:P;if(p>0&&p<=G){this._trySkipBufferHole(null);return}}var Z=self.performance.now();if(s===null){this.stalled=Z;return}var ie=Z-s;!E&&ie>=U&&this._reportStall(g.len);var z=$.BufferHelper.bufferInfo(o,l,u.maxBufferHole);this._tryFixBufferStall(z,ie)},A._tryFixBufferStall=function(S,u){var o=this.config,s=this.fragmentTracker,l=this.media,E=l.currentTime,m=s.getPartialFragment(E);if(m){var f=this._trySkipBufferHole(m);if(f)return}S.len>o.maxBufferHole&&u>o.highBufferWatchdogPeriod*1e3&&(j.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},A._reportStall=function(S){var u=this.hls,o=this.media,s=this.stallReported;s||(this.stallReported=!0,j.logger.warn("Playback stalling at @"+o.currentTime+" due to low buffer (buffer="+S+")"),u.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:S}))},A._trySkipBufferHole=function(S){for(var u=this.config,o=this.hls,s=this.media,l=s.currentTime,E=0,m=$.BufferHelper.getBuffered(s),f=0;f<m.length;f++){var L=m.start(f);if(l+u.maxBufferHole>=E&&l<L){var g=Math.max(L+v,s.currentTime+O);return j.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+g),this.moved=!0,this.stalled=null,s.currentTime=g,S&&o.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+g,frag:S}),g}E=m.end(f)}return 0},A._tryNudgeBuffer=function(){var S=this.config,u=this.hls,o=this.media,s=o.currentTime,l=(this.nudgeRetry||0)+1;if(this.nudgeRetry=l,l<S.nudgeMaxRetry){var E=s+l*S.nudgeOffset;j.logger.warn("Nudging 'currentTime' from "+s+" to "+E),o.currentTime=E,u.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else j.logger.error("Playhead still not moving while enough data buffered @"+s+" after "+S.nudgeMaxRetry+" nudges"),u.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},R}()},"./src/controller/id3-track-controller.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/events.ts"),I=_("./src/utils/texttrack-utils.ts"),D=_("./src/demux/id3.ts"),j=.25,U=function(){function P(v){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=v,this._registerListeners()}var O=P.prototype;return O.destroy=function(){this._unregisterListeners()},O._registerListeners=function(){var T=this.hls;T.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),T.on($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.on($.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),T.on($.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O._unregisterListeners=function(){var T=this.hls;T.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),T.off($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),T.off($.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),T.off($.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},O.onMediaAttached=function(T,R){this.media=R.media},O.onMediaDetaching=function(){if(!this.id3Track)return;Object(I.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},O.getID3Track=function(T){if(!this.media)return;for(var R=0;R<T.length;R++){var A=T[R];if(A.kind==="metadata"&&A.label==="id3")return Object(I.sendAddTrackEvent)(A,this.media),A}return this.media.addTextTrack("metadata","id3")},O.onFragParsingMetadata=function(T,R){if(!this.media)return;var A=R.frag,C=R.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var S=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,u=0;u<C.length;u++){var o=D.getID3Frames(C[u].data);if(o){var s=C[u].pts,l=u<C.length-1?C[u+1].pts:A.end,E=l-s;E<=0&&(l=s+j);for(var m=0;m<o.length;m++){var f=o[m];if(!D.isTimeStampFrame(f)){var L=new S(s,l,"");L.value=f,this.id3Track.addCue(L)}}}}},O.onBufferFlushing=function(T,R){var A=R.startOffset,C=R.endOffset,S=R.type;if(!S||S==="audio"){var u=this.id3Track;u&&Object(I.removeCuesInRange)(u,A,C)}},P}();J.default=U},"./src/controller/latency-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return P});var $=_("./src/errors.ts"),I=_("./src/events.ts"),D=_("./src/utils/logger.ts");function j(O,v){for(var T=0;T<v.length;T++){var R=v[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(O,R.key,R)}}function U(O,v,T){return v&&j(O.prototype,v),T&&j(O,T),O}var P=function(){function O(T){var R=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 R.timeupdate()},this.hls=T,this.config=T.config,this.registerListeners()}var v=O.prototype;return v.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},v.registerListeners=function(){this.hls.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(I.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){this.hls.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(I.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(I.Events.ERROR,this.onError)},v.onMediaAttached=function(R,A){this.media=A.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(R,A){var C=A.details;this.levelDetails=C,C.advanced&&this.timeupdate(),!C.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},v.onError=function(R,A){if(A.details!==$.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,D.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},v.timeupdate=function(){var R=this.media,A=this.levelDetails;if(!R||!A)return;this.currentTime=R.currentTime;var C=this.computeLatency();if(C===null)return;this._latency=C;var S=this.config,u=S.lowLatencyMode,o=S.maxLiveSyncPlaybackRate;if(!u||o===1)return;var s=this.targetLatency;if(s===null)return;var l=C-s,E=Math.min(this.maxLatency,s+A.targetduration),m=l<E;if(A.live&&m&&l>.05&&this.forwardBufferLength>1){var f=Math.min(2,Math.max(1,o)),L=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;R.playbackRate=Math.min(f,Math.max(1,L))}else R.playbackRate!==1&&R.playbackRate!==0&&(R.playbackRate=1)},v.estimateLiveEdge=function(){var R=this.levelDetails;return R===null?null:R.edge+R.age},v.computeLatency=function(){var R=this.estimateLiveEdge();return R===null?null:R-this.currentTime},U(O,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var R=this.config,A=this.levelDetails;return R.liveMaxLatencyDuration!==void 0?R.liveMaxLatencyDuration:A?R.liveMaxLatencyDurationCount*A.targetduration:0}},{key:"targetLatency",get:function(){var R=this.levelDetails;if(R===null)return null;var A=R.holdBack,C=R.partHoldBack,S=R.targetduration,u=this.config,o=u.liveSyncDuration,s=u.liveSyncDurationCount,l=u.lowLatencyMode,E=this.hls.userConfig,m=l&&C||A;(E.liveSyncDuration||E.liveSyncDurationCount||m===0)&&(m=o!==void 0?o:s*S);var f=S,L=1;return m+Math.min(this.stallCount*L,f)}},{key:"liveSyncPosition",get:function(){var R=this.estimateLiveEdge(),A=this.targetLatency,C=this.levelDetails;if(R===null||A===null||C===null)return null;var S=C.edge,u=R-A-this.edgeStalled,o=S-C.totalduration,s=S-(this.config.lowLatencyMode&&C.partTarget||C.targetduration);return Math.min(Math.max(o,u),s)}},{key:"drift",get:function(){var R=this.levelDetails;return R===null?1:R.drift}},{key:"edgeStalled",get:function(){var R=this.levelDetails;if(R===null)return 0;var A=(this.config.lowLatencyMode&&R.partTarget||R.targetduration)*3;return Math.max(R.age-A,0)}},{key:"forwardBufferLength",get:function(){var R=this.media,A=this.levelDetails;if(!R||!A)return 0;var C=R.buffered.length;return C?R.buffered.end(C-1):A.edge-this.currentTime}}]),O}()},"./src/controller/level-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return u});var $=_("./src/types/level.ts"),I=_("./src/events.ts"),D=_("./src/errors.ts"),j=_("./src/utils/codecs.ts"),U=_("./src/controller/level-helper.ts"),P=_("./src/controller/base-playlist-controller.ts"),O=_("./src/types/loader.ts");function v(){return v=Object.assign||function(o){for(var s=1;s<arguments.length;s++){var l=arguments[s];for(var E in l)Object.prototype.hasOwnProperty.call(l,E)&&(o[E]=l[E])}return o},v.apply(this,arguments)}function T(o,s){for(var l=0;l<s.length;l++){var E=s[l];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(o,E.key,E)}}function R(o,s,l){return s&&T(o.prototype,s),l&&T(o,l),o}function A(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,C(o,s)}function C(o,s){return C=Object.setPrototypeOf||function(E,m){return E.__proto__=m,E},C(o,s)}var S=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),u=function(o){A(s,o);function s(E){var m;return m=o.call(this,E,"[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 l=s.prototype;return l._registerListeners=function(){var m=this.hls;m.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),m.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),m.on(I.Events.ERROR,this.onError,this)},l._unregisterListeners=function(){var m=this.hls;m.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),m.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),m.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),m.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),m.off(I.Events.ERROR,this.onError,this)},l.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,o.prototype.destroy.call(this)},l.startLoad=function(){var m=this._levels;m.forEach(function(f){f.loadError=0}),o.prototype.startLoad.call(this)},l.onManifestLoaded=function(m,f){var L=[],g=[],d=[],c,h={},a,x=!1,p=!1,b=!1;if(f.levels.forEach(function(ie){var z=ie.attrs;x=x||!!(ie.width&&ie.height),p=p||!!ie.videoCodec,b=b||!!ie.audioCodec,S&&ie.audioCodec&&ie.audioCodec.indexOf("mp4a.40.34")!==-1&&(ie.audioCodec=void 0);var F=ie.bitrate+"-"+ie.attrs.RESOLUTION+"-"+ie.attrs.CODECS;a=h[F],a?a.url.push(ie.url):(a=new $.Level(ie),h[F]=a,L.push(a)),z&&(z.AUDIO&&Object(U.addGroupId)(a,"audio",z.AUDIO),z.SUBTITLES&&Object(U.addGroupId)(a,"text",z.SUBTITLES))}),(x||p)&&b&&(L=L.filter(function(ie){var z=ie.videoCodec,F=ie.width,ne=ie.height;return!!z||!!(F&&ne)})),L=L.filter(function(ie){var z=ie.audioCodec,F=ie.videoCodec;return(!z||Object(j.isCodecSupportedInMp4)(z,"audio"))&&(!F||Object(j.isCodecSupportedInMp4)(F,"video"))}),f.audioTracks&&(g=f.audioTracks.filter(function(ie){return!ie.audioCodec||Object(j.isCodecSupportedInMp4)(ie.audioCodec,"audio")}),Object(U.assignTrackIdsByGroup)(g)),f.subtitles&&(d=f.subtitles,Object(U.assignTrackIdsByGroup)(d)),L.length>0){c=L[0].bitrate,L.sort(function(ie,z){return ie.bitrate-z.bitrate}),this._levels=L;for(var M=0;M<L.length;M++)if(L[M].bitrate===c){this._firstLevel=M,this.log("manifest loaded, "+L.length+" level(s) found, first bitrate: "+c);break}var G=b&&!p,Z={levels:L,audioTracks:g,subtitleTracks:d,firstLevel:this._firstLevel,stats:f.stats,audio:b,video:p,altAudio:!G&&g.some(function(ie){return!!ie.url})};this.hls.trigger(I.Events.MANIFEST_PARSED,Z),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(I.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:f.url,reason:"no level with compatible codecs found in manifest"})},l.onError=function(m,f){if(o.prototype.onError.call(this,m,f),f.fatal)return;var L=f.context,g=this._levels[this.currentLevelIndex];if(L&&(L.type===O.PlaylistContextType.AUDIO_TRACK&&g.audioGroupIds&&L.groupId===g.audioGroupIds[g.urlId]||L.type===O.PlaylistContextType.SUBTITLE_TRACK&&g.textGroupIds&&L.groupId===g.textGroupIds[g.urlId])){this.redundantFailover(this.currentLevelIndex);return}var d=!1,c=!0,h;switch(f.details){case D.ErrorDetails.FRAG_LOAD_ERROR:case D.ErrorDetails.FRAG_LOAD_TIMEOUT:case D.ErrorDetails.KEY_LOAD_ERROR:case D.ErrorDetails.KEY_LOAD_TIMEOUT:if(f.frag){var a=this._levels[f.frag.level];a?(a.fragmentError++,a.fragmentError>this.hls.config.fragLoadingMaxRetry&&(h=f.frag.level)):h=f.frag.level}break;case D.ErrorDetails.LEVEL_LOAD_ERROR:case D.ErrorDetails.LEVEL_LOAD_TIMEOUT:L&&(L.deliveryDirectives&&(c=!1),h=L.level),d=!0;break;case D.ErrorDetails.REMUX_ALLOC_ERROR:h=f.level,d=!0;break}h!==void 0&&this.recoverLevel(f,h,d,c)},l.recoverLevel=function(m,f,L,g){var d=m.details,c=this._levels[f];if(c.loadError++,L){var h=this.retryLoadingOrFail(m);if(h)m.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(g){var a=c.url.length;if(a>1&&c.loadError<a)m.levelRetry=!0,this.redundantFailover(f);else if(this.manualLevelIndex===-1){var x=f===0?this._levels.length-1:f-1;this.currentLevelIndex!==x&&this._levels[x].loadError===0&&(this.warn(d+": switch to "+x),m.levelRetry=!0,this.hls.nextAutoLevel=x)}}},l.redundantFailover=function(m){var f=this._levels[m],L=f.url.length;if(L>1){var g=(f.urlId+1)%L;this.warn("Switching to redundant URL-id "+g),this._levels.forEach(function(d){d.urlId=g}),this.level=m}},l.onFragLoaded=function(m,f){var L=f.frag;if(L!==void 0&&L.type===O.PlaylistLevelType.MAIN){var g=this._levels[L.level];g!==void 0&&(g.fragmentError=0,g.loadError=0)}},l.onLevelLoaded=function(m,f){var L,g=f.level,d=f.details,c=this._levels[g];if(!c){var h;this.warn("Invalid level index "+g),(h=f.deliveryDirectives)!==null&&h!==void 0&&h.skip&&(d.deltaUpdateFailed=!0);return}g===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(g,f,c.details)):(L=f.deliveryDirectives)!==null&&L!==void 0&&L.skip&&(d.deltaUpdateFailed=!0)},l.onAudioTrackSwitched=function(m,f){var L=this.hls.levels[this.currentLevelIndex];if(!L)return;if(L.audioGroupIds){for(var g=-1,d=this.hls.audioTracks[f.id].groupId,c=0;c<L.audioGroupIds.length;c++)if(L.audioGroupIds[c]===d){g=c;break}g!==L.urlId&&(L.urlId=g,this.startLoad())}},l.loadPlaylist=function(m){var f=this.currentLevelIndex,L=this._levels[f];if(this.canLoad&&L&&L.url.length>0){var g=L.urlId,d=L.url[g];if(m)try{d=m.addDirectives(d)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+f+(m?" at sn "+m.msn+" part "+m.part:"")+" with URL-id "+g+" "+d),this.clearTimer(),this.hls.trigger(I.Events.LEVEL_LOADING,{url:d,level:f,id:g,deliveryDirectives:m||null})}},l.removeLevel=function(m,f){var L=function(c,h){return h!==f},g=this._levels.filter(function(d,c){return c!==m?!0:d.url.length>1&&f!==void 0?(d.url=d.url.filter(L),d.audioGroupIds&&(d.audioGroupIds=d.audioGroupIds.filter(L)),d.textGroupIds&&(d.textGroupIds=d.textGroupIds.filter(L)),d.urlId=0,!0):!1}).map(function(d,c){var h=d.details;return h!=null&&h.fragments&&h.fragments.forEach(function(a){a.level=c}),d});this._levels=g,this.hls.trigger(I.Events.LEVELS_UPDATED,{levels:g})},R(s,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(m){var f,L=this._levels;if(L.length===0)return;if(this.currentLevelIndex===m&&(f=L[m])!==null&&f!==void 0&&f.details)return;if(m<0||m>=L.length){var g=m<0;if(this.hls.trigger(I.Events.ERROR,{type:D.ErrorTypes.OTHER_ERROR,details:D.ErrorDetails.LEVEL_SWITCH_ERROR,level:m,fatal:g,reason:"invalid level idx"}),g)return;m=Math.min(m,L.length-1)}this.clearTimer();var d=this.currentLevelIndex,c=L[d],h=L[m];this.log("switching to level "+m+" from "+d),this.currentLevelIndex=m;var a=v({},h,{level:m,maxBitrate:h.maxBitrate,uri:h.uri,urlId:h.urlId});delete a._urlId,this.hls.trigger(I.Events.LEVEL_SWITCHING,a);var x=h.details;if(!x||x.live){var p=this.switchParams(h.uri,c==null?void 0:c.details);this.loadPlaylist(p)}}},{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}(P.default)},"./src/controller/level-helper.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"addGroupId",function(){return D}),_.d(J,"assignTrackIdsByGroup",function(){return j}),_.d(J,"updatePTS",function(){return U}),_.d(J,"updateFragPTSDTS",function(){return O}),_.d(J,"mergeDetails",function(){return v}),_.d(J,"mapPartIntersection",function(){return T}),_.d(J,"mapFragmentIntersection",function(){return R}),_.d(J,"adjustSliding",function(){return A}),_.d(J,"addSliding",function(){return C}),_.d(J,"computeReloadInterval",function(){return S}),_.d(J,"getFragmentWithSN",function(){return u}),_.d(J,"getPartWith",function(){return o});var $=_("./src/polyfills/number.ts"),I=_("./src/utils/logger.ts");function D(s,l,E){switch(l){case"audio":s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds.push(E);break;case"text":s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds.push(E);break}}function j(s){var l={};s.forEach(function(E){var m=E.groupId||"";E.id=l[m]=l[m]||0,l[m]++})}function U(s,l,E){var m=s[l],f=s[E];P(m,f)}function P(s,l){var E=l.startPTS;if(Object($.isFiniteNumber)(E)){var m=0,f;l.sn>s.sn?(m=E-s.start,f=s):(m=s.start-E,f=l),f.duration!==m&&(f.duration=m)}else if(l.sn>s.sn){var L=s.cc===l.cc;L&&s.minEndPTS?l.start=s.start+(s.minEndPTS-s.start):l.start=s.start+s.duration}else l.start=Math.max(s.start-l.duration,0)}function O(s,l,E,m,f,L){var g=m-E;g<=0&&(I.logger.warn("Fragment should have a positive duration",l),m=E+l.duration,L=f+l.duration);var d=E,c=m,h=l.startPTS,a=l.endPTS;if(Object($.isFiniteNumber)(h)){var x=Math.abs(h-E);Object($.isFiniteNumber)(l.deltaPTS)?l.deltaPTS=Math.max(x,l.deltaPTS):l.deltaPTS=x,d=Math.max(E,h),E=Math.min(E,h),f=Math.min(f,l.startDTS),c=Math.min(m,a),m=Math.max(m,a),L=Math.max(L,l.endDTS)}l.duration=m-E;var p=E-l.start;l.appendedPTS=m,l.start=l.startPTS=E,l.maxStartPTS=d,l.startDTS=f,l.endPTS=m,l.minEndPTS=c,l.endDTS=L;var b=l.sn;if(!s||b<s.startSN||b>s.endSN)return 0;var M,G=b-s.startSN,Z=s.fragments;for(Z[G]=l,M=G;M>0;M--)P(Z[M],Z[M-1]);for(M=G;M<Z.length-1;M++)P(Z[M],Z[M+1]);return s.fragmentHint&&P(Z[Z.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,p}function v(s,l){for(var E=null,m=s.fragments,f=m.length-1;f>=0;f--){var L=m[f].initSegment;if(L){E=L;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var g=0,d;if(R(s,l,function(M,G){M.relurl&&(g=M.cc-G.cc),Object($.isFiniteNumber)(M.startPTS)&&Object($.isFiniteNumber)(M.endPTS)&&(G.start=G.startPTS=M.startPTS,G.startDTS=M.startDTS,G.appendedPTS=M.appendedPTS,G.maxStartPTS=M.maxStartPTS,G.endPTS=M.endPTS,G.endDTS=M.endDTS,G.minEndPTS=M.minEndPTS,G.duration=M.endPTS-M.startPTS,G.duration&&(d=G),l.PTSKnown=l.alignedSliding=!0),G.elementaryStreams=M.elementaryStreams,G.loader=M.loader,G.stats=M.stats,G.urlId=M.urlId,M.initSegment&&(G.initSegment=M.initSegment,E=M.initSegment)}),E){var c=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments;c.forEach(function(M){var G;(!M.initSegment||M.initSegment.relurl===((G=E)===null||G===void 0?void 0:G.relurl))&&(M.initSegment=E)})}if(l.skippedSegments&&(l.deltaUpdateFailed=l.fragments.some(function(M){return!M}),l.deltaUpdateFailed)){I.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=l.skippedSegments;h--;)l.fragments.shift();l.startSN=l.fragments[0].sn,l.startCC=l.fragments[0].cc}var a=l.fragments;if(g){I.logger.warn("discontinuity sliding from playlist, take drift into account");for(var x=0;x<a.length;x++)a[x].cc+=g}l.skippedSegments&&(l.startCC=l.fragments[0].cc),T(s.partList,l.partList,function(M,G){G.elementaryStreams=M.elementaryStreams,G.stats=M.stats}),d?O(l,d,d.startPTS,d.endPTS,d.startDTS,d.endDTS):A(s,l),a.length&&(l.totalduration=l.edge-a[0].start),l.driftStartTime=s.driftStartTime,l.driftStart=s.driftStart;var p=l.advancedDateTime;if(l.advanced&&p){var b=l.edge;l.driftStart||(l.driftStartTime=p,l.driftStart=b),l.driftEndTime=p,l.driftEnd=b}else l.driftEndTime=s.driftEndTime,l.driftEnd=s.driftEnd,l.advancedDateTime=s.advancedDateTime}function T(s,l,E){if(s&&l)for(var m=0,f=0,L=s.length;f<=L;f++){var g=s[f],d=l[f+m];g&&d&&g.index===d.index&&g.fragment.sn===d.fragment.sn?E(g,d):m--}}function R(s,l,E){for(var m=l.skippedSegments,f=Math.max(s.startSN,l.startSN)-l.startSN,L=(s.fragmentHint?1:0)+(m?l.endSN:Math.min(s.endSN,l.endSN))-l.startSN,g=l.startSN-s.startSN,d=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,c=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments,h=f;h<=L;h++){var a=c[g+h],x=d[h];m&&!x&&h<m&&(x=l.fragments[h]=a),a&&x&&E(a,x)}}function A(s,l){var E=l.startSN+l.skippedSegments-s.startSN,m=s.fragments;if(E<0||E>=m.length)return;C(l,m[E].start)}function C(s,l){if(l){for(var E=s.fragments,m=s.skippedSegments;m<E.length;m++)E[m].start+=l;s.fragmentHint&&(s.fragmentHint.start+=l)}}function S(s,l){var E=1e3*s.levelTargetDuration,m=E/2,f=s.age,L=f>0&&f<E*3,g=l.loading.end-l.loading.start,d,c=s.availabilityDelay;if(s.updated===!1)if(L){var h=333*s.misses;d=Math.max(Math.min(m,g*2),h),s.availabilityDelay=(s.availabilityDelay||0)+d}else d=m;else L?(c=Math.min(c||E/2,f),s.availabilityDelay=c,d=c+E-f):d=E-g;return Math.round(d)}function u(s,l,E){if(!s||!s.details)return null;var m=s.details,f=m.fragments[l-m.startSN];return f||(f=m.fragmentHint,f&&f.sn===l?f:l<m.startSN&&E&&E.sn===l?E:null)}function o(s,l,E){if(!s||!s.details)return null;var m=s.details.partList;if(m)for(var f=m.length;f--;){var L=m[f];if(L.index===E&&L.fragment.sn===l)return L}return null}},"./src/controller/stream-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return m});var $=_("./src/polyfills/number.ts"),I=_("./src/controller/base-stream-controller.ts"),D=_("./src/is-supported.ts"),j=_("./src/events.ts"),U=_("./src/utils/buffer-helper.ts"),P=_("./src/controller/fragment-tracker.ts"),O=_("./src/types/loader.ts"),v=_("./src/loader/fragment.ts"),T=_("./src/demux/transmuxer-interface.ts"),R=_("./src/types/transmuxer.ts"),A=_("./src/controller/gap-controller.ts"),C=_("./src/errors.ts"),S=_("./src/utils/logger.ts");function u(f,L){for(var g=0;g<L.length;g++){var d=L[g];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(f,d.key,d)}}function o(f,L,g){return L&&u(f.prototype,L),g&&u(f,g),f}function s(f,L){f.prototype=Object.create(L.prototype),f.prototype.constructor=f,l(f,L)}function l(f,L){return l=Object.setPrototypeOf||function(d,c){return d.__proto__=c,d},l(f,L)}var E=100,m=function(f){s(L,f);function L(d,c){var h;return h=f.call(this,d,c,"[stream-controller]")||this,h.audioCodecSwap=!1,h.gapController=null,h.level=-1,h._forceStartLoad=!1,h.altAudio=!1,h.audioOnly=!1,h.fragPlaying=null,h.onvplaying=null,h.onvseeked=null,h.fragLastKbps=0,h.stalled=!1,h.couldBacktrack=!1,h.audioCodecSwitch=!1,h.videoBuffer=null,h._registerListeners(),h}var g=L.prototype;return g._registerListeners=function(){var c=this.hls;c.on(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.on(j.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(j.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.on(j.Events.ERROR,this.onError,this),c.on(j.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(j.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.on(j.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(j.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(j.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.on(j.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g._unregisterListeners=function(){var c=this.hls;c.off(j.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(j.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(j.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(j.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.off(j.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(j.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.off(j.Events.ERROR,this.onError,this),c.off(j.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(j.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.off(j.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(j.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(j.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.off(j.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},g.startLoad=function(c){if(this.levels){var h=this.lastCurrentTime,a=this.hls;if(this.stopLoad(),this.setInterval(E),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var x=a.startLevel;x===-1&&(a.config.testBandwidth?(x=0,this.bitrateTest=!0):x=a.nextAutoLevel),this.level=a.nextLoadLevel=x,this.loadedmetadata=!1}h>0&&c===-1&&(this.log("Override startPosition with lastCurrentTime @"+h.toFixed(3)),c=h),this.state=I.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()}else this._forceStartLoad=!0,this.state=I.State.STOPPED},g.stopLoad=function(){this._forceStartLoad=!1,f.prototype.stopLoad.call(this)},g.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_LEVEL:{var c,h=this.levels,a=this.level,x=h==null||((c=h[a])===null||c===void 0)?void 0:c.details;if(x&&(!x.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(x))break;this.state=I.State.IDLE;break}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var p,b=self.performance.now(),M=this.retryDate;(!M||b>=M||(p=this.media)!==null&&p!==void 0&&p.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=I.State.IDLE)}break;default:break}this.onTickEnd()},g.onTickEnd=function(){f.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},g.doTickIdle=function(){var c,h,a=this.hls,x=this.levelLastLoaded,p=this.levels,b=this.media,M=a.config,G=a.nextLoadLevel;if(x===null||!b&&(this.startFragRequested||!M.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!p||!p[G])return;var Z=p[G];this.level=a.nextLoadLevel=G;var ie=Z.details;if(!ie||this.state===I.State.WAITING_LEVEL||ie.live&&this.levelLastLoaded!==G){this.state=I.State.WAITING_LEVEL;return}var z=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:b,O.PlaylistLevelType.MAIN);if(z===null)return;var F=z.len,ne=this.getMaxBufferLength(Z.maxBitrate);if(F>=ne)return;if(this._streamEnded(z,ie)){var ce={};this.altAudio&&(ce.type="video"),this.hls.trigger(j.Events.BUFFER_EOS,ce),this.state=I.State.ENDED;return}var ge=z.end,xe=this.getNextFragment(ge,ie);if(this.couldBacktrack&&!this.fragPrevious&&xe&&xe.sn!=="initSegment"){var Me=xe.sn-ie.startSN;Me>1&&(xe=ie.fragments[Me-1],this.fragmentTracker.removeFragment(xe))}if(xe&&this.fragmentTracker.getState(xe)===P.FragmentState.OK&&this.nextLoadPosition>ge){var Te=this.audioOnly&&!this.altAudio?v.ElementaryStreamTypes.AUDIO:v.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(b,Te,O.PlaylistLevelType.MAIN),xe=this.getNextFragment(this.nextLoadPosition,ie)}if(!xe)return;xe.initSegment&&!xe.initSegment.data&&!this.bitrateTest&&(xe=xe.initSegment),((c=xe.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((h=xe.decryptdata)!==null&&h!==void 0&&h.key)?this.loadKey(xe,ie):this.loadFragment(xe,ie,ge)},g.loadFragment=function(c,h,a){var x,p=this.fragmentTracker.getState(c);if(this.fragCurrent=c,p===P.FragmentState.BACKTRACKED){var b=this.fragmentTracker.getBacktrackData(c);if(b){this._handleFragmentLoadProgress(b),this._handleFragmentLoadComplete(b);return}else p=P.FragmentState.NOT_LOADED}p===P.FragmentState.NOT_LOADED||p===P.FragmentState.PARTIAL?c.sn==="initSegment"?this._loadInitSegment(c):this.bitrateTest?(c.bitrateTest=!0,this.log("Fragment "+c.sn+" of level "+c.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(c)):(this.startFragRequested=!0,f.prototype.loadFragment.call(this,c,h,a)):p===P.FragmentState.APPENDING?this.reduceMaxBufferLength(c.duration)&&this.fragmentTracker.removeFragment(c):((x=this.media)===null||x===void 0?void 0:x.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},g.getAppendedFrag=function(c){var h=this.fragmentTracker.getAppendedFrag(c,O.PlaylistLevelType.MAIN);return h&&"fragment"in h?h.fragment:h},g.getBufferedFrag=function(c){return this.fragmentTracker.getBufferedFrag(c,O.PlaylistLevelType.MAIN)},g.followingBufferedFrag=function(c){return c?this.getBufferedFrag(c.end+.5):null},g.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},g.nextLevelSwitch=function(){var c=this.levels,h=this.media;if(h!=null&&h.readyState){var a,x=this.getAppendedFrag(h.currentTime);if(x&&x.start>1&&this.flushMainBuffer(0,x.start-1),!h.paused&&c){var p=this.hls.nextLoadLevel,b=c[p],M=this.fragLastKbps;M&&this.fragCurrent?a=this.fragCurrent.duration*b.maxBitrate/(1e3*M)+1:a=0}else a=0;var G=this.getBufferedFrag(h.currentTime+a);if(G){var Z=this.followingBufferedFrag(G);if(Z){this.abortCurrentFrag();var ie=Z.maxStartPTS?Z.maxStartPTS:Z.start,z=Z.duration,F=Math.max(G.end,ie+Math.min(Math.max(z-this.config.maxFragLookUpTolerance,z*.5),z*.75));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},g.abortCurrentFrag=function(){var c=this.fragCurrent;this.fragCurrent=null,c!=null&&c.loader&&c.loader.abort(),this.state===I.State.KEY_LOADING&&(this.state=I.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},g.flushMainBuffer=function(c,h){f.prototype.flushMainBuffer.call(this,c,h,this.altAudio?"video":null)},g.onMediaAttached=function(c,h){f.prototype.onMediaAttached.call(this,c,h);var a=h.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 A.default(this.config,a,this.fragmentTracker,this.hls)},g.onMediaDetaching=function(){var c=this.media;c&&(c.removeEventListener("playing",this.onvplaying),c.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),f.prototype.onMediaDetaching.call(this)},g.onMediaPlaying=function(){this.tick()},g.onMediaSeeked=function(){var c=this.media,h=c?c.currentTime:null;Object($.isFiniteNumber)(h)&&this.log("Media seeked to "+h.toFixed(3)),this.tick()},g.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(j.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},g.onManifestParsed=function(c,h){var a=!1,x=!1,p;h.levels.forEach(function(b){p=b.audioCodec,p&&(p.indexOf("mp4a.40.2")!==-1&&(a=!0),p.indexOf("mp4a.40.5")!==-1&&(x=!0))}),this.audioCodecSwitch=a&&x&&!Object(D.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=h.levels,this.startFragRequested=!1},g.onLevelLoading=function(c,h){var a=this.levels;if(!a||this.state!==I.State.IDLE)return;var x=a[h.level];(!x.details||x.details.live&&this.levelLastLoaded!==h.level||this.waitForCdnTuneIn(x.details))&&(this.state=I.State.WAITING_LEVEL)},g.onLevelLoaded=function(c,h){var a,x=this.levels,p=h.level,b=h.details,M=b.totalduration;if(!x){this.warn("Levels were reset while loading level "+p);return}this.log("Level "+p+" loaded ["+b.startSN+","+b.endSN+"], cc ["+b.startCC+", "+b.endCC+"] duration:"+M);var G=this.fragCurrent;G&&(this.state===I.State.FRAG_LOADING||this.state===I.State.FRAG_LOADING_WAITING_RETRY)&&(G.level!==h.level&&G.loader&&(this.state=I.State.IDLE,G.loader.abort()));var Z=x[p],ie=0;if(b.live||(a=Z.details)!==null&&a!==void 0&&a.live){if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed)return;ie=this.alignPlaylists(b,Z.details)}if(Z.details=b,this.levelLastLoaded=p,this.hls.trigger(j.Events.LEVEL_UPDATED,{details:b,level:p}),this.state===I.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(b))return;this.state=I.State.IDLE}this.startFragRequested?b.live&&this.synchronizeToLiveEdge(b):this.setStartPosition(b,ie),this.tick()},g._handleFragmentLoadProgress=function(c){var h,a=c.frag,x=c.part,p=c.payload,b=this.levels;if(!b){this.warn("Levels were reset while fragment load was in progress. Fragment "+a.sn+" of level "+a.level+" will not be buffered");return}var M=b[a.level],G=M.details;if(!G){this.warn("Dropping fragment "+a.sn+" of level "+a.level+" after level details were reset");return}var Z=M.videoCodec,ie=G.PTSKnown||!G.live,z=(h=a.initSegment)===null||h===void 0?void 0:h.data,F=this._getAudioCodec(M),ne=this.transmuxer=this.transmuxer||new T.default(this.hls,O.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),ce=x?x.index:-1,ge=ce!==-1,xe=new R.ChunkMetadata(a.level,a.sn,a.stats.chunkCount,p.byteLength,ce,ge),Me=this.initPTS[a.cc];ne.push(p,z,F,Z,a,x,G.totalduration,ie,xe,Me)},g.onAudioTrackSwitching=function(c,h){var a=this.altAudio,x=!!h.url,p=h.id;if(!x){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var b=this.fragCurrent;b!=null&&b.loader&&(this.log("Switching to main audio track, cancel main fragment load"),b.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var M=this.hls;a&&M.trigger(j.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),M.trigger(j.Events.AUDIO_TRACK_SWITCHED,{id:p})}},g.onAudioTrackSwitched=function(c,h){var a=h.id,x=!!this.hls.audioTracks[a].url;if(x){var p=this.videoBuffer;p&&this.mediaBuffer!==p&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=p)}this.altAudio=x,this.tick()},g.onBufferCreated=function(c,h){var a=h.tracks,x,p,b=!1;for(var M in a){var G=a[M];if(G.id==="main"){if(p=M,x=G,M==="video"){var Z=a[M];Z&&(this.videoBuffer=Z.buffer)}}else b=!0}b&&x?(this.log("Alternate track found, use "+p+".buffered to schedule main fragment loading"),this.mediaBuffer=x.buffer):this.mediaBuffer=this.media},g.onFragBuffered=function(c,h){var a=h.frag,x=h.part;if(a&&a.type!==O.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(a)){this.warn("Fragment "+a.sn+(x?" p: "+x.index:"")+" of level "+a.level+" finished buffering, but was aborted. state: "+this.state),this.state===I.State.PARSED&&(this.state=I.State.IDLE);return}var p=x?x.stats:a.stats;this.fragLastKbps=Math.round(8*p.total/(p.buffering.end-p.loading.first)),a.sn!=="initSegment"&&(this.fragPrevious=a),this.fragBufferedComplete(a,x)},g.onError=function(c,h){switch(h.details){case C.ErrorDetails.FRAG_LOAD_ERROR:case C.ErrorDetails.FRAG_LOAD_TIMEOUT:case C.ErrorDetails.KEY_LOAD_ERROR:case C.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(O.PlaylistLevelType.MAIN,h);break;case C.ErrorDetails.LEVEL_LOAD_ERROR:case C.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==I.State.ERROR&&(h.fatal?(this.warn(""+h.details),this.state=I.State.ERROR):!h.levelRetry&&this.state===I.State.WAITING_LEVEL&&(this.state=I.State.IDLE));break;case C.ErrorDetails.BUFFER_FULL_ERROR:if(h.parent==="main"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var a=!0,x=this.getFwdBufferInfo(this.media,O.PlaylistLevelType.MAIN);x&&x.len>.5&&(a=!this.reduceMaxBufferLength(x.len)),a&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},g.checkBuffer=function(){var c=this.media,h=this.gapController;if(!c||!h||!c.readyState)return;var a=U.BufferHelper.getBuffered(c);!this.loadedmetadata&&a.length?(this.loadedmetadata=!0,this.seekToStartPos()):h.poll(this.lastCurrentTime),this.lastCurrentTime=c.currentTime},g.onFragLoadEmergencyAborted=function(){this.state=I.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},g.onBufferFlushed=function(c,h){var a=h.type;if(a!==v.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var x=(a===v.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(x,a,O.PlaylistLevelType.MAIN)}},g.onLevelsUpdated=function(c,h){this.levels=h.levels},g.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},g.seekToStartPos=function(){var c=this.media,h=c.currentTime,a=this.startPosition;if(a>=0&&h<a){if(c.seeking){S.logger.log("could not seek to "+a+", already seeking at "+h);return}var x=U.BufferHelper.getBuffered(c),p=x.length?x.start(0):0,b=p-a;b>0&&(b<this.config.maxBufferHole||b<this.config.maxFragLookUpTolerance)&&(S.logger.log("adjusting start position by "+b+" to match buffer start"),a+=b,this.startPosition=a),this.log("seek to target start position "+a+" from current time "+h),c.currentTime=a}},g._getAudioCodec=function(c){var h=this.config.defaultAudioCodec||c.audioCodec;return this.audioCodecSwap&&h&&(this.log("Swapping audio codec"),h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5"),h},g._loadBitrateTestFrag=function(c){var h=this;this._doFragLoad(c).then(function(a){var x=h.hls;if(!a||x.nextLoadLevel||h.fragContextChanged(c))return;h.fragLoadError=0,h.state=I.State.IDLE,h.startFragRequested=!1,h.bitrateTest=!1;var p=c.stats;p.parsing.start=p.parsing.end=p.buffering.start=p.buffering.end=self.performance.now(),x.trigger(j.Events.FRAG_LOADED,a)})},g._handleTransmuxComplete=function(c){var h,a="main",x=this.hls,p=c.remuxResult,b=c.chunkMeta,M=this.getCurrentContext(b);if(!M){this.warn("The loading context changed while buffering fragment "+b.sn+" of level "+b.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(b.level);return}var G=M.frag,Z=M.part,ie=M.level,z=p.video,F=p.text,ne=p.id3,ce=p.initSegment,ge=this.altAudio?void 0:p.audio;if(this.fragContextChanged(G))return;if(this.state=I.State.PARSING,ce){ce.tracks&&(this._bufferInitSegment(ie,ce.tracks,G,b),x.trigger(j.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:a,tracks:ce.tracks}));var xe=ce.initPTS,Me=ce.timescale;Object($.isFiniteNumber)(xe)&&(this.initPTS[G.cc]=xe,x.trigger(j.Events.INIT_PTS_FOUND,{frag:G,id:a,initPTS:xe,timescale:Me}))}if(z&&p.independent!==!1){if(ie.details){var Te=z.startPTS,Oe=z.endPTS,Ce=z.startDTS,we=z.endDTS;if(Z)Z.elementaryStreams[z.type]={startPTS:Te,endPTS:Oe,startDTS:Ce,endDTS:we};else if(z.firstKeyFrame&&z.independent&&(this.couldBacktrack=!0),z.dropped&&z.independent){var ve=this.getLoadPosition()+this.config.maxBufferHole;if(ve<Te){this.backtrack(G);return}G.setElementaryStreamInfo(z.type,G.start,Oe,G.start,we,!0)}G.setElementaryStreamInfo(z.type,Te,Oe,Ce,we),this.bufferFragmentData(z,G,Z,b)}}else if(p.independent===!1){this.backtrack(G);return}if(ge){var W=ge.startPTS,w=ge.endPTS,k=ge.startDTS,H=ge.endDTS;Z&&(Z.elementaryStreams[v.ElementaryStreamTypes.AUDIO]={startPTS:W,endPTS:w,startDTS:k,endDTS:H}),G.setElementaryStreamInfo(v.ElementaryStreamTypes.AUDIO,W,w,k,H),this.bufferFragmentData(ge,G,Z,b)}if(ne!=null&&(h=ne.samples)!==null&&h!==void 0&&h.length){var q={frag:G,id:a,samples:ne.samples};x.trigger(j.Events.FRAG_PARSING_METADATA,q)}if(F){var B={frag:G,id:a,samples:F.samples};x.trigger(j.Events.FRAG_PARSING_USERDATA,B)}},g._bufferInitSegment=function(c,h,a,x){var p=this;if(this.state!==I.State.PARSING)return;this.audioOnly=!!h.audio&&!h.video,this.altAudio&&!this.audioOnly&&delete h.audio;var b=h.audio,M=h.video,G=h.audiovideo;if(b){var Z=c.audioCodec,ie=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(Z&&(Z.indexOf("mp4a.40.5")!==-1?Z="mp4a.40.2":Z="mp4a.40.5"),b.metadata.channelCount!==1&&ie.indexOf("firefox")===-1&&(Z="mp4a.40.5")),ie.indexOf("android")!==-1&&b.container!=="audio/mpeg"&&(Z="mp4a.40.2",this.log("Android: force audio codec to "+Z)),c.audioCodec&&c.audioCodec!==Z&&this.log('Swapping manifest audio codec "'+c.audioCodec+'" for "'+Z+'"'),b.levelCodec=Z,b.id="main",this.log("Init audio buffer, container:"+b.container+", codecs[selected/level/parsed]=["+(Z||"")+"/"+(c.audioCodec||"")+"/"+b.codec+"]")}M&&(M.levelCodec=c.videoCodec,M.id="main",this.log("Init video buffer, container:"+M.container+", codecs[level/parsed]=["+(c.videoCodec||"")+"/"+M.codec+"]")),G&&this.log("Init audiovideo buffer, container:"+G.container+", codecs[level/parsed]=["+(c.attrs.CODECS||"")+"/"+G.codec+"]"),this.hls.trigger(j.Events.BUFFER_CODECS,h),Object.keys(h).forEach(function(z){var F=h[z],ne=F.initSegment;ne!=null&&ne.byteLength&&p.hls.trigger(j.Events.BUFFER_APPENDING,{type:z,data:ne,frag:a,part:null,chunkMeta:x,parent:a.type})}),this.tick()},g.backtrack=function(c){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(c);var h=this.fragmentTracker.backtrack(c);this.fragPrevious=null,this.nextLoadPosition=c.start,h?this.resetFragmentLoading(c):this.state=I.State.BACKTRACKING},g.checkFragmentChanged=function(){var c=this.media,h=null;if(c&&c.readyState>1&&c.seeking===!1){var a=c.currentTime;if(U.BufferHelper.isBuffered(c,a)?h=this.getAppendedFrag(a):U.BufferHelper.isBuffered(c,a+.1)&&(h=this.getAppendedFrag(a+.1)),h){var x=this.fragPlaying,p=h.level;(!x||h.sn!==x.sn||x.level!==p||h.urlId!==x.urlId)&&(this.hls.trigger(j.Events.FRAG_CHANGED,{frag:h}),(!x||x.level!==p)&&this.hls.trigger(j.Events.LEVEL_SWITCHED,{level:p}),this.fragPlaying=h)}}},o(L,[{key:"nextLevel",get:function(){var c=this.nextBufferedFrag;return c?c.level:-1}},{key:"currentLevel",get:function(){var c=this.media;if(c){var h=this.getAppendedFrag(c.currentTime);if(h)return h.level}return-1}},{key:"nextBufferedFrag",get:function(){var c=this.media;if(c){var h=this.getAppendedFrag(c.currentTime);return this.followingBufferedFrag(h)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),L}(I.default)},"./src/controller/subtitle-stream-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"SubtitleStreamController",function(){return s});var $=_("./src/events.ts"),I=_("./src/utils/logger.ts"),D=_("./src/utils/buffer-helper.ts"),j=_("./src/controller/fragment-finders.ts"),U=_("./src/utils/discontinuities.ts"),P=_("./src/controller/level-helper.ts"),O=_("./src/controller/fragment-tracker.ts"),v=_("./src/controller/base-stream-controller.ts"),T=_("./src/types/loader.ts"),R=_("./src/types/level.ts");function A(l,E){for(var m=0;m<E.length;m++){var f=E[m];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(l,f.key,f)}}function C(l,E,m){return E&&A(l.prototype,E),m&&A(l,m),l}function S(l,E){l.prototype=Object.create(E.prototype),l.prototype.constructor=l,u(l,E)}function u(l,E){return u=Object.setPrototypeOf||function(f,L){return f.__proto__=L,f},u(l,E)}var o=500,s=function(l){S(E,l);function E(f,L){var g;return g=l.call(this,f,L,"[subtitle-stream-controller]")||this,g.levels=[],g.currentTrackId=-1,g.tracksBuffered=[],g.mainDetails=null,g._registerListeners(),g}var m=E.prototype;return m.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},m._registerListeners=function(){var L=this.hls;L.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.on($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.on($.Events.MANIFEST_LOADING,this.onManifestLoading,this),L.on($.Events.LEVEL_LOADED,this.onLevelLoaded,this),L.on($.Events.ERROR,this.onError,this),L.on($.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),L.on($.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),L.on($.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),L.on($.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),L.on($.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},m._unregisterListeners=function(){var L=this.hls;L.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),L.off($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),L.off($.Events.MANIFEST_LOADING,this.onManifestLoading,this),L.off($.Events.LEVEL_LOADED,this.onLevelLoaded,this),L.off($.Events.ERROR,this.onError,this),L.off($.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),L.off($.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),L.off($.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),L.off($.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),L.off($.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,g){this.mainDetails=g.details},m.onSubtitleFragProcessed=function(L,g){var d=g.frag,c=g.success;if(this.fragPrevious=d,this.state=v.State.IDLE,!c)return;var h=this.tracksBuffered[this.currentTrackId];if(!h)return;for(var a,x=d.start,p=0;p<h.length;p++)if(x>=h[p].start&&x<=h[p].end){a=h[p];break}var b=d.start+d.duration;a?a.end=b:(a={start:x,end:b},h.push(a)),this.fragmentTracker.fragBuffered(d)},m.onBufferFlushing=function(L,g){var d=g.startOffset,c=g.endOffset;if(d===0&&c!==Number.POSITIVE_INFINITY){var h=this.currentTrackId,a=this.levels;if(!a.length||!a[h]||!a[h].details)return;var x=a[h].details,p=x.targetduration,b=c-p;if(b<=0)return;g.endOffsetSubtitles=Math.max(0,b),this.tracksBuffered.forEach(function(M){for(var G=0;G<M.length;){if(M[G].end<=b){M.shift();continue}else if(M[G].start<b)M[G].start=b;else break;G++}}),this.fragmentTracker.removeFragmentsInRange(d,b,T.PlaylistLevelType.SUBTITLE)}},m.onError=function(L,g){var d,c=g.frag;if(!c||c.type!==T.PlaylistLevelType.SUBTITLE)return;(d=this.fragCurrent)!==null&&d!==void 0&&d.loader&&this.fragCurrent.loader.abort(),this.state=v.State.IDLE},m.onSubtitleTracksUpdated=function(L,g){var d=this,c=g.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(h){return new R.Level(h)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(h){d.tracksBuffered[h.id]=[]}),this.mediaBuffer=null},m.onSubtitleTrackSwitch=function(L,g){if(this.currentTrackId=g.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var d=this.levels[this.currentTrackId];d!=null&&d.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,d&&this.setInterval(o)},m.onSubtitleTrackLoaded=function(L,g){var d,c=g.details,h=g.id,a=this.currentTrackId,x=this.levels;if(!x.length)return;var p=x[a];if(h>=x.length||h!==a||!p)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(d=p.details)!==null&&d!==void 0&&d.live){var b=this.mainDetails;if(c.deltaUpdateFailed||!b)return;var M=b.fragments[0];if(!p.details)c.hasProgramDateTime&&b.hasProgramDateTime?Object(U.alignMediaPlaylistByPDT)(c,b):M&&Object(P.addSliding)(c,M.start);else{var G=this.alignPlaylists(c,p.details);G===0&&M&&Object(P.addSliding)(c,M.start)}}if(p.details=c,this.levelLastLoaded=h,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===v.State.IDLE){var Z=Object(j.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);Z||(this.warn("Subtitle playlist not aligned with playback"),p.details=void 0)}},m._handleFragmentLoadComplete=function(L){var g=L.frag,d=L.payload,c=g.decryptdata,h=this.hls;if(this.fragContextChanged(g))return;if(d&&d.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(d),c.key.buffer,c.iv.buffer).then(function(x){var p=performance.now();h.trigger($.Events.FRAG_DECRYPTED,{frag:g,payload:x,stats:{tstart:a,tdecrypt:p}})})}},m.doTick=function(){if(!this.media){this.state=v.State.IDLE;return}if(this.state===v.State.IDLE){var L,g=this.currentTrackId,d=this.levels;if(!d.length||!d[g]||!d[g].details)return;var c=d[g].details,h=c.targetduration,a=this.config,x=this.media,p=D.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,x.currentTime-h,a.maxBufferHole),b=p.end,M=p.len,G=this.getMaxBufferLength()+h;if(M>G)return;console.assert(c,"Subtitle track details are defined on idle subtitle stream controller tick");var Z=c.fragments,ie=Z.length,z=c.edge,F,ne=this.fragPrevious;if(b<z){var ce=a.maxFragLookUpTolerance;ne&&c.hasProgramDateTime&&(F=Object(j.findFragmentByPDT)(Z,ne.endProgramDateTime,ce)),F||(F=Object(j.findFragmentByPTS)(ne,Z,b,ce),!F&&ne&&ne.start<Z[0].start&&(F=Z[0]))}else F=Z[ie-1];(L=F)!==null&&L!==void 0&&L.encrypted?(I.logger.log("Loading key for "+F.sn),this.state=v.State.KEY_LOADING,this.hls.trigger($.Events.KEY_LOADING,{frag:F})):F&&this.fragmentTracker.getState(F)===O.FragmentState.NOT_LOADED&&this.loadFragment(F,c,b)}},m.loadFragment=function(L,g,d){this.fragCurrent=L,l.prototype.loadFragment.call(this,L,g,d)},C(E,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),E}(v.default)},"./src/controller/subtitle-track-controller.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/events.ts"),I=_("./src/utils/texttrack-utils.ts"),D=_("./src/controller/base-playlist-controller.ts"),j=_("./src/types/loader.ts");function U(A,C){for(var S=0;S<C.length;S++){var u=C[S];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(A,u.key,u)}}function P(A,C,S){return C&&U(A.prototype,C),S&&U(A,S),A}function O(A,C){A.prototype=Object.create(C.prototype),A.prototype.constructor=A,v(A,C)}function v(A,C){return v=Object.setPrototypeOf||function(u,o){return u.__proto__=o,u},v(A,C)}var T=function(A){O(C,A);function C(u){var o;return o=A.call(this,u,"[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 S=C.prototype;return S.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,A.prototype.destroy.call(this)},S.registerListeners=function(){var o=this.hls;o.on($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on($.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on($.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.on($.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on($.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.on($.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.on($.Events.ERROR,this.onError,this)},S.unregisterListeners=function(){var o=this.hls;o.off($.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off($.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off($.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off($.Events.MANIFEST_PARSED,this.onManifestParsed,this),o.off($.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off($.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),o.off($.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),o.off($.Events.ERROR,this.onError,this)},S.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)},S.pollTrackChange=function(o){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,o)},S.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=R(this.media.textTracks);o.forEach(function(s){Object(I.clearCurrentCues)(s)}),this.subtitleTrack=-1,this.media=null},S.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},S.onManifestParsed=function(o,s){this.tracks=s.subtitleTracks},S.onSubtitleTrackLoaded=function(o,s){var l=s.id,E=s.details,m=this.trackId,f=this.tracksInGroup[m];if(!f){this.warn("Invalid subtitle track id "+l);return}var L=f.details;f.details=s.details,this.log("subtitle track "+l+" loaded ["+E.startSN+"-"+E.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,L))},S.onLevelLoading=function(o,s){this.switchLevel(s.level)},S.onLevelSwitching=function(o,s){this.switchLevel(s.level)},S.switchLevel=function(o){var s=this.hls.levels[o];if(!(s!=null&&s.textGroupIds))return;var l=s.textGroupIds[s.urlId];if(this.groupId!==l){var E=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,m=this.tracks.filter(function(g){return!l||g.groupId===l});this.tracksInGroup=m;var f=this.findTrackId(E==null?void 0:E.name)||this.findTrackId();this.groupId=l;var L={subtitleTracks:m};this.log("Updating subtitle tracks, "+m.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger($.Events.SUBTITLE_TRACKS_UPDATED,L),f!==-1&&this.setSubtitleTrack(f,E)}},S.findTrackId=function(o){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var E=s[l];if((!this.selectDefaultTrack||E.default)&&(!o||o===E.name))return E.id}return-1},S.onError=function(o,s){if(A.prototype.onError.call(this,o,s),s.fatal||!s.context)return;s.context.type===j.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},S.loadPlaylist=function(o){var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,E=s.groupId,m=s.url;if(o)try{m=o.addDirectives(m)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("Loading subtitle playlist for id "+l),this.hls.trigger($.Events.SUBTITLE_TRACK_LOADING,{url:m,id:l,groupId:E,deliveryDirectives:o||null})}},S.toggleTrackModes=function(o){var s=this,l=this.media,E=this.subtitleDisplay,m=this.trackId;if(!l)return;var f=R(l.textTracks),L=f.filter(function(c){return c.groupId===s.groupId});if(o===-1)[].slice.call(f).forEach(function(c){c.mode="disabled"});else{var g=L[m];g&&(g.mode="disabled")}var d=L[o];d&&(d.mode=E?"showing":"hidden")},S.setSubtitleTrack=function(o,s){var l,E=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=o;return}if(this.trackId!==o&&this.toggleTrackModes(o),this.trackId===o&&(o===-1||(l=E[o])!==null&&l!==void 0&&l.details)||o<-1||o>=E.length)return;this.clearTimer();var m=E[o];if(this.log("Switching to subtitle track "+o),this.trackId=o,m){var f=m.id,L=m.groupId,g=L===void 0?"":L,d=m.name,c=m.type,h=m.url;this.hls.trigger($.Events.SUBTITLE_TRACK_SWITCH,{id:f,groupId:g,name:d,type:c,url:h});var a=this.switchParams(m.url,s==null?void 0:s.details);this.loadPlaylist(a)}else this.hls.trigger($.Events.SUBTITLE_TRACK_SWITCH,{id:o})},S.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var o=-1,s=R(this.media.textTracks),l=0;l<s.length;l++)if(s[l].mode==="hidden")o=l;else if(s[l].mode==="showing"){o=l;break}this.subtitleTrack!==o&&(this.subtitleTrack=o)},P(C,[{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)}}]),C}(D.default);function R(A){for(var C=[],S=0;S<A.length;S++){var u=A[S];u.kind==="subtitles"&&u.label&&C.push(A[S])}return C}J.default=T},"./src/controller/timeline-controller.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"TimelineController",function(){return R});var $=_("./src/polyfills/number.ts"),I=_("./src/events.ts"),D=_("./src/utils/cea-608-parser.ts"),j=_("./src/utils/output-filter.ts"),U=_("./src/utils/webvtt-parser.ts"),P=_("./src/utils/texttrack-utils.ts"),O=_("./src/utils/imsc1-ttml-parser.ts"),v=_("./src/types/loader.ts"),T=_("./src/utils/logger.ts"),R=function(){function u(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=S(),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 l=new j.default(this,"textTrack1"),E=new j.default(this,"textTrack2"),m=new j.default(this,"textTrack3"),f=new j.default(this,"textTrack4");this.cea608Parser1=new D.default(1,l,E),this.cea608Parser2=new D.default(3,m,f)}s.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),s.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),s.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),s.on(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),s.on(I.Events.FRAG_LOADING,this.onFragLoading,this),s.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),s.on(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),s.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),s.on(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),s.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=u.prototype;return o.destroy=function(){var l=this.hls;l.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.off(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.off(I.Events.FRAG_LOADING,this.onFragLoading,this),l.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),l.off(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.off(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.off(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(l,E,m,f,L){for(var g=!1,d=L.length;d--;){var c=L[d],h=C(c[0],c[1],E,m);if(h>=0&&(c[0]=Math.min(c[0],E),c[1]=Math.max(c[1],m),g=!0,h/(m-E)>.5))return}if(g||L.push([E,m]),this.config.renderTextTracksNatively){var a=this.captionsTracks[l];this.Cues.newCue(a,E,m,f)}else{var x=this.Cues.newCue(null,E,m,f);this.hls.trigger(I.Events.CUES_PARSED,{type:"captions",cues:x,track:l})}},o.onInitPtsFound=function(l,E){var m=this,f=E.frag,L=E.id,g=E.initPTS,d=E.timescale,c=this.unparsedVttFrags;L==="main"&&(this.initPTS[f.cc]=g,this.timescale[f.cc]=d),c.length&&(this.unparsedVttFrags=[],c.forEach(function(h){m.onFragLoaded(I.Events.FRAG_LOADED,h)}))},o.getExistingTrack=function(l){var E=this.media;if(E)for(var m=0;m<E.textTracks.length;m++){var f=E.textTracks[m];if(f[l])return f}return null},o.createCaptionsTrack=function(l){this.config.renderTextTracksNatively?this.createNativeTrack(l):this.createNonNativeTrack(l)},o.createNativeTrack=function(l){if(this.captionsTracks[l])return;var E=this.captionsProperties,m=this.captionsTracks,f=this.media,L=E[l],g=L.label,d=L.languageCode,c=this.getExistingTrack(l);if(c)m[l]=c,Object(P.clearCurrentCues)(m[l]),Object(P.sendAddTrackEvent)(m[l],f);else{var h=this.createTextTrack("captions",g,d);h&&(h[l]=!0,m[l]=h)}},o.createNonNativeTrack=function(l){if(this.nonNativeCaptionsTracks[l])return;var E=this.captionsProperties[l];if(!E)return;var m=E.label,f={_id:l,label:m,kind:"captions",default:E.media?!!E.media.default:!1,closedCaptions:E.media};this.nonNativeCaptionsTracks[l]=f,this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[f]})},o.createTextTrack=function(l,E,m){var f=this.media;return f?f.addTextTrack(l,E,m):void 0},o.onMediaAttaching=function(l,E){this.media=E.media,this._cleanTracks()},o.onMediaDetaching=function(){var l=this.captionsTracks;Object.keys(l).forEach(function(E){Object(P.clearCurrentCues)(l[E]),delete l[E]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=S(),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 l=this.media;if(!l)return;var E=l.textTracks;if(E)for(var m=0;m<E.length;m++)Object(P.clearCurrentCues)(E[m])},o.onSubtitleTracksUpdated=function(l,E){var m=this;this.textTracks=[];var f=E.subtitleTracks||[],L=f.some(function(h){return h.textCodec===O.IMSC1_CODEC});if(this.config.enableWebVTT||L&&this.config.enableIMSC1){var g=this.tracks&&f&&this.tracks.length===f.length;if(this.tracks=f||[],this.config.renderTextTracksNatively){var d=this.media?this.media.textTracks:[];this.tracks.forEach(function(h,a){var x;if(a<d.length){for(var p=null,b=0;b<d.length;b++)if(A(d[b],h)){p=d[b];break}p&&(x=p)}x?Object(P.clearCurrentCues)(x):(x=m.createTextTrack("subtitles",h.name,h.lang),x&&(x.mode="disabled")),x&&(x.groupId=h.groupId,m.textTracks.push(x))})}else if(!g&&this.tracks&&this.tracks.length){var c=this.tracks.map(function(h){return{label:h.name,kind:h.type.toLowerCase(),default:h.default,subtitleTrack:h}});this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},o.onManifestLoaded=function(l,E){var m=this;this.config.enableCEA708Captions&&E.captions&&E.captions.forEach(function(f){var L=/(?:CC|SERVICE)([1-4])/.exec(f.instreamId);if(!L)return;var g="textTrack"+L[1],d=m.captionsProperties[g];if(!d)return;d.label=f.name,f.lang&&(d.languageCode=f.lang),d.media=f})},o.onFragLoading=function(l,E){var m=this.cea608Parser1,f=this.cea608Parser2,L=this.lastSn,g=this.lastPartIndex;if(!this.enabled||!(m&&f))return;if(E.frag.type===v.PlaylistLevelType.MAIN){var d,c,h=E.frag.sn,a=(d=E==null||((c=E.part)===null||c===void 0)?void 0:c.index)!=null?d:-1;h===L+1||h===L&&a===g+1||(m.reset(),f.reset()),this.lastSn=h,this.lastPartIndex=a}},o.onFragLoaded=function(l,E){var m=E.frag,f=E.payload,L=this.initPTS,g=this.unparsedVttFrags;if(m.type===v.PlaylistLevelType.SUBTITLE)if(f.byteLength){if(!Object($.isFiniteNumber)(L[m.cc])){g.push(E),L.length&&this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Missing initial subtitle PTS")});return}var d=m.decryptdata;if(d==null||d.key==null||d.method!=="AES-128"){var c=this.tracks[m.level],h=this.vttCCs;h[m.cc]||(h[m.cc]={start:m.start,prevCC:this.prevCC,new:!0},this.prevCC=m.cc),c&&c.textCodec===O.IMSC1_CODEC?this._parseIMSC1(m,f):this._parseVTTs(m,f,h)}}else this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:m,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(l,E){var m=this,f=this.hls;Object(O.parseIMSC1)(E,this.initPTS[l.cc],this.timescale[l.cc],function(L){m._appendCues(L,l.level),f.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:l})},function(L){T.logger.log("Failed to parse IMSC1: "+L),f.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:l,error:L})})},o._parseVTTs=function(l,E,m){var f=this,L=this.hls;Object(U.parseWebVTT)(E,this.initPTS[l.cc],this.timescale[l.cc],m,l.cc,l.start,function(g){f._appendCues(g,l.level),L.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:l})},function(g){f._fallbackToIMSC1(l,E),T.logger.log("Failed to parse VTT cue: "+g),L.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:l,error:g})})},o._fallbackToIMSC1=function(l,E){var m=this,f=this.tracks[l.level];f.textCodec||Object(O.parseIMSC1)(E,this.initPTS[l.cc],this.timescale[l.cc],function(){f.textCodec=O.IMSC1_CODEC,m._parseIMSC1(l,E)},function(){f.textCodec="wvtt"})},o._appendCues=function(l,E){var m=this.hls;if(this.config.renderTextTracksNatively){var f=this.textTracks[E];if(f.mode==="disabled")return;l.forEach(function(d){return Object(P.addCueToTrack)(f,d)})}else{var L=this.tracks[E],g=L.default?"default":"subtitles"+E;m.trigger(I.Events.CUES_PARSED,{type:"subtitles",cues:l,track:g})}},o.onFragDecrypted=function(l,E){var m=E.frag;if(m.type===v.PlaylistLevelType.SUBTITLE){if(!Object($.isFiniteNumber)(this.initPTS[m.cc])){this.unparsedVttFrags.push(E);return}this.onFragLoaded(I.Events.FRAG_LOADED,E)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(l,E){var m=this.cea608Parser1,f=this.cea608Parser2;if(!this.enabled||!(m&&f))return;for(var L=0;L<E.samples.length;L++){var g=E.samples[L].bytes;if(g){var d=this.extractCea608Data(g);m.addData(E.samples[L].pts,d[0]),f.addData(E.samples[L].pts,d[1])}}},o.onBufferFlushing=function(l,E){var m=E.startOffset,f=E.endOffset,L=E.endOffsetSubtitles,g=E.type,d=this.media;if(!d||d.currentTime<f)return;if(!g||g==="video"){var c=this.captionsTracks;Object.keys(c).forEach(function(a){return Object(P.removeCuesInRange)(c[a],m,f)})}if(this.config.renderTextTracksNatively&&(m===0&&L!==void 0)){var h=this.textTracks;Object.keys(h).forEach(function(a){return Object(P.removeCuesInRange)(h[a],m,L)})}},o.extractCea608Data=function(l){for(var E=l[0]&31,m=2,f=[[],[]],L=0;L<E;L++){var g=l[m++],d=127&l[m++],c=127&l[m++],h=(4&g)!==0,a=3&g;if(d===0&&c===0)continue;h&&((a===0||a===1)&&(f[a].push(d),f[a].push(c)))}return f},u}();function A(u,o){return u&&u.label===o.name&&!(u.textTrack1||u.textTrack2)}function C(u,o,s,l){return Math.min(o,l)-Math.max(u,s)}function S(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return $});var $=function(){function I(j,U){this.subtle=void 0,this.aesIV=void 0,this.subtle=j,this.aesIV=U}var D=I.prototype;return D.decrypt=function(U,P){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},P,U)},I}()},"./src/crypt/aes-decryptor.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"removePadding",function(){return I}),_.d(J,"default",function(){return D});var $=_("./src/utils/typed-array.ts");function I(j){var U=j.byteLength,P=U&&new DataView(j.buffer).getUint8(U-1);return P?Object($.sliceUint8)(j,0,U-P):j}var D=function(){function j(){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 U=j.prototype;return U.uint8ArrayToUint32Array_=function(O){for(var v=new DataView(O),T=new Uint32Array(4),R=0;R<4;R++)T[R]=v.getUint32(R*4);return T},U.initTable=function(){var O=this.sBox,v=this.invSBox,T=this.subMix,R=T[0],A=T[1],C=T[2],S=T[3],u=this.invSubMix,o=u[0],s=u[1],l=u[2],E=u[3],m=new Uint32Array(256),f=0,L=0,g=0;for(g=0;g<256;g++)g<128?m[g]=g<<1:m[g]=g<<1^283;for(g=0;g<256;g++){var d=L^L<<1^L<<2^L<<3^L<<4;d=d>>>8^d&255^99,O[f]=d,v[d]=f;var c=m[f],h=m[c],a=m[h],x=m[d]*257^d*16843008;R[f]=x<<24|x>>>8,A[f]=x<<16|x>>>16,C[f]=x<<8|x>>>24,S[f]=x,x=a*16843009^h*65537^c*257^f*16843008,o[d]=x<<24|x>>>8,s[d]=x<<16|x>>>16,l[d]=x<<8|x>>>24,E[d]=x,f?(f=c^m[m[m[a^c]]],L^=m[m[L]]):f=L=1}},U.expandKey=function(O){for(var v=this.uint8ArrayToUint32Array_(O),T=!0,R=0;R<v.length&&T;)T=v[R]===this.key[R],R++;if(T)return;this.key=v;var A=this.keySize=v.length;if(A!==4&&A!==6&&A!==8)throw new Error("Invalid aes key size="+A);var C=this.ksRows=(A+6+1)*4,S,u,o=this.keySchedule=new Uint32Array(C),s=this.invKeySchedule=new Uint32Array(C),l=this.sBox,E=this.rcon,m=this.invSubMix,f=m[0],L=m[1],g=m[2],d=m[3],c,h;for(S=0;S<C;S++){if(S<A){c=o[S]=v[S];continue}h=c,S%A===0?(h=h<<8|h>>>24,h=l[h>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[h&255],h^=E[S/A|0]<<24):A>6&&S%A===4&&(h=l[h>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[h&255]),o[S]=c=(o[S-A]^h)>>>0}for(u=0;u<C;u++)S=C-u,u&3?h=o[S]:h=o[S-4],u<4||S<=4?s[u]=h:s[u]=f[l[h>>>24]]^L[l[h>>>16&255]]^g[l[h>>>8&255]]^d[l[h&255]],s[u]=s[u]>>>0},U.networkToHostOrderSwap=function(O){return O<<24|(O&65280)<<8|(O&16711680)>>8|O>>>24},U.decrypt=function(O,v,T){for(var R=this.keySize+6,A=this.invKeySchedule,C=this.invSBox,S=this.invSubMix,u=S[0],o=S[1],s=S[2],l=S[3],E=this.uint8ArrayToUint32Array_(T),m=E[0],f=E[1],L=E[2],g=E[3],d=new Int32Array(O),c=new Int32Array(d.length),h,a,x,p,b,M,G,Z,ie,z,F,ne,ce,ge,xe=this.networkToHostOrderSwap;v<d.length;){for(ie=xe(d[v]),z=xe(d[v+1]),F=xe(d[v+2]),ne=xe(d[v+3]),b=ie^A[0],M=ne^A[1],G=F^A[2],Z=z^A[3],ce=4,ge=1;ge<R;ge++)h=u[b>>>24]^o[M>>16&255]^s[G>>8&255]^l[Z&255]^A[ce],a=u[M>>>24]^o[G>>16&255]^s[Z>>8&255]^l[b&255]^A[ce+1],x=u[G>>>24]^o[Z>>16&255]^s[b>>8&255]^l[M&255]^A[ce+2],p=u[Z>>>24]^o[b>>16&255]^s[M>>8&255]^l[G&255]^A[ce+3],b=h,M=a,G=x,Z=p,ce=ce+4;h=C[b>>>24]<<24^C[M>>16&255]<<16^C[G>>8&255]<<8^C[Z&255]^A[ce],a=C[M>>>24]<<24^C[G>>16&255]<<16^C[Z>>8&255]<<8^C[b&255]^A[ce+1],x=C[G>>>24]<<24^C[Z>>16&255]<<16^C[b>>8&255]<<8^C[M&255]^A[ce+2],p=C[Z>>>24]<<24^C[b>>16&255]<<16^C[M>>8&255]<<8^C[G&255]^A[ce+3],c[v]=xe(h^m),c[v+1]=xe(p^f),c[v+2]=xe(x^L),c[v+3]=xe(a^g),m=ie,f=z,L=F,g=ne,v=v+4}return c.buffer},j}()},"./src/crypt/decrypter.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return v});var $=_("./src/crypt/aes-crypto.ts"),I=_("./src/crypt/fast-aes-key.ts"),D=_("./src/crypt/aes-decryptor.ts"),j=_("./src/utils/logger.ts"),U=_("./src/utils/mp4-tools.ts"),P=_("./src/utils/typed-array.ts"),O=16,v=function(){function T(A,C,S){var u=S===void 0?{}:S,o=u.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=A,this.config=C,this.removePKCS7Padding=s,s)try{var l=self.crypto;l&&(this.subtle=l.subtle||l.webkitSubtle)}catch(E){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var R=T.prototype;return R.destroy=function(){this.observer=null},R.isSync=function(){return this.config.enableSoftwareAES},R.flush=function(){var C=this.currentResult;if(!C){this.reset();return}var S=new Uint8Array(C);return this.reset(),this.removePKCS7Padding?Object(D.removePadding)(S):S},R.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},R.decrypt=function(C,S,u,o){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(C),S,u);var s=this.flush();s&&o(s.buffer)}else this.webCryptoDecrypt(new Uint8Array(C),S,u).then(o)},R.softwareDecrypt=function(C,S,u){var o=this.currentIV,s=this.currentResult,l=this.remainderData;this.logOnce("JS AES decrypt"),l&&(C=Object(U.appendUint8Array)(l,C),this.remainderData=null);var E=this.getValidChunk(C);if(!E.length)return null;o&&(u=o);var m=this.softwareDecrypter;m||(m=this.softwareDecrypter=new D.default),m.expandKey(S);var f=s;return this.currentResult=m.decrypt(E.buffer,0,u),this.currentIV=Object(P.sliceUint8)(E,-16).buffer,f||null},R.webCryptoDecrypt=function(C,S,u){var o=this,s=this.subtle;return(this.key!==S||!this.fastAesKey)&&(this.key=S,this.fastAesKey=new I.default(s,S)),this.fastAesKey.expandKey().then(function(l){if(!s)return Promise.reject(new Error("web crypto not initialized"));var E=new $.default(s,u);return E.decrypt(C.buffer,l)}).catch(function(l){return o.onWebCryptoError(l,C,S,u)})},R.onWebCryptoError=function(C,S,u,o){return j.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",C),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(S,u,o)},R.getValidChunk=function(C){var S=C,u=C.length-C.length%O;return u!==C.length&&(S=Object(P.sliceUint8)(C,0,u),this.remainderData=Object(P.sliceUint8)(C,u)),S},R.logOnce=function(C){if(!this.logEnabled)return;j.logger.log("[decrypter.ts]: "+C),this.logEnabled=!1},T}()},"./src/crypt/fast-aes-key.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return $});var $=function(){function I(j,U){this.subtle=void 0,this.key=void 0,this.subtle=j,this.key=U}var D=I.prototype;return D.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},I}()},"./src/demux/aacdemuxer.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/demux/base-audio-demuxer.ts"),I=_("./src/demux/adts.ts"),D=_("./src/utils/logger.ts"),j=_("./src/demux/id3.ts");function U(v,T){v.prototype=Object.create(T.prototype),v.prototype.constructor=v,P(v,T)}function P(v,T){return P=Object.setPrototypeOf||function(A,C){return A.__proto__=C,A},P(v,T)}var O=function(v){U(T,v);function T(A,C){var S;return S=v.call(this)||this,S.observer=void 0,S.config=void 0,S.observer=A,S.config=C,S}var R=T.prototype;return R.resetInitSegment=function(C,S,u){v.prototype.resetInitSegment.call(this,C,S,u),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:C,duration:u,inputTimeScale:9e4,dropped:0}},T.probe=function(C){if(!C)return!1;for(var S=j.getID3Data(C,0)||[],u=S.length,o=C.length;u<o;u++)if(I.probe(C,u))return D.logger.log("ADTS sync word found !"),!0;return!1},R.canParse=function(C,S){return I.canParse(C,S)},R.appendFrame=function(C,S,u){I.initTrackConfig(C,this.observer,S,u,C.manifestCodec);var o=I.appendFrame(C,S,u,this.initPTS,this.frameIndex);if(o&&o.missing===0)return o},T}($.default);O.minProbeByteLength=9,J.default=O},"./src/demux/adts.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"getAudioConfig",function(){return j}),_.d(J,"isHeaderPattern",function(){return U}),_.d(J,"getHeaderLength",function(){return P}),_.d(J,"getFullFrameLength",function(){return O}),_.d(J,"canGetFrameLength",function(){return v}),_.d(J,"isHeader",function(){return T}),_.d(J,"canParse",function(){return R}),_.d(J,"probe",function(){return A}),_.d(J,"initTrackConfig",function(){return C}),_.d(J,"getFrameDuration",function(){return S}),_.d(J,"parseFrameHeader",function(){return u}),_.d(J,"appendFrame",function(){return o});var $=_("./src/utils/logger.ts"),I=_("./src/errors.ts"),D=_("./src/events.ts");function j(s,l,E,m){var f,L,g,d,c=navigator.userAgent.toLowerCase(),h=m,a=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];f=((l[E+2]&192)>>>6)+1;var x=(l[E+2]&60)>>>2;if(x>a.length-1){s.trigger(D.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+x});return}return g=(l[E+2]&1)<<2,g|=(l[E+3]&192)>>>6,$.logger.log("manifest codec:"+m+", ADTS type:"+f+", samplingIndex:"+x),/firefox/i.test(c)?x>=6?(f=5,d=new Array(4),L=x-3):(f=2,d=new Array(2),L=x):c.indexOf("android")!==-1?(f=2,d=new Array(2),L=x):(f=5,d=new Array(4),m&&(m.indexOf("mp4a.40.29")!==-1||m.indexOf("mp4a.40.5")!==-1)||!m&&x>=6?L=x-3:((m&&m.indexOf("mp4a.40.2")!==-1&&(x>=6&&g===1||/vivaldi/i.test(c))||!m&&g===1)&&(f=2,d=new Array(2)),L=x)),d[0]=f<<3,d[0]|=(x&14)>>1,d[1]|=(x&1)<<7,d[1]|=g<<3,f===5&&(d[1]|=(L&14)>>1,d[2]=(L&1)<<7,d[2]|=2<<2,d[3]=0),{config:d,samplerate:a[x],channelCount:g,codec:"mp4a.40."+f,manifestCodec:h}}function U(s,l){return s[l]===255&&(s[l+1]&246)===240}function P(s,l){return s[l+1]&1?7:9}function O(s,l){return(s[l+3]&3)<<11|s[l+4]<<3|(s[l+5]&224)>>>5}function v(s,l){return l+5<s.length}function T(s,l){return l+1<s.length&&U(s,l)}function R(s,l){return v(s,l)&&U(s,l)&&O(s,l)<=s.length-l}function A(s,l){if(T(s,l)){var E=P(s,l);if(l+E>=s.length)return!1;var m=O(s,l);if(m<=E)return!1;var f=l+m;return f===s.length||T(s,f)}return!1}function C(s,l,E,m,f){if(!s.samplerate){var L=j(l,E,m,f);if(!L)return;s.config=L.config,s.samplerate=L.samplerate,s.channelCount=L.channelCount,s.codec=L.codec,s.manifestCodec=L.manifestCodec,$.logger.log("parsed codec:"+s.codec+", rate:"+L.samplerate+", channels:"+L.channelCount)}}function S(s){return 1024*9e4/s}function u(s,l,E,m,f){var L=P(s,l),g=O(s,l);if(g-=L,g>0){var d=E+m*f;return{headerLength:L,frameLength:g,stamp:d}}}function o(s,l,E,m,f){var L=S(s.samplerate),g=u(l,E,m,f,L);if(g){var d=g.frameLength,c=g.headerLength,h=g.stamp,a=c+d,x=Math.max(0,E+a-l.length),p;x?(p=new Uint8Array(a-c),p.set(l.subarray(E+c,l.length),0)):p=l.subarray(E+c,E+a);var b={unit:p,pts:h};return x||s.samples.push(b),{sample:b,length:a,missing:x}}}},"./src/demux/base-audio-demuxer.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"initPTSFn",function(){return O});var $=_("./src/polyfills/number.ts"),I=_("./src/demux/id3.ts"),D=_("./src/demux/dummy-demuxed-track.ts"),j=_("./src/utils/mp4-tools.ts"),U=_("./src/utils/typed-array.ts"),P=function(){function v(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var T=v.prototype;return T.resetInitSegment=function(A,C,S){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},T.resetTimeStamp=function(){},T.resetContiguity=function(){},T.canParse=function(A,C){return!1},T.appendFrame=function(A,C,S){},T.demux=function(A,C){this.cachedData&&(A=Object(j.appendUint8Array)(this.cachedData,A),this.cachedData=null);var S=I.getID3Data(A,0),u=S?S.length:0,o,s,l=this._audioTrack,E=this._id3Track,m=S?I.getTimeStamp(S):void 0,f=A.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=O(m,C)),S&&S.length>0&&E.samples.push({pts:this.initPTS,dts:this.initPTS,data:S}),s=this.initPTS;u<f;){if(this.canParse(A,u)){var L=this.appendFrame(l,A,u);L?(this.frameIndex++,s=L.sample.pts,u+=L.length,o=u):u=f}else I.canParse(A,u)?(S=I.getID3Data(A,u),E.samples.push({pts:s,dts:s,data:S}),u+=S.length,o=u):u++;if(u===f&&o!==f){var g=Object(U.sliceUint8)(A,o);this.cachedData?this.cachedData=Object(j.appendUint8Array)(this.cachedData,g):this.cachedData=g}}return{audioTrack:l,avcTrack:Object(D.dummyTrack)(),id3Track:E,textTrack:Object(D.dummyTrack)()}},T.demuxSampleAes=function(A,C,S){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},T.flush=function(A){var C=this.cachedData;return C&&(this.cachedData=null,this.demux(C,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(D.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(D.dummyTrack)()}},T.destroy=function(){},v}(),O=function(T,R){return Object($.isFiniteNumber)(T)?T*90:R*9e4};J.default=P},"./src/demux/chunk-cache.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return $});var $=function(){function D(){this.chunks=[],this.dataLength=0}var j=D.prototype;return j.push=function(P){this.chunks.push(P),this.dataLength+=P.length},j.flush=function(){var P=this.chunks,O=this.dataLength,v;if(P.length)P.length===1?v=P[0]:v=I(P,O);else return new Uint8Array(0);return this.reset(),v},j.reset=function(){this.chunks.length=0,this.dataLength=0},D}();function I(D,j){for(var U=new Uint8Array(j),P=0,O=0;O<D.length;O++){var v=D[O];U.set(v,P),P+=v.length}return U}},"./src/demux/dummy-demuxed-track.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"dummyTrack",function(){return $});function $(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/utils/logger.ts"),I=function(){function D(U){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=U,this.bytesAvailable=U.byteLength,this.word=0,this.bitsAvailable=0}var j=D.prototype;return j.loadWord=function(){var P=this.data,O=this.bytesAvailable,v=P.byteLength-O,T=new Uint8Array(4),R=Math.min(4,O);if(R===0)throw new Error("no bytes available");T.set(P.subarray(v,v+R)),this.word=new DataView(T.buffer).getUint32(0),this.bitsAvailable=R*8,this.bytesAvailable-=R},j.skipBits=function(P){var O;this.bitsAvailable>P?(this.word<<=P,this.bitsAvailable-=P):(P-=this.bitsAvailable,O=P>>3,P-=O>>3,this.bytesAvailable-=O,this.loadWord(),this.word<<=P,this.bitsAvailable-=P)},j.readBits=function(P){var O=Math.min(this.bitsAvailable,P),v=this.word>>>32-O;return P>32&&$.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=O,this.bitsAvailable>0?this.word<<=O:this.bytesAvailable>0&&this.loadWord(),O=P-O,O>0&&this.bitsAvailable?v<<O|this.readBits(O):v},j.skipLZ=function(){var P;for(P=0;P<this.bitsAvailable;++P)if((this.word&2147483648>>>P)!==0)return this.word<<=P,this.bitsAvailable-=P,P;return this.loadWord(),P+this.skipLZ()},j.skipUEG=function(){this.skipBits(1+this.skipLZ())},j.skipEG=function(){this.skipBits(1+this.skipLZ())},j.readUEG=function(){var P=this.skipLZ();return this.readBits(P+1)-1},j.readEG=function(){var P=this.readUEG();return 1&P?1+P>>>1:-1*(P>>>1)},j.readBoolean=function(){return this.readBits(1)===1},j.readUByte=function(){return this.readBits(8)},j.readUShort=function(){return this.readBits(16)},j.readUInt=function(){return this.readBits(32)},j.skipScalingList=function(P){for(var O=8,v=8,T,R=0;R<P;R++)v!==0&&(T=this.readEG(),v=(O+T+256)%256),O=v===0?O:v},j.readSPS=function(){var P=0,O=0,v=0,T=0,R,A,C,S=this.readUByte.bind(this),u=this.readBits.bind(this),o=this.readUEG.bind(this),s=this.readBoolean.bind(this),l=this.skipBits.bind(this),E=this.skipEG.bind(this),m=this.skipUEG.bind(this),f=this.skipScalingList.bind(this);S();var L=S();if(u(5),l(3),S(),m(),L===100||L===110||L===122||L===244||L===44||L===83||L===86||L===118||L===128){var g=o();if(g===3&&l(1),m(),m(),l(1),s())for(A=g!==3?8:12,C=0;C<A;C++)s()&&(C<6?f(16):f(64))}m();var d=o();if(d===0)o();else if(d===1)for(l(1),E(),E(),R=o(),C=0;C<R;C++)E();m(),l(1);var c=o(),h=o(),a=u(1);a===0&&l(1),l(1),s()&&(P=o(),O=o(),v=o(),T=o());var x=[1,1];if(s()&&s()){var p=S();switch(p){case 1:x=[1,1];break;case 2:x=[12,11];break;case 3:x=[10,11];break;case 4:x=[16,11];break;case 5:x=[40,33];break;case 6:x=[24,11];break;case 7:x=[20,11];break;case 8:x=[32,11];break;case 9:x=[80,33];break;case 10:x=[18,11];break;case 11:x=[15,11];break;case 12:x=[64,33];break;case 13:x=[160,99];break;case 14:x=[4,3];break;case 15:x=[3,2];break;case 16:x=[2,1];break;case 255:{x=[S()<<8|S(),S()<<8|S()];break}}}return{width:Math.ceil((c+1)*16-P*2-O*2),height:(2-a)*(h+1)*16-(a?2:4)*(v+T),pixelRatio:x}},j.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},D}();J.default=I},"./src/demux/id3.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"isHeader",function(){return $}),_.d(J,"isFooter",function(){return I}),_.d(J,"getID3Data",function(){return D}),_.d(J,"canParse",function(){return U}),_.d(J,"getTimeStamp",function(){return P}),_.d(J,"isTimeStampFrame",function(){return O}),_.d(J,"getID3Frames",function(){return T}),_.d(J,"decodeFrame",function(){return R}),_.d(J,"utf8ArrayToStr",function(){return o}),_.d(J,"testables",function(){return s});var $=function(f,L){return L+10<=f.length&&(f[L]===73&&f[L+1]===68&&f[L+2]===51&&(f[L+3]<255&&f[L+4]<255&&(f[L+6]<128&&f[L+7]<128&&f[L+8]<128&&f[L+9]<128)))},I=function(f,L){return L+10<=f.length&&(f[L]===51&&f[L+1]===68&&f[L+2]===73&&(f[L+3]<255&&f[L+4]<255&&(f[L+6]<128&&f[L+7]<128&&f[L+8]<128&&f[L+9]<128)))},D=function(f,L){for(var g=L,d=0;$(f,L);){d+=10;var c=j(f,L+6);d+=c,I(f,L+10)&&(d+=10),L+=d}return d>0?f.subarray(g,g+d):void 0},j=function(f,L){var g=0;return g=(f[L]&127)<<21,g|=(f[L+1]&127)<<14,g|=(f[L+2]&127)<<7,g|=f[L+3]&127,g},U=function(f,L){return $(f,L)&&j(f,L+6)+10<=f.length-L},P=function(f){for(var L=T(f),g=0;g<L.length;g++){var d=L[g];if(O(d))return u(d)}return},O=function(f){return f&&f.key==="PRIV"&&f.info==="com.apple.streaming.transportStreamTimestamp"},v=function(f){var L=String.fromCharCode(f[0],f[1],f[2],f[3]),g=j(f,4),d=10;return{type:L,size:g,data:f.subarray(d,d+g)}},T=function(f){for(var L=0,g=[];$(f,L);){var d=j(f,L+6);L+=10;for(var c=L+d;L+8<c;){var h=v(f.subarray(L)),a=R(h);a&&g.push(a),L+=h.size+10}I(f,L)&&(L+=10)}return g},R=function(f){return f.type==="PRIV"?A(f):f.type[0]==="W"?S(f):C(f)},A=function(f){if(f.size<2)return;var L=o(f.data,!0),g=new Uint8Array(f.data.subarray(L.length+1));return{key:f.type,info:L,data:g.buffer}},C=function(f){if(f.size<2)return;if(f.type==="TXXX"){var L=1,g=o(f.data.subarray(L),!0);L+=g.length+1;var d=o(f.data.subarray(L));return{key:f.type,info:g,data:d}}var c=o(f.data.subarray(1));return{key:f.type,data:c}},S=function(f){if(f.type==="WXXX"){if(f.size<2)return;var L=1,g=o(f.data.subarray(L),!0);L+=g.length+1;var d=o(f.data.subarray(L));return{key:f.type,info:g,data:d}}var c=o(f.data);return{key:f.type,data:c}},u=function(f){if(f.data.byteLength===8){var L=new Uint8Array(f.data),g=L[3]&1,d=(L[4]<<23)+(L[5]<<15)+(L[6]<<7)+L[7];return d/=45,g&&(d+=4772185884e-2),Math.round(d)}return},o=function(f,L){L===void 0&&(L=!1);var g=E();if(g){var d=g.decode(f);if(L){var c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}for(var h=f.length,a,x,p,b="",M=0;M<h;){if(a=f[M++],a===0&&L)return b;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:b+=String.fromCharCode(a);break;case 12:case 13:x=f[M++],b+=String.fromCharCode((a&31)<<6|x&63);break;case 14:x=f[M++],p=f[M++],b+=String.fromCharCode((a&15)<<12|(x&63)<<6|(p&63)<<0);break;default:}}return b},s={decodeTextFrame:C},l;function E(){return!l&&typeof self.TextDecoder!="undefined"&&(l=new self.TextDecoder("utf-8")),l}},"./src/demux/mp3demuxer.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/demux/base-audio-demuxer.ts"),I=_("./src/demux/id3.ts"),D=_("./src/utils/logger.ts"),j=_("./src/demux/mpegaudio.ts");function U(v,T){v.prototype=Object.create(T.prototype),v.prototype.constructor=v,P(v,T)}function P(v,T){return P=Object.setPrototypeOf||function(A,C){return A.__proto__=C,A},P(v,T)}var O=function(v){U(T,v);function T(){return v.apply(this,arguments)||this}var R=T.prototype;return R.resetInitSegment=function(C,S,u){v.prototype.resetInitSegment.call(this,C,S,u),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:C,duration:u,inputTimeScale:9e4,dropped:0}},T.probe=function(C){if(!C)return!1;for(var S=I.getID3Data(C,0)||[],u=S.length,o=C.length;u<o;u++)if(j.probe(C,u))return D.logger.log("MPEG Audio sync word found !"),!0;return!1},R.canParse=function(C,S){return j.canParse(C,S)},R.appendFrame=function(C,S,u){return this.initPTS===null?void 0:j.appendFrame(C,S,u,this.initPTS,this.frameIndex)},T}($.default);O.minProbeByteLength=4,J.default=O},"./src/demux/mp4demuxer.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/utils/mp4-tools.ts"),I=_("./src/demux/dummy-demuxed-track.ts"),D=function(){function j(P,O){this.remainderData=null,this.config=void 0,this.config=O}var U=j.prototype;return U.resetTimeStamp=function(){},U.resetInitSegment=function(){},U.resetContiguity=function(){},j.probe=function(O){return Object($.findBox)({data:O,start:0,end:Math.min(O.length,16384)},["moof"]).length>0},U.demux=function(O){var v=O,T=Object(I.dummyTrack)();if(this.config.progressive){this.remainderData&&(v=Object($.appendUint8Array)(this.remainderData,O));var R=Object($.segmentValidRange)(v);this.remainderData=R.remainder,T.samples=R.valid||new Uint8Array}else T.samples=v;return{audioTrack:Object(I.dummyTrack)(),avcTrack:T,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},U.flush=function(){var O=Object(I.dummyTrack)();return O.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(I.dummyTrack)(),avcTrack:O,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},U.demuxSampleAes=function(O,v,T){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},U.destroy=function(){},j}();D.minProbeByteLength=1024,J.default=D},"./src/demux/mpegaudio.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"appendFrame",function(){return P}),_.d(J,"parseHeader",function(){return O}),_.d(J,"isHeaderPattern",function(){return v}),_.d(J,"isHeader",function(){return T}),_.d(J,"canParse",function(){return R}),_.d(J,"probe",function(){return A});var $=null,I=[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],D=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],j=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],U=[0,1,1,4];function P(C,S,u,o,s){if(u+24>S.length)return;var l=O(S,u);if(l&&u+l.frameLength<=S.length){var E=l.samplesPerFrame*9e4/l.sampleRate,m=o+s*E,f={unit:S.subarray(u,u+l.frameLength),pts:m,dts:m};return C.config=[],C.channelCount=l.channelCount,C.samplerate=l.sampleRate,C.samples.push(f),{sample:f,length:l.frameLength,missing:0}}}function O(C,S){var u=C[S+1]>>3&3,o=C[S+1]>>1&3,s=C[S+2]>>4&15,l=C[S+2]>>2&3;if(u!==1&&s!==0&&s!==15&&l!==3){var E=C[S+2]>>1&1,m=C[S+3]>>6,f=u===3?3-o:o===3?3:4,L=I[f*14+s-1]*1e3,g=u===3?0:u===2?1:2,d=D[g*3+l],c=m===3?1:2,h=j[u][o],a=U[o],x=h*8*a,p=Math.floor(h*L/d+E)*a;if($===null){var b=navigator.userAgent||"",M=b.match(/Chrome\/(\d+)/i);$=M?parseInt(M[1]):0}var G=!!$&&$<=87;return G&&o===2&&L>=224e3&&m===0&&(C[S+3]=C[S+3]|128),{sampleRate:d,channelCount:c,frameLength:p,samplesPerFrame:x}}}function v(C,S){return C[S]===255&&(C[S+1]&224)===224&&(C[S+1]&6)!==0}function T(C,S){return S+1<C.length&&v(C,S)}function R(C,S){var u=4;return v(C,S)&&u<=C.length-S}function A(C,S){if(S+1<C.length&&v(C,S)){var u=4,o=O(C,S),s=u;o!=null&&o.frameLength&&(s=o.frameLength);var l=S+s;return l===C.length||T(C,l)}return!1}},"./src/demux/sample-aes.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/crypt/decrypter.ts"),I=_("./src/demux/tsdemuxer.ts"),D=function(){function j(P,O,v){this.keyData=void 0,this.decrypter=void 0,this.keyData=v,this.decrypter=new $.default(P,O,{removePKCS7Padding:!1})}var U=j.prototype;return U.decryptBuffer=function(O,v){this.decrypter.decrypt(O,this.keyData.key.buffer,this.keyData.iv.buffer,v)},U.decryptAacSample=function(O,v,T,R){var A=O[v].unit,C=A.subarray(16,A.length-A.length%16),S=C.buffer.slice(C.byteOffset,C.byteOffset+C.length),u=this;this.decryptBuffer(S,function(o){var s=new Uint8Array(o);A.set(s,16),R||u.decryptAacSamples(O,v+1,T)})},U.decryptAacSamples=function(O,v,T){for(;;v++){if(v>=O.length){T();return}if(O[v].unit.length<32)continue;var R=this.decrypter.isSync();if(this.decryptAacSample(O,v,T,R),!R)return}},U.getAvcEncryptedData=function(O){for(var v=Math.floor((O.length-48)/160)*16+16,T=new Int8Array(v),R=0,A=32;A<=O.length-16;A+=160,R+=16)T.set(O.subarray(A,A+16),R);return T},U.getAvcDecryptedUnit=function(O,v){for(var T=new Uint8Array(v),R=0,A=32;A<=O.length-16;A+=160,R+=16)O.set(T.subarray(R,R+16),A);return O},U.decryptAvcSample=function(O,v,T,R,A,C){var S=Object(I.discardEPB)(A.data),u=this.getAvcEncryptedData(S),o=this;this.decryptBuffer(u.buffer,function(s){A.data=o.getAvcDecryptedUnit(S,s),C||o.decryptAvcSamples(O,v,T+1,R)})},U.decryptAvcSamples=function(O,v,T,R){if(O instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;v++,T=0){if(v>=O.length){R();return}for(var A=O[v].units;!(T>=A.length);T++){var C=A[T];if(C.data.length<=48||C.type!==1&&C.type!==5)continue;var S=this.decrypter.isSync();if(this.decryptAvcSample(O,v,T,R,C,S),!S)return}}},j}();J.default=D},"./src/demux/transmuxer-interface.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return A});var $=_("./node_modules/webworkify-webpack/index.js"),I=_.n($),D=_("./src/events.ts"),j=_("./src/demux/transmuxer.ts"),U=_("./src/utils/logger.ts"),P=_("./src/errors.ts"),O=_("./src/utils/mediasource-helper.ts"),v=_("./node_modules/eventemitter3/index.js"),T=_.n(v),R=Object(O.getMediaSource)()||{isTypeSupported:function(){return!1}},A=function(){function C(u,o,s,l){var E=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=u,this.id=o,this.onTransmuxComplete=s,this.onFlush=l;var m=u.config,f=function(h,a){a=a||{},a.frag=E.frag,a.id=E.id,u.trigger(h,a)};this.observer=new v.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,f),this.observer.on(D.Events.ERROR,f);var L={mp4:R.isTypeSupported("video/mp4"),mpeg:R.isTypeSupported("audio/mpeg"),mp3:R.isTypeSupported('audio/mp4; codecs="mp3"')},g=navigator.vendor;if(m.enableWorker&&typeof Worker!="undefined"){U.logger.log("demuxing in webworker");var d;try{d=this.worker=$("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),d.addEventListener("message",this.onwmsg),d.onerror=function(c){u.trigger(D.Events.ERROR,{type:P.ErrorTypes.OTHER_ERROR,details:P.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},d.postMessage({cmd:"init",typeSupported:L,vendor:g,id:o,config:JSON.stringify(m)})}catch(c){U.logger.warn("Error in worker:",c),U.logger.error("Error while initializing DemuxerWorker, fallback to inline"),d&&self.URL.revokeObjectURL(d.objectURL),this.transmuxer=new j.default(this.observer,L,m,g,o),this.worker=null}}else this.transmuxer=new j.default(this.observer,L,m,g,o)}var S=C.prototype;return S.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 l=this.observer;l&&l.removeAllListeners(),this.observer=null},S.push=function(o,s,l,E,m,f,L,g,d,c){var h=this;d.transmuxing.start=self.performance.now();var a=this.transmuxer,x=this.worker,p=f?f.start:m.start,b=m.decryptdata,M=this.frag,G=!(M&&m.cc===M.cc),Z=!(M&&d.level===M.level),ie=M?d.sn-M.sn:-1,z=this.part?d.part-this.part.index:1,F=!Z&&(ie===1||ie===0&&z===1),ne=self.performance.now();(Z||ie||m.stats.parsing.start===0)&&(m.stats.parsing.start=ne),f&&(z||!F)&&(f.stats.parsing.start=ne);var ce=new j.TransmuxState(G,F,g,Z,p);if(!F||G){U.logger.log("[transmuxer-interface, "+m.type+"]: Starting new transmux session for sn: "+d.sn+" p: "+d.part+" level: "+d.level+" id: "+d.id+`
discontinuity: `+G+`
trackSwitch: `+Z+`
contiguous: `+F+`
accurateTimeOffset: `+g+`
timeOffset: `+p);var ge=new j.TransmuxConfig(l,E,s,L,c);this.configureTransmuxer(ge)}if(this.frag=m,this.part=f,x)x.postMessage({cmd:"demux",data:o,decryptdata:b,chunkMeta:d,state:ce},o instanceof ArrayBuffer?[o]:[]);else if(a){var xe=a.push(o,b,d,ce);Object(j.isPromise)(xe)?xe.then(function(Me){h.handleTransmuxComplete(Me)}):this.handleTransmuxComplete(xe)}},S.flush=function(o){var s=this;o.transmuxing.start=self.performance.now();var l=this.transmuxer,E=this.worker;if(E)E.postMessage({cmd:"flush",chunkMeta:o});else if(l){var m=l.flush(o);Object(j.isPromise)(m)?m.then(function(f){s.handleFlushResult(f,o)}):this.handleFlushResult(m,o)}},S.handleFlushResult=function(o,s){var l=this;o.forEach(function(E){l.handleTransmuxComplete(E)}),this.onFlush(s)},S.onWorkerMessage=function(o){var s=o.data,l=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,l.trigger(s.event,s.data);break}}},S.configureTransmuxer=function(o){var s=this.worker,l=this.transmuxer;s?s.postMessage({cmd:"configure",config:o}):l&&l.configure(o)},S.handleTransmuxComplete=function(o){o.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(o)},C}()},"./src/demux/transmuxer-worker.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return P});var $=_("./src/demux/transmuxer.ts"),I=_("./src/events.ts"),D=_("./src/utils/logger.ts"),j=_("./node_modules/eventemitter3/index.js"),U=_.n(j);function P(A){var C=new j.EventEmitter,S=function(o,s){A.postMessage({event:o,data:s})};C.on(I.Events.FRAG_DECRYPTED,S),C.on(I.Events.ERROR,S),A.addEventListener("message",function(u){var o=u.data;switch(o.cmd){case"init":{var s=JSON.parse(o.config);A.transmuxer=new $.default(C,o.typeSupported,s,o.vendor,o.id),Object(D.enableLogs)(s.debug),S("init",null);break}case"configure":{A.transmuxer.configure(o.config);break}case"demux":{var l=A.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object($.isPromise)(l)?l.then(function(f){O(A,f)}):O(A,l);break}case"flush":{var E=o.chunkMeta,m=A.transmuxer.flush(E);Object($.isPromise)(m)?m.then(function(f){T(A,f,E)}):T(A,m,E);break}default:break}})}function O(A,C){if(R(C.remuxResult))return;var S=[],u=C.remuxResult,o=u.audio,s=u.video;o&&v(S,o),s&&v(S,s),A.postMessage({event:"transmuxComplete",data:C},S)}function v(A,C){C.data1&&A.push(C.data1.buffer),C.data2&&A.push(C.data2.buffer)}function T(A,C,S){C.forEach(function(u){O(A,u)}),A.postMessage({event:"flush",data:S})}function R(A){return!A.audio&&!A.video&&!A.text&&!A.id3&&!A.initSegment}},"./src/demux/transmuxer.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return s}),_.d(J,"isPromise",function(){return m}),_.d(J,"TransmuxConfig",function(){return f}),_.d(J,"TransmuxState",function(){return L});var $=_("./src/events.ts"),I=_("./src/errors.ts"),D=_("./src/crypt/decrypter.ts"),j=_("./src/demux/aacdemuxer.ts"),U=_("./src/demux/mp4demuxer.ts"),P=_("./src/demux/tsdemuxer.ts"),O=_("./src/demux/mp3demuxer.ts"),v=_("./src/remux/mp4-remuxer.ts"),T=_("./src/remux/passthrough-remuxer.ts"),R=_("./src/demux/chunk-cache.ts"),A=_("./src/utils/mp4-tools.ts"),C=_("./src/utils/logger.ts"),S;try{S=self.performance.now.bind(self.performance)}catch(g){C.logger.debug("Unable to use Performance API on this environment"),S=self.Date.now}var u=[{demux:P.default,remux:v.default},{demux:U.default,remux:T.default},{demux:j.default,remux:v.default},{demux:O.default,remux:v.default}],o=1024;u.forEach(function(g){var d=g.demux;o=Math.max(o,d.minProbeByteLength)});var s=function(){function g(c,h,a,x,p){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 R.default,this.observer=c,this.typeSupported=h,this.config=a,this.vendor=x,this.id=p}var d=g.prototype;return d.configure=function(h){this.transmuxConfig=h,this.decrypter&&this.decrypter.reset()},d.push=function(h,a,x,p){var b=this,M=x.transmuxing;M.executeStart=S();var G=new Uint8Array(h),Z=this.cache,ie=this.config,z=this.currentTransmuxState,F=this.transmuxConfig;p&&(this.currentTransmuxState=p);var ne=l(G,a);if(ne&&ne.method==="AES-128"){var ce=this.getDecrypter();if(ie.enableSoftwareAES){var ge=ce.softwareDecrypt(G,ne.key.buffer,ne.iv.buffer);if(!ge)return M.executeEnd=S(),E(x);G=new Uint8Array(ge)}else return this.decryptionPromise=ce.webCryptoDecrypt(G,ne.key.buffer,ne.iv.buffer).then(function(Ee){var Le=b.push(Ee,null,x);return b.decryptionPromise=null,Le}),this.decryptionPromise}var xe=p||z,Me=xe.contiguous,Te=xe.discontinuity,Oe=xe.trackSwitch,Ce=xe.accurateTimeOffset,we=xe.timeOffset,ve=F.audioCodec,W=F.videoCodec,w=F.defaultInitPts,k=F.duration,H=F.initSegmentData;if((Te||Oe)&&this.resetInitSegment(H,ve,W,k),Te&&this.resetInitialTimestamp(w),Me||this.resetContiguity(),this.needsProbing(G,Te,Oe)){if(Z.dataLength){var q=Z.flush();G=Object(A.appendUint8Array)(q,G)}this.configureTransmuxer(G,F)}var B=this.transmux(G,ne,we,Ce,x),he=this.currentTransmuxState;return he.contiguous=!0,he.discontinuity=!1,he.trackSwitch=!1,M.executeEnd=S(),B},d.flush=function(h){var a=this,x=h.transmuxing;x.executeStart=S();var p=this.decrypter,b=this.cache,M=this.currentTransmuxState,G=this.decryptionPromise;if(G)return G.then(function(){return a.flush(h)});var Z=[],ie=M.timeOffset;if(p){var z=p.flush();z&&Z.push(this.push(z,null,h))}var F=b.dataLength;b.reset();var ne=this.demuxer,ce=this.remuxer;if(!ne||!ce)return F>=o&&this.observer.emit($.Events.ERROR,$.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),x.executeEnd=S(),[E(h)];var ge=ne.flush(ie);return m(ge)?ge.then(function(xe){return a.flushRemux(Z,xe,h),Z}):(this.flushRemux(Z,ge,h),Z)},d.flushRemux=function(h,a,x){var p=a.audioTrack,b=a.avcTrack,M=a.id3Track,G=a.textTrack,Z=this.currentTransmuxState,ie=Z.accurateTimeOffset,z=Z.timeOffset;C.logger.log("[transmuxer.ts]: Flushed fragment "+x.sn+(x.part>-1?" p: "+x.part:"")+" of level "+x.level);var F=this.remuxer.remux(p,b,M,G,z,ie,!0,this.id);h.push({remuxResult:F,chunkMeta:x}),x.transmuxing.executeEnd=S()},d.resetInitialTimestamp=function(h){var a=this.demuxer,x=this.remuxer;if(!a||!x)return;a.resetTimeStamp(h),x.resetTimeStamp(h)},d.resetContiguity=function(){var h=this.demuxer,a=this.remuxer;if(!h||!a)return;h.resetContiguity(),a.resetNextTimestamp()},d.resetInitSegment=function(h,a,x,p){var b=this.demuxer,M=this.remuxer;if(!b||!M)return;b.resetInitSegment(a,x,p),M.resetInitSegment(h,a,x)},d.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},d.transmux=function(h,a,x,p,b){var M;return a&&a.method==="SAMPLE-AES"?M=this.transmuxSampleAes(h,a,x,p,b):M=this.transmuxUnencrypted(h,x,p,b),M},d.transmuxUnencrypted=function(h,a,x,p){var b=this.demuxer.demux(h,a,!1,!this.config.progressive),M=b.audioTrack,G=b.avcTrack,Z=b.id3Track,ie=b.textTrack,z=this.remuxer.remux(M,G,Z,ie,a,x,!1,this.id);return{remuxResult:z,chunkMeta:p}},d.transmuxSampleAes=function(h,a,x,p,b){var M=this;return this.demuxer.demuxSampleAes(h,a,x).then(function(G){var Z=M.remuxer.remux(G.audioTrack,G.avcTrack,G.id3Track,G.textTrack,x,p,!1,M.id);return{remuxResult:Z,chunkMeta:b}})},d.configureTransmuxer=function(h,a){for(var x=this.config,p=this.observer,b=this.typeSupported,M=this.vendor,G=a.audioCodec,Z=a.defaultInitPts,ie=a.duration,z=a.initSegmentData,F=a.videoCodec,ne,ce=0,ge=u.length;ce<ge;ce++)if(u[ce].demux.probe(h)){ne=u[ce];break}ne||(C.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),ne={demux:U.default,remux:T.default});var xe=this.demuxer,Me=this.remuxer,Te=ne.remux,Oe=ne.demux;(!Me||!(Me instanceof Te))&&(this.remuxer=new Te(p,x,b,M)),(!xe||!(xe instanceof Oe))&&(this.demuxer=new Oe(p,x,b),this.probe=Oe.probe),this.resetInitSegment(z,G,F,ie),this.resetInitialTimestamp(Z)},d.needsProbing=function(h,a,x){return!this.demuxer||!this.remuxer||a||x},d.getDecrypter=function(){var h=this.decrypter;return h||(h=this.decrypter=new D.default(this.observer,this.config)),h},g}();function l(g,d){var c=null;return g.byteLength>0&&d!=null&&d.key!=null&&d.iv!==null&&d.method!=null&&(c=d),c}var E=function(d){return{remuxResult:{},chunkMeta:d}};function m(g){return"then"in g&&g.then instanceof Function}var f=function(d,c,h,a,x){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=d,this.videoCodec=c,this.initSegmentData=h,this.duration=a,this.defaultInitPts=x},L=function(d,c,h,a,x){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=d,this.contiguous=c,this.accurateTimeOffset=h,this.trackSwitch=a,this.timeOffset=x}},"./src/demux/tsdemuxer.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"discardEPB",function(){return E});var $=_("./src/demux/adts.ts"),I=_("./src/demux/mpegaudio.ts"),D=_("./src/demux/exp-golomb.ts"),j=_("./src/demux/id3.ts"),U=_("./src/demux/sample-aes.ts"),P=_("./src/events.ts"),O=_("./src/utils/mp4-tools.ts"),v=_("./src/utils/logger.ts"),T=_("./src/errors.ts"),R={video:1,audio:2,id3:3,text:4},A=function(){function m(L,g,d){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=g,this.typeSupported=d}m.probe=function(g){var d=m.syncOffset(g);return d<0?!1:(d&&v.logger.warn("MPEG2-TS detected but first sync word found @ offset "+d+", junk ahead ?"),!0)},m.syncOffset=function(g){for(var d=Math.min(1e3,g.length-3*188),c=0;c<d;){if(g[c]===71&&g[c+188]===71&&g[c+2*188]===71)return c;c++}return-1},m.createTrack=function(g,d){return{container:g==="video"||g==="audio"?"video/mp2t":void 0,type:g,id:R[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:g==="audio"?d:void 0}};var f=m.prototype;return f.resetInitSegment=function(g,d,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=m.createTrack("video",c),this._audioTrack=m.createTrack("audio",c),this._id3Track=m.createTrack("id3",c),this._txtTrack=m.createTrack("text",c),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=g,this.videoCodec=d,this._duration=c},f.resetTimeStamp=function(){},f.resetContiguity=function(){var g=this._audioTrack,d=this._avcTrack,c=this._id3Track;g&&(g.pesData=null),d&&(d.pesData=null),c&&(c.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},f.demux=function(g,d,c,h){c===void 0&&(c=!1),h===void 0&&(h=!1),c||(this.sampleAes=null);var a,x=this._avcTrack,p=this._audioTrack,b=this._id3Track,M=x.pid,G=x.pesData,Z=p.pid,ie=b.pid,z=p.pesData,F=b.pesData,ne=!1,ce=this.pmtParsed,ge=this._pmtId,xe=g.length;if(this.remainderData&&(g=Object(O.appendUint8Array)(this.remainderData,g),xe=g.length,this.remainderData=null),xe<188&&!h)return this.remainderData=g,{audioTrack:p,avcTrack:x,id3Track:b,textTrack:this._txtTrack};var Me=Math.max(0,m.syncOffset(g));xe-=(xe+Me)%188,xe<g.byteLength&&!h&&(this.remainderData=new Uint8Array(g.buffer,xe,g.buffer.byteLength-xe));for(var Te=Me;Te<xe;Te+=188)if(g[Te]===71){var Oe=!!(g[Te+1]&64),Ce=((g[Te+1]&31)<<8)+g[Te+2],we=(g[Te+3]&48)>>4,ve=void 0;if(we>1){if(ve=Te+5+g[Te+4],ve===Te+188)continue}else ve=Te+4;switch(Ce){case M:Oe&&(G&&(a=o(G))&&this.parseAVCPES(a,!1),G={data:[],size:0}),G&&(G.data.push(g.subarray(ve,Te+188)),G.size+=Te+188-ve);break;case Z:Oe&&(z&&(a=o(z))&&(p.isAAC?this.parseAACPES(a):this.parseMPEGPES(a)),z={data:[],size:0}),z&&(z.data.push(g.subarray(ve,Te+188)),z.size+=Te+188-ve);break;case ie:Oe&&(F&&(a=o(F))&&this.parseID3PES(a),F={data:[],size:0}),F&&(F.data.push(g.subarray(ve,Te+188)),F.size+=Te+188-ve);break;case 0:Oe&&(ve+=g[ve]+1),ge=this._pmtId=S(g,ve);break;case ge:{Oe&&(ve+=g[ve]+1);var W=u(g,ve,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,c);M=W.avc,M>0&&(x.pid=M),Z=W.audio,Z>0&&(p.pid=Z,p.isAAC=W.isAAC),ie=W.id3,ie>0&&(b.pid=ie),ne&&!ce&&(v.logger.log("reparse from beginning"),ne=!1,Te=Me-188),ce=this.pmtParsed=!0;break}case 17:case 8191:break;default:ne=!0;break}}else this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});x.pesData=G,p.pesData=z,b.pesData=F;var w={audioTrack:p,avcTrack:x,id3Track:b,textTrack:this._txtTrack};return h&&this.extractRemainingSamples(w),w},f.flush=function(){var g=this.remainderData;this.remainderData=null;var d;return g?d=this.demux(g,-1,!1,!0):d={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(d),this.sampleAes?this.decrypt(d,this.sampleAes):d},f.extractRemainingSamples=function(g){var d=g.audioTrack,c=g.avcTrack,h=g.id3Track,a=c.pesData,x=d.pesData,p=h.pesData,b;a&&(b=o(a))?(this.parseAVCPES(b,!0),c.pesData=null):c.pesData=a,x&&(b=o(x))?(d.isAAC?this.parseAACPES(b):this.parseMPEGPES(b),d.pesData=null):(x!=null&&x.size&&v.logger.log("last AAC PES packet truncated,might overlap between fragments"),d.pesData=x),p&&(b=o(p))?(this.parseID3PES(b),h.pesData=null):h.pesData=p},f.demuxSampleAes=function(g,d,c){var h=this.demux(g,c,!0,!this.config.progressive),a=this.sampleAes=new U.default(this.observer,this.config,d);return this.decrypt(h,a)},f.decrypt=function(g,d){return new Promise(function(c){var h=g.audioTrack,a=g.avcTrack;h.samples&&h.isAAC?d.decryptAacSamples(h.samples,0,function(){a.samples?d.decryptAvcSamples(a.samples,0,0,function(){c(g)}):c(g)}):a.samples&&d.decryptAvcSamples(a.samples,0,0,function(){c(g)})})},f.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},f.parseAVCPES=function(g,d){var c=this,h=this._avcTrack,a=this.parseAVCNALu(g.data),x=!1,p=this.avcSample,b,M=!1;g.data=null,p&&a.length&&!h.audFound&&(s(p,h),p=this.avcSample=C(!1,g.pts,g.dts,"")),a.forEach(function(G){switch(G.type){case 1:{b=!0,p||(p=c.avcSample=C(!0,g.pts,g.dts,"")),x&&(p.debug+="NDR "),p.frame=!0;var Z=G.data;if(M&&Z.length>4){var ie=new D.default(Z).readSliceType();(ie===2||ie===4||ie===7||ie===9)&&(p.key=!0)}break}case 5:b=!0,p||(p=c.avcSample=C(!0,g.pts,g.dts,"")),x&&(p.debug+="IDR "),p.key=!0,p.frame=!0;break;case 6:{b=!0,x&&p&&(p.debug+="SEI ");var z=new D.default(E(G.data));z.readUByte();for(var F=0,ne=0,ce=!1,ge=0;!ce&&z.bytesAvailable>1;){F=0;do ge=z.readUByte(),F+=ge;while(ge===255);ne=0;do ge=z.readUByte(),ne+=ge;while(ge===255);if(F===4&&z.bytesAvailable!==0){ce=!0;var xe=z.readUByte();if(xe===181){var Me=z.readUShort();if(Me===49){var Te=z.readUInt();if(Te===1195456820){var Oe=z.readUByte();if(Oe===3){for(var Ce=z.readUByte(),we=z.readUByte(),ve=31&Ce,W=[Ce,we],w=0;w<ve;w++)W.push(z.readUByte()),W.push(z.readUByte()),W.push(z.readUByte());l(c._txtTrack.samples,{type:3,pts:g.pts,bytes:W})}}}}}else if(F===5&&z.bytesAvailable!==0){if(ce=!0,ne>16){for(var k=[],H=0;H<16;H++)k.push(z.readUByte().toString(16)),(H===3||H===5||H===7||H===9)&&k.push("-");for(var q=ne-16,B=new Uint8Array(q),he=0;he<q;he++)B[he]=z.readUByte();l(c._txtTrack.samples,{pts:g.pts,payloadType:F,uuid:k.join(""),userData:Object(j.utf8ArrayToStr)(B),userDataBytes:B})}}else if(ne<z.bytesAvailable)for(var Ee=0;Ee<ne;Ee++)z.readUByte()}break}case 7:if(b=!0,M=!0,x&&p&&(p.debug+="SPS "),!h.sps){var Le=new D.default(G.data),Ie=Le.readSPS();h.width=Ie.width,h.height=Ie.height,h.pixelRatio=Ie.pixelRatio,h.sps=[G.data],h.duration=c._duration;for(var _e=G.data.subarray(1,4),De="avc1.",Pe=0;Pe<3;Pe++){var je=_e[Pe].toString(16);je.length<2&&(je="0"+je),De+=je}h.codec=De}break;case 8:b=!0,x&&p&&(p.debug+="PPS "),h.pps||(h.pps=[G.data]);break;case 9:b=!1,h.audFound=!0,p&&s(p,h),p=c.avcSample=C(!1,g.pts,g.dts,x?"AUD ":"");break;case 12:b=!1;break;default:b=!1,p&&(p.debug+="unknown NAL "+G.type+" ");break}if(p&&b){var ze=p.units;ze.push(G)}}),d&&p&&(s(p,h),this.avcSample=null)},f.getLastNalUnit=function(){var g,d=this.avcSample,c;if(!d||d.units.length===0){var h=this._avcTrack.samples;d=h[h.length-1]}if((g=d)!==null&&g!==void 0&&g.units){var a=d.units;c=a[a.length-1]}return c},f.parseAVCNALu=function(g){var d=g.byteLength,c=this._avcTrack,h=c.naluState||0,a=h,x=[],p=0,b,M,G,Z=-1,ie=0;for(h===-1&&(Z=0,ie=g[0]&31,h=0,p=1);p<d;){if(b=g[p++],!h){h=b?0:1;continue}if(h===1){h=b?0:2;continue}if(!b)h=3;else if(b===1){if(Z>=0){var z={data:g.subarray(Z,p-h-1),type:ie};x.push(z)}else{var F=this.getLastNalUnit();if(F&&(a&&p<=4-a&&(F.state&&(F.data=F.data.subarray(0,F.data.byteLength-a))),M=p-h-1,M>0)){var ne=new Uint8Array(F.data.byteLength+M);ne.set(F.data,0),ne.set(g.subarray(0,M),F.data.byteLength),F.data=ne,F.state=0}}p<d?(G=g[p]&31,Z=p,ie=G,h=0):h=-1}else h=0}if(Z>=0&&h>=0){var ce={data:g.subarray(Z,d),type:ie,state:h};x.push(ce)}if(x.length===0){var ge=this.getLastNalUnit();if(ge){var xe=new Uint8Array(ge.data.byteLength+g.byteLength);xe.set(ge.data,0),xe.set(g,ge.data.byteLength),ge.data=xe}}return c.naluState=h,x},f.parseAACPES=function(g){var d=0,c=this._audioTrack,h=this.aacOverFlow,a=g.data;if(h){this.aacOverFlow=null;var x=h.sample.unit.byteLength,p=Math.min(h.missing,x),b=x-p;h.sample.unit.set(a.subarray(0,p),b),c.samples.push(h.sample),d=h.missing}var M,G;for(M=d,G=a.length;M<G-1&&!$.isHeader(a,M);M++);if(M!==d){var Z,ie;if(M<G-1?(Z="AAC PES did not start with ADTS header,offset:"+M,ie=!1):(Z="no ADTS header found in AAC PES",ie=!0),v.logger.warn("parsing error:"+Z),this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:ie,reason:Z}),ie)return}$.initTrackConfig(c,this.observer,a,M,this.audioCodec);var z;if(g.pts!==void 0)z=g.pts;else if(h){var F=$.getFrameDuration(c.samplerate);z=h.sample.pts+F}else{v.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var ne=0;M<G;)if($.isHeader(a,M)){if(M+5<G){var ce=$.appendFrame(c,a,M,z,ne);if(ce)if(ce.missing)this.aacOverFlow=ce;else{M+=ce.length,ne++;continue}}break}else M++},f.parseMPEGPES=function(g){var d=g.data,c=d.length,h=0,a=0,x=g.pts;if(x===void 0){v.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<c;)if(I.isHeader(d,a)){var p=I.appendFrame(this._audioTrack,d,a,x,h);if(p)a+=p.length,h++;else break}else a++},f.parseID3PES=function(g){if(g.pts===void 0){v.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(g)},m}();A.minProbeByteLength=188;function C(m,f,L,g){return{key:m,frame:!1,pts:f,dts:L,units:[],debug:g,length:0}}function S(m,f){return(m[f+10]&31)<<8|m[f+11]}function u(m,f,L,g){var d={audio:-1,avc:-1,id3:-1,isAAC:!0},c=(m[f+1]&15)<<8|m[f+2],h=f+3+c-4,a=(m[f+10]&15)<<8|m[f+11];for(f+=12+a;f<h;){var x=(m[f+1]&31)<<8|m[f+2];switch(m[f]){case 207:if(!g){v.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:d.audio===-1&&(d.audio=x);break;case 21:d.id3===-1&&(d.id3=x);break;case 219:if(!g){v.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:d.avc===-1&&(d.avc=x);break;case 3:case 4:L?d.audio===-1&&(d.audio=x,d.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}f+=((m[f+3]&15)<<8|m[f+4])+5}return d}function o(m){var f=0,L,g,d,c,h,a=m.data;if(!m||m.size===0)return null;for(;a[0].length<19&&a.length>1;){var x=new Uint8Array(a[0].length+a[1].length);x.set(a[0]),x.set(a[1],a[0].length),a[0]=x,a.splice(1,1)}L=a[0];var p=(L[0]<<16)+(L[1]<<8)+L[2];if(p===1){if(g=(L[4]<<8)+L[5],g&&g>m.size-6)return null;var b=L[7];b&192&&(c=(L[9]&14)*536870912+(L[10]&255)*4194304+(L[11]&254)*16384+(L[12]&255)*128+(L[13]&254)/2,b&64?(h=(L[14]&14)*536870912+(L[15]&255)*4194304+(L[16]&254)*16384+(L[17]&255)*128+(L[18]&254)/2,c-h>60*9e4&&(v.logger.warn(Math.round((c-h)/9e4)+"s delta between PTS and DTS, align them"),c=h)):h=c),d=L[8];var M=d+9;if(m.size<=M)return null;m.size-=M;for(var G=new Uint8Array(m.size),Z=0,ie=a.length;Z<ie;Z++){L=a[Z];var z=L.byteLength;if(M)if(M>z){M-=z;continue}else L=L.subarray(M),z-=M,M=0;G.set(L,f),f+=z}return g&&(g-=d+3),{data:G,pts:c,dts:h,len:g}}return null}function s(m,f){if(m.units.length&&m.frame){if(m.pts===void 0){var L=f.samples,g=L.length;if(g){var d=L[g-1];m.pts=d.pts,m.dts=d.dts}else{f.dropped++;return}}f.samples.push(m)}m.debug.length&&v.logger.log(m.pts+"/"+m.dts+":"+m.debug)}function l(m,f){var L=m.length;if(L>0){if(f.pts>=m[L-1].pts)m.push(f);else for(var g=L-1;g>=0;g--)if(f.pts<m[g].pts){m.splice(g,0,f);break}}else m.push(f)}function E(m){for(var f=m.byteLength,L=[],g=1;g<f-2;)m[g]===0&&m[g+1]===0&&m[g+2]===3?(L.push(g+2),g+=2):g++;if(L.length===0)return m;var d=f-L.length,c=new Uint8Array(d),h=0;for(g=0;g<d;h++,g++)h===L[0]&&(h++,L.shift()),c[g]=m[h];return c}J.default=A},"./src/errors.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"ErrorTypes",function(){return $}),_.d(J,"ErrorDetails",function(){return I});var $;(function(D){D.NETWORK_ERROR="networkError",D.MEDIA_ERROR="mediaError",D.KEY_SYSTEM_ERROR="keySystemError",D.MUX_ERROR="muxError",D.OTHER_ERROR="otherError"})($||($={}));var I;(function(D){D.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",D.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",D.KEY_SYSTEM_NO_SESSION="keySystemNoSession",D.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",D.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",D.MANIFEST_LOAD_ERROR="manifestLoadError",D.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",D.MANIFEST_PARSING_ERROR="manifestParsingError",D.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",D.LEVEL_EMPTY_ERROR="levelEmptyError",D.LEVEL_LOAD_ERROR="levelLoadError",D.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",D.LEVEL_SWITCH_ERROR="levelSwitchError",D.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",D.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",D.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",D.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",D.FRAG_LOAD_ERROR="fragLoadError",D.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",D.FRAG_DECRYPT_ERROR="fragDecryptError",D.FRAG_PARSING_ERROR="fragParsingError",D.REMUX_ALLOC_ERROR="remuxAllocError",D.KEY_LOAD_ERROR="keyLoadError",D.KEY_LOAD_TIMEOUT="keyLoadTimeOut",D.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",D.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",D.BUFFER_APPEND_ERROR="bufferAppendError",D.BUFFER_APPENDING_ERROR="bufferAppendingError",D.BUFFER_STALLED_ERROR="bufferStalledError",D.BUFFER_FULL_ERROR="bufferFullError",D.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",D.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",D.INTERNAL_EXCEPTION="internalException",D.INTERNAL_ABORTED="aborted",D.UNKNOWN="unknown"})(I||(I={}))},"./src/events.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"Events",function(){return $});var $;(function(I){I.MEDIA_ATTACHING="hlsMediaAttaching",I.MEDIA_ATTACHED="hlsMediaAttached",I.MEDIA_DETACHING="hlsMediaDetaching",I.MEDIA_DETACHED="hlsMediaDetached",I.BUFFER_RESET="hlsBufferReset",I.BUFFER_CODECS="hlsBufferCodecs",I.BUFFER_CREATED="hlsBufferCreated",I.BUFFER_APPENDING="hlsBufferAppending",I.BUFFER_APPENDED="hlsBufferAppended",I.BUFFER_EOS="hlsBufferEos",I.BUFFER_FLUSHING="hlsBufferFlushing",I.BUFFER_FLUSHED="hlsBufferFlushed",I.MANIFEST_LOADING="hlsManifestLoading",I.MANIFEST_LOADED="hlsManifestLoaded",I.MANIFEST_PARSED="hlsManifestParsed",I.LEVEL_SWITCHING="hlsLevelSwitching",I.LEVEL_SWITCHED="hlsLevelSwitched",I.LEVEL_LOADING="hlsLevelLoading",I.LEVEL_LOADED="hlsLevelLoaded",I.LEVEL_UPDATED="hlsLevelUpdated",I.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",I.LEVELS_UPDATED="hlsLevelsUpdated",I.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",I.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",I.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",I.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",I.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",I.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",I.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",I.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",I.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",I.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",I.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",I.CUES_PARSED="hlsCuesParsed",I.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",I.INIT_PTS_FOUND="hlsInitPtsFound",I.FRAG_LOADING="hlsFragLoading",I.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",I.FRAG_LOADED="hlsFragLoaded",I.FRAG_DECRYPTED="hlsFragDecrypted",I.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",I.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",I.FRAG_PARSING_METADATA="hlsFragParsingMetadata",I.FRAG_PARSED="hlsFragParsed",I.FRAG_BUFFERED="hlsFragBuffered",I.FRAG_CHANGED="hlsFragChanged",I.FPS_DROP="hlsFpsDrop",I.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",I.ERROR="hlsError",I.DESTROYING="hlsDestroying",I.KEY_LOADING="hlsKeyLoading",I.KEY_LOADED="hlsKeyLoaded",I.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",I.BACK_BUFFER_REACHED="hlsBackBufferReached"})($||($={}))},"./src/hls.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return m});var $=_("./node_modules/url-toolkit/src/url-toolkit.js"),I=_.n($),D=_("./src/loader/playlist-loader.ts"),j=_("./src/loader/key-loader.ts"),U=_("./src/controller/id3-track-controller.ts"),P=_("./src/controller/latency-controller.ts"),O=_("./src/controller/level-controller.ts"),v=_("./src/controller/fragment-tracker.ts"),T=_("./src/controller/stream-controller.ts"),R=_("./src/is-supported.ts"),A=_("./src/utils/logger.ts"),C=_("./src/config.ts"),S=_("./node_modules/eventemitter3/index.js"),u=_.n(S),o=_("./src/events.ts"),s=_("./src/errors.ts");function l(f,L){for(var g=0;g<L.length;g++){var d=L[g];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(f,d.key,d)}}function E(f,L,g){return L&&l(f.prototype,L),g&&l(f,g),f}var m=function(){f.isSupported=function(){return Object(R.isSupported)()};function f(g){g===void 0&&(g={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new S.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 d=this.config=Object(C.mergeConfig)(f.DefaultConfig,g);this.userConfig=g,Object(A.enableLogs)(d.debug),this._autoLevelCapping=-1,d.progressive&&Object(C.enableStreamingMode)(d);var c=d.abrController,h=d.bufferController,a=d.capLevelController,x=d.fpsController,p=this.abrController=new c(this),b=this.bufferController=new h(this),M=this.capLevelController=new a(this),G=new x(this),Z=new D.default(this),ie=new j.default(this),z=new U.default(this),F=this.levelController=new O.default(this),ne=new v.FragmentTracker(this),ce=this.streamController=new T.default(this,ne);M.setStreamController(ce),G.setStreamController(ce);var ge=[F,ce];this.networkControllers=ge;var xe=[Z,ie,p,b,M,G,z,ne];this.audioTrackController=this.createController(d.audioTrackController,null,ge),this.createController(d.audioStreamController,ne,ge),this.subtitleTrackController=this.createController(d.subtitleTrackController,null,ge),this.createController(d.subtitleStreamController,ne,ge),this.createController(d.timelineController,null,xe),this.emeController=this.createController(d.emeController,null,xe),this.cmcdController=this.createController(d.cmcdController,null,xe),this.latencyController=this.createController(P.default,null,xe),this.coreComponents=xe}var L=f.prototype;return L.createController=function(d,c,h){if(d){var a=c?new d(this,c):new d(this);return h&&h.push(a),a}return null},L.on=function(d,c,h){h===void 0&&(h=this),this._emitter.on(d,c,h)},L.once=function(d,c,h){h===void 0&&(h=this),this._emitter.once(d,c,h)},L.removeAllListeners=function(d){this._emitter.removeAllListeners(d)},L.off=function(d,c,h,a){h===void 0&&(h=this),this._emitter.off(d,c,h,a)},L.listeners=function(d){return this._emitter.listeners(d)},L.emit=function(d,c,h){return this._emitter.emit(d,c,h)},L.trigger=function(d,c){if(this.config.debug)return this.emit(d,d,c);try{return this.emit(d,d,c)}catch(h){A.logger.error("An internal error happened while handling event "+d+'. Error message: "'+h.message+'". Here is a stacktrace:',h),this.trigger(o.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:d,error:h})}return!1},L.listenerCount=function(d){return this._emitter.listenerCount(d)},L.destroy=function(){A.logger.log("destroy"),this.trigger(o.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(d){return d.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(d){return d.destroy()}),this.coreComponents.length=0},L.attachMedia=function(d){A.logger.log("attachMedia"),this._media=d,this.trigger(o.Events.MEDIA_ATTACHING,{media:d})},L.detachMedia=function(){A.logger.log("detachMedia"),this.trigger(o.Events.MEDIA_DETACHING,void 0),this._media=null},L.loadSource=function(d){this.stopLoad();var c=this.media,h=this.url,a=this.url=$.buildAbsoluteURL(self.location.href,d,{alwaysNormalize:!0});A.logger.log("loadSource:"+a),c&&h&&h!==a&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(o.Events.MANIFEST_LOADING,{url:d})},L.startLoad=function(d){d===void 0&&(d=-1),A.logger.log("startLoad("+d+")"),this.networkControllers.forEach(function(c){c.startLoad(d)})},L.stopLoad=function(){A.logger.log("stopLoad"),this.networkControllers.forEach(function(d){d.stopLoad()})},L.swapAudioCodec=function(){A.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},L.recoverMediaError=function(){A.logger.log("recoverMediaError");var d=this._media;this.detachMedia(),d&&this.attachMedia(d)},L.removeLevel=function(d,c){c===void 0&&(c=0),this.levelController.removeLevel(d,c)},E(f,[{key:"levels",get:function(){var d=this.levelController.levels;return d||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(d){A.logger.log("set currentLevel:"+d),this.loadLevel=d,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(d){A.logger.log("set nextLevel:"+d),this.levelController.manualLevel=d,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(d){A.logger.log("set loadLevel:"+d),this.levelController.manualLevel=d}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(d){this.levelController.nextLoadLevel=d}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(d){A.logger.log("set firstLevel:"+d),this.levelController.firstLevel=d}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(d){A.logger.log("set startLevel:"+d),d!==-1&&(d=Math.max(d,this.minAutoLevel)),this.levelController.startLevel=d}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(d){var c=!!d;c!==this.config.capLevelToPlayerSize&&(c?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=c)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(d){this._autoLevelCapping!==d&&(A.logger.log("set autoLevelCapping:"+d),this._autoLevelCapping=d)}},{key:"bandwidthEstimate",get:function(){var d=this.abrController.bwEstimator;return d?d.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var d=this.levels,c=this.config.minAutoBitrate;if(!d)return 0;for(var h=d.length,a=0;a<h;a++)if(d[a].maxBitrate>c)return a;return 0}},{key:"maxAutoLevel",get:function(){var d=this.levels,c=this.autoLevelCapping,h;return c===-1&&d&&d.length?h=d.length-1:h=c,h}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(d){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,d)}},{key:"audioTracks",get:function(){var d=this.audioTrackController;return d?d.audioTracks:[]}},{key:"audioTrack",get:function(){var d=this.audioTrackController;return d?d.audioTrack:-1},set:function(d){var c=this.audioTrackController;c&&(c.audioTrack=d)}},{key:"subtitleTracks",get:function(){var d=this.subtitleTrackController;return d?d.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var d=this.subtitleTrackController;return d?d.subtitleTrack:-1},set:function(d){var c=this.subtitleTrackController;c&&(c.subtitleTrack=d)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var d=this.subtitleTrackController;return d?d.subtitleDisplay:!1},set:function(d){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=d)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(d){this.config.lowLatencyMode=d}},{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 f.defaultConfig?f.defaultConfig:C.hlsDefaultConfig},set:function(d){f.defaultConfig=d}}]),f}();m.defaultConfig=void 0},"./src/is-supported.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"isSupported",function(){return D}),_.d(J,"changeTypeSupported",function(){return j});var $=_("./src/utils/mediasource-helper.ts");function I(){return self.SourceBuffer||self.WebKitSourceBuffer}function D(){var U=Object($.getMediaSource)();if(!U)return!1;var P=I(),O=U&&typeof U.isTypeSupported=="function"&&U.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),v=!P||P.prototype&&typeof P.prototype.appendBuffer=="function"&&typeof P.prototype.remove=="function";return!!O&&!!v}function j(){var U,P=I();return typeof(P==null||((U=P.prototype)===null||U===void 0)?void 0:U.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return A}),_.d(J,"LoadError",function(){return S});var $=_("./src/polyfills/number.ts"),I=_("./src/errors.ts");function D(u,o){u.prototype=Object.create(o.prototype),u.prototype.constructor=u,v(u,o)}function j(u){var o=typeof Map=="function"?new Map:void 0;return j=function(l){if(l===null||!O(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o!="undefined"){if(o.has(l))return o.get(l);o.set(l,E)}function E(){return U(l,arguments,T(this).constructor)}return E.prototype=Object.create(l.prototype,{constructor:{value:E,enumerable:!1,writable:!0,configurable:!0}}),v(E,l)},j(u)}function U(u,o,s){return P()?U=Reflect.construct:U=function(E,m,f){var L=[null];L.push.apply(L,m);var g=Function.bind.apply(E,L),d=new g;return f&&v(d,f.prototype),d},U.apply(null,arguments)}function P(){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 O(u){return Function.toString.call(u).indexOf("[native code]")!==-1}function v(u,o){return v=Object.setPrototypeOf||function(l,E){return l.__proto__=E,l},v(u,o)}function T(u){return T=Object.setPrototypeOf?Object.getPrototypeOf:function(s){return s.__proto__||Object.getPrototypeOf(s)},T(u)}var R=Math.pow(2,17),A=function(){function u(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var o=u.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(l,E){var m=this,f=l.url;if(!f)return Promise.reject(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,networkDetails:null},"Fragment does not have a "+(f?"part list":"url")));this.abort();var L=this.config,g=L.fLoader,d=L.loader;return new Promise(function(c,h){m.loader&&m.loader.destroy();var a=m.loader=l.loader=g?new g(L):new d(L),x=C(l),p={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:R};l.stats=a.stats,a.load(x,p,{onSuccess:function(M,G,Z,ie){m.resetLoader(l,a),c({frag:l,part:null,payload:M.data,networkDetails:ie})},onError:function(M,G,Z){m.resetLoader(l,a),h(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,response:M,networkDetails:Z}))},onAbort:function(M,G,Z){m.resetLoader(l,a),h(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:l,networkDetails:Z}))},onTimeout:function(M,G,Z){m.resetLoader(l,a),h(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,networkDetails:Z}))},onProgress:function(M,G,Z,ie){E&&E({frag:l,part:null,payload:Z,networkDetails:ie})}})})},o.loadPart=function(l,E,m){var f=this;this.abort();var L=this.config,g=L.fLoader,d=L.loader;return new Promise(function(c,h){f.loader&&f.loader.destroy();var a=f.loader=l.loader=g?new g(L):new d(L),x=C(l,E),p={timeout:L.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:L.fragLoadingMaxRetryTimeout,highWaterMark:R};E.stats=a.stats,a.load(x,p,{onSuccess:function(M,G,Z,ie){f.resetLoader(l,a),f.updateStatsFromPart(l,E);var z={frag:l,part:E,payload:M.data,networkDetails:ie};m(z),c(z)},onError:function(M,G,Z){f.resetLoader(l,a),h(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:E,response:M,networkDetails:Z}))},onAbort:function(M,G,Z){l.stats.aborted=E.stats.aborted,f.resetLoader(l,a),h(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:l,part:E,networkDetails:Z}))},onTimeout:function(M,G,Z){f.resetLoader(l,a),h(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:E,networkDetails:Z}))}})})},o.updateStatsFromPart=function(l,E){var m=l.stats,f=E.stats,L=f.total;if(m.loaded+=f.loaded,L){var g=Math.round(l.duration/E.duration),d=Math.min(Math.round(m.loaded/L),g),c=g-d,h=c*Math.round(m.loaded/d);m.total=m.loaded+h}else m.total=Math.max(m.loaded,m.total);var a=m.loading,x=f.loading;a.start?a.first+=x.first-x.start:(a.start=x.start,a.first=x.first),a.end=x.end},o.resetLoader=function(l,E){l.loader=null,this.loader===E&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),E.destroy()},u}();function C(u,o){o===void 0&&(o=null);var s=o||u,l={frag:u,part:o,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},E=s.byteRangeStartOffset,m=s.byteRangeEndOffset;return Object($.isFiniteNumber)(E)&&Object($.isFiniteNumber)(m)&&(l.rangeStart=E,l.rangeEnd=m),l}var S=function(u){D(o,u);function o(s){for(var l,E=arguments.length,m=new Array(E>1?E-1:0),f=1;f<E;f++)m[f-1]=arguments[f];return l=u.call.apply(u,[this].concat(m))||this,l.data=void 0,l.data=s,l}return o}(j(Error))},"./src/loader/fragment.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"ElementaryStreamTypes",function(){return A}),_.d(J,"BaseSegment",function(){return C}),_.d(J,"Fragment",function(){return S}),_.d(J,"Part",function(){return u});var $=_("./src/polyfills/number.ts"),I=_("./node_modules/url-toolkit/src/url-toolkit.js"),D=_.n(I),j=_("./src/utils/logger.ts"),U=_("./src/loader/level-key.ts"),P=_("./src/loader/load-stats.ts");function O(o,s){o.prototype=Object.create(s.prototype),o.prototype.constructor=o,v(o,s)}function v(o,s){return v=Object.setPrototypeOf||function(E,m){return E.__proto__=m,E},v(o,s)}function T(o,s){for(var l=0;l<s.length;l++){var E=s[l];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(o,E.key,E)}}function R(o,s,l){return s&&T(o.prototype,s),l&&T(o,l),o}var A;(function(o){o.AUDIO="audio",o.VIDEO="video",o.AUDIOVIDEO="audiovideo"})(A||(A={}));var C=function(){function o(l){var E;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(E={},E[A.AUDIO]=null,E[A.VIDEO]=null,E[A.AUDIOVIDEO]=null,E),this.baseurl=l}var s=o.prototype;return s.setByteRange=function(E,m){var f=E.split("@",2),L=[];f.length===1?L[0]=m?m.byteRangeEndOffset:0:L[0]=parseInt(f[1]),L[1]=parseInt(f[0])+L[0],this._byteRange=L},R(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(I.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(E){this._url=E}}]),o}(),S=function(o){O(s,o);function s(E,m){var f;return f=o.call(this,m)||this,f._decryptdata=null,f.rawProgramDateTime=null,f.programDateTime=null,f.tagList=[],f.duration=0,f.sn=0,f.levelkey=void 0,f.type=void 0,f.loader=null,f.level=-1,f.cc=0,f.startPTS=void 0,f.endPTS=void 0,f.appendedPTS=void 0,f.startDTS=void 0,f.endDTS=void 0,f.start=0,f.deltaPTS=void 0,f.maxStartPTS=void 0,f.minEndPTS=void 0,f.stats=new P.LoadStats,f.urlId=0,f.data=void 0,f.bitrateTest=!1,f.title=null,f.initSegment=null,f.type=E,f}var l=s.prototype;return l.createInitializationVector=function(m){for(var f=new Uint8Array(16),L=12;L<16;L++)f[L]=m>>8*(15-L)&255;return f},l.setDecryptDataFromLevelKey=function(m,f){var L=m;return(m==null?void 0:m.method)==="AES-128"&&m.uri&&!m.iv&&(L=U.LevelKey.fromURI(m.uri),L.method=m.method,L.iv=this.createInitializationVector(f),L.keyFormat="identity"),L},l.setElementaryStreamInfo=function(m,f,L,g,d,c){c===void 0&&(c=!1);var h=this.elementaryStreams,a=h[m];if(!a){h[m]={startPTS:f,endPTS:L,startDTS:g,endDTS:d,partial:c};return}a.startPTS=Math.min(a.startPTS,f),a.endPTS=Math.max(a.endPTS,L),a.startDTS=Math.min(a.startDTS,g),a.endDTS=Math.max(a.endDTS,d)},l.clearElementaryStreamInfo=function(){var m=this.elementaryStreams;m[A.AUDIO]=null,m[A.VIDEO]=null,m[A.AUDIOVIDEO]=null},R(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&&j.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($.isFiniteNumber)(this.programDateTime))return null;var m=Object($.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}(C),u=function(o){O(s,o);function s(l,E,m,f,L){var g;g=o.call(this,m)||this,g.fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new P.LoadStats,g.duration=l.decimalFloatingPoint("DURATION"),g.gap=l.bool("GAP"),g.independent=l.bool("INDEPENDENT"),g.relurl=l.enumeratedString("URI"),g.fragment=E,g.index=f;var d=l.enumeratedString("BYTERANGE");return d&&g.setByteRange(d,L),L&&(g.fragOffset=L.fragOffset+L.duration),g}return R(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 E=this.elementaryStreams;return!!(E.audio||E.video||E.audiovideo)}}]),s}(C)},"./src/loader/key-loader.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return j});var $=_("./src/events.ts"),I=_("./src/errors.ts"),D=_("./src/utils/logger.ts"),j=function(){function U(O){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=O,this._registerListeners()}var P=U.prototype;return P._registerListeners=function(){this.hls.on($.Events.KEY_LOADING,this.onKeyLoading,this)},P._unregisterListeners=function(){this.hls.off($.Events.KEY_LOADING,this.onKeyLoading)},P.destroy=function(){this._unregisterListeners();for(var v in this.loaders){var T=this.loaders[v];T&&T.destroy()}this.loaders={}},P.onKeyLoading=function(v,T){var R=T.frag,A=R.type,C=this.loaders[A];if(!R.decryptdata){D.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var S=R.decryptdata.uri;if(S!==this.decrypturl||this.decryptkey===null){var u=this.hls.config;if(C&&(D.logger.warn("abort previous key loader for type:"+A),C.abort()),!S){D.logger.warn("key uri is falsy");return}var o=u.loader,s=R.loader=this.loaders[A]=new o(u);this.decrypturl=S,this.decryptkey=null;var l={url:S,frag:R,responseType:"arraybuffer"},E={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:u.fragLoadingRetryDelay,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};s.load(l,E,m)}else this.decryptkey&&(R.decryptdata.key=this.decryptkey,this.hls.trigger($.Events.KEY_LOADED,{frag:R}))},P.loadsuccess=function(v,T,R){var A=R.frag;if(!A.decryptdata){D.logger.error("after key load, decryptdata unset");return}this.decryptkey=A.decryptdata.key=new Uint8Array(v.data),A.loader=null,delete this.loaders[A.type],this.hls.trigger($.Events.KEY_LOADED,{frag:A})},P.loaderror=function(v,T){var R=T.frag,A=R.loader;A&&A.abort(),delete this.loaders[R.type],this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:R,response:v})},P.loadtimeout=function(v,T){var R=T.frag,A=R.loader;A&&A.abort(),delete this.loaders[R.type],this.hls.trigger($.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:R})},U}()},"./src/loader/level-details.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"LevelDetails",function(){return U});var $=_("./src/polyfills/number.ts");function I(P,O){for(var v=0;v<O.length;v++){var T=O[v];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(P,T.key,T)}}function D(P,O,v){return O&&I(P.prototype,O),v&&I(P,v),P}var j=10,U=function(){function P(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 O=P.prototype;return O.reloaded=function(T){if(!T){this.advanced=!0,this.updated=!0;return}var R=this.lastPartSn-T.lastPartSn,A=this.lastPartIndex-T.lastPartIndex;this.updated=this.endSN!==T.endSN||!!A||!!R,this.advanced=this.endSN>T.endSN||R>0||R===0&&A>0,this.updated||this.advanced?this.misses=Math.floor(T.misses*.6):this.misses=T.misses+1,this.availabilityDelay=T.availabilityDelay},D(P,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object($.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||j}},{key:"drift",get:function(){var T=this.driftEndTime-this.driftStartTime;if(T>0){var R=this.driftEnd-this.driftStart;return R*1e3/T}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var T;return(T=this.fragments)!==null&&T!==void 0&&T.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 T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var T;return(T=this.partList)!==null&&T!==void 0&&T.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),P}()},"./src/loader/level-key.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"LevelKey",function(){return U});var $=_("./node_modules/url-toolkit/src/url-toolkit.js"),I=_.n($);function D(P,O){for(var v=0;v<O.length;v++){var T=O[v];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(P,T.key,T)}}function j(P,O,v){return O&&D(P.prototype,O),v&&D(P,v),P}var U=function(){P.fromURL=function(v,T){return new P(v,T)},P.fromURI=function(v){return new P(v)};function P(O,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($.buildAbsoluteURL)(O,v,{alwaysNormalize:!0}):this._uri=O}return j(P,[{key:"uri",get:function(){return this._uri}}]),P}()},"./src/loader/load-stats.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"LoadStats",function(){return $});var $=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(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return s});var $=_("./src/polyfills/number.ts"),I=_("./node_modules/url-toolkit/src/url-toolkit.js"),D=_.n(I),j=_("./src/loader/fragment.ts"),U=_("./src/loader/level-details.ts"),P=_("./src/loader/level-key.ts"),O=_("./src/utils/attr-list.ts"),v=_("./src/utils/logger.ts"),T=_("./src/utils/codecs.ts"),R=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,A=/#EXT-X-MEDIA:(.*)/g,C=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),S=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("|")),u=/\.(mp4|m4s|m4v|m4a)$/i;function o(L){var g,d;return u.test((g=(d=I.parseURL(L))===null||d===void 0?void 0:d.path)!=null?g:"")}var s=function(){function L(){}return L.findGroup=function(d,c){for(var h=0;h<d.length;h++){var a=d[h];if(a.id===c)return a}},L.convertAVC1ToAVCOTI=function(d){var c=d.split(".");if(c.length>2){var h=c.shift()+".";return h+=parseInt(c.shift()).toString(16),h+=("000"+parseInt(c.shift()).toString(16)).substr(-4),h}return d},L.resolve=function(d,c){return I.buildAbsoluteURL(c,d,{alwaysNormalize:!0})},L.parseMasterPlaylist=function(d,c){var h=[],a={},x=!1;R.lastIndex=0;for(var p;(p=R.exec(d))!=null;)if(p[1]){var b=new O.AttrList(p[1]),M={attrs:b,bitrate:b.decimalInteger("AVERAGE-BANDWIDTH")||b.decimalInteger("BANDWIDTH"),name:b.NAME,url:L.resolve(p[2],c)},G=b.decimalResolution("RESOLUTION");G&&(M.width=G.width,M.height=G.height),l((b.CODECS||"").split(/[ ,]+/).filter(function(ie){return ie}),M),M.videoCodec&&M.videoCodec.indexOf("avc1")!==-1&&(M.videoCodec=L.convertAVC1ToAVCOTI(M.videoCodec)),h.push(M)}else if(p[3]){var Z=new O.AttrList(p[3]);Z["DATA-ID"]&&(x=!0,a[Z["DATA-ID"]]=Z)}return{levels:h,sessionData:x?a:null}},L.parseMasterPlaylistMedia=function(d,c,h,a){a===void 0&&(a=[]);var x,p=[],b=0;for(A.lastIndex=0;(x=A.exec(d))!==null;){var M=new O.AttrList(x[1]);if(M.TYPE===h){var G={attrs:M,bitrate:0,id:b++,groupId:M["GROUP-ID"],instreamId:M["INSTREAM-ID"],name:M.NAME||M.LANGUAGE||"",type:h,default:M.bool("DEFAULT"),autoselect:M.bool("AUTOSELECT"),forced:M.bool("FORCED"),lang:M.LANGUAGE,url:M.URI?L.resolve(M.URI,c):""};if(a.length){var Z=L.findGroup(a,G.groupId)||a[0];E(G,Z,"audioCodec"),E(G,Z,"textCodec")}p.push(G)}}return p},L.parseLevelPlaylist=function(d,c,h,a,x){var p=new U.LevelDetails(c),b=p.fragments,M=null,G=0,Z=0,ie=0,z=0,F=null,ne=new j.Fragment(a,c),ce,ge,xe,Me=-1,Te=!1;for(C.lastIndex=0,p.m3u8=d;(ce=C.exec(d))!==null;){Te&&(Te=!1,ne=new j.Fragment(a,c),ne.start=ie,ne.sn=G,ne.cc=z,ne.level=h,M&&(ne.initSegment=M,ne.rawProgramDateTime=M.rawProgramDateTime));var Oe=ce[1];if(Oe){ne.duration=parseFloat(Oe);var Ce=(" "+ce[2]).slice(1);ne.title=Ce||null,ne.tagList.push(Ce?["INF",Oe,Ce]:["INF",Oe])}else if(ce[3])Object($.isFiniteNumber)(ne.duration)&&(ne.start=ie,xe&&(ne.levelkey=xe),ne.sn=G,ne.level=h,ne.cc=z,ne.urlId=x,b.push(ne),ne.relurl=(" "+ce[3]).slice(1),f(ne,F),F=ne,ie+=ne.duration,G++,Z=0,Te=!0);else if(ce[4]){var we=(" "+ce[4]).slice(1);F?ne.setByteRange(we,F):ne.setByteRange(we)}else if(ce[5])ne.rawProgramDateTime=(" "+ce[5]).slice(1),ne.tagList.push(["PROGRAM-DATE-TIME",ne.rawProgramDateTime]),Me===-1&&(Me=b.length);else{if(ce=ce[0].match(S),!ce){v.logger.warn("No matches on slow regex match for level playlist!");continue}for(ge=1;ge<ce.length&&!(typeof ce[ge]!="undefined");ge++);var ve=(" "+ce[ge]).slice(1),W=(" "+ce[ge+1]).slice(1),w=ce[ge+2]?(" "+ce[ge+2]).slice(1):"";switch(ve){case"PLAYLIST-TYPE":p.type=W.toUpperCase();break;case"MEDIA-SEQUENCE":G=p.startSN=parseInt(W);break;case"SKIP":{var k=new O.AttrList(W),H=k.decimalInteger("SKIPPED-SEGMENTS");if(Object($.isFiniteNumber)(H)){p.skippedSegments=H;for(var q=H;q--;)b.unshift(null);G+=H}var B=k.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(p.recentlyRemovedDateranges=B.split(" "));break}case"TARGETDURATION":p.targetduration=parseFloat(W);break;case"VERSION":p.version=parseInt(W);break;case"EXTM3U":break;case"ENDLIST":p.live=!1;break;case"#":(W||w)&&ne.tagList.push(w?[W,w]:[W]);break;case"DIS":z++;case"GAP":ne.tagList.push([ve]);break;case"BITRATE":ne.tagList.push([ve,W]);break;case"DISCONTINUITY-SEQ":z=parseInt(W);break;case"KEY":{var he,Ee=new O.AttrList(W),Le=Ee.enumeratedString("METHOD"),Ie=Ee.URI,_e=Ee.hexadecimalInteger("IV"),De=Ee.enumeratedString("KEYFORMATVERSIONS"),Pe=Ee.enumeratedString("KEYID"),je=(he=Ee.enumeratedString("KEYFORMAT"))!=null?he:"identity",ze=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ze.indexOf(je)>-1){v.logger.warn("Keyformat "+je+" is not supported from the manifest");continue}else if(je!=="identity")continue;Le&&(xe=P.LevelKey.fromURL(c,Ie),Ie&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(Le)>=0&&(xe.method=Le,xe.keyFormat=je,Pe&&(xe.keyID=Pe),De&&(xe.keyFormatVersions=De),xe.iv=_e));break}case"START":{var Ke=new O.AttrList(W),Ve=Ke.decimalFloatingPoint("TIME-OFFSET");Object($.isFiniteNumber)(Ve)&&(p.startTimeOffset=Ve);break}case"MAP":{var at=new O.AttrList(W);ne.relurl=at.URI,at.BYTERANGE&&ne.setByteRange(at.BYTERANGE),ne.level=h,ne.sn="initSegment",xe&&(ne.levelkey=xe),ne.initSegment=null,M=ne,Te=!0;break}case"SERVER-CONTROL":{var Xe=new O.AttrList(W);p.canBlockReload=Xe.bool("CAN-BLOCK-RELOAD"),p.canSkipUntil=Xe.optionalFloat("CAN-SKIP-UNTIL",0),p.canSkipDateRanges=p.canSkipUntil>0&&Xe.bool("CAN-SKIP-DATERANGES"),p.partHoldBack=Xe.optionalFloat("PART-HOLD-BACK",0),p.holdBack=Xe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var $e=new O.AttrList(W);p.partTarget=$e.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ae=p.partList;Ae||(Ae=p.partList=[]);var rt=Z>0?Ae[Ae.length-1]:void 0,Je=Z++,ae=new j.Part(new O.AttrList(W),ne,c,Je,rt);Ae.push(ae),ne.duration+=ae.duration;break}case"PRELOAD-HINT":{var V=new O.AttrList(W);p.preloadHint=V;break}case"RENDITION-REPORT":{var Y=new O.AttrList(W);p.renditionReports=p.renditionReports||[],p.renditionReports.push(Y);break}default:v.logger.warn("line parsed but not handled: "+ce);break}}}F&&!F.relurl?(b.pop(),ie-=F.duration,p.partList&&(p.fragmentHint=F)):p.partList&&(f(ne,F),ne.cc=z,p.fragmentHint=ne);var te=b.length,oe=b[0],Q=b[te-1];if(ie+=p.skippedSegments*p.targetduration,ie>0&&te&&Q){p.averagetargetduration=ie/te;var ee=Q.sn;p.endSN=ee!=="initSegment"?ee:0,oe&&(p.startCC=oe.cc,oe.initSegment||p.fragments.every(function(se){return se.relurl&&o(se.relurl)})&&(v.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),ne=new j.Fragment(a,c),ne.relurl=Q.relurl,ne.level=h,ne.sn="initSegment",oe.initSegment=ne,p.needSidxRanges=!0))}else p.endSN=0,p.startCC=0;return p.fragmentHint&&(ie+=p.fragmentHint.duration),p.totalduration=ie,p.endCC=z,Me>0&&m(b,Me),p},L}();function l(L,g){["video","audio","text"].forEach(function(d){var c=L.filter(function(a){return Object(T.isCodecType)(a,d)});if(c.length){var h=c.filter(function(a){return a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0});g[d+"Codec"]=h.length>0?h[0]:c[0],L=L.filter(function(a){return c.indexOf(a)===-1})}}),g.unknownCodecs=L}function E(L,g,d){var c=g[d];c&&(L[d]=c)}function m(L,g){for(var d=L[g],c=g;c--;){var h=L[c];if(!h)return;h.programDateTime=d.programDateTime-h.duration*1e3,d=h}}function f(L,g){L.rawProgramDateTime?L.programDateTime=Date.parse(L.rawProgramDateTime):g!=null&&g.programDateTime&&(L.programDateTime=g.endProgramDateTime),Object($.isFiniteNumber)(L.programDateTime)||(L.programDateTime=null,L.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/polyfills/number.ts"),I=_("./src/events.ts"),D=_("./src/errors.ts"),j=_("./src/utils/logger.ts"),U=_("./src/utils/mp4-tools.ts"),P=_("./src/loader/m3u8-parser.ts"),O=_("./src/types/loader.ts"),v=_("./src/utils/attr-list.ts");function T(C){var S=C.type;switch(S){case O.PlaylistContextType.AUDIO_TRACK:return O.PlaylistLevelType.AUDIO;case O.PlaylistContextType.SUBTITLE_TRACK:return O.PlaylistLevelType.SUBTITLE;default:return O.PlaylistLevelType.MAIN}}function R(C,S){var u=C.url;return(u===void 0||u.indexOf("data:")===0)&&(u=S.url),u}var A=function(){function C(u){this.hls=void 0,this.loaders=Object.create(null),this.hls=u,this.registerListeners()}var S=C.prototype;return S.registerListeners=function(){var o=this.hls;o.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),o.on(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.on(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.unregisterListeners=function(){var o=this.hls;o.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),o.off(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),o.off(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.createInternalLoader=function(o){var s=this.hls.config,l=s.pLoader,E=s.loader,m=l||E,f=new m(s);return o.loader=f,this.loaders[o.type]=f,f},S.getInternalLoader=function(o){return this.loaders[o.type]},S.resetInternalLoader=function(o){this.loaders[o]&&delete this.loaders[o]},S.destroyInternalLoaders=function(){for(var o in this.loaders){var s=this.loaders[o];s&&s.destroy(),this.resetInternalLoader(o)}},S.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},S.onManifestLoading=function(o,s){var l=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:O.PlaylistContextType.MANIFEST,url:l,deliveryDirectives:null})},S.onLevelLoading=function(o,s){var l=s.id,E=s.level,m=s.url,f=s.deliveryDirectives;this.load({id:l,groupId:null,level:E,responseType:"text",type:O.PlaylistContextType.LEVEL,url:m,deliveryDirectives:f})},S.onAudioTrackLoading=function(o,s){var l=s.id,E=s.groupId,m=s.url,f=s.deliveryDirectives;this.load({id:l,groupId:E,level:null,responseType:"text",type:O.PlaylistContextType.AUDIO_TRACK,url:m,deliveryDirectives:f})},S.onSubtitleTrackLoading=function(o,s){var l=s.id,E=s.groupId,m=s.url,f=s.deliveryDirectives;this.load({id:l,groupId:E,level:null,responseType:"text",type:O.PlaylistContextType.SUBTITLE_TRACK,url:m,deliveryDirectives:f})},S.load=function(o){var s,l=this.hls.config,E=this.getInternalLoader(o);if(E){var m=E.context;if(m&&m.url===o.url){j.logger.trace("[playlist-loader]: playlist request ongoing");return}j.logger.log("[playlist-loader]: aborting previous loader for type: "+o.type),E.abort()}var f,L,g,d;switch(o.type){case O.PlaylistContextType.MANIFEST:f=l.manifestLoadingMaxRetry,L=l.manifestLoadingTimeOut,g=l.manifestLoadingRetryDelay,d=l.manifestLoadingMaxRetryTimeout;break;case O.PlaylistContextType.LEVEL:case O.PlaylistContextType.AUDIO_TRACK:case O.PlaylistContextType.SUBTITLE_TRACK:f=0,L=l.levelLoadingTimeOut;break;default:f=l.levelLoadingMaxRetry,L=l.levelLoadingTimeOut,g=l.levelLoadingRetryDelay,d=l.levelLoadingMaxRetryTimeout;break}if(E=this.createInternalLoader(o),(s=o.deliveryDirectives)!==null&&s!==void 0&&s.part){var c;if(o.type===O.PlaylistContextType.LEVEL&&o.level!==null?c=this.hls.levels[o.level].details:o.type===O.PlaylistContextType.AUDIO_TRACK&&o.id!==null?c=this.hls.audioTracks[o.id].details:o.type===O.PlaylistContextType.SUBTITLE_TRACK&&o.id!==null&&(c=this.hls.subtitleTracks[o.id].details),c){var h=c.partTarget,a=c.targetduration;h&&a&&(L=Math.min(Math.max(h*3,a*.8)*1e3,L))}}var x={timeout:L,maxRetry:f,retryDelay:g,maxRetryDelay:d,highWaterMark:0},p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};E.load(o,x,p)},S.loadsuccess=function(o,s,l,E){if(E===void 0&&(E=null),l.isSidxRequest){this.handleSidxRequest(o,l),this.handlePlaylistLoaded(o,s,l,E);return}this.resetInternalLoader(l.type);var m=o.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(o,l,"no EXTM3U delimiter",E);return}s.parsing.start=performance.now(),m.indexOf("#EXTINF:")>0||m.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(o,s,l,E):this.handleMasterPlaylist(o,s,l,E)},S.loaderror=function(o,s,l){l===void 0&&(l=null),this.handleNetworkError(s,l,!1,o)},S.loadtimeout=function(o,s,l){l===void 0&&(l=null),this.handleNetworkError(s,l,!0)},S.handleMasterPlaylist=function(o,s,l,E){var m=this.hls,f=o.data,L=R(o,l),g=P.default.parseMasterPlaylist(f,L),d=g.levels,c=g.sessionData;if(!d.length){this.handleManifestParsingError(o,l,"no level found in manifest",E);return}var h=d.map(function(G){return{id:G.attrs.AUDIO,audioCodec:G.audioCodec}}),a=d.map(function(G){return{id:G.attrs.SUBTITLES,textCodec:G.textCodec}}),x=P.default.parseMasterPlaylistMedia(f,L,"AUDIO",h),p=P.default.parseMasterPlaylistMedia(f,L,"SUBTITLES",a),b=P.default.parseMasterPlaylistMedia(f,L,"CLOSED-CAPTIONS");if(x.length){var M=x.some(function(G){return!G.url});!M&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(j.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),x.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new v.AttrList({}),bitrate:0,url:""}))}m.trigger(I.Events.MANIFEST_LOADED,{levels:d,audioTracks:x,subtitles:p,captions:b,url:L,stats:s,networkDetails:E,sessionData:c})},S.handleTrackOrLevelPlaylist=function(o,s,l,E){var m=this.hls,f=l.id,L=l.level,g=l.type,d=R(o,l),c=Object($.isFiniteNumber)(f)?f:0,h=Object($.isFiniteNumber)(L)?L:c,a=T(l),x=P.default.parseLevelPlaylist(o.data,d,h,a,c);if(!x.fragments.length){m.trigger(I.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:d,reason:"no fragments found in level",level:typeof l.level=="number"?l.level:void 0});return}if(g===O.PlaylistContextType.MANIFEST){var p={attrs:new v.AttrList({}),bitrate:0,details:x,name:"",url:d};m.trigger(I.Events.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:d,stats:s,networkDetails:E,sessionData:null})}if(s.parsing.end=performance.now(),x.needSidxRanges){var b,M=(b=x.fragments[0].initSegment)===null||b===void 0?void 0:b.url;this.load({url:M,isSidxRequest:!0,type:g,level:L,levelDetails:x,id:f,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}l.levelDetails=x,this.handlePlaylistLoaded(o,s,l,E)},S.handleSidxRequest=function(o,s){var l=Object(U.parseSegmentIndex)(new Uint8Array(o.data));if(!l)return;var E=l.references,m=s.levelDetails;E.forEach(function(f,L){var g=f.info,d=m.fragments[L];d.byteRange.length===0&&d.setByteRange(String(1+g.end-g.start)+"@"+String(g.start)),d.initSegment&&d.initSegment.setByteRange(String(l.moovEndOffset)+"@0")})},S.handleManifestParsingError=function(o,s,l,E){this.hls.trigger(I.Events.ERROR,{type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===O.PlaylistContextType.MANIFEST,url:o.url,reason:l,response:o,context:s,networkDetails:E})},S.handleNetworkError=function(o,s,l,E){l===void 0&&(l=!1),j.logger.warn("[playlist-loader]: A network "+(l?"timeout":"error")+" occurred while loading "+o.type+" level: "+o.level+" id: "+o.id+' group-id: "'+o.groupId+'"');var m=D.ErrorDetails.UNKNOWN,f=!1,L=this.getInternalLoader(o);switch(o.type){case O.PlaylistContextType.MANIFEST:m=l?D.ErrorDetails.MANIFEST_LOAD_TIMEOUT:D.ErrorDetails.MANIFEST_LOAD_ERROR,f=!0;break;case O.PlaylistContextType.LEVEL:m=l?D.ErrorDetails.LEVEL_LOAD_TIMEOUT:D.ErrorDetails.LEVEL_LOAD_ERROR,f=!1;break;case O.PlaylistContextType.AUDIO_TRACK:m=l?D.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,f=!1;break;case O.PlaylistContextType.SUBTITLE_TRACK:m=l?D.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:D.ErrorDetails.SUBTITLE_LOAD_ERROR,f=!1;break}L&&this.resetInternalLoader(o.type);var g={type:D.ErrorTypes.NETWORK_ERROR,details:m,fatal:f,url:o.url,loader:L,context:o,networkDetails:s};E&&(g.response=E),this.hls.trigger(I.Events.ERROR,g)},S.handlePlaylistLoaded=function(o,s,l,E){var m=l.type,f=l.level,L=l.id,g=l.groupId,d=l.loader,c=l.levelDetails,h=l.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(o,l,"invalid target duration",E);return}if(!d)return;c.live&&(d.getCacheAge&&(c.ageHeader=d.getCacheAge()||0),(!d.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0));switch(m){case O.PlaylistContextType.MANIFEST:case O.PlaylistContextType.LEVEL:this.hls.trigger(I.Events.LEVEL_LOADED,{details:c,level:f||0,id:L||0,stats:s,networkDetails:E,deliveryDirectives:h});break;case O.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(I.Events.AUDIO_TRACK_LOADED,{details:c,id:L||0,groupId:g||"",stats:s,networkDetails:E,deliveryDirectives:h});break;case O.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADED,{details:c,id:L||0,groupId:g||"",stats:s,networkDetails:E,deliveryDirectives:h});break}},C}();J.default=A},"./src/polyfills/number.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"isFiniteNumber",function(){return $}),_.d(J,"MAX_SAFE_INTEGER",function(){return I});var $=Number.isFinite||function(D){return typeof D=="number"&&isFinite(D)},I=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(fe,J,_){"use strict";_.r(J);var $=function(){function I(){}return I.getSilentFrame=function(j,U){switch(j){case"mp4a.40.2":if(U===1)return new Uint8Array([0,200,0,128,35,128]);if(U===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(U===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(U===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(U===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(U===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(U===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(U===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(U===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},I}();J.default=$},"./src/remux/mp4-generator.ts":function(fe,J,_){"use strict";_.r(J);var $=Math.pow(2,32)-1,I=function(){function D(){}return D.init=function(){D.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var U;for(U in D.types)D.types.hasOwnProperty(U)&&(D.types[U]=[U.charCodeAt(0),U.charCodeAt(1),U.charCodeAt(2),U.charCodeAt(3)]);var P=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]),O=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);D.HDLR_TYPES={video:P,audio:O};var v=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),T=new Uint8Array([0,0,0,0,0,0,0,0]);D.STTS=D.STSC=D.STCO=T,D.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),D.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),D.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),D.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var R=new Uint8Array([105,115,111,109]),A=new Uint8Array([97,118,99,49]),C=new Uint8Array([0,0,0,1]);D.FTYP=D.box(D.types.ftyp,R,C,R,A),D.DINF=D.box(D.types.dinf,D.box(D.types.dref,v))},D.box=function(U){for(var P=8,O=arguments.length,v=new Array(O>1?O-1:0),T=1;T<O;T++)v[T-1]=arguments[T];for(var R=v.length,A=R;R--;)P+=v[R].byteLength;var C=new Uint8Array(P);for(C[0]=P>>24&255,C[1]=P>>16&255,C[2]=P>>8&255,C[3]=P&255,C.set(U,4),R=0,P=8;R<A;R++)C.set(v[R],P),P+=v[R].byteLength;return C},D.hdlr=function(U){return D.box(D.types.hdlr,D.HDLR_TYPES[U])},D.mdat=function(U){return D.box(D.types.mdat,U)},D.mdhd=function(U,P){P*=U;var O=Math.floor(P/($+1)),v=Math.floor(P%($+1));return D.box(D.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,U&255,O>>24,O>>16&255,O>>8&255,O&255,v>>24,v>>16&255,v>>8&255,v&255,85,196,0,0]))},D.mdia=function(U){return D.box(D.types.mdia,D.mdhd(U.timescale,U.duration),D.hdlr(U.type),D.minf(U))},D.mfhd=function(U){return D.box(D.types.mfhd,new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,U&255]))},D.minf=function(U){return U.type==="audio"?D.box(D.types.minf,D.box(D.types.smhd,D.SMHD),D.DINF,D.stbl(U)):D.box(D.types.minf,D.box(D.types.vmhd,D.VMHD),D.DINF,D.stbl(U))},D.moof=function(U,P,O){return D.box(D.types.moof,D.mfhd(U),D.traf(O,P))},D.moov=function(U){for(var P=U.length,O=[];P--;)O[P]=D.trak(U[P]);return D.box.apply(null,[D.types.moov,D.mvhd(U[0].timescale,U[0].duration)].concat(O).concat(D.mvex(U)))},D.mvex=function(U){for(var P=U.length,O=[];P--;)O[P]=D.trex(U[P]);return D.box.apply(null,[D.types.mvex].concat(O))},D.mvhd=function(U,P){P*=U;var O=Math.floor(P/($+1)),v=Math.floor(P%($+1)),T=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,U&255,O>>24,O>>16&255,O>>8&255,O&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 D.box(D.types.mvhd,T)},D.sdtp=function(U){var P=U.samples||[],O=new Uint8Array(4+P.length),v,T;for(v=0;v<P.length;v++)T=P[v].flags,O[v+4]=T.dependsOn<<4|T.isDependedOn<<2|T.hasRedundancy;return D.box(D.types.sdtp,O)},D.stbl=function(U){return D.box(D.types.stbl,D.stsd(U),D.box(D.types.stts,D.STTS),D.box(D.types.stsc,D.STSC),D.box(D.types.stsz,D.STSZ),D.box(D.types.stco,D.STCO))},D.avc1=function(U){var P=[],O=[],v,T,R;for(v=0;v<U.sps.length;v++)T=U.sps[v],R=T.byteLength,P.push(R>>>8&255),P.push(R&255),P=P.concat(Array.prototype.slice.call(T));for(v=0;v<U.pps.length;v++)T=U.pps[v],R=T.byteLength,O.push(R>>>8&255),O.push(R&255),O=O.concat(Array.prototype.slice.call(T));var A=D.box(D.types.avcC,new Uint8Array([1,P[3],P[4],P[5],252|3,224|U.sps.length].concat(P).concat([U.pps.length]).concat(O))),C=U.width,S=U.height,u=U.pixelRatio[0],o=U.pixelRatio[1];return D.box(D.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,C>>8&255,C&255,S>>8&255,S&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]),A,D.box(D.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),D.box(D.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,o>>24,o>>16&255,o>>8&255,o&255])))},D.esds=function(U){var P=U.config.length;return new Uint8Array([0,0,0,0,3,23+P,0,1,0,4,15+P,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([P]).concat(U.config).concat([6,1,2]))},D.mp4a=function(U){var P=U.samplerate;return D.box(D.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]),D.box(D.types.esds,D.esds(U)))},D.mp3=function(U){var P=U.samplerate;return D.box(D.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,P>>8&255,P&255,0,0]))},D.stsd=function(U){return U.type==="audio"?!U.isAAC&&U.codec==="mp3"?D.box(D.types.stsd,D.STSD,D.mp3(U)):D.box(D.types.stsd,D.STSD,D.mp4a(U)):D.box(D.types.stsd,D.STSD,D.avc1(U))},D.tkhd=function(U){var P=U.id,O=U.duration*U.timescale,v=U.width,T=U.height,R=Math.floor(O/($+1)),A=Math.floor(O%($+1));return D.box(D.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,P>>24&255,P>>16&255,P>>8&255,P&255,0,0,0,0,R>>24,R>>16&255,R>>8&255,R&255,A>>24,A>>16&255,A>>8&255,A&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,T>>8&255,T&255,0,0]))},D.traf=function(U,P){var O=D.sdtp(U),v=U.id,T=Math.floor(P/($+1)),R=Math.floor(P%($+1));return D.box(D.types.traf,D.box(D.types.tfhd,new Uint8Array([0,0,0,0,v>>24,v>>16&255,v>>8&255,v&255])),D.box(D.types.tfdt,new Uint8Array([1,0,0,0,T>>24,T>>16&255,T>>8&255,T&255,R>>24,R>>16&255,R>>8&255,R&255])),D.trun(U,O.length+16+20+8+16+8+8),O)},D.trak=function(U){return U.duration=U.duration||4294967295,D.box(D.types.trak,D.tkhd(U),D.mdia(U))},D.trex=function(U){var P=U.id;return D.box(D.types.trex,new Uint8Array([0,0,0,0,P>>24,P>>16&255,P>>8&255,P&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},D.trun=function(U,P){var O=U.samples||[],v=O.length,T=12+16*v,R=new Uint8Array(T),A,C,S,u,o,s;for(P+=8+T,R.set([0,0,15,1,v>>>24&255,v>>>16&255,v>>>8&255,v&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255],0),A=0;A<v;A++)C=O[A],S=C.duration,u=C.size,o=C.flags,s=C.cts,R.set([S>>>24&255,S>>>16&255,S>>>8&255,S&255,u>>>24&255,u>>>16&255,u>>>8&255,u&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*A);return D.box(D.types.trun,R)},D.initSegment=function(U){D.types||D.init();var P=D.moov(U),O=new Uint8Array(D.FTYP.byteLength+P.byteLength);return O.set(D.FTYP),O.set(P,D.FTYP.byteLength),O},D}();I.types=void 0,I.HDLR_TYPES=void 0,I.STTS=void 0,I.STSC=void 0,I.STCO=void 0,I.STSZ=void 0,I.VMHD=void 0,I.SMHD=void 0,I.STSD=void 0,I.FTYP=void 0,I.DINF=void 0,J.default=I},"./src/remux/mp4-remuxer.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return s}),_.d(J,"normalizePts",function(){return l});var $=_("./src/polyfills/number.ts"),I=_("./src/remux/aac-helper.ts"),D=_("./src/remux/mp4-generator.ts"),j=_("./src/events.ts"),U=_("./src/errors.ts"),P=_("./src/utils/logger.ts"),O=_("./src/types/loader.ts"),v=_("./src/utils/timescale-conversion.ts");function T(){return T=Object.assign||function(L){for(var g=1;g<arguments.length;g++){var d=arguments[g];for(var c in d)Object.prototype.hasOwnProperty.call(d,c)&&(L[c]=d[c])}return L},T.apply(this,arguments)}var R=10*1e3,A=1024,C=1152,S=null,u=null,o=!1,s=function(){function L(d,c,h,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=d,this.config=c,this.typeSupported=h,this.ISGenerated=!1,S===null){var x=navigator.userAgent||"",p=x.match(/Chrome\/(\d+)/i);S=p?parseInt(p[1]):0}if(u===null){var b=navigator.userAgent.match(/Safari\/(\d+)/i);u=b?parseInt(b[1]):0}o=!!S&&S<75||!!u&&u<600}var g=L.prototype;return g.destroy=function(){},g.resetTimeStamp=function(c){P.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=c},g.resetNextTimestamp=function(){P.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},g.resetInitSegment=function(){P.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},g.getVideoStartPts=function(c){var h=!1,a=c.reduce(function(x,p){var b=p.pts-x;return b<-4294967296?(h=!0,l(x,p.pts)):b>0?x:p.pts},c[0].pts);return h&&P.logger.debug("PTS rollover detected"),a},g.remux=function(c,h,a,x,p,b,M,G){var Z,ie,z,F,ne,ce,ge=p,xe=p,Me=c.pid>-1,Te=h.pid>-1,Oe=h.samples.length,Ce=c.samples.length>0,we=Oe>1,ve=(!Me||Ce)&&(!Te||we)||this.ISGenerated||M;if(ve){this.ISGenerated||(z=this.generateIS(c,h,p));var W=this.isVideoContiguous,w=-1;if(we&&(w=E(h.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(ce=!0,w>0){P.logger.warn("[mp4-remuxer]: Dropped "+w+" out of "+Oe+" video samples due to a missing keyframe");var k=this.getVideoStartPts(h.samples);h.samples=h.samples.slice(w),h.dropped+=w,xe+=(h.samples[0].pts-k)/(h.timescale||9e4)}else w===-1&&(P.logger.warn("[mp4-remuxer]: No keyframe found out of "+Oe+" video samples"),ce=!1);if(this.ISGenerated){if(Ce&&we){var H=this.getVideoStartPts(h.samples),q=l(c.samples[0].pts,H)-H,B=q/h.inputTimeScale;ge+=Math.max(0,B),xe+=Math.max(0,-B)}if(Ce){if(c.samplerate||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),z=this.generateIS(c,h,p)),ie=this.remuxAudio(c,ge,this.isAudioContiguous,b,Te||we||G===O.PlaylistLevelType.AUDIO?xe:void 0),we){var he=ie?ie.endPTS-ie.startPTS:0;h.inputTimeScale||(P.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),z=this.generateIS(c,h,p)),Z=this.remuxVideo(h,xe,W,he)}}else we&&(Z=this.remuxVideo(h,xe,W,0));Z&&(Z.firstKeyFrame=w,Z.independent=w!==-1)}}return this.ISGenerated&&(a.samples.length&&(ne=this.remuxID3(a,p)),x.samples.length&&(F=this.remuxText(x,p))),{audio:ie,video:Z,initSegment:z,independent:ce,text:F,id3:ne}},g.generateIS=function(c,h,a){var x=c.samples,p=h.samples,b=this.typeSupported,M={},G=!Object($.isFiniteNumber)(this._initPTS),Z="audio/mp4",ie,z,F;if(G&&(ie=z=Infinity),c.config&&x.length&&(c.timescale=c.samplerate,c.isAAC||(b.mpeg?(Z="audio/mpeg",c.codec=""):b.mp3&&(c.codec="mp3")),M.audio={id:"audio",container:Z,codec:c.codec,initSegment:!c.isAAC&&b.mpeg?new Uint8Array(0):D.default.initSegment([c]),metadata:{channelCount:c.channelCount}},G&&(F=c.inputTimeScale,ie=z=x[0].pts-Math.round(F*a))),h.sps&&h.pps&&p.length&&(h.timescale=h.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:h.codec,initSegment:D.default.initSegment([h]),metadata:{width:h.width,height:h.height}},G)){F=h.inputTimeScale;var ne=this.getVideoStartPts(p),ce=Math.round(F*a);z=Math.min(z,l(p[0].dts,ne)-ce),ie=Math.min(ie,ne-ce)}if(Object.keys(M).length)return this.ISGenerated=!0,G&&(this._initPTS=ie,this._initDTS=z),{tracks:M,initPTS:ie,timescale:F}},g.remuxVideo=function(c,h,a,x){var p=c.inputTimeScale,b=c.samples,M=[],G=b.length,Z=this._initPTS,ie=this.nextAvcDts,z=8,F,ne,ce,ge=Number.POSITIVE_INFINITY,xe=Number.NEGATIVE_INFINITY,Me=0,Te=!1;if(!a||ie===null){var Oe=h*p,Ce=b[0].pts-l(b[0].dts,b[0].pts);ie=Oe-Ce}for(var we=0;we<G;we++){var ve=b[we];if(ve.pts=l(ve.pts-Z,ie),ve.dts=l(ve.dts-Z,ie),ve.dts>ve.pts){var W=9e4*.2;Me=Math.max(Math.min(Me,ve.pts-ve.dts),-1*W)}ve.dts<b[we>0?we-1:we].dts&&(Te=!0)}Te&&b.sort(function(vt,ot){var it=vt.dts-ot.dts,wt=vt.pts-ot.pts;return it||wt}),ne=b[0].dts,ce=b[b.length-1].dts;var w=Math.round((ce-ne)/(G-1));if(Me<0){if(Me<w*-2){P.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(v.toMsFromMpegTsClock)(-w,!0)+" ms");for(var k=Me,H=0;H<G;H++)b[H].dts=k=Math.max(k,b[H].pts-w),b[H].pts=Math.max(k,b[H].pts)}else{P.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(v.toMsFromMpegTsClock)(Me,!0)+" ms to overcome this issue");for(var q=0;q<G;q++)b[q].dts=b[q].dts+Me}ne=b[0].dts}if(a){var B=ne-ie,he=B>w,Ee=B<-1;if(he||Ee){he?P.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(B,!0)+" ms ("+B+"dts) hole between fragments detected, filling it"):P.logger.warn("AVC: "+Object(v.toMsFromMpegTsClock)(-B,!0)+" ms ("+B+"dts) overlapping between fragments detected"),ne=ie;var Le=b[0].pts-B;b[0].dts=ne,b[0].pts=Le,P.logger.log("Video: First PTS/DTS adjusted: "+Object(v.toMsFromMpegTsClock)(Le,!0)+"/"+Object(v.toMsFromMpegTsClock)(ne,!0)+", delta: "+Object(v.toMsFromMpegTsClock)(B,!0)+" ms")}}o&&(ne=Math.max(0,ne));for(var Ie=0,_e=0,De=0;De<G;De++){for(var Pe=b[De],je=Pe.units,ze=je.length,Ke=0,Ve=0;Ve<ze;Ve++)Ke+=je[Ve].data.length;_e+=Ke,Ie+=ze,Pe.length=Ke,Pe.dts=Math.max(Pe.dts,ne),Pe.pts=Math.max(Pe.pts,Pe.dts,0),ge=Math.min(Pe.pts,ge),xe=Math.max(Pe.pts,xe)}ce=b[G-1].dts;var at=_e+4*Ie+8,Xe;try{Xe=new Uint8Array(at)}catch(vt){this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:at,reason:"fail allocating video mdat "+at});return}var $e=new DataView(Xe.buffer);$e.setUint32(0,at),Xe.set(D.default.types.mdat,4);for(var Ae=0;Ae<G;Ae++){for(var rt=b[Ae],Je=rt.units,ae=0,V=0,Y=Je.length;V<Y;V++){var te=Je[V],oe=te.data,Q=te.data.byteLength;$e.setUint32(z,Q),z+=4,Xe.set(oe,z),z+=Q,ae+=4+Q}if(Ae<G-1)F=b[Ae+1].dts-rt.dts;else{var ee=this.config,se=rt.dts-b[Ae>0?Ae-1:Ae].dts;if(ee.stretchShortVideoTrack&&this.nextAudioPts!==null){var ue=Math.floor(ee.maxBufferHole*p),me=(x?ge+x*p:this.nextAudioPts)-rt.pts;me>ue?(F=me-se,F<0&&(F=se),P.logger.log("[mp4-remuxer]: It is approximately "+me/90+" ms to the next segment; using duration "+F/90+" ms for the last video frame.")):F=se}else F=se}var ye=Math.round(rt.pts-rt.dts);M.push(new m(rt.key,F,ae,ye))}if(M.length&&S&&S<70){var ke=M[0].flags;ke.dependsOn=2,ke.isNonSync=0}console.assert(F!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=ie=ce+F,this.isVideoContiguous=!0;var We=D.default.moof(c.sequenceNumber++,ne,T({},c,{samples:M})),Qe="video",tt={data1:We,data2:Xe,startPTS:ge/p,endPTS:(xe+F)/p,startDTS:ne/p,endDTS:ie/p,type:Qe,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:c.dropped};return c.samples=[],c.dropped=0,console.assert(Xe.length,"MDAT length must not be zero"),tt},g.remuxAudio=function(c,h,a,x,p){var b=c.inputTimeScale,M=c.samplerate?c.samplerate:b,G=b/M,Z=c.isAAC?A:C,ie=Z*G,z=this._initPTS,F=!c.isAAC&&this.typeSupported.mpeg,ne=[],ce=c.samples,ge=F?0:8,xe=this.nextAudioPts||-1,Me=h*b;if(this.isAudioContiguous=a=a||ce.length&&xe>0&&(x&&Math.abs(Me-xe)<9e3||Math.abs(l(ce[0].pts-z,Me)-xe)<20*ie),ce.forEach(function(oe){oe.pts=l(oe.pts-z,Me)}),!a||xe<0){if(ce=ce.filter(function(oe){return oe.pts>=0}),!ce.length)return;p===0?xe=0:x?xe=Math.max(0,Me):xe=ce[0].pts}if(c.isAAC)for(var Te=p!==void 0,Oe=this.config.maxAudioFramesDrift,Ce=0,we=xe;Ce<ce.length;Ce++){var ve=ce[Ce],W=ve.pts,w=W-we,k=Math.abs(1e3*w/b);if(w<=-Oe*ie&&Te)Ce===0&&(P.logger.warn("Audio frame @ "+(W/b).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*w/b)+" ms."),this.nextAudioPts=xe=we=W);else if(w>=Oe*ie&&k<R&&Te){var H=Math.round(w/ie);we=W-H*ie,we<0&&(H--,we+=ie),Ce===0&&(this.nextAudioPts=xe=we),P.logger.warn("[mp4-remuxer]: Injecting "+H+" audio frame @ "+(we/b).toFixed(3)+"s due to "+Math.round(1e3*w/b)+" ms gap.");for(var q=0;q<H;q++){var B=Math.max(we,0),he=I.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);he||(P.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),he=ve.unit.subarray()),ce.splice(Ce,0,{unit:he,pts:B}),we+=ie,Ce++}}ve.pts=we,we+=ie}for(var Ee=null,Le=null,Ie,_e=0,De=ce.length;De--;)_e+=ce[De].unit.byteLength;for(var Pe=0,je=ce.length;Pe<je;Pe++){var ze=ce[Pe],Ke=ze.unit,Ve=ze.pts;if(Le!==null){var at=ne[Pe-1];at.duration=Math.round((Ve-Le)/G)}else if(a&&c.isAAC&&(Ve=xe),Ee=Ve,_e>0){_e+=ge;try{Ie=new Uint8Array(_e)}catch(oe){this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:_e,reason:"fail allocating audio mdat "+_e});return}if(!F){var Xe=new DataView(Ie.buffer);Xe.setUint32(0,_e),Ie.set(D.default.types.mdat,4)}}else return;Ie.set(Ke,ge);var $e=Ke.byteLength;ge+=$e,ne.push(new m(!0,Z,$e,0)),Le=Ve}var Ae=ne.length;if(!Ae)return;var rt=ne[ne.length-1];this.nextAudioPts=xe=Le+G*rt.duration;var Je=F?new Uint8Array(0):D.default.moof(c.sequenceNumber++,Ee/G,T({},c,{samples:ne}));c.samples=[];var ae=Ee/b,V=xe/b,Y="audio",te={data1:Je,data2:Ie,startPTS:ae,endPTS:V,startDTS:ae,endDTS:V,type:Y,hasAudio:!0,hasVideo:!1,nb:Ae};return this.isAudioContiguous=!0,console.assert(Ie.length,"MDAT length must not be zero"),te},g.remuxEmptyAudio=function(c,h,a,x){var p=c.inputTimeScale,b=c.samplerate?c.samplerate:p,M=p/b,G=this.nextAudioPts,Z=(G!==null?G:x.startDTS*p)+this._initDTS,ie=x.endDTS*p+this._initDTS,z=M*A,F=Math.ceil((ie-Z)/z),ne=I.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);if(P.logger.warn("[mp4-remuxer]: remux empty Audio"),!ne){P.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var ce=[],ge=0;ge<F;ge++){var xe=Z+ge*z;ce.push({unit:ne,pts:xe,dts:xe})}return c.samples=ce,this.remuxAudio(c,h,a,!1)},g.remuxID3=function(c,h){var a=c.samples.length;if(!a)return;for(var x=c.inputTimeScale,p=this._initPTS,b=this._initDTS,M=0;M<a;M++){var G=c.samples[M];G.pts=l(G.pts-p,h*x)/x,G.dts=l(G.dts-b,h*x)/x}var Z=c.samples;return c.samples=[],{samples:Z}},g.remuxText=function(c,h){var a=c.samples.length;if(!a)return;for(var x=c.inputTimeScale,p=this._initPTS,b=0;b<a;b++){var M=c.samples[b];M.pts=l(M.pts-p,h*x)/x}c.samples.sort(function(Z,ie){return Z.pts-ie.pts});var G=c.samples;return c.samples=[],{samples:G}},L}();function l(L,g){var d;if(g===null)return L;for(g<L?d=-8589934592:d=8589934592;Math.abs(L-g)>4294967296;)L+=d;return L}function E(L){for(var g=0;g<L.length;g++)if(L[g].key)return g;return-1}var m=function(g,d,c,h){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=d,this.size=c,this.cts=h,this.flags=new f(g)},f=function(g){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=g?2:1,this.isNonSync=g?0:1}},"./src/remux/passthrough-remuxer.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/polyfills/number.ts"),I=_("./src/utils/mp4-tools.ts"),D=_("./src/loader/fragment.ts"),j=_("./src/utils/logger.ts"),U=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 T=v.prototype;return T.destroy=function(){},T.resetTimeStamp=function(A){this.initPTS=A,this.lastEndDTS=null},T.resetNextTimestamp=function(){this.lastEndDTS=null},T.resetInitSegment=function(A,C,S){this.audioCodec=C,this.videoCodec=S,this.generateInitSegment(A),this.emitInitSegment=!0},T.generateInitSegment=function(A){var C=this.audioCodec,S=this.videoCodec;if(!A||!A.byteLength){this.initTracks=void 0,this.initData=void 0;return}var u=this.initData=Object(I.parseInitSegment)(A);C||(C=O(u.audio,D.ElementaryStreamTypes.AUDIO)),S||(S=O(u.video,D.ElementaryStreamTypes.VIDEO));var o={};u.audio&&u.video?o.audiovideo={container:"video/mp4",codec:C+","+S,initSegment:A,id:"main"}:u.audio?o.audio={container:"audio/mp4",codec:C,initSegment:A,id:"audio"}:u.video?o.video={container:"video/mp4",codec:S,initSegment:A,id:"main"}:j.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},T.remux=function(A,C,S,u,o){var s=this.initPTS,l=this.lastEndDTS,E={audio:void 0,video:void 0,text:u,id3:S,initSegment:void 0};Object($.isFiniteNumber)(l)||(l=this.lastEndDTS=o||0);var m=C.samples;if(!m||!m.length)return E;var f={initPTS:void 0,timescale:1},L=this.initData;if((!L||!L.length)&&(this.generateInitSegment(m),L=this.initData),!L||!L.length)return j.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),E;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1),Object($.isFiniteNumber)(s)||(this.initPTS=f.initPTS=s=P(L,m,l));var g=Object(I.getDuration)(m,L),d=l,c=g+d;Object(I.offsetStartDTS)(L,m,s),g>0?this.lastEndDTS=c:(j.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var h=!!L.audio,a=!!L.video,x="";h&&(x+="audio"),a&&(x+="video");var p={data1:m,startPTS:d,startDTS:d,endPTS:c,endDTS:c,type:x,hasAudio:h,hasVideo:a,nb:1,dropped:0};return E.audio=p.type==="audio"?p:void 0,E.video=p.type!=="audio"?p:void 0,E.text=u,E.id3=S,E.initSegment=f,E},v}(),P=function(T,R,A){return Object(I.getStartDTS)(T,R)-A};function O(v,T){var R=v==null?void 0:v.codec;return R&&R.length>4?R:R==="hvc1"?"hvc1.1.c.L120.90":R==="av01"?"av01.0.04M.08":R==="avc1"||T===D.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}J.default=U},"./src/task-loop.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return $});var $=function(){function I(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var D=I.prototype;return D.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},D.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},D.onHandlerDestroyed=function(){},D.hasInterval=function(){return!!this._tickInterval},D.hasNextTick=function(){return!!this._tickTimer},D.setInterval=function(U){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,U),!0)},D.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},D.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},D.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},D.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},D.doTick=function(){},I}()},"./src/types/cmcd.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"CMCDVersion",function(){return $}),_.d(J,"CMCDObjectType",function(){return I}),_.d(J,"CMCDStreamingFormat",function(){return D}),_.d(J,"CMCDStreamType",function(){return j});var $=1,I;(function(U){U.MANIFEST="m",U.AUDIO="a",U.VIDEO="v",U.MUXED="av",U.INIT="i",U.CAPTION="c",U.TIMED_TEXT="tt",U.KEY="k",U.OTHER="o"})(I||(I={}));var D;(function(U){U.DASH="d",U.HLS="h",U.SMOOTH="s",U.OTHER="o"})(D||(D={}));var j;(function(U){U.VOD="v",U.LIVE="l"})(j||(j={}))},"./src/types/level.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"HlsSkip",function(){return D}),_.d(J,"getSkipValue",function(){return j}),_.d(J,"HlsUrlParameters",function(){return U}),_.d(J,"Level",function(){return P});function $(O,v){for(var T=0;T<v.length;T++){var R=v[T];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(O,R.key,R)}}function I(O,v,T){return v&&$(O.prototype,v),T&&$(O,T),O}var D;(function(O){O.No="",O.Yes="YES",O.v2="v2"})(D||(D={}));function j(O,v){var T=O.canSkipUntil,R=O.canSkipDateRanges,A=O.endSN,C=v!==void 0?v-A:0;return T&&C<T?R?D.v2:D.Yes:D.No}var U=function(){function O(T,R,A){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=T,this.part=R,this.skip=A}var v=O.prototype;return v.addDirectives=function(R){var A=new self.URL(R);return this.msn!==void 0&&A.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&A.searchParams.set("_HLS_part",this.part.toString()),this.skip&&A.searchParams.set("_HLS_skip",this.skip),A.toString()},O}(),P=function(){function O(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(T){return T}).join(",").replace(/\.[^.,]+/g,"")}return I(O,[{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(T){var R=T%this.url.length;this._urlId!==R&&(this.details=void 0,this._urlId=R)}}]),O}()},"./src/types/loader.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"PlaylistContextType",function(){return $}),_.d(J,"PlaylistLevelType",function(){return I});var $;(function(D){D.MANIFEST="manifest",D.LEVEL="level",D.AUDIO_TRACK="audioTrack",D.SUBTITLE_TRACK="subtitleTrack"})($||($={}));var I;(function(D){D.MAIN="main",D.AUDIO="audio",D.SUBTITLE="subtitle"})(I||(I={}))},"./src/types/transmuxer.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"ChunkMetadata",function(){return $});var $=function(j,U,P,O,v,T){O===void 0&&(O=0),v===void 0&&(v=-1),T===void 0&&(T=!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=I(),this.buffering={audio:I(),video:I(),audiovideo:I()},this.level=j,this.sn=U,this.id=P,this.size=O,this.part=v,this.partial=T};function I(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"AttrList",function(){return D});var $=/^(\d+)x(\d+)$/,I=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,D=function(){function j(P){typeof P=="string"&&(P=j.parseAttrList(P));for(var O in P)P.hasOwnProperty(O)&&(this[O]=P[O])}var U=j.prototype;return U.decimalInteger=function(O){var v=parseInt(this[O],10);return v>Number.MAX_SAFE_INTEGER?Infinity:v},U.hexadecimalInteger=function(O){if(this[O]){var v=(this[O]||"0x").slice(2);v=(v.length&1?"0":"")+v;for(var T=new Uint8Array(v.length/2),R=0;R<v.length/2;R++)T[R]=parseInt(v.slice(R*2,R*2+2),16);return T}else return null},U.hexadecimalIntegerAsNumber=function(O){var v=parseInt(this[O],16);return v>Number.MAX_SAFE_INTEGER?Infinity:v},U.decimalFloatingPoint=function(O){return parseFloat(this[O])},U.optionalFloat=function(O,v){var T=this[O];return T?parseFloat(T):v},U.enumeratedString=function(O){return this[O]},U.bool=function(O){return this[O]==="YES"},U.decimalResolution=function(O){var v=$.exec(this[O]);return v===null?void 0:{width:parseInt(v[1],10),height:parseInt(v[2],10)}},j.parseAttrList=function(O){var v,T={},R='"';for(I.lastIndex=0;(v=I.exec(O))!==null;){var A=v[2];A.indexOf(R)===0&&A.lastIndexOf(R)===A.length-1&&(A=A.slice(1,-1)),T[v[1]]=A}return T},j}()},"./src/utils/binary-search.ts":function(fe,J,_){"use strict";_.r(J);var $={search:function(D,j){for(var U=0,P=D.length-1,O=null,v=null;U<=P;){O=(U+P)/2|0,v=D[O];var T=j(v);if(T>0)U=O+1;else if(T<0)P=O-1;else return v}return null}};J.default=$},"./src/utils/buffer-helper.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"BufferHelper",function(){return D});var $=_("./src/utils/logger.ts"),I={length:0,start:function(){return 0},end:function(){return 0}},D=function(){function j(){}return j.isBuffered=function(P,O){try{if(P){for(var v=j.getBuffered(P),T=0;T<v.length;T++)if(O>=v.start(T)&&O<=v.end(T))return!0}}catch(R){}return!1},j.bufferInfo=function(P,O,v){try{if(P){var T=j.getBuffered(P),R=[],A;for(A=0;A<T.length;A++)R.push({start:T.start(A),end:T.end(A)});return this.bufferedInfo(R,O,v)}}catch(C){}return{len:0,start:O,end:O,nextStart:void 0}},j.bufferedInfo=function(P,O,v){O=Math.max(0,O),P.sort(function(f,L){var g=f.start-L.start;return g||L.end-f.end});var T=[];if(v)for(var R=0;R<P.length;R++){var A=T.length;if(A){var C=T[A-1].end;P[R].start-C<v?P[R].end>C&&(T[A-1].end=P[R].end):T.push(P[R])}else T.push(P[R])}else T=P;for(var S=0,u,o=O,s=O,l=0;l<T.length;l++){var E=T[l].start,m=T[l].end;if(O+v>=E&&O<m)o=E,s=m,S=s-O;else if(O+v<E){u=E;break}}return{len:S,start:o||0,end:s||0,nextStart:u}},j.getBuffered=function(P){try{return P.buffered}catch(O){return $.logger.log("failed to get media.buffered",O),I}},j}()},"./src/utils/cea-608-parser.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"Row",function(){return s}),_.d(J,"CaptionScreen",function(){return l});var $=_("./src/utils/logger.ts"),I={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},D=function(c){var h=c;return I.hasOwnProperty(c)&&(h=I[c]),String.fromCharCode(h)},j=15,U=100,P={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},O={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},T={25:2,26:4,29:6,30:8,31:10,27:13,28:15},R=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],A;(function(d){d[d.ERROR=0]="ERROR",d[d.TEXT=1]="TEXT",d[d.WARNING=2]="WARNING",d[d.INFO=2]="INFO",d[d.DEBUG=3]="DEBUG",d[d.DATA=3]="DATA"})(A||(A={}));var C=function(){function d(){this.time=null,this.verboseLevel=A.ERROR}var c=d.prototype;return c.log=function(a,x){this.verboseLevel>=a&&$.logger.log(this.time+" ["+a+"] "+x)},d}(),S=function(c){for(var h=[],a=0;a<c.length;a++)h.push(c[a].toString(16));return h},u=function(){function d(h,a,x,p,b){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=h||"white",this.underline=a||!1,this.italics=x||!1,this.background=p||"black",this.flash=b||!1}var c=d.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(a){for(var x=["foreground","underline","italics","background","flash"],p=0;p<x.length;p++){var b=x[p];a.hasOwnProperty(b)&&(this[b]=a[b])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(a){return this.foreground===a.foreground&&this.underline===a.underline&&this.italics===a.italics&&this.background===a.background&&this.flash===a.flash},c.copy=function(a){this.foreground=a.foreground,this.underline=a.underline,this.italics=a.italics,this.background=a.background,this.flash=a.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},d}(),o=function(){function d(h,a,x,p,b,M){this.uchar=void 0,this.penState=void 0,this.uchar=h||" ",this.penState=new u(a,x,p,b,M)}var c=d.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(a,x){this.uchar=a,this.penState.copy(x)},c.setPenState=function(a){this.penState.copy(a)},c.equals=function(a){return this.uchar===a.uchar&&this.penState.equals(a.penState)},c.copy=function(a){this.uchar=a.uchar,this.penState.copy(a.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},d}(),s=function(){function d(h){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<U;a++)this.chars.push(new o);this.logger=h,this.pos=0,this.currPenState=new u}var c=d.prototype;return c.equals=function(a){for(var x=!0,p=0;p<U;p++)if(!this.chars[p].equals(a.chars[p])){x=!1;break}return x},c.copy=function(a){for(var x=0;x<U;x++)this.chars[x].copy(a.chars[x])},c.isEmpty=function(){for(var a=!0,x=0;x<U;x++)if(!this.chars[x].isEmpty()){a=!1;break}return a},c.setCursor=function(a){this.pos!==a&&(this.pos=a),this.pos<0?(this.logger.log(A.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>U&&(this.logger.log(A.DEBUG,"Too large cursor position "+this.pos),this.pos=U)},c.moveCursor=function(a){var x=this.pos+a;if(a>1)for(var p=this.pos+1;p<x+1;p++)this.chars[p].setPenState(this.currPenState);this.setCursor(x)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(a){a>=144&&this.backSpace();var x=D(a);if(this.pos>=U){this.logger.log(A.ERROR,"Cannot insert "+a.toString(16)+" ("+x+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(x,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(a){var x;for(x=a;x<U;x++)this.chars[x].reset()},c.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},c.clearToEndOfRow=function(){this.clearFromPos(this.pos)},c.getTextString=function(){for(var a=[],x=!0,p=0;p<U;p++){var b=this.chars[p].uchar;b!==" "&&(x=!1),a.push(b)}return x?"":a.join("")},c.setPenStyles=function(a){this.currPenState.setStyles(a);var x=this.chars[this.pos];x.setPenState(this.currPenState)},d}(),l=function(){function d(h){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<j;a++)this.rows.push(new s(h));this.logger=h,this.currRow=j-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=d.prototype;return c.reset=function(){for(var a=0;a<j;a++)this.rows[a].clear();this.currRow=j-1},c.equals=function(a){for(var x=!0,p=0;p<j;p++)if(!this.rows[p].equals(a.rows[p])){x=!1;break}return x},c.copy=function(a){for(var x=0;x<j;x++)this.rows[x].copy(a.rows[x])},c.isEmpty=function(){for(var a=!0,x=0;x<j;x++)if(!this.rows[x].isEmpty()){a=!1;break}return a},c.backSpace=function(){var a=this.rows[this.currRow];a.backSpace()},c.clearToEndOfRow=function(){var a=this.rows[this.currRow];a.clearToEndOfRow()},c.insertChar=function(a){var x=this.rows[this.currRow];x.insertChar(a)},c.setPen=function(a){var x=this.rows[this.currRow];x.setPenStyles(a)},c.moveCursor=function(a){var x=this.rows[this.currRow];x.moveCursor(a)},c.setCursor=function(a){this.logger.log(A.INFO,"setCursor: "+a);var x=this.rows[this.currRow];x.setCursor(a)},c.setPAC=function(a){this.logger.log(A.INFO,"pacData = "+JSON.stringify(a));var x=a.row-1;if(this.nrRollUpRows&&x<this.nrRollUpRows-1&&(x=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==x){for(var p=0;p<j;p++)this.rows[p].clear();var b=this.currRow+1-this.nrRollUpRows,M=this.lastOutputScreen;if(M){var G=M.rows[b].cueStartTime,Z=this.logger.time;if(G&&Z!==null&&G<Z)for(var ie=0;ie<this.nrRollUpRows;ie++)this.rows[x-this.nrRollUpRows+ie+1].copy(M.rows[b+ie])}}this.currRow=x;var z=this.rows[this.currRow];if(a.indent!==null){var F=a.indent,ne=Math.max(F-1,0);z.setCursor(a.indent),a.color=z.chars[ne].penState.foreground}var ce={foreground:a.color,underline:a.underline,italics:a.italics,background:"black",flash:!1};this.setPen(ce)},c.setBkgData=function(a){this.logger.log(A.INFO,"bkgData = "+JSON.stringify(a)),this.backSpace(),this.setPen(a),this.insertChar(32)},c.setRollUpRows=function(a){this.nrRollUpRows=a},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(A.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(A.TEXT,this.getDisplayText());var a=this.currRow+1-this.nrRollUpRows,x=this.rows.splice(a,1)[0];x.clear(),this.rows.splice(this.currRow,0,x),this.logger.log(A.INFO,"Rolling up")},c.getDisplayText=function(a){a=a||!1;for(var x=[],p="",b=-1,M=0;M<j;M++){var G=this.rows[M].getTextString();G&&(b=M+1,a?x.push("Row "+b+": '"+G+"'"):x.push(G.trim()))}return x.length>0&&(a?p="["+x.join(" | ")+"]":p=x.join(`
`)),p},c.getTextAndFormat=function(){return this.rows},d}(),E=function(){function d(h,a,x){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=h,this.outputFilter=a,this.mode=null,this.verbose=0,this.displayedMemory=new l(x),this.nonDisplayedMemory=new l(x),this.lastOutputScreen=new l(x),this.currRollUpRow=this.displayedMemory.rows[j-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=x}var c=d.prototype;return c.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[j-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(a){this.outputFilter=a},c.setPAC=function(a){this.writeScreen.setPAC(a)},c.setBkgData=function(a){this.writeScreen.setBkgData(a)},c.setMode=function(a){if(a===this.mode)return;this.mode=a,this.logger.log(A.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},c.insertChars=function(a){for(var x=0;x<a.length;x++)this.writeScreen.insertChar(a[x]);var p=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(A.INFO,p+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(A.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(A.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){if(this.logger.log(A.INFO,"BS - BackSpace"),this.mode==="MODE_TEXT")return;this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate()},c.ccAOF=function(){},c.ccAON=function(){},c.ccDER=function(){this.logger.log(A.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(a){this.logger.log(A.INFO,"RU("+a+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(a)},c.ccFON=function(){this.logger.log(A.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(A.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(A.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(A.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(A.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(A.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(A.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(A.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(A.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(a){this.logger.log(A.INFO,"TO("+a+") - Tab Offset"),this.writeScreen.moveCursor(a)},c.ccMIDROW=function(a){var x={flash:!1};if(x.underline=a%2===1,x.italics=a>=46,x.italics)x.foreground="white";else{var p=Math.floor(a/2)-16,b=["white","green","blue","cyan","red","yellow","magenta"];x.foreground=b[p]}this.logger.log(A.INFO,"MIDROW: "+JSON.stringify(x)),this.writeScreen.setPen(x)},c.outputDataUpdate=function(a){a===void 0&&(a=!1);var x=this.logger.time;if(x===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=x:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,x,this.lastOutputScreen),a&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:x),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(a){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,a,this.displayedMemory),this.cueStartTime=a))},d}(),m=function(){function d(h,a,x){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var p=new C;this.channels=[null,new E(h,a,p),new E(h+1,x,p)],this.cmdHistory=g(),this.logger=p}var c=d.prototype;return c.getHandler=function(a){return this.channels[a].getHandler()},c.setHandler=function(a,x){this.channels[a].setHandler(x)},c.addData=function(a,x){var p,b,M,G=!1;this.logger.time=a;for(var Z=0;Z<x.length;Z+=2){if(b=x[Z]&127,M=x[Z+1]&127,b===0&&M===0)continue;if(this.logger.log(A.DATA,"["+S([x[Z],x[Z+1]])+"] -> ("+S([b,M])+")"),p=this.parseCmd(b,M),p||(p=this.parseMidrow(b,M)),p||(p=this.parsePAC(b,M)),p||(p=this.parseBackgroundAttributes(b,M)),!p&&(G=this.parseChars(b,M),G)){var ie=this.currentChannel;if(ie&&ie>0){var z=this.channels[ie];z.insertChars(G)}else this.logger.log(A.WARNING,"No channel found yet. TEXT-MODE?")}!p&&!G&&this.logger.log(A.WARNING,"Couldn't parse cleaned data "+S([b,M])+" orig: "+S([x[Z],x[Z+1]]))}},c.parseCmd=function(a,x){var p=this.cmdHistory,b=(a===20||a===28||a===21||a===29)&&x>=32&&x<=47,M=(a===23||a===31)&&x>=33&&x<=35;if(!(b||M))return!1;if(L(a,x,p))return f(null,null,p),this.logger.log(A.DEBUG,"Repeated command ("+S([a,x])+") is dropped"),!0;var G=a===20||a===21||a===23?1:2,Z=this.channels[G];return a===20||a===21||a===28||a===29?x===32?Z.ccRCL():x===33?Z.ccBS():x===34?Z.ccAOF():x===35?Z.ccAON():x===36?Z.ccDER():x===37?Z.ccRU(2):x===38?Z.ccRU(3):x===39?Z.ccRU(4):x===40?Z.ccFON():x===41?Z.ccRDC():x===42?Z.ccTR():x===43?Z.ccRTD():x===44?Z.ccEDM():x===45?Z.ccCR():x===46?Z.ccENM():x===47&&Z.ccEOC():Z.ccTO(x-32),f(a,x,p),this.currentChannel=G,!0},c.parseMidrow=function(a,x){var p=0;if((a===17||a===25)&&x>=32&&x<=47){if(a===17?p=1:p=2,p!==this.currentChannel)return this.logger.log(A.ERROR,"Mismatch channel in midrow parsing"),!1;var b=this.channels[p];return b?(b.ccMIDROW(x),this.logger.log(A.DEBUG,"MIDROW ("+S([a,x])+")"),!0):!1}return!1},c.parsePAC=function(a,x){var p,b=this.cmdHistory,M=(a>=17&&a<=23||a>=25&&a<=31)&&x>=64&&x<=127,G=(a===16||a===24)&&x>=64&&x<=95;if(!(M||G))return!1;if(L(a,x,b))return f(null,null,b),!0;var Z=a<=23?1:2;x>=64&&x<=95?p=Z===1?P[a]:v[a]:p=Z===1?O[a]:T[a];var ie=this.channels[Z];return ie?(ie.setPAC(this.interpretPAC(p,x)),f(a,x,b),this.currentChannel=Z,!0):!1},c.interpretPAC=function(a,x){var p,b={color:null,italics:!1,indent:null,underline:!1,row:a};return x>95?p=x-96:p=x-64,b.underline=(p&1)===1,p<=13?b.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(p/2)]:p<=15?(b.italics=!0,b.color="white"):b.indent=Math.floor((p-16)/2)*4,b},c.parseChars=function(a,x){var p,b=null,M=null;if(a>=25?(p=2,M=a-8):(p=1,M=a),M>=17&&M<=19){var G;M===17?G=x+80:M===18?G=x+112:G=x+144,this.logger.log(A.INFO,"Special char '"+D(G)+"' in channel "+p),b=[G]}else a>=32&&a<=127&&(b=x===0?[a]:[a,x]);if(b){var Z=S(b);this.logger.log(A.DEBUG,"Char codes = "+Z.join(",")),f(a,x,this.cmdHistory)}return b},c.parseBackgroundAttributes=function(a,x){var p=(a===16||a===24)&&x>=32&&x<=47,b=(a===23||a===31)&&x>=45&&x<=47;if(!(p||b))return!1;var M,G={};a===16||a===24?(M=Math.floor((x-32)/2),G.background=R[M],x%2===1&&(G.background=G.background+"_semi")):x===45?G.background="transparent":(G.foreground="black",x===47&&(G.underline=!0));var Z=a<=23?1:2,ie=this.channels[Z];return ie.setBkgData(G),f(a,x,this.cmdHistory),!0},c.reset=function(){for(var a=0;a<Object.keys(this.channels).length;a++){var x=this.channels[a];x&&x.reset()}this.cmdHistory=g()},c.cueSplitAtTime=function(a){for(var x=0;x<this.channels.length;x++){var p=this.channels[x];p&&p.cueSplitAtTime(a)}},d}();function f(d,c,h){h.a=d,h.b=c}function L(d,c,h){return h.a===d&&h.b===c}function g(){return{a:null,b:null}}J.default=m},"./src/utils/codecs.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"isCodecType",function(){return I}),_.d(J,"isCodecSupportedInMp4",function(){return D});var $={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 I(j,U){var P=$[U];return!!P&&P[j.slice(0,4)]===!0}function D(j,U){return MediaSource.isTypeSupported((U||"video")+'/mp4;codecs="'+j+'"')}},"./src/utils/cues.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/utils/vttparser.ts"),I=_("./src/utils/webvtt-parser.ts"),D=_("./src/utils/texttrack-utils.ts"),j=/\s/,U={newCue:function(O,v,T,R){for(var A=[],C,S,u,o,s,l=self.VTTCue||self.TextTrackCue,E=0;E<R.rows.length;E++)if(C=R.rows[E],u=!0,o=0,s="",!C.isEmpty()){for(var m=0;m<C.chars.length;m++)j.test(C.chars[m].uchar)&&u?o++:(s+=C.chars[m].uchar,u=!1);C.cueStartTime=v,v===T&&(T+=1e-4),o>=16?o--:o++;var f=Object($.fixLineBreaks)(s.trim()),L=Object(I.generateCueId)(v,T,f);(!O||!O.cues||!O.cues.getCueById(L))&&(S=new l(v,T,f),S.id=L,S.line=E+1,S.align="left",S.position=10+Math.min(80,Math.floor(o*8/32)*10),A.push(S))}return O&&A.length&&(A.sort(function(g,d){return g.line==="auto"||d.line==="auto"?0:g.line>8&&d.line>8?d.line-g.line:g.line-d.line}),A.forEach(function(g){return Object(D.addCueToTrack)(O,g)})),A}};J.default=U},"./src/utils/discontinuities.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"findFirstFragWithCC",function(){return j}),_.d(J,"shouldAlignOnDiscontinuities",function(){return U}),_.d(J,"findDiscontinuousReferenceFrag",function(){return P}),_.d(J,"adjustSlidingStart",function(){return v}),_.d(J,"alignStream",function(){return T}),_.d(J,"alignPDT",function(){return A}),_.d(J,"alignFragmentByPDTDelta",function(){return C}),_.d(J,"alignMediaPlaylistByPDT",function(){return S});var $=_("./src/polyfills/number.ts"),I=_("./src/utils/logger.ts"),D=_("./src/controller/level-helper.ts");function j(u,o){for(var s=null,l=0,E=u.length;l<E;l++){var m=u[l];if(m&&m.cc===o){s=m;break}}return s}function U(u,o,s){return!!(o.details&&(s.endCC>s.startCC||u&&u.cc<s.startCC))}function P(u,o){var s=u.fragments,l=o.fragments;if(!l.length||!s.length){I.logger.log("No fragments to align");return}var E=j(s,l[0].cc);if(!E||E&&!E.startPTS){I.logger.log("No frag in previous level to align on");return}return E}function O(u,o){if(u){var s=u.start+o;u.start=u.startPTS=s,u.endPTS=s+u.duration}}function v(u,o){for(var s=o.fragments,l=0,E=s.length;l<E;l++)O(s[l],u);o.fragmentHint&&O(o.fragmentHint,u),o.alignedSliding=!0}function T(u,o,s){if(!o)return;R(u,s,o),!s.alignedSliding&&o.details&&A(s,o.details),!s.alignedSliding&&o.details&&!s.skippedSegments&&Object(D.adjustSliding)(o.details,s)}function R(u,o,s){if(U(u,s,o)){var l=P(s.details,o);l&&Object($.isFiniteNumber)(l.start)&&(I.logger.log("Adjusting PTS using last level due to CC increase within current level "+o.url),v(l.start,o))}}function A(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,l=u.fragments[0].programDateTime,E=(l-s)/1e3+o.fragments[0].start;E&&Object($.isFiniteNumber)(E)&&(I.logger.log("Adjusting PTS using programDateTime delta "+(l-s)+"ms, sliding:"+E.toFixed(3)+" "+u.url+" "),v(E,u))}function C(u,o){var s=u.programDateTime;if(!s)return;var l=(s-o)/1e3;u.start=u.startPTS=l,u.endPTS=l+u.duration}function S(u,o){if(!o.fragments.length||!u.hasProgramDateTime||!o.hasProgramDateTime)return;var s=o.fragments[0].programDateTime,l=o.fragments[0].start,E=s-l*1e3;u.fragments.forEach(function(m){C(m,E)}),u.fragmentHint&&C(u.fragmentHint,E),u.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/utils/ewma.ts"),I=function(){function D(U,P,O){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=O,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new $.default(U),this.fast_=new $.default(P)}var j=D.prototype;return j.update=function(P,O){var v=this.slow_,T=this.fast_;this.slow_.halfLife!==P&&(this.slow_=new $.default(P,v.getEstimate(),v.getTotalWeight())),this.fast_.halfLife!==O&&(this.fast_=new $.default(O,T.getEstimate(),T.getTotalWeight()))},j.sample=function(P,O){P=Math.max(P,this.minDelayMs_);var v=8*O,T=P/1e3,R=v/T;this.fast_.sample(T,R),this.slow_.sample(T,R)},j.canEstimate=function(){var P=this.fast_;return P&&P.getTotalWeight()>=this.minWeight_},j.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},j.destroy=function(){},D}();J.default=I},"./src/utils/ewma.ts":function(fe,J,_){"use strict";_.r(J);var $=function(){function I(j,U,P){U===void 0&&(U=0),P===void 0&&(P=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=j,this.alpha_=j?Math.exp(Math.log(.5)/j):0,this.estimate_=U,this.totalWeight_=P}var D=I.prototype;return D.sample=function(U,P){var O=Math.pow(this.alpha_,U);this.estimate_=P*(1-O)+O*this.estimate_,this.totalWeight_+=U},D.getTotalWeight=function(){return this.totalWeight_},D.getEstimate=function(){if(this.alpha_){var U=1-Math.pow(this.alpha_,this.totalWeight_);if(U)return this.estimate_/U}return this.estimate_},I}();J.default=$},"./src/utils/fetch-loader.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"fetchSupported",function(){return C});var $=_("./src/polyfills/number.ts"),I=_("./src/loader/load-stats.ts"),D=_("./src/demux/chunk-cache.ts");function j(l,E){l.prototype=Object.create(E.prototype),l.prototype.constructor=l,T(l,E)}function U(l){var E=typeof Map=="function"?new Map:void 0;return U=function(f){if(f===null||!v(f))return f;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(typeof E!="undefined"){if(E.has(f))return E.get(f);E.set(f,L)}function L(){return P(f,arguments,R(this).constructor)}return L.prototype=Object.create(f.prototype,{constructor:{value:L,enumerable:!1,writable:!0,configurable:!0}}),T(L,f)},U(l)}function P(l,E,m){return O()?P=Reflect.construct:P=function(L,g,d){var c=[null];c.push.apply(c,g);var h=Function.bind.apply(L,c),a=new h;return d&&T(a,d.prototype),a},P.apply(null,arguments)}function O(){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 v(l){return Function.toString.call(l).indexOf("[native code]")!==-1}function T(l,E){return T=Object.setPrototypeOf||function(f,L){return f.__proto__=L,f},T(l,E)}function R(l){return R=Object.setPrototypeOf?Object.getPrototypeOf:function(m){return m.__proto__||Object.getPrototypeOf(m)},R(l)}function A(){return A=Object.assign||function(l){for(var E=1;E<arguments.length;E++){var m=arguments[E];for(var f in m)Object.prototype.hasOwnProperty.call(m,f)&&(l[f]=m[f])}return l},A.apply(this,arguments)}function C(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(l){}return!1}var S=function(){function l(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 I.LoadStats}var E=l.prototype;return E.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},E.abortInternal=function(){var f=this.response;(!f||!f.ok)&&(this.stats.aborted=!0,this.controller.abort())},E.abort=function(){var f;this.abortInternal(),(f=this.callbacks)!==null&&f!==void 0&&f.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},E.load=function(f,L,g){var d=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var h=u(f,this.controller.signal),a=g.onProgress,x=f.responseType==="arraybuffer",p=x?"byteLength":"length";this.context=f,this.config=L,this.callbacks=g,this.request=this.fetchSetup(f,h),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){d.abortInternal(),g.onTimeout(c,f,d.response)},L.timeout),self.fetch(this.request).then(function(b){if(d.response=d.loader=b,!b.ok){var M=b.status,G=b.statusText;throw new s(G||"fetch, bad network response",M,b)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(b.headers.get("Content-Length")||"0"),a&&Object($.isFiniteNumber)(L.highWaterMark)?d.loadProgressively(b,c,f,L.highWaterMark,a):x?b.arrayBuffer():b.text()}).then(function(b){var M=d.response;self.clearTimeout(d.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=b[p];var G={url:M.url,data:b};a&&!Object($.isFiniteNumber)(L.highWaterMark)&&a(c,f,b,M),g.onSuccess(G,c,f,M)}).catch(function(b){if(self.clearTimeout(d.requestTimeout),c.aborted)return;var M=b.code||0;g.onError({code:M,text:b.message},f,b.details)})},E.getCacheAge=function(){var f=null;if(this.response){var L=this.response.headers.get("age");f=L?parseFloat(L):null}return f},E.loadProgressively=function(f,L,g,d,c){d===void 0&&(d=0);var h=new D.default,a=f.body.getReader(),x=function p(){return a.read().then(function(b){if(b.done)return h.dataLength&&c(L,g,h.flush(),f),Promise.resolve(new ArrayBuffer(0));var M=b.value,G=M.length;return L.loaded+=G,G<d||h.dataLength?(h.push(M),h.dataLength>=d&&c(L,g,h.flush(),f)):c(L,g,M,f),p()}).catch(function(){return Promise.reject()})};return x()},l}();function u(l,E){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:E,headers:new self.Headers(A({},l.headers))};return l.rangeEnd&&m.headers.set("Range","bytes="+l.rangeStart+"-"+String(l.rangeEnd-1)),m}function o(l,E){return new self.Request(l.url,E)}var s=function(l){j(E,l);function E(m,f,L){var g;return g=l.call(this,m)||this,g.code=void 0,g.details=void 0,g.code=f,g.details=L,g}return E}(U(Error));J.default=S},"./src/utils/imsc1-ttml-parser.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"IMSC1_CODEC",function(){return v}),_.d(J,"parseIMSC1",function(){return C});var $=_("./src/utils/mp4-tools.ts"),I=_("./src/utils/vttparser.ts"),D=_("./src/utils/vttcue.ts"),j=_("./src/demux/id3.ts"),U=_("./src/utils/timescale-conversion.ts"),P=_("./src/utils/webvtt-parser.ts");function O(){return O=Object.assign||function(d){for(var c=1;c<arguments.length;c++){var h=arguments[c];for(var a in h)Object.prototype.hasOwnProperty.call(h,a)&&(d[a]=h[a])}return d},O.apply(this,arguments)}var v="stpp.ttml.im1t",T=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,R=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,A={left:"start",center:"center",right:"end",start:"start",end:"end"};function C(d,c,h,a,x){var p=Object($.findBox)(new Uint8Array(d),["mdat"]);if(p.length===0){x(new Error("Could not parse IMSC1 mdat"));return}var b=p[0],M=Object(j.utf8ArrayToStr)(new Uint8Array(d,b.start,b.end-b.start)),G=Object(U.toTimescaleFromScale)(c,1,h);try{a(S(M,G))}catch(Z){x(Z)}}function S(d,c){var h=new DOMParser,a=h.parseFromString(d,"text/xml"),x=a.getElementsByTagName("tt")[0];if(!x)throw new Error("Invalid ttml");var p={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},b=Object.keys(p).reduce(function(z,F){return z[F]=x.getAttribute("ttp:"+F)||p[F],z},{}),M=x.getAttribute("xml:space")!=="preserve",G=o(u(x,"styling","style")),Z=o(u(x,"layout","region")),ie=u(x,"body","[begin]");return[].map.call(ie,function(z){var F=s(z,M);if(!F||!z.hasAttribute("begin"))return null;var ne=f(z.getAttribute("begin"),b),ce=f(z.getAttribute("dur"),b),ge=f(z.getAttribute("end"),b);if(ne===null)throw m(z);if(ge===null){if(ce===null)throw m(z);ge=ne+ce}var xe=new D.default(ne-c,ge-c,F);xe.id=Object(P.generateCueId)(xe.startTime,xe.endTime,xe.text);var Me=Z[z.getAttribute("region")],Te=G[z.getAttribute("style")];xe.position=10,xe.size=80;var Oe=l(Me,Te),Ce=Oe.textAlign;if(Ce){var we=A[Ce];we&&(xe.lineAlign=we),xe.align=Ce}return O(xe,Oe),xe}).filter(function(z){return z!==null})}function u(d,c,h){var a=d.getElementsByTagName(c)[0];return a?[].slice.call(a.querySelectorAll(h)):[]}function o(d){return d.reduce(function(c,h){var a=h.getAttribute("xml:id");return a&&(c[a]=h),c},{})}function s(d,c){return[].slice.call(d.childNodes).reduce(function(h,a,x){var p;return a.nodeName==="br"&&x?h+`
`:(p=a.childNodes)!==null&&p!==void 0&&p.length?s(a,c):c?h+a.textContent.trim().replace(/\s+/g," "):h+a.textContent},"")}function l(d,c){var h="http://www.w3.org/ns/ttml#styling",a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return a.reduce(function(x,p){var b=E(c,h,p)||E(d,h,p);return b&&(x[p]=b),x},{})}function E(d,c,h){return d.hasAttributeNS(c,h)?d.getAttributeNS(c,h):null}function m(d){return new Error("Could not parse ttml timestamp "+d)}function f(d,c){if(!d)return null;var h=Object(I.parseTimeStamp)(d);return h===null&&(T.test(d)?h=L(d,c):R.test(d)&&(h=g(d,c))),h}function L(d,c){var h=T.exec(d),a=(h[4]|0)+(h[5]|0)/c.subFrameRate;return(h[1]|0)*3600+(h[2]|0)*60+(h[3]|0)+a/c.frameRate}function g(d,c){var h=R.exec(d),a=Number(h[1]),x=h[2];switch(x){case"h":return a*3600;case"m":return a*60;case"ms":return a*1e3;case"f":return a/c.frameRate;case"t":return a/c.tickRate}return a}},"./src/utils/logger.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"enableLogs",function(){return P}),_.d(J,"logger",function(){return O});var $=function(){},I={trace:$,debug:$,log:$,warn:$,info:$,error:$},D=I;function j(v){var T=self.console[v];return T?T.bind(self.console,"["+v+"] >"):$}function U(v){for(var T=arguments.length,R=new Array(T>1?T-1:0),A=1;A<T;A++)R[A-1]=arguments[A];R.forEach(function(C){D[C]=v[C]?v[C].bind(v):j(C)})}function P(v){if(self.console&&v===!0||typeof v=="object"){U(v,"debug","log","info","warn","error");try{D.log()}catch(T){D=I}}else D=I}var O=D},"./src/utils/mediakeys-helper.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"KeySystems",function(){return $}),_.d(J,"requestMediaKeySystemAccess",function(){return I});var $;(function(D){D.WIDEVINE="com.widevine.alpha",D.PLAYREADY="com.microsoft.playready"})($||($={}));var I=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"getMediaSource",function(){return $});function $(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"bin2str",function(){return U}),_.d(J,"readUint16",function(){return P}),_.d(J,"readUint32",function(){return O}),_.d(J,"writeUint32",function(){return v}),_.d(J,"findBox",function(){return T}),_.d(J,"parseSegmentIndex",function(){return R}),_.d(J,"parseInitSegment",function(){return A}),_.d(J,"getStartDTS",function(){return C}),_.d(J,"getDuration",function(){return S}),_.d(J,"computeRawDurationFromSamples",function(){return u}),_.d(J,"offsetStartDTS",function(){return o}),_.d(J,"segmentValidRange",function(){return s}),_.d(J,"appendUint8Array",function(){return l});var $=_("./src/utils/typed-array.ts"),I=_("./src/loader/fragment.ts"),D=Math.pow(2,32)-1,j=[].push;function U(E){return String.fromCharCode.apply(null,E)}function P(E,m){"data"in E&&(m+=E.start,E=E.data);var f=E[m]<<8|E[m+1];return f<0?65536+f:f}function O(E,m){"data"in E&&(m+=E.start,E=E.data);var f=E[m]<<24|E[m+1]<<16|E[m+2]<<8|E[m+3];return f<0?4294967296+f:f}function v(E,m,f){"data"in E&&(m+=E.start,E=E.data),E[m]=f>>24,E[m+1]=f>>16&255,E[m+2]=f>>8&255,E[m+3]=f&255}function T(E,m){var f=[];if(!m.length)return f;var L,g,d;"data"in E?(L=E.data,g=E.start,d=E.end):(L=E,g=0,d=L.byteLength);for(var c=g;c<d;){var h=O(L,c),a=U(L.subarray(c+4,c+8)),x=h>1?c+h:d;if(a===m[0])if(m.length===1)f.push({data:L,start:c+8,end:x});else{var p=T({data:L,start:c+8,end:x},m.slice(1));p.length&&j.apply(f,p)}c=x}return f}function R(E){var m=T(E,["moov"]),f=m[0],L=f?f.end:null,g=T(E,["sidx"]);if(!g||!g[0])return null;var d=[],c=g[0],h=c.data[0],a=h===0?8:16,x=O(c,a);a+=4;var p=0,b=0;h===0?a+=8:a+=16,a+=2;var M=c.end+b,G=P(c,a);a+=2;for(var Z=0;Z<G;Z++){var ie=a,z=O(c,ie);ie+=4;var F=z&2147483647,ne=(z&2147483648)>>>31;if(ne===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var ce=O(c,ie);ie+=4,d.push({referenceSize:F,subsegmentDuration:ce,info:{duration:ce/x,start:M,end:M+F-1}}),M+=F,ie+=4,a=ie}return{earliestPresentationTime:p,timescale:x,version:h,referencesCount:G,references:d,moovEndOffset:L}}function A(E){for(var m=[],f=T(E,["moov","trak"]),L=0;L<f.length;L++){var g=f[L],d=T(g,["tkhd"])[0];if(d){var c=d.data[d.start],h=c===0?12:20,a=O(d,h),x=T(g,["mdia","mdhd"])[0];if(x){c=x.data[x.start],h=c===0?12:20;var p=O(x,h),b=T(g,["mdia","hdlr"])[0];if(b){var M=U(b.data.subarray(b.start+8,b.start+12)),G={soun:I.ElementaryStreamTypes.AUDIO,vide:I.ElementaryStreamTypes.VIDEO}[M];if(G){var Z=T(g,["mdia","minf","stbl","stsd"])[0],ie=void 0;Z&&(ie=U(Z.data.subarray(Z.start+12,Z.start+16))),m[a]={timescale:p,type:G},m[G]={timescale:p,id:a,codec:ie}}}}}}var z=T(E,["moov","mvex","trex"]);return z.forEach(function(F){var ne=O(F,4),ce=m[ne];ce&&(ce.default={duration:O(F,12),flags:O(F,20)})}),m}function C(E,m){return T(m,["moof","traf"]).reduce(function(f,L){var g=T(L,["tfdt"])[0],d=g.data[g.start],c=T(L,["tfhd"]).reduce(function(h,a){var x=O(a,4),p=E[x];if(p){var b=O(g,4);d===1&&(b*=Math.pow(2,32),b+=O(g,8));var M=p.timescale||9e4,G=b/M;if(isFinite(G)&&(h===null||G<h))return G}return h},null);return c!==null&&isFinite(c)&&(f===null||c<f)?c:f},null)||0}function S(E,m){for(var f=0,L=0,g=0,d=T(E,["moof","traf"]),c=0;c<d.length;c++){var h=d[c],a=T(h,["tfhd"])[0],x=O(a,4),p=m[x];if(!p)continue;var b=p.default,M=O(a,0)|(b==null?void 0:b.flags),G=b==null?void 0:b.duration;M&8&&(M&2?G=O(a,12):G=O(a,8));for(var Z=p.timescale||9e4,ie=T(h,["trun"]),z=0;z<ie.length;z++){if(G){var F=O(ie[z],4);f=G*F}else f=u(ie[z]);p.type===I.ElementaryStreamTypes.VIDEO?L+=f/Z:p.type===I.ElementaryStreamTypes.AUDIO&&(g+=f/Z)}}if(L===0&&g===0){var ne=R(E);if(ne!=null&&ne.references)return ne.references.reduce(function(ce,ge){return ce+ge.info.duration||0},0)}return L||g}function u(E){var m=O(E,0),f=8;m&1&&(f+=4),m&4&&(f+=4);for(var L=0,g=O(E,4),d=0;d<g;d++){if(m&256){var c=O(E,f);L+=c,f+=4}m&512&&(f+=4),m&1024&&(f+=4),m&2048&&(f+=4)}return L}function o(E,m,f){T(m,["moof","traf"]).forEach(function(L){T(L,["tfhd"]).forEach(function(g){var d=O(g,4),c=E[d];if(!c)return;var h=c.timescale||9e4;T(L,["tfdt"]).forEach(function(a){var x=a.data[a.start],p=O(a,4);if(x===0)v(a,4,p-f*h);else{p*=Math.pow(2,32),p+=O(a,8),p-=f*h,p=Math.max(p,0);var b=Math.floor(p/(D+1)),M=Math.floor(p%(D+1));v(a,4,b),v(a,8,M)}})})})}function s(E){var m={valid:null,remainder:null},f=T(E,["moof"]);if(f){if(f.length<2)return m.remainder=E,m}else return m;var L=f[f.length-1];return m.valid=Object($.sliceUint8)(E,0,L.start-8),m.remainder=Object($.sliceUint8)(E,L.start-8),m}function l(E,m){var f=new Uint8Array(E.length+m.length);return f.set(E),f.set(m,E.length),f}},"./src/utils/output-filter.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"default",function(){return $});var $=function(){function I(j,U){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=j,this.trackName=U}var D=I.prototype;return D.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},D.newCue=function(U,P,O){(this.startTime===null||this.startTime>U)&&(this.startTime=U),this.endTime=P,this.screen=O,this.timelineController.createCaptionsTrack(this.trackName)},D.reset=function(){this.cueRanges=[]},I}()},"./src/utils/texttrack-utils.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"sendAddTrackEvent",function(){return I}),_.d(J,"addCueToTrack",function(){return D}),_.d(J,"clearCurrentCues",function(){return j}),_.d(J,"removeCuesInRange",function(){return U}),_.d(J,"getCuesInRange",function(){return O});var $=_("./src/utils/logger.ts");function I(v,T){var R;try{R=new Event("addtrack")}catch(A){R=document.createEvent("Event"),R.initEvent("addtrack",!1,!1)}R.track=v,T.dispatchEvent(R)}function D(v,T){var R=v.mode;if(R==="disabled"&&(v.mode="hidden"),v.cues&&!v.cues.getCueById(T.id))try{if(v.addCue(T),!v.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(C){$.logger.debug("[texttrack-utils]: "+C);var A=new self.TextTrackCue(T.startTime,T.endTime,T.text);A.id=T.id,v.addCue(A)}R==="disabled"&&(v.mode=R)}function j(v){var T=v.mode;if(T==="disabled"&&(v.mode="hidden"),v.cues)for(var R=v.cues.length;R--;)v.removeCue(v.cues[R]);T==="disabled"&&(v.mode=T)}function U(v,T,R){var A=v.mode;if(A==="disabled"&&(v.mode="hidden"),v.cues&&v.cues.length>0)for(var C=O(v.cues,T,R),S=0;S<C.length;S++)v.removeCue(C[S]);A==="disabled"&&(v.mode=A)}function P(v,T){if(T<v[0].startTime)return 0;var R=v.length-1;if(T>v[R].endTime)return-1;for(var A=0,C=R;A<=C;){var S=Math.floor((C+A)/2);if(T<v[S].startTime)C=S-1;else if(T>v[S].startTime&&A<R)A=S+1;else return S}return v[A].startTime-T<T-v[C].startTime?A:C}function O(v,T,R){var A=[],C=P(v,T);if(C>-1)for(var S=C,u=v.length;S<u;S++){var o=v[S];if(o.startTime>=T&&o.endTime<=R)A.push(o);else if(o.startTime>R)return A}return A}},"./src/utils/time-ranges.ts":function(fe,J,_){"use strict";_.r(J);var $={toString:function(D){for(var j="",U=D.length,P=0;P<U;P++)j+="["+D.start(P).toFixed(3)+","+D.end(P).toFixed(3)+"]";return j}};J.default=$},"./src/utils/timescale-conversion.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"toTimescaleFromBase",function(){return I}),_.d(J,"toTimescaleFromScale",function(){return D}),_.d(J,"toMsFromMpegTsClock",function(){return j}),_.d(J,"toMpegTsClockFromTimescale",function(){return U});var $=9e4;function I(P,O,v,T){v===void 0&&(v=1),T===void 0&&(T=!1);var R=P*O*v;return T?Math.round(R):R}function D(P,O,v,T){return v===void 0&&(v=1),T===void 0&&(T=!1),I(P,O,1/v,T)}function j(P,O){return O===void 0&&(O=!1),I(P,1e3,1/$,O)}function U(P,O){return O===void 0&&(O=1),I(P,$,1/O)}},"./src/utils/typed-array.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"sliceUint8",function(){return $});function $(I,D,j){return Uint8Array.prototype.slice?I.slice(D,j):new Uint8Array(Array.prototype.slice.call(I,D,j))}},"./src/utils/vttcue.ts":function(fe,J,_){"use strict";_.r(J),J.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var $=["","lr","rl"],I=["start","middle","end","left","right"];function D(v,T){if(typeof T!="string")return!1;if(!Array.isArray(v))return!1;var R=T.toLowerCase();return~v.indexOf(R)?R:!1}function j(v){return D($,v)}function U(v){return D(I,v)}function P(v){for(var T=arguments.length,R=new Array(T>1?T-1:0),A=1;A<T;A++)R[A-1]=arguments[A];for(var C=1;C<arguments.length;C++){var S=arguments[C];for(var u in S)v[u]=S[u]}return v}function O(v,T,R){var A=this,C={enumerable:!0};A.hasBeenReset=!1;var S="",u=!1,o=v,s=T,l=R,E=null,m="",f=!0,L="auto",g="start",d=50,c="middle",h=50,a="middle";Object.defineProperty(A,"id",P({},C,{get:function(){return S},set:function(p){S=""+p}})),Object.defineProperty(A,"pauseOnExit",P({},C,{get:function(){return u},set:function(p){u=!!p}})),Object.defineProperty(A,"startTime",P({},C,{get:function(){return o},set:function(p){if(typeof p!="number")throw new TypeError("Start time must be set to a number.");o=p,this.hasBeenReset=!0}})),Object.defineProperty(A,"endTime",P({},C,{get:function(){return s},set:function(p){if(typeof p!="number")throw new TypeError("End time must be set to a number.");s=p,this.hasBeenReset=!0}})),Object.defineProperty(A,"text",P({},C,{get:function(){return l},set:function(p){l=""+p,this.hasBeenReset=!0}})),Object.defineProperty(A,"region",P({},C,{get:function(){return E},set:function(p){E=p,this.hasBeenReset=!0}})),Object.defineProperty(A,"vertical",P({},C,{get:function(){return m},set:function(p){var b=j(p);if(b===!1)throw new SyntaxError("An invalid or illegal string was specified.");m=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"snapToLines",P({},C,{get:function(){return f},set:function(p){f=!!p,this.hasBeenReset=!0}})),Object.defineProperty(A,"line",P({},C,{get:function(){return L},set:function(p){if(typeof p!="number"&&p!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");L=p,this.hasBeenReset=!0}})),Object.defineProperty(A,"lineAlign",P({},C,{get:function(){return g},set:function(p){var b=U(p);if(!b)throw new SyntaxError("An invalid or illegal string was specified.");g=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"position",P({},C,{get:function(){return d},set:function(p){if(p<0||p>100)throw new Error("Position must be between 0 and 100.");d=p,this.hasBeenReset=!0}})),Object.defineProperty(A,"positionAlign",P({},C,{get:function(){return c},set:function(p){var b=U(p);if(!b)throw new SyntaxError("An invalid or illegal string was specified.");c=b,this.hasBeenReset=!0}})),Object.defineProperty(A,"size",P({},C,{get:function(){return h},set:function(p){if(p<0||p>100)throw new Error("Size must be between 0 and 100.");h=p,this.hasBeenReset=!0}})),Object.defineProperty(A,"align",P({},C,{get:function(){return a},set:function(p){var b=U(p);if(!b)throw new SyntaxError("An invalid or illegal string was specified.");a=b,this.hasBeenReset=!0}})),A.displayState=void 0}return O.prototype.getCueAsHTML=function(){var v=self.WebVTT;return v.convertCueToDOMTree(self,this.text)},O}()},"./src/utils/vttparser.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"parseTimeStamp",function(){return D}),_.d(J,"fixLineBreaks",function(){return T}),_.d(J,"VTTParser",function(){return R});var $=_("./src/utils/vttcue.ts"),I=function(){function A(){}var C=A.prototype;return C.decode=function(u,o){if(!u)return"";if(typeof u!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(u))},A}();function D(A){function C(u,o,s,l){return(u|0)*3600+(o|0)*60+(s|0)+parseFloat(l||0)}var S=A.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return S?parseFloat(S[2])>59?C(S[2],S[3],0,S[4]):C(S[1],S[2],S[3],S[4]):null}var j=function(){function A(){this.values=Object.create(null)}var C=A.prototype;return C.set=function(u,o){!this.get(u)&&o!==""&&(this.values[u]=o)},C.get=function(u,o,s){return s?this.has(u)?this.values[u]:o[s]:this.has(u)?this.values[u]:o},C.has=function(u){return u in this.values},C.alt=function(u,o,s){for(var l=0;l<s.length;++l)if(o===s[l]){this.set(u,o);break}},C.integer=function(u,o){/^-?\d+$/.test(o)&&this.set(u,parseInt(o,10))},C.percent=function(u,o){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(o)){var s=parseFloat(o);if(s>=0&&s<=100)return this.set(u,s),!0}return!1},A}();function U(A,C,S,u){var o=u?A.split(u):[A];for(var s in o){if(typeof o[s]!="string")continue;var l=o[s].split(S);if(l.length!==2)continue;var E=l[0],m=l[1];C(E,m)}}var P=new $.default(0,0,""),O=P.align==="middle"?"middle":"center";function v(A,C,S){var u=A;function o(){var E=D(A);if(E===null)throw new Error("Malformed timestamp: "+u);return A=A.replace(/^[^\sa-zA-Z-]+/,""),E}function s(E,m){var f=new j;U(E,function(d,c){var h;switch(d){case"region":for(var a=S.length-1;a>=0;a--)if(S[a].id===c){f.set(d,S[a].region);break}break;case"vertical":f.alt(d,c,["rl","lr"]);break;case"line":h=c.split(","),f.integer(d,h[0]),f.percent(d,h[0])&&f.set("snapToLines",!1),f.alt(d,h[0],["auto"]),h.length===2&&f.alt("lineAlign",h[1],["start",O,"end"]);break;case"position":h=c.split(","),f.percent(d,h[0]),h.length===2&&f.alt("positionAlign",h[1],["start",O,"end","line-left","line-right","auto"]);break;case"size":f.percent(d,c);break;case"align":f.alt(d,c,["start",O,"end","left","right"]);break}},/:/,/\s/),m.region=f.get("region",null),m.vertical=f.get("vertical","");var L=f.get("line","auto");L==="auto"&&P.line===-1&&(L=-1),m.line=L,m.lineAlign=f.get("lineAlign","start"),m.snapToLines=f.get("snapToLines",!0),m.size=f.get("size",100),m.align=f.get("align",O);var g=f.get("position","auto");g==="auto"&&P.position===50&&(g=m.align==="start"||m.align==="left"?0:m.align==="end"||m.align==="right"?100:50),m.position=g}function l(){A=A.replace(/^\s+/,"")}if(l(),C.startTime=o(),l(),A.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+u);A=A.substr(3),l(),C.endTime=o(),l(),s(A,C)}function T(A){return A.replace(/<br(?: \/)?>/gi,`
`)}var R=function(){function A(){this.state="INITIAL",this.buffer="",this.decoder=new I,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var C=A.prototype;return C.parse=function(u){var o=this;u&&(o.buffer+=o.decoder.decode(u,{stream:!0}));function s(){var g=o.buffer,d=0;for(g=T(g);d<g.length&&g[d]!=="\r"&&g[d]!==`
`;)++d;var c=g.substr(0,d);return g[d]==="\r"&&++d,g[d]===`
`&&++d,o.buffer=g.substr(d),c}function l(g){U(g,function(d,c){},/:/)}try{var E="";if(o.state==="INITIAL"){if(!/\r\n|\n/.test(o.buffer))return this;E=s();var m=E.match(/^()?WEBVTT([ \t].*)?$/);if(!m||!m[0])throw new Error("Malformed WebVTT signature.");o.state="HEADER"}for(var f=!1;o.buffer;){if(!/\r\n|\n/.test(o.buffer))return this;f?f=!1:E=s();switch(o.state){case"HEADER":/:/.test(E)?l(E):E||(o.state="ID");continue;case"NOTE":E||(o.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(E)){o.state="NOTE";break}if(!E)continue;if(o.cue=new $.default(0,0,""),o.state="CUE",E.indexOf("-->")===-1){o.cue.id=E;continue}case"CUE":if(!o.cue){o.state="BADCUE";continue}try{v(E,o.cue,o.regionList)}catch(g){o.cue=null,o.state="BADCUE";continue}o.state="CUETEXT";continue;case"CUETEXT":{var L=E.indexOf("-->")!==-1;if(!E||L&&(f=!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+=E}continue;case"BADCUE":E||(o.state="ID")}}}catch(g){o.state==="CUETEXT"&&o.cue&&o.oncue&&o.oncue(o.cue),o.cue=null,o.state=o.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},C.flush=function(){var u=this;try{if((u.cue||u.state==="HEADER")&&(u.buffer+=`
`,u.parse()),u.state==="INITIAL"||u.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(o){u.onparsingerror&&u.onparsingerror(o)}return u.onflush&&u.onflush(),this},A}()},"./src/utils/webvtt-parser.ts":function(fe,J,_){"use strict";_.r(J),_.d(J,"generateCueId",function(){return R}),_.d(J,"parseWebVTT",function(){return C});var $=_("./src/polyfills/number.ts"),I=_("./src/utils/vttparser.ts"),D=_("./src/demux/id3.ts"),j=_("./src/utils/timescale-conversion.ts"),U=_("./src/remux/mp4-remuxer.ts"),P=/\r\n|\n\r|\n|\r/g,O=function(u,o,s){return s===void 0&&(s=0),u.substr(s,o.length)===o},v=function(u){var o=parseInt(u.substr(-3)),s=parseInt(u.substr(-6,2)),l=parseInt(u.substr(-9,2)),E=u.length>9?parseInt(u.substr(0,u.indexOf(":"))):0;if(!Object($.isFiniteNumber)(o)||!Object($.isFiniteNumber)(s)||!Object($.isFiniteNumber)(l)||!Object($.isFiniteNumber)(E))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+u);return o+=1e3*s,o+=60*1e3*l,o+=60*60*1e3*E,o},T=function(u){for(var o=5381,s=u.length;s;)o=o*33^u.charCodeAt(--s);return(o>>>0).toString()};function R(S,u,o){return T(S.toString())+T(u.toString())+T(o)}var A=function(u,o,s){var l=u[o],E=u[l.prevCC];if(!E||!E.new&&l.new){u.ccOffset=u.presentationOffset=l.start,l.new=!1;return}for(;(m=E)!==null&&m!==void 0&&m.new;){var m;u.ccOffset+=l.start-E.start,l.new=!1,l=E,E=u[l.prevCC]}u.presentationOffset=s};function C(S,u,o,s,l,E,m,f){var L=new I.VTTParser,g=Object(D.utf8ArrayToStr)(new Uint8Array(S)).trim().replace(P,`
`).split(`
`),d=[],c=Object(j.toMpegTsClockFromTimescale)(u,o),h="00:00.000",a=0,x=0,p,b=!0,M=!1;L.oncue=function(G){var Z=s[l],ie=s.ccOffset,z=(a-c)/9e4;if(Z!=null&&Z.new&&(x!==void 0?ie=s.ccOffset=Z.start:A(s,l,z)),z&&(ie=z-s.presentationOffset),M){var F=G.endTime-G.startTime,ne=Object(U.normalizePts)((G.startTime+ie-x)*9e4,E*9e4)/9e4;G.startTime=ne,G.endTime=ne+F}var ce=G.text.trim();G.text=decodeURIComponent(encodeURIComponent(ce)),G.id||(G.id=R(G.startTime,G.endTime,ce)),G.endTime>0&&d.push(G)},L.onparsingerror=function(G){p=G},L.onflush=function(){if(p){f(p);return}m(d)},g.forEach(function(G){if(b)if(O(G,"X-TIMESTAMP-MAP=")){b=!1,M=!0,G.substr(16).split(",").forEach(function(Z){O(Z,"LOCAL:")?h=Z.substr(6):O(Z,"MPEGTS:")&&(a=parseInt(Z.substr(7)))});try{x=v(h)/1e3}catch(Z){M=!1,p=Z}return}else G===""&&(b=!1);L.parse(G+`
`)}),L.flush()}},"./src/utils/xhr-loader.ts":function(fe,J,_){"use strict";_.r(J);var $=_("./src/utils/logger.ts"),I=_("./src/loader/load-stats.ts"),D=/^age:\s*[\d.]+\s*$/m,j=function(){function U(O){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=O?O.xhrSetup:null,this.stats=new I.LoadStats,this.retryDelay=0}var P=U.prototype;return P.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},P.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()))},P.abort=function(){var v;this.abortInternal(),(v=this.callbacks)!==null&&v!==void 0&&v.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},P.load=function(v,T,R){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=v,this.config=T,this.callbacks=R,this.retryDelay=T.retryDelay,this.loadInternal()},P.loadInternal=function(){var v=this.config,T=this.context;if(!v)return;var R=this.loader=new self.XMLHttpRequest,A=this.stats;A.loading.first=0,A.loaded=0;var C=this.xhrSetup;try{if(C)try{C(R,T.url)}catch(o){R.open("GET",T.url,!0),C(R,T.url)}R.readyState||R.open("GET",T.url,!0);var S=this.context.headers;if(S)for(var u in S)R.setRequestHeader(u,S[u])}catch(o){this.callbacks.onError({code:R.status,text:o.message},T,R);return}T.rangeEnd&&R.setRequestHeader("Range","bytes="+T.rangeStart+"-"+(T.rangeEnd-1)),R.onreadystatechange=this.readystatechange.bind(this),R.onprogress=this.loadprogress.bind(this),R.responseType=T.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout),R.send()},P.readystatechange=function(){var v=this.context,T=this.loader,R=this.stats;if(!v||!T)return;var A=T.readyState,C=this.config;if(R.aborted)return;if(A>=2)if(self.clearTimeout(this.requestTimeout),R.loading.first===0&&(R.loading.first=Math.max(self.performance.now(),R.loading.start)),A===4){T.onreadystatechange=null,T.onprogress=null;var S=T.status;if(S>=200&&S<300){R.loading.end=Math.max(self.performance.now(),R.loading.first);var u,o;if(v.responseType==="arraybuffer"?(u=T.response,o=u.byteLength):(u=T.responseText,o=u.length),R.loaded=R.total=o,!this.callbacks)return;var s=this.callbacks.onProgress;if(s&&s(R,v,u,T),!this.callbacks)return;var l={url:T.responseURL,data:u};this.callbacks.onSuccess(l,R,v,T)}else R.retry>=C.maxRetry||S>=400&&S<499?($.logger.error(S+" while loading "+v.url),this.callbacks.onError({code:S,text:T.statusText},v,T)):($.logger.warn(S+" 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,C.maxRetryDelay),R.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),C.timeout)},P.loadtimeout=function(){$.logger.warn("timeout while loading "+this.context.url);var v=this.callbacks;v&&(this.abortInternal(),v.onTimeout(this.stats,this.context,this.loader))},P.loadprogress=function(v){var T=this.stats;T.loaded=v.loaded,v.lengthComputable&&(T.total=v.total)},P.getCacheAge=function(){var v=null;if(this.loader&&D.test(this.loader.getAllResponseHeaders())){var T=this.loader.getResponseHeader("age");v=T?parseFloat(T):null}return v},U}();J.default=j}}).default})},vHTk:function(dt,et,le){dt.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}}}]);