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__Forums__Detail__id.4ece7...

367 lines
948 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[146,5,7,17],{"+NIl":function(ht,ot,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";ie.defineMode("stex",function(Y,D){"use strict";function V(L,x){L.cmdState.push(x)}function I(L){return L.cmdState.length>0?L.cmdState[L.cmdState.length-1]:null}function w(L){var x=L.cmdState.pop();x&&x.closeBracket()}function B(L){for(var x=L.cmdState,S=x.length-1;S>=0;S--){var d=x[S];if(d.name=="DEFAULT")continue;return d}return{styleIdentifier:function(){return null}}}function N(L,x,S){return function(){this.name=L,this.bracketNo=0,this.style=x,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 M={};M.importmodule=N("importmodule","tag",["string","builtin"]),M.documentclass=N("documentclass","tag",["","atom"]),M.usepackage=N("usepackage","tag",["atom"]),M.begin=N("begin","tag",["atom"]),M.end=N("end","tag",["atom"]),M.label=N("label","tag",["atom"]),M.ref=N("ref","tag",["atom"]),M.eqref=N("eqref","tag",["atom"]),M.cite=N("cite","tag",["atom"]),M.bibitem=N("bibitem","tag",["atom"]),M.Bibitem=N("Bibitem","tag",["atom"]),M.RBibitem=N("RBibitem","tag",["atom"]),M.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function k(L,x){L.f=x}function p(L,x){var S;if(L.match(/^\\[a-zA-Z@]+/)){var d=L.current().slice(1);return S=M.hasOwnProperty(d)?M[d]:M.DEFAULT,S=new S,V(x,S),k(x,P),S.style}if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/\\]/))return"tag";if(L.match("\\["))return k(x,function(l,h){return y(l,h,"\\]")}),"keyword";if(L.match("\\("))return k(x,function(l,h){return y(l,h,"\\)")}),"keyword";if(L.match("$$"))return k(x,function(l,h){return y(l,h,"$$")}),"keyword";if(L.match("$"))return k(x,function(l,h){return y(l,h,"$")}),"keyword";var a=L.next();if(a=="%")return L.skipToEnd(),"comment";if(a=="}"||a=="]"){if(S=I(x),S)S.closeBracket(a),k(x,P);else return"error";return"bracket"}else return a=="{"||a=="["?(S=M.DEFAULT,S=new S,V(x,S),"bracket"):/\d/.test(a)?(L.eatWhile(/[\w.%]/),"atom"):(L.eatWhile(/[\w\-_]/),S=B(x),S.name=="begin"&&(S.argument=L.current()),S.styleIdentifier())}function y(L,x,S){if(L.eatSpace())return null;if(S&&L.match(S))return k(x,p),"keyword";if(L.match(/^\\[a-zA-Z@]+/))return"tag";if(L.match(/^[a-zA-Z]+/))return"variable-2";if(L.match(/^\\[$&%#{}_]/))return"tag";if(L.match(/^\\[,;!\/]/))return"tag";if(L.match(/^[\^_&]/))return"tag";if(L.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(L.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var d=L.next();return d=="{"||d=="}"||d=="["||d=="]"||d=="("||d==")"?"bracket":d=="%"?(L.skipToEnd(),"comment"):"error"}function P(L,x){var S=L.peek(),d;return S=="{"||S=="["?(d=I(x),d.openBracket(S),L.eat(S),k(x,p),"bracket"):/[ \t\r]/.test(S)?(L.eat(S),null):(k(x,p),w(x),p(L,x))}return{startState:function(){var L=D.inMathMode?function(x,S){return y(x,S)}:p;return{cmdState:[],f:L}},copyState:function(L){return{cmdState:L.cmdState.slice(),f:L.f}},token:function(L,x){return x.f(L,x)},blankLine:function(L){L.f=p,L.cmdState.length=0},lineComment:"%"}}),ie.defineMIME("text/x-stex","stex"),ie.defineMIME("text/x-latex","stex")})},"19Vz":function(ht,ot,re){(function(ie){ie(re("VrN/"))})(function(ie){ie.defineOption("placeholder","",function(N,M,k){var p=k&&k!=ie.Init;if(M&&!p)N.on("blur",I),N.on("change",w),N.on("swapDoc",w),ie.on(N.getInputField(),"compositionupdate",N.state.placeholderCompose=function(){V(N)}),w(N);else if(!M&&p){N.off("blur",I),N.off("change",w),N.off("swapDoc",w),ie.off(N.getInputField(),"compositionupdate",N.state.placeholderCompose),Y(N);var y=N.getWrapperElement();y.className=y.className.replace(" CodeMirror-empty","")}M&&!N.hasFocus()&&I(N)});function Y(N){N.state.placeholder&&(N.state.placeholder.parentNode.removeChild(N.state.placeholder),N.state.placeholder=null)}function D(N){Y(N);var M=N.state.placeholder=document.createElement("pre");M.style.cssText="height: 0; overflow: visible",M.style.direction=N.getOption("direction"),M.className="CodeMirror-placeholder CodeMirror-line-like";var k=N.getOption("placeholder");typeof k=="string"&&(k=document.createTextNode(k)),M.appendChild(k),N.display.lineSpace.insertBefore(M,N.display.lineSpace.firstChild)}function V(N){setTimeout(function(){var M=!1,k=N.getInputField();k.nodeName=="TEXTAREA"?M=!k.value:N.lineCount()==1&&(M=!/[^\u200b]/.test(k.querySelector(".CodeMirror-line").textContent)),M?D(N):Y(N)},20)}function I(N){B(N)&&D(N)}function w(N){var M=N.getWrapperElement(),k=B(N);M.className=M.className.replace(" CodeMirror-empty","")+(k?" CodeMirror-empty":""),k?D(N):Y(N)}function B(N){return N.lineCount()===1&&N.getLine(0)===""}})},"1eCo":function(ht,ot,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";var Y={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},D={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};ie.defineMode("xml",function(V,I){var w=V.indentUnit,B={},N=I.htmlMode?Y:D;for(var M in N)B[M]=N[M];for(var M in I)B[M]=I[M];var k,p;function y(o,C){function E(j){return C.tokenize=j,j(o,C)}var v=o.next();if(v=="<")return o.eat("!")?o.eat("[")?o.match("CDATA[")?E(x("atom","]]>")):null:o.match("--")?E(x("comment","-->")):o.match("DOCTYPE",!0,!0)?(o.eatWhile(/[\w\._\-]/),E(S(1))):null:o.eat("?")?(o.eatWhile(/[\w\._\-]/),C.tokenize=x("meta","?>"),"meta"):(k=o.eat("/")?"closeTag":"openTag",C.tokenize=P,"tag bracket");if(v=="&"){var O;return o.eat("#")?o.eat("x")?O=o.eatWhile(/[a-fA-F\d]/)&&o.eat(";"):O=o.eatWhile(/[\d]/)&&o.eat(";"):O=o.eatWhile(/[\w\.\-:]/)&&o.eat(";"),O?"atom":"error"}else return o.eatWhile(/[^&<]/),null}y.isInText=!0;function P(o,C){var E=o.next();if(E==">"||E=="/"&&o.eat(">"))return C.tokenize=y,k=E==">"?"endTag":"selfcloseTag","tag bracket";if(E=="=")return k="equals",null;if(E=="<"){C.tokenize=y,C.state=h,C.tagName=C.tagStart=null;var v=C.tokenize(o,C);return v?v+" tag error":"tag error"}else return/[\'\"]/.test(E)?(C.tokenize=L(E),C.stringStartCol=o.column(),C.tokenize(o,C)):(o.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function L(o){var C=function(E,v){for(;!E.eol();)if(E.next()==o){v.tokenize=P;break}return"string"};return C.isInAttribute=!0,C}function x(o,C){return function(E,v){for(;!E.eol();){if(E.match(C)){v.tokenize=y;break}E.next()}return o}}function S(o){return function(C,E){for(var v;(v=C.next())!=null;){if(v=="<")return E.tokenize=S(o+1),E.tokenize(C,E);if(v==">")if(o==1){E.tokenize=y;break}else return E.tokenize=S(o-1),E.tokenize(C,E)}return"meta"}}function d(o,C,E){this.prev=o.context,this.tagName=C,this.indent=o.indented,this.startOfLine=E,(B.doNotIndent.hasOwnProperty(C)||o.context&&o.context.noIndent)&&(this.noIndent=!0)}function a(o){o.context&&(o.context=o.context.prev)}function l(o,C){for(var E;;){if(!o.context)return;if(E=o.context.tagName,!B.contextGrabbers.hasOwnProperty(E)||!B.contextGrabbers[E].hasOwnProperty(C))return;a(o)}}function h(o,C,E){return o=="openTag"?(E.tagStart=C.column(),_):o=="closeTag"?f:h}function _(o,C,E){return o=="word"?(E.tagName=C.current(),p="tag",T):B.allowMissingTagName&&o=="endTag"?(p="tag bracket",T(o,C,E)):(p="error",_)}function f(o,C,E){if(o=="word"){var v=C.current();return E.context&&E.context.tagName!=v&&B.implicitlyClosed.hasOwnProperty(E.context.tagName)&&a(E),E.context&&E.context.tagName==v||B.matchClosing===!1?(p="tag",b):(p="tag error",R)}else return B.allowMissingTagName&&o=="endTag"?(p="tag bracket",b(o,C,E)):(p="error",R)}function b(o,C,E){return o!="endTag"?(p="error",b):(a(E),h)}function R(o,C,E){return p="error",b(o,C,E)}function T(o,C,E){if(o=="word")return p="attribute",g;if(o=="endTag"||o=="selfcloseTag"){var v=E.tagName,O=E.tagStart;return E.tagName=E.tagStart=null,o=="selfcloseTag"||B.autoSelfClosers.hasOwnProperty(v)?l(E,v):(l(E,v),E.context=new d(E,v,O==E.indented)),h}return p="error",T}function g(o,C,E){return o=="equals"?c:(B.allowMissing||(p="error"),T(o,C,E))}function c(o,C,E){return o=="string"?u:o=="word"&&B.allowUnquoted?(p="string",T):(p="error",T(o,C,E))}function u(o,C,E){return o=="string"?u:T(o,C,E)}return{startState:function(o){var C={tokenize:y,state:h,indented:o||0,tagName:null,tagStart:null,context:null};return o!=null&&(C.baseIndent=o),C},token:function(o,C){if(!C.tagName&&o.sol()&&(C.indented=o.indentation()),o.eatSpace())return null;k=null;var E=C.tokenize(o,C);return(E||k)&&E!="comment"&&(p=null,C.state=C.state(k||E,o,C),p&&(E=p=="error"?E+" error":p)),E},indent:function(o,C,E){var v=o.context;if(o.tokenize.isInAttribute)return o.tagStart==o.indented?o.stringStartCol+1:o.indented+w;if(v&&v.noIndent)return ie.Pass;if(o.tokenize!=P&&o.tokenize!=y)return E?E.match(/^(\s*)/)[0].length:0;if(o.tagName)return B.multilineTagIndentPastTag!==!1?o.tagStart+o.tagName.length+2:o.tagStart+w*(B.multilineTagIndentFactor||1);if(B.alignCDATA&&/<!\[CDATA\[/.test(C))return 0;var O=C&&/^<(\/)?([\w_:\.-]*)/.exec(C);if(O&&O[1])for(;v;)if(v.tagName==O[2]){v=v.prev;break}else if(B.implicitlyClosed.hasOwnProperty(v.tagName))v=v.prev;else break;else if(O)for(;v;){var j=B.contextGrabbers[v.tagName];if(j&&j.hasOwnProperty(O[2]))v=v.prev;else break}for(;v&&v.prev&&!v.startOfLine;)v=v.prev;return v?v.indent+w:o.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:B.htmlMode?"html":"xml",helperType:B.htmlMode?"html":"xml",skipAttribute:function(o){o.state==c&&(o.state=T)},xmlCurrentTag:function(o){return o.tagName?{name:o.tagName,close:o.type=="closeTag"}:null},xmlCurrentContext:function(o){for(var C=[],E=o.context;E;E=E.prev)E.tagName&&C.push(E.tagName);return C.reverse()}}}),ie.defineMIME("text/xml","xml"),ie.defineMIME("application/xml","xml"),ie.mimeModes.hasOwnProperty("text/html")||ie.defineMIME("text/html",{name:"xml",htmlMode:!0})})},"55Ip":function(ht,ot,re){"use strict";re.d(ot,"a",function(){return l}),re.d(ot,"b",function(){return T});var ie=re("Ty5D"),Y=re("dI71"),D=re("q1tI"),V=re.n(D),I=re("YS25"),w=re("17x9"),B=re.n(w),N=re("wx14"),M=re("zLVn"),k=re("9R94"),p=function(c){Object(Y.a)(u,c);function u(){for(var C,E=arguments.length,v=new Array(E),O=0;O<E;O++)v[O]=arguments[O];return C=c.call.apply(c,[this].concat(v))||this,C.history=Object(I.a)(C.props),C}var o=u.prototype;return o.render=function(){return V.a.createElement(ie.c,{history:this.history,children:this.props.children})},u}(V.a.Component),y=function(c){Object(Y.a)(u,c);function u(){for(var C,E=arguments.length,v=new Array(E),O=0;O<E;O++)v[O]=arguments[O];return C=c.call.apply(c,[this].concat(v))||this,C.history=Object(I.b)(C.props),C}var o=u.prototype;return o.render=function(){return V.a.createElement(ie.c,{history:this.history,children:this.props.children})},u}(V.a.Component),P=function(u,o){return typeof u=="function"?u(o):u},L=function(u,o){return typeof u=="string"?Object(I.c)(u,null,null,o):u},x=function(u){return u},S=V.a.forwardRef;typeof S=="undefined"&&(S=x);function d(c){return!!(c.metaKey||c.altKey||c.ctrlKey||c.shiftKey)}var a=S(function(c,u){var o=c.innerRef,C=c.navigate,E=c.onClick,v=Object(M.a)(c,["innerRef","navigate","onClick"]),O=v.target,j=Object(N.a)({},v,{onClick:function(J){try{E&&E(J)}catch(K){throw J.preventDefault(),K}!J.defaultPrevented&&J.button===0&&(!O||O==="_self")&&!d(J)&&(J.preventDefault(),C())}});return x!==S?j.ref=u||o:j.ref=o,V.a.createElement("a",j)}),l=S(function(c,u){var o=c.component,C=o===void 0?a:o,E=c.replace,v=c.to,O=c.innerRef,j=Object(M.a)(c,["component","replace","to","innerRef"]);return V.a.createElement(ie.e.Consumer,null,function(G){G||Object(k.a)(!1);var J=G.history,K=L(P(v,G.location),G.location),F=K?J.createHref(K):"",ee=Object(N.a)({},j,{href:F,navigate:function(){var he=P(v,G.location),ge=E?J.replace:J.push;ge(he)}});return x!==S?ee.ref=u||O:ee.innerRef=O,V.a.createElement(C,ee)})});if(!1)var h,_;var f=function(u){return u},b=V.a.forwardRef;typeof b=="undefined"&&(b=f);function R(){for(var c=arguments.length,u=new Array(c),o=0;o<c;o++)u[o]=arguments[o];return u.filter(function(C){return C}).join(" ")}var T=b(function(c,u){var o=c["aria-current"],C=o===void 0?"page":o,E=c.activeClassName,v=E===void 0?"active":E,O=c.activeStyle,j=c.className,G=c.exact,J=c.isActive,K=c.location,F=c.sensitive,ee=c.strict,oe=c.style,he=c.to,ge=c.innerRef,_e=Object(M.a)(c,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return V.a.createElement(ie.e.Consumer,null,function(be){be||Object(k.a)(!1);var Ee=K||be.location,Te=L(P(he,Ee),Ee),Ce=Te.pathname,me=Ce&&Ce.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),se=me?Object(ie.f)(Ee.pathname,{path:me,exact:G,sensitive:F,strict:ee}):null,Re=!!(J?J(se,Ee):se),et=Re?R(j,v):j,Ge=Re?Object(N.a)({},oe,{},O):oe,tt=Object(N.a)({"aria-current":Re&&C||null,className:et,style:Ge,to:Te},_e);return f!==b?tt.ref=u||ge:tt.innerRef=ge,V.a.createElement(l,tt)})});if(!1)var g},"7Cbv":function(ht,ot,re){"use strict";var ie=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),Y=new Uint8Array(16);function D(){if(!ie)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ie(Y)}var V=/^(?:[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(P){return typeof P=="string"&&V.test(P)}for(var w=I,B=[],N=0;N<256;++N)B.push((N+256).toString(16).substr(1));function M(P){var L=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,x=(B[P[L+0]]+B[P[L+1]]+B[P[L+2]]+B[P[L+3]]+"-"+B[P[L+4]]+B[P[L+5]]+"-"+B[P[L+6]]+B[P[L+7]]+"-"+B[P[L+8]]+B[P[L+9]]+"-"+B[P[L+10]]+B[P[L+11]]+B[P[L+12]]+B[P[L+13]]+B[P[L+14]]+B[P[L+15]]).toLowerCase();if(!w(x))throw TypeError("Stringified UUID is invalid");return x}var k=M;function p(P,L,x){P=P||{};var S=P.random||(P.rng||D)();if(S[6]=S[6]&15|64,S[8]=S[8]&63|128,L){x=x||0;for(var d=0;d<16;++d)L[x+d]=S[d];return L}return k(S)}var y=ot.a=p},"7ahc":function(ht,ot,re){"use strict";re.d(ot,"a",function(){return _});var ie=re("k1fw"),Y=re("0Owb"),D=re("+L6B"),V=re("2/Rp"),I=re("y8nQ"),w=re("Vl3Y"),B=re("tJVT"),N=re("OaEy"),M=re("2fM7"),k=re("q1tI"),p=re.n(k),y=re("VrN/"),P=re.n(y),L=re("p77/"),x=re.n(L),S=re("c5Ni"),d=re.n(S),a=M.a.Option,l={labelCol:{span:4},wrapperCol:{span:20}},h={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"]};ot.b=function(f){var b=f.callback,R=f.onCancel,T=Object(k.useState)("python"),g=Object(B.a)(T,2),c=g[0],u=g[1];function o(E){u(h[E][1])}function C(E){b(E)}return p.a.createElement(w.a,Object(Y.a)({},l,{className:"code-block-panel",initialValues:{language:"python",content:""},onFinish:C}),p.a.createElement(w.a.Item,{label:"\u4EE3\u7801\u8BED\u8A00",name:"language"},p.a.createElement(M.a,{onChange:o},Object.keys(h).map(function(E){return p.a.createElement(a,{key:E,value:E},h[E][0])}))),p.a.createElement(w.a.Item,{label:"\u4EE3\u7801\u5185\u5BB9",name:"content",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u4EE3\u7801\u5185\u5BB9"}]},p.a.createElement(_,{mode:c})),p.a.createElement("div",{className:"flex-container flex-end"},p.a.createElement(V.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),p.a.createElement(V.a,{type:"ghost",onClick:R},"\u53D6\u6D88")))};function _(f){var b=f.value,R=f.onChange,T=f.mode,g=f.options,c=g===void 0?{}:g,u=Object(k.useRef)(),o=Object(k.useState)(),C=Object(B.a)(o,2),E=C[0],v=C[1];return Object(k.useEffect)(function(){if(E){function O(j){var G=j.getValue();R&&R(G)}return E.on("change",O),function(){E.off("change",O)}}},[E,R]),Object(k.useEffect)(function(){E&&E.setOption("mode",T)},[E,T]),Object(k.useEffect)(function(){E&&((b!==E.getValue()||b==="")&&setTimeout(function(){E.setValue(b||" ")},300))},[E,b]),Object(k.useEffect)(function(){if(u.current&&!E){var O=P.a.fromTextArea(u.current,Object(ie.a)({mode:T,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,tabSize:4,autofocus:!0,autoCloseTags:!0,matchBrackets:!0,styleActiveLine:!0},c));v(O)}},[u.current,E]),p.a.createElement("div",{className:"my-codemirror-container"},p.a.createElement("textarea",{ref:u}))}},"8EBN":function(ht,ot,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";ie.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 Y=0;Y<ie.modeInfo.length;Y++){var D=ie.modeInfo[Y];D.mimes&&(D.mime=D.mimes[0])}ie.findModeByMIME=function(V){V=V.toLowerCase();for(var I=0;I<ie.modeInfo.length;I++){var w=ie.modeInfo[I];if(w.mime==V)return w;if(w.mimes){for(var B=0;B<w.mimes.length;B++)if(w.mimes[B]==V)return w}}if(/\+xml$/.test(V))return ie.findModeByMIME("application/xml");if(/\+json$/.test(V))return ie.findModeByMIME("application/json")},ie.findModeByExtension=function(V){V=V.toLowerCase();for(var I=0;I<ie.modeInfo.length;I++){var w=ie.modeInfo[I];if(w.ext){for(var B=0;B<w.ext.length;B++)if(w.ext[B]==V)return w}}},ie.findModeByFileName=function(V){for(var I=0;I<ie.modeInfo.length;I++){var w=ie.modeInfo[I];if(w.file&&w.file.test(V))return w}var B=V.lastIndexOf("."),N=B>-1&&V.substring(B+1,V.length);if(N)return ie.findModeByExtension(N)},ie.findModeByName=function(V){V=V.toLowerCase();for(var I=0;I<ie.modeInfo.length;I++){var w=ie.modeInfo[I];if(w.name.toLowerCase()==V)return w;if(w.alias){for(var B=0;B<w.alias.length;B++)if(w.alias[B].toLowerCase()==V)return w}}}})},"8JLL":function(ht,ot,re){ht.exports={flex_box_center:"flex_box_center___15KPT",flex_space_between:"flex_space_between___1QiSE",flex_box_vertical_center:"flex_box_vertical_center___3bNXy",flex_box_center_end:"flex_box_center_end___1hLE4",flex_box_column:"flex_box_column___3CCm3",reply:"reply___eY1t0",replyList:"replyList___3g6Og",comment:"comment___LHpQl",content:"content___XWl90",commentItem:"commentItem___2Y_u_"}},"8hTe":function(ht,ot,re){ht.exports={button:"button___1wy9m"}},"9Bee":function(ht,ot,re){"use strict";var ie=re("DYRE"),Y=re("zeV3"),D=re("+L6B"),V=re("2/Rp"),I=re("k1fw"),w=re("9og8"),B=re("tJVT"),N=re("WmNS"),M=re.n(N),k=re("q1tI"),p=re.n(k),y=re("vg9a"),P=re("DlQD"),L=re.n(P),x=re("rUJ1");function S(z,s){var m=z.match(/^(\s+)(?:```)/);if(m===null)return s;var W=m[1];return s.split(`
`).map(function(Q){var H=Q.match(/^\s+/);if(H===null)return Q;var fe=Object(B.a)(H,1),Me=fe[0];return Me.length>=W.length?Q.slice(W.length):Q}).join(`
`)}var d=[],a=["<ul>"],l=new L.a.Renderer,h=/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/;function _(){d.length=0,a=["<ul>"]}var f={overflow:"hidden",WebkitBoxOrient:"vertical",display:"-webkit-box",WebkitLineClamp:2};function b(z,s,m,W){if(s>=z.length||z[s].level<=m)return s;var Q=z[s];W.push("<li><a href='#"+Q.anchor+"'>"+Q.text+"</a>"),s++;var H=[];return s=b(z,s,Q.level,H),H.length>0&&(W.push("<ul>"),H.forEach(function(fe){W.push(fe)}),W.push("</ul>")),W.push("</li>"),s=b(z,s,m,W),s}function R(){return b(d,0,0,a),a.push("</ul>"),a.join("")}var T={heading:function(s){var m=h.exec(s);if(m)return{type:"heading",raw:m[0],depth:m[1].length,text:m[2]}},fences:function(s){var m=this.rules.block.fences.exec(s);if(m){var W=m[0],Q=S(W,m[3]||""),H=m[2]?m[2].trim():m[2];if(["latex","katex","math"].indexOf(H)>=0){var fe=u(),Me=Q;Q=fe,o[fe]={type:"block",expression:Me}}return{type:"code",raw:W,lang:H,text:Q}}}},g=/(?:\${2})([^\n`]+?)(?:\${2})/gi,c=0,u=function(){return"__special_katext_id_".concat(c++,"__")},o={};function C(){return o}function E(){c=0,o={}}function v(z){return z=z.replace(g,function(s,m){var W=u();return o[W]={type:"inline",expression:m},W}),z}var O=l.listitem;l.listitem=function(z){return O(v(z))};var j=l.paragraph;l.paragraph=function(z){return j(v(z))};var G=l.tablecell;l.tablecell=function(z,s){return G(v(z),s)},l.code=function(z,s,m){var W=(s||"").match(/\S*/)[0];return W?["latex","katex","math"].indexOf(W)>=0?"<p class='editormd-tex'>".concat(z,"</p>"):'<pre class="prettyprint linenums"><code class="language-'.concat(s,'">').concat(m?z:Object(x.escape)(z,!0),`</code></pre>
`):'<pre class="prettyprint linenums"><code>'+(m?z:Object(x.escape)(z,!0))+"</code></pre>"},l.heading=function(z,s,m){var W=this.options.headerPrefix+m.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g,"-");return d.push({anchor:W,level:s,text:z}),"<h"+s+' id="'+W+'">'+z+"</h"+s+">"},L.a.setOptions({silent:!0,gfm:!0,pedantic:!1}),L.a.use({tokenizer:T,renderer:l});var J=L.a,K=re("SJMd"),F=re("ulZh"),ee=re.n(F),oe=re("m3rI"),he=re("Oy/b"),ge=re("p5ED"),_e=re("ErOA");/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var be=function(z,s){return(be=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,W){m.__proto__=W}||function(m,W){for(var Q in W)Object.prototype.hasOwnProperty.call(W,Q)&&(m[Q]=W[Q])})(z,s)};function Ee(z,s){function m(){this.constructor=z}be(z,s),z.prototype=s===null?Object.create(s):(m.prototype=s.prototype,new m)}function Te(z,s,m,W){return new(m||(m=Promise))(function(Q,H){function fe(vt){try{Se(W.next(vt))}catch(Ne){H(Ne)}}function Me(vt){try{Se(W.throw(vt))}catch(Ne){H(Ne)}}function Se(vt){var Ne;vt.done?Q(vt.value):(Ne=vt.value,Ne instanceof m?Ne:new m(function(_t){_t(Ne)})).then(fe,Me)}Se((W=W.apply(z,s||[])).next())})}function Ce(z,s){var m,W,Q,H,fe={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return H={next:Me(0),throw:Me(1),return:Me(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function Me(Se){return function(vt){return function(Ne){if(m)throw new TypeError("Generator is already executing.");for(;fe;)try{if(m=1,W&&(Q=2&Ne[0]?W.return:Ne[0]?W.throw||((Q=W.return)&&Q.call(W),0):W.next)&&!(Q=Q.call(W,Ne[1])).done)return Q;switch(W=0,Q&&(Ne=[2&Ne[0],Q.value]),Ne[0]){case 0:case 1:Q=Ne;break;case 4:return fe.label++,{value:Ne[1],done:!1};case 5:fe.label++,W=Ne[1],Ne=[0];continue;case 7:Ne=fe.ops.pop(),fe.trys.pop();continue;default:if(!(Q=fe.trys,(Q=Q.length>0&&Q[Q.length-1])||Ne[0]!==6&&Ne[0]!==2)){fe=0;continue}if(Ne[0]===3&&(!Q||Ne[1]>Q[0]&&Ne[1]<Q[3])){fe.label=Ne[1];break}if(Ne[0]===6&&fe.label<Q[1]){fe.label=Q[1],Q=Ne;break}if(Q&&fe.label<Q[2]){fe.label=Q[2],fe.ops.push(Ne);break}Q[2]&&fe.ops.pop(),fe.trys.pop();continue}Ne=s.call(z,fe)}catch(_t){Ne=[6,_t],W=0}finally{m=Q=0}if(5&Ne[0])throw Ne[1];return{value:Ne[0]?Ne[1]:void 0,done:!0}}([Se,vt])}}}function me(){for(var z=0,s=0,m=arguments.length;s<m;s++)z+=arguments[s].length;var W=Array(z),Q=0;for(s=0;s<m;s++)for(var H=arguments[s],fe=0,Me=H.length;fe<Me;fe++,Q++)W[Q]=H[fe];return W}var se=function(){function z(){}return z.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},z.setAttributes=function(s,m){for(var W=0,Q=m;W<Q.length;W++){var H=Q[W],fe=H[0],Me=H[1];s.setAttribute(fe,Me)}},z.createRect=function(s,m,W){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",m.toString()),W&&z.setAttributes(Q,W),Q},z.createLine=function(s,m,W,Q,H){var fe=document.createElementNS("http://www.w3.org/2000/svg","line");return fe.setAttribute("x1",s.toString()),fe.setAttribute("y1",m.toString()),fe.setAttribute("x2",W.toString()),fe.setAttribute("y2",Q.toString()),H&&z.setAttributes(fe,H),fe},z.createPolygon=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","polygon");return W.setAttribute("points",s),m&&z.setAttributes(W,m),W},z.createCircle=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","circle");return W.setAttribute("cx",(s/2).toString()),W.setAttribute("cy",(s/2).toString()),W.setAttribute("r",s.toString()),m&&z.setAttributes(W,m),W},z.createEllipse=function(s,m,W){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(m/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(m/2).toString()),W&&z.setAttributes(Q,W),Q},z.createGroup=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&z.setAttributes(m,s),m},z.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},z.createMarker=function(s,m,W,Q,H,fe,Me){var Se=document.createElementNS("http://www.w3.org/2000/svg","marker");return z.setAttributes(Se,[["id",s],["orient",m],["markerWidth",W.toString()],["markerHeight",Q.toString()],["refX",H.toString()],["refY",fe.toString()]]),Se.appendChild(Me),Se},z.createText=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","text");return m.setAttribute("x","0"),m.setAttribute("y","0"),s&&z.setAttributes(m,s),m},z.createTSpan=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","tspan");return W.textContent=s,m&&z.setAttributes(W,m),W},z.createImage=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&z.setAttributes(m,s),m},z.createPoint=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return W.x=s,W.y=m,W},z.createPath=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","path");return W.setAttribute("d",s),m&&z.setAttributes(W,m),W},z}(),Re=function(){function z(){}return z.addKey=function(s){z.key=s},Object.defineProperty(z,"isLicensed",{get:function(){return!!z.key&&new RegExp(/^MJS2-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(z.key)},enumerable:!1,configurable:!0}),z}(),et=function(){function z(){this.naturalSize=!1,this.imageType="image/png",this.markersOnly=!1}return z.prototype.rasterize=function(s,m,W){var Q=this;return new Promise(function(H){var fe=W!==void 0?W:document.createElement("canvas");s===null&&(Q.markersOnly=!0,Q.naturalSize=!1);var Me=document.createElementNS("http://www.w3.org/2000/svg","svg");Me.setAttribute("xmlns","http://www.w3.org/2000/svg"),Me.setAttribute("width",m.width.baseVal.valueAsString),Me.setAttribute("height",m.height.baseVal.valueAsString),Me.setAttribute("viewBox","0 0 "+m.viewBox.baseVal.width.toString()+" "+m.viewBox.baseVal.height.toString()),Me.innerHTML=m.innerHTML,Q.naturalSize===!0?(Me.width.baseVal.value=s.naturalWidth,Me.height.baseVal.value=s.naturalHeight):Q.width!==void 0&&Q.height!==void 0&&(Me.width.baseVal.value=Q.width,Me.height.baseVal.value=Q.height),fe.width=Me.width.baseVal.value,fe.height=Me.height.baseVal.value;var Se=Me.outerHTML,vt=fe.getContext("2d");Q.markersOnly!==!0&&vt.drawImage(s,0,0,fe.width,fe.height);var Ne=window.URL,_t=new Image(fe.width,fe.height);_t.setAttribute("crossOrigin","anonymous");var Ut=new Blob([Se],{type:"image/svg+xml"}),Kt=Ne.createObjectURL(Ut);_t.onload=function(){vt.drawImage(_t,0,0),Ne.revokeObjectURL(Kt);var Gr=fe.toDataURL(Q.imageType,Q.imageQuality);H(Gr)},_t.src=Kt})},z}(),Ge=function(){},tt=function(){function z(s){this._classNamePrefixBase="__markerjs2_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(z.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(z.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(z.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"fade_out"},enumerable:!1,configurable:!0}),z.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},z.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},z.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new Ye("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new Ye("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new Ye("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new De("fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new De("fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},z.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},z}(),Ye=function(z,s){this.selector=z,this.style=s},De=function(z,s){this.localName=z,this.style=s},je=function(){function z(s,m,W,Q,H){this.buttons=[],this.markerButtons=[],this.buttonClickListeners=[],this.markerjsContainer=s,this.displayMode=m,this.markerItems=W,this.uiStyleSettings=Q,this.styles=H,this.addStyles(),this.adjustLayout=this.adjustLayout.bind(this),this.overflowButtonClicked=this.overflowButtonClicked.bind(this),this.setCurrentMarker=this.setCurrentMarker.bind(this)}return z.prototype.show=function(s){var m=this;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolbarStyleClass.name+" "+this.styles.fadeInAnimationClassName+" "+(this.uiStyleSettings.toolbarStyleColorsClassName?this.uiStyleSettings.toolbarStyleColorsClassName:this.toolbarStyleColorsClass.name);var W=document.createElement("div");W.className=this.toolbarBlockStyleClass.name,W.style.whiteSpace="nowrap",this.uiContainer.appendChild(W),this.addActionButton(W,'<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(W,'<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(W,'<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(W,'<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(W,'<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(W,'<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(W,'<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(W,'<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(H){var fe=document.createElement("div");fe.className=""+m.toolbarButtonStyleClass.name,fe.setAttribute("data-type-name",H.typeName),fe.innerHTML=H.icon,fe.addEventListener("click",function(){m.markerToolbarButtonClicked(fe,H)}),m.buttons.push(fe),m.markerButtons.push(fe)}),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()},z.prototype.addButtonClickListener=function(s){this.buttonClickListeners.push(s)},z.prototype.removeButtonClickListener=function(s){this.buttonClickListeners.indexOf(s)>-1&&this.buttonClickListeners.splice(this.buttonClickListeners.indexOf(s),1)},z.prototype.setSelectMode=function(){this.resetButtonStyles(),this.setActiveButton(this.buttons[0])},z.prototype.adjustLayout=function(){if(this.markerButtons&&this.markerButtons.length>0){var s=Math.floor(this.markerButtonBlock.clientWidth/this.uiStyleSettings.toolbarHeight)-1;this.markerButtonBlock.innerHTML="",this.markerButtonOverflowBlock.innerHTML="";for(var m=0;m<this.markerButtons.length;m++)m<s||m===s&&this.markerButtons.length-1===s?this.markerButtonBlock.appendChild(this.markerButtons[m]):(m===s&&this.markerButtonBlock.appendChild(this.overflowButton),this.markerButtonOverflowBlock.appendChild(this.markerButtons[m]))}},z.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")},z.prototype.resetButtonStyles=function(){var s=this;this.buttons.forEach(function(m){m.className=m.className.replace(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name,"").trim(),m.className=m.className.replace(s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?s.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:s.toolbarActiveButtonStyleColorsClass.name,"").trim(),m.className+=" "+(s.uiStyleSettings.toolbarButtonStyleColorsClassName?s.uiStyleSettings.toolbarButtonStyleColorsClassName:s.toolbarButtonStyleColorsClass.name)})},z.prototype.addActionButton=function(s,m,W){var Q=this,H=document.createElement("div");switch(H.className=""+this.toolbarButtonStyleClass.name,H.innerHTML=m,H.setAttribute("data-action",W),H.addEventListener("click",function(){Q.actionToolbarButtonClicked(H,W)}),W){case"select":H.style.fill=this.uiStyleSettings.selectButtonColor;break;case"delete":case"clear":H.style.fill=this.uiStyleSettings.deleteButtonColor;break;case"undo":case"redo":H.style.fill=this.uiStyleSettings.selectButtonColor;break;case"render":H.style.fill=this.uiStyleSettings.okButtonColor;break;case"close":H.style.fill=this.uiStyleSettings.closeButtonColor}s.appendChild(H),this.buttons.push(H)},z.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new De("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 De("toolbar_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
box-shadow: 0px 3px rgba(33, 33, 33, 0.1);
`)),this.toolbarBlockStyleClass=this.styles.addClass(new De("toolbar-block",`
display: inline-block;
box-sizing: content-box;
`)),this.toolbarOverflowBlockStyleClass=this.styles.addClass(new De("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 De("toolbar-overflow-block_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`));var s=this.uiStyleSettings.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new De("toolbar_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*s)+`px;
padding: `+s+`px;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new De("toolbar_button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new De("toolbar_active_button",`
fill: `+this.uiStyleSettings.toolbarColor+`;
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Ye("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`)),this.styles.addRule(new Ye("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`))},z.prototype.markerToolbarButtonClicked=function(s,m){this.setActiveButton(s),this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(W){return W("marker",m)}),this.markerButtonOverflowBlock.style.display="none"},z.prototype.actionToolbarButtonClicked=function(s,m){this.buttonClickListeners&&this.buttonClickListeners.length>0&&this.buttonClickListeners.forEach(function(W){return W("action",m)}),this.markerButtonOverflowBlock.style.display="none",this.setActiveButton(this.buttons[0])},z.prototype.setActiveButton=function(s){this.resetButtonStyles(),s.className=s.className.replace(this.uiStyleSettings.toolbarButtonStyleColorsClassName?this.uiStyleSettings.toolbarButtonStyleColorsClassName:this.toolbarButtonStyleColorsClass.name,"").trim(),s.className+=" "+(this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName?this.uiStyleSettings.toolbarActiveButtonStyleColorsClassName:this.toolbarActiveButtonStyleColorsClass.name)},z.prototype.setActiveMarkerButton=function(s){var m=this.markerButtons.find(function(W){return W.getAttribute("data-type-name")===s});m&&this.setActiveButton(m)},z.prototype.setCurrentMarker=function(s){var m=this;this.currentMarker=s,this.buttons.filter(function(W){return/delete|notes/.test(W.getAttribute("data-action"))}).forEach(function(W){m.currentMarker===void 0?(W.style.fillOpacity="0.4",W.style.pointerEvents="none"):(W.style.fillOpacity="1",W.style.pointerEvents="all")})},z}(),$e=function(){function z(s,m,W,Q){this.panels=[],this.panelButtons=[],this.markerjsContainer=s,this.displayMode=m,this.uiStyleSettings=W,this.styles=Q,this.panelButtonClick=this.panelButtonClick.bind(this),this.addStyles()}return z.prototype.addStyles=function(){var s;this.toolboxStyleClass=this.styles.addClass(new De("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 De("toolbox_colors",`
color: `+this.uiStyleSettings.toolboxColor+`;
`));var m=this.uiStyleSettings.toolbarHeight/4;this.toolboxButtonRowStyleClass=this.styles.addClass(new De("toolbox-button-row",`
display: flex;
cursor: default;
box-sizing: content-box;
`)),this.toolboxButtonRowStyleColorsClass=this.styles.addClass(new De("toolbox-button-row_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundColor+`;
`)),this.toolboxPanelRowStyleClass=this.styles.addClass(new De("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 De("toolbox-panel-row_colors",`
background-color: `+((s=this.uiStyleSettings.toolboxBackgroundColor)!==null&&s!==void 0?s:this.uiStyleSettings.toolbarBackgroundHoverColor)+`;
`)),this.toolboxButtonStyleClass=this.styles.addClass(new De("toolbox_button",`
display: inline-block;
width: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px;
height: `+(this.uiStyleSettings.toolbarHeight-2*m)+`px;
padding: `+m+`px;
box-sizing: content-box;
`)),this.toolboxButtonStyleColorsClass=this.styles.addClass(new De("toolbox-button_colors",`
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.toolboxActiveButtonStyleColorsClass=this.styles.addClass(new De("toolbox-active-button_colors",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`;
fill: `+this.uiStyleSettings.toolbarColor+`;
`)),this.styles.addRule(new Ye("."+this.toolboxButtonStyleColorsClass.name+":hover",`
background-color: `+this.uiStyleSettings.toolbarBackgroundHoverColor+`
`)),this.styles.addRule(new Ye("."+this.toolboxButtonStyleClass.name+" svg",`
height: `+this.uiStyleSettings.toolbarHeight/2+`px;
`))},z.prototype.show=function(s){var m;this.uiContainer=document.createElement("div"),this.uiContainer.style.visibility=s,this.uiContainer.className=this.toolboxStyleClass.name+" "+((m=this.uiStyleSettings.toolboxStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxStyleColorsClass.name),this.markerjsContainer.appendChild(this.uiContainer)},z.prototype.setPanelButtons=function(s){var m,W,Q=this;this.panels=s,this.uiContainer!==void 0&&(this.uiContainer.innerHTML="",this.panelRow=document.createElement("div"),this.panelRow.className=this.toolboxPanelRowStyleClass.name+" "+((m=this.uiStyleSettings.toolboxPanelRowStyleColorsClassName)!==null&&m!==void 0?m:this.toolboxPanelRowStyleColorsClass.name),this.uiContainer.appendChild(this.panelRow),this.buttonRow=document.createElement("div"),this.buttonRow.className=this.toolboxButtonRowStyleClass.name+" "+((W=this.uiStyleSettings.toolboxButtonRowStyleColorsClassName)!==null&&W!==void 0?W:this.toolboxButtonRowStyleColorsClass.name)+" ",this.uiContainer.appendChild(this.buttonRow),this.panelButtons.splice(0),this.panels.forEach(function(H){var fe;H.uiStyleSettings=Q.uiStyleSettings;var Me=document.createElement("div");Me.className=Q.toolboxButtonStyleClass.name+" "+((fe=Q.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&fe!==void 0?fe:Q.toolboxButtonStyleColorsClass.name),Me.innerHTML=H.icon,Me.title=H.title,Me.addEventListener("click",function(){Q.panelButtonClick(H)}),Q.panelButtons.push(Me),Q.buttonRow.appendChild(Me)}),this.displayMode==="inline"?this.panelRow.style.display="none":this.panelRow.style.visibility="hidden")},z.prototype.panelButtonClick=function(s){var m=this,W=-1;if(s!==this.activePanel){W=this.panels.indexOf(s),this.panelRow.innerHTML="";var Q=s.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=s}else this.activePanel=void 0,this.panelRow.className=this.panelRow.className.replace(this.styles.fadeInAnimationClassName,""),this.panelRow.className+=" "+this.styles.fadeOutAnimationClassName,setTimeout(function(){m.displayMode==="inline"?m.panelRow.style.display="none":m.panelRow.style.visibility="hidden"},200);this.panelButtons.forEach(function(H,fe){var Me,Se;H.className=m.toolboxButtonStyleClass.name+" "+(fe===W?""+((Me=m.uiStyleSettings.toolboxActiveButtonStyleColorsClassName)!==null&&Me!==void 0?Me:m.toolboxActiveButtonStyleColorsClass.name):""+((Se=m.uiStyleSettings.toolboxButtonStyleColorsClassName)!==null&&Se!==void 0?Se:m.toolboxButtonStyleColorsClass.name))})},z}(),st=function(z,s){this.title=z,this.icon=s},Qe=function(z){function s(m,W,Q,H){var fe=z.call(this,m,H||'<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 fe.colors=[],fe.addTransparent=!1,fe.colorBoxes=[],fe.colors=W,fe.currentColor=Q,fe.setCurrentColor=fe.setCurrentColor.bind(fe),fe.getColorBox=fe.getColorBox.bind(fe),fe}return Ee(s,z),s.prototype.getUi=function(){var m=this,W=document.createElement("div");return W.style.overflow="hidden",W.style.whiteSpace="nowrap",this.colors.forEach(function(Q){var H=m.getColorBox(Q);W.appendChild(H),m.colorBoxes.push(H)}),W},s.prototype.getColorBox=function(m){var W=this,Q=this.uiStyleSettings.toolbarHeight/4,H=this.uiStyleSettings.toolbarHeight-Q,fe=document.createElement("div");fe.style.display="inline-block",fe.style.boxSizing="content-box",fe.style.width=H-2+"px",fe.style.height=H-2+"px",fe.style.padding="1px",fe.style.marginRight="2px",fe.style.marginBottom="2px",fe.style.borderWidth="2px",fe.style.borderStyle="solid",fe.style.borderRadius=(H+2)/2+"px",fe.style.borderColor=m===this.currentColor?this.uiStyleSettings.toolboxAccentColor:"transparent",fe.addEventListener("click",function(){W.setCurrentColor(m,fe)});var Me=document.createElement("div");return Me.style.display="inline-block",Me.style.width=H-2+"px",Me.style.height=H-2+"px",Me.style.backgroundColor=m,Me.style.borderRadius=H/2+"px",m==="transparent"&&(Me.style.fill=this.uiStyleSettings.toolboxAccentColor,Me.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>`),fe.appendChild(Me),fe},s.prototype.setCurrentColor=function(m,W){var Q=this;this.currentColor=m,this.colorBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onColorChanged&&this.onColorChanged(m)},s}(st),Be=function(){function z(s,m,W){this._state="new",this._isSelected=!1,this._container=s,this._overlayContainer=m,this.globalSettings=W,this.stateChanged=this.stateChanged.bind(this),this.colorChanged=this.colorChanged.bind(this),this.fillColorChanged=this.fillColorChanged.bind(this)}return Object.defineProperty(z.prototype,"typeName",{get:function(){return Object.getPrototypeOf(this).constructor.typeName},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"container",{get:function(){return this._container},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"overlayContainer",{get:function(){return this._overlayContainer},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"toolboxPanels",{get:function(){return[]},enumerable:!1,configurable:!0}),z.prototype.ownsTarget=function(s){return!1},Object.defineProperty(z.prototype,"isSelected",{get:function(){return this._isSelected},enumerable:!1,configurable:!0}),z.prototype.select=function(){this.container.style.cursor="move",this._isSelected=!0,this.manipulationStartState=this.getState()},z.prototype.deselect=function(){this.container.style.cursor="default",this._isSelected=!1,this.stateChanged()},z.prototype.pointerDown=function(s,m){},z.prototype.dblClick=function(s,m){},z.prototype.manipulate=function(s){},z.prototype.pointerUp=function(s){this.stateChanged()},z.prototype.dispose=function(){},z.prototype.addMarkerVisualToContainer=function(s){this.container.childNodes.length>0?this.container.insertBefore(s,this.container.childNodes[0]):this.container.appendChild(s)},z.prototype.getState=function(){return{typeName:z.typeName,state:this.state,notes:this.notes}},z.prototype.restoreState=function(s){this._state=s.state,this.notes=s.notes},z.prototype.scale=function(s,m){},z.prototype.colorChanged=function(s){this.onColorChanged&&this.onColorChanged(s),this.stateChanged()},z.prototype.fillColorChanged=function(s){this.onFillColorChanged&&this.onFillColorChanged(s),this.stateChanged()},z.prototype.stateChanged=function(){if(this.onStateChanged&&this.state!=="creating"&&this.state!=="new"){var s=this.getState();this.manipulationStartState!==void 0&&(this.manipulationStartState.state="select"),s.state="select",JSON.stringify(this.manipulationStartState)!=JSON.stringify(s)&&this.onStateChanged(this)}},z.typeName="MarkerBase",z}(),We=function(){function z(){this.findGripByVisual=this.findGripByVisual.bind(this)}return z.prototype.findGripByVisual=function(s){return this.topLeft.ownsTarget(s)?this.topLeft:this.topCenter.ownsTarget(s)?this.topCenter:this.topRight.ownsTarget(s)?this.topRight:this.centerLeft.ownsTarget(s)?this.centerLeft:this.centerRight.ownsTarget(s)?this.centerRight:this.bottomLeft.ownsTarget(s)?this.bottomLeft:this.bottomCenter.ownsTarget(s)?this.bottomCenter:this.bottomRight.ownsTarget(s)?this.bottomRight:void 0},z}(),ft=function(){function z(){this.GRIP_SIZE=10,this.visual=se.createGroup(),this.visual.appendChild(se.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(se.createCircle(this.GRIP_SIZE,[["fill","#cccccc"],["fill-opacity","0.7"],["stroke","#333333"],["stroke-width","2"],["stroke-opacity","0.7"]]))}return z.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},z}(),Ke=function(){function z(){}return z.toITransformMatrix=function(s){return{a:s.a,b:s.b,c:s.c,d:s.d,e:s.e,f:s.f}},z.toSVGMatrix=function(s,m){return s.a=m.a,s.b=m.b,s.c=m.c,s.d=m.d,s.e=m.e,s.f=m.f,s},z}(),Ue=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.left=0,H.top=0,H.width=0,H.height=0,H.defaultSize={x:50,y:20},H.offsetX=0,H.offsetY=0,H.rotationAngle=0,H.CB_DISTANCE=10,H._suppressMarkerCreateEvent=!1,H.container.transform.baseVal.appendItem(se.createTransform()),H.setupControlBox(),H}return Ee(s,z),Object.defineProperty(s.prototype,"centerX",{get:function(){return this.left+this.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"centerY",{get:function(){return this.top+this.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"visual",{get:function(){return this._visual},set:function(m){this._visual=m;var W=se.createTransform();this._visual.transform.baseVal.appendItem(W)},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(m){return!!z.prototype.ownsTarget.call(this,m)||!!(this.controlGrips.findGripByVisual(m)!==void 0||this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(m))},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.state==="new"&&(this.left=m.x,this.top=m.y),this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.manipulationStartWidth=this.width,this.manipulationStartHeight=this.height;var Q=this.unrotatePoint(m);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(W),this.activeGrip!==void 0)this._state="resize";else if(this.rotatorGrip!==void 0&&this.rotatorGrip.ownsTarget(W)){this.activeGrip=this.rotatorGrip;var H=this.rotatePoint({x:this.centerX,y:this.centerY});this.left=H.x-this.width/2,this.top=H.y-this.height/2,this.moveVisual({x:this.left,y:this.top});var fe=this.container.transform.baseVal.getItem(0);fe.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(fe,0),this.adjustControlBox(),this._state="rotate"}else this._state="move"},s.prototype.pointerUp=function(m){var W=this.state;z.prototype.pointerUp.call(this,m),this.state==="creating"&&this.width<10&&this.height<10?(this.width=this.defaultSize.x,this.height=this.defaultSize.y):this.manipulate(m),this._state="select",W==="creating"&&this.onMarkerCreated&&this._suppressMarkerCreateEvent===!1&&this.onMarkerCreated(this)},s.prototype.moveVisual=function(m){this.visual.style.transform="translate("+m.x+"px, "+m.y+"px)"},s.prototype.manipulate=function(m){var W=this.unrotatePoint(m);this.state==="creating"?this.resize(m):this.state==="move"?(this.left=this.manipulationStartLeft+(W.x-this.manipulationStartLeft)-this.offsetX,this.top=this.manipulationStartTop+(W.y-this.manipulationStartTop)-this.offsetY,this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()):this.state==="resize"?this.resize(W):this.state==="rotate"&&this.rotate(m)},s.prototype.resize=function(m){var W=this.manipulationStartLeft,Q=this.manipulationStartWidth,H=this.manipulationStartTop,fe=this.manipulationStartHeight;switch(this.activeGrip){case this.controlGrips.bottomLeft:case this.controlGrips.centerLeft:case this.controlGrips.topLeft:W=this.manipulationStartLeft+m.x-this.manipulationStartX,Q=this.manipulationStartWidth+this.manipulationStartLeft-W;break;case this.controlGrips.bottomRight:case this.controlGrips.centerRight:case this.controlGrips.topRight:case void 0:Q=this.manipulationStartWidth+m.x-this.manipulationStartX}switch(this.activeGrip){case this.controlGrips.topCenter:case this.controlGrips.topLeft:case this.controlGrips.topRight:H=this.manipulationStartTop+m.y-this.manipulationStartY,fe=this.manipulationStartHeight+this.manipulationStartTop-H;break;case this.controlGrips.bottomCenter:case this.controlGrips.bottomLeft:case this.controlGrips.bottomRight:case void 0:fe=this.manipulationStartHeight+m.y-this.manipulationStartY}Q>=0?(this.left=W,this.width=Q):(this.left=W+Q,this.width=-Q),fe>=0?(this.top=H,this.height=fe):(this.top=H+fe,this.height=-fe),this.setSize()},s.prototype.setSize=function(){this.moveVisual({x:this.left,y:this.top}),this.adjustControlBox()},s.prototype.rotate=function(m){if(Math.abs(m.x-this.centerX)>.1){var W=Math.sign(m.x-this.centerX);this.rotationAngle=180*Math.atan((m.y-this.centerY)/(m.x-this.centerX))/Math.PI+90*W,this.applyRotation()}},s.prototype.applyRotation=function(){var m=this.container.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.centerX,this.centerY),this.container.transform.baseVal.replaceItem(m,0)},s.prototype.rotatePoint=function(m){if(this.rotationAngle===0)return m;var W=this.container.getCTM(),Q=se.createPoint(m.x,m.y);return{x:(Q=Q.matrixTransform(W)).x,y:Q.y}},s.prototype.unrotatePoint=function(m){if(this.rotationAngle===0)return m;var W=this.container.getCTM();W=W.inverse();var Q=se.createPoint(m.x,m.y);return{x:(Q=Q.matrixTransform(W)).x,y:Q.y}},s.prototype.select=function(){z.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){z.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=se.createGroup();var m=se.createTransform();m.setTranslate(-this.CB_DISTANCE/2,-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.appendItem(m),this.container.appendChild(this.controlBox),this.controlRect=se.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=se.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 We,this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){var m=this.controlBox.transform.baseVal.getItem(0);m.setTranslate(this.left-this.CB_DISTANCE/2,this.top-this.CB_DISTANCE/2),this.controlBox.transform.baseVal.replaceItem(m,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()},s.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()},s.prototype.createGrip=function(){var m=new ft;return m.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(m.visual),m},s.prototype.positionGrips=function(){var m=this.controlGrips.topLeft.GRIP_SIZE,W=-m/2,Q=W,H=(this.width+this.CB_DISTANCE)/2-m/2,fe=(this.height+this.CB_DISTANCE)/2-m/2,Me=this.height+this.CB_DISTANCE-m/2,Se=this.width+this.CB_DISTANCE-m/2;this.positionGrip(this.controlGrips.topLeft.visual,W,Q),this.positionGrip(this.controlGrips.topCenter.visual,H,Q),this.positionGrip(this.controlGrips.topRight.visual,Se,Q),this.positionGrip(this.controlGrips.centerLeft.visual,W,fe),this.positionGrip(this.controlGrips.centerRight.visual,Se,fe),this.positionGrip(this.controlGrips.bottomLeft.visual,W,Me),this.positionGrip(this.controlGrips.bottomCenter.visual,H,Me),this.positionGrip(this.controlGrips.bottomRight.visual,Se,Me),this.rotatorGrip!==void 0&&this.positionGrip(this.rotatorGrip.visual,H,Q-3*this.CB_DISTANCE)},s.prototype.positionGrip=function(m,W,Q){var H=m.transform.baseVal.getItem(0);H.setTranslate(W,Q),m.transform.baseVal.replaceItem(H,0)},s.prototype.hideControlBox=function(){this.controlBox.style.display="none"},s.prototype.showControlBox=function(){this.controlBox.style.display=""},s.prototype.getState=function(){return Object.assign({left:this.left,top:this.top,width:this.width,height:this.height,rotationAngle:this.rotationAngle,visualTransformMatrix:Ke.toITransformMatrix(this.visual.transform.baseVal.getItem(0).matrix),containerTransformMatrix:Ke.toITransformMatrix(this.container.transform.baseVal.getItem(0).matrix)},z.prototype.getState.call(this))},s.prototype.restoreState=function(m){z.prototype.restoreState.call(this,m);var W=m;this.left=W.left,this.top=W.top,this.width=W.width,this.height=W.height,this.rotationAngle=W.rotationAngle,this.visual.transform.baseVal.getItem(0).setMatrix(Ke.toSVGMatrix(this.visual.transform.baseVal.getItem(0).matrix,W.visualTransformMatrix)),this.container.transform.baseVal.getItem(0).setMatrix(Ke.toSVGMatrix(this.container.transform.baseVal.getItem(0).matrix,W.containerTransformMatrix))},s.prototype.scale=function(m,W){z.prototype.scale.call(this,m,W);var Q=this.rotatePoint({x:this.left,y:this.top}),H=this.unrotatePoint({x:Q.x*m,y:Q.y*W});this.left=H.x,this.top=H.y,this.width=this.width*m,this.height=this.height*W,this.adjustControlBox()},s}(Be),Xe=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.fillColor="transparent",H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.opacity=1,H.setStrokeColor=H.setStrokeColor.bind(H),H.setFillColor=H.setFillColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.createVisual=H.createVisual.bind(H),H}return Ee(s,z),s.prototype.ownsTarget=function(m){return!(!z.prototype.ownsTarget.call(this,m)&&m!==this.visual)},s.prototype.createVisual=function(){this.visual=se.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)},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.manipulate=function(m){z.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){z.prototype.resize.call(this,m),this.setSize()},s.prototype.setSize=function(){z.prototype.setSize.call(this),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(m){z.prototype.pointerUp.call(this,m),this.setSize()},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},s.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.stateChanged()},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.getState=function(){return Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},z.prototype.getState.call(this))},s.prototype.restoreState=function(m){var W=m;this.fillColor=W.fillColor,this.strokeColor=W.strokeColor,this.strokeWidth=W.strokeWidth,this.strokeDasharray=W.strokeDasharray,this.opacity=W.opacity,this.createVisual(),z.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,W){z.prototype.scale.call(this,m,W),this.setSize()},s.title="Rectangle marker",s}(Ue),Ze=function(z){function s(m,W,Q,H){var fe=z.call(this,m,H||'<svg viewBox="0 0 24 24"><path d="M3 17h18v-2H3v2m0 3h18v-1H3v1m0-7h18v-3H3v3m0-9v4h18V4H3z"/></svg>')||this;return fe.widths=[],fe.widthBoxes=[],fe.widths=W,fe.currentWidth=Q,fe.setCurrentWidth=fe.setCurrentWidth.bind(fe),fe}return Ee(s,z),s.prototype.getUi=function(){var m=this,W=document.createElement("div");return W.style.display="flex",W.style.overflow="hidden",W.style.flexGrow="2",this.widths.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.flexGrow="2",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.borderColor=Q===m.currentWidth?m.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){m.setCurrentWidth(Q,H)}),W.appendChild(H);var fe=document.createElement("div");fe.innerText=Q.toString(),fe.style.marginRight="5px",H.appendChild(fe);var Me=document.createElement("div");Me.style.minHeight="20px",Me.style.flexGrow="2",Me.style.display="flex",Me.style.alignItems="center";var Se=document.createElement("hr");Se.style.minWidth="20px",Se.style.border="0px",Se.style.borderTop=Q+"px solid "+m.uiStyleSettings.toolboxColor,Se.style.flexGrow="2",Me.appendChild(Se),H.appendChild(Me),m.widthBoxes.push(H)}),W},s.prototype.setCurrentWidth=function(m,W){var Q=this;this.currentWidth=m,this.widthBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onWidthChanged&&this.onWidthChanged(this.currentWidth)},s}(st),Ve=function(z){function s(m,W,Q,H){var fe=z.call(this,m,H||'<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 fe.styles=[],fe.styleBoxes=[],fe.styles=W,fe.currentStyle=Q,fe.setCurrentStyle=fe.setCurrentStyle.bind(fe),fe}return Ee(s,z),s.prototype.getUi=function(){var m=this,W=document.createElement("div");return W.style.display="flex",W.style.overflow="hidden",W.style.flexGrow="2",this.styles.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.overflow="hidden",H.style.maxWidth=100/m.styles.length-5+"%",H.style.borderColor=Q===m.currentStyle?m.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){m.setCurrentStyle(Q,H)}),W.appendChild(H);var fe=document.createElement("div");fe.style.minHeight="20px",fe.style.flexGrow="2",fe.style.overflow="hidden";var Me=`<svg width="100" height="20">
<line x1="0" y1="10" x2="100" y2="10" stroke="`+m.uiStyleSettings.toolboxColor+'" stroke-width="3" '+(Q!==""?'stroke-dasharray="'+Q+'"':"")+` />
</svg>`;fe.innerHTML=Me,H.appendChild(fe),m.styleBoxes.push(H)}),W},s.prototype.setCurrentStyle=function(m,W){var Q=this;this.currentStyle=m,this.styleBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onStyleChanged&&this.onStyleChanged(this.currentStyle)},s}(st),rt=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new Qe("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new Ze("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new Ve("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return Ee(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=z.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="FrameMarker",s.title="Frame marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4m14 11H6V8h12v9z"/></svg>',s}(Xe),we=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},qe=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.x1=0,H.y1=0,H.x2=0,H.y2=0,H.defaultLength=50,H.manipulationStartX=0,H.manipulationStartY=0,H.manipulationStartX1=0,H.manipulationStartY1=0,H.manipulationStartX2=0,H.manipulationStartY2=0,H.setupControlBox(),H}return Ee(s,z),s.prototype.ownsTarget=function(m){return!!z.prototype.ownsTarget.call(this,m)||!(!this.grip1.ownsTarget(m)&&!this.grip2.ownsTarget(m))},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.manipulationStartX=m.x,this.manipulationStartY=m.y,this.state==="new"&&(this.x1=m.x,this.y1=m.y,this.x2=m.x,this.y2=m.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(W)?this.activeGrip=this.grip1:this.grip2.ownsTarget(W)?this.activeGrip=this.grip2:this.activeGrip=void 0,this.activeGrip?this._state="resize":this._state="move")},s.prototype.pointerUp=function(m){var W=this.state;z.prototype.pointerUp.call(this,m),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(m),this._state="select",W==="creating"&&this.onMarkerCreated&&this.onMarkerCreated(this)},s.prototype.adjustVisual=function(){},s.prototype.manipulate=function(m){this.state==="creating"?this.resize(m):this.state==="move"?(this.x1=this.manipulationStartX1+m.x-this.manipulationStartX,this.y1=this.manipulationStartY1+m.y-this.manipulationStartY,this.x2=this.manipulationStartX2+m.x-this.manipulationStartX,this.y2=this.manipulationStartY2+m.y-this.manipulationStartY,this.adjustVisual(),this.adjustControlBox()):this.state==="resize"&&this.resize(m)},s.prototype.resize=function(m){switch(this.activeGrip){case this.grip1:this.x1=m.x,this.y1=m.y;break;case this.grip2:case void 0:this.x2=m.x,this.y2=m.y}this.adjustVisual(),this.adjustControlBox()},s.prototype.select=function(){z.prototype.select.call(this),this.adjustControlBox(),this.controlBox.style.display=""},s.prototype.deselect=function(){z.prototype.deselect.call(this),this.controlBox.style.display="none"},s.prototype.setupControlBox=function(){this.controlBox=se.createGroup(),this.container.appendChild(this.controlBox),this.addControlGrips(),this.controlBox.style.display="none"},s.prototype.adjustControlBox=function(){this.positionGrips()},s.prototype.addControlGrips=function(){this.grip1=this.createGrip(),this.grip2=this.createGrip(),this.positionGrips()},s.prototype.createGrip=function(){var m=new ft;return m.visual.transform.baseVal.appendItem(se.createTransform()),this.controlBox.appendChild(m.visual),m},s.prototype.positionGrips=function(){var m=this.grip1.GRIP_SIZE;this.positionGrip(this.grip1.visual,this.x1-m/2,this.y1-m/2),this.positionGrip(this.grip2.visual,this.x2-m/2,this.y2-m/2)},s.prototype.positionGrip=function(m,W,Q){var H=m.transform.baseVal.getItem(0);H.setTranslate(W,Q),m.transform.baseVal.replaceItem(H,0)},s.prototype.getState=function(){return Object.assign({x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2},z.prototype.getState.call(this))},s.prototype.restoreState=function(m){z.prototype.restoreState.call(this,m);var W=m;this.x1=W.x1,this.y1=W.y1,this.x2=W.x2,this.y2=W.y2},s.prototype.scale=function(m,W){z.prototype.scale.call(this,m,W),this.x1=this.x1*m,this.y1=this.y1*W,this.x2=this.x2*m,this.y2=this.y2*W,this.adjustVisual(),this.adjustControlBox()},s}(Be),it=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.setStrokeColor=H.setStrokeColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new Qe("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new Ze("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new Ve("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return Ee(s,z),s.prototype.ownsTarget=function(m){return!(!z.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorLine&&m!==this.visibleLine)},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorLine=se.createLine(this.x1,this.y1,this.x2,this.y2,[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()]]),this.visibleLine=se.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)},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.state==="new"&&(this.createVisual(),this.adjustVisual(),this._state="creating")},s.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()),se.setAttributes(this.visibleLine,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleLine,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleLine,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray},z.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){z.prototype.restoreState.call(this,m);var W=m;this.strokeColor=W.strokeColor,this.strokeWidth=W.strokeWidth,this.strokeDasharray=W.strokeDasharray,this.createVisual(),this.adjustVisual()},s.typeName="LineMarker",s.title="Line marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>',s}(qe),Ae=function(z){function s(m,W,Q,H){var fe=z.call(this,m,H||'<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 fe.fonts=[],fe.fontBoxes=[],fe.fonts=W,fe.currentFont=Q,fe.setCurrentFont=fe.setCurrentFont.bind(fe),fe}return Ee(s,z),s.prototype.getUi=function(){var m=this,W=document.createElement("div");return W.style.overflow="hidden",W.style.flexGrow="2",this.fonts.forEach(function(Q){var H=document.createElement("div");H.style.display="inline-block",H.style.alignItems="center",H.style.justifyContent="space-between",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.overflow="hidden",H.style.maxWidth=100/m.fonts.length-5+"%",H.style.borderColor=Q===m.currentFont?m.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){m.setCurrentFont(Q,H)}),W.appendChild(H);var fe=document.createElement("div");fe.style.display="flex",fe.style.minHeight="20px",fe.style.flexGrow="2",fe.style.fontFamily=Q,fe.style.overflow="hidden";var Me=document.createElement("div");Me.style.whiteSpace="nowrap",Me.style.overflow="hidden",Me.style.textOverflow="ellipsis",Me.innerHTML="The quick brown fox jumps over the lazy dog",fe.appendChild(Me),H.appendChild(fe),m.fontBoxes.push(H)}),W},s.prototype.setCurrentFont=function(m,W){var Q=this;this.currentFont=m,this.fontBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onFontChanged&&this.onFontChanged(this.currentFont)},s}(st),Oe=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.color="transparent",H.padding=5,H.DEFAULT_TEXT="your text here",H.text=H.DEFAULT_TEXT,H.isMoved=!1,H.color=Q.defaultColor,H.fontFamily=Q.defaultFontFamily,H.defaultSize={x:100,y:30},H.setColor=H.setColor.bind(H),H.setFont=H.setFont.bind(H),H.renderText=H.renderText.bind(H),H.sizeText=H.sizeText.bind(H),H.textEditDivClicked=H.textEditDivClicked.bind(H),H.showTextEditor=H.showTextEditor.bind(H),H.setSize=H.setSize.bind(H),H.positionTextEditor=H.positionTextEditor.bind(H),H.colorPanel=new Qe("Color",Q.defaultColorSet,Q.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.fontFamilyPanel=new Ae("Font",Q.defaultFontFamilies,Q.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H}return Ee(s,z),s.prototype.ownsTarget=function(m){if(z.prototype.ownsTarget.call(this,m)||m===this.visual||m===this.textElement||m===this.bgRectangle)return!0;var W=!1;return this.textElement.childNodes.forEach(function(Q){Q===m&&(W=!0)}),W},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.bgRectangle=se.createRect(1,1,[["fill","transparent"]]),this.visual.appendChild(this.bgRectangle),this.textElement=se.createText([["fill",this.color],["font-family",this.fontFamily],["font-size","16px"],["x","0"],["y","0"]]),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.textElement.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.textElement),this.addMarkerVisualToContainer(this.visual),this.renderText()},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.isMoved=!1,this.pointerDownPoint=m,this.pointerDownTimestamp=Date.now(),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.renderText=function(){var m=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(W){m.textElement.appendChild(se.createTSpan(W.trim()===""?" ":W.trim(),[["x","0"],["dy","1.2em"]]))}),setTimeout(this.sizeText,10)}},s.prototype.getTextScale=function(){var m=this.textElement.getBBox(),W=1;if(m.width>0&&m.height>0){var Q=(1*this.width-this.width*this.padding*2/100)/m.width,H=(1*this.height-this.height*this.padding*2/100)/m.height;W=Math.min(Q,H)}return W},s.prototype.getTextPosition=function(m){var W=this.textElement.getBBox(),Q=0,H=0;return W.width>0&&W.height>0&&(Q=(this.width-W.width*m)/2,H=this.height/2-W.height*m/2),{x:Q,y:H}},s.prototype.sizeText=function(){var m=this.textElement.getBBox(),W=this.getTextScale(),Q=this.getTextPosition(W);Q.y-=m.y*W,navigator.userAgent.indexOf("Edge/")>-1?this.textElement.style.transform="translate("+Q.x+"px, "+Q.y+"px) scale("+W+", "+W+")":(this.textElement.transform.baseVal.getItem(0).setTranslate(Q.x,Q.y),this.textElement.transform.baseVal.getItem(1).setScale(W,W))},s.prototype.manipulate=function(m){z.prototype.manipulate.call(this,m),this.pointerDownPoint!==void 0&&(this.isMoved=Math.abs(m.x-this.pointerDownPoint.x)>5||Math.abs(m.y-this.pointerDownPoint.y)>5)},s.prototype.resize=function(m){z.prototype.resize.call(this,m),this.isMoved=!0,this.setSize(),this.sizeText()},s.prototype.setSize=function(){z.prototype.setSize.call(this),this.visual&&this.bgRectangle&&(se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.bgRectangle,[["width",this.width.toString()],["height",this.height.toString()]]))},s.prototype.pointerUp=function(m){var W=this.state;W==="creating"&&(this._suppressMarkerCreateEvent=!0),z.prototype.pointerUp.call(this,m),this.setSize(),(W==="creating"||!this.isMoved&&Date.now()-this.pointerDownTimestamp>500)&&this.showTextEditor(),this.pointerDownPoint=void 0},s.prototype.showTextEditor=function(){var m=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(W){W.stopPropagation()}),this.textEditor.addEventListener("input",function(){for(var W=Number.parseFloat(m.textEditor.style.fontSize);m.textEditor.clientWidth>=Number.parseInt(m.textEditor.style.maxWidth)&&W>.9;)W-=.1,m.textEditor.style.fontSize=Math.max(W,.9)+"em"}),this.textEditor.addEventListener("keyup",function(W){W.cancelBubble=!0}),this.textEditor.addEventListener("paste",function(W){if(W.clipboardData){var Q=W.clipboardData.getData("text"),H=window.getSelection();if(!H.rangeCount)return!1;H.deleteFromDocument(),H.getRangeAt(0).insertNode(document.createTextNode(Q)),W.preventDefault()}}),this.textEditDiv.addEventListener("pointerup",function(){m.textEditDivClicked(m.textEditor.innerText)}),this.textEditDiv.appendChild(this.textEditor),this.overlayContainer.appendChild(this.textEditDiv),this.hideVisual(),this.textEditor.focus(),document.execCommand("selectAll")},s.prototype.positionTextEditor=function(){if(this.state==="edit")if(this.textEditor===void 0)this.showTextEditor();else{this.textElement.style.display="";var m=this.getTextScale(),W=this.rotatePoint({x:this.left+this.width/2,y:this.top+this.height/2}),Q=this.textElement.getBBox(),H={x:Q.width*m,y:Q.height*m};W.x-=H.x/2,W.y-=H.y/2,this.textEditor.style.top=W.y+"px",this.textEditor.style.left=W.x+"px",this.textEditor.style.maxWidth=this.overlayContainer.offsetWidth-W.x+"px",this.textEditor.style.fontSize=Math.max(16*m,12)+"px",this.textElement.style.display="none"}},s.prototype.textEditDivClicked=function(m){this.text=m.trim(),this.overlayContainer.innerHTML="",this.renderText(),this.showVisual(),this._suppressMarkerCreateEvent&&(this._suppressMarkerCreateEvent=!1,this.onMarkerCreated&&this.onMarkerCreated(this)),this.stateChanged()},s.prototype.select=function(){z.prototype.select.call(this),this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText)},s.prototype.deselect=function(){this.state==="edit"&&this.textEditDivClicked(this.textEditor.innerText),z.prototype.deselect.call(this)},s.prototype.dblClick=function(m,W){z.prototype.dblClick.call(this,m,W),this.showTextEditor()},s.prototype.setColor=function(m){this.textElement&&se.setAttributes(this.textElement,[["fill",m]]),this.color=m,this.textEditor&&(this.textEditor.style.color=this.color),this.colorChanged(m)},s.prototype.setFont=function(m){this.textElement&&se.setAttributes(this.textElement,[["font-family",m]]),this.fontFamily=m,this.textEditor&&(this.textEditor.style.fontFamily=this.fontFamily),this.renderText(),this.stateChanged()},s.prototype.hideVisual=function(){this.textElement.style.display="none",this.hideControlBox()},s.prototype.showVisual=function(){this.state==="edit"&&(this._state="select"),this.textElement.style.display="",this.showControlBox()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({color:this.color,fontFamily:this.fontFamily,padding:this.padding,text:this.text},z.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var W=m;this.color=W.color,this.fontFamily=W.fontFamily,this.padding=W.padding,this.text=W.text,this.createVisual(),z.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,W){z.prototype.scale.call(this,m,W),this.setSize(),this.sizeText(),this.positionTextEditor()},s.typeName="TextMarker",s.title="Text marker",s.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>',s}(Ue),pe=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.color="transparent",H.lineWidth=3,H.drawing=!1,H.pixelRatio=1,H.color=Q.defaultColor,H.lineWidth=Q.defaultStrokeWidth,H.pixelRatio=Q.freehandPixelRatio,H.setColor=H.setColor.bind(H),H.addCanvas=H.addCanvas.bind(H),H.finishCreation=H.finishCreation.bind(H),H.setLineWidth=H.setLineWidth.bind(H),H.colorPanel=new Qe("Color",Q.defaultColorSet,Q.defaultColor),H.colorPanel.onColorChanged=H.setColor,H.lineWidthPanel=new Ze("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.lineWidthPanel.onWidthChanged=H.setLineWidth,H}return Ee(s,z),s.prototype.ownsTarget=function(m){return!(!z.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.drawingImage)},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.drawingImage=se.createImage(),this.visual.appendChild(this.drawingImage);var m=se.createTransform();this.visual.transform.baseVal.appendItem(m),this.addMarkerVisualToContainer(this.visual)},s.prototype.pointerDown=function(m,W){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(m.x,m.y),this.drawing=!0):z.prototype.pointerDown.call(this,m,W)},s.prototype.manipulate=function(m){this.state==="creating"?this.drawing&&(this.canvasContext.lineTo(m.x,m.y),this.canvasContext.stroke()):z.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){z.prototype.resize.call(this,m),se.setAttributes(this.visual,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]])},s.prototype.pointerUp=function(m){this._state==="creating"?this.drawing&&(this.canvasContext.closePath(),this.drawing=!1,this.globalSettings.newFreehandMarkerOnPointerUp&&this.finishCreation()):z.prototype.pointerUp.call(this,m)},s.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)},s.prototype.select=function(){this.state==="creating"&&this.finishCreation(),z.prototype.select.call(this)},s.prototype.deselect=function(){this.state==="creating"&&this.finishCreation(),z.prototype.deselect.call(this)},s.prototype.finishCreation=function(){for(var m=this.canvasContext.getImageData(0,0,this.canvasElement.width,this.canvasElement.height),W=[this.canvasElement.width+1,this.canvasElement.height+1,-1,-1],Q=W[0],H=W[1],fe=W[2],Me=W[3],Se=!1,vt=0;vt<this.canvasElement.height;vt++)for(var Ne=0;Ne<this.canvasElement.width;Ne++)m.data[vt*this.canvasElement.width*4+4*Ne+3]>0&&(Se=!0,vt<H&&(H=vt),Ne<Q&&(Q=Ne),vt>Me&&(Me=vt),Ne>fe&&(fe=Ne));if(Se){this.left=Q/this.pixelRatio,this.top=H/this.pixelRatio,this.width=(fe-Q)/this.pixelRatio,this.height=(Me-H)/this.pixelRatio;var _t=document.createElement("canvas");_t.width=fe-Q,_t.height=Me-H,_t.getContext("2d").putImageData(this.canvasContext.getImageData(Q,H,fe-Q,Me-H),0,0),this.drawingImgUrl=_t.toDataURL("image/png"),this.setDrawingImage(),this._state="select",this.onMarkerCreated&&this.onMarkerCreated(this)}this.overlayContainer.innerHTML=""},s.prototype.setDrawingImage=function(){se.setAttributes(this.drawingImage,[["width",this.width.toString()],["height",this.height.toString()]]),se.setAttributes(this.drawingImage,[["href",this.drawingImgUrl]]),this.moveVisual({x:this.left,y:this.top})},s.prototype.setColor=function(m){this.color=m,this.colorChanged(m)},s.prototype.setLineWidth=function(m){this.lineWidth=m},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return this.state==="new"||this.state==="creating"?[this.colorPanel,this.lineWidthPanel]:[]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({drawingImgUrl:this.drawingImgUrl},z.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){this.createVisual(),z.prototype.restoreState.call(this,m),this.drawingImgUrl=m.drawingImgUrl,this.setDrawingImage()},s.prototype.scale=function(m,W){z.prototype.scale.call(this,m,W),this.setDrawingImage()},s.typeName="FreehandMarker",s.title="Freehand marker",s.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>',s}(Ue),de=function(z){function s(m,W,Q){var H=z.call(this,m,Q||'<svg viewBox="0 0 24 24"><path d="M8 14v4l-6-6 6-6v4h8V6l6 6-6 6v-4H8z"/></svg>')||this;return H.typeBoxes=[],H.currentType=W,H.setCurrentType=H.setCurrentType.bind(H),H}return Ee(s,z),s.prototype.getUi=function(){var m=this,W=document.createElement("div");W.style.display="flex",W.style.overflow="hidden",W.style.flexGrow="2";for(var Q=function(Me){var Se="both";switch(Me){case 0:Se="both";break;case 1:Se="start";break;case 2:Se="end";break;case 3:Se="none"}var vt=document.createElement("div");if(vt.style.display="flex",vt.style.flexGrow="2",vt.style.alignItems="center",vt.style.justifyContent="space-between",vt.style.padding="5px",vt.style.borderWidth="2px",vt.style.borderStyle="solid",vt.style.borderColor=Se===H.currentType?H.uiStyleSettings.toolboxAccentColor:"transparent",vt.addEventListener("click",function(){m.setCurrentType(Se,vt)}),W.appendChild(vt),Se==="both"||Se==="start"){var Ne=document.createElement("div");Ne.style.display="flex",Ne.style.alignItems="center",Ne.style.minHeight="20px",Ne.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="`+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Ne.style.marginLeft="5px",vt.appendChild(Ne)}var _t=document.createElement("div");_t.style.display="flex",_t.style.alignItems="center",_t.style.minHeight="20px",_t.style.flexGrow="2";var Ut=document.createElement("hr");if(Ut.style.minWidth="20px",Ut.style.border="0px",Ut.style.borderTop="3px solid "+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee"),Ut.style.flexGrow="2",_t.appendChild(Ut),vt.appendChild(_t),Se==="both"||Se==="end"){var Kt=document.createElement("div");Kt.style.display="flex",Kt.style.alignItems="center",Kt.style.minHeight="20px",Kt.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="`+(H.uiStyleSettings!==void 0?H.uiStyleSettings.toolboxColor:"#eeeeee")+`" />
</svg>`,Kt.style.marginRight="5px",vt.appendChild(Kt)}H.typeBoxes.push(vt)},H=this,fe=0;fe<4;fe++)Q(fe);return W},s.prototype.setCurrentType=function(m,W){var Q=this;this.currentType=m,this.typeBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings!==void 0?Q.uiStyleSettings.toolboxAccentColor:"#3080c3":"transparent"}),this.onArrowTypeChanged&&this.onArrowTypeChanged(this.currentType)},s}(st),ue=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.arrowType="end",H.arrowBaseHeight=10,H.arrowBaseWidth=10,H.getArrowPoints=H.getArrowPoints.bind(H),H.setArrowType=H.setArrowType.bind(H),H.arrowTypePanel=new de("Arrow type","end"),H.arrowTypePanel.onArrowTypeChanged=H.setArrowType,H}return Ee(s,z),s.prototype.ownsTarget=function(m){return!(!z.prototype.ownsTarget.call(this,m)&&m!==this.arrow1&&m!==this.arrow2)},s.prototype.getArrowPoints=function(m,W){var Q=this.arrowBaseWidth+2*this.strokeWidth,H=this.arrowBaseHeight+2*this.strokeWidth;return m-Q/2+","+(W+H/2)+" "+m+","+(W-H/2)+" "+(m+Q/2)+","+(W+H/2)},s.prototype.createTips=function(){this.arrow1=se.createPolygon(this.getArrowPoints(this.x1,this.y1),[["fill",this.strokeColor]]),this.arrow1.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow1),this.arrow2=se.createPolygon(this.getArrowPoints(this.x2,this.y2),[["fill",this.strokeColor]]),this.arrow2.transform.baseVal.appendItem(se.createTransform()),this.visual.appendChild(this.arrow2)},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(z.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",se.setAttributes(this.arrow1,[["points",this.getArrowPoints(this.x1,this.y1)],["fill",this.strokeColor]]),se.setAttributes(this.arrow2,[["points",this.getArrowPoints(this.x2,this.y2)],["fill",this.strokeColor]]),Math.abs(this.x1-this.x2)>.1)){var m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),W=this.arrow1.transform.baseVal.getItem(0);W.setRotate(m,this.x1,this.y1),this.arrow1.transform.baseVal.replaceItem(W,0);var Q=this.arrow2.transform.baseVal.getItem(0);Q.setRotate(m+180,this.x2,this.y2),this.arrow2.transform.baseVal.replaceItem(Q,0)}},s.prototype.setArrowType=function(m){this.arrowType=m,this.adjustVisual(),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel,this.arrowTypePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({arrowType:this.arrowType},z.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){z.prototype.restoreState.call(this,m);var W=m;this.arrowType=W.arrowType,this.createTips(),this.adjustVisual()},s.typeName="ArrowMarker",s.title="Arrow marker",s.icon='<svg viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 7 15.59V9H5v10h10v-2H8.41L19 6.41z"/></svg>',s}(it),te=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.fillColor=Q.defaultFillColor,H.strokeWidth=0,H.fillPanel=new Qe("Color",Q.defaultColorSet,Q.defaultFillColor),H.fillPanel.onColorChanged=H.setFillColor,H}return Ee(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=z.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="CoverMarker",s.title="Cover marker",s.icon='<svg viewBox="0 0 24 24"><path d="M4 6v13h16V6H4z"/></svg>',s}(Xe),q=function(z){function s(m,W,Q,H){var fe=z.call(this,m,H||'<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 fe.opacities=[],fe.opacityBoxes=[],fe.opacities=W,fe.currentOpacity=Q,fe.setCurrentOpacity=fe.setCurrentOpacity.bind(fe),fe}return Ee(s,z),s.prototype.getUi=function(){var m=this,W=document.createElement("div");return W.style.display="flex",W.style.overflow="hidden",W.style.flexGrow="2",W.style.justifyContent="space-between",this.opacities.forEach(function(Q){var H=document.createElement("div");H.style.display="flex",H.style.alignItems="center",H.style.justifyContent="center",H.style.padding="5px",H.style.borderWidth="2px",H.style.borderStyle="solid",H.style.borderColor=Q===m.currentOpacity?m.uiStyleSettings.toolboxAccentColor:"transparent",H.addEventListener("click",function(){m.setCurrentOpacity(Q,H)}),W.appendChild(H);var fe=document.createElement("div");fe.innerText=100*Q+"%",H.appendChild(fe),m.opacityBoxes.push(H)}),W},s.prototype.setCurrentOpacity=function(m,W){var Q=this;this.currentOpacity=m,this.opacityBoxes.forEach(function(H){H.style.borderColor=H===W?Q.uiStyleSettings.toolboxAccentColor:"transparent"}),this.onOpacityChanged&&this.onOpacityChanged(this.currentOpacity)},s}(st),ne=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.setOpacity=H.setOpacity.bind(H),H.fillColor=Q.defaultHighlightColor,H.strokeWidth=0,H.opacity=Q.defaultHighlightOpacity,H.fillPanel=new Qe("Color",Q.defaultColorSet,H.fillColor),H.fillPanel.onColorChanged=H.setFillColor,H.opacityPanel=new q("Opacity",Q.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return Ee(s,z),s.prototype.setOpacity=function(m){this.opacity=m,this.visual&&se.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.fillPanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=z.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="HighlightMarker",s.title="Highlight marker",s.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>',s}(te),ae='<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>',ve=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.bgColor="transparent",H.tipPosition={x:0,y:0},H.tipBase1Position={x:0,y:0},H.tipBase2Position={x:0,y:0},H.tipMoving=!1,H.color=Q.defaultStrokeColor,H.bgColor=Q.defaultFillColor,H.fontFamily=Q.defaultFontFamily,H.defaultSize={x:100,y:30},H.setBgColor=H.setBgColor.bind(H),H.getTipPoints=H.getTipPoints.bind(H),H.positionTip=H.positionTip.bind(H),H.setTipPoints=H.setTipPoints.bind(H),H.colorPanel=new Qe("Text color",Q.defaultColorSet,H.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>'),H.colorPanel.onColorChanged=H.setColor,H.bgColorPanel=new Qe("Fill color",Q.defaultColorSet,H.bgColor,ae),H.bgColorPanel.onColorChanged=H.setBgColor,H.fontFamilyPanel=new Ae("Font",Q.defaultFontFamilies,Q.defaultFontFamily),H.fontFamilyPanel.onFontChanged=H.setFont,H.tipGrip=new ft,H.tipGrip.visual.transform.baseVal.appendItem(se.createTransform()),H.controlBox.appendChild(H.tipGrip.visual),H}return Ee(s,z),s.prototype.ownsTarget=function(m){return z.prototype.ownsTarget.call(this,m)||this.tipGrip.ownsTarget(m)||this.tip===m},s.prototype.createTip=function(){se.setAttributes(this.bgRectangle,[["fill",this.bgColor],["rx","10px"]]),this.tip=se.createPolygon(this.getTipPoints(),[["fill",this.bgColor]]),this.visual.appendChild(this.tip)},s.prototype.pointerDown=function(m,W){this.state==="new"&&z.prototype.pointerDown.call(this,m,W),this.state==="creating"?this.createTip():this.tipGrip.ownsTarget(W)?(this.manipulationStartLeft=this.left,this.manipulationStartTop=this.top,this.tipMoving=!0):z.prototype.pointerDown.call(this,m,W)},s.prototype.pointerUp=function(m){if(this.tipMoving)this.tipMoving=!1,this.isMoved=!0,z.prototype.pointerUp.call(this,m);else{var W=this.state==="creating";z.prototype.pointerUp.call(this,m),this.setTipPoints(W),this.positionTip()}},s.prototype.manipulate=function(m){if(this.tipMoving){var W=this.unrotatePoint(m);this.tipPosition={x:W.x-this.manipulationStartLeft,y:W.y-this.manipulationStartTop},this.positionTip()}else z.prototype.manipulate.call(this,m)},s.prototype.setBgColor=function(m){this.bgRectangle&&this.tip&&(se.setAttributes(this.bgRectangle,[["fill",m]]),se.setAttributes(this.tip,[["fill",m]])),this.bgColor=m,this.fillColorChanged(m)},s.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},s.prototype.setTipPoints=function(m){m===void 0&&(m=!1);var W=Math.min(this.height/2,15),Q=this.height/5;m&&(this.tipPosition={x:W+Q/2,y:this.height+20});var H=Math.atan(this.height/2/(this.width/2));this.tipPosition.x<this.width/2&&this.tipPosition.y<this.height/2?H<Math.atan((this.height/2-this.tipPosition.y)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,W=Math.min(this.width/2,15),this.tipBase1Position={x:W,y:0},this.tipBase2Position={x:W+Q,y:0}):(this.tipBase1Position={x:0,y:W},this.tipBase2Position={x:0,y:W+Q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y<this.height/2?H<Math.atan((this.height/2-this.tipPosition.y)/(this.tipPosition.x-this.width/2))?(Q=this.width/5,W=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-W-Q,y:0},this.tipBase2Position={x:this.width-W,y:0}):(this.tipBase1Position={x:this.width,y:W},this.tipBase2Position={x:this.width,y:W+Q}):this.tipPosition.x>=this.width/2&&this.tipPosition.y>=this.height/2?H<Math.atan((this.tipPosition.y-this.height/2)/(this.tipPosition.x-this.width/2))?(Q=this.width/5,W=Math.min(this.width/2,15),this.tipBase1Position={x:this.width-W-Q,y:this.height},this.tipBase2Position={x:this.width-W,y:this.height}):(this.tipBase1Position={x:this.width,y:this.height-W-Q},this.tipBase2Position={x:this.width,y:this.height-W}):H<Math.atan((this.tipPosition.y-this.height/2)/(this.width/2-this.tipPosition.x))?(Q=this.width/5,W=Math.min(this.width/2,15),this.tipBase1Position={x:W,y:this.height},this.tipBase2Position={x:W+Q,y:this.height}):(this.tipBase1Position={x:0,y:this.height-W},this.tipBase2Position={x:0,y:this.height-W-Q})},s.prototype.resize=function(m){z.prototype.resize.call(this,m),this.positionTip()},s.prototype.positionTip=function(){se.setAttributes(this.tip,[["points",this.getTipPoints()]]);var m=this.tipGrip.visual.transform.baseVal.getItem(0);m.setTranslate(this.tipPosition.x,this.tipPosition.y),this.tipGrip.visual.transform.baseVal.replaceItem(m,0)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.colorPanel,this.bgColorPanel,this.fontFamilyPanel]},enumerable:!1,configurable:!0}),s.prototype.select=function(){this.positionTip(),z.prototype.select.call(this)},s.prototype.getState=function(){var m=Object.assign({bgColor:this.bgColor,tipPosition:this.tipPosition},z.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var W=m;this.bgColor=W.bgColor,this.tipPosition=W.tipPosition,z.prototype.restoreState.call(this,m),this.createTip(),this.setTipPoints()},s.prototype.scale=function(m,W){z.prototype.scale.call(this,m,W),this.tipPosition={x:this.tipPosition.x*m,y:this.tipPosition.y*W},this.positionTip()},s.typeName="CalloutMarker",s.title="Callout marker",s.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>',s}(Oe),Le=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.fillColor="transparent",H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.opacity=1,H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.fillColor=Q.defaultFillColor,H.setStrokeColor=H.setStrokeColor.bind(H),H.setFillColor=H.setFillColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.setOpacity=H.setOpacity.bind(H),H.createVisual=H.createVisual.bind(H),H.strokePanel=new Qe("Line color",me(Q.defaultColorSet,["transparent"]),Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.fillPanel=new Qe("Fill color",me(Q.defaultColorSet,["transparent"]),H.fillColor,ae),H.fillPanel.onColorChanged=H.setFillColor,H.strokeWidthPanel=new Ze("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new Ve("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H.opacityPanel=new q("Opacity",Q.defaultOpacitySteps,H.opacity),H.opacityPanel.onOpacityChanged=H.setOpacity,H}return Ee(s,z),s.prototype.ownsTarget=function(m){return!(!z.prototype.ownsTarget.call(this,m)&&m!==this.visual)},s.prototype.createVisual=function(){this.visual=se.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)},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.state==="new"&&(this.createVisual(),this.moveVisual(m),this._state="creating")},s.prototype.manipulate=function(m){z.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){z.prototype.resize.call(this,m),this.setSize()},s.prototype.setSize=function(){z.prototype.setSize.call(this),se.setAttributes(this.visual,[["cx",(this.width/2).toString()],["cy",(this.height/2).toString()],["rx",(this.width/2).toString()],["ry",(this.height/2).toString()]])},s.prototype.pointerUp=function(m){z.prototype.pointerUp.call(this,m),this.setSize()},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.visual&&se.setAttributes(this.visual,[["stroke",this.strokeColor]]),this.colorChanged(m),this.stateChanged()},s.prototype.setFillColor=function(m){this.fillColor=m,this.visual&&se.setAttributes(this.visual,[["fill",this.fillColor]]),this.fillColorChanged(m),this.stateChanged()},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.visual&&se.setAttributes(this.visual,[["stroke-width",this.strokeWidth.toString()]]),this.stateChanged()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.visual&&se.setAttributes(this.visual,[["stroke-dasharray",this.strokeDasharray]]),this.stateChanged()},s.prototype.setOpacity=function(m){this.opacity=m,this.visual&&se.setAttributes(this.visual,[["opacity",this.opacity.toString()]]),this.stateChanged()},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.fillPanel,this.strokeWidthPanel,this.strokeStylePanel,this.opacityPanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({fillColor:this.fillColor,strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,opacity:this.opacity},z.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){var W=m;this.fillColor=W.fillColor,this.strokeColor=W.strokeColor,this.strokeWidth=W.strokeWidth,this.strokeDasharray=W.strokeDasharray,this.opacity=W.opacity,this.createVisual(),z.prototype.restoreState.call(this,m),this.setSize()},s.prototype.scale=function(m,W){z.prototype.scale.call(this,m,W),this.setSize()},s.typeName="EllipseMarker",s.title="Ellipse marker",s.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>',s}(Ue),Ie=function(z){function s(m,W,Q){return z.call(this,m,W,Q)||this}return Ee(s,z),Object.defineProperty(s.prototype,"tipLength",{get:function(){return 10+3*this.strokeWidth},enumerable:!1,configurable:!0}),s.prototype.ownsTarget=function(m){return!(!z.prototype.ownsTarget.call(this,m)&&m!==this.tip1&&m!==this.tip2)},s.prototype.createTips=function(){this.tip1=se.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(se.createTransform()),this.visual.appendChild(this.tip1),this.tip2=se.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(se.createTransform()),this.visual.appendChild(this.tip2)},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.state==="creating"&&this.createTips()},s.prototype.adjustVisual=function(){if(z.prototype.adjustVisual.call(this),this.tip1&&this.tip2&&(se.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()]]),se.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 m=180*Math.atan((this.y2-this.y1)/(this.x2-this.x1))/Math.PI+90*Math.sign(this.x1-this.x2),W=this.tip1.transform.baseVal.getItem(0);W.setRotate(m,this.x1,this.y1),this.tip1.transform.baseVal.replaceItem(W,0);var Q=this.tip2.transform.baseVal.getItem(0);Q.setRotate(m+180,this.x2,this.y2),this.tip2.transform.baseVal.replaceItem(Q,0)}},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=z.prototype.getState.call(this);return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){z.prototype.restoreState.call(this,m),this.createTips(),this.adjustVisual()},s.typeName="MeasurementMarker",s.title="Measurement marker",s.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>',s}(it),lt=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.strokePanel.colors=Q.defaultColorSet,H.fillColor="transparent",H}return Ee(s,z),Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=z.prototype.getState.call(this);return m.typeName=s.typeName,m},s.typeName="EllipseFrameMarker",s.title="Ellipse frame marker",s.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>',s}(Le),Rt=function(){function z(){this.undoStack=[],this.redoStack=[]}return Object.defineProperty(z.prototype,"isUndoPossible",{get:function(){return this.undoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isRedoPossible",{get:function(){return this.redoStack.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"undoStepCount",{get:function(){return this.undoStack.length},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"redoStepCount",{get:function(){return this.redoStack.length},enumerable:!1,configurable:!0}),z.prototype.addUndoStep=function(s){this.undoStack.length!==0&&JSON.stringify(this.undoStack[this.undoStack.length-1])===JSON.stringify(s)||(this.undoStack.push(s),JSON.stringify(this.lastRedoStep)!==JSON.stringify(s)&&this.redoStack.splice(0,this.redoStack.length))},z.prototype.replaceLastUndoStep=function(s){this.undoStack.length>0&&(this.undoStack[this.undoStack.length-1]=s)},z.prototype.getLastUndoStep=function(){return this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0},z.prototype.undo=function(){if(this.undoStack.length>1){var s=this.undoStack.pop();return s!==void 0&&this.redoStack.push(s),this.undoStack.length>0?this.undoStack[this.undoStack.length-1]:void 0}},z.prototype.redo=function(){return this.lastRedoStep=this.redoStack.pop(),this.lastRedoStep},z}(),Pe=function(z){function s(m,W,Q){var H=z.call(this,m,W,Q)||this;return H.strokeColor="transparent",H.strokeWidth=0,H.strokeDasharray="",H.curveX=0,H.curveY=0,H.manipulationStartCurveX=0,H.manipulationStartCurveY=0,H.setStrokeColor=H.setStrokeColor.bind(H),H.setStrokeWidth=H.setStrokeWidth.bind(H),H.setStrokeDasharray=H.setStrokeDasharray.bind(H),H.positionGrips=H.positionGrips.bind(H),H.addControlGrips=H.addControlGrips.bind(H),H.adjustVisual=H.adjustVisual.bind(H),H.setupControlBox=H.setupControlBox.bind(H),H.resize=H.resize.bind(H),H.strokeColor=Q.defaultColor,H.strokeWidth=Q.defaultStrokeWidth,H.strokeDasharray=Q.defaultStrokeDasharray,H.strokePanel=new Qe("Line color",Q.defaultColorSet,Q.defaultColor),H.strokePanel.onColorChanged=H.setStrokeColor,H.strokeWidthPanel=new Ze("Line width",Q.defaultStrokeWidths,Q.defaultStrokeWidth),H.strokeWidthPanel.onWidthChanged=H.setStrokeWidth,H.strokeStylePanel=new Ve("Line style",Q.defaultStrokeDasharrays,Q.defaultStrokeDasharray),H.strokeStylePanel.onStyleChanged=H.setStrokeDasharray,H}return Ee(s,z),s.prototype.ownsTarget=function(m){return!(!z.prototype.ownsTarget.call(this,m)&&m!==this.visual&&m!==this.selectorCurve&&m!==this.visibleCurve&&!this.curveGrip.ownsTarget(m))},s.prototype.getPathD=function(){return"M "+this.x1+" "+this.y1+" Q "+this.curveX+" "+this.curveY+", "+this.x2+" "+this.y2},s.prototype.createVisual=function(){this.visual=se.createGroup(),this.selectorCurve=se.createPath(this.getPathD(),[["stroke","transparent"],["stroke-width",(this.strokeWidth+10).toString()],["fill","transparent"]]),this.visibleCurve=se.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)},s.prototype.pointerDown=function(m,W){z.prototype.pointerDown.call(this,m,W),this.manipulationStartCurveX=this.curveX,this.manipulationStartCurveY=this.curveY,this.state==="new"&&(this.curveX=m.x,this.curveY=m.y),this.state==="new"?(this.createVisual(),this.adjustVisual(),this._state="creating"):this.curveGrip.ownsTarget(W)&&(this.activeGrip=this.curveGrip,this._state="resize")},s.prototype.adjustVisual=function(){this.selectorCurve&&this.visibleCurve&&(this.selectorCurve.setAttribute("d",this.getPathD()),this.visibleCurve.setAttribute("d",this.getPathD()),se.setAttributes(this.visibleCurve,[["stroke",this.strokeColor]]),se.setAttributes(this.visibleCurve,[["stroke-width",this.strokeWidth.toString()]]),se.setAttributes(this.visibleCurve,[["stroke-dasharray",this.strokeDasharray.toString()]]))},s.prototype.setupControlBox=function(){z.prototype.setupControlBox.call(this),this.curveControlLine1=se.createLine(this.x1,this.y1,this.curveX,this.curveY,[["stroke","black"],["stroke-width","1"],["stroke-opacity","0.5"],["stroke-dasharray","3, 2"]]),this.curveControlLine2=se.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)},s.prototype.addControlGrips=function(){this.curveGrip=this.createGrip(),this.curveX=0,this.curveY=0,z.prototype.addControlGrips.call(this)},s.prototype.positionGrips=function(){z.prototype.positionGrips.call(this);var m=this.curveGrip.GRIP_SIZE;this.positionGrip(this.curveGrip.visual,this.curveX-m/2,this.curveY-m/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()))},s.prototype.manipulate=function(m){this.state==="move"&&(this.curveX=this.manipulationStartCurveX+m.x-this.manipulationStartX,this.curveY=this.manipulationStartCurveY+m.y-this.manipulationStartY),z.prototype.manipulate.call(this,m)},s.prototype.resize=function(m){this.activeGrip===this.curveGrip&&(this.curveX=m.x,this.curveY=m.y),z.prototype.resize.call(this,m),this.state==="creating"&&(this.curveX=this.x1+(this.x2-this.x1)/2,this.curveY=this.y1+(this.y2-this.y1)/2)},s.prototype.setStrokeColor=function(m){this.strokeColor=m,this.adjustVisual(),this.colorChanged(m)},s.prototype.setStrokeWidth=function(m){this.strokeWidth=m,this.adjustVisual()},s.prototype.setStrokeDasharray=function(m){this.strokeDasharray=m,this.adjustVisual()},s.prototype.scale=function(m,W){this.curveX=this.curveX*m,this.curveY=this.curveY*W,z.prototype.scale.call(this,m,W)},Object.defineProperty(s.prototype,"toolboxPanels",{get:function(){return[this.strokePanel,this.strokeWidthPanel,this.strokeStylePanel]},enumerable:!1,configurable:!0}),s.prototype.getState=function(){var m=Object.assign({strokeColor:this.strokeColor,strokeWidth:this.strokeWidth,strokeDasharray:this.strokeDasharray,curveX:this.curveX,curveY:this.curveY},z.prototype.getState.call(this));return m.typeName=s.typeName,m},s.prototype.restoreState=function(m){z.prototype.restoreState.call(this,m);var W=m;this.strokeColor=W.strokeColor,this.strokeWidth=W.strokeWidth,this.strokeDasharray=W.strokeDasharray,this.curveX=W.curveX,this.curveY=W.curveY,this.createVisual(),this.adjustVisual()},s.typeName="CurveMarker",s.title="Curve marker",s.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>',s}(qe),xt=function(){function z(s,m){m===void 0&&(m=!1),this.cancelable=!1,this._defaultPrevented=!1,this.markerArea=s,this.cancelable=m}return Object.defineProperty(z.prototype,"defaultPrevented",{get:function(){return this._defaultPrevented},enumerable:!1,configurable:!0}),z.prototype.preventDefault=function(){this._defaultPrevented=!0},z}(),mt=function(z){function s(m,W,Q){var H=z.call(this,m,!1)||this;return H.dataUrl=W,H.state=Q,H}return Ee(s,z),s}(xt),He=function(z){function s(m,W,Q){Q===void 0&&(Q=!1);var H=z.call(this,m,Q)||this;return H.marker=W,H}return Ee(s,z),s}(xt),Tt=function(){function z(){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 z.prototype.addEventListener=function(s,m){this[s].push(m)},z.prototype.removeEventListener=function(s,m){var W=this[s].indexOf(m);W>-1&&this[s].splice(W,1)},z}(),yt=function(){function z(s){this.touchPoints=0,this._availableMarkerTypes=this.DEFAULT_MARKER_TYPES,this.mode="select",this.markers=[],this.isDragging=!1,this.renderEventListeners=[],this.closeEventListeners=[],this.settings=new we,this._isOpen=!1,this.undoRedoManager=new Rt,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 Tt,this._silentRenderMode=!1,this._isFocused=!1,this._instanceNo=z.instanceCounter++,this.styles=new tt(this.instanceNo),this.uiStyleSettings=this.styles.settings,this.target=s,this.targetRoot=document.body,this.width=s.clientWidth,this.height=s.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(z.prototype,"ALL_MARKER_TYPES",{get:function(){return[rt,pe,ue,Oe,lt,Le,ne,ve,Ie,te,it,Pe]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"DEFAULT_MARKER_TYPES",{get:function(){return[rt,pe,ue,Oe,Le,ne,ve]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"BASIC_MARKER_TYPES",{get:function(){return[rt,pe,ue,Oe,ne]},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"availableMarkerTypes",{get:function(){return this._availableMarkerTypes},set:function(s){var m=this;this._availableMarkerTypes.splice(0),s.forEach(function(W){if(typeof W=="string"){var Q=m.ALL_MARKER_TYPES.find(function(H){return H.typeName===W});Q!==void 0&&m._availableMarkerTypes.push(Q)}else m._availableMarkerTypes.push(W)})},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"currentMarker",{get:function(){return this._currentMarker},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isUndoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isUndoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isRedoPossible",{get:function(){return!(!this.undoRedoManager||!this.undoRedoManager.isRedoPossible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomLevel",{get:function(){return this._zoomLevel},set:function(s){this._zoomLevel=s,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(z.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),z.prototype.open=function(){this.setupResizeObserver(),this.setEditingTarget(),this.setTopLeft(),this.initMarkerCanvas(),this.initOverlay(),this.attachEvents(),this.settings.displayMode==="popup"&&this.onPopupTargetResize(),Re.isLicensed||this.addLogo(),this._isOpen=!0,this._isFocused=!0},z.prototype.show=function(){var s=this;this.styles.styleSheetRoot===void 0&&Ge.styleSheetRoot!==void 0&&(this.styles.styleSheetRoot=Ge.styleSheetRoot),this.setWindowHeight(),this.showUI(),this.open(),this.eventListeners.show.forEach(function(m){return m(new xt(s))})},z.prototype.render=function(){return Te(this,void 0,void 0,function(){var s;return Ce(this,function(m){switch(m.label){case 0:return this.setCurrentMarker(),(s=new et).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.markersOnly=this.renderMarkersOnly,s.width=this.renderWidth,s.height=this.renderHeight,[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 1:return m.sent(),[4,s.rasterize(this.target instanceof HTMLImageElement?this.target:null,this.markerImage,this.renderTarget)];case 2:return[2,m.sent()]}})})},z.prototype.close=function(s){var m=this;if(s===void 0&&(s=!1),this.isOpen){var W=!1;s||this.eventListeners.beforeclose.forEach(function(Q){var H=new xt(m,!0);Q(H),H.defaultPrevented&&(W=!0)}),W||(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 xt(m))}),this.detachEvents(),this._isOpen=!1)}},z.prototype.addMarkersToToolbar=function(){for(var s,m=[],W=0;W<arguments.length;W++)m[W]=arguments[W];(s=this._availableMarkerTypes).push.apply(s,m)},z.prototype.addRenderEventListener=function(s){this.addEventListener("render",function(m){s(m.dataUrl,m.state)})},z.prototype.removeRenderEventListener=function(s){},z.prototype.addCloseEventListener=function(s){this.addEventListener("close",function(){s()})},z.prototype.removeCloseEventListener=function(s){},z.prototype.setupResizeObserver=function(){var s=this;this.settings.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.target.clientHeight)}),this.targetObserver.observe(this.target)):this.settings.displayMode==="popup"&&(window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){return s.onPopupTargetResize()}),this.targetObserver.observe(this.editorCanvas)),window.addEventListener("resize",this.setWindowHeight))},z.prototype.onPopupTargetResize=function(){var s=1*this.target.clientWidth/this.target.clientHeight,m=this.editorCanvas.clientWidth/s>this.editorCanvas.clientHeight?this.editorCanvas.clientHeight*s:this.editorCanvas.clientWidth,W=m<this.editorCanvas.clientWidth?this.editorCanvas.clientHeight:this.editorCanvas.clientWidth/s;this.resize(m,W)},z.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},z.prototype.resize=function(s,m){this._isResizing=!0;var W=s/this.imageWidth,Q=m/this.imageHeight;this.imageWidth=Math.round(s),this.imageHeight=Math.round(m),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(W,Q),this._isResizing=!1},z.prototype.scaleMarkers=function(s,m){var W,Q=this;this._currentMarker&&this._currentMarker instanceof Oe?this._currentMarker.scale(s,m):(W=this._currentMarker,this.setCurrentMarker()),this.markers.forEach(function(H){H!==Q._currentMarker&&H.scale(s,m)}),W!==void 0&&this.setCurrentMarker(W)},z.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"},z.prototype.setTopLeft=function(){var s=this.editingTarget.getBoundingClientRect(),m=this.editorCanvas.getBoundingClientRect();this.left=s.left-m.left,this.top=s.top-m.top},z.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)},z.prototype.addDefs=function(){for(var s,m=[],W=0;W<arguments.length;W++)m[W]=arguments[W];this.defs=se.createDefs(),this.addDefsToImage(),(s=this.defs).append.apply(s,m)},z.prototype.addDefsToImage=function(){this.defs&&this.markerImage.insertBefore(this.defs,this.markerImage.firstChild)},z.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)},z.prototype.positionMarkerImage=function(){this.markerImageHolder.style.top=this.top/this.zoomLevel+"px",this.markerImageHolder.style.left=this.left/this.zoomLevel+"px"},z.prototype.attachEvents=function(){this.markerImage.addEventListener("pointerdown",this.onPointerDown),this.markerImage.addEventListener("dblclick",this.onDblClick),this.attachWindowEvents()},z.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)},z.prototype.detachEvents=function(){this.markerImage.removeEventListener("pointerdown",this.onPointerDown),this.markerImage.removeEventListener("dblclick",this.onDblClick),this.detachWindowEvents()},z.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)},z.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 s=document.createElement("a");s.href="https://markerjs.com/",s.target="_blank",s.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>',s.title="Powered by marker.js",s.style.display="grid",s.style.alignItems="center",s.style.justifyItems="center",s.style.padding="3px",s.style.width="20px",s.style.height="20px",this.logoUI.appendChild(s),this.editorCanvas.appendChild(this.logoUI),this.logoUI.style.position="absolute",this.logoUI.style.pointerEvents="all",this.positionLogo()},z.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")},z.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"},z.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},z.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 s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"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 je(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 $e(this.uiDiv,this.settings.displayMode,this.uiStyleSettings,this.styles),this.toolbox.show(this._silentRenderMode||this.uiStyleSettings.hideToolbox?"hidden":"visible")},z.prototype.closeUI=function(){this.settings.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},z.prototype.removeMarker=function(s){this.markerImage.removeChild(s.container),this.markers.indexOf(s)>-1&&this.markers.splice(this.markers.indexOf(s),1),s.dispose()},z.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())},z.prototype.toolbarButtonClicked=function(s,m){if(s==="marker"&&m!==void 0)this.createNewMarker(m);else if(s==="action")switch(m){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()}},z.prototype.deleteSelectedMarker=function(){var s=this;if(this._currentMarker!==void 0){var m=!1;if(this.eventListeners.markerbeforedelete.forEach(function(Q){var H=new He(s,s._currentMarker,!0);Q(H),H.defaultPrevented&&(m=!0)}),!m){var W=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 He(s,W))})}}},z.prototype.clear=function(){var s=this,m=!1;if(this.markers.length>0&&(this.eventListeners.markerbeforedelete.forEach(function(fe){var Me=new He(s,void 0,!0);fe(Me),Me.defaultPrevented&&(m=!0)}),!m)){this.setCurrentMarker();for(var W=function(fe){var Me=Q.markers[fe];Q.setCurrentMarker(Q.markers[fe]),Q._currentMarker.dispose(),Q.markerImage.removeChild(Q._currentMarker.container),Q.markers.splice(Q.markers.indexOf(Q._currentMarker),1),Q.eventListeners.markerdelete.forEach(function(Se){return Se(new He(s,Me))})},Q=this,H=this.markers.length-1;H>=0;H--)W(H);this.addUndoStep()}},Object.defineProperty(z.prototype,"isNotesAreaOpen",{get:function(){return this.notesArea!==void 0},enumerable:!1,configurable:!0}),z.prototype.showNotesEditor=function(){var s;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=(s=this._currentMarker.notes)!==null&&s!==void 0?s:"",this.overlayContainer.appendChild(this.notesArea))},z.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)},z.prototype.selectLastMarker=function(){this.markers.length>0?this.setCurrentMarker(this.markers[this.markers.length-1]):this.setCurrentMarker()},z.prototype.addUndoStep=function(){var s=this;if(this._currentMarker===void 0||this._currentMarker.state!=="edit"){var m=this.getState(),W=this.undoRedoManager.getLastUndoStep();if(!W||W.width===m.width&&W.height===m.height){var Q=this.undoRedoManager.undoStepCount;this.undoRedoManager.addUndoStep(m),Q<this.undoRedoManager.undoStepCount&&this.eventListeners.statechange.forEach(function(H){return H(new xt(s))})}else this.undoRedoManager.replaceLastUndoStep(m),this.eventListeners.statechange.forEach(function(H){return H(new xt(s))})}},z.prototype.undo=function(){this.switchToSelectMode(),this.addUndoStep(),this.undoStep()},z.prototype.undoStep=function(){var s=this,m=this.undoRedoManager.undo();m!==void 0&&(this.restoreState(m),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(W){return W(new xt(s))}))},z.prototype.redo=function(){this.switchToSelectMode(),this.redoStep()},z.prototype.redoStep=function(){var s=this,m=this.undoRedoManager.redo();m!==void 0&&(this.restoreState(m),this.addDefsToImage(),this.selectLastMarker(),this.eventListeners.statechange.forEach(function(W){return W(new xt(s))}))},z.prototype.stepZoom=function(){var s=this.zoomSteps.indexOf(this.zoomLevel);this.zoomLevel=s<this.zoomSteps.length-1?this.zoomSteps[s+1]:this.zoomSteps[0]},z.prototype.panTo=function(s){this.contentDiv.scrollBy({left:this.prevPanPoint.x-s.x,top:this.prevPanPoint.y-s.y}),this.prevPanPoint=s},z.prototype.startRenderAndClose=function(){return Te(this,void 0,void 0,function(){var s,m,W=this;return Ce(this,function(Q){switch(Q.label){case 0:return[4,this.render()];case 1:return s=Q.sent(),m=this.getState(),this.eventListeners.render.forEach(function(H){return H(new mt(W,s,m))}),this.close(!0),[2]}})})},z.prototype.getState=function(s){s===!0&&this.setCurrentMarker();var m={width:this.imageWidth,height:this.imageHeight,markers:[]};return this.markers.forEach(function(W){return m.markers.push(W.getState())}),m},z.prototype.restoreState=function(s){var m=this;for(this.markers.splice(0);this.markerImage.lastChild;)this.markerImage.removeChild(this.markerImage.lastChild);s.markers.forEach(function(W){var Q=m._availableMarkerTypes.find(function(fe){return fe.typeName===W.typeName});if(Q!==void 0){var H=m.addNewMarker(Q);H.restoreState(W),m.markers.push(H)}}),s.width&&s.height&&(s.width!==this.imageWidth||s.height!==this.imageHeight)&&this.scaleMarkers(this.imageWidth/s.width,this.imageHeight/s.height),this.eventListeners.restorestate.forEach(function(W){return W(new xt(m))})},z.prototype.addNewMarker=function(s){var m=se.createGroup();return this.markerImage.appendChild(m),new s(m,this.overlayContainer,this.settings)},z.prototype.createNewMarker=function(s){var m,W=this;(m=typeof s=="string"?this._availableMarkerTypes.find(function(Q){return Q.typeName===s}):s)&&(this.setCurrentMarker(),this.addUndoStep(),this._currentMarker=this.addNewMarker(m),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(m.typeName),this.toolbox.setPanelButtons(this._currentMarker.toolboxPanels),this.eventListeners.markercreating.forEach(function(Q){return Q(new He(W,W._currentMarker))}))},z.prototype.markerCreated=function(s){var m=this;this.mode="select",this.markerImage.style.cursor="default",this.markers.push(s),this.setCurrentMarker(s),s instanceof pe&&this.settings.newFreehandMarkerOnPointerUp?this.createNewMarker(pe):this.toolbar.setSelectMode(),this.addUndoStep(),this.eventListeners.markercreate.forEach(function(W){return W(new He(m,m._currentMarker))})},z.prototype.colorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultColor=s,this.settings.defaultStrokeColor=s)},z.prototype.fillColorChanged=function(s){this.settings.defaultColorsFollowCurrentColors&&(this.settings.defaultFillColor=s)},z.prototype.markerStateChanged=function(s){var m=this;this.eventListeners.markerchange.forEach(function(W){return W(new He(m,s))})},z.prototype.setCurrentMarker=function(s){var m=this;this._currentMarker!==s&&this._currentMarker!==void 0&&(this._currentMarker.deselect(),this.toolbar.setCurrentMarker(),this.toolbox.setPanelButtons([]),this._isResizing||this.eventListeners.markerdeselect.forEach(function(W){return W(new He(m,m._currentMarker))})),this._currentMarker=s,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(W){return W(new He(m,m._currentMarker))}))},z.prototype.onPointerDown=function(s){if(this._isFocused||this.focus(),this.touchPoints++,this.touchPoints===1||s.pointerType!=="touch")if(this._currentMarker===void 0||this._currentMarker.state!=="new"&&this._currentMarker.state!=="creating"){if(this.mode==="select"){var m=this.markers.find(function(W){return W.ownsTarget(s.target)});m!==void 0?(this.setCurrentMarker(m),this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target)):(this.setCurrentMarker(),this.isDragging=!0,this.prevPanPoint={x:s.clientX,y:s.clientY})}}else this.isDragging=!0,this._currentMarker.pointerDown(this.clientToLocalCoordinates(s.clientX,s.clientY))},z.prototype.onDblClick=function(s){if(this._isFocused||this.focus(),this.mode==="select"){var m=this.markers.find(function(W){return W.ownsTarget(s.target)});m!==void 0&&m!==this._currentMarker&&this.setCurrentMarker(m),this._currentMarker!==void 0?this._currentMarker.dblClick(this.clientToLocalCoordinates(s.clientX,s.clientY),s.target):this.setCurrentMarker()}},z.prototype.onPointerMove=function(s){this.touchPoints!==1&&s.pointerType==="touch"||(this._currentMarker!==void 0||this.isDragging)&&(this._currentMarker!==void 0&&this._currentMarker.state==="edit"||s.preventDefault(),this._currentMarker!==void 0?this._currentMarker.manipulate(this.clientToLocalCoordinates(s.clientX,s.clientY)):this.zoomLevel>1&&this.panTo({x:s.clientX,y:s.clientY}))},z.prototype.onPointerUp=function(s){this.touchPoints>0&&this.touchPoints--,this.touchPoints===0&&this.isDragging&&this._currentMarker!==void 0&&this._currentMarker.pointerUp(this.clientToLocalCoordinates(s.clientX,s.clientY)),this.isDragging=!1,this.addUndoStep()},z.prototype.onPointerOut=function(){this.touchPoints>0&&this.touchPoints--},z.prototype.onKeyUp=function(s){this._currentMarker===void 0||this.notesArea!==void 0||s.key!=="Delete"&&s.key!=="Backspace"||this.deleteSelectedMarker()},z.prototype.clientToLocalCoordinates=function(s,m){var W=this.markerImage.getBoundingClientRect();return{x:(s-W.left)/this.zoomLevel,y:(m-W.top)/this.zoomLevel}},z.prototype.onWindowResize=function(){this.positionUI()},z.prototype.positionUI=function(){switch(this.setTopLeft(),this.settings.displayMode){case"inline":var s=this.target.getClientRects().item(0).y>this.styles.settings.toolbarHeight?this.target.offsetTop-this.styles.settings.toolbarHeight:0;this.coverDiv.style.top=s+"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()},z.prototype.addLicenseKey=function(s){Re.addKey(s)},z.prototype.addEventListener=function(s,m){this.eventListeners.addEventListener(s,m)},z.prototype.removeEventListener=function(s,m){this.eventListeners.removeEventListener(s,m)},z.prototype.renderState=function(s){this._silentRenderMode=!0,this.settings.displayMode="inline",this.isOpen||this.show(),this.restoreState(s),this.startRenderAndClose(),this._silentRenderMode=!1},Object.defineProperty(z.prototype,"isFocused",{get:function(){return this._isFocused},enumerable:!1,configurable:!0}),z.prototype.focus=function(){var s=this;this._isFocused||(this.attachWindowEvents(),this._isFocused=!0,this._previousCurrentMarker!==void 0&&this.setCurrentMarker(this._previousCurrentMarker),this.eventListeners.focus.forEach(function(m){return m(new xt(s))}))},z.prototype.blur=function(){var s=this;this._isFocused&&(this.detachWindowEvents(),this._isFocused=!1,this._previousCurrentMarker=this._currentMarker,this.setCurrentMarker(),this.eventListeners.blur.forEach(function(m){return m(new xt(s))}))},z.instanceCounter=0,z}();/* **********************************
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 kt=function(z,s){return(kt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,W){m.__proto__=W}||function(m,W){for(var Q in W)Object.prototype.hasOwnProperty.call(W,Q)&&(m[Q]=W[Q])})(z,s)};function Lt(z,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function m(){this.constructor=z}kt(z,s),z.prototype=s===null?Object.create(s):(m.prototype=s.prototype,new m)}function Et(z,s,m,W){return new(m||(m=Promise))(function(Q,H){function fe(vt){try{Se(W.next(vt))}catch(Ne){H(Ne)}}function Me(vt){try{Se(W.throw(vt))}catch(Ne){H(Ne)}}function Se(vt){var Ne;vt.done?Q(vt.value):(Ne=vt.value,Ne instanceof m?Ne:new m(function(_t){_t(Ne)})).then(fe,Me)}Se((W=W.apply(z,s||[])).next())})}function sr(z,s){var m,W,Q,H,fe={label:0,sent:function(){if(1&Q[0])throw Q[1];return Q[1]},trys:[],ops:[]};return H={next:Me(0),throw:Me(1),return:Me(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function Me(Se){return function(vt){return function(Ne){if(m)throw new TypeError("Generator is already executing.");for(;fe;)try{if(m=1,W&&(Q=2&Ne[0]?W.return:Ne[0]?W.throw||((Q=W.return)&&Q.call(W),0):W.next)&&!(Q=Q.call(W,Ne[1])).done)return Q;switch(W=0,Q&&(Ne=[2&Ne[0],Q.value]),Ne[0]){case 0:case 1:Q=Ne;break;case 4:return fe.label++,{value:Ne[1],done:!1};case 5:fe.label++,W=Ne[1],Ne=[0];continue;case 7:Ne=fe.ops.pop(),fe.trys.pop();continue;default:if(!(Q=fe.trys,(Q=Q.length>0&&Q[Q.length-1])||Ne[0]!==6&&Ne[0]!==2)){fe=0;continue}if(Ne[0]===3&&(!Q||Ne[1]>Q[0]&&Ne[1]<Q[3])){fe.label=Ne[1];break}if(Ne[0]===6&&fe.label<Q[1]){fe.label=Q[1],Q=Ne;break}if(Q&&fe.label<Q[2]){fe.label=Q[2],fe.ops.push(Ne);break}Q[2]&&fe.ops.pop(),fe.trys.pop();continue}Ne=s.call(z,fe)}catch(_t){Ne=[6,_t],W=0}finally{m=Q=0}if(5&Ne[0])throw Ne[1];return{value:Ne[0]?Ne[1]:void 0,done:!0}}([Se,vt])}}}var Xt=function(){function z(){}return z.addKey=function(s){z.key=s},Object.defineProperty(z,"isLicensed",{get:function(){return!!z.key&&new RegExp(/^CRPR-[A-Z][0-9]{3}-[A-Z][0-9]{3}-[0-9]{4}$/,"i").test(z.key)},enumerable:!1,configurable:!0}),z}(),gt=function(){function z(){}return z.createDefs=function(){return document.createElementNS("http://www.w3.org/2000/svg","defs")},z.setAttributes=function(s,m){for(var W=0,Q=m;W<Q.length;W++){var H=Q[W],fe=H[0],Me=H[1];s.setAttribute(fe,Me)}},z.createRect=function(s,m,W){var Q=document.createElementNS("http://www.w3.org/2000/svg","rect");return Q.setAttribute("width",s.toString()),Q.setAttribute("height",m.toString()),W&&z.setAttributes(Q,W),Q},z.createLine=function(s,m,W,Q,H){var fe=document.createElementNS("http://www.w3.org/2000/svg","line");return fe.setAttribute("x1",s.toString()),fe.setAttribute("y1",m.toString()),fe.setAttribute("x2",W.toString()),fe.setAttribute("y2",Q.toString()),H&&z.setAttributes(fe,H),fe},z.createPolygon=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","polygon");return W.setAttribute("points",s),m&&z.setAttributes(W,m),W},z.createCircle=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","circle");return W.setAttribute("cx",(s/2).toString()),W.setAttribute("cy",(s/2).toString()),W.setAttribute("r",s.toString()),m&&z.setAttributes(W,m),W},z.createEllipse=function(s,m,W){var Q=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return Q.setAttribute("cx",(s/2).toString()),Q.setAttribute("cy",(m/2).toString()),Q.setAttribute("rx",(s/2).toString()),Q.setAttribute("ry",(m/2).toString()),W&&z.setAttributes(Q,W),Q},z.createGroup=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","g");return s&&z.setAttributes(m,s),m},z.createTransform=function(){return document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGTransform()},z.createMarker=function(s,m,W,Q,H,fe,Me){var Se=document.createElementNS("http://www.w3.org/2000/svg","marker");return z.setAttributes(Se,[["id",s],["orient",m],["markerWidth",W.toString()],["markerHeight",Q.toString()],["refX",H.toString()],["refY",fe.toString()]]),Se.appendChild(Me),Se},z.createText=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","text");return m.setAttribute("x","0"),m.setAttribute("y","0"),s&&z.setAttributes(m,s),m},z.createTSpan=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","tspan");return W.textContent=s,m&&z.setAttributes(W,m),W},z.createImage=function(s){var m=document.createElementNS("http://www.w3.org/2000/svg","image");return s&&z.setAttributes(m,s),m},z.createPoint=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGPoint();return W.x=s,W.y=m,W},z.createPath=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg","path");return W.setAttribute("d",s),m&&z.setAttributes(W,m),W},z.createElement=function(s,m){var W=document.createElementNS("http://www.w3.org/2000/svg",s);return m&&z.setAttributes(W,m),W},z.getHollowRectanglePath=function(s,m,W,Q,H,fe,Me,Se){return"M"+s+","+m+"V"+(m+Q)+"H"+(s+W)+"V"+m+"H"+H+"V"+fe+"H"+(H+Me)+"V"+(fe+Se)+"H"+H+"V"+m+"Z"},z}(),ir=function(){function z(s){this._classNamePrefixBase="__cropro_",this.classes=[],this.rules=[],this.settings=this.defaultSettings,this._classNamePrefix=this._classNamePrefixBase+"_"+s+"_"}return Object.defineProperty(z.prototype,"classNamePrefixBase",{get:function(){return this._classNamePrefixBase},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"classNamePrefix",{get:function(){return this._classNamePrefix},enumerable:!1,configurable:!0}),Object.defineProperty(z.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(z.prototype,"fadeInAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_in"},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"fadeOutAnimationClassName",{get:function(){return this.classNamePrefix+"_fade_out"},enumerable:!1,configurable:!0}),z.prototype.addClass=function(s){return this.styleSheet===void 0&&this.addStyleSheet(),s.name=""+this.classNamePrefix+s.localName,this.classes.push(s),this.styleSheet.sheet.insertRule("."+s.name+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length),s},z.prototype.addRule=function(s){this.styleSheet===void 0&&this.addStyleSheet(),this.rules.push(s),this.styleSheet.sheet.insertRule(s.selector+" {"+s.style+"}",this.styleSheet.sheet.cssRules.length)},z.prototype.addStyleSheet=function(){var s;this.styleSheet=document.createElement("style"),((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).appendChild(this.styleSheet),this.addRule(new pr("."+this.classNamePrefix+" h3","font-family: sans-serif")),this.addRule(new pr("@keyframes "+this.classNamePrefix+"_fade_in_animation_frames",`
from {
opacity: 0;
}
to {
opacity: 1;
}
`)),this.addRule(new pr("@keyframes "+this.classNamePrefix+"_fade_out_animation_frames",`
from {
opacity: 1;
}
to {
opacity: 0;
}
`)),this.addClass(new lr("_fade_in",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_in_animation_frames;
`)),this.addClass(new lr("_fade_out",`
animation-duration: 0.3s;
animation-name: `+this.classNamePrefix+`_fade_out_animation_frames;
`))},z.prototype.removeStyleSheet=function(){var s;this.styleSheet&&(((s=this.styleSheetRoot)!==null&&s!==void 0?s:document.head).removeChild(this.styleSheet),this.styleSheet=void 0)},z}(),pr=function(z,s){this.selector=z,this.style=s},lr=function(z,s){this.localName=z,this.style=s},wr=function(){function z(){this.blocks=[],this.display=""}return z.prototype.addButtonBlock=function(s){s.className=this.blockClassName,s.buttonClassName=this.buttonClassName,s.buttonColorsClassName=this.buttonColorsClassName,s.buttonActiveColorsClassName=this.buttonActiveColorsClassName,this.blocks.push(s)},z.prototype.addElementBlock=function(s){s.className===void 0&&(s.className=this.blockClassName),this.blocks.push(s)},z.prototype.getUI=function(){var s=document.createElement("div");return s.className=this.className+" "+this.colorsClassName+" "+this.fadeInClassName,s.style.display=this.display,this.blocks.forEach(function(m){return s.appendChild(m.getUI())}),s},z}(),$r=function(){function z(){}return z.prototype.getUI=function(){var s=document.createElement("div");if(s.className=this.className,this.minWidth!==void 0&&(s.style.minWidth=this.minWidth),this.contentAlign!==void 0)switch(this.contentAlign){case"start":s.style.justifyContent="flex-start";break;case"center":s.style.justifyContent="center";break;case"end":s.style.justifyContent="flex-end"}return s.style.whiteSpace="nowrap",s},z}(),Ur=function(z){function s(){var m=z!==null&&z.apply(this,arguments)||this;return m.buttons=[],m}return Lt(s,z),s.prototype.addButton=function(m){m.className=this.buttonClassName,m.colorsClassName=this.buttonColorsClassName,m.activeColorsClassName=this.buttonActiveColorsClassName,this.buttons.push(m)},s.prototype.getUI=function(){var m=z.prototype.getUI.call(this);return this.buttons.forEach(function(W){return m.appendChild(W.getUI())}),m},s}($r),ct=function(){function z(s,m){this._isActive=!1,this._isHidden=!1,this._icon=s,this.title=m,this.uiContainer=document.createElement("div"),this.adjustClassName=this.adjustClassName.bind(this)}return Object.defineProperty(z.prototype,"icon",{get:function(){return this._icon},set:function(s){this._icon=s,this.buttonContainer.innerHTML=this._icon},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isActive",{get:function(){return this._isActive},set:function(s){this._isActive=s,this.adjustClassName()},enumerable:!1,configurable:!0}),z.prototype.getUI=function(){var s=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 s.onClick()}),this.uiContainer.appendChild(this.buttonContainer),this.uiContainer.style.display=this._isHidden?"none":"inline-block",this.uiContainer},z.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,"")))},z.prototype.hide=function(){this._isHidden=!0},z}(),ut=function(z){function s(){var m=z!==null&&z.apply(this,arguments)||this;return m.elements=[],m}return Lt(s,z),s.prototype.addElement=function(m){this.elements.push(m)},s.prototype.getUI=function(){var m=z.prototype.getUI.call(this);return this.elements.forEach(function(W){return m.appendChild(W)}),m},s}($r),qt=function(){function z(s,m){this.horizontal=s,this.vertical=m}return Object.defineProperty(z.prototype,"ratio",{get:function(){return 1*this.horizontal/this.vertical},enumerable:!1,configurable:!0}),z.prototype.getVerticalLength=function(s){return s/this.ratio},z.prototype.getHorizontalLength=function(s){return s*this.ratio},z}(),jt=function(){function z(){}return z.getIcon=function(s,m){if(s>0&&m>0){var W=new qt(s,m),Q=W.ratio>=1?20:W.getHorizontalLength(20),H=W.ratio<1?20:W.getVerticalLength(20),fe=document.createElementNS("http://www.w3.org/2000/svg","svg");fe.setAttribute("xmlns","http://www.w3.org/2000/svg"),fe.setAttribute("viewBox","0 0 24 24"),document.body.appendChild(fe);var Me=gt.createDefs();fe.appendChild(Me);var Se=gt.createElement("clipPath",[["id","text-bg-clip"]]);Me.appendChild(Se);var vt=gt.createPath(gt.getHollowRectanglePath((24-Q)/2,(24-H)/2,Q,H,(24-Q)/2+2,(24-H)/2+2,Q-4,H-4));fe.appendChild(vt);var Ne=gt.createText([["x","0"],["y","0"],["font-size","7px"],["font-family","monospace"]]);Ne.appendChild(gt.createTSpan(s+":"+m)),fe.appendChild(Ne);var _t=Ne.getBBox();gt.setAttributes(Ne,[["x",((24-_t.width)/2).toString()],["y",((24-_t.height)/2-_t.y).toString()]]);var Ut=gt.createPath(gt.getHollowRectanglePath(0,0,24,24,(24-Math.ceil(_t.width))/2,(24-Math.ceil(_t.height))/2,Math.ceil(_t.width),Math.ceil(_t.height)));return Se.appendChild(Ut),gt.setAttributes(vt,[["clip-path","url(#text-bg-clip)"]]),document.body.removeChild(fe),fe.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>'},z}(),Nt=function(z){function s(m,W,Q){var H=z.call(this,m,W)||this;return H.isDropdownOpen=!1,H.onClick=H.dropdownButtonClicked,H.dropdownButtons=Q,H}return Lt(s,z),s.prototype.setupDropdown=function(){var m=this;this.dropdownBlock=document.createElement("div"),this.dropdownBlock.className=this.dropdownClassName+" "+this.dropdownColorsClassName,this.dropdownBlock.style.display="none",this.dropdownButtons.forEach(function(W){W.className=m.className,W.colorsClassName=m.colorsClassName,m.dropdownBlock.appendChild(W.getUI())}),this.uiContainer.appendChild(this.dropdownBlock)},s.prototype.positionDropdown=function(){this.dropdownBlock.style.left=this.uiContainer.clientLeft+"px",this.dropdownBlock.style.top=this.uiContainer.clientTop+this.uiContainer.clientHeight+"px"},s.prototype.dropdownButtonClicked=function(){this.dropdownBlock===void 0&&this.setupDropdown(),this.isDropdownOpen=!this.isDropdownOpen,this.toggleDropdown()},s.prototype.toggleDropdown=function(){this.positionDropdown(),this.dropdownBlock.style.display=this.isDropdownOpen?"inline-block":"none"},s.prototype.showDropdown=function(){this.isDropdownOpen=!0,this.toggleDropdown()},s.prototype.hideDropdown=function(){this.isDropdownOpen=!1,this.toggleDropdown()},s}(ct),Ot=function(){function z(s,m){this.GRIP_SIZE=10,this.color=s,this.fillColor=m,this.visual=gt.createGroup(),this.visual.appendChild(gt.createCircle(1.5*this.GRIP_SIZE,[["fill","transparent"]])),this.visual.appendChild(gt.createCircle(this.GRIP_SIZE,[["fill",this.fillColor],["fill-opacity","0.9"],["stroke",this.color],["stroke-width","2"],["stroke-opacity","0.7"]]))}return z.prototype.ownsTarget=function(s){return s===this.visual||s===this.visual.childNodes[0]||s===this.visual.childNodes[1]},z.prototype.setCenter=function(s,m){this.visual.childNodes.forEach(function(W){return gt.setAttributes(W,[["cx",s.toString()],["cy",m.toString()]])})},z}(),zt=function(){function z(s,m,W,Q){this.isMoving=!1,this._isGridVisible=!0,this.numberOfGridLines=2,this.horizontalGridLines=[],this.verticalGridLines=[],this._zoomFactor=1,this.cropRectChanged=!1,this.canvasWidth=s,this.canvasHeight=m,this.margin=W,this.container=Q,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(z.prototype,"aspectRatio",{get:function(){return this._aspectRatio},set:function(s){this._aspectRatio=s,this.adjustCropRect(),this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.gridContainer&&gt.setAttributes(this.gridContainer,[["display",this._isGridVisible?"":"none"]])},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomFactor",{get:function(){return this._zoomFactor},set:function(s){this._zoomFactor=s,this.setCropRectangle(this.cropRect)},enumerable:!1,configurable:!0}),z.prototype.open=function(){var s=this;this.cropShadeElement=gt.createPath("M0,0Z",[["fill",this.cropShadeColor],["fill-opacity","0.8"]]),this.container.appendChild(this.cropShadeElement),this.gridContainer=gt.createGroup([["display",this.isGridVisible?"":"none"]]),this.container.appendChild(this.gridContainer);for(var m=0;m<this.numberOfGridLines;m++)this.horizontalGridLines.push(gt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]])),this.verticalGridLines.push(gt.createLine(0,0,0,0,[["stroke",this.cropFrameColor],["stroke-width","1"],["stroke-dasharray","3 1"],["opacity","0.7"]]));this.horizontalGridLines.forEach(function(W){return s.gridContainer.appendChild(W)}),this.verticalGridLines.forEach(function(W){return s.gridContainer.appendChild(W)}),this.cropRectElement=gt.createRect(0,0,[["stroke",this.cropFrameColor],["stroke-width","3"],["fill","transparent"]]),this.container.appendChild(this.cropRectElement),this.topLeftGrip=new Ot(this.gripColor,this.gripFillColor),this.container.appendChild(this.topLeftGrip.visual),this.topRightGrip=new Ot(this.gripColor,this.gripFillColor),this.container.appendChild(this.topRightGrip.visual),this.bottomLeftGrip=new Ot(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomLeftGrip.visual),this.bottomRightGrip=new Ot(this.gripColor,this.gripFillColor),this.container.appendChild(this.bottomRightGrip.visual),this.attachEvents()},z.prototype.setCropRectangle=function(s){this.cropRect=s;var m=Object.assign({},this.cropRect);this.zoomFactor!==1&&(m.width=this.cropRect.width*this.zoomFactor,m.height=this.cropRect.height*this.zoomFactor,m.x=this.cropRect.height/this.cropRect.width<this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasWidth/2-m.width/2,m.y=this.cropRect.height/this.cropRect.width>this.canvasHeight/this.canvasWidth?this.margin:this.margin+this.canvasHeight/2-m.height/2),gt.setAttributes(this.cropRectElement,[["x",m.x.toString()],["y",m.y.toString()],["width",m.width.toString()],["height",m.height.toString()]]);var W=m.height/(this.numberOfGridLines+1);this.horizontalGridLines.forEach(function(H,fe){var Me=m.y+W*(fe+1);gt.setAttributes(H,[["x1",""+m.x],["y1",""+Me],["x2",""+(m.x+m.width)],["y2",""+Me]])});var Q=m.width/(this.numberOfGridLines+1);this.verticalGridLines.forEach(function(H,fe){var Me=m.x+Q*(fe+1);gt.setAttributes(H,[["x1",""+Me],["y1",""+m.y],["x2",""+Me],["y2",""+(m.y+m.height)]])}),gt.setAttributes(this.cropShadeElement,[["d",gt.getHollowRectanglePath(0,0,this.canvasWidth+2*this.margin,this.canvasHeight+2*this.margin,m.x,m.y,m.width,m.height)]]),this.topLeftGrip.setCenter(m.x,m.y),this.topRightGrip.setCenter(m.x+m.width,m.y),this.bottomLeftGrip.setCenter(m.x,m.y+m.height),this.bottomRightGrip.setCenter(m.x+m.width,m.y+m.height),this.cropRectChanged&&this.onCropChange&&(this.cropRectChanged=!1,this.onCropChange(this.cropRect)),this.cropRectChanged=!1},z.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)},z.prototype.clientToLocalCoordinates=function(s,m){var W=this.container.getBoundingClientRect();return{x:s-W.left+this.margin,y:m-W.top+this.margin}},z.prototype.onPointerDown=function(s){this.container.setPointerCapture(s.pointerId),this.previousPoint=this.clientToLocalCoordinates(s.clientX,s.clientY),this.cropRectElement===s.target?this.isMoving=!0:this.topLeftGrip.ownsTarget(s.target)?this.activeGrip=this.topLeftGrip:this.bottomLeftGrip.ownsTarget(s.target)?this.activeGrip=this.bottomLeftGrip:this.topRightGrip.ownsTarget(s.target)?this.activeGrip=this.topRightGrip:this.bottomRightGrip.ownsTarget(s.target)&&(this.activeGrip=this.bottomRightGrip)},z.prototype.onPointerMove=function(s){if(this.isMoving)this.move(this.clientToLocalCoordinates(s.clientX,s.clientY));else if(this.activeGrip){var m=this.clientToLocalCoordinates(s.clientX,s.clientY);this.resize(m)}s.preventDefault()},z.prototype.onPointerUp=function(s){this.activeGrip=void 0,this.isMoving=!1,this.container.releasePointerCapture(s.pointerId)},z.prototype.move=function(s){var m=s.x-this.previousPoint.x,W=s.y-this.previousPoint.y;this.zoomFactor!==1&&(m=-m/this.zoomFactor,W=-W/this.zoomFactor),this.cropRect.x=Math.min(Math.max(this.margin,this.cropRect.x+m),this.canvasWidth-this.cropRect.width+this.margin),this.cropRect.y=Math.min(Math.max(this.margin,this.cropRect.y+W),this.canvasHeight-this.cropRect.height+this.margin),this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect),this.previousPoint=s},z.prototype.resize=function(s){var m=Object.assign({},this.cropRect),W=s.x-this.previousPoint.x,Q=s.y-this.previousPoint.y;switch(this.activeGrip){case this.bottomLeftGrip:case this.topLeftGrip:m.x+W<this.margin&&(W=this.margin-m.x),m.x+=W,m.width=this.cropRect.x+this.cropRect.width-m.x;break;case this.bottomRightGrip:case this.topRightGrip:m.width+W>this.canvasWidth*this.zoomFactor&&(W=this.canvasWidth*this.zoomFactor-m.width),m.width+=W}switch(this.activeGrip){case this.topLeftGrip:case this.topRightGrip:this.aspectRatio?(m.y=this.cropRect.y-(this.activeGrip===this.topLeftGrip?-1:1)*this.aspectRatio.getVerticalLength(W),m.height=this.aspectRatio.getVerticalLength(m.width)):(m.y+=Q,m.height=this.cropRect.y+this.cropRect.height-m.y);break;case this.bottomLeftGrip:case this.bottomRightGrip:this.aspectRatio?m.height=this.aspectRatio.getVerticalLength(m.width):m.height+=Q}m.width<10&&(m.x=this.cropRect.x,m.width=10),m.height<10&&(m.y=this.cropRect.y,m.height=10),this.previousPoint=s,m.x>=this.margin&&m.y>=this.margin&&m.x-this.margin+m.width<=this.canvasWidth&&m.y-this.margin+m.height<=this.canvasHeight&&(this.cropRect=m,this.onCropChange?(this.cropRectChanged=!0,this.onCropChange(this.cropRect)):this.setCropRectangle(this.cropRect))},z.prototype.adjustCropRect=function(){if(this.aspectRatio&&Math.round(this.cropRect.height)!==Math.round(this.aspectRatio.getVerticalLength(this.cropRect.width))){var s=this.cropRect.x+this.cropRect.width/2,m=this.cropRect.y+this.cropRect.height/2,W=this.aspectRatio.getHorizontalLength(this.cropRect.height),Q=this.aspectRatio.getVerticalLength(this.cropRect.width);W/this.canvasWidth<Q/this.canvasHeight?this.cropRect.width=W:this.cropRect.height=Q,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=s-this.cropRect.width/2,this.cropRect.y=m-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)}},z.prototype.getRescaledRect=function(s,m,W,Q,H,fe){var Me=W/s,Se=Q/m;return{x:(H.x-fe)*Me+fe,y:(H.y-fe)*Se+fe,width:H.width*Me,height:H.height*Se}},z.prototype.scaleCanvas=function(s,m){var W=this.getRescaledRect(this.canvasWidth,this.canvasHeight,s,m,this.cropRect,this.margin);this.canvasWidth=s,this.canvasHeight=m,this.onCropChange&&this.onCropChange(W),this.setCropRectangle(W)},z}(),Rr=function(){function z(s){this._angle=0,this.isDragging=!1,this.width=401,this.height=24,this.title=s,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(z.prototype,"angle",{get:function(){return this._angle},set:function(s){this._angle=s,this.setAngleLabel(),this.positionScaleShape()},enumerable:!1,configurable:!0}),z.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},z.prototype.onPointerDown=function(s){this.controlContainer.setPointerCapture(s.pointerId),this.isDragging=!0,this.previousPoint={x:s.clientX,y:s.clientY}},z.prototype.onPointerMove=function(s){this.isDragging&&(this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.previousPoint.x=s.clientX)},z.prototype.onPointerUp=function(s){this.isDragging&&this.onAngleChange&&this.onAngleChange((s.clientX-this.previousPoint.x)/5),this.isDragging=!1,this.controlContainer.releasePointerCapture(s.pointerId)},z.prototype.setAngleLabel=function(){if(this.angleLabelText){this.angleLabelText.innerHTML=""+Math.round(this._angle);var s=this.angleLabelText.getBBox();gt.setAttributes(this.angleLabelElement,[["x",((this.width-s.width)/2).toString()],["y",(this.height/2).toString()]])}},z.prototype.positionScaleShape=function(){if(this.scaleShape){var s=this.scaleShape.transform.baseVal.getItem(0);s.setTranslate(this._angle%5*5-25,0),this.scaleShape.transform.baseVal.replaceItem(s,0)}},z.prototype.getVisual=function(){var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width",this.width+"px"),s.setAttribute("height",this.height+"px"),s.setAttribute("viewBox","0 0 "+this.width+" "+this.height),s.style.flexShrink="0",document.body.appendChild(s);for(var m="M0,"+(this.height-1)+" v"+-this.height/3+"h1v"+this.height/3,W=1;W<=this.width/5+10;W++){var Q=W%5==0?this.height/3:this.height/6;m+="h4v"+-Q+"h1v"+Q}m+="v1H0Z",this.scaleShape=gt.createPath(m);var H=gt.createTransform();this.scaleShape.transform.baseVal.appendItem(H),s.appendChild(this.scaleShape),this.angleLabelElement=gt.createText([["x","0"],["y","0"],["font-size","10px"],["font-family","monospace"]]),this.angleLabelText=gt.createTSpan(""),this.angleLabelElement.appendChild(this.angleLabelText);var fe=gt.createTSpan("");return fe.innerHTML="&deg;",this.angleLabelElement.appendChild(fe),s.appendChild(this.angleLabelElement),document.body.removeChild(s),s},z}(),gi=function(){function z(){this.naturalSize=!1,this.imageType="image/png"}return z.prototype.rasterize=function(s,m,W,Q,H,fe,Me){var Se=this;return new Promise(function(vt){var Ne=document.createElement("canvas");Ne.width=s.width.baseVal.value-2*Q,Ne.height=s.height.baseVal.value-2*Q;var _t=1,Ut=1;Se.naturalSize===!0?(_t=m.naturalWidth/(s.width.baseVal.value-2*Q)/fe,Ut=m.naturalHeight/(s.height.baseVal.value-2*Q)/Me,Ne.width=m.naturalWidth/fe,Ne.height=m.naturalHeight/Me):Se.width!==void 0&&Se.height!==void 0&&(_t=Se.width/W.width,Ut=Se.height/W.height,Ne.width*=_t,Ne.height*=Ut);var Kt=Ne.getContext("2d");Kt.translate(Ne.width/2,Ne.height/2),Kt.rotate(H*Math.PI/180),Kt.scale(fe,Me),Kt.translate(-Ne.width/2,-Ne.height/2),Kt.drawImage(m,0,0,Ne.width,Ne.height);var Gr=document.createElement("canvas");Gr.width=W.width*_t,Gr.height=W.height*Ut,Gr.getContext("2d").putImageData(Kt.getImageData((W.x-Q)*_t,(W.y-Q)*Ut,W.width*_t,W.height*Ut),0,0),vt(Gr.toDataURL(Se.imageType,Se.imageQuality))})},z}(),ze=function(){function z(s){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=z.instanceCounter++,this.styles=new ir(this.instanceNo),this.target=s,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(z.prototype,"instanceNo",{get:function(){return this._instanceNo},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"zoomToCropEnabled",{get:function(){return this._zoomToCropEnabled},set:function(s){this._zoomToCropEnabled=s,s?this.zoomToCrop():this.unzoomFromCrop()},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isGridVisible",{get:function(){return this._isGridVisible},set:function(s){this._isGridVisible=s,this.cropLayer&&(this.cropLayer.isGridVisible=this._isGridVisible)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"gridLines",{get:function(){return this._gridLines},set:function(s){this._gridLines=s,this.cropLayer&&(this.cropLayer.numberOfGridLines=this._gridLines)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"rotationAngle",{get:function(){return this._rotationAngle},set:function(s){this._rotationAngle=s,this.straightener&&(this.straightener.angle=this._rotationAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"paddedImageWidth",{get:function(){return this.imageWidth+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"paddedImageHeight",{get:function(){return this.imageHeight+2*this.CANVAS_MARGIN},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"isOpen",{get:function(){return this._isOpen},enumerable:!1,configurable:!0}),Object.defineProperty(z.prototype,"aspectRatio",{get:function(){var s;return(s=this._aspectRatio)!==null&&s!==void 0?s:this.aspectRatios[0]},set:function(s){this._aspectRatio=s},enumerable:!1,configurable:!0}),z.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},z.prototype.show=function(){this.showUI(),this.open()},z.prototype.close=function(s){s===void 0&&(s=!1),this.isOpen&&(this.coverDiv&&this.closeUI(),this.targetObserver&&this.targetObserver.unobserve(this.target),this.displayMode==="popup"&&window.removeEventListener("resize",this.setWindowHeight),s||this.closeEventListeners.forEach(function(m){return m()}),this._isOpen=!1)},z.prototype.addRenderEventListener=function(s){this.renderEventListeners.push(s)},z.prototype.removeRenderEventListener=function(s){this.renderEventListeners.indexOf(s)>-1&&this.renderEventListeners.splice(this.renderEventListeners.indexOf(s),1)},z.prototype.addCloseEventListener=function(s){this.closeEventListeners.push(s)},z.prototype.removeCloseEventListener=function(s){this.closeEventListeners.indexOf(s)>-1&&this.closeEventListeners.splice(this.closeEventListeners.indexOf(s),1)},z.prototype.setupResizeObserver=function(){var s=this;this.displayMode==="inline"?window.ResizeObserver&&(this.targetObserver=new ResizeObserver(function(){s.resize(s.target.clientWidth,s.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))},z.prototype.onPopupResize=function(){if(this.contentDiv.clientWidth>0&&this.contentDiv.clientHeight>0){var s=1*this.target.clientWidth/this.target.clientHeight,m=this.contentDiv.clientWidth/s>this.contentDiv.clientHeight?(this.contentDiv.clientHeight-2*this.CANVAS_MARGIN)*s:this.contentDiv.clientWidth-2*this.CANVAS_MARGIN,W=m+2*this.CANVAS_MARGIN<this.contentDiv.clientWidth?this.contentDiv.clientHeight-2*this.CANVAS_MARGIN:(this.contentDiv.clientWidth-2*this.CANVAS_MARGIN)/s;this.resize(m,W)}},z.prototype.setWindowHeight=function(){this.windowHeight=window.innerHeight},z.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",gt.setAttributes(this.editingTarget,[["width",""+this.imageWidth],["height",""+this.imageHeight]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px"},z.prototype.resize=function(s,m){this.imageWidth=Math.round(s),this.imageHeight=Math.round(m),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()},z.prototype.setEditingTarget=function(){var s=document.createElement("canvas");s.width=this.target.naturalWidth,s.height=this.target.naturalHeight,s.getContext("2d").drawImage(this.target,0,0,this.target.naturalWidth,this.target.naturalHeight);var m=s.toDataURL();gt.setAttributes(this.editingTarget,[["href",m]]),this.setEditingTargetSize()},z.prototype.setTopLeft=function(){var s=this.target.getBoundingClientRect(),m=this.editorCanvas.getBoundingClientRect();this.left=s.left-m.left-this.CANVAS_MARGIN,this.top=s.top-m.top-this.CANVAS_MARGIN},z.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=gt.createDefs(),this.cropImage.appendChild(this.defs),this.editingTarget=gt.createImage([["href",""]]),this.editingTarget.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationContainer=gt.createGroup(),this.editingTargetRotationScaleContainer=gt.createGroup(),this.editingTargetRotationScaleContainer.appendChild(this.editingTarget),this.editingTargetRotationContainer.appendChild(this.editingTargetRotationScaleContainer);var s=gt.createTransform();this.editingTargetRotationContainer.transform.baseVal.appendItem(s);var m=gt.createTransform();this.editingTargetRotationScaleContainer.transform.baseVal.appendItem(m),this.editingTargetContainer=gt.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)},z.prototype.positionCropImage=function(){this.cropImageHolder.style.top=this.top+"px",this.cropImageHolder.style.left=this.left+"px"},z.prototype.initCropLayer=function(){this.cropRect={x:this.CANVAS_MARGIN,y:this.CANVAS_MARGIN,width:this.imageWidth,height:this.imageHeight},this.cropLayerContainer=gt.createGroup(),this.cropImage.appendChild(this.cropLayerContainer),this.cropLayer=new zt(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()},z.prototype.zoomToCrop=function(){if(this.cropRect){var s=this.cropRect.x-this.CANVAS_MARGIN+this.cropRect.width/2,m=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=s+"px "+m+"px",this.editingTargetContainer.style.transform="translate("+(this.imageWidth/2-s+this.CANVAS_MARGIN)+"px,"+(this.imageHeight/2-m+this.CANVAS_MARGIN)+"px) scale("+this.zoomFactor+")",this.cropLayer.zoomFactor=this.zoomFactor)}},z.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)},z.prototype.cropRectChanged=function(s){this.cropRect=s,this.zoomToCropEnabled?this.zoomToCrop():this.cropLayer.zoomFactor=1},z.prototype.attachEvents=function(){window.addEventListener("resize",this.onWindowResize)},z.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"},z.prototype.restoreOverflow=function(){document.body.style.overflow=this.bodyOverflowState,window.scroll({top:this.scrollYState,left:this.scrollXState})},z.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 s=this.styles.settings.hideTopToolbar?0:this.toolbarHeight,m=this.target.offsetTop>s+this.CANVAS_MARGIN?this.target.offsetTop-(s+this.CANVAS_MARGIN):0;this.coverDiv.style.top=m+"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},z.prototype.addToolbars=function(){this.addTopToolbar(),this.addBottomToolbar()},z.prototype.addTopToolbar=function(){var s=this;this.topToolbar=new wr,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 m=new Ur;m.minWidth=3*this.toolbarHeight+"px",this.topToolbar.addButtonBlock(m);var W=[];this.aspectRatios.forEach(function(Ut){var Kt=new ct(jt.getIcon(Ut.horizontal,Ut.vertical),Ut.horizontal===0&&Ut.vertical===0?"FREE":Ut.horizontal+":"+Ut.vertical);Kt.onClick=function(){return s.ratioButtonClicked(Ut)},W.push(Kt)}),this.aspectRatioButton=new Nt(jt.getIcon(0,0),"Aspect ratio",W),this.aspectRatioButton.dropdownClassName=this.toolbarDropdownStyleClass.name,this.aspectRatioButton.dropdownColorsClassName=this.styles.settings.toolbarDropdownStyleColorsClassName?this.styles.settings.toolbarDropdownStyleColorsClassName:this.toolbarDropdownStyleColorsClass.name,m.addButton(this.aspectRatioButton),this.aspectRatios.length<2&&this.aspectRatioButton.hide();var Q=new ct('<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");Q.isActive=this.isGridVisible,Q.onClick=function(){s.isGridVisible=!s.isGridVisible,Q.isActive=s.isGridVisible},m.addButton(Q);var H=new ct('<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(H.isActive=this.zoomToCropEnabled,H.onClick=function(){s.zoomToCropEnabled=!s.zoomToCropEnabled,H.isActive=s.zoomToCropEnabled},m.addButton(H),!Xt.isLicensed){var fe=new ut;this.topToolbar.addElementBlock(fe);var Me=document.createElement("div");Me.className=this.topToolbar.buttonClassName+" "+this.topToolbar.buttonColorsClassName;var Se=document.createElement("a");Se.style.color="currentColor",Se.href="https://markerjs.com/products/cropro",Se.target="_blank",Se.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>',Me.appendChild(Se),fe.addElement(Me)}var vt=new Ur;vt.minWidth=3*this.toolbarHeight+"px",vt.contentAlign="end",this.topToolbar.addButtonBlock(vt);var Ne=new ct('<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");Ne.onClick=this.startRenderAndClose,vt.addButton(Ne),this.styles.settings.toolbarOkButtonStyleColorsClassName&&(Ne.colorsClassName=this.styles.settings.toolbarOkButtonStyleColorsClassName);var _t=new ct('<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");_t.onClick=this.close,vt.addButton(_t),this.styles.settings.toolbarCloseButtonStyleColorsClassName&&(_t.colorsClassName=this.styles.settings.toolbarCloseButtonStyleColorsClassName)},z.prototype.addBottomToolbar=function(){var s=this;this.bottomToolbar=new wr,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 m=new Ur;m.minWidth=2*this.toolbarHeight+"px",this.bottomToolbar.addButtonBlock(m);var W=new ct('<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");W.onClick=this.rotateLeftButtonClicked,m.addButton(W);var Q=new ct('<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");Q.onClick=this.rotateRightButtonClicked,m.addButton(Q);var H=new ut;H.className=this.toolbarStraightenerBlockStyleClass.name,this.bottomToolbar.addElementBlock(H),this.straightener=new Rr("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(vt){s.rotateBy(vt),s.straightener.angle=s.rotationAngle},H.addElement(this.straightener.getUI());var fe=new Ur;fe.minWidth=2*this.toolbarHeight+"px",fe.contentAlign="end",this.bottomToolbar.addButtonBlock(fe);var Me=new ct('<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");Me.onClick=this.flipHorizontallyButtonClicked,fe.addButton(Me);var Se=new ct('<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");Se.onClick=this.flipVerticallyButtonClicked,fe.addButton(Se)},z.prototype.ratioButtonClicked=function(s){this.aspectRatio=s,this.applyAspectRatio(),this.aspectRatioButton.hideDropdown()},z.prototype.applyAspectRatio=function(){this.setCropLayerAspectRatio(),this.aspectRatioButton.icon=jt.getIcon(this.aspectRatio.horizontal,this.aspectRatio.vertical)},z.prototype.setCropLayerAspectRatio=function(){this.cropLayer&&(this.aspectRatio&&this.aspectRatio.horizontal!==0&&this.aspectRatio.vertical!==0?this.cropLayer.aspectRatio=new qt(this.aspectRatio.horizontal,this.aspectRatio.vertical):this.cropLayer.aspectRatio=void 0)},z.prototype.closeUI=function(){this.displayMode==="popup"&&this.restoreOverflow(),this.targetRoot.removeChild(this.coverDiv)},z.prototype.getState=function(){return{width:this.imageWidth,height:this.imageHeight,rotationAngle:this.rotationAngle,flippedHorizontally:this.flippedHorizontally,flippedVertically:this.flippedVertically,cropRect:Object.assign({},this.cropRect)}},z.prototype.restoreState=function(s){if(s){var m=this.cropLayer.getRescaledRect(s.width,s.height,this.imageWidth,this.imageHeight,s.cropRect,this.CANVAS_MARGIN);this.cropLayer.setCropRectangle(m),this.cropRectChanged(m),this.flippedHorizontally=s.flippedHorizontally,this.flippedVertically=s.flippedVertically,this.applyFlip(),this.rotationAngle=s.rotationAngle,this.applyRotation()}},z.prototype.clientToLocalCoordinates=function(s,m){var W=this.cropImage.getBoundingClientRect();return{x:s-W.left,y:m-W.top}},z.prototype.onWindowResize=function(){this.positionUI()},z.prototype.positionUI=function(){switch(this.setTopLeft(),this.displayMode){case"inline":var s=this.target.offsetTop>this.toolbarHeight?this.target.offsetTop-this.toolbarHeight:0;this.coverDiv.style.top=s+"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()},z.prototype.rotateLeftButtonClicked=function(){var s=this.rotationAngle-90;this.rotationAngle%90!=0&&(s+=this.rotationAngle>=0?90-this.rotationAngle%90:-this.rotationAngle%90),this.rotateTo(s)},z.prototype.rotateRightButtonClicked=function(){var s=this.rotationAngle+90;this.rotationAngle%90!=0&&(s-=this.rotationAngle>=0?this.rotationAngle%90:90+this.rotationAngle%90),this.rotateTo(s)},z.prototype.rotateTo=function(s){s=(s=s>180?s-360:s)<=-180?s+360:s,this.rotationAngle=s,this.applyRotation()},z.prototype.rotateBy=function(s){this.rotateTo((this.rotationAngle+s)%360)},z.prototype.applyRotation=function(){var s=this.zoomToCropEnabled;this.zoomToCropEnabled=!1,this.editingTargetRotationScaleContainer.style.transformOrigin=this.imageWidth/2+"px "+this.imageHeight/2+"px",this.editingTargetRotationScaleContainer.style.transform="scale(1)";var m=this.editingTargetRotationContainer.transform.baseVal.getItem(0);m.setRotate(this.rotationAngle,this.imageWidth/2,this.imageHeight/2),this.editingTargetRotationContainer.transform.baseVal.replaceItem(m,0);var W=this.editingTarget.getBoundingClientRect();this.scaleFactor=Math.min(this.imageWidth/W.width,this.imageHeight/W.height),this.editingTargetRotationScaleContainer.style.transform="scale("+this.scaleFactor+")",this.zoomToCropEnabled=s},z.prototype.flipHorizontallyButtonClicked=function(){this.flippedHorizontally=!this.flippedHorizontally,this.applyFlip()},z.prototype.flipVerticallyButtonClicked=function(){this.flippedVertically=!this.flippedVertically,this.applyFlip()},z.prototype.applyFlip=function(){this.editingTarget.style.transform="scale("+(this.flippedHorizontally?-1:1)+","+(this.flippedVertically?-1:1)+")"},z.prototype.startRenderAndClose=function(){return Et(this,void 0,void 0,function(){var s,m;return sr(this,function(W){switch(W.label){case 0:return[4,this.render()];case 1:return s=W.sent(),m=this.getState(),this.renderEventListeners.forEach(function(Q){return Q(s,m)}),this.close(!0),[2]}})})},z.prototype.render=function(){return Et(this,void 0,void 0,function(){var s;return sr(this,function(m){switch(m.label){case 0:return(s=new gi).naturalSize=this.renderAtNaturalSize,s.imageType=this.renderImageType,s.imageQuality=this.renderImageQuality,s.width=this.renderWidth,s.height=this.renderHeight,this.unzoomFromCrop(),gt.setAttributes(this.cropLayerContainer,[["display","none"]]),[4,s.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 m.sent(),[4,s.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,m.sent()]}})})},z.prototype.addStyles=function(){this.toolbarStyleClass=this.styles.addClass(new lr("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 lr("toolbar_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarBlockStyleClass=this.styles.addClass(new lr("toolbar-block",`
display: flex;
align-items: center;
box-sizing: content-box;
`));var s=this.toolbarHeight/4;this.toolbarButtonStyleClass=this.styles.addClass(new lr("toolbar_button",`
display: inline-block;
width: `+(this.toolbarHeight-2*s)+`px;
height: `+(this.toolbarHeight-2*s)+`px;
padding: `+s+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarButtonStyleColorsClass=this.styles.addClass(new lr("toolbar_button_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`)),this.toolbarActiveButtonStyleColorsClass=this.styles.addClass(new lr("toolbar_active_button",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
background-color: `+this.styles.settings.toolbarBackgroundActiveColor+`
`)),this.styles.addRule(new pr("."+this.toolbarButtonStyleClass.name+" svg",`
height: `+this.toolbarHeight/2+`px;
`)),this.styles.addRule(new pr("."+this.toolbarButtonStyleColorsClass.name+":hover",`
background-color: `+this.styles.settings.toolbarBackgroundHoverColor+`
`)),this.toolbarDropdownStyleClass=this.styles.addClass(new lr("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 lr("toolbar_dropdown_colors",`
background-color: `+this.styles.settings.toolbarBackgroundColor+`;
`)),this.toolbarStraightenerBlockStyleClass=this.styles.addClass(new lr("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 lr("toolbar_straightener",`
display: flex;
overflow: hidden;
justify-content: center;
height: `+(this.toolbarHeight-2*s)+`px;
padding: `+s+`px;
cursor: default;
user-select: none;
box-sizing: content-box;
`)),this.toolbarStraightenerStyleColorsClass=this.styles.addClass(new lr("toolbar_straightener_colors",`
color: `+this.styles.settings.toolbarColor+`;
fill: currentColor;
`))},z.instanceCounter=0,z}(),At=re("8hTe"),ii=re.n(At),di=/<pre[^>]*>/g;function hi(z){var s=document.createElement("div");return s.innerHTML=z,s.childNodes.length===0?"":s.childNodes[0].nodeValue}var Ri=ot.a=function(z){var s=z.value,m=s===void 0?"":s,W=z.edit,Q=W===void 0?!1:W,H=z.className,fe=z.showTextOnly,Me=z.showLines,Se=z.replaces,vt=z.zoomImg,Ne=z.hasMask,_t=z.style,Ut=_t===void 0?{}:_t,Kt=z.stylesPrev,Gr=Kt===void 0?{}:Kt,Kr=String(m),mr=Object(k.useRef)(),Qr=Object(k.useRef)(),Ki=Object(k.useState)(""),kr=Object(B.a)(Ki,2),Or=kr[0],ni=kr[1],vi=Object(k.useState)("office"),Zr=Object(B.a)(vi,2),ai=Zr[0],Vr=Zr[1],fn=function(){var Wt=new ze(Qr.current);Wt.displayMode="popup",Wt.addRenderEventListener(function(){var Er=Object(w.a)(M.a.mark(function Ht(Sr){var Jt;return M.a.wrap(function(hr){for(;;)switch(hr.prev=hr.next){case 0:return mr.current.style.display="none",hr.next=3,Object(_e.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Sr}});case 3:Jt=hr.sent,Jt!=null&&Jt.id&&Se(Qr.current.getAttribute("src").replace(oe.a.API_SERVER,""),"/api/attachments/".concat(Jt==null?void 0:Jt.id,"?type=").concat(Jt.content_type));case 5:case"end":return hr.stop()}},Ht)}));return function(Ht){return Er.apply(this,arguments)}}()),Wt.show()},Vi=function(){var Wt=new yt(Qr.current);Wt.settings.displayMode="popup",Wt.addEventListener("render",function(){var Er=Object(w.a)(M.a.mark(function Ht(Sr){var Jt;return M.a.wrap(function(hr){for(;;)switch(hr.prev=hr.next){case 0:if(mr.current.style.display="none",!Qr.current){hr.next=6;break}return hr.next=4,Object(_e.a)("/api/attachments.json",{method:"post",body:{file_type:"base64",original_filename:"educoder.png",file:Sr.dataUrl}});case 4:Jt=hr.sent,Jt!=null&&Jt.id&&Se(Qr.current.getAttribute("src").replace(oe.a.API_SERVER,""),"/api/attachments/".concat(Jt==null?void 0:Jt.id,"?type=").concat(Jt.content_type));case 6:case"end":return hr.stop()}},Ht)}));return function(Ht){return Er.apply(this,arguments)}}()),Wt.show(),window.markerArea=Wt},Fr=Object(k.useMemo)(function(){try{var ar=/\(\s+\/api\/attachments\/|\(\/api\/attachments\/|\(\/attachments\/download\//g,Wt=/\"\/api\/attachments\/|\"\/attachments\/download\//g,Er=/\(\s+\/files\/uploads\/|\"\/files\/uploads\//g;Kr=Kr.replace(ar,"("+oe.a.API_SERVER+"/api/attachments/").replace(Wt,'"'+oe.a.API_SERVER+"/api/attachments/").replace(Er,'"'+oe.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,`
`),Kr=Kr.replace(new RegExp("(?<!\\n)\\n(?!\\n)","g"),`
`)}catch(yi){}var Ht=J(Kr),Sr=C();if(Kr.match(/\[TOC\]/)&&(Ht=Ht.replace("<p>[TOC]</p>",R()),_()),Ht=Ht.replace(/(__special_katext_id_\d+__)/g,function(yi,hr){var cr=Sr[hr],oi=cr.type,bi=cr.expression;return Object(he.renderToString)(hi(bi)||"",{displayMode:oi==="block",throwOnError:!1,output:"html"})}),Ht=Ht.replace(/▁/g,"\u2581\u2581\u2581"),E(),fe){var Jt=document.createElement("div");return Jt.innerHTML=Ht,Jt.innerText}return setTimeout(function(){return Oi()},500),Ht},[Kr]),jr=Object(k.useRef)();f.WebkitLineClamp=Me,Me&&(Ut=Object(I.a)(Object(I.a)({},Ut),f));function ki(ar){var Wt=ar.target;if(Wt.tagName.toUpperCase()==="IMG"){if(vt){var Er=Wt.getAttribute("src");ni(Er),Vr("image")}}else if(Wt.tagName.toUpperCase()==="A"){var Ht=Wt.getAttribute("href");if(Ht.indexOf("office")>-1)ar.preventDefault(),ni(Ht),Vr("office");else if(Ht.indexOf("application/pdf")>-1)ar.preventDefault(),ni(Ht),Vr("pdf");else if(Ht.indexOf("type=text")>-1)ar.preventDefault(),ni(Ht),Vr("html");else if(Ht.startsWith("#")){ar.preventDefault();var Sr=document.getElementById(Ht.replace("#",""));Sr&&Sr.scrollIntoView(!0)}}}var Oi=function(){var Wt,Er=(Wt=jr.current)===null||Wt===void 0?void 0:Wt.querySelectorAll("video");Er==null||Er.forEach(function(Ht){if(Ht.oncontextmenu=function(){return!1},Ht.src.indexOf(".m3u8")>-1&&!Ht.canPlayType("application/vnd.apple.mpegurl")){if(ee.a.isSupported()){var Sr=new ee.a;Sr.loadSource(Ht.src),Sr.attachMedia(Ht)}}})};Object(k.useEffect)(function(){if(jr.current&&Fr&&(Fr.match(di)&&window.PR.prettyPrint()),jr.current)return jr.current.addEventListener("click",ki),function(){jr.current.removeEventListener("click",ki),E(),_()}},[Fr,jr.current,ki]);var Mi=function(Wt){if(!Q)return;Wt.target.nodeName==="IMG"?(mr.current.style.display="flex",mr.current.style.width=Wt.target.clientWidth+"px",mr.current.style.height=Wt.target.clientHeight+"px",mr.current.style.top=Wt.target.offsetTop+"px",mr.current.style.left=Wt.target.offsetLeft+"px",Qr.current.src=Wt.target.getAttribute("src")):mr.current.style.display="none"};return p.a.createElement("div",{style:{position:"relative"}},p.a.createElement("div",{ref:jr,style:Object(I.a)({},Ut),className:"".concat(H||""," markdown-body ").concat(ii.a.mdBody),onMouseOver:Mi,dangerouslySetInnerHTML:{__html:Fr}}),p.a.createElement("div",{ref:mr,className:ii.a.button},p.a.createElement(Y.a,null,p.a.createElement(V.a,{onClick:function(){return fn()}},"\u88C1\u526A"),p.a.createElement(V.a,{onClick:function(){return Vi()}},"\u7F16\u8F91"))),p.a.createElement("img",{ref:Qr,src:"",alt:"sample",crossOrigin:"anonymous",style:{maxWidth:"90%",opacity:0,position:"absolute",zIndex:-1,top:"-10000px"}}),p.a.createElement(ge.a,{close:!0,data:Or,hasMask:Ne,type:Or!=null&&Or.length?ai:"",style:Object(I.a)({},Gr),onClose:function(){return ni("")}}))}},"9VGf":function(ht,ot,re){"use strict";re.d(ot,"a",function(){return D});var ie=re("q1tI"),Y=re.n(ie);function D(V,I){var w=Object(ie.useRef)();Object(ie.useEffect)(function(){w.current=V}),Object(ie.useEffect)(function(){function B(){w.current()}if(I!==null){var N=setInterval(B,I);return function(){return clearInterval(N)}}},[I])}},BU3w:function(ht,ot,re){"use strict";re.d(ot,"a",function(){return w});var ie=re("MNnm"),Y="rc-util-key";function D(B){if(B.attachTo)return B.attachTo;var N=document.querySelector("head");return N||document.body}function V(B){var N,M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Object(ie.a)())return null;var k=document.createElement("style");if((N=M.csp)===null||N===void 0?void 0:N.nonce){var p;k.nonce=(p=M.csp)===null||p===void 0?void 0:p.nonce}k.innerHTML=B;var y=D(M),P=y.firstChild;return M.prepend&&y.prepend?y.prepend(k):M.prepend&&P?y.insertBefore(k,P):y.appendChild(k),k}var I=new Map;function w(B,N){var M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},k=D(M);if(!I.has(k)){var p=V("",M),y=p.parentNode;I.set(k,y),y.removeChild(p)}var P=Array.from(I.get(k).children).find(function(a){return a.tagName==="STYLE"&&a[Y]===N});if(P){var L,x;if(((L=M.csp)===null||L===void 0?void 0:L.nonce)&&P.nonce!==((x=M.csp)===null||x===void 0?void 0:x.nonce)){var S;P.nonce=(S=M.csp)===null||S===void 0?void 0:S.nonce}return P.innerHTML!==B&&(P.innerHTML=B),P}var d=V(B,M);return d[Y]=N,d}},Bd2K:function(ht,ot,re){(function(ie){ie(re("VrN/"),re("osHv"))})(function(ie){ie.defineOption("autoCloseTags",!1,function(M,k,p){if(p!=ie.Init&&p&&M.removeKeyMap("autoCloseTags"),!k)return;var y={name:"autoCloseTags"};(typeof k!="object"||k.whenClosing!==!1)&&(y["'/'"]=function(P){return w(P)}),(typeof k!="object"||k.whenOpening!==!1)&&(y["'>'"]=function(P){return V(P)}),M.addKeyMap(y)});var Y=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],D=["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 V(M){if(M.getOption("disableInput"))return ie.Pass;for(var k=M.listSelections(),p=[],y=M.getOption("autoCloseTags"),P=0;P<k.length;P++){if(!k[P].empty())return ie.Pass;var L=k[P].head,x=M.getTokenAt(L),S=ie.innerMode(M.getMode(),x.state),d=S.state,a=S.mode.xmlCurrentTag&&S.mode.xmlCurrentTag(d),l=a&&a.name;if(!l)return ie.Pass;var h=S.mode.configuration=="html",_=typeof y=="object"&&y.dontCloseTags||h&&Y,f=typeof y=="object"&&y.indentTags||h&&D;x.end>L.ch&&(l=l.slice(0,l.length-x.end+L.ch));var b=l.toLowerCase();if(!l||x.type=="string"&&(x.end!=L.ch||!/[\"\']/.test(x.string.charAt(x.string.length-1))||x.string.length==1)||x.type=="tag"&&a.close||x.string.indexOf("/")==L.ch-x.start-1||_&&B(_,b)>-1||N(M,S.mode.xmlCurrentContext&&S.mode.xmlCurrentContext(d)||[],l,L,!0))return ie.Pass;var R=typeof y=="object"&&y.emptyTags;if(R&&B(R,l)>-1){p[P]={text:"/>",newPos:ie.Pos(L.line,L.ch+2)};continue}var T=f&&B(f,b)>-1;p[P]={indent:T,text:">"+(T?`
`:"")+"</"+l+">",newPos:T?ie.Pos(L.line+1,0):ie.Pos(L.line,L.ch+1)}}for(var g=typeof y=="object"&&y.dontIndentOnAutoClose,P=k.length-1;P>=0;P--){var c=p[P];M.replaceRange(c.text,k[P].head,k[P].anchor,"+insert");var u=M.listSelections().slice(0);u[P]={head:c.newPos,anchor:c.newPos},M.setSelections(u),!g&&c.indent&&(M.indentLine(c.newPos.line,null,!0),M.indentLine(c.newPos.line+1,null,!0))}}function I(M,k){for(var p=M.listSelections(),y=[],P=k?"/":"</",L=M.getOption("autoCloseTags"),x=typeof L=="object"&&L.dontIndentOnSlash,S=0;S<p.length;S++){if(!p[S].empty())return ie.Pass;var d=p[S].head,a=M.getTokenAt(d),l=ie.innerMode(M.getMode(),a.state),h=l.state;if(k&&(a.type=="string"||a.string.charAt(0)!="<"||a.start!=d.ch-1))return ie.Pass;var _,f=l.mode.name!="xml"&&M.getMode().name=="htmlmixed";if(f&&l.mode.name=="javascript")_=P+"script";else if(f&&l.mode.name=="css")_=P+"style";else{var b=l.mode.xmlCurrentContext&&l.mode.xmlCurrentContext(h);if(!b||b.length&&N(M,b,b[b.length-1],d))return ie.Pass;_=P+b[b.length-1]}M.getLine(d.line).charAt(a.end)!=">"&&(_+=">"),y[S]=_}if(M.replaceSelections(y),p=M.listSelections(),!x)for(var S=0;S<p.length;S++)(S==p.length-1||p[S].head.line<p[S+1].head.line)&&M.indentLine(p[S].head.line)}function w(M){return M.getOption("disableInput")?ie.Pass:I(M,!0)}ie.commands.closeTag=function(M){return I(M)};function B(M,k){if(M.indexOf)return M.indexOf(k);for(var p=0,y=M.length;p<y;++p)if(M[p]==k)return p;return-1}function N(M,k,p,y,P){if(!ie.scanForClosingTag)return!1;var L=Math.min(M.lastLine()+1,y.line+500),x=ie.scanForClosingTag(M,y,null,L);if(!x||x.tag!=p)return!1;for(var S=P?1:0,d=k.length-1;d>=0&&k[d]==p;d--)++S;y=x.to;for(var d=1;d<S;d++){var a=ie.scanForClosingTag(M,y,null,L);if(!a||a.tag!=p)return!1;y=a.to}return!0}})},BjJ7:function(ht,ot,re){"use strict";re.d(ot,"d",function(){return Y}),re.d(ot,"c",function(){return D}),re.d(ot,"e",function(){return V}),re.d(ot,"b",function(){return I}),re.d(ot,"a",function(){return B});var ie=re("m3rI");function Y(N){var M=!0;if(N.length>0){for(var k=0;k<N.length;k++)if(N[k].compile_success==0||!N[k].compile_success){M=!1;break}}else M=!1;return M}function D(N){for(var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",k=[],p=0;p<N.length;p++){var y=N[p],P=M?"".concat(M,"/").concat(y.name):"".concat(y.name);k.push({title:y.name,isLeaf:!(y.type==="tree"),key:P})}return k}function V(N,M,k){for(var p=0;p<N.length;p++){var y=N[p];if(y.key===M){y.children=k;break}y.children&&V(y.children,M,k)}return N}function I(N,M,k){var p;return function(){var y=this,P=arguments,L=function(){p=null,k||N.apply(y,P)},x=k&&!p;clearTimeout(p),p=setTimeout(L,M),x&&N.apply(y,P)}}var w=!0,B=ie.a.API_SERVER},"C+DQ":function(ht,ot,re){},D1Df:function(ht,ot,re){"use strict";function ie(v){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ie=function(j){return typeof j}:ie=function(j){return j&&typeof Symbol=="function"&&j.constructor===Symbol&&j!==Symbol.prototype?"symbol":typeof j},ie(v)}function Y(){return Y=Object.assign||function(v){for(var O=1;O<arguments.length;O++){var j=arguments[O];for(var G in j)Object.prototype.hasOwnProperty.call(j,G)&&(v[G]=j[G])}return v},Y.apply(this,arguments)}function D(v,O){var j=Object.keys(v);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(v);O&&(G=G.filter(function(J){return Object.getOwnPropertyDescriptor(v,J).enumerable})),j.push.apply(j,G)}return j}function V(v){for(var O=1;O<arguments.length;O++){var j=arguments[O]!=null?arguments[O]:{};O%2?D(j,!0).forEach(function(G){x(v,G,j[G])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(j)):D(j).forEach(function(G){Object.defineProperty(v,G,Object.getOwnPropertyDescriptor(j,G))})}return v}function I(v,O){if(v==null)return{};var j=w(v,O),G,J;if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(v);for(J=0;J<K.length;J++){if(G=K[J],O.indexOf(G)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(v,G))continue;j[G]=v[G]}}return j}function w(v,O){if(v==null)return{};var j={},G=Object.keys(v),J,K;for(K=0;K<G.length;K++){if(J=G[K],O.indexOf(J)>=0)continue;j[J]=v[J]}return j}function B(v,O){if(!(v instanceof O))throw new TypeError("Cannot call a class as a function")}function N(v,O){for(var j=0;j<O.length;j++){var G=O[j];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(v,G.key,G)}}function M(v,O,j){return O&&N(v.prototype,O),j&&N(v,j),v}function k(v,O){return O&&(ie(O)==="object"||typeof O=="function")?O:y(v)}function p(v){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(j){return j.__proto__||Object.getPrototypeOf(j)},p(v)}function y(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}function P(v,O){if(typeof O!="function"&&O!==null)throw new TypeError("Super expression must either be null or a function");v.prototype=Object.create(O&&O.prototype,{constructor:{value:v,writable:!0,configurable:!0}}),O&&L(v,O)}function L(v,O){return L=Object.setPrototypeOf||function(G,J){return G.__proto__=J,G},L(v,O)}function x(v,O,j){return O in v?Object.defineProperty(v,O,{value:j,enumerable:!0,configurable:!0,writable:!0}):v[O]=j,v}var S=re("q1tI"),d=re("17x9"),a=re("H38U"),l=re("aRTE");function h(v){for(var O="",j=0;j<v.length;j++){var G=v.charCodeAt(j);G<128?O+=String.fromCharCode(G):G<2048?(O+=String.fromCharCode(192|G>>6),O+=String.fromCharCode(128|G&63)):G<55296||G>=57344?(O+=String.fromCharCode(224|G>>12),O+=String.fromCharCode(128|G>>6&63),O+=String.fromCharCode(128|G&63)):(j++,G=65536+((G&1023)<<10|v.charCodeAt(j)&1023),O+=String.fromCharCode(240|G>>18),O+=String.fromCharCode(128|G>>12&63),O+=String.fromCharCode(128|G>>6&63),O+=String.fromCharCode(128|G&63))}return O}var _={size:128,level:"L",bgColor:"#FFFFFF",fgColor:"#000000",includeMargin:!1},f={},b=4,R=.1;function T(v){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,j=[];return v.forEach(function(G,J){var K=null;G.forEach(function(F,ee){if(!F&&K!==null){j.push("M".concat(K+O," ").concat(J+O,"h").concat(ee-K,"v1H").concat(K+O,"z")),K=null;return}if(ee===G.length-1){if(!F)return;K===null?j.push("M".concat(ee+O,",").concat(J+O," h1v1H").concat(ee+O,"z")):j.push("M".concat(K+O,",").concat(J+O," h").concat(ee+1-K,"v1H").concat(K+O,"z"));return}F&&K===null&&(K=ee)})}),j.join("")}function g(v,O){return v.slice().map(function(j,G){return G<O.y||G>=O.y+O.h?j:j.map(function(J,K){return K<O.x||K>=O.x+O.w?J:!1})})}function c(v,O){var j=v.imageSettings,G=v.size,J=v.includeMargin;if(j==null)return null;var K=J?b:0,F=O.length+K*2,ee=Math.floor(G*R),oe=F/G,he=(j.width||ee)*oe,ge=(j.height||ee)*oe,_e=j.x==null?O.length/2-he/2:j.x*oe,be=j.y==null?O.length/2-ge/2:j.y*oe,Ee=null;if(j.excavate){var Te=Math.floor(_e),Ce=Math.floor(be),me=Math.ceil(he+_e-Te),se=Math.ceil(ge+be-Ce);Ee={x:Te,y:Ce,w:me,h:se}}return{x:_e,y:be,h:ge,w:he,excavation:Ee}}var u=function(){try{new Path2D().addPath(new Path2D)}catch(v){return!1}return!0}(),o=function(v){P(O,v);function O(){var j,G;B(this,O);for(var J=arguments.length,K=new Array(J),F=0;F<J;F++)K[F]=arguments[F];return G=k(this,(j=p(O)).call.apply(j,[this].concat(K))),x(y(G),"_canvas",void 0),x(y(G),"_image",void 0),x(y(G),"state",{imgLoaded:!1}),x(y(G),"handleImageLoad",function(){G.setState({imgLoaded:!0})}),G}return M(O,[{key:"componentDidMount",value:function(){this.update()}},{key:"componentDidUpdate",value:function(){this.update()}},{key:"update",value:function(){var G=this.props,J=G.value,K=G.size,F=G.level,ee=G.bgColor,oe=G.fgColor,he=G.includeMargin,ge=G.imageSettings,_e=new a(-1,l[F]);if(_e.addData(h(J)),_e.make(),this._canvas!=null){var be=this._canvas,Ee=be.getContext("2d");if(!Ee)return;var Te=_e.modules;if(Te===null)return;var Ce=he?b:0,me=Te.length+Ce*2,se=c(this.props,Te);ge!=null&&se!=null&&(se.excavation!=null&&(Te=g(Te,se.excavation)));var Re=window.devicePixelRatio||1;be.height=be.width=K*Re;var et=K/me*Re;Ee.scale(et,et),Ee.fillStyle=ee,Ee.fillRect(0,0,me,me),Ee.fillStyle=oe,u?Ee.fill(new Path2D(T(Te,Ce))):Te.forEach(function(Ge,tt){Ge.forEach(function(Ye,De){Ye&&Ee.fillRect(De+Ce,tt+Ce,1,1)})}),this.state.imgLoaded&&this._image&&se!=null&&Ee.drawImage(this._image,se.x+Ce,se.y+Ce,se.w,se.h)}}},{key:"render",value:function(){var G=this,J=this.props,K=J.value,F=J.size,ee=J.level,oe=J.bgColor,he=J.fgColor,ge=J.style,_e=J.includeMargin,be=J.imageSettings,Ee=I(J,["value","size","level","bgColor","fgColor","style","includeMargin","imageSettings"]),Te=V({height:F,width:F},ge),Ce=null,me=be&&be.src;return be!=null&&me!=null&&(Ce=S.createElement("img",{src:me,style:{display:"none"},onLoad:this.handleImageLoad,ref:function(Re){return G._image=Re}})),S.createElement(S.Fragment,null,S.createElement("canvas",Y({style:Te,height:F,width:F,ref:function(Re){return G._canvas=Re}},Ee)),Ce)}}]),O}(S.PureComponent);x(o,"defaultProps",_);var C=function(v){P(O,v);function O(){return B(this,O),k(this,p(O).apply(this,arguments))}return M(O,[{key:"render",value:function(){var G=this.props,J=G.value,K=G.size,F=G.level,ee=G.bgColor,oe=G.fgColor,he=G.includeMargin,ge=G.imageSettings,_e=I(G,["value","size","level","bgColor","fgColor","includeMargin","imageSettings"]),be=new a(-1,l[F]);be.addData(h(J)),be.make();var Ee=be.modules;if(Ee===null)return null;var Te=he?b:0,Ce=Ee.length+Te*2,me=c(this.props,Ee),se=null;ge!=null&&me!=null&&(me.excavation!=null&&(Ee=g(Ee,me.excavation)),se=S.createElement("image",{xlinkHref:ge.src,height:me.h,width:me.w,x:me.x+Te,y:me.y+Te,preserveAspectRatio:"none"}));var Re=T(Ee,Te);return S.createElement("svg",Y({shapeRendering:"crispEdges",height:K,width:K,viewBox:"0 0 ".concat(Ce," ").concat(Ce)},_e),S.createElement("path",{fill:ee,d:"M0,0 h".concat(Ce,"v").concat(Ce,"H0z")}),S.createElement("path",{fill:oe,d:Re}),se)}}]),O}(S.PureComponent);x(C,"defaultProps",_);var E=function(O){var j=O.renderAs,G=I(O,["renderAs"]),J=j==="svg"?C:o;return S.createElement(J,G)};E.defaultProps=V({renderAs:"canvas"},_),ht.exports=E},DlQD:function(ht,ot,re){(function(ie,Y){ht.exports=Y()})(this,function(){"use strict";function ie(pe,de){for(var ue=0;ue<de.length;ue++){var te=de[ue];te.enumerable=te.enumerable||!1,te.configurable=!0,"value"in te&&(te.writable=!0),Object.defineProperty(pe,te.key,te)}}function Y(pe,de,ue){return de&&ie(pe.prototype,de),ue&&ie(pe,ue),pe}function D(pe,de){if(!pe)return;if(typeof pe=="string")return V(pe,de);var ue=Object.prototype.toString.call(pe).slice(8,-1);if(ue==="Object"&&pe.constructor&&(ue=pe.constructor.name),ue==="Map"||ue==="Set")return Array.from(pe);if(ue==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(ue))return V(pe,de)}function V(pe,de){(de==null||de>pe.length)&&(de=pe.length);for(var ue=0,te=new Array(de);ue<de;ue++)te[ue]=pe[ue];return te}function I(pe,de){var ue;if(typeof Symbol=="undefined"||pe[Symbol.iterator]==null){if(Array.isArray(pe)||(ue=D(pe))||de&&pe&&typeof pe.length=="number"){ue&&(pe=ue);var te=0;return function(){return te>=pe.length?{done:!0}:{done:!1,value:pe[te++]}}}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 ue=pe[Symbol.iterator](),ue.next.bind(ue)}function w(pe,de){return de={exports:{}},pe(de,de.exports),de.exports}var B=w(function(pe){function de(){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 ue(te){pe.exports.defaults=te}pe.exports={defaults:de(),getDefaults:de,changeDefaults:ue}}),N=B.defaults,M=B.getDefaults,k=B.changeDefaults,p=/[&<>"']/,y=/[&<>"']/g,P=/[<>"']|&(?!#?\w+;)/,L=/[<>"']|&(?!#?\w+;)/g,x={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},S=function(de){return x[de]};function d(pe,de){if(de){if(p.test(pe))return pe.replace(y,S)}else if(P.test(pe))return pe.replace(L,S);return pe}var a=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function l(pe){return pe.replace(a,function(de,ue){return ue=ue.toLowerCase(),ue==="colon"?":":ue.charAt(0)==="#"?ue.charAt(1)==="x"?String.fromCharCode(parseInt(ue.substring(2),16)):String.fromCharCode(+ue.substring(1)):""})}var h=/(^|[^\[])\^/g;function _(pe,de){pe=pe.source||pe,de=de||"";var ue={replace:function(q,ne){return ne=ne.source||ne,ne=ne.replace(h,"$1"),pe=pe.replace(q,ne),ue},getRegex:function(){return new RegExp(pe,de)}};return ue}var f=/[^\w:]/g,b=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function R(pe,de,ue){if(pe){var te;try{te=decodeURIComponent(l(ue)).replace(f,"").toLowerCase()}catch(q){return null}if(te.indexOf("javascript:")===0||te.indexOf("vbscript:")===0||te.indexOf("data:")===0)return null}de&&!b.test(ue)&&(ue=o(de,ue));try{ue=encodeURI(ue).replace(/%25/g,"%")}catch(q){return null}return ue}var T={},g=/^[^:]+:\/*[^/]*$/,c=/^([^:]+:)[\s\S]*$/,u=/^([^:]+:\/*[^/]*)[\s\S]*$/;function o(pe,de){T[" "+pe]||(g.test(pe)?T[" "+pe]=pe+"/":T[" "+pe]=O(pe,"/",!0)),pe=T[" "+pe];var ue=pe.indexOf(":")===-1;return de.substring(0,2)==="//"?ue?de:pe.replace(c,"$1")+de:de.charAt(0)==="/"?ue?de:pe.replace(u,"$1")+de:pe+de}var C={exec:function(){}};function E(pe){for(var de=1,ue,te;de<arguments.length;de++){ue=arguments[de];for(te in ue)Object.prototype.hasOwnProperty.call(ue,te)&&(pe[te]=ue[te])}return pe}function v(pe,de){var ue=pe.replace(/\|/g,function(ne,ae,ve){for(var Le=!1,Ie=ae;--Ie>=0&&ve[Ie]==="\\";)Le=!Le;return Le?"|":" |"}),te=ue.split(/ \|/),q=0;if(te.length>de)te.splice(de);else for(;te.length<de;)te.push("");for(;q<te.length;q++)te[q]=te[q].trim().replace(/\\\|/g,"|");return te}function O(pe,de,ue){var te=pe.length;if(te===0)return"";for(var q=0;q<te;){var ne=pe.charAt(te-q-1);if(ne===de&&!ue)q++;else if(ne!==de&&ue)q++;else break}return pe.substr(0,te-q)}function j(pe,de){if(pe.indexOf(de[1])===-1)return-1;for(var ue=pe.length,te=0,q=0;q<ue;q++)if(pe[q]==="\\")q++;else if(pe[q]===de[0])te++;else if(pe[q]===de[1]&&(te--,te<0))return q;return-1}function G(pe){pe&&pe.sanitize&&!pe.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 J={escape:d,unescape:l,edit:_,cleanUrl:R,resolveUrl:o,noopTest:C,merge:E,splitCells:v,rtrim:O,findClosingBracket:j,checkSanitizeDeprecation:G},K=B.defaults,F=J.rtrim,ee=J.splitCells,oe=J.escape,he=J.findClosingBracket;function ge(pe,de,ue){var te=de.href,q=de.title?oe(de.title):null,ne=pe[1].replace(/\\([\[\]])/g,"$1");return pe[0].charAt(0)!=="!"?{type:"link",raw:ue,href:te,title:q,text:ne}:{type:"image",raw:ue,href:te,title:q,text:oe(ne)}}function _e(pe,de){var ue=pe.match(/^(\s+)(?:```)/);if(ue===null)return de;var te=ue[1];return de.split(`
`).map(function(q){var ne=q.match(/^\s+/);if(ne===null)return q;var ae=ne[0];return ae.length>=te.length?q.slice(te.length):q}).join(`
`)}var be=function(){function pe(ue){this.options=ue||K}var de=pe.prototype;return de.space=function(te){var q=this.rules.block.newline.exec(te);if(q)return q[0].length>1?{type:"space",raw:q[0]}:{raw:`
`}},de.code=function(te,q){var ne=this.rules.block.code.exec(te);if(ne){var ae=q[q.length-1];if(ae&&ae.type==="paragraph")return{raw:ne[0],text:ne[0].trimRight()};var ve=ne[0].replace(/^ {4}/gm,"");return{type:"code",raw:ne[0],codeBlockStyle:"indented",text:this.options.pedantic?ve:F(ve,`
`)}}},de.fences=function(te){var q=this.rules.block.fences.exec(te);if(q){var ne=q[0],ae=_e(ne,q[3]||"");return{type:"code",raw:ne,lang:q[2]?q[2].trim():q[2],text:ae}}},de.heading=function(te){var q=this.rules.block.heading.exec(te);if(q)return{type:"heading",raw:q[0],depth:q[1].length,text:q[2]}},de.nptable=function(te){var q=this.rules.block.nptable.exec(te);if(q){var ne={type:"table",header:ee(q[1].replace(/^ *| *\| *$/g,"")),align:q[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:q[3]?q[3].replace(/\n$/,"").split(`
`):[],raw:q[0]};if(ne.header.length===ne.align.length){var ae=ne.align.length,ve;for(ve=0;ve<ae;ve++)/^ *-+: *$/.test(ne.align[ve])?ne.align[ve]="right":/^ *:-+: *$/.test(ne.align[ve])?ne.align[ve]="center":/^ *:-+ *$/.test(ne.align[ve])?ne.align[ve]="left":ne.align[ve]=null;for(ae=ne.cells.length,ve=0;ve<ae;ve++)ne.cells[ve]=ee(ne.cells[ve],ne.header.length);return ne}}},de.hr=function(te){var q=this.rules.block.hr.exec(te);if(q)return{type:"hr",raw:q[0]}},de.blockquote=function(te){var q=this.rules.block.blockquote.exec(te);if(q){var ne=q[0].replace(/^ *> ?/gm,"");return{type:"blockquote",raw:q[0],text:ne}}},de.list=function(te){var q=this.rules.block.list.exec(te);if(q){for(var ne=q[0],ae=q[2],ve=ae.length>1,Le=ae[ae.length-1]===")",Ie={type:"list",raw:ne,ordered:ve,start:ve?+ae.slice(0,-1):"",loose:!1,items:[]},lt=q[0].match(this.rules.block.item),Rt=!1,Pe,xt,mt,He,Tt,yt,kt,Lt=lt.length,Et=0;Et<Lt;Et++)Pe=lt[Et],ne=Pe,xt=Pe.length,Pe=Pe.replace(/^ *([*+-]|\d+[.)]) */,""),~Pe.indexOf(`
`)&&(xt-=Pe.length,Pe=this.options.pedantic?Pe.replace(/^ {1,4}/gm,""):Pe.replace(new RegExp("^ {1,"+xt+"}","gm"),"")),Et!==Lt-1&&(mt=this.rules.block.bullet.exec(lt[Et+1])[0],(ve?mt.length===1||!Le&&mt[mt.length-1]===")":mt.length>1||this.options.smartLists&&mt!==ae)&&(He=lt.slice(Et+1).join(`
`),Ie.raw=Ie.raw.substring(0,Ie.raw.length-He.length),Et=Lt-1)),Tt=Rt||/\n\n(?!\s*$)/.test(Pe),Et!==Lt-1&&(Rt=Pe.charAt(Pe.length-1)===`
`,Tt||(Tt=Rt)),Tt&&(Ie.loose=!0),yt=/^\[[ xX]\] /.test(Pe),kt=void 0,yt&&(kt=Pe[1]!==" ",Pe=Pe.replace(/^\[[ xX]\] +/,"")),Ie.items.push({type:"list_item",raw:ne,task:yt,checked:kt,loose:Tt,text:Pe});return Ie}},de.html=function(te){var q=this.rules.block.html.exec(te);if(q)return{type:this.options.sanitize?"paragraph":"html",raw:q[0],pre:!this.options.sanitizer&&(q[1]==="pre"||q[1]==="script"||q[1]==="style"),text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(q[0]):oe(q[0]):q[0]}},de.def=function(te){var q=this.rules.block.def.exec(te);if(q){q[3]&&(q[3]=q[3].substring(1,q[3].length-1));var ne=q[1].toLowerCase().replace(/\s+/g," ");return{tag:ne,raw:q[0],href:q[2],title:q[3]}}},de.table=function(te){var q=this.rules.block.table.exec(te);if(q){var ne={type:"table",header:ee(q[1].replace(/^ *| *\| *$/g,"")),align:q[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:q[3]?q[3].replace(/\n$/,"").split(`
`):[]};if(ne.header.length===ne.align.length){ne.raw=q[0];var ae=ne.align.length,ve;for(ve=0;ve<ae;ve++)/^ *-+: *$/.test(ne.align[ve])?ne.align[ve]="right":/^ *:-+: *$/.test(ne.align[ve])?ne.align[ve]="center":/^ *:-+ *$/.test(ne.align[ve])?ne.align[ve]="left":ne.align[ve]=null;for(ae=ne.cells.length,ve=0;ve<ae;ve++)ne.cells[ve]=ee(ne.cells[ve].replace(/^ *\| *| *\| *$/g,""),ne.header.length);return ne}}},de.lheading=function(te){var q=this.rules.block.lheading.exec(te);if(q)return{type:"heading",raw:q[0],depth:q[2].charAt(0)==="="?1:2,text:q[1]}},de.paragraph=function(te){var q=this.rules.block.paragraph.exec(te);if(q)return{type:"paragraph",raw:q[0],text:q[1].charAt(q[1].length-1)===`
`?q[1].slice(0,-1):q[1]}},de.text=function(te,q){var ne=this.rules.block.text.exec(te);if(ne){var ae=q[q.length-1];return ae&&ae.type==="text"?{raw:ne[0],text:ne[0]}:{type:"text",raw:ne[0],text:ne[0]}}},de.escape=function(te){var q=this.rules.inline.escape.exec(te);if(q)return{type:"escape",raw:q[0],text:oe(q[1])}},de.tag=function(te,q,ne){var ae=this.rules.inline.tag.exec(te);if(ae)return!q&&/^<a /i.test(ae[0])?q=!0:q&&/^<\/a>/i.test(ae[0])&&(q=!1),!ne&&/^<(pre|code|kbd|script)(\s|>)/i.test(ae[0])?ne=!0:ne&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(ae[0])&&(ne=!1),{type:this.options.sanitize?"text":"html",raw:ae[0],inLink:q,inRawBlock:ne,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ae[0]):oe(ae[0]):ae[0]}},de.link=function(te){var q=this.rules.inline.link.exec(te);if(q){var ne=he(q[2],"()");if(ne>-1){var ae=q[0].indexOf("!")===0?5:4,ve=ae+q[1].length+ne;q[2]=q[2].substring(0,ne),q[0]=q[0].substring(0,ve).trim(),q[3]=""}var Le=q[2],Ie="";if(this.options.pedantic){var lt=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(Le);lt?(Le=lt[1],Ie=lt[3]):Ie=""}else Ie=q[3]?q[3].slice(1,-1):"";Le=Le.trim().replace(/^<([\s\S]*)>$/,"$1");var Rt=ge(q,{href:Le&&Le.replace(this.rules.inline._escapes,"$1"),title:Ie&&Ie.replace(this.rules.inline._escapes,"$1")},q[0]);return Rt}},de.reflink=function(te,q){var ne;if((ne=this.rules.inline.reflink.exec(te))||(ne=this.rules.inline.nolink.exec(te))){var ae=(ne[2]||ne[1]).replace(/\s+/g," ");if(ae=q[ae.toLowerCase()],!ae||!ae.href){var ve=ne[0].charAt(0);return{type:"text",raw:ve,text:ve}}var Le=ge(ne,ae,ne[0]);return Le}},de.strong=function(te,q,ne){ne===void 0&&(ne="");var ae=this.rules.inline.strong.start.exec(te);if(ae&&(!ae[1]||ae[1]&&(ne===""||this.rules.inline.punctuation.exec(ne)))){q=q.slice(-1*te.length);var ve=ae[0]==="**"?this.rules.inline.strong.endAst:this.rules.inline.strong.endUnd;ve.lastIndex=0;for(var Le;(ae=ve.exec(q))!=null;)if(Le=this.rules.inline.strong.middle.exec(q.slice(0,ae.index+3)),Le)return{type:"strong",raw:te.slice(0,Le[0].length),text:te.slice(2,Le[0].length-2)}}},de.em=function(te,q,ne){ne===void 0&&(ne="");var ae=this.rules.inline.em.start.exec(te);if(ae&&(!ae[1]||ae[1]&&(ne===""||this.rules.inline.punctuation.exec(ne)))){q=q.slice(-1*te.length);var ve=ae[0]==="*"?this.rules.inline.em.endAst:this.rules.inline.em.endUnd;ve.lastIndex=0;for(var Le;(ae=ve.exec(q))!=null;)if(Le=this.rules.inline.em.middle.exec(q.slice(0,ae.index+2)),Le)return{type:"em",raw:te.slice(0,Le[0].length),text:te.slice(1,Le[0].length-1)}}},de.codespan=function(te){var q=this.rules.inline.code.exec(te);if(q){var ne=q[2].replace(/\n/g," "),ae=/[^ ]/.test(ne),ve=ne.startsWith(" ")&&ne.endsWith(" ");return ae&&ve&&(ne=ne.substring(1,ne.length-1)),ne=oe(ne,!0),{type:"codespan",raw:q[0],text:ne}}},de.br=function(te){var q=this.rules.inline.br.exec(te);if(q)return{type:"br",raw:q[0]}},de.del=function(te){var q=this.rules.inline.del.exec(te);if(q)return{type:"del",raw:q[0],text:q[1]}},de.autolink=function(te,q){var ne=this.rules.inline.autolink.exec(te);if(ne){var ae,ve;return ne[2]==="@"?(ae=oe(this.options.mangle?q(ne[1]):ne[1]),ve="mailto:"+ae):(ae=oe(ne[1]),ve=ae),{type:"link",raw:ne[0],text:ae,href:ve,tokens:[{type:"text",raw:ae,text:ae}]}}},de.url=function(te,q){var ne;if(ne=this.rules.inline.url.exec(te)){var ae,ve;if(ne[2]==="@")ae=oe(this.options.mangle?q(ne[0]):ne[0]),ve="mailto:"+ae;else{var Le;do Le=ne[0],ne[0]=this.rules.inline._backpedal.exec(ne[0])[0];while(Le!==ne[0]);ae=oe(ne[0]),ne[1]==="www."?ve="http://"+ae:ve=ae}return{type:"link",raw:ne[0],text:ae,href:ve,tokens:[{type:"text",raw:ae,text:ae}]}}},de.inlineText=function(te,q,ne){var ae=this.rules.inline.text.exec(te);if(ae){var ve;return q?ve=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(ae[0]):oe(ae[0]):ae[0]:ve=oe(this.options.smartypants?ne(ae[0]):ae[0]),{type:"text",raw:ae[0],text:ve}}},pe}(),Ee=J.noopTest,Te=J.edit,Ce=J.merge,me={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:Ee,table:Ee,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};me._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,me._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,me.def=Te(me.def).replace("label",me._label).replace("title",me._title).getRegex(),me.bullet=/(?:[*+-]|\d{1,9}[.)])/,me.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,me.item=Te(me.item,"gm").replace(/bull/g,me.bullet).getRegex(),me.list=Te(me.list).replace(/bull/g,me.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+me.def.source+")").getRegex(),me._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",me._comment=/<!--(?!-?>)[\s\S]*?-->/,me.html=Te(me.html,"i").replace("comment",me._comment).replace("tag",me._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),me.paragraph=Te(me._paragraph).replace("hr",me.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",me._tag).getRegex(),me.blockquote=Te(me.blockquote).replace("paragraph",me.paragraph).getRegex(),me.normal=Ce({},me),me.gfm=Ce({},me.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*|$)"}),me.gfm.nptable=Te(me.gfm.nptable).replace("hr",me.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",me._tag).getRegex(),me.gfm.table=Te(me.gfm.table).replace("hr",me.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",me._tag).getRegex(),me.pedantic=Ce({},me.normal,{html:Te(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",me._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:Ee,paragraph:Te(me.normal._paragraph).replace("hr",me.hr).replace("heading",` *#{1,6} *[^
]`).replace("lheading",me.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var se={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ee,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:Ee,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/,punctuation:/^([\s*punctuation])/};se._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",se.punctuation=Te(se.punctuation).replace(/punctuation/g,se._punctuation).getRegex(),se._blockSkip="\\[[^\\]]*?\\]\\([^\\)]*?\\)|`[^`]*?`|<[^>]*?>",se._overlapSkip="__[^_]*?__|\\*\\*\\[^\\*\\]*?\\*\\*",se.em.start=Te(se.em.start).replace(/punctuation/g,se._punctuation).getRegex(),se.em.middle=Te(se.em.middle).replace(/punctuation/g,se._punctuation).replace(/overlapSkip/g,se._overlapSkip).getRegex(),se.em.endAst=Te(se.em.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.em.endUnd=Te(se.em.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.start=Te(se.strong.start).replace(/punctuation/g,se._punctuation).getRegex(),se.strong.middle=Te(se.strong.middle).replace(/punctuation/g,se._punctuation).replace(/blockSkip/g,se._blockSkip).getRegex(),se.strong.endAst=Te(se.strong.endAst,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.strong.endUnd=Te(se.strong.endUnd,"g").replace(/punctuation/g,se._punctuation).getRegex(),se.blockSkip=Te(se._blockSkip,"g").getRegex(),se.overlapSkip=Te(se._overlapSkip,"g").getRegex(),se._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,se._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,se._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])?)+(?![-_])/,se.autolink=Te(se.autolink).replace("scheme",se._scheme).replace("email",se._email).getRegex(),se._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,se.tag=Te(se.tag).replace("comment",me._comment).replace("attribute",se._attribute).getRegex(),se._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,se._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,se._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,se.link=Te(se.link).replace("label",se._label).replace("href",se._href).replace("title",se._title).getRegex(),se.reflink=Te(se.reflink).replace("label",se._label).getRegex(),se.reflinkSearch=Te(se.reflinkSearch,"g").replace("reflink",se.reflink).replace("nolink",se.nolink).getRegex(),se.normal=Ce({},se),se.pedantic=Ce({},se.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:Te(/^!?\[(label)\]\((.*?)\)/).replace("label",se._label).getRegex(),reflink:Te(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",se._label).getRegex()}),se.gfm=Ce({},se.normal,{escape:Te(se.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.!#$%&'*+\/=?_`{\|}~-]+@))/}),se.gfm.url=Te(se.gfm.url,"i").replace("email",se.gfm._extended_email).getRegex(),se.breaks=Ce({},se.gfm,{br:Te(se.br).replace("{2,}","*").getRegex(),text:Te(se.gfm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()});var Re={block:me,inline:se},et=B.defaults,Ge=Re.block,tt=Re.inline;function Ye(pe){return pe.replace(/---/g,"\u2014").replace(/--/g,"\u2013").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201C").replace(/"/g,"\u201D").replace(/\.{3}/g,"\u2026")}function De(pe){var de="",ue,te,q=pe.length;for(ue=0;ue<q;ue++)te=pe.charCodeAt(ue),Math.random()>.5&&(te="x"+te.toString(16)),de+="&#"+te+";";return de}var je=function(){function pe(ue){this.tokens=[],this.tokens.links=Object.create(null),this.options=ue||et,this.options.tokenizer=this.options.tokenizer||new be,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var te={block:Ge.normal,inline:tt.normal};this.options.pedantic?(te.block=Ge.pedantic,te.inline=tt.pedantic):this.options.gfm&&(te.block=Ge.gfm,this.options.breaks?te.inline=tt.breaks:te.inline=tt.gfm),this.tokenizer.rules=te}pe.lex=function(te,q){var ne=new pe(q);return ne.lex(te)};var de=pe.prototype;return de.lex=function(te){return te=te.replace(/\r\n|\r/g,`
`).replace(/\t/g," "),this.blockTokens(te,this.tokens,!0),this.inline(this.tokens),this.tokens},de.blockTokens=function(te,q,ne){q===void 0&&(q=[]),ne===void 0&&(ne=!0),te=te.replace(/^ +$/gm,"");for(var ae,ve,Le,Ie;te;){if(ae=this.tokenizer.space(te)){te=te.substring(ae.raw.length),ae.type&&q.push(ae);continue}if(ae=this.tokenizer.code(te,q)){te=te.substring(ae.raw.length),ae.type?q.push(ae):(Ie=q[q.length-1],Ie.raw+=`
`+ae.raw,Ie.text+=`
`+ae.text);continue}if(ae=this.tokenizer.fences(te)){te=te.substring(ae.raw.length),q.push(ae);continue}if(ae=this.tokenizer.heading(te)){te=te.substring(ae.raw.length),q.push(ae);continue}if(ae=this.tokenizer.nptable(te)){te=te.substring(ae.raw.length),q.push(ae);continue}if(ae=this.tokenizer.hr(te)){te=te.substring(ae.raw.length),q.push(ae);continue}if(ae=this.tokenizer.blockquote(te)){te=te.substring(ae.raw.length),ae.tokens=this.blockTokens(ae.text,[],ne),q.push(ae);continue}if(ae=this.tokenizer.list(te)){for(te=te.substring(ae.raw.length),Le=ae.items.length,ve=0;ve<Le;ve++)ae.items[ve].tokens=this.blockTokens(ae.items[ve].text,[],!1);q.push(ae);continue}if(ae=this.tokenizer.html(te)){te=te.substring(ae.raw.length),q.push(ae);continue}if(ne&&(ae=this.tokenizer.def(te))){te=te.substring(ae.raw.length),this.tokens.links[ae.tag]||(this.tokens.links[ae.tag]={href:ae.href,title:ae.title});continue}if(ae=this.tokenizer.table(te)){te=te.substring(ae.raw.length),q.push(ae);continue}if(ae=this.tokenizer.lheading(te)){te=te.substring(ae.raw.length),q.push(ae);continue}if(ne&&(ae=this.tokenizer.paragraph(te))){te=te.substring(ae.raw.length),q.push(ae);continue}if(ae=this.tokenizer.text(te,q)){te=te.substring(ae.raw.length),ae.type?q.push(ae):(Ie=q[q.length-1],Ie.raw+=`
`+ae.raw,Ie.text+=`
`+ae.text);continue}if(te){var lt="Infinite loop on byte: "+te.charCodeAt(0);if(this.options.silent){console.error(lt);break}else throw new Error(lt)}}return q},de.inline=function(te){var q,ne,ae,ve,Le,Ie,lt=te.length;for(q=0;q<lt;q++){Ie=te[q];switch(Ie.type){case"paragraph":case"text":case"heading":{Ie.tokens=[],this.inlineTokens(Ie.text,Ie.tokens);break}case"table":{for(Ie.tokens={header:[],cells:[]},ve=Ie.header.length,ne=0;ne<ve;ne++)Ie.tokens.header[ne]=[],this.inlineTokens(Ie.header[ne],Ie.tokens.header[ne]);for(ve=Ie.cells.length,ne=0;ne<ve;ne++)for(Le=Ie.cells[ne],Ie.tokens.cells[ne]=[],ae=0;ae<Le.length;ae++)Ie.tokens.cells[ne][ae]=[],this.inlineTokens(Le[ae],Ie.tokens.cells[ne][ae]);break}case"blockquote":{this.inline(Ie.tokens);break}case"list":{for(ve=Ie.items.length,ne=0;ne<ve;ne++)this.inline(Ie.items[ne].tokens);break}}}return te},de.inlineTokens=function(te,q,ne,ae,ve){q===void 0&&(q=[]),ne===void 0&&(ne=!1),ae===void 0&&(ae=!1),ve===void 0&&(ve="");var Le,Ie=te,lt;if(this.tokens.links){var Rt=Object.keys(this.tokens.links);if(Rt.length>0)for(;(lt=this.tokenizer.rules.inline.reflinkSearch.exec(Ie))!=null;)Rt.includes(lt[0].slice(lt[0].lastIndexOf("[")+1,-1))&&(Ie=Ie.slice(0,lt.index)+"["+"a".repeat(lt[0].length-2)+"]"+Ie.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(lt=this.tokenizer.rules.inline.blockSkip.exec(Ie))!=null;)Ie=Ie.slice(0,lt.index)+"["+"a".repeat(lt[0].length-2)+"]"+Ie.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;te;){if(Le=this.tokenizer.escape(te)){te=te.substring(Le.raw.length),q.push(Le);continue}if(Le=this.tokenizer.tag(te,ne,ae)){te=te.substring(Le.raw.length),ne=Le.inLink,ae=Le.inRawBlock,q.push(Le);continue}if(Le=this.tokenizer.link(te)){te=te.substring(Le.raw.length),Le.type==="link"&&(Le.tokens=this.inlineTokens(Le.text,[],!0,ae)),q.push(Le);continue}if(Le=this.tokenizer.reflink(te,this.tokens.links)){te=te.substring(Le.raw.length),Le.type==="link"&&(Le.tokens=this.inlineTokens(Le.text,[],!0,ae)),q.push(Le);continue}if(Le=this.tokenizer.strong(te,Ie,ve)){te=te.substring(Le.raw.length),Le.tokens=this.inlineTokens(Le.text,[],ne,ae),q.push(Le);continue}if(Le=this.tokenizer.em(te,Ie,ve)){te=te.substring(Le.raw.length),Le.tokens=this.inlineTokens(Le.text,[],ne,ae),q.push(Le);continue}if(Le=this.tokenizer.codespan(te)){te=te.substring(Le.raw.length),q.push(Le);continue}if(Le=this.tokenizer.br(te)){te=te.substring(Le.raw.length),q.push(Le);continue}if(Le=this.tokenizer.del(te)){te=te.substring(Le.raw.length),Le.tokens=this.inlineTokens(Le.text,[],ne,ae),q.push(Le);continue}if(Le=this.tokenizer.autolink(te,De)){te=te.substring(Le.raw.length),q.push(Le);continue}if(!ne&&(Le=this.tokenizer.url(te,De))){te=te.substring(Le.raw.length),q.push(Le);continue}if(Le=this.tokenizer.inlineText(te,ae,Ye)){te=te.substring(Le.raw.length),ve=Le.raw.slice(-1),q.push(Le);continue}if(te){var Pe="Infinite loop on byte: "+te.charCodeAt(0);if(this.options.silent){console.error(Pe);break}else throw new Error(Pe)}}return q},Y(pe,null,[{key:"rules",get:function(){return{block:Ge,inline:tt}}}]),pe}(),$e=B.defaults,st=J.cleanUrl,Qe=J.escape,Be=function(){function pe(ue){this.options=ue||$e}var de=pe.prototype;return de.code=function(te,q,ne){var ae=(q||"").match(/\S*/)[0];if(this.options.highlight){var ve=this.options.highlight(te,ae);ve!=null&&ve!==te&&(ne=!0,te=ve)}return ae?'<pre><code class="'+this.options.langPrefix+Qe(ae,!0)+'">'+(ne?te:Qe(te,!0))+`</code></pre>
`:"<pre><code>"+(ne?te:Qe(te,!0))+`</code></pre>
`},de.blockquote=function(te){return`<blockquote>
`+te+`</blockquote>
`},de.html=function(te){return te},de.heading=function(te,q,ne,ae){return this.options.headerIds?"<h"+q+' id="'+this.options.headerPrefix+ae.slug(ne)+'">'+te+"</h"+q+`>
`:"<h"+q+">"+te+"</h"+q+`>
`},de.hr=function(){return this.options.xhtml?`<hr/>
`:`<hr>
`},de.list=function(te,q,ne){var ae=q?"ol":"ul",ve=q&&ne!==1?' start="'+ne+'"':"";return"<"+ae+ve+`>
`+te+"</"+ae+`>
`},de.listitem=function(te){return"<li>"+te+`</li>
`},de.checkbox=function(te){return"<input "+(te?'checked="" ':"")+'disabled="" type="checkbox"'+(this.options.xhtml?" /":"")+"> "},de.paragraph=function(te){return"<p>"+te+`</p>
`},de.table=function(te,q){return q&&(q="<tbody>"+q+"</tbody>"),`<table>
<thead>
`+te+`</thead>
`+q+`</table>
`},de.tablerow=function(te){return`<tr>
`+te+`</tr>
`},de.tablecell=function(te,q){var ne=q.header?"th":"td",ae=q.align?"<"+ne+' align="'+q.align+'">':"<"+ne+">";return ae+te+"</"+ne+`>
`},de.strong=function(te){return"<strong>"+te+"</strong>"},de.em=function(te){return"<em>"+te+"</em>"},de.codespan=function(te){return"<code>"+te+"</code>"},de.br=function(){return this.options.xhtml?"<br/>":"<br>"},de.del=function(te){return"<del>"+te+"</del>"},de.link=function(te,q,ne){if(te=st(this.options.sanitize,this.options.baseUrl,te),te===null)return ne;var ae='<a href="'+Qe(te)+'"';return q&&(ae+=' title="'+q+'"'),ae+=">"+ne+"</a>",ae},de.image=function(te,q,ne){if(te=st(this.options.sanitize,this.options.baseUrl,te),te===null)return ne;var ae='<img src="'+te+'" alt="'+ne+'"';return q&&(ae+=' title="'+q+'"'),ae+=this.options.xhtml?"/>":">",ae},de.text=function(te){return te},pe}(),We=function(){function pe(){}var de=pe.prototype;return de.strong=function(te){return te},de.em=function(te){return te},de.codespan=function(te){return te},de.del=function(te){return te},de.html=function(te){return te},de.text=function(te){return te},de.link=function(te,q,ne){return""+ne},de.image=function(te,q,ne){return""+ne},de.br=function(){return""},pe}(),ft=function(){function pe(){this.seen={}}var de=pe.prototype;return de.slug=function(te){var q=te.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(q)){var ne=q;do this.seen[ne]++,q=ne+"-"+this.seen[ne];while(this.seen.hasOwnProperty(q))}return this.seen[q]=0,q},pe}(),Ke=B.defaults,Ue=J.unescape,Xe=function(){function pe(ue){this.options=ue||Ke,this.options.renderer=this.options.renderer||new Be,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new We,this.slugger=new ft}pe.parse=function(te,q){var ne=new pe(q);return ne.parse(te)};var de=pe.prototype;return de.parse=function(te,q){q===void 0&&(q=!0);var ne="",ae,ve,Le,Ie,lt,Rt,Pe,xt,mt,He,Tt,yt,kt,Lt,Et,sr,Xt,gt,ir=te.length;for(ae=0;ae<ir;ae++){He=te[ae];switch(He.type){case"space":continue;case"hr":{ne+=this.renderer.hr();continue}case"heading":{ne+=this.renderer.heading(this.parseInline(He.tokens),He.depth,Ue(this.parseInline(He.tokens,this.textRenderer)),this.slugger);continue}case"code":{ne+=this.renderer.code(He.text,He.lang,He.escaped);continue}case"table":{for(xt="",Pe="",Ie=He.header.length,ve=0;ve<Ie;ve++)Pe+=this.renderer.tablecell(this.parseInline(He.tokens.header[ve]),{header:!0,align:He.align[ve]});for(xt+=this.renderer.tablerow(Pe),mt="",Ie=He.cells.length,ve=0;ve<Ie;ve++){for(Rt=He.tokens.cells[ve],Pe="",lt=Rt.length,Le=0;Le<lt;Le++)Pe+=this.renderer.tablecell(this.parseInline(Rt[Le]),{header:!1,align:He.align[Le]});mt+=this.renderer.tablerow(Pe)}ne+=this.renderer.table(xt,mt);continue}case"blockquote":{mt=this.parse(He.tokens),ne+=this.renderer.blockquote(mt);continue}case"list":{for(Tt=He.ordered,yt=He.start,kt=He.loose,Ie=He.items.length,mt="",ve=0;ve<Ie;ve++)Et=He.items[ve],sr=Et.checked,Xt=Et.task,Lt="",Et.task&&(gt=this.renderer.checkbox(sr),kt?Et.tokens.length>0&&Et.tokens[0].type==="text"?(Et.tokens[0].text=gt+" "+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=gt+" "+Et.tokens[0].tokens[0].text)):Et.tokens.unshift({type:"text",text:gt}):Lt+=gt),Lt+=this.parse(Et.tokens,kt),mt+=this.renderer.listitem(Lt,Xt,sr);ne+=this.renderer.list(mt,Tt,yt);continue}case"html":{ne+=this.renderer.html(He.text);continue}case"paragraph":{ne+=this.renderer.paragraph(this.parseInline(He.tokens));continue}case"text":{for(mt=He.tokens?this.parseInline(He.tokens):He.text;ae+1<ir&&te[ae+1].type==="text";)He=te[++ae],mt+=`
`+(He.tokens?this.parseInline(He.tokens):He.text);ne+=q?this.renderer.paragraph(mt):mt;continue}default:{var pr='Token with "'+He.type+'" type was not found.';if(this.options.silent){console.error(pr);return}else throw new Error(pr)}}}return ne},de.parseInline=function(te,q){q=q||this.renderer;var ne="",ae,ve,Le=te.length;for(ae=0;ae<Le;ae++){ve=te[ae];switch(ve.type){case"escape":{ne+=q.text(ve.text);break}case"html":{ne+=q.html(ve.text);break}case"link":{ne+=q.link(ve.href,ve.title,this.parseInline(ve.tokens,q));break}case"image":{ne+=q.image(ve.href,ve.title,ve.text);break}case"strong":{ne+=q.strong(this.parseInline(ve.tokens,q));break}case"em":{ne+=q.em(this.parseInline(ve.tokens,q));break}case"codespan":{ne+=q.codespan(ve.text);break}case"br":{ne+=q.br();break}case"del":{ne+=q.del(this.parseInline(ve.tokens,q));break}case"text":{ne+=q.text(ve.text);break}default:{var Ie='Token with "'+ve.type+'" type was not found.';if(this.options.silent){console.error(Ie);return}else throw new Error(Ie)}}}return ne},pe}(),Ze=J.merge,Ve=J.checkSanitizeDeprecation,rt=J.escape,we=B.getDefaults,qe=B.changeDefaults,it=B.defaults;function Ae(pe,de,ue){if(typeof pe=="undefined"||pe===null)throw new Error("marked(): input parameter is undefined or null");if(typeof pe!="string")throw new Error("marked(): input parameter is of type "+Object.prototype.toString.call(pe)+", string expected");if(typeof de=="function"&&(ue=de,de=null),de=Ze({},Ae.defaults,de||{}),Ve(de),ue){var te=de.highlight,q;try{q=je.lex(pe,de)}catch(Le){return ue(Le)}var ne=function(Ie){var lt;if(!Ie)try{lt=Xe.parse(q,de)}catch(Rt){Ie=Rt}return de.highlight=te,Ie?ue(Ie):ue(null,lt)};if(!te||te.length<3)return ne();if(delete de.highlight,!q.length)return ne();var ae=0;Ae.walkTokens(q,function(Le){Le.type==="code"&&(ae++,setTimeout(function(){te(Le.text,Le.lang,function(Ie,lt){if(Ie)return ne(Ie);lt!=null&&lt!==Le.text&&(Le.text=lt,Le.escaped=!0),ae--,ae===0&&ne()})},0))}),ae===0&&ne();return}try{var ve=je.lex(pe,de);return de.walkTokens&&Ae.walkTokens(ve,de.walkTokens),Xe.parse(ve,de)}catch(Le){if(Le.message+=`
Please report this to https://github.com/markedjs/marked.`,de.silent)return"<p>An error occurred:</p><pre>"+rt(Le.message+"",!0)+"</pre>";throw Le}}Ae.options=Ae.setOptions=function(pe){return Ze(Ae.defaults,pe),qe(Ae.defaults),Ae},Ae.getDefaults=we,Ae.defaults=it,Ae.use=function(pe){var de=Ze({},pe);if(pe.renderer&&function(){var te=Ae.defaults.renderer||new Be,q=function(ve){var Le=te[ve];te[ve]=function(){for(var Ie=arguments.length,lt=new Array(Ie),Rt=0;Rt<Ie;Rt++)lt[Rt]=arguments[Rt];var Pe=pe.renderer[ve].apply(te,lt);return Pe===!1&&(Pe=Le.apply(te,lt)),Pe}};for(var ne in pe.renderer)q(ne);de.renderer=te}(),pe.tokenizer&&function(){var te=Ae.defaults.tokenizer||new be,q=function(ve){var Le=te[ve];te[ve]=function(){for(var Ie=arguments.length,lt=new Array(Ie),Rt=0;Rt<Ie;Rt++)lt[Rt]=arguments[Rt];var Pe=pe.tokenizer[ve].apply(te,lt);return Pe===!1&&(Pe=Le.apply(te,lt)),Pe}};for(var ne in pe.tokenizer)q(ne);de.tokenizer=te}(),pe.walkTokens){var ue=Ae.defaults.walkTokens;de.walkTokens=function(te){pe.walkTokens(te),ue&&ue(te)}}Ae.setOptions(de)},Ae.walkTokens=function(pe,de){for(var ue=I(pe),te;!(te=ue()).done;){var q=te.value;de(q);switch(q.type){case"table":{for(var ne=I(q.tokens.header),ae;!(ae=ne()).done;){var ve=ae.value;Ae.walkTokens(ve,de)}for(var Le=I(q.tokens.cells),Ie;!(Ie=Le()).done;)for(var lt=Ie.value,Rt=I(lt),Pe;!(Pe=Rt()).done;){var xt=Pe.value;Ae.walkTokens(xt,de)}break}case"list":{Ae.walkTokens(q.items,de);break}default:q.tokens&&Ae.walkTokens(q.tokens,de)}}},Ae.Parser=Xe,Ae.parser=Xe.parse,Ae.Renderer=Be,Ae.TextRenderer=We,Ae.Lexer=je,Ae.lexer=je.lex,Ae.Tokenizer=be,Ae.Slugger=ft,Ae.parse=Ae;var Oe=Ae;return Oe})},ELLl:function(ht,ot,re){(function(ie){ie(re("VrN/"))})(function(ie){var Y={pairs:`()[]{}''""`,closeBefore:`)]}'":;>`,triples:"",explode:"[]{}"},D=ie.Pos;ie.defineOption("autoCloseBrackets",!1,function(x,S,d){d&&d!=ie.Init&&(x.removeKeyMap(I),x.state.closeBrackets=null),S&&(w(V(S,"pairs")),x.state.closeBrackets=S,x.addKeyMap(I))});function V(x,S){return S=="pairs"&&typeof x=="string"?x:typeof x=="object"&&x[S]!=null?x[S]:Y[S]}var I={Backspace:M,Enter:k};function w(x){for(var S=0;S<x.length;S++){var d=x.charAt(S),a="'"+d+"'";I[a]||(I[a]=B(d))}}w(Y.pairs+"`");function B(x){return function(S){return y(S,x)}}function N(x){var S=x.state.closeBrackets;if(!S||S.override)return S;var d=x.getModeAt(x.getCursor());return d.closeBrackets||S}function M(x){var S=N(x);if(!S||x.getOption("disableInput"))return ie.Pass;for(var d=V(S,"pairs"),a=x.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return ie.Pass;var h=P(x,a[l].head);if(!h||d.indexOf(h)%2!=0)return ie.Pass}for(var l=a.length-1;l>=0;l--){var _=a[l].head;x.replaceRange("",D(_.line,_.ch-1),D(_.line,_.ch+1),"+delete")}}function k(x){var S=N(x),d=S&&V(S,"explode");if(!d||x.getOption("disableInput"))return ie.Pass;for(var a=x.listSelections(),l=0;l<a.length;l++){if(!a[l].empty())return ie.Pass;var h=P(x,a[l].head);if(!h||d.indexOf(h)%2!=0)return ie.Pass}x.operation(function(){var _=x.lineSeparator()||`
`;x.replaceSelection(_+_,null),x.execCommand("goCharLeft"),a=x.listSelections();for(var f=0;f<a.length;f++){var b=a[f].head.line;x.indentLine(b,null,!0),x.indentLine(b+1,null,!0)}})}function p(x){var S=ie.cmpPos(x.anchor,x.head)>0;return{anchor:new D(x.anchor.line,x.anchor.ch+(S?-1:1)),head:new D(x.head.line,x.head.ch+(S?1:-1))}}function y(x,S){var d=N(x);if(!d||x.getOption("disableInput"))return ie.Pass;var a=V(d,"pairs"),l=a.indexOf(S);if(l==-1)return ie.Pass;for(var h=V(d,"closeBefore"),_=V(d,"triples"),f=a.charAt(l+1)==S,b=x.listSelections(),R=l%2==0,T,g=0;g<b.length;g++){var c=b[g],u=c.head,o,C=x.getRange(u,D(u.line,u.ch+1));if(R&&!c.empty())o="surround";else if((f||!R)&&C==S)f&&L(x,u)?o="both":_.indexOf(S)>=0&&x.getRange(u,D(u.line,u.ch+3))==S+S+S?o="skipThree":o="skip";else if(f&&u.ch>1&&_.indexOf(S)>=0&&x.getRange(D(u.line,u.ch-2),u)==S+S){if(u.ch>2&&/\bstring/.test(x.getTokenTypeAt(D(u.line,u.ch-2))))return ie.Pass;o="addFour"}else if(f){var E=u.ch==0?" ":x.getRange(D(u.line,u.ch-1),u);if(!ie.isWordChar(C)&&E!=S&&!ie.isWordChar(E))o="both";else return ie.Pass}else if(R&&(C.length===0||/\s/.test(C)||h.indexOf(C)>-1))o="both";else return ie.Pass;if(!T)T=o;else if(T!=o)return ie.Pass}var v=l%2?a.charAt(l-1):S,O=l%2?S:a.charAt(l+1);x.operation(function(){if(T=="skip")x.execCommand("goCharRight");else if(T=="skipThree")for(var j=0;j<3;j++)x.execCommand("goCharRight");else if(T=="surround"){for(var G=x.getSelections(),j=0;j<G.length;j++)G[j]=v+G[j]+O;x.replaceSelections(G,"around"),G=x.listSelections().slice();for(var j=0;j<G.length;j++)G[j]=p(G[j]);x.setSelections(G)}else T=="both"?(x.replaceSelection(v+O,null),x.triggerElectric(v+O),x.execCommand("goCharLeft")):T=="addFour"&&(x.replaceSelection(v+v+v+v,"before"),x.execCommand("goCharRight"))})}function P(x,S){var d=x.getRange(D(S.line,S.ch-1),D(S.line,S.ch+1));return d.length==2?d:null}function L(x,S){var d=x.getTokenAt(D(S.line,S.ch+1));return/\bstring/.test(d.type)&&d.start==S.ch&&(S.ch==0||!/\bstring/.test(x.getTokenTypeAt(S)))}})},G8my:function(ht,ot,re){ht.exports={flex:"flex___1FMOA"}},H38U:function(ht,ot,re){var ie=re("f4xo"),Y=re("rcnY"),D=re("wU8J"),V=re("Iq15"),I=re("dWSS");function w(N,M){this.typeNumber=N,this.errorCorrectLevel=M,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var B=w.prototype;B.addData=function(N){var M=new ie(N);this.dataList.push(M),this.dataCache=null},B.isDark=function(N,M){if(N<0||this.moduleCount<=N||M<0||this.moduleCount<=M)throw new Error(N+","+M);return this.modules[N][M]},B.getModuleCount=function(){return this.moduleCount},B.make=function(){if(this.typeNumber<1){var N=1;for(N=1;N<40;N++){for(var M=Y.getRSBlocks(N,this.errorCorrectLevel),k=new D,p=0,y=0;y<M.length;y++)p+=M[y].dataCount;for(var y=0;y<this.dataList.length;y++){var P=this.dataList[y];k.put(P.mode,4),k.put(P.getLength(),V.getLengthInBits(P.mode,N)),P.write(k)}if(k.getLengthInBits()<=p*8)break}this.typeNumber=N}this.makeImpl(!1,this.getBestMaskPattern())},B.makeImpl=function(N,M){this.moduleCount=this.typeNumber*4+17,this.modules=new Array(this.moduleCount);for(var k=0;k<this.moduleCount;k++){this.modules[k]=new Array(this.moduleCount);for(var p=0;p<this.moduleCount;p++)this.modules[k][p]=null}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(N,M),this.typeNumber>=7&&this.setupTypeNumber(N),this.dataCache==null&&(this.dataCache=w.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,M)},B.setupPositionProbePattern=function(N,M){for(var k=-1;k<=7;k++){if(N+k<=-1||this.moduleCount<=N+k)continue;for(var p=-1;p<=7;p++){if(M+p<=-1||this.moduleCount<=M+p)continue;0<=k&&k<=6&&(p==0||p==6)||0<=p&&p<=6&&(k==0||k==6)||2<=k&&k<=4&&2<=p&&p<=4?this.modules[N+k][M+p]=!0:this.modules[N+k][M+p]=!1}}},B.getBestMaskPattern=function(){for(var N=0,M=0,k=0;k<8;k++){this.makeImpl(!0,k);var p=V.getLostPoint(this);(k==0||N>p)&&(N=p,M=k)}return M},B.createMovieClip=function(N,M,k){var p=N.createEmptyMovieClip(M,k),y=1;this.make();for(var P=0;P<this.modules.length;P++)for(var L=P*y,x=0;x<this.modules[P].length;x++){var S=x*y,d=this.modules[P][x];d&&(p.beginFill(0,100),p.moveTo(S,L),p.lineTo(S+y,L),p.lineTo(S+y,L+y),p.lineTo(S,L+y),p.endFill())}return p},B.setupTimingPattern=function(){for(var N=8;N<this.moduleCount-8;N++){if(this.modules[N][6]!=null)continue;this.modules[N][6]=N%2==0}for(var M=8;M<this.moduleCount-8;M++){if(this.modules[6][M]!=null)continue;this.modules[6][M]=M%2==0}},B.setupPositionAdjustPattern=function(){for(var N=V.getPatternPosition(this.typeNumber),M=0;M<N.length;M++)for(var k=0;k<N.length;k++){var p=N[M],y=N[k];if(this.modules[p][y]!=null)continue;for(var P=-2;P<=2;P++)for(var L=-2;L<=2;L++)P==-2||P==2||L==-2||L==2||P==0&&L==0?this.modules[p+P][y+L]=!0:this.modules[p+P][y+L]=!1}},B.setupTypeNumber=function(N){for(var M=V.getBCHTypeNumber(this.typeNumber),k=0;k<18;k++){var p=!N&&(M>>k&1)==1;this.modules[Math.floor(k/3)][k%3+this.moduleCount-8-3]=p}for(var k=0;k<18;k++){var p=!N&&(M>>k&1)==1;this.modules[k%3+this.moduleCount-8-3][Math.floor(k/3)]=p}},B.setupTypeInfo=function(N,M){for(var k=this.errorCorrectLevel<<3|M,p=V.getBCHTypeInfo(k),y=0;y<15;y++){var P=!N&&(p>>y&1)==1;y<6?this.modules[y][8]=P:y<8?this.modules[y+1][8]=P:this.modules[this.moduleCount-15+y][8]=P}for(var y=0;y<15;y++){var P=!N&&(p>>y&1)==1;y<8?this.modules[8][this.moduleCount-y-1]=P:y<9?this.modules[8][15-y-1+1]=P:this.modules[8][15-y-1]=P}this.modules[this.moduleCount-8][8]=!N},B.mapData=function(N,M){for(var k=-1,p=this.moduleCount-1,y=7,P=0,L=this.moduleCount-1;L>0;L-=2)for(L==6&&L--;;){for(var x=0;x<2;x++)if(this.modules[p][L-x]==null){var S=!1;P<N.length&&(S=(N[P]>>>y&1)==1);var d=V.getMask(M,p,L-x);d&&(S=!S),this.modules[p][L-x]=S,y--,y==-1&&(P++,y=7)}if(p+=k,p<0||this.moduleCount<=p){p-=k,k=-k;break}}},w.PAD0=236,w.PAD1=17,w.createData=function(N,M,k){for(var p=Y.getRSBlocks(N,M),y=new D,P=0;P<k.length;P++){var L=k[P];y.put(L.mode,4),y.put(L.getLength(),V.getLengthInBits(L.mode,N)),L.write(y)}for(var x=0,P=0;P<p.length;P++)x+=p[P].dataCount;if(y.getLengthInBits()>x*8)throw new Error("code length overflow. ("+y.getLengthInBits()+">"+x*8+")");for(y.getLengthInBits()+4<=x*8&&y.put(0,4);y.getLengthInBits()%8!=0;)y.putBit(!1);for(;!(y.getLengthInBits()>=x*8);){if(y.put(w.PAD0,8),y.getLengthInBits()>=x*8)break;y.put(w.PAD1,8)}return w.createBytes(y,p)},w.createBytes=function(N,M){for(var k=0,p=0,y=0,P=new Array(M.length),L=new Array(M.length),x=0;x<M.length;x++){var S=M[x].dataCount,d=M[x].totalCount-S;p=Math.max(p,S),y=Math.max(y,d),P[x]=new Array(S);for(var a=0;a<P[x].length;a++)P[x][a]=255&N.buffer[a+k];k+=S;var l=V.getErrorCorrectPolynomial(d),h=new I(P[x],l.getLength()-1),_=h.mod(l);L[x]=new Array(l.getLength()-1);for(var a=0;a<L[x].length;a++){var f=a+_.getLength()-L[x].length;L[x][a]=f>=0?_.get(f):0}}for(var b=0,a=0;a<M.length;a++)b+=M[a].totalCount;for(var R=new Array(b),T=0,a=0;a<p;a++)for(var x=0;x<M.length;x++)a<P[x].length&&(R[T++]=P[x][a]);for(var a=0;a<y;a++)for(var x=0;x<M.length;x++)a<L[x].length&&(R[T++]=L[x][a]);return R},ht.exports=w},HmJG:function(ht,ot,re){},Iq15:function(ht,ot,re){var ie=re("nVVt"),Y=re("dWSS"),D=re("dQei"),V={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},I={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1<<10|1<<8|1<<5|1<<4|1<<2|1<<1|1<<0,G18:1<<12|1<<11|1<<10|1<<9|1<<8|1<<5|1<<2|1<<0,G15_MASK:1<<14|1<<12|1<<10|1<<4|1<<1,getBCHTypeInfo:function(w){for(var B=w<<10;I.getBCHDigit(B)-I.getBCHDigit(I.G15)>=0;)B^=I.G15<<I.getBCHDigit(B)-I.getBCHDigit(I.G15);return(w<<10|B)^I.G15_MASK},getBCHTypeNumber:function(w){for(var B=w<<12;I.getBCHDigit(B)-I.getBCHDigit(I.G18)>=0;)B^=I.G18<<I.getBCHDigit(B)-I.getBCHDigit(I.G18);return w<<12|B},getBCHDigit:function(w){for(var B=0;w!=0;)B++,w>>>=1;return B},getPatternPosition:function(w){return I.PATTERN_POSITION_TABLE[w-1]},getMask:function(w,B,N){switch(w){case V.PATTERN000:return(B+N)%2==0;case V.PATTERN001:return B%2==0;case V.PATTERN010:return N%3==0;case V.PATTERN011:return(B+N)%3==0;case V.PATTERN100:return(Math.floor(B/2)+Math.floor(N/3))%2==0;case V.PATTERN101:return B*N%2+B*N%3==0;case V.PATTERN110:return(B*N%2+B*N%3)%2==0;case V.PATTERN111:return(B*N%3+(B+N)%2)%2==0;default:throw new Error("bad maskPattern:"+w)}},getErrorCorrectPolynomial:function(w){for(var B=new Y([1],0),N=0;N<w;N++)B=B.multiply(new Y([1,D.gexp(N)],0));return B},getLengthInBits:function(w,B){if(1<=B&&B<10)switch(w){case ie.MODE_NUMBER:return 10;case ie.MODE_ALPHA_NUM:return 9;case ie.MODE_8BIT_BYTE:return 8;case ie.MODE_KANJI:return 8;default:throw new Error("mode:"+w)}else if(B<27)switch(w){case ie.MODE_NUMBER:return 12;case ie.MODE_ALPHA_NUM:return 11;case ie.MODE_8BIT_BYTE:return 16;case ie.MODE_KANJI:return 10;default:throw new Error("mode:"+w)}else if(B<41)switch(w){case ie.MODE_NUMBER:return 14;case ie.MODE_ALPHA_NUM:return 13;case ie.MODE_8BIT_BYTE:return 16;case ie.MODE_KANJI:return 12;default:throw new Error("mode:"+w)}else throw new Error("type:"+B)},getLostPoint:function(w){for(var B=w.getModuleCount(),N=0,M=0;M<B;M++)for(var k=0;k<B;k++){for(var p=0,y=w.isDark(M,k),P=-1;P<=1;P++){if(M+P<0||B<=M+P)continue;for(var L=-1;L<=1;L++){if(k+L<0||B<=k+L)continue;if(P==0&&L==0)continue;y==w.isDark(M+P,k+L)&&p++}}p>5&&(N+=3+p-5)}for(var M=0;M<B-1;M++)for(var k=0;k<B-1;k++){var x=0;w.isDark(M,k)&&x++,w.isDark(M+1,k)&&x++,w.isDark(M,k+1)&&x++,w.isDark(M+1,k+1)&&x++,(x==0||x==4)&&(N+=3)}for(var M=0;M<B;M++)for(var k=0;k<B-6;k++)w.isDark(M,k)&&!w.isDark(M,k+1)&&w.isDark(M,k+2)&&w.isDark(M,k+3)&&w.isDark(M,k+4)&&!w.isDark(M,k+5)&&w.isDark(M,k+6)&&(N+=40);for(var k=0;k<B;k++)for(var M=0;M<B-6;M++)w.isDark(M,k)&&!w.isDark(M+1,k)&&w.isDark(M+2,k)&&w.isDark(M+3,k)&&w.isDark(M+4,k)&&!w.isDark(M+5,k)&&w.isDark(M+6,k)&&(N+=40);for(var S=0,k=0;k<B;k++)for(var M=0;M<B;M++)w.isDark(M,k)&&S++;var d=Math.abs(100*S/B/B-50)/5;return N+=d*10,N}};ht.exports=I},JkjM:function(ht,ot,re){"use strict";re.r(ot);var ie=re("9og8"),Y=re("PpiC"),D=re("WmNS"),V=re.n(D),I=re("q1tI"),w=re.n(I),B=re("Ty5D"),N=re("9kvl"),M=re("14J3"),k=re("BMrR"),p=re("jCWc"),y=re("kPKH"),P=re("+L6B"),L=re("2/Rp"),x=re("k1fw"),S=re("m3rI"),d=re("LO5M"),a=re.n(d),l=re("h+Ho"),h=function(Ue){var Xe,Ze,Ve,rt,we=Ue.user,qe=Ue.forumsDetail,it=Ue.globalSetting,Ae=Ue.loading,Oe=Ue.dispatch,pe=Object(Y.a)(Ue,["user","forumsDetail","globalSetting","loading","dispatch"]),de=qe.forumsDetailData||{},ue=de.author_info,te=de.memo,q=de.recommend_shixuns,ne=function(){var ae=Object(ie.a)(V.a.mark(function ve(){var Le;return V.a.wrap(function(lt){for(;;)switch(lt.prev=lt.next){case 0:if(!(ue!=null&&ue.watched)){lt.next=6;break}return lt.next=3,Object(l.a)({user_id:ue.user_id});case 3:lt.t0=lt.sent,lt.next=9;break;case 6:return lt.next=8,Object(l.o)({user_id:ue.user_id});case 8:lt.t0=lt.sent;case 9:Le=lt.t0,Le&&Oe({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},qe.forumsDetailData),{},{author_info:Object(x.a)(Object(x.a)({},ue),{},{watched:!(ue!=null&&ue.watched)})})});case 11:case"end":return lt.stop()}},ve)}));return function(){return ae.apply(this,arguments)}}();return w.a.createElement("section",{className:a.a.wrap},w.a.createElement("aside",{className:"ml20"},w.a.createElement("div",{className:"bg-white pt40 pb40 pl20 pr20 ".concat(a.a.head)},w.a.createElement("a",{href:"/users/".concat(ue==null?void 0:ue.login),target:"_blank"},(ue==null?void 0:ue.image_url)&&w.a.createElement("img",{src:"".concat(S.a.API_SERVER,"/images/").concat(ue==null?void 0:ue.image_url)})),w.a.createElement("div",{className:"tc font20"},ue==null?void 0:ue.username),w.a.createElement("div",{className:"tc c-grey-999"},ue==null?void 0:ue.identity),((Xe=we.userInfo)===null||Xe===void 0?void 0:Xe.user_id)!==(ue==null?void 0:ue.user_id)&&w.a.createElement(k.a,{justify:"center",className:"mt30 ".concat(a.a.buttonWrap)},w.a.createElement(y.a,null,w.a.createElement(L.a,{type:"primary",className:"mr10",onClick:ne},ue!=null&&ue.watched?"\u53D6\u6D88\u5173\u6CE8":"\u5173\u6CE8")),w.a.createElement(y.a,null,w.a.createElement(L.a,{ghost:!0,className:a.a.privateMessage,href:"/messages/".concat((Ze=we.userInfo)===null||Ze===void 0?void 0:Ze.login,"/message_detail?target_ids=").concat(ue==null?void 0:ue.user_id),target:"_blank"},"\u79C1\u4FE1")))),!!(te!=null&&(Ve=te.tag)!==null&&Ve!==void 0&&Ve.length)&&w.a.createElement("div",{className:"bg-white mt10 pt40 pb40 pl20 pr20"},w.a.createElement("div",{className:"font16"},"\u8BDD\u9898\u6807\u7B7E"),w.a.createElement("div",{className:"mt30 ".concat(a.a.tag)},te==null||((rt=te.tag)===null||rt===void 0)?void 0:rt.map(function(ae){return w.a.createElement("a",null,ae==null?void 0:ae.name)}))),w.a.createElement("div",{className:"pt10 pb10 pl10 pr10"},w.a.createElement("div",{className:"font16 mb20"},"\u63A8\u8350\u5B9E\u8BAD"),w.a.createElement("div",{className:a.a.recommend},q==null?void 0:q.map(function(ae){return w.a.createElement("div",{className:a.a.recommendItem},w.a.createElement("a",{href:"/shixuns/".concat(ae.identifier,"/challenges"),target:"_blank"},w.a.createElement("img",{alt:ae.id,src:"".concat(S.a.API_SERVER,"/").concat(ae.image_url)})),w.a.createElement("div",{className:"".concat(a.a.flex1," ml10")},w.a.createElement("a",{href:"/shixuns/".concat(ae.identifier,"/challenges"),target:"_blank",title:ae.name,className:"".concat(a.a.mWidth147," multi-llipsis1e c-grey-666 mb10")},ae.name),w.a.createElement("div",{className:"c-grey-999"},ae.myshixuns_count," \u4EBA\u5B66\u4E60")))})))))},_=Object(N.a)(function(Ke){var Ue=Ke.user,Xe=Ke.forumsDetail,Ze=Ke.loading,Ve=Ke.globalSetting;return{user:Ue,forumsDetail:Xe,globalSetting:Ve,loading:Ze.models.forumsDetail}})(h),f=re("qVdP"),b=re("jsC+"),R=re("5Dmo"),T=re("3S7+"),g=re("sPJy"),c=re("bE4q"),u=re("lUTK"),o=re("BvKs"),C=re("5NDa"),E=re("5rEg"),v=re("2qtc"),O=re("kLXV"),j=re("miYZ"),G=re("tsqr"),J=re("55Ip"),K=re("wd/R"),F=re.n(K),ee=re("9Bee"),oe=re("oBTY"),he=re("tJVT"),ge=re("Ot1p"),_e=re("/MfK"),be=re("8JLL"),Ee=re.n(be);F.a.lang("ZH-cn");function Te(Ke){var Ue=Ke.user,Xe=Ke.vlist,Ze=Xe===void 0?[]:Xe,Ve=Ke.dispatch,rt=Ke.params,we=Ke.id,qe=Ke.memo_replies,it=Ke.forumsDetail;return w.a.createElement("aside",{className:Ee.a.comment},Ze.map(function(Ae,Oe){var pe,de;return w.a.createElement(k.a,{key:Oe,className:Ee.a.commentItem},w.a.createElement(y.a,{span:24},w.a.createElement(k.a,null,w.a.createElement(y.a,{flex:"1"},w.a.createElement("a",{href:"/users/".concat(Ae.user_login),target:"_blank",className:"c-light-black"},Ae==null?void 0:Ae.username),w.a.createElement("span",{className:"c-light-black ml10"},Ae.time)),(Ae.can_delete||Ae.user_id===((pe=Ue.userInfo)===null||pe===void 0?void 0:pe.user_id)||Ae.user_login===((de=Ue.userInfo)===null||de===void 0?void 0:de.login))&&w.a.createElement(y.a,{className:"forums-comment-delete",style:{display:"none"}},w.a.createElement(T.a,{title:"\u5220\u9664"},w.a.createElement(_e.a,{className:"current",onClick:function(){O.a.confirm({centered:!0,width:530,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u63D0\u793A",content:w.a.createElement("div",{className:"font16 tc"},"\u786E\u5B9A\u8981\u5220\u9664\u8BE5\u6761\u56DE\u590D\u5417\uFF1F"),onOk:function(){var te=Object(ie.a)(V.a.mark(function ne(){var ae,ve;return V.a.wrap(function(Ie){for(;;)switch(Ie.prev=Ie.next){case 0:return Ie.next=2,Object(l.b)({id:Ae.id});case 2:ae=Ie.sent,ve=qe.find(function(lt){return lt.id===we}).children.filter(function(lt){return lt.id!==Ae.id}),qe.find(function(lt){return lt.id===we}).children=ve,Ve({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},it.forumsDetailData),{},{memo_replies:Object(oe.a)(qe)})});case 6:case"end":return Ie.stop()}},ne)}));function q(){return te.apply(this,arguments)}return q}()})}}))))),w.a.createElement(y.a,null,w.a.createElement(ee.a,{value:Ae.content})))}))}var Ce=Te,me=re("1vsH");F.a.lang("ZH-cn");var se=function(Ue,Xe){var Ze=Ue.user,Ve=Ue.forumsDetail,rt=Ue.globalSetting,we=Ue.loading,qe=Ue.dispatch,it=Ue.handleClick,Ae=Object(Y.a)(Ue,["user","forumsDetail","globalSetting","loading","dispatch","handleClick"]),Oe=Ve.forumsDetailData||{},pe=Oe.memo,de=Oe.memo_replies,ue=Object(B.i)(),te=Object(I.useState)(""),q=Object(he.a)(te,2),ne=q[0],ae=q[1],ve=Object(I.useState)(""),Le=Object(he.a)(ve,2),Ie=Le[0],lt=Le[1],Rt=Object(I.useState)(-1),Pe=Object(he.a)(Rt,2),xt=Pe[0],mt=Pe[1],He=Object(I.useState)(!1),Tt=Object(he.a)(He,2),yt=Tt[0],kt=Tt[1],Lt=Object(I.useState)(1),Et=Object(he.a)(Lt,2),sr=Et[0],Xt=Et[1],gt=Object(I.useState)(!1),ir=Object(he.a)(gt,2),pr=ir[0],lr=ir[1];Object(I.useImperativeHandle)(Xe,function(){return{onMdFouch:Ur}}),Object(I.useEffect)(function(){kt((pe==null?void 0:pe.replies_count)>10)},[pe==null?void 0:pe.replies_count]);var wr=function(){var ct=Object(ie.a)(V.a.mark(function ut(){var qt,jt,Nt;return V.a.wrap(function(zt){for(;;)switch(zt.prev=zt.next){case 0:return qt=sr+1,Xt(qt),zt.next=4,Object(l.h)({id:ue.memoId,page:qt});case 4:jt=zt.sent,jt!=null&&jt.memo_replies&&(qe({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},Ve.forumsDetailData),{},{memo_replies:[].concat(Object(oe.a)(de),Object(oe.a)(jt.memo_replies))})}),kt(((Nt=jt.memo_replies)===null||Nt===void 0?void 0:Nt.length)===10));case 6:case"end":return zt.stop()}},ut)}));return function(){return ct.apply(this,arguments)}}(),$r=function(ut){var qt,jt,Nt,Ot;return Object(x.a)(Object(x.a)({},ut),{},{image_url:(qt=Ze.userInfo)===null||qt===void 0?void 0:qt.image_url,children:[],user_id:(jt=Ze.userInfo)===null||jt===void 0?void 0:jt.user_id,user_login:(Nt=Ze.userInfo)===null||Nt===void 0?void 0:Nt.login,username:(Ot=Ze.userInfo)===null||Ot===void 0?void 0:Ot.username,time:"".concat(Object(me.Z)((new Date().getTime()-new Date(ut.created_at).getTime())/1e3),"\u524D")})},Ur=function(){lr(!0)};return w.a.createElement("section",{className:Ee.a.wrap},!!(de!=null&&de.length)&&w.a.createElement("aside",{className:Ee.a.content},w.a.createElement("div",{style:{padding:"10px 15px 5px 15px",justifyContent:"space-between",display:"flex"}},w.a.createElement("span",null,"\u5168\u90E8\u56DE\u590D\uFF08",pe.replies_count,"\uFF09")),w.a.createElement("aside",{className:Ee.a.replyList},de==null?void 0:de.map(function(ct,ut){var qt;return w.a.createElement(k.a,{gutter:[12,12],key:ut},w.a.createElement(y.a,{flex:"40px"},w.a.createElement("a",{href:"/users/".concat(ct.user_login),target:"_blank"},w.a.createElement("img",{alt:"\u7528\u6237\u5934\u50CF",width:"50",height:"50",src:"".concat(S.a.IMG_SERVER,"/images/").concat(ct==null?void 0:ct.image_url)}))),w.a.createElement(y.a,{flex:"1"},w.a.createElement(k.a,{align:"middle"},w.a.createElement(y.a,{span:24},w.a.createElement("a",{href:"/users/".concat(ct.user_login),target:"_blank"},w.a.createElement("span",{className:"c-light-black"},ct==null?void 0:ct.username)),w.a.createElement("span",{className:"c-light-black ml10"},ct.time)),w.a.createElement(y.a,{span:24},w.a.createElement("div",{onClick:it},w.a.createElement(ee.a,{value:ct.content}))),!!(ct!=null&&(qt=ct.children)!==null&&qt!==void 0&&qt.length)&&w.a.createElement(Ce,{user:Ze,id:ct==null?void 0:ct.id,vlist:ct==null?void 0:ct.children,dispatch:qe,params:ue,memo_replies:de,forumsDetail:Ve}),w.a.createElement(y.a,{span:24,className:"mt5 c-light-black"},xt===ut?w.a.createElement("aside",null,w.a.createElement(ge.a,{onChange:function(Nt){lt(Nt)},height:150,isFocus:!0,placeholder:"\u6211\u8981\u56DE\u590D..."}),w.a.createElement(k.a,null,w.a.createElement(y.a,{span:24,className:"tr"},w.a.createElement(L.a,{type:"primary",size:"large",onClick:Object(ie.a)(V.a.mark(function jt(){var Nt;return V.a.wrap(function(zt){for(;;)switch(zt.prev=zt.next){case 0:if(!(Ie==="")){zt.next=4;break}G.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),zt.next=9;break;case 4:return zt.next=6,Object(l.k)({parent_id:ct.id,content:Ie});case 6:Nt=zt.sent,lt(null),Nt&&(mt(-1),de.find(function(Rr){return Rr.id===Nt.parent_id}).children.push($r(Nt)),qe({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},Ve.forumsDetailData),{},{memo:Object(x.a)(Object(x.a)({},pe),{},{replies_count:pe.replies_count+1}),memo_replies:Object(oe.a)(de)})}));case 9:case"end":return zt.stop()}},jt)}))},"\u53D1\u9001")))):w.a.createElement("div",{className:"tr"},w.a.createElement("span",{className:"iconfont icon-huifu1 mr15 ml30 current",onClick:function(){return mt(ut)}}),w.a.createElement(T.a,{title:ct.user_praise?"\u53D6\u6D88\u70B9\u8D5E":"\u70B9\u8D5E"},w.a.createElement("span",{className:ct.user_praise?"c-orange":"c-gery-888"},w.a.createElement("i",{className:"iconfont icon-dianzan mr3 current",onClick:Object(ie.a)(V.a.mark(function jt(){var Nt;return V.a.wrap(function(zt){for(;;)switch(zt.prev=zt.next){case 0:return zt.next=2,Object(l.i)({id:ct.id,container_type:"Memo",type:ct.user_praise?0:1});case 2:Nt=zt.sent,(Nt==null?void 0:Nt.praise_count)>=0&&(de.find(function(Rr){return Rr.id===ct.id}).user_praise=!ct.user_praise,de.find(function(Rr){return Rr.id===ct.id}).praise_count=Nt==null?void 0:Nt.praise_count,qe({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},Ve.forumsDetailData),{},{memo_replies:Object(oe.a)(de)})}));case 4:case"end":return zt.stop()}},jt)}))}),ct.praise_count>0?ct.praise_count:"")))))))}))),yt&&w.a.createElement("aside",{className:"bg-white pb20",style:{display:"flex",justifyContent:"center"}},w.a.createElement(k.a,{justify:"space-between"},w.a.createElement(y.a,null),w.a.createElement(y.a,null,yt&&w.a.createElement("a",{className:"c-black",onClick:wr},"\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA")))),w.a.createElement("aside",{className:Ee.a.reply},w.a.createElement(ge.a,{onBlur:function(){return lr(!1)},isFocus:pr,defaultValue:ne,id:"writeForumsReviewId",onChange:function(ut){ae(ut)},placeholder:"\u6211\u8981\u56DE\u590D...",height:240}),w.a.createElement(k.a,null,w.a.createElement(y.a,{flex:"1"}),w.a.createElement(y.a,null,w.a.createElement(L.a,{type:"primary",size:"large",onClick:Object(ie.a)(V.a.mark(function ct(){var ut;return V.a.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:if(!(ne==="")){jt.next=4;break}G.b.error("\u8BF7\u8F93\u5165\u5185\u5BB9"),jt.next=9;break;case 4:return jt.next=6,Object(l.k)({parent_id:pe.id,content:ne});case 6:ut=jt.sent,ae(null),ut&&qe({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},Ve.forumsDetailData),{},{memo:Object(x.a)(Object(x.a)({},pe),{},{replies_count:pe.replies_count+1}),memo_replies:[$r(ut)].concat(Object(oe.a)(de))})});case 9:case"end":return jt.stop()}},ct)}))},"\u53D1\u9001")))))},Re=Object(N.a)(function(Ke){var Ue=Ke.user,Xe=Ke.forumsDetail,Ze=Ke.loading,Ve=Ke.globalSetting;return{user:Ue,forumsDetail:Xe,globalSetting:Ve,loading:Ze.models.forumsDetail}},null,null,{forwardRef:!0})(Object(I.forwardRef)(se)),et=re("smFo"),Ge=re.n(et),tt=re("RCxd"),Ye=re("kaH+"),De=re("dhSg"),je={5:"\u6280\u672F\u5206\u4EAB",3:"\u64CD\u4F5C\u6307\u5357",16:"\u901A\u77E5\u516C\u544A"},$e=function(Ue){var Xe,Ze,Ve,rt,we,qe=Ue.user,it=Ue.forumsDetail,Ae=Ue.globalSetting,Oe=Ue.loading,pe=Ue.dispatch,de=Object(Y.a)(Ue,["user","forumsDetail","globalSetting","loading","dispatch"]),ue=it.forumsDetailData||{},te=ue.author_info,q=ue.memo,ne=ue.attachments_list,ae=Object(I.useRef)(),ve=Object(I.useRef)(),Le=function(){var He=Object(ie.a)(V.a.mark(function Tt(){var yt,kt;return V.a.wrap(function(Et){for(;;)switch(Et.prev=Et.next){case 0:return yt={id:q.id,sticky:q.sticky?0:1},Et.next=3,Object(l.m)(yt);case 3:kt=Et.sent,(kt==null?void 0:kt.status)===0&&pe({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},it.forumsDetailData),{},{memo:Object(x.a)(Object(x.a)({},q),{},{sticky:!(q!=null&&q.sticky)})})});case 5:case"end":return Et.stop()}},Tt)}));return function(){return He.apply(this,arguments)}}(),Ie=function(){var He=Object(ie.a)(V.a.mark(function Tt(){var yt;return V.a.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:return Lt.next=2,Object(l.b)({id:q==null?void 0:q.id});case 2:yt=Lt.sent,(yt==null?void 0:yt.status)===0&&(G.b.success("\u5220\u9664\u6210\u529F"),N.d.push("/forums")),(yt==null?void 0:yt.status)===-1&&N.d.push("/forums");case 5:case"end":return Lt.stop()}},Tt)}));return function(){return He.apply(this,arguments)}}(),lt=function(){var He=Object(ie.a)(V.a.mark(function Tt(){return V.a.wrap(function(kt){for(;;)switch(kt.prev=kt.next){case 0:O.a.confirm({centered:!0,width:530,okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88",title:"\u5956\u52B1\u8BBE\u7F6E",content:w.a.createElement("div",{className:"font14 tc"},w.a.createElement(E.a,{defaultValue:ae.current,onChange:function(Et){return ae.current=Et.target.value}})),onOk:function(){var Lt=Object(ie.a)(V.a.mark(function sr(){var Xt;return V.a.wrap(function(ir){for(;;)switch(ir.prev=ir.next){case 0:return ir.next=2,Object(l.l)({id:q==null?void 0:q.id,container_type:"Memo",score:ae.current?Number(ae.current):0,user_id:te==null?void 0:te.user_id});case 2:if(Xt=ir.sent,ae.current=null,!((Xt==null?void 0:Xt.code)>0)){ir.next=8;break}return pe({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},it.forumsDetailData),{},{memo:Object(x.a)(Object(x.a)({},q),{},{reward:Xt==null?void 0:Xt.code})})}),G.b.success("\u5956\u52B1\u6210\u529F"),ir.abrupt("return");case 8:G.b.success("\u5956\u52B1\u5931\u8D25\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\uFF01");case 9:case"end":return ir.stop()}},sr)}));function Et(){return Lt.apply(this,arguments)}return Et}()});case 1:case"end":return kt.stop()}},Tt)}));return function(){return He.apply(this,arguments)}}(),Rt=function(){ve.current.onMdFouch&&ve.current.onMdFouch()},Pe=function(){var He=Object(ie.a)(V.a.mark(function Tt(){var yt;return V.a.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:return Lt.next=2,Object(l.i)({id:q.id,container_type:"Memo",type:1});case 2:yt=Lt.sent,(yt==null?void 0:yt.praise_count)>=0&&pe({type:"forumsDetail/setForumsDetailData",payload:Object(x.a)(Object(x.a)({},it.forumsDetailData),{},{memo:Object(x.a)(Object(x.a)({},q),{},{user_praise:!(q!=null&&q.user_praise),memo_praise_count:yt==null?void 0:yt.praise_count})})});case 4:case"end":return Lt.stop()}},Tt)}));return function(){return He.apply(this,arguments)}}(),xt=w.a.createElement(o.a,{className:Ge.a.menu},((Xe=qe.userInfo)===null||Xe===void 0?void 0:Xe.admin)&&(q==null?void 0:q.sticky)&&w.a.createElement(o.a.Item,null,w.a.createElement("a",{onClick:function(){return Le()}},"\u53D6\u6D88\u7F6E\u9876")),((Ze=qe.userInfo)===null||Ze===void 0?void 0:Ze.admin)&&!(q!=null&&q.sticky)&&w.a.createElement(o.a.Item,null,w.a.createElement("a",{onClick:function(){return Le()}},"\u7F6E\xA0\xA0\u9876")),w.a.createElement(o.a.Item,null,w.a.createElement(J.a,{to:"/forums/".concat(q==null?void 0:q.id,"/edit")},"\u7F16\xA0\xA0\u8F91")),w.a.createElement(o.a.Item,null,w.a.createElement("a",{onClick:function(){O.a.confirm({title:"\u63D0\u793A",icon:w.a.createElement(tt.a,null),content:"\u5E16\u5B50\u5C06\u88AB\u5220\u9664\uFF0C\u65E0\u6CD5\u6062\u590D\u3002\u662F\u5426\u786E\u8BA4\u5220\u9664\uFF1F",okText:"\u786E\u8BA4",onOk:function(){Ie()},cancelText:"\u53D6\u6D88"})}},"\u5220\xA0\xA0\u9664"))),mt=function(Tt){var yt=Tt.target,kt=yt.nodeName,Lt=yt.src;kt==="IMG"&&(De.a.publish("preview-image",Lt),console.log("src:",Lt))};return Object(I.useEffect)(function(){},[]),w.a.createElement("section",{className:Ge.a.wrap},w.a.createElement(c.a,{separator:"/",className:"mb5"},w.a.createElement(c.a.Item,null,w.a.createElement(J.a,{to:"/forums/categories/".concat(q==null?void 0:q.forum_id)},je[q==null?void 0:q.forum_id])),w.a.createElement(c.a.Item,null,"\u8BE6\u60C5")),w.a.createElement("header",{className:"bg-white pt40 pb40 pl30 pr30 ".concat(Ge.a.header)},w.a.createElement(k.a,{align:"middle"},w.a.createElement(y.a,{flex:1,className:"font24 mb5"},w.a.createElement("span",{className:Ge.a.title},q==null?void 0:q.subject),(q==null?void 0:q.sticky)&&w.a.createElement("span",{className:Ge.a.top},"\u7F6E\u9876"),!!(q!=null&&q.reward)&&w.a.createElement(T.a,{placement:"bottom",title:"\u83B7\u5F97\u5E73\u53F0\u5956\u52B1\u91D1\u5E01\uFF1A".concat(q==null?void 0:q.reward)},w.a.createElement("span",{className:"ml10 c-orange-ff7"},w.a.createElement("i",{className:"iconfont icon-gift font16 mr5"}),w.a.createElement("span",{className:"font14"},q==null?void 0:q.reward)))),w.a.createElement(y.a,null,(((Ve=qe.userInfo)===null||Ve===void 0?void 0:Ve.admin)||((rt=qe.userInfo)===null||rt===void 0?void 0:rt.user_id)===(te==null?void 0:te.user_id))&&w.a.createElement(b.a,{overlay:xt},w.a.createElement("i",{className:"fa fa-bars font-16 current c-grey-bcb"})))),w.a.createElement(k.a,{align:"middle",className:"font14"},w.a.createElement(y.a,{flex:1,className:"c-grey-999"},w.a.createElement("span",null,F()(q==null?void 0:q.time).fromNow()," \u53D1\u5E03")),w.a.createElement(y.a,{className:"c-grey-999"},((we=qe.userInfo)===null||we===void 0?void 0:we.admin)&&w.a.createElement(T.a,{placement:"bottom",title:"\u5E16\u5B50\u5956\u52B1"},w.a.createElement("span",{className:"current pr10 ".concat(Ge.a.line),onClick:lt},w.a.createElement("i",{className:"iconfont icon-jiangli font18 mr5"}))),w.a.createElement("span",{className:"pr10 pl10 ".concat(q!=null&&q.replies_count?Ge.a.line:"")},w.a.createElement("i",{className:"iconfont icon-liulanyan font18 mr5"}),q==null?void 0:q.viewed_count),!!(q!=null&&q.replies_count)&&w.a.createElement(T.a,{placement:"bottom",title:"\u5199\u8BC4\u8BBA"},w.a.createElement("span",{className:"current pl10",onClick:Rt},w.a.createElement("i",{className:"iconfont icon-huifu1 font18 mr5"}),q==null?void 0:q.replies_count))))),w.a.createElement("main",{className:"bg-white pt40 pb40 pl40 pr40"},w.a.createElement("div",{onClick:mt},w.a.createElement(ee.a,{value:q==null?void 0:q.content})),w.a.createElement("div",{className:"bg-white pl40 pr40 mt40"},w.a.createElement("div",{className:"mt10 mb20 ".concat(Ge.a.flexCenter)},w.a.createElement("div",{className:"".concat(Ge.a.like," ").concat(q!=null&&q.user_praise?"":Ge.a.canLike),onClick:Pe},w.a.createElement("i",{className:"iconfont icon-dianzan font18"}),w.a.createElement("br",null),w.a.createElement("span",null,q==null?void 0:q.memo_praise_count)))),!!(ne!=null&&ne.length)&&w.a.createElement("div",{className:"mt40"},ne==null?void 0:ne.map(function(He){return w.a.createElement("div",{className:"c-grey-888 ".concat(Ge.a.flexCenter)},w.a.createElement("i",{className:"iconfont icon-fujian mr10 font14 c-green-29b"}),w.a.createElement("a",{href:He==null?void 0:He.url,title:He==null?void 0:He.title,className:"".concat(Ge.a.attachmentName," mr10")},He==null?void 0:He.title),w.a.createElement("span",{className:"font12 c-grey-666 mt3"},He==null?void 0:He.filesize))}))),w.a.createElement(Re,{ref:ve,handleClick:mt}),w.a.createElement(Ye.a,null))},st=Object(N.a)(function(Ke){var Ue=Ke.user,Xe=Ke.forumsDetail,Ze=Ke.loading,Ve=Ke.globalSetting;return{user:Ue,forumsDetail:Xe,globalSetting:Ve,loading:Ze.effects}})($e),Qe=re("G8my"),Be=re.n(Qe),We=function(Ue){var Xe=Ue.forumsDetail,Ze=Ue.globalSetting,Ve=Ue.loading,rt=Ue.dispatch,we=Object(Y.a)(Ue,["forumsDetail","globalSetting","loading","dispatch"]),qe=Object(B.i)();Object(I.useEffect)(function(){it()},[qe.memoId]);var it=function(){var Ae=Object(ie.a)(V.a.mark(function Oe(){return V.a.wrap(function(de){for(;;)switch(de.prev=de.next){case 0:rt({type:"forumsDetail/getForumsDetailData",payload:{id:qe.memoId}});case 1:case"end":return de.stop()}},Oe)}));return function(){return Ae.apply(this,arguments)}}();return w.a.createElement("section",{className:"edu-container mb20 mt30 ".concat(Be.a.flex)},w.a.createElement(st,null),w.a.createElement(_,null))},ft=ot.default=Object(N.a)(function(Ke){var Ue=Ke.forumsDetail,Xe=Ke.loading,Ze=Ke.globalSetting;return{forumsDetail:Ue,globalSetting:Ze,loading:Xe.models.forumsDetail}})(We)},LO5M:function(ht,ot,re){ht.exports={wrap:"wrap___1d4rP",head:"head___1_Uzf",recommendItem:"recommendItem___IStR9",buttonWrap:"buttonWrap___3dpFm",privateMessage:"privateMessage___24GfS",flex1:"flex1___3wIqQ",mWidth147:"mWidth147___3ODny"}},LdHM:function(ht,ot,re){"use strict";re.d(ot,"b",function(){return h}),re.d(ot,"a",function(){return f});var ie=re("1OyB"),Y=re("vuIU"),D=re("Ji7U"),V=re("LK+K"),I=re("q1tI"),w=re("rePB"),B=re("Ff2n"),N=re("ODXe"),M=re("4IlW"),k=re("bX4T"),p=re("YrtM"),y=re("TSYQ"),P=re.n(y),L=re("+nKL"),x=re("8OUc"),S=function(ee,oe){var he=ee.prefixCls,ge=ee.id,_e=ee.flattenOptions,be=ee.childrenAsData,Ee=ee.values,Te=ee.searchValue,Ce=ee.multiple,me=ee.defaultActiveFirstOption,se=ee.height,Re=ee.itemHeight,et=ee.notFoundContent,Ge=ee.open,tt=ee.menuItemSelectedIcon,Ye=ee.virtual,De=ee.onSelect,je=ee.onToggleOpen,$e=ee.onActiveValue,st=ee.onScroll,Qe=ee.onMouseEnter,Be="".concat(he,"-item"),We=Object(p.a)(function(){return _e},[Ge,_e],function(Oe,pe){return pe[0]&&Oe[1]!==pe[1]}),ft=I.useRef(null),Ke=function(pe){pe.preventDefault()},Ue=function(pe){ft.current&&ft.current.scrollTo({index:pe})},Xe=function(pe){for(var de=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,ue=We.length,te=0;te<ue;te+=1){var q=(pe+te*de+ue)%ue,ne=We[q],ae=ne.group,ve=ne.data;if(!ae&&!ve.disabled)return q}return-1},Ze=I.useState(function(){return Xe(0)}),Ve=Object(N.a)(Ze,2),rt=Ve[0],we=Ve[1],qe=function(pe){we(pe);var de=We[pe];if(!de){$e(null,-1);return}$e(de.data.value,pe)};I.useEffect(function(){qe(me!==!1?Xe(0):-1)},[We.length,Te]),I.useEffect(function(){var Oe=setTimeout(function(){if(!Ce&&Ge&&Ee.size===1){var pe=Array.from(Ee)[0],de=We.findIndex(function(ue){var te=ue.data;return te.value===pe});qe(de),Ue(de)}});return function(){return clearTimeout(Oe)}},[Ge]);var it=function(pe){pe!==void 0&&De(pe,{selected:!Ee.has(pe)}),Ce||je(!1)};if(I.useImperativeHandle(oe,function(){return{onKeyDown:function(pe){var de=pe.which;switch(de){case M.a.UP:case M.a.DOWN:{var ue=0;if(de===M.a.UP?ue=-1:de===M.a.DOWN&&(ue=1),ue!==0){var te=Xe(rt+ue,ue);Ue(te),qe(te)}break}case M.a.ENTER:{var q=We[rt];q&&!q.data.disabled?it(q.data.value):it(void 0),Ge&&pe.preventDefault();break}case M.a.ESC:je(!1)}},onKeyUp:function(){},scrollTo:function(pe){Ue(pe)}}}),We.length===0)return I.createElement("div",{role:"listbox",id:"".concat(ge,"_list"),className:"".concat(Be,"-empty"),onMouseDown:Ke},et);function Ae(Oe){var pe=We[Oe];if(!pe)return null;var de=pe.data||{},ue=de.value,te=de.label,q=de.children,ne=Object(k.a)(de,!0),ae=be?q:te;return pe?I.createElement("div",Object.assign({"aria-label":typeof ae=="string"?ae:null},ne,{key:Oe,role:"option",id:"".concat(ge,"_list_").concat(Oe),"aria-selected":Ee.has(ue)}),ue):null}return I.createElement(I.Fragment,null,I.createElement("div",{role:"listbox",id:"".concat(ge,"_list"),style:{height:0,width:0,overflow:"hidden"}},Ae(rt-1),Ae(rt),Ae(rt+1)),I.createElement(L.a,{itemKey:"key",ref:ft,data:We,height:se,itemHeight:Re,fullHeight:!1,onMouseDown:Ke,onScroll:st,virtual:Ye,onMouseEnter:Qe},function(Oe,pe){var de,ue=Oe.group,te=Oe.groupOption,q=Oe.data,ne=q.label,ae=q.key;if(ue)return I.createElement("div",{className:P()(Be,"".concat(Be,"-group"))},ne!==void 0?ne:ae);var ve=q.disabled,Le=q.value,Ie=q.title,lt=q.children,Rt=q.style,Pe=q.className,xt=Object(B.a)(q,["disabled","value","title","children","style","className"]),mt=Ee.has(Le),He="".concat(Be,"-option"),Tt=P()(Be,He,Pe,(de={},Object(w.a)(de,"".concat(He,"-grouped"),te),Object(w.a)(de,"".concat(He,"-active"),rt===pe&&!ve),Object(w.a)(de,"".concat(He,"-disabled"),ve),Object(w.a)(de,"".concat(He,"-selected"),mt),de)),yt=be?lt:ne,kt=!tt||typeof tt=="function"||mt;return I.createElement("div",Object.assign({},xt,{"aria-selected":mt,className:Tt,title:Ie,onMouseMove:function(){if(rt===pe||ve)return;qe(pe)},onClick:function(){ve||it(Le)},style:Rt}),I.createElement("div",{className:"".concat(He,"-content")},yt||Le),I.isValidElement(tt)||mt,kt&&I.createElement(x.a,{className:"".concat(Be,"-option-state"),customizeIcon:tt,customizeIconProps:{isSelected:mt}},mt?"\u2713":null))}))},d=I.forwardRef(S);d.displayName="OptionList";var a=d,l=function(){return null};l.isSelectOption=!0;var h=l,_=function(){return null};_.isSelectOptGroup=!0;var f=_,b=re("VTBJ"),R=re("Zm9Q");function T(F){var ee=F.key,oe=F.props,he=oe.children,ge=oe.value,_e=Object(B.a)(oe,["children","value"]);return Object(b.a)({key:ee,value:ge!==void 0?ge:ee,children:he},_e)}function g(F){var ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return Object(R.a)(F).map(function(oe,he){if(!I.isValidElement(oe)||!oe.type)return null;var ge=oe.type.isSelectOptGroup,_e=oe.key,be=oe.props,Ee=be.children,Te=Object(B.a)(be,["children"]);return ee||!ge?T(oe):Object(b.a)(Object(b.a)({key:"__RC_SELECT_GRP__".concat(_e===null?he:_e,"__"),label:_e},Te),{},{options:g(Ee)})}).filter(function(oe){return oe})}var c=re("2Qr1"),u=re("qNPg"),o=re("U8pU"),C=re("Kwbf"),E=re("WKfj");function v(F){var ee=F.mode,oe=F.options,he=F.children,ge=F.backfill,_e=F.allowClear,be=F.placeholder,Ee=F.getInputElement,Te=F.showSearch,Ce=F.onSearch,me=F.defaultOpen,se=F.autoFocus,Re=F.labelInValue,et=F.value,Ge=F.inputValue,tt=F.optionLabelProp,Ye=ee==="multiple"||ee==="tags",De=Te!==void 0?Te:Ye||ee==="combobox",je=oe||g(he);if(Object(C.a)(ee!=="tags"||je.every(function(Be){return!Be.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),ee==="tags"||ee==="combobox"){var $e=je.some(function(Be){return Be.options?Be.options.some(function(We){return typeof("value"in We?We.value:We.key)=="number"}):typeof("value"in Be?Be.value:Be.key)=="number"});Object(C.a)(!$e,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(Object(C.a)(ee!=="combobox"||!tt,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),Object(C.a)(ee==="combobox"||!ge,"`backfill` only works with `combobox` mode."),Object(C.a)(ee==="combobox"||!Ee,"`getInputElement` only work with `combobox` mode."),Object(C.b)(ee!=="combobox"||!Ee||!_e||!be,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),Ce&&!De&&ee!=="combobox"&&ee!=="tags"&&Object(C.a)(!1,"`onSearch` should work with `showSearch` instead of use alone."),Object(C.b)(!me||se,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),et!=null){var st=Object(E.d)(et);Object(C.a)(!Re||st.every(function(Be){return Object(o.a)(Be)==="object"&&("key"in Be||"value"in Be)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),Object(C.a)(!Ye||Array.isArray(et),"`value` should be array when `mode` is `multiple` or `tags`")}if(he){var Qe=null;Object(R.a)(he).some(function(Be){if(!I.isValidElement(Be)||!Be.type)return!1;var We=Be.type;if(We.isSelectOption)return!1;if(We.isSelectOptGroup){var ft=Object(R.a)(Be.props.children).every(function(Ke){return!I.isValidElement(Ke)||!Be.type||Ke.type.isSelectOption?!0:(Qe=Ke.type,!1)});return!ft}return Qe=We,!0}),Qe&&Object(C.a)(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(Qe.displayName||Qe.name||Qe,"`.")),Object(C.a)(Ge===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}var O=v,j=Object(u.a)({prefixCls:"rc-select",components:{optionList:a},convertChildrenToData:g,flattenOptions:c.d,getLabeledValue:c.e,filterOptions:c.b,isValueDisabled:c.g,findValueOption:c.c,warningProps:O,fillOptionsWithMissingValue:c.a}),G=function(F){Object(D.a)(oe,F);var ee=Object(V.a)(oe);function oe(){var he;return Object(ie.a)(this,oe),he=ee.apply(this,arguments),he.selectRef=I.createRef(),he.focus=function(){he.selectRef.current.focus()},he.blur=function(){he.selectRef.current.blur()},he}return Object(Y.a)(oe,[{key:"render",value:function(){return I.createElement(j,Object.assign({ref:this.selectRef},this.props))}}]),oe}(I.Component);G.Option=h,G.OptGroup=f;var J=G,K=ot.c=J},M8RZ:function(ht,ot,re){"use strict";re.d(ot,"a",function(){return M});var ie=re("fWQN"),Y=re("mtLc"),D=re("yKVA"),V=re("879j"),I=re("q1tI"),w=re.n(I),B=re("i8i4"),N=re.n(B),M=function(k){Object(D.a)(y,k);var p=Object(V.a)(y);function y(P){var L;Object(ie.a)(this,y),L=p.call(this,P);var x=window.document;return L.node=x.createElement("div"),x.body.appendChild(L.node),L}return Object(Y.a)(y,[{key:"render",value:function(){var L=this.props.children;return Object(B.createPortal)(L,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),y}(w.a.Component)},Ot1p:function(ht,ot,re){"use strict";var ie=re("2qtc"),Y=re("kLXV"),D=re("rAM+"),V=re("miYZ"),I=re("tsqr"),w=re("9og8"),B=re("tJVT"),N=re("jrin"),M=re("WmNS"),k=re.n(M),p=re("q1tI"),y=re.n(p),P=re("VrN/"),L=re.n(P),x=re("bdgK"),S=re("p77/"),d=re("Bd2K"),a=re("ELLl"),l=re("19Vz"),h=re("lZu9"),_=re("+NIl"),f=re("kSUc"),b=re("9Bee"),R=function(Pe){var xt=Pe.value,mt=xt===void 0?"":xt,He=Pe.className,Tt=Pe.showTextOnly,yt=Pe.showLines,kt=Pe.style,Lt=kt===void 0?{}:kt,Et=Object(p.useMemo)(function(){return""},[mt]);return y.a.createElement(y.a.Fragment,null,y.a.createElement("div",{dangerouslySetInnerHTML:{__html:Et}}))},T=re("Q9mQ"),g=re("diRs"),c=re("0Owb"),u=re("dejd"),o=re("C+DQ"),C=re("D1Df"),E=re.n(C),v=re("1vsH"),O=re("m3rI"),j=[{title:"\u7C97\u4F53",icon:"icon-bold",actionName:"bold"},{title:"\u659C\u4F53",icon:"icon-italic",actionName:"italic"},"|",{title:"\u65E0\u5E8F\u5217\u8868",icon:"icon-unorder-list",actionName:"list-ul"},{title:"\u6709\u5E8F\u5217\u8868",icon:"icon-order-list",actionName:"list-ol"},"|",{title:"\u884C\u5185\u4EE3\u7801",icon:"icon-code",actionName:"code"},{title:"\u4EE3\u7801\u5757\uFF08\u591A\u8BED\u8A00\u98CE\u683C\uFF09",icon:"icon-file-code",actionName:"code-block"},{title:"\u94FE\u63A5",icon:"icon-link",actionName:"link"},"|",{title:"\u884C\u5185\u516C\u5F0F",icon:"icon-sum",actionName:"inline-latex"},{title:"\u591A\u884C\u516C\u5F0F",icon:"icon-formula",actionName:"latex"},"|",{title:"\u6DFB\u52A0\u56FE\u7247",icon:"icon-picture",actionName:"upload-image"},{title:"\u8868\u683C",icon:"icon-table",actionName:"add-table"},"|",{title:"\u6362\u884C",icon:"icon-minus",actionName:"line-break"},{title:"\u6E05\u7A7A",icon:"icon-eraser",actionName:"eraser"}];function G(Pe){var xt=Pe.onActionCallback,mt=Pe.title,He=Pe.icon,Tt=Pe.actionName,yt=Pe.className,kt=yt===void 0?"":yt,Lt=Pe.children;function Et(){xt(Tt)}return y.a.createElement("a",{title:mt,className:kt,onClick:Et},y.a.createElement("i",{className:"md-iconfont ".concat(He)}),Lt)}var J=function(Pe){var xt=Pe.watch,mt=Pe.showNullButton,He=Pe.onActionCallback,Tt=Pe.fullScreen,yt=Pe.insertTemp,kt=Pe.hidetoolBar,Lt=Pe.uuid,Et=Pe.setOpenPhones;console.log("link:","".concat(location.origin,"/upload.html?_educoder_session_login=").concat(Object(v.E)("_educoder_session_login"),"&_educoder_session=").concat(Object(v.E)("_educoder_session"),"&key=").concat(Lt,"&api=").concat(encodeURIComponent(O.a.PROXY_SERVER)));var sr=[].concat(j,[{title:"".concat(xt?"\u5173\u95ED\u5B9E\u65F6\u9884\u89C8":"\u5F00\u542F\u5B9E\u65F6\u9884\u89C8"),icon:"".concat(xt?"icon-eye-slash":"icon-eye"),actionName:"trigger-watch"}]);return y.a.createElement("ul",{className:"markdown-toolbar-container"},!kt&&sr.map(function(Xt,gt){return y.a.createElement("li",{key:gt},Xt.actionName?y.a.createElement(G,Object(c.a)({},Xt,{onActionCallback:He})):y.a.createElement("span",{className:"v-line"}))}),mt?y.a.createElement("li",null,y.a.createElement(G,{icon:"icon-edit",className:"btn-null",title:"\u589E\u52A0\u586B\u7A7A",actionName:"add-null-ch",onActionCallback:He},y.a.createElement("span",{className:"fill-tip"},"\u70B9\u51FB\u63D2\u5165\b\u586B\u7A7A\u9879"))):null,yt&&y.a.createElement("li",null,y.a.createElement(G,{icon:"icon-edit",className:"btn-null",title:"\u63D2\u5165\u6A21\u677F",actionName:"inster-template-".concat(yt),onActionCallback:He},y.a.createElement("span",{className:"fill-tip"},"\u63D2\u5165\u6A21\u677F"))),y.a.createElement("li",null,y.a.createElement(g.a,{title:"\u6253\u5F00\u624B\u673A\u626B\u4E00\u626B",content:y.a.createElement("div",null,y.a.createElement(E.a,{size:150,fgColor:"#000",value:"https://test2.educoder.net/upload.html?_educoder_session_login=".concat(Object(v.E)("_educoder_session_login"),"&_educoder_session=").concat(Object(v.E)("_educoder_session"),"&key=").concat(Lt,"&api=").concat(encodeURIComponent(O.a.PROXY_SERVER))}))},y.a.createElement("span",{className:"fill-tip",onMouseOver:function(){return Et(!0)}},"\u624B\u673A\u4E0A\u4F20\u6587\u4EF6"))),y.a.createElement("li",{className:"btn-full-screen"},y.a.createElement(G,{icon:"".concat(Tt?"icon-shrink":"icon-enlarge"),title:Tt?"\u5173\u95ED\u5168\u5C4F":"\u5F00\u542F\u5168\u5C4F",actionName:"trigger-full-screen",onActionCallback:He})))},K=re("M8RZ"),F=re("+L6B"),ee=re("2/Rp"),oe=re("y8nQ"),he=re("Vl3Y"),ge=re("5NDa"),_e=re("5rEg"),be={labelCol:{span:4},wrapperCol:{span:20}},Ee=function(Pe){var xt=Pe.callback,mt=Pe.onCancel;function He(Tt){xt(Tt)}return y.a.createElement(he.a,Object(c.a)({},be,{initialValues:{link:"http://",title:""},className:"link-panel",onFinish:He}),y.a.createElement(he.a.Item,{label:"\u94FE\u63A5\u5730\u5740",name:"link",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740"}]},y.a.createElement(_e.a,null)),y.a.createElement(he.a.Item,{label:"\u94FE\u63A5\u6807\u9898",name:"title",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u94FE\u63A5\u6807\u9898"}]},y.a.createElement(_e.a,null)),y.a.createElement("div",{className:"flex-container flex-end"},y.a.createElement(ee.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement(ee.a,{type:"ghost",onClick:mt},"\u53D6\u6D88")))},Te=re("7ahc"),Ce=re("k1fw"),me=re("HmJG"),se=re("BjJ7"),Re=he.a.useForm,et={width:280,marginRight:10},Ge={labelCol:{span:5},wrapperCol:{span:19}},tt=function(Pe){var xt=Pe.callback,mt=Pe.onCancel,He=Re(),Tt=Object(B.a)(He,1),yt=Tt[0],kt=Object(p.useRef)();function Lt(Xt){xt(Object(Ce.a)(Object(Ce.a)({},Xt),{},{name:kt.current}))}function Et(Xt,gt){yt.setFieldsValue({src:"/api/attachments/".concat(Xt.id,"?type=").concat(Xt.content_type),type:gt.type})}function sr(Xt){var gt=Xt.target.files[0];kt.current=gt.name,De(gt,Et)}return y.a.createElement(he.a,Object(c.a)({form:yt},Ge,{className:"upload-image-panel",onFinish:Lt}),y.a.createElement(he.a.Item,{label:"\u6587\u4EF6\u5730\u5740",required:!0},y.a.createElement("div",{className:"flex-container"},y.a.createElement(he.a.Item,{noStyle:!0,name:"src",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u6587\u4EF6\u5730\u5740"}]},y.a.createElement(_e.a,{style:et})),y.a.createElement(Ye,{onFileChange:sr}))),y.a.createElement(he.a.Item,{label:"\u6587\u4EF6\u63CF\u8FF0",name:"alt"},y.a.createElement(_e.a,{style:{width:264}})),y.a.createElement(he.a.Item,{style:{textAlign:"right"}},y.a.createElement(ee.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement(ee.a,{type:"ghost",onClick:mt},"\u53D6\u6D88")))};function Ye(Pe){var xt=Pe.onFileChange;return y.a.createElement("a",{className:"upload-button"},"\u672C\u5730\u4E0A\u4F20",y.a.createElement("input",{type:"file",onChange:xt}))}function De(Pe,xt){if(!Pe)throw new String("\u6CA1\u6709\u6587\u4EF6");var mt=new FormData;mt.append("editormd-image-file",Pe),mt.append("file_param_name","editormd-image-file"),mt.append("byxhr","true");var He=new window.XMLHttpRequest;He.withCredentials=!0,He.addEventListener("load",function(Tt){xt(JSON.parse(Tt.target.responseText),Pe)},!1),He.addEventListener("error",function(Tt){console.error(Tt)},!1),He.open("POST","".concat(se.a,"/api/attachments.json")),He.send(mt)}var je=re("giR+"),$e=re("fyUT"),st=re("7Kak"),Qe=re("9yH6"),Be=Qe.a.Group,We={margin:"0 8px"},ft=function(Pe){var xt=Pe.callback,mt=Pe.onCancel;function He(Tt){xt(Tt)}return y.a.createElement(he.a,{className:"add-table-panel",initialValues:{row:3,col:2,align:"default"},onFinish:He},y.a.createElement("div",{className:"flex-container"},y.a.createElement("span",{style:We},"\u5355\u5143\u683C\u6570\uFF1A"),y.a.createElement("span",{style:We},"\u884C\u6570"),y.a.createElement(he.a.Item,{name:"row",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u884C\u6570"}]},y.a.createElement($e.a,null)),y.a.createElement("span",{style:We},"\u5217\u6570"),y.a.createElement(he.a.Item,{name:"col",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u5217\u6570"}]},y.a.createElement($e.a,null))),y.a.createElement("div",{className:"flex-container",style:{marginTop:12}},y.a.createElement("span",{style:We},"\u5BF9\u9F50\u65B9\u5F0F\uFF1A"),y.a.createElement(he.a.Item,{name:"align"},y.a.createElement(Be,null,y.a.createElement(Qe.a,{value:"default"},y.a.createElement("i",{className:"fa fa-align-justify"})),y.a.createElement(Qe.a,{value:"left"},y.a.createElement("i",{className:"fa fa-align-left"})),y.a.createElement(Qe.a,{value:"center"},y.a.createElement("i",{className:"fa fa-align-center"})),y.a.createElement(Qe.a,{value:"right"},y.a.createElement("i",{className:"fa fa-align-right"}))))),y.a.createElement("div",{className:"flex-container flex-end"},y.a.createElement(ee.a,{type:"primary",htmlType:"submit",style:{marginRight:10}},"\u786E\u5B9A"),y.a.createElement(ee.a,{type:"ghost",onClick:mt},"\u53D6\u6D88")))},Ke=re("ErOA"),Ue=re("7Cbv"),Xe="link",Ze="upload-image",Ve="code-block",rt="add-table",we="------------",qe={default:we,left:":".concat(we),center:":".concat(we,":"),right:"".concat(we,":")},it=re("9VGf"),Ae,Oe;function pe(){}var de=0,ue=1e4,te="\u2581",q=`
**\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 ne(Pe){return/^\d+$/.test(Pe)?"".concat(Pe,"px"):Pe}var ae=navigator.platform.toUpperCase().indexOf("MAC")>=0,ve=ae?"Cmd":"Ctrl",Le=["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"],Ie=(Ae={},Object(N.a)(Ae,ve+"-B","bold"),Object(N.a)(Ae,ve+"-I","italic"),Ae),lt=(Oe={},Object(N.a)(Oe,Xe,"\u6DFB\u52A0\u94FE\u63A5"),Object(N.a)(Oe,Ve,"\u6DFB\u52A0\u4EE3\u7801\u5757"),Object(N.a)(Oe,Ze,"\u6DFB\u52A0\u6587\u4EF6"),Object(N.a)(Oe,rt,"\u6DFB\u52A0\u8868\u683C"),Oe),Rt=ot.a=function(Pe){var xt=Pe.defaultValue,mt=xt===void 0?"":xt,He=Pe.onChange,Tt=Pe.width,yt=Tt===void 0?"100%":Tt,kt=Pe.height,Lt=kt===void 0?400:kt,Et=Pe.miniToolbar,sr=Et===void 0?!1:Et,Xt=Pe.isFocus,gt=Xt===void 0?!1:Xt,ir=Pe.watch,pr=Pe.insertTemp,lr=Pe.mode,wr=lr===void 0?"markdown":lr,$r=Pe.id,Ur=$r===void 0?"markdown-editor-id":$r,ct=Pe.showResizeBar,ut=ct===void 0?!1:ct,qt=Pe.noStorage,jt=qt===void 0?!1:qt,Nt=Pe.showNullButton,Ot=Nt===void 0?!1:Nt,zt=Pe.hidetoolBar,Rr=zt===void 0?!1:zt,gi=Pe.fullScreen,ze=gi===void 0?!1:gi,At=Pe.onBlur,ii=Pe.onCMBeforeChange,di=Pe.onFullScreen,hi=Pe.className,Ri=hi===void 0?"":hi,z=Pe.disablePaste,s=z===void 0?!1:z,m=Pe.placeholder,W=m===void 0?"":m,Q=Pe.values,H=Q===void 0?"":Q,fe=Object(p.useState)(null),Me=Object(B.a)(fe,2),Se=Me[0],vt=Me[1],Ne=Object(p.useState)(mt),_t=Object(B.a)(Ne,2),Ut=_t[0],Kt=_t[1],Gr=Object(p.useState)(ir),Kr=Object(B.a)(Gr,2),mr=Kr[0],Qr=Kr[1],Ki=Object(p.useState)(ze),kr=Object(B.a)(Ki,2),Or=kr[0],ni=kr[1],vi=Object(p.useState)(""),Zr=Object(B.a)(vi,2),ai=Zr[0],Vr=Zr[1],fn=Object(p.useState)(0),Vi=Object(B.a)(fn,2),Fr=Vi[0],jr=Vi[1],ki=Object(p.useState)(Lt),Oi=Object(B.a)(ki,2),Mi=Oi[0],ar=Oi[1],Wt=Object(p.useState)(!1),Er=Object(B.a)(Wt,2),Ht=Er[0],Sr=Er[1],Jt=Object(p.useRef)(Object(Ue.a)()),yi=Object(p.useRef)(!1),hr=Object(p.useRef)(),cr=Object(p.useRef)(),oi=Object(p.useRef)(),bi=Object(p.useRef)(),xi=Object(p.useRef)(),Fn=function(){var bt=Object(w.a)(k.a.mark(function Dt(){var Ct,Pt;return k.a.wrap(function(Vt){for(;;)switch(Vt.prev=Vt.next){case 0:return Vt.next=2,Object(Ke.a)("/api/attachments/distinct_hash_val.json",{method:"post",body:{hash_val:Jt.current}});case 2:Pt=Vt.sent,Pt!=null&&(Ct=Pt.attachments)!==null&&Ct!==void 0&&Ct.length&&(console.log("cm:",Se,cr),Pt.attachments.map(function(Bt){Bt.content_type.indexOf("image")>-1?Se.replaceSelection("![,](/api/attachments/".concat(Bt.id,"?type=").concat(Bt.content_type,")")):Bt.content_type.indexOf("video")>-1?Se.replaceSelection('<video width="100%" controls src="'.concat(O.a.API_SERVER,"/api/attachments/").concat(data.id,'"></video>')):Bt.content_type.indexOf("pdf")>-1?Se.replaceSelection('<a href="'.concat(O.a.API_SERVER,"/api/attachments/").concat(Bt.id,"?type=").concat(Bt.content_type,'&disposition=inline" target="_blank">').concat(Bt.name,"</a>")):Se.replaceSelection("[".concat(Bt.name,"](").concat(O.a.API_SERVER,"/api/attachments/").concat(Bt.id,"?type=").concat(Bt.content_type,")"))}));case 4:case"end":return Vt.stop()}},Dt)}));return function(){return bt.apply(this,arguments)}}();Object(p.useEffect)(function(){Kt(H),Se==null||Se.setValue(H)},[H]),Object(p.useEffect)(function(){di==null||di(Or)},[Or]),Object(p.useEffect)(function(){if(cr.current){var bt=L.a.fromTextArea(cr.current,{mode:wr,lineNumbers:!sr,lineWrapping:!0,value:mt,autoCloseTags:!0,autoCloseBrackets:!0});gt&&bt.focus();function Dt(Ct,Pt){if(s){Pt.preventDefault();return}var Ft=Pt.clipboardData;if(Ft){var Vt=Ft.types.toString(),Bt=Ft.items;if(Vt==="Files"||Ft.types.indexOf("Files")>-1){if(Pt.preventDefault(),wr=="stex")return;try{var tr,gr=Bt[1];((tr=Bt[0])===null||tr===void 0?void 0:tr.kind)==="file"&&(gr=Bt[0]);var It=gr.getAsFile(),Pi=It.name.split(".").pop();De(It,function(Yt){if(Yt.id){var Cr,Qt,Jr;(It==null||((Cr=It.type)===null||Cr===void 0)?void 0:Cr.indexOf("image"))>-1?bt.replaceSelection("![,](/api/attachments/".concat(Yt.id,"?type=").concat(Yt.content_type,")")):(It==null||((Qt=It.type)===null||Qt===void 0)?void 0:Qt.indexOf("video"))>-1?bt.replaceSelection('<video width="100%" controls src="'.concat(O.a.API_SERVER,"/api/attachments/").concat(Yt.id,'"></video>')):(It==null||((Jr=It.type)===null||Jr===void 0)?void 0:Jr.indexOf("pdf"))>-1?bt.replaceSelection('<a href="'.concat(O.a.API_SERVER,"/api/attachments/").concat(Yt.id,"?type=").concat(It.type,'&disposition=inline" target="_blank">').concat(It.name,"</a>")):Le.includes(Pi)?bt.replaceSelection('<a href="'.concat(O.a.API_SERVER,"/api/attachments/").concat(Yt.id,'?type=office&disposition=inline" target="_blank">').concat(It.name,"</a>")):bt.replaceSelection("[".concat(It.name,"](").concat(O.a.API_SERVER,"/api/attachments/").concat(Yt.id,"?type=").concat(Yt.content_type,")"))}else(Yt==null?void 0:Yt.status)===401&&(document.location.href="/user/login")})}catch(Yt){I.b.warn("\u8BF7\u4F7F\u7528chrome\u6D4F\u89C8\u5668\u7C98\u8D34")}return!0}else return!0}return!0}return bt.on("paste",Dt),bt.on("dragleave",function(Ct,Pt){oi.current.classList.remove("mouse-hover-md")}),bt.on("dragover",function(Ct,Pt){oi.current.classList.add("mouse-hover-md")}),bt.on("drop",function(Ct,Pt){oi.current.classList.add("mouse-hover-md");var Ft;if(Ft=Pt.dataTransfer.files,Ft.length>0){Pt.preventDefault(),Pt.stopPropagation();for(var Vt=function(gr){var It=Ft[gr],Pi=It.name.split(".").pop();De(It,function(Yt){if(Yt.id){var Cr,Qt,Jr;(It==null||((Cr=It.type)===null||Cr===void 0)?void 0:Cr.indexOf("image"))>-1?bt.replaceSelection("![,](/api/attachments/".concat(Yt.id,"?type=").concat(Yt.content_type,")")):(It==null||((Qt=It.type)===null||Qt===void 0)?void 0:Qt.indexOf("video"))>-1?bt.replaceSelection('<video width="100%" controls src="'.concat(O.a.API_SERVER,"/api/attachments/").concat(Yt.id,'"></video>')):(It==null||((Jr=It.type)===null||Jr===void 0)?void 0:Jr.indexOf("pdf"))>-1?bt.replaceSelection('<a href="'.concat(O.a.API_SERVER,"/api/attachments/").concat(Yt.id,"?type=").concat(It.type,'&disposition=inline" target="_blank">').concat(It.name,"</a>")):Le.includes(Pi)?bt.replaceSelection('<a href="'.concat(O.a.API_SERVER,"/api/attachments/").concat(Yt.id,'?type=office&disposition=inline" target="_blank">').concat(It.name,"</a>")):bt.replaceSelection("[".concat(It.name,"](").concat(O.a.API_SERVER,"/api/attachments/").concat(Yt.id,"?type=").concat(Yt.content_type,")"))}else(Yt==null?void 0:Yt.status)===401&&(document.location.href="/user/login")})},Bt=0;Bt<Ft.length;Bt++)Vt(Bt)}}),vt(bt),function(){bt.off("paste",Dt)}}},[]);var qr=Object(p.useCallback)(function(){if(oi.current)try{}catch(bt){console.log(bt,"---- to set md editor body height")}},[Mi,oi,Or]);Object(p.useEffect)(function(){function bt(){var Ct=new x.default(function(Pt){var Ft=Object(D.a)(Pt),Vt;try{for(Ft.s();!(Vt=Ft.n()).done;){var Bt=Vt.value;(Bt.target.offsetHeight>0||Bt.target.offsetWidth>0)&&(qr(),Se.setSize("100%","100%"),Se.refresh())}}catch(tr){Ft.e(tr)}finally{Ft.f()}});return Ct.observe(cr.current.parentElement),Ct}if(Se){var Dt=bt();return function(){Dt.unobserve(cr.current.parentElement)}}},[Se,qr]),Object(p.useEffect)(function(){if(Se){for(var bt=[],Dt=function(){var Bt=Pt[Ct];Ft=Object(B.a)(Bt,2);var tr=Ft[0],gr=Ft[1],It=Object(N.a)({},tr,function(){Xi(gr)});bt.push(It),Se.addKeyMap(It)},Ct=0,Pt=Object.entries(Ie);Ct<Pt.length;Ct++){var Ft;Dt()}return hr.current=setInterval(function(){yi.current&&Fn()},4e3),function(){clearInterval(hr.current);var Vt=Object(D.a)(bt),Bt;try{for(Vt.s();!(Bt=Vt.n()).done;){var tr=Bt.value;Se.removeKeyMap(tr)}}catch(gr){Vt.e(gr)}finally{Vt.f()}}}},[Se]),Object(p.useEffect)(function(){ze!==Or&&ni(ze)},[ze]),Object(it.a)(function(){if(!jt&&Fr>0){var bt=new Date().getTime(),Dt=window.sessionStorage.getItem(Ur);bt>=Fr+ue&&(!Dt||Dt!==Ut)&&(window.sessionStorage.setItem(Ur,Ut),Sr(!0))}},ue),Object(p.useEffect)(function(){Qr(ir)},[Se,ir]),Object(p.useEffect)(function(){Se&&(gt&&Se.focus())},[Se,gt]),Object(p.useEffect)(function(){if(mr&&Se){var bt=Se.getScrollerElement();function Dt(Ct){var Pt=Ct.target;if(xi.current){var Ft=Pt.scrollTop/Pt.scrollHeight;xi.current.scrollTop=xi.current.scrollHeight*Ft}}return bt.addEventListener("scroll",Dt),function(){bt.removeEventListener("scroll",Dt)}}},[Se,mr]),Object(p.useEffect)(function(){if(Se&&ii){function bt(Dt,Ct){ii(Dt,Ct)}return Se.on("beforeChange",bt),function(){Se.off("beforeChange",bt)}}},[Se,ii]),Object(p.useEffect)(function(){if(Se&&At){function bt(){At(Se.getValue())}return Se.on("blur",bt),function(){Se.off("blur",bt)}}},[Se,At]),Object(p.useEffect)(function(){if(Se){function bt(Dt){var Ct=Dt.getValue();Kt(Ct),jr(new Date().getTime()),Dt.getScrollerElement().dispatchEvent(new CustomEvent("scroll")),He&&He(Ct)}return Se.on("change",bt),function(){Se.off("change",bt)}}},[Se,He]),Object(p.useEffect)(function(){Se&&(mt==null?(Se.setValue(""),Kt("")):mt!==Se.getValue()&&(Se.setValue(mt),Kt(mt),Se.setCursor(Se.lineCount(),0)))},[Se,mt]);var Xi=Object(p.useCallback)(function(bt){var Dt=Se.getCursor(),Ct=Se.getSelection(),Pt=Ct.split(`
`);switch(bt){case"bold":return Se.replaceSelection("**"+Ct+"**"),Ct===""&&Se.setCursor(Dt.line,Dt.ch+2),Se.focus();case"italic":return Se.replaceSelection("*"+Ct+"*"),Ct===""&&Se.setCursor(Dt.line,Dt.ch+1),Se.focus();case"code":return Se.replaceSelection("`"+Ct+"`"),Ct===""&&Se.setCursor(Dt.line,Dt.ch+1),Se.focus();case"inline-latex":return Se.replaceSelection("`$$"+Ct+"$$`"),Ct===""&&Se.setCursor(Dt.line,Dt.ch+3),Se.focus();case"latex":return Se.replaceSelection("```latex\n"+Ct+"\n```"),Se.setCursor(Dt.line+1,Ct.length+1),Se.focus();case"line-break":return Se.replaceSelection(`<br/>
`),Se.focus();case"list-ul":return Ct===""?Se.replaceSelection("- "+Ct):Se.replaceSelection(Pt.map(function(Ft){return Ft===""?"":"- ".concat(Ft)}).join(`
`)),Se.focus();case"list-ol":return Ct===""?Se.replaceSelection("1. "+Ct):Se.replaceSelection(Pt.map(function(Ft,Vt){return Ft===""?"":"".concat(Vt+1,". ").concat(Ft)}).join(`
`)),Se.focus();case"add-null-ch":return Ct===""&&Se.setCursor(Dt.line,Dt.ch+1),Se.replaceSelection(te),Se.focus();case"inster-template-1":return Ct===""&&Se.setCursor(Dt.line,Dt.ch),Se.replaceSelection(q),Se.focus();case"eraser":return Se.setValue(""),Se.focus();case"trigger-watch":return Qr(!mr),Se.focus();case"trigger-full-screen":return ni(!Or),Se.focus();case Xe:Vr(Xe);return;case Ve:Vr(Ve);return;case Ze:Vr(Ze);return;case rt:Vr(rt);return;default:throw new Error}},[Se,mr,Or]),Wr=Object(p.useCallback)(function(bt){Vr("");switch(ai){case Xe:var Dt=bt.title,Ct=bt.link;return Se.replaceSelection("[".concat(Dt,"](").concat(Ct,")")),Se.focus();case Ve:var Pt=bt.language,Ft=bt.content;return Se.replaceSelection(["```"+Pt,Ft,"```"].join(`
`)),Se.focus();case Ze:var Vt=bt.src,Bt=bt.alt,tr=bt.name;return Vt.indexOf("type=image")>-1?Se.replaceSelection("![ ".concat(Bt||""," ]( ").concat(Vt,' "').concat(Bt||"",'" )')):Vt.indexOf("type=application/pdf")>-1?Se.replaceSelection('<a href="'.concat(Vt,'&disposition=inline" target="_blank">').concat(tr,"</a>")):Se.replaceSelection('<a href="'.concat(Vt,'" target="_blank">').concat(tr,"</a>")),Se.focus();case rt:for(var gr=bt.row,It=bt.col,Pi=bt.align,Yt=`
`,Cr=0;Cr<gr;Cr++){for(var Qt=[],Jr=[],pn=0;pn<It;pn++)Cr===1&&Jr.push(qe[Pi]),Qt.push(" ");Cr===1&&(Yt+="| ".concat(Jr.join(" | "),` |
`)),Yt+="| ".concat(Qt.join(It===1?"":" | "),` |
`)}return Se.replaceSelection(Yt+`
`),Se.focus();default:throw new Error}},[Se,ai]),Yi=Object(p.useMemo)(function(){switch(ai){case Xe:return y.a.createElement(Ee,{callback:Wr,onCancel:ci});case Ve:return y.a.createElement(Te.b,{callback:Wr,onCancel:ci});case Ze:return y.a.createElement(tt,{callback:Wr,onCancel:ci});case rt:return y.a.createElement(ft,{callback:Wr,onCancel:ci});default:return null}},[ai]);function ci(){Vr("")}Object(p.useEffect)(function(){if(bi.current){var bt=bi.current,Dt=!1,Ct=0;function Pt(Bt){Dt=!0,Ct=Bt.pageY}function Ft(){Dt=!1}function Vt(Bt){if(Dt){var tr=Bt.pageY-Ct;tr<0&&(tr=0),tr>300&&(tr=300);var gr=Lt+tr+"px";ar(gr)}}return bt.addEventListener("mousedown",Pt),document.addEventListener("mousemove",Vt),document.addEventListener("mouseup",Ft),function(){bt.removeEventListener("mousedown",Pt),document.removeEventListener("mousemove",Vt),document.removeEventListener("mouseup",Ft)}}},[Se,bi]),Object(p.useEffect)(function(){ar(Lt)},[Lt]);var Ei=ne(yt),ua=ne(Mi),da={width:Ei,height:ua},Qa=Object(p.useMemo)(function(){if(Fr){var bt=new Date(Fr),Dt=bt.getHours(),Ct=bt.getMinutes(),Pt=bt.getSeconds();return Dt=Dt<10?"0"+Dt:Dt,Ct=Ct<10?"0"+Ct:Ct,Pt=Pt<10?"0"+Pt:Pt,"".concat(Dt,":").concat(Ct,":").concat(Pt)}return 0},[Fr]);function Ja(){window.sessionStorage.removeItem(Ur),Sr(!1),jr(0)}function ha(){Sr(!1),jr(0),Se.setValue(window.sessionStorage.getItem(Ur))}function jn(bt,Dt){var Ct=Se.getValue();Ct=Ct.replace(bt,Dt),Kt(Ct),Se==null||Se.setValue(Ct)}return y.a.createElement(p.Fragment,null,y.a.createElement("div",{className:"markdown-editor-wrapper",ref:oi},y.a.createElement("div",{className:"markdown-editor-container ".concat(Ri," ").concat(mr?"on-preview":""," ").concat(sr?"mini":""," ").concat(Or?"full-screen":""),style:da},y.a.createElement(J,{insertTemp:pr,watch:mr,fullScreen:Or,showNullButton:Ot,onActionCallback:Xi,hidetoolBar:Rr,uuid:Jt.current,setOpenPhones:function(){yi.current=!0}}),y.a.createElement("div",{className:"markdown-editor-body"},y.a.createElement("div",{className:"codemirror-container"},y.a.createElement("textarea",{ref:cr,placeholder:W})),mr?y.a.createElement("div",{ref:xi,className:"preview-container"},wr==="stex"&&y.a.createElement(R,{value:Ut}),wr!=="stex"&&y.a.createElement(b.a,{edit:!0,value:Ut,replaces:jn})):null))),ut?y.a.createElement("a",{ref:bi,className:"editor-resize"}):null,y.a.createElement(K.a,null,lt[ai]?y.a.createElement(Y.a,{centered:!0,title:lt[ai],visible:!0,onCancel:ci,footer:null},Yi):null))}},SJMd:function(ht,ot){/**
* @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 re,ie,Y,D=!1,V,I;window.PR_SHOULD_USE_CONTINUATION=!0;var w,B;(function(){var N=window,M=["break,continue,do,else,for,if,return,while"],k=[M,"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"],p=[k,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],y=[p,"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"],P=[p,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],L=[p,"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"],x="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=[p,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],d="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",a=[M,"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"],l=[M,"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"],h=[M,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],_=[y,L,P,S,d,a,l,h],f=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,b="str",R="kwd",T="com",g="typ",c="lit",u="pun",o="pln",C="tag",E="dec",v="src",O="atn",j="atv",G="nocode",J="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function K(De){for(var je=0,$e=!1,st=!1,Qe=0,Be=De.length;Qe<Be;++Qe){var We=De[Qe];if(We.ignoreCase)st=!0;else if(/[a-z]/i.test(We.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){$e=!0,st=!1;break}}var ft={b:8,t:9,n:10,v:11,f:12,r:13};function Ke(rt){var we=rt.charCodeAt(0);if(we!==92)return we;var qe=rt.charAt(1);return we=ft[qe],we||("0"<=qe&&qe<="7"?parseInt(rt.substring(1),8):qe==="u"||qe==="x"?parseInt(rt.substring(2),16):rt.charCodeAt(1))}function Ue(rt){if(rt<32)return(rt<16?"\\x0":"\\x")+rt.toString(16);var we=String.fromCharCode(rt);return we==="\\"||we==="-"||we==="]"||we==="^"?"\\"+we:we}function Xe(rt){var we=rt.substring(1,rt.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")),qe=[],it=we[0]==="^",Ae=["["];it&&Ae.push("^");for(var Oe=it?1:0,pe=we.length;Oe<pe;++Oe){var de=we[Oe];if(/\\[bdsw]/i.test(de))Ae.push(de);else{var ue=Ke(de),te;Oe+2<pe&&we[Oe+1]==="-"?(te=Ke(we[Oe+2]),Oe+=2):te=ue,qe.push([ue,te]),te<65||ue>122||(te<65||ue>90||qe.push([Math.max(65,ue)|32,Math.min(te,90)|32]),te<97||ue>122||qe.push([Math.max(97,ue)&~32,Math.min(te,122)&~32]))}}qe.sort(function(ve,Le){return ve[0]-Le[0]||Le[1]-ve[1]});for(var q=[],ne=[],Oe=0;Oe<qe.length;++Oe){var ae=qe[Oe];ae[0]<=ne[1]+1?ne[1]=Math.max(ne[1],ae[1]):q.push(ne=ae)}for(var Oe=0;Oe<q.length;++Oe){var ae=q[Oe];Ae.push(Ue(ae[0])),ae[1]>ae[0]&&(ae[1]+1>ae[0]&&Ae.push("-"),Ae.push(Ue(ae[1])))}return Ae.push("]"),Ae.join("")}function Ze(rt){for(var we=rt.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")),qe=we.length,it=[],Ae=0,Oe=0;Ae<qe;++Ae){var pe=we[Ae];if(pe==="(")++Oe;else if(pe.charAt(0)==="\\"){var de=+pe.substring(1);de&&(de<=Oe?it[de]=-1:we[Ae]=Ue(de))}}for(var Ae=1;Ae<it.length;++Ae)it[Ae]===-1&&(it[Ae]=++je);for(var Ae=0,Oe=0;Ae<qe;++Ae){var pe=we[Ae];if(pe==="(")++Oe,it[Oe]||(we[Ae]="(?:");else if(pe.charAt(0)==="\\"){var de=+pe.substring(1);de&&de<=Oe&&(we[Ae]="\\"+it[de])}}for(var Ae=0;Ae<qe;++Ae)we[Ae]==="^"&&we[Ae+1]!=="^"&&(we[Ae]="");if(rt.ignoreCase&&$e)for(var Ae=0;Ae<qe;++Ae){var pe=we[Ae],ue=pe.charAt(0);pe.length>=2&&ue==="["?we[Ae]=Xe(pe):ue!=="\\"&&(we[Ae]=pe.replace(/[a-zA-Z]/g,function(ne){var ae=ne.charCodeAt(0);return"["+String.fromCharCode(ae&~32,ae|32)+"]"}))}return we.join("")}for(var Ve=[],Qe=0,Be=De.length;Qe<Be;++Qe){var We=De[Qe];if(We.global||We.multiline)throw new Error(""+We);Ve.push("(?:"+Ze(We)+")")}return new RegExp(Ve.join("|"),st?"gi":"g")}function F(De,je){var $e=/(?:^|\s)nocode(?:\s|$)/,st=[],Qe=0,Be=[],We=0;function ft(Ke){var Ue=Ke.nodeType;if(Ue==1){if($e.test(Ke.className))return;for(var Xe=Ke.firstChild;Xe;Xe=Xe.nextSibling)ft(Xe);var Ze=Ke.nodeName.toLowerCase();(Ze==="br"||Ze==="li")&&(st[We]=`
`,Be[We<<1]=Qe++,Be[We++<<1|1]=Ke)}else if(Ue==3||Ue==4){var Ve=Ke.nodeValue;Ve.length&&(je?Ve=Ve.replace(/\r\n?/g,`
`):Ve=Ve.replace(/[ \t\r\n]+/g," "),st[We]=Ve,Be[We<<1]=Qe,Qe+=Ve.length,Be[We++<<1|1]=Ke)}}return ft(De),{sourceCode:st.join("").replace(/\n$/,""),spans:Be}}function ee(De,je,$e,st,Qe){if(!$e)return;var Be={sourceNode:De,pre:1,langExtension:null,numberLines:null,sourceCode:$e,spans:null,basePos:je,decorations:null};st(Be),Qe.push.apply(Qe,Be.decorations)}var oe=/\S/;function he(De){for(var je=void 0,$e=De.firstChild;$e;$e=$e.nextSibling){var st=$e.nodeType;je=st===1?je?De:$e:st===3&&oe.test($e.nodeValue)?De:je}return je===De?void 0:je}function ge(De,je){var $e={},st;(function(){for(var We=De.concat(je),ft=[],Ke={},Ue=0,Xe=We.length;Ue<Xe;++Ue){var Ze=We[Ue],Ve=Ze[3];if(Ve)for(var rt=Ve.length;--rt>=0;)$e[Ve.charAt(rt)]=Ze;var we=Ze[1],qe=""+we;Ke.hasOwnProperty(qe)||(ft.push(we),Ke[qe]=null)}ft.push(/[\0-\uffff]/),st=K(ft)})();var Qe=je.length,Be=function(We){for(var ft=We.sourceCode,Ke=We.basePos,Ue=We.sourceNode,Xe=[Ke,o],Ze=0,Ve=ft.match(st)||[],rt={},we=0,qe=Ve.length;we<qe;++we){var it=Ve[we],Ae=rt[it],Oe=void 0,pe;if(typeof Ae=="string")pe=!1;else{var de=$e[it.charAt(0)];if(de)Oe=it.match(de[1]),Ae=de[0];else{for(var ue=0;ue<Qe;++ue)if(de=je[ue],Oe=it.match(de[1]),Oe){Ae=de[0];break}Oe||(Ae=o)}pe=Ae.length>=5&&Ae.substring(0,5)==="lang-",pe&&!(Oe&&typeof Oe[1]=="string")&&(pe=!1,Ae=v),pe||(rt[it]=Ae)}var te=Ze;if(Ze+=it.length,!pe)Xe.push(Ke+te,Ae);else{var q=Oe[1],ne=it.indexOf(q),ae=ne+q.length;Oe[2]&&(ae=it.length-Oe[2].length,ne=ae-q.length);var ve=Ae.substring(5);ee(Ue,Ke+te,it.substring(0,ne),Be,Xe),ee(Ue,Ke+te+ne,q,se(ve,q),Xe),ee(Ue,Ke+te+ae,it.substring(ae),Be,Xe)}}We.decorations=Xe};return Be}function _e(De){var je=[],$e=[];De.tripleQuotedStrings?je.push([b,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,`'"`]):De.multiLineStrings?je.push([b,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):je.push([b,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,`"'`]),De.verbatimStrings&&$e.push([b,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var st=De.hashComments;st&&(De.cStyleComments?(st>1?je.push([T,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):je.push([T,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"]),$e.push([b,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):je.push([T,/^#[^\r\n]*/,null,"#"])),De.cStyleComments&&($e.push([T,/^\/\/[^\r\n]*/,null]),$e.push([T,/^\/\*[\s\S]*?(?:\*\/|$)/,null]));var Qe=De.regexLiterals;if(Qe){var Be=Qe>1?"":`
\r`,We=Be?".":"[\\S\\s]",ft="/(?=[^/*"+Be+"])(?:[^/\\x5B\\x5C"+Be+"]|\\x5C"+We+"|\\x5B(?:[^\\x5C\\x5D"+Be+"]|\\x5C"+We+")*(?:\\x5D|$))+/";$e.push(["lang-regex",RegExp("^"+J+"("+ft+")")])}var Ke=De.types;Ke&&$e.push([g,Ke]);var Ue=(""+De.keywords).replace(/^ | $/g,"");Ue.length&&$e.push([R,new RegExp("^(?:"+Ue.replace(/[\s,]+/g,"|")+")\\b"),null]),je.push([o,/^\s+/,null,` \r
\xA0`]);var Xe="^.[^\\s\\w.$@'\"`/\\\\]*";return De.regexLiterals&&(Xe+="(?!s*/)"),$e.push([c,/^@[a-z_$][a-z_$@0-9]*/i,null],[g,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[o,/^[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"],[o,/^\\[\s\S]?/,null],[u,new RegExp(Xe),null]),ge(je,$e)}var be=_e({keywords:_,hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0});function Ee(De,je,$e){for(var st=/(?:^|\s)nocode(?:\s|$)/,Qe=/\r\n?|\n/,Be=De.ownerDocument,We=Be.createElement("li");De.firstChild;)We.appendChild(De.firstChild);var ft=[We];function Ke(we){var qe=we.nodeType;if(qe==1&&!st.test(we.className))if(we.nodeName==="br")Ue(we),we.parentNode&&we.parentNode.removeChild(we);else for(var it=we.firstChild;it;it=it.nextSibling)Ke(it);else if((qe==3||qe==4)&&$e){var Ae=we.nodeValue,Oe=Ae.match(Qe);if(Oe){var pe=Ae.substring(0,Oe.index);we.nodeValue=pe;var de=Ae.substring(Oe.index+Oe[0].length);if(de){var ue=we.parentNode;ue.insertBefore(Be.createTextNode(de),we.nextSibling)}Ue(we),pe||we.parentNode.removeChild(we)}}}function Ue(we){for(;!we.nextSibling;)if(we=we.parentNode,!we)return;function qe(Oe,pe){var de=pe?Oe.cloneNode(!1):Oe,ue=Oe.parentNode;if(ue){var te=qe(ue,1),q=Oe.nextSibling;te.appendChild(de);for(var ne=q;ne;ne=q)q=ne.nextSibling,te.appendChild(ne)}return de}for(var it=qe(we.nextSibling,0),Ae;(Ae=it.parentNode)&&Ae.nodeType===1;)it=Ae;ft.push(it)}for(var Xe=0;Xe<ft.length;++Xe)Ke(ft[Xe]);je===(je|0)&&ft[0].setAttribute("value",je);var Ze=Be.createElement("ol");Ze.className="linenums";for(var Ve=Math.max(0,je-1|0)||0,Xe=0,rt=ft.length;Xe<rt;++Xe)We=ft[Xe],We.className="L"+(Xe+Ve)%10,We.firstChild||We.appendChild(Be.createTextNode("\xA0")),Ze.appendChild(We);De.appendChild(Ze)}function Te(De){var je=/\bMSIE\s(\d+)/.exec(navigator.userAgent);je=je&&+je[1]<=8;var $e=/\n/g,st=De.sourceCode,Qe=st.length,Be=0,We=De.spans,ft=We.length,Ke=0,Ue=De.decorations,Xe=Ue.length,Ze=0;Ue[Xe]=Qe;var Ve,rt;for(rt=Ve=0;rt<Xe;)Ue[rt]!==Ue[rt+2]?(Ue[Ve++]=Ue[rt++],Ue[Ve++]=Ue[rt++]):rt+=2;for(Xe=Ve,rt=Ve=0;rt<Xe;){for(var we=Ue[rt],qe=Ue[rt+1],it=rt+2;it+2<=Xe&&Ue[it+1]===qe;)it+=2;Ue[Ve++]=we,Ue[Ve++]=qe,rt=it}Xe=Ue.length=Ve;var Ae=De.sourceNode,Oe="";Ae&&(Oe=Ae.style.display,Ae.style.display="none");try{for(var pe=null;Ke<ft;){var de=We[Ke],ue=We[Ke+2]||Qe,te=Ue[Ze+2]||Qe,it=Math.min(ue,te),q=We[Ke+1],ne;if(q.nodeType!==1&&(ne=st.substring(Be,it))){je&&(ne=ne.replace($e,"\r")),q.nodeValue=ne;var ae=q.ownerDocument,ve=ae.createElement("span");ve.className=Ue[Ze+1];var Le=q.parentNode;Le.replaceChild(ve,q),ve.appendChild(q),Be<ue&&(We[Ke+1]=q=ae.createTextNode(st.substring(it,ue)),Le.insertBefore(q,ve.nextSibling))}Be=it,Be>=ue&&(Ke+=2),Be>=te&&(Ze+=2)}}finally{Ae&&(Ae.style.display=Oe)}}var Ce={};function me(De,je){for(var $e=je.length;--$e>=0;){var st=je[$e];Ce.hasOwnProperty(st)?N.console&&console.warn("cannot override language handler %s",st):Ce[st]=De}}function se(De,je){return De&&Ce.hasOwnProperty(De)||(De=/^\s*</.test(je)?"default-markup":"default-code"),Ce[De]}me(be,["default-code"]),me(ge([],[[o,/^[^<?]+/],[E,/^<!\w[^>]*(?:>|$)/],[T,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[u,/^(?:<[%?]|[%?]>)/],["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"]),me(ge([[o,/^[\s]+/,null,` \r
`],[j,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,`"'`]],[[C,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[O,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[u,/^[=<>\/]+/],["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"]),me(ge([],[[j,/^[\s\S]+/]]),["uq.val"]),me(_e({keywords:y,hashComments:!0,cStyleComments:!0,types:f}),["c","cc","cpp","cxx","cyc","m"]),me(_e({keywords:"null,true,false"}),["json"]),me(_e({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:f}),["cs"]),me(_e({keywords:P,cStyleComments:!0}),["java"]),me(_e({keywords:h,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]),me(_e({keywords:a,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]),me(_e({keywords:d,hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]),me(_e({keywords:l,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]),me(_e({keywords:S,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]),me(_e({keywords:x,hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]),me(ge([],[[b,/^[\s\S]+/]]),["regex"]);function Re(De){var je=De.langExtension;try{var $e=F(De.sourceNode,De.pre),st=$e.sourceCode;De.sourceCode=st,De.spans=$e.spans,De.basePos=0,se(je,st)(De),Te(De)}catch(Qe){N.console&&console.log(Qe&&Qe.stack||Qe)}}function et(De,je,$e){var st=$e||!1,Qe=je||null,Be=document.createElement("div");Be.innerHTML="<pre>"+De+"</pre>",Be=Be.firstChild,st&&Ee(Be,st,!0);var We={langExtension:Qe,numberLines:st,sourceNode:Be,pre:1,sourceCode:null,basePos:null,spans:null,decorations:null};return Re(We),Be.innerHTML}function Ge(De,je){var $e=je||document.body,st=$e.ownerDocument||document;function Qe(de){return $e.getElementsByTagName(de)}for(var Be=[Qe("pre"),Qe("code"),Qe("xmp")],We=[],ft=0;ft<Be.length;++ft)for(var Ke=0,Ue=Be[ft].length;Ke<Ue;++Ke)We.push(Be[ft][Ke]);Be=null;var Xe=Date;Xe.now||(Xe={now:function(){return+new Date}});var Ze=0,Ve=/\blang(?:uage)?-([\w.]+)(?!\S)/,rt=/\bprettyprint\b/,we=/\bprettyprinted\b/,qe=/pre|xmp/i,it=/^code$/i,Ae=/^(?:pre|code|xmp)$/i,Oe={};function pe(){for(var de=N.PR_SHOULD_USE_CONTINUATION?Xe.now()+250:Infinity;Ze<We.length&&Xe.now()<de;Ze++){for(var ue=We[Ze],te=Oe,q=ue;q=q.previousSibling;){var ne=q.nodeType,ae=(ne===7||ne===8)&&q.nodeValue;if(ae?!/^\??prettify\b/.test(ae):ne!==3||/\S/.test(q.nodeValue))break;if(ae){te={},ae.replace(/\b(\w+)=([\w:.%+-]+)/g,function(Lt,Et,sr){te[Et]=sr});break}}var ve=ue.className;if((te!==Oe||rt.test(ve))&&!we.test(ve)){for(var Le=!1,Ie=ue.parentNode;Ie;Ie=Ie.parentNode){var lt=Ie.tagName;if(Ae.test(lt)&&Ie.className&&rt.test(Ie.className)){Le=!0;break}}if(!Le){ue.className+=" prettyprinted";var Rt=te.lang;if(!Rt){Rt=ve.match(Ve);var Pe;!Rt&&(Pe=he(ue))&&it.test(Pe.tagName)&&(Rt=Pe.className.match(Ve)),Rt&&(Rt=Rt[1])}var xt;if(qe.test(ue.tagName))xt=1;else{var mt=ue.currentStyle,He=st.defaultView,Tt=mt?mt.whiteSpace:He&&He.getComputedStyle?He.getComputedStyle(ue,null).getPropertyValue("white-space"):0;xt=Tt&&Tt.substring(0,3)==="pre"}var yt=te.linenums;(yt=yt==="true"||+yt)||(yt=ve.match(/\blinenums\b(?::(\d+))?/),yt=yt?yt[1]&&yt[1].length?+yt[1]:!0:!1),yt&&Ee(ue,yt,xt);var kt={langExtension:Rt,sourceNode:ue,numberLines:yt,pre:xt,sourceCode:null,basePos:null,spans:null,decorations:null};Re(kt)}}}Ze<We.length?N.setTimeout(pe,250):typeof De=="function"&&De()}pe()}var tt=N.PR={createSimpleLexer:ge,registerLangHandler:me,sourceDecorator:_e,PR_ATTRIB_NAME:O,PR_ATTRIB_VALUE:j,PR_COMMENT:T,PR_DECLARATION:E,PR_KEYWORD:R,PR_LITERAL:c,PR_NOCODE:G,PR_PLAIN:o,PR_PUNCTUATION:u,PR_SOURCE:v,PR_STRING:b,PR_TAG:C,PR_TYPE:g,prettyPrintOne:D?N.prettyPrintOne=et:w=et,prettyPrint:B=D?N.prettyPrint=Ge:B=Ge},Ye=N.define;typeof Ye=="function"&&Ye.amd&&Ye("google-code-prettify",[],function(){return tt})})()},UZu5:function(ht,ot,re){},"VrN/":function(ht,ot,re){(function(ie,Y){ht.exports=Y()})(this,function(){"use strict";var ie=navigator.userAgent,Y=navigator.platform,D=/gecko\/\d/i.test(ie),V=/MSIE \d/.test(ie),I=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ie),w=/Edge\/(\d+)/.exec(ie),B=V||I||w,N=B&&(V?document.documentMode||6:+(w||I)[1]),M=!w&&/WebKit\//.test(ie),k=M&&/Qt\/\d+\.\d+/.test(ie),p=!w&&/Chrome\//.test(ie),y=/Opera\//.test(ie),P=/Apple Computer/.test(navigator.vendor),L=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ie),x=/PhantomJS/.test(ie),S=!w&&/AppleWebKit/.test(ie)&&/Mobile\/\w+/.test(ie),d=/Android/.test(ie),a=S||d||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ie),l=S||/Mac/.test(Y),h=/\bCrOS\b/.test(ie),_=/win/i.test(Y),f=y&&ie.match(/Version\/(\d*\.\d*)/);f&&(f=Number(f[1])),f&&f>=15&&(y=!1,M=!0);var b=l&&(k||y&&(f==null||f<12.11)),R=D||B&&N>=9;function T(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var g=function(e,t){var i=e.className,r=T(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 u(e,t){return c(e).appendChild(t)}function o(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 A=0;A<t.length;++A)n.appendChild(t[A]);return n}function C(e,t,i,r){var n=o(e,t,i,r);return n.setAttribute("role","presentation"),n}var E;document.createRange?E=function(e,t,i,r){var n=document.createRange();return n.setEnd(r||e,i),n.setStart(e,t),n}:E=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 v(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 O(){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 j(e,t){var i=e.className;T(t).test(i)||(e.className+=(i?" ":"")+t)}function G(e,t){for(var i=e.split(" "),r=0;r<i.length;r++)i[r]&&!T(i[r]).test(t)&&(t+=" "+i[r]);return t}var J=function(e){e.select()};S?J=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:B&&(J=function(e){try{e.select()}catch(t){}});function K(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 ee(e,t,i,r,n){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var A=r||0,U=n||0;;){var X=e.indexOf(" ",A);if(X<0||X>=t)return U+(t-A);U+=X-A,U+=i-U%i,A=X+1}}var oe=function(){this.id=null,this.f=null,this.time=0,this.handler=K(this.onTimeout,this)};oe.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},oe.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 he(e,t){for(var i=0;i<e.length;++i)if(e[i]==t)return i;return-1}var ge=50,_e={toString:function(){return"CodeMirror.Pass"}},be={scroll:!1},Ee={origin:"*mouse"},Te={origin:"+move"};function Ce(e,t,i){for(var r=0,n=0;;){var A=e.indexOf(" ",r);A==-1&&(A=e.length);var U=A-r;if(A==e.length||n+U>=t)return r+Math.min(U,t-n);if(n+=A-r,n+=i-n%i,r=A+1,n>=t)return r}}var me=[""];function se(e){for(;me.length<=e;)me.push(Re(me)+" ");return me[e]}function Re(e){return e[e.length-1]}function et(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r);return i}function Ge(e,t,i){for(var r=0,n=i(t);r<e.length&&i(e[r])<=n;)r++;e.splice(r,0,t)}function tt(){}function Ye(e,t){var i;return Object.create?i=Object.create(e):(tt.prototype=e,i=new tt),t&&F(t,i),i}var De=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function je(e){return/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||De.test(e))}function $e(e,t){return t?t.source.indexOf("\\w")>-1&&je(e)?!0:t.test(e):je(e)}function st(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var Qe=/[\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 Be(e){return e.charCodeAt(0)>=768&&Qe.test(e)}function We(e,t,i){for(;(i<0?t>0:t<e.length)&&Be(e.charAt(t));)t+=i;return t}function ft(e,t,i){for(var r=t>i?-1:1;;){if(t==i)return t;var n=(t+i)/2,A=r<0?Math.ceil(n):Math.floor(n);if(A==t)return e(A)?t:i;e(A)?i=A:t=A+r}}function Ke(e,t,i,r){if(!e)return r(t,i,"ltr",0);for(var n=!1,A=0;A<e.length;++A){var U=e[A];(U.from<i&&U.to>t||t==i&&U.to==t)&&(r(Math.max(U.from,t),Math.min(U.to,i),U.level==1?"rtl":"ltr",A),n=!0)}n||r(t,i,"ltr")}var Ue=null;function Xe(e,t,i){var r;Ue=null;for(var n=0;n<e.length;++n){var A=e[n];if(A.from<t&&A.to>t)return n;A.to==t&&(A.from!=A.to&&i=="before"?r=n:Ue=n),A.from==t&&(A.from!=A.to&&i!="before"?r=n:Ue=n)}return r!=null?r:Ue}var Ze=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function i(Z){return Z<=247?e.charAt(Z):1424<=Z&&Z<=1524?"R":1536<=Z&&Z<=1785?t.charAt(Z-1536):1774<=Z&&Z<=2220?"r":8192<=Z&&Z<=8203?"w":Z==8204?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,A=/[LRr]/,U=/[Lb1n]/,X=/[1n]/;function $(Z,le,ce){this.level=Z,this.from=le,this.to=ce}return function(Z,le){var ce=le=="ltr"?"L":"R";if(Z.length==0||le=="ltr"&&!r.test(Z))return!1;for(var xe=Z.length,ye=[],ke=0;ke<xe;++ke)ye.push(i(Z.charCodeAt(ke)));for(var Fe=0,Je=ce;Fe<xe;++Fe){var nt=ye[Fe];nt=="m"?ye[Fe]=Je:Je=nt}for(var dt=0,at=ce;dt<xe;++dt){var pt=ye[dt];pt=="1"&&at=="r"?ye[dt]="n":A.test(pt)&&(at=pt,pt=="r"&&(ye[dt]="R"))}for(var wt=1,St=ye[0];wt<xe-1;++wt){var Mt=ye[wt];Mt=="+"&&St=="1"&&ye[wt+1]=="1"?ye[wt]="1":Mt==","&&St==ye[wt+1]&&(St=="1"||St=="n")&&(ye[wt]=St),St=Mt}for(var Zt=0;Zt<xe;++Zt){var br=ye[Zt];if(br==",")ye[Zt]="N";else if(br=="%"){var rr=void 0;for(rr=Zt+1;rr<xe&&ye[rr]=="%";++rr);for(var zr=Zt&&ye[Zt-1]=="!"||rr<xe&&ye[rr]=="1"?"1":"N",Ir=Zt;Ir<rr;++Ir)ye[Ir]=zr;Zt=rr-1}}for(var ur=0,Nr=ce;ur<xe;++ur){var Tr=ye[ur];Nr=="L"&&Tr=="1"?ye[ur]="L":A.test(Tr)&&(Nr=Tr)}for(var fr=0;fr<xe;++fr)if(n.test(ye[fr])){var dr=void 0;for(dr=fr+1;dr<xe&&n.test(ye[dr]);++dr);for(var nr=(fr?ye[fr-1]:ce)=="L",Br=(dr<xe?ye[dr]:ce)=="L",hn=nr==Br?nr?"L":"R":ce,Di=fr;Di<dr;++Di)ye[Di]=hn;fr=dr-1}for(var Ar=[],ui,xr=0;xr<xe;)if(U.test(ye[xr])){var Ya=xr;for(++xr;xr<xe&&U.test(ye[xr]);++xr);Ar.push(new $(0,Ya,xr))}else{var mi=xr,zi=Ar.length,Gi=le=="rtl"?1:0;for(++xr;xr<xe&&ye[xr]!="L";++xr);for(var Dr=mi;Dr<xr;)if(X.test(ye[Dr])){mi<Dr&&(Ar.splice(zi,0,new $(1,mi,Dr)),zi+=Gi);var cn=Dr;for(++Dr;Dr<xr&&X.test(ye[Dr]);++Dr);Ar.splice(zi,0,new $(2,cn,Dr)),zi+=Gi,mi=Dr}else++Dr;mi<xr&&Ar.splice(zi,0,new $(1,mi,xr))}return le=="ltr"&&(Ar[0].level==1&&(ui=Z.match(/^\s+/))&&(Ar[0].from=ui[0].length,Ar.unshift(new $(0,0,ui[0].length))),Re(Ar).level==1&&(ui=Z.match(/\s+$/))&&(Re(Ar).to-=ui[0].length,Ar.push(new $(0,xe-ui[0].length,xe)))),le=="rtl"?Ar.reverse():Ar}}();function Ve(e,t){var i=e.order;return i==null&&(i=e.order=Ze(e.text,t)),i}var rt=[],we=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]||rt).concat(i)}};function qe(e,t){return e._handlers&&e._handlers[t]||rt}function it(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 A=he(n,i);A>-1&&(r[t]=n.slice(0,A).concat(n.slice(A+1)))}}}function Ae(e,t){var i=qe(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 Oe(e,t,i){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Ae(e,i||t.type,e,t),ne(t)||t.codemirrorIgnore}function pe(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)he(i,t[r])==-1&&i.push(t[r])}function de(e,t){return qe(e,t).length>0}function ue(e){e.prototype.on=function(t,i){we(this,t,i)},e.prototype.off=function(t,i){it(this,t,i)}}function te(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function q(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ne(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==!1}function ae(e){te(e),q(e)}function ve(e){return e.target||e.srcElement}function Le(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),l&&e.ctrlKey&&t==1&&(t=3),t}var Ie=function(){if(B&&N<9)return!1;var e=o("div");return"draggable"in e||"dragDrop"in e}(),lt;function Rt(e){if(lt==null){var t=o("span","\u200B");u(e,o("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(lt=t.offsetWidth<=1&&t.offsetHeight>2&&!(B&&N<8))}var i=lt?o("span","\u200B"):o("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}var Pe;function xt(e){if(Pe!=null)return Pe;var t=u(e,document.createTextNode("A\u062EA")),i=E(t,0,1).getBoundingClientRect(),r=E(t,1,2).getBoundingClientRect();return c(e),!i||i.left==i.right?!1:Pe=r.right-i.right<3}var mt=`
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 A=e.slice(t,e.charAt(n-1)=="\r"?n-1:n),U=A.indexOf("\r");U!=-1?(i.push(A.slice(0,U)),t+=U+1):(i.push(A),t=n+1)}return i}:function(e){return e.split(/\r\n?|\n/)},He=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},Tt=function(){var e=o("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),yt=null;function kt(e){if(yt!=null)return yt;var t=u(e,o("span","x")),i=t.getBoundingClientRect(),r=E(t,0,1).getBoundingClientRect();return yt=Math.abs(i.left-r.left)>1}var Lt={},Et={};function sr(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Lt[e]=t}function Xt(e,t){Et[e]=t}function gt(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=Ye(t,e),e.name=t.name}else{if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return gt("application/xml");if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return gt("application/json")}return typeof e=="string"?{name:e}:e||{name:"null"}}function ir(e,t){t=gt(t);var i=Lt[t.name];if(!i)return ir(e,"text/plain");var r=i(e,t);if(pr.hasOwnProperty(t.name)){var n=pr[t.name];for(var A in n){if(!n.hasOwnProperty(A))continue;r.hasOwnProperty(A)&&(r["_"+A]=r[A]),r[A]=n[A]}}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var U in t.modeProps)r[U]=t.modeProps[U];return r}var pr={};function lr(e,t){var i=pr.hasOwnProperty(e)?pr[e]:pr[e]={};F(t,i)}function wr(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 $r(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 Ur(e,t,i){return e.startState?e.startState(t,i):!0}var ct=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};ct.prototype.eol=function(){return this.pos>=this.string.length},ct.prototype.sol=function(){return this.pos==this.lineStart},ct.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},ct.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},ct.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},ct.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},ct.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},ct.prototype.skipToEnd=function(){this.pos=this.string.length},ct.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},ct.prototype.backUp=function(e){this.pos-=e},ct.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ee(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?ee(this.string,this.lineStart,this.tabSize):0)},ct.prototype.indentation=function(){return ee(this.string,null,this.tabSize)-(this.lineStart?ee(this.string,this.lineStart,this.tabSize):0)},ct.prototype.match=function(e,t,i){if(typeof e=="string"){var r=function(U){return i?U.toLowerCase():U},n=this.string.substr(this.pos,e.length);if(r(n)==r(e))return t!==!1&&(this.pos+=e.length),!0}else{var A=this.string.slice(this.pos).match(e);return A&&A.index>0?null:(A&&t!==!1&&(this.pos+=A[0].length),A)}},ct.prototype.current=function(){return this.string.slice(this.start,this.pos)},ct.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},ct.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},ct.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};function ut(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],A=n.chunkSize();if(t<A){i=n;break}t-=A}return i.lines[t]}function qt(e,t,i){var r=[],n=t.line;return e.iter(t.line,i.line+1,function(A){var U=A.text;n==i.line&&(U=U.slice(0,i.ch)),n==t.line&&(U=U.slice(t.ch)),r.push(U),++n}),r}function jt(e,t,i){var r=[];return e.iter(t,i,function(n){r.push(n.text)}),r}function Nt(e,t){var i=t-e.height;if(i)for(var r=e;r;r=r.parent)r.height+=i}function Ot(e){if(e.parent==null)return null;for(var t=e.parent,i=he(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 zt(e,t){var i=e.first;e:do{for(var r=0;r<e.children.length;++r){var n=e.children[r],A=n.height;if(t<A){e=n;continue e}t-=A,i+=n.chunkSize()}return i}while(!e.lines);for(var U=0;U<e.lines.length;++U){var X=e.lines[U],$=X.height;if(t<$)break;t-=$}return i+U}function Rr(e,t){return t>=e.first&&t<e.first+e.size}function gi(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function ze(e,t,i){if(i===void 0&&(i=null),!(this instanceof ze))return new ze(e,t,i);this.line=e,this.ch=t,this.sticky=i}function At(e,t){return e.line-t.line||e.ch-t.ch}function ii(e,t){return e.sticky==t.sticky&&At(e,t)==0}function di(e){return ze(e.line,e.ch)}function hi(e,t){return At(e,t)<0?t:e}function Ri(e,t){return At(e,t)<0?e:t}function z(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function s(e,t){if(t.line<e.first)return ze(e.first,0);var i=e.first+e.size-1;return t.line>i?ze(i,ut(e,i).text.length):m(t,ut(e,t.line).text.length)}function m(e,t){var i=e.ch;return i==null||i>t?ze(e.line,t):i<0?ze(e.line,0):e}function W(e,t){for(var i=[],r=0;r<t.length;r++)i[r]=s(e,t[r]);return i}var Q=function(e,t){this.state=e,this.lookAhead=t},H=function(e,t,i,r){this.state=t,this.doc=e,this.line=i,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};H.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return t!=null&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},H.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}},H.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},H.fromSaved=function(e,t,i){return t instanceof Q?new H(e,wr(e.mode,t.state),i,t.lookAhead):new H(e,wr(e.mode,t),i)},H.prototype.save=function(e){var t=e!==!1?wr(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Q(t,this.maxLookAhead):t};function fe(e,t,i,r){var n=[e.state.modeGen],A={};Kr(e,t.text,e.doc.mode,i,function(Z,le){return n.push(Z,le)},A,r);for(var U=i.state,X=function(Z){i.baseTokens=n;var le=e.state.overlays[Z],ce=1,xe=0;i.state=!0,Kr(e,t.text,le.mode,i,function(ye,ke){for(var Fe=ce;xe<ye;){var Je=n[ce];Je>ye&&n.splice(ce,1,ye,n[ce+1],Je),ce+=2,xe=Math.min(ye,Je)}if(!ke)return;if(le.opaque)n.splice(Fe,ce-Fe,ye,"overlay "+ke),ce=Fe+2;else for(;Fe<ce;Fe+=2){var nt=n[Fe+1];n[Fe+1]=(nt?nt+" ":"")+"overlay "+ke}},A),i.state=U,i.baseTokens=null,i.baseTokenPos=1},$=0;$<e.state.overlays.length;++$)X($);return{styles:n,classes:A.bgClass||A.textClass?A:null}}function Me(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Se(e,Ot(t)),n=t.text.length>e.options.maxHighlightLength&&wr(e.doc.mode,r.state),A=fe(e,t,r);n&&(r.state=n),t.stateAfter=r.save(!n),t.styles=A.styles,A.classes?t.styleClasses=A.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 Se(e,t,i){var r=e.doc,n=e.display;if(!r.mode.startState)return new H(r,!0,t);var A=mr(e,t,i),U=A>r.first&&ut(r,A-1).stateAfter,X=U?H.fromSaved(r,U,A):new H(r,Ur(r.mode),A);return r.iter(A,t,function($){vt(e,$.text,X);var Z=X.line;$.stateAfter=Z==t-1||Z%5==0||Z>=n.viewFrom&&Z<n.viewTo?X.save():null,X.nextLine()}),i&&(r.modeFrontier=X.line),X}function vt(e,t,i,r){var n=e.doc.mode,A=new ct(t,e.options.tabSize,i);for(A.start=A.pos=r||0,t==""&&Ne(n,i.state);!A.eol();)_t(n,A,i.state),A.start=A.pos}function Ne(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var i=$r(e,t);if(i.mode.blankLine)return i.mode.blankLine(i.state)}function _t(e,t,i,r){for(var n=0;n<10;n++){r&&(r[0]=$r(e,i).mode);var A=e.token(t,i);if(t.pos>t.start)return A}throw new Error("Mode "+e.name+" failed to advance stream.")}var Ut=function(e,t,i){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=i};function Kt(e,t,i,r){var n=e.doc,A=n.mode,U;t=s(n,t);var X=ut(n,t.line),$=Se(e,t.line,i),Z=new ct(X.text,e.options.tabSize,$),le;for(r&&(le=[]);(r||Z.pos<t.ch)&&!Z.eol();)Z.start=Z.pos,U=_t(A,Z,$.state),r&&le.push(new Ut(Z,U,wr(n.mode,$.state)));return r?le:new Ut(Z,U,$.state)}function Gr(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 Kr(e,t,i,r,n,A,U){var X=i.flattenSpans;X==null&&(X=e.options.flattenSpans);var $=0,Z=null,le=new ct(t,e.options.tabSize,r),ce,xe=e.options.addModeClass&&[null];for(t==""&&Gr(Ne(i,r.state),A);!le.eol();){if(le.pos>e.options.maxHighlightLength?(X=!1,U&&vt(e,t,r,le.pos),le.pos=t.length,ce=null):ce=Gr(_t(i,le,r.state,xe),A),xe){var ye=xe[0].name;ye&&(ce="m-"+(ce?ye+" "+ce:ye))}if(!X||Z!=ce){for(;$<le.start;)$=Math.min(le.start,$+5e3),n($,Z);Z=ce}le.start=le.pos}for(;$<le.pos;){var ke=Math.min(le.pos,$+5e3);n(ke,Z),$=ke}}function mr(e,t,i){for(var r,n,A=e.doc,U=i?-1:t-(e.doc.mode.innerMode?1e3:100),X=t;X>U;--X){if(X<=A.first)return A.first;var $=ut(A,X-1),Z=$.stateAfter;if(Z&&(!i||X+(Z instanceof Q?Z.lookAhead:0)<=A.modeFrontier))return X;var le=ee($.text,null,e.options.tabSize);(n==null||r>le)&&(n=X-1,r=le)}return n}function Qr(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=ut(e,r).stateAfter;if(n&&(!(n instanceof Q)||r+n.lookAhead<t)){i=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var Ki=!1,kr=!1;function Or(){Ki=!0}function ni(){kr=!0}function vi(e,t,i){this.marker=e,this.from=t,this.to=i}function Zr(e,t){if(e)for(var i=0;i<e.length;++i){var r=e[i];if(r.marker==t)return r}}function ai(e,t){for(var i,r=0;r<e.length;++r)e[r]!=t&&(i||(i=[])).push(e[r]);return i}function Vr(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function fn(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var A=e[n],U=A.marker,X=A.from==null||(U.inclusiveLeft?A.from<=t:A.from<t);if(X||A.from==t&&U.type=="bookmark"&&(!i||!A.marker.insertLeft)){var $=A.to==null||(U.inclusiveRight?A.to>=t:A.to>t);(r||(r=[])).push(new vi(U,A.from,$?null:A.to))}}return r}function Vi(e,t,i){var r;if(e)for(var n=0;n<e.length;++n){var A=e[n],U=A.marker,X=A.to==null||(U.inclusiveRight?A.to>=t:A.to>t);if(X||A.from==t&&U.type=="bookmark"&&(!i||A.marker.insertLeft)){var $=A.from==null||(U.inclusiveLeft?A.from<=t:A.from<t);(r||(r=[])).push(new vi(U,$?null:A.from-t,A.to==null?null:A.to-t))}}return r}function Fr(e,t){if(t.full)return null;var i=Rr(e,t.from.line)&&ut(e,t.from.line).markedSpans,r=Rr(e,t.to.line)&&ut(e,t.to.line).markedSpans;if(!i&&!r)return null;var n=t.from.ch,A=t.to.ch,U=At(t.from,t.to)==0,X=fn(i,n,U),$=Vi(r,A,U),Z=t.text.length==1,le=Re(t.text).length+(Z?n:0);if(X)for(var ce=0;ce<X.length;++ce){var xe=X[ce];if(xe.to==null){var ye=Zr($,xe.marker);ye?Z&&(xe.to=ye.to==null?null:ye.to+le):xe.to=n}}if($)for(var ke=0;ke<$.length;++ke){var Fe=$[ke];if(Fe.to!=null&&(Fe.to+=le),Fe.from==null){var Je=Zr(X,Fe.marker);Je||(Fe.from=le,Z&&(X||(X=[])).push(Fe))}else Fe.from+=le,Z&&(X||(X=[])).push(Fe)}X&&(X=jr(X)),$&&$!=X&&($=jr($));var nt=[X];if(!Z){var dt=t.text.length-2,at;if(dt>0&&X)for(var pt=0;pt<X.length;++pt)X[pt].to==null&&(at||(at=[])).push(new vi(X[pt].marker,null,null));for(var wt=0;wt<dt;++wt)nt.push(at);nt.push($)}return nt}function jr(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 ki(e,t,i){var r=null;if(e.iter(t.line,i.line+1,function(ye){if(ye.markedSpans)for(var ke=0;ke<ye.markedSpans.length;++ke){var Fe=ye.markedSpans[ke].marker;Fe.readOnly&&(!r||he(r,Fe)==-1)&&(r||(r=[])).push(Fe)}}),!r)return null;for(var n=[{from:t,to:i}],A=0;A<r.length;++A)for(var U=r[A],X=U.find(0),$=0;$<n.length;++$){var Z=n[$];if(At(Z.to,X.from)<0||At(Z.from,X.to)>0)continue;var le=[$,1],ce=At(Z.from,X.from),xe=At(Z.to,X.to);(ce<0||!U.inclusiveLeft&&!ce)&&le.push({from:Z.from,to:X.from}),(xe>0||!U.inclusiveRight&&!xe)&&le.push({from:X.to,to:Z.to}),n.splice.apply(n,le),$+=le.length-3}return n}function Oi(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 Mi(e,t){if(!t)return;for(var i=0;i<t.length;++i)t[i].marker.attachLine(e);e.markedSpans=t}function ar(e){return e.inclusiveLeft?-1:0}function Wt(e){return e.inclusiveRight?1:0}function Er(e,t){var i=e.lines.length-t.lines.length;if(i!=0)return i;var r=e.find(),n=t.find(),A=At(r.from,n.from)||ar(e)-ar(t);if(A)return-A;var U=At(r.to,n.to)||Wt(e)-Wt(t);return U||t.id-e.id}function Ht(e,t){var i=kr&&e.markedSpans,r;if(i)for(var n=void 0,A=0;A<i.length;++A)n=i[A],n.marker.collapsed&&(t?n.from:n.to)==null&&(!r||Er(r,n.marker)<0)&&(r=n.marker);return r}function Sr(e){return Ht(e,!0)}function Jt(e){return Ht(e,!1)}function yi(e,t){var i=kr&&e.markedSpans,r;if(i)for(var n=0;n<i.length;++n){var A=i[n];A.marker.collapsed&&(A.from==null||A.from<t)&&(A.to==null||A.to>t)&&(!r||Er(r,A.marker)<0)&&(r=A.marker)}return r}function hr(e,t,i,r,n){var A=ut(e,t),U=kr&&A.markedSpans;if(U)for(var X=0;X<U.length;++X){var $=U[X];if(!$.marker.collapsed)continue;var Z=$.marker.find(0),le=At(Z.from,i)||ar($.marker)-ar(n),ce=At(Z.to,r)||Wt($.marker)-Wt(n);if(le>=0&&ce<=0||le<=0&&ce>=0)continue;if(le<=0&&($.marker.inclusiveRight&&n.inclusiveLeft?At(Z.to,i)>=0:At(Z.to,i)>0)||le>=0&&($.marker.inclusiveRight&&n.inclusiveLeft?At(Z.from,r)<=0:At(Z.from,r)<0))return!0}}function cr(e){for(var t;t=Sr(e);)e=t.find(-1,!0).line;return e}function oi(e){for(var t;t=Jt(e);)e=t.find(1,!0).line;return e}function bi(e){for(var t,i;t=Jt(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function xi(e,t){var i=ut(e,t),r=cr(i);return i==r?t:Ot(r)}function Fn(e,t){if(t>e.lastLine())return t;var i=ut(e,t),r;if(!qr(e,i))return t;for(;r=Jt(i);)i=r.find(1,!0).line;return Ot(i)+1}function qr(e,t){var i=kr&&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&&Xi(e,t,r))return!0}}function Xi(e,t,i){if(i.to==null){var r=i.marker.find(1,!0);return Xi(e,r.line,Zr(r.line.markedSpans,i.marker))}if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(var n=void 0,A=0;A<t.markedSpans.length;++A)if(n=t.markedSpans[A],n.marker.collapsed&&!n.marker.widgetNode&&n.from==i.to&&(n.to==null||n.to!=i.from)&&(n.marker.inclusiveLeft||i.marker.inclusiveRight)&&Xi(e,t,n))return!0}function Wr(e){e=cr(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 A=i.parent;A;i=A,A=i.parent)for(var U=0;U<A.children.length;++U){var X=A.children[U];if(X==i)break;t+=X.height}return t}function Yi(e){if(e.height==0)return 0;for(var t=e.text.length,i,r=e;i=Sr(r);){var n=i.find(0,!0);r=n.from.line,t+=n.from.ch-n.to.ch}for(r=e;i=Jt(r);){var A=i.find(0,!0);t-=r.text.length-A.from.ch,r=A.to.line,t+=r.text.length-A.to.ch}return t}function ci(e){var t=e.display,i=e.doc;t.maxLine=ut(i,i.first),t.maxLineLength=Yi(t.maxLine),t.maxLineChanged=!0,i.iter(function(r){var n=Yi(r);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=r)})}var Ei=function(e,t,i){this.text=e,Mi(this,t),this.height=i?i(this):1};Ei.prototype.lineNo=function(){return Ot(this)},ue(Ei);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),Oi(e),Mi(e,i);var n=r?r(e):1;n!=e.height&&Nt(e,n)}function da(e){e.parent=null,Oi(e)}var Qa={},Ja={};function ha(e,t){if(!e||/^\s*$/.test(e))return null;var i=t.addModeClass?Ja:Qa;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function jn(e,t){var i=C("span",null,null,M?"padding-right: .1px":null),r={pre:C("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 A=n?t.rest[n-1]:t.line,U=void 0;r.pos=0,r.addToken=Dt,xt(e.display.measure)&&(U=Ve(A,e.doc.direction))&&(r.addToken=Pt(r.addToken,U)),r.map=[];var X=t!=e.display.externalMeasured&&Ot(A);Vt(A,r,Me(e,A,X)),A.styleClasses&&(A.styleClasses.bgClass&&(r.bgClass=G(A.styleClasses.bgClass,r.bgClass||"")),A.styleClasses.textClass&&(r.textClass=G(A.styleClasses.textClass,r.textClass||""))),r.map.length==0&&r.map.push(0,0,r.content.appendChild(Rt(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(M){var $=r.content.lastChild;(/\bcm-tab\b/.test($.className)||$.querySelector&&$.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Ae(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=G(r.pre.className,r.textClass||"")),r}function bt(e){var t=o("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Dt(e,t,i,r,n,A,U){if(!t)return;var X=e.splitSpaces?Ct(t,e.trailingSpace):t,$=e.cm.state.specialChars,Z=!1,le;if(!$.test(t))e.col+=t.length,le=document.createTextNode(X),e.map.push(e.pos,e.pos+t.length,le),B&&N<9&&(Z=!0),e.pos+=t.length;else{le=document.createDocumentFragment();for(var ce=0;;){$.lastIndex=ce;var xe=$.exec(t),ye=xe?xe.index-ce:t.length-ce;if(ye){var ke=document.createTextNode(X.slice(ce,ce+ye));B&&N<9?le.appendChild(o("span",[ke])):le.appendChild(ke),e.map.push(e.pos,e.pos+ye,ke),e.col+=ye,e.pos+=ye}if(!xe)break;ce+=ye+1;var Fe=void 0;if(xe[0]==" "){var Je=e.cm.options.tabSize,nt=Je-e.col%Je;Fe=le.appendChild(o("span",se(nt),"cm-tab")),Fe.setAttribute("role","presentation"),Fe.setAttribute("cm-text"," "),e.col+=nt}else xe[0]=="\r"||xe[0]==`
`?(Fe=le.appendChild(o("span",xe[0]=="\r"?"\u240D":"\u2424","cm-invalidchar")),Fe.setAttribute("cm-text",xe[0]),e.col+=1):(Fe=e.cm.options.specialCharPlaceholder(xe[0]),Fe.setAttribute("cm-text",xe[0]),B&&N<9?le.appendChild(o("span",[Fe])):le.appendChild(Fe),e.col+=1);e.map.push(e.pos,e.pos+1,Fe),e.pos++}}if(e.trailingSpace=X.charCodeAt(t.length-1)==32,i||r||n||Z||A||U){var dt=i||"";r&&(dt+=r),n&&(dt+=n);var at=o("span",[le],dt,A);if(U)for(var pt in U)U.hasOwnProperty(pt)&&pt!="style"&&pt!="class"&&at.setAttribute(pt,U[pt]);return e.content.appendChild(at)}e.content.appendChild(le)}function Ct(e,t){if(e.length>1&&!/ /.test(e))return e;for(var i=t,r="",n=0;n<e.length;n++){var A=e.charAt(n);A==" "&&i&&(n==e.length-1||e.charCodeAt(n+1)==32)&&(A="\xA0"),r+=A,i=A==" "}return r}function Pt(e,t){return function(i,r,n,A,U,X,$){n=n?n+" cm-force-border":"cm-force-border";for(var Z=i.pos,le=Z+r.length;;){for(var ce=void 0,xe=0;xe<t.length&&!(ce=t[xe],ce.to>Z&&ce.from<=Z);xe++);if(ce.to>=le)return e(i,r,n,A,U,X,$);e(i,r.slice(0,ce.to-Z),n,A,null,X,$),A=null,r=r.slice(ce.to-Z),Z=ce.to}}}function Ft(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 Vt(e,t,i){var r=e.markedSpans,n=e.text,A=0;if(!r){for(var U=1;U<i.length;U+=2)t.addToken(t,n.slice(A,A=i[U]),ha(i[U+1],t.cm.options));return}for(var X=n.length,$=0,Z=1,le="",ce,xe,ye=0,ke,Fe,Je,nt,dt;;){if(ye==$){ke=Fe=Je=xe="",dt=null,nt=null,ye=Infinity;for(var at=[],pt=void 0,wt=0;wt<r.length;++wt){var St=r[wt],Mt=St.marker;if(Mt.type=="bookmark"&&St.from==$&&Mt.widgetNode)at.push(Mt);else if(St.from<=$&&(St.to==null||St.to>$||Mt.collapsed&&St.to==$&&St.from==$)){if(St.to!=null&&St.to!=$&&ye>St.to&&(ye=St.to,Fe=""),Mt.className&&(ke+=" "+Mt.className),Mt.css&&(xe=(xe?xe+";":"")+Mt.css),Mt.startStyle&&St.from==$&&(Je+=" "+Mt.startStyle),Mt.endStyle&&St.to==ye&&(pt||(pt=[])).push(Mt.endStyle,St.to),Mt.title&&((dt||(dt={})).title=Mt.title),Mt.attributes)for(var Zt in Mt.attributes)(dt||(dt={}))[Zt]=Mt.attributes[Zt];Mt.collapsed&&(!nt||Er(nt.marker,Mt)<0)&&(nt=St)}else St.from>$&&ye>St.from&&(ye=St.from)}if(pt)for(var br=0;br<pt.length;br+=2)pt[br+1]==ye&&(Fe+=" "+pt[br]);if(!nt||nt.from==$)for(var rr=0;rr<at.length;++rr)Ft(t,0,at[rr]);if(nt&&(nt.from||0)==$){if(Ft(t,(nt.to==null?X+1:nt.to)-$,nt.marker,nt.from==null),nt.to==null)return;nt.to==$&&(nt=!1)}}if($>=X)break;for(var zr=Math.min(X,ye);;){if(le){var Ir=$+le.length;if(!nt){var ur=Ir>zr?le.slice(0,zr-$):le;t.addToken(t,ur,ce?ce+ke:ke,Je,$+ur.length==ye?Fe:"",xe,dt)}if(Ir>=zr){le=le.slice(zr-$),$=zr;break}$=Ir,Je=""}le=n.slice(A,A=i[Z++]),ce=ha(i[Z++],t.cm.options)}}}function Bt(e,t,i){this.line=t,this.rest=bi(t),this.size=this.rest?Ot(Re(this.rest))-i+1:1,this.node=this.text=null,this.hidden=qr(e,t)}function tr(e,t,i){for(var r=[],n,A=t;A<i;A=n){var U=new Bt(e.doc,ut(e.doc,A),A);n=A+U.size,r.push(U)}return r}var gr=null;function It(e){gr?gr.ops.push(e):e.ownsGroup=gr={ops:[e],delayedCallbacks:[]}}function Pi(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 Yt(e,t){var i=e.ownsGroup;if(!i)return;try{Pi(i)}finally{gr=null,t(i)}}var Cr=null;function Qt(e,t){var i=qe(e,t);if(!i.length)return;var r=Array.prototype.slice.call(arguments,2),n;gr?n=gr.delayedCallbacks:Cr?n=Cr:(n=Cr=[],setTimeout(Jr,0));for(var A=function(X){n.push(function(){return i[X].apply(null,r)})},U=0;U<i.length;++U)A(U)}function Jr(){var e=Cr;Cr=null;for(var t=0;t<e.length;++t)e[t]()}function pn(e,t,i,r){for(var n=0;n<t.changes.length;n++){var A=t.changes[n];A=="text"?Ps(e,t):A=="gutter"?qa(e,t,i,r):A=="class"?ca(e,t):A=="widget"&&Is(e,t,r)}t.changes=null}function mn(e){return e.node==e.text&&(e.node=o("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),B&&N<8&&(e.node.style.zIndex=2)),e.node}function Ms(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=mn(t);t.background=r.insertBefore(o("div",null,i),r.firstChild),e.display.input.setUneditable(t.background)}}function Za(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):jn(e,t)}function Ps(e,t){var i=t.text.className,r=Za(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,ca(e,t)):i&&(t.text.className=i)}function ca(e,t){Ms(e,t),t.line.wrapClass?mn(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 qa(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=mn(t);t.gutterBackground=o("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 A=t.line.gutterMarkers;if(e.options.lineNumbers||A){var U=mn(t),X=t.gutter=o("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(X),U.insertBefore(X,t.text),t.line.gutterClass&&(X.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!A||!A["CodeMirror-linenumbers"])&&(t.lineNumber=X.appendChild(o("div",gi(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),A)for(var $=0;$<e.display.gutterSpecs.length;++$){var Z=e.display.gutterSpecs[$].className,le=A.hasOwnProperty(Z)&&A[Z];le&&X.appendChild(o("div",[le],"CodeMirror-gutter-elt","left: "+r.gutterLeft[Z]+"px; width: "+r.gutterWidth[Z]+"px"))}}}function Is(e,t,i){t.alignable&&(t.alignable=null);for(var r=T("CodeMirror-linewidget"),n=t.node.firstChild,A=void 0;n;n=A)A=n.nextSibling,r.test(n.className)&&t.node.removeChild(n);eo(e,t,i)}function Ns(e,t,i,r){var n=Za(e,t);return t.text=t.node=n.pre,n.bgClass&&(t.bgClass=n.bgClass),n.textClass&&(t.textClass=n.textClass),ca(e,t),qa(e,t,i,r),eo(e,t,r),t.node}function eo(e,t,i){if(to(e,t.line,t,i,!0),t.rest)for(var r=0;r<t.rest.length;r++)to(e,t.rest[r],t,i,!1)}function to(e,t,i,r,n){if(!t.widgets)return;for(var A=mn(i),U=0,X=t.widgets;U<X.length;++U){var $=X[U],Z=o("div",[$.node],"CodeMirror-linewidget"+($.className?" "+$.className:""));$.handleMouseEvents||Z.setAttribute("cm-ignore-events","true"),Bs($,Z,i,r),e.display.input.setUneditable(Z),n&&$.above?A.insertBefore(Z,i.gutter||i.text):A.appendChild(Z),Qt($,"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 gn(e){if(e.height!=null)return e.height;var t=e.doc.cm;if(!t)return 0;if(!v(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;"),u(t.display.measure,o("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function fi(e,t){for(var i=ve(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 Wn(e){return e.lineSpace.offsetTop}function fa(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function ro(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=u(e.measure,o("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 si(e){return ge-e.display.nativeBarWidth}function Ii(e){return e.display.scroller.clientWidth-si(e)-e.display.barWidth}function pa(e){return e.display.scroller.clientHeight-si(e)-e.display.barHeight}function Us(e,t,i){var r=e.options.lineWrapping,n=r&&Ii(e);if(!t.measure.heights||r&&t.measure.width!=n){var A=t.measure.heights=[];if(r){t.measure.width=n;for(var U=t.text.firstChild.getClientRects(),X=0;X<U.length-1;X++){var $=U[X],Z=U[X+1];Math.abs($.bottom-Z.bottom)>2&&A.push(($.bottom+Z.top)/2-i.top)}}A.push(i.bottom-i.top)}}function io(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(Ot(e.rest[n])>i)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Fs(e,t){t=cr(t);var i=Ot(t),r=e.display.externalMeasured=new Bt(e.doc,t,i);r.lineN=i;var n=r.built=jn(e,r);return r.text=n.pre,u(e.display.lineMeasure,n.pre),r}function no(e,t,i,r){return li(e,$i(e,t),i,r)}function ma(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Ui(e,t)];var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size)return i}function $i(e,t){var i=Ot(t),r=ma(e,i);r&&!r.text?r=null:r&&r.changes&&(pn(e,r,i,Ea(e)),e.curOp.forceUpdate=!0),r||(r=Fs(e,t));var n=io(r,t,i);return{line:t,view:r,rect:null,map:n.map,cache:n.cache,before:n.before,hasHeights:!1}}function li(e,t,i,r,n){t.before&&(i=-1);var A=i+(r||""),U;return t.cache.hasOwnProperty(A)?U=t.cache[A]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Us(e,t.view,t.rect),t.hasHeights=!0),U=Ws(e,t,i,r),U.bogus||(t.cache[A]=U)),{left:U.left,right:U.right,top:n?U.rtop:U.top,bottom:n?U.rbottom:U.bottom}}var ao={left:0,right:0,top:0,bottom:0};function oo(e,t,i){for(var r,n,A,U,X,$,Z=0;Z<e.length;Z+=3)if(X=e[Z],$=e[Z+1],t<X?(n=0,A=1,U="left"):t<$?(n=t-X,A=n+1):(Z==e.length-3||t==$&&e[Z+3]>t)&&(A=$-X,n=A-1,t>=$&&(U="right")),n!=null){if(r=e[Z+2],X==$&&i==(r.insertLeft?"left":"right")&&(U=i),i=="left"&&n==0)for(;Z&&e[Z-2]==e[Z-3]&&e[Z-1].insertLeft;)r=e[(Z-=3)+2],U="left";if(i=="right"&&n==$-X)for(;Z<e.length-3&&e[Z+3]==e[Z+4]&&!e[Z+5].insertLeft;)r=e[(Z+=3)+2],U="right";break}return{node:r,start:n,end:A,collapse:U,coverStart:X,coverEnd:$}}function js(e,t){var i=ao;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 Ws(e,t,i,r){var n=oo(t.map,i,r),A=n.node,U=n.start,X=n.end,$=n.collapse,Z;if(A.nodeType==3){for(var le=0;le<4;le++){for(;U&&Be(t.line.text.charAt(n.coverStart+U));)--U;for(;n.coverStart+X<n.coverEnd&&Be(t.line.text.charAt(n.coverStart+X));)++X;if(B&&N<9&&U==0&&X==n.coverEnd-n.coverStart?Z=A.parentNode.getBoundingClientRect():Z=js(E(A,U,X).getClientRects(),r),Z.left||Z.right||U==0)break;X=U,U=U-1,$="right"}B&&N<11&&(Z=Hs(e.display.measure,Z))}else{U>0&&($=r="right");var ce;e.options.lineWrapping&&(ce=A.getClientRects()).length>1?Z=ce[r=="right"?ce.length-1:0]:Z=A.getBoundingClientRect()}if(B&&N<9&&!U&&(!Z||!Z.left&&!Z.right)){var xe=A.parentNode.getClientRects()[0];xe?Z={left:xe.left,right:xe.left+Ji(e.display),top:xe.top,bottom:xe.bottom}:Z=ao}for(var ye=Z.top-t.rect.top,ke=Z.bottom-t.rect.top,Fe=(ye+ke)/2,Je=t.view.measure.heights,nt=0;nt<Je.length-1&&!(Fe<Je[nt]);nt++);var dt=nt?Je[nt-1]:0,at=Je[nt],pt={left:($=="right"?Z.right:Z.left)-t.rect.left,right:($=="left"?Z.left:Z.right)-t.rect.left,top:dt,bottom:at};return!Z.left&&!Z.right&&(pt.bogus=!0),e.options.singleCursorHeightPerLine||(pt.rtop=ye,pt.rbottom=ke),pt}function Hs(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!kt(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 so(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 lo(e){e.display.externalMeasure=null,c(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)so(e.display.view[t])}function vn(e){lo(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function uo(){return p&&d?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function ho(){return p&&d?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function ga(e){var t=0;if(e.widgets)for(var i=0;i<e.widgets.length;++i)e.widgets[i].above&&(t+=gn(e.widgets[i]));return t}function Hn(e,t,i,r,n){if(!n){var A=ga(t);i.top+=A,i.bottom+=A}if(r=="line")return i;r||(r="local");var U=Wr(t);if(r=="local"?U+=Wn(e.display):U-=e.display.viewOffset,r=="page"||r=="window"){var X=e.display.lineSpace.getBoundingClientRect();U+=X.top+(r=="window"?0:ho());var $=X.left+(r=="window"?0:uo());i.left+=$,i.right+=$}return i.top+=U,i.bottom+=U,i}function co(e,t,i){if(i=="div")return t;var r=t.left,n=t.top;if(i=="page")r-=uo(),n-=ho();else if(i=="local"||!i){var A=e.display.sizer.getBoundingClientRect();r+=A.left,n+=A.top}var U=e.display.lineSpace.getBoundingClientRect();return{left:r-U.left,top:n-U.top}}function va(e,t,i,r,n){return r||(r=ut(e.doc,t.line)),Hn(e,r,no(e,r,t.ch,n),i)}function ei(e,t,i,r,n,A){r=r||ut(e.doc,t.line),n||(n=$i(e,r));function U(ke,Fe){var Je=li(e,n,ke,Fe?"right":"left",A);return Fe?Je.left=Je.right:Je.right=Je.left,Hn(e,r,Je,i)}var X=Ve(r,e.doc.direction),$=t.ch,Z=t.sticky;if($>=r.text.length?($=r.text.length,Z="before"):$<=0&&($=0,Z="after"),!X)return U(Z=="before"?$-1:$,Z=="before");function le(ke,Fe,Je){var nt=X[Fe],dt=nt.level==1;return U(Je?ke-1:ke,dt!=Je)}var ce=Xe(X,$,Z),xe=Ue,ye=le($,ce,Z=="before");return xe!=null&&(ye.other=le($,xe,Z!="before")),ye}function fo(e,t){var i=0;t=s(e.doc,t),e.options.lineWrapping||(i=Ji(e.display)*t.ch);var r=ut(e.doc,t.line),n=Wr(r)+Wn(e.display);return{left:i,right:i,top:n,bottom:n+r.height}}function ya(e,t,i,r,n){var A=ze(e,t,i);return A.xRel=n,r&&(A.outside=r),A}function ba(e,t,i){var r=e.doc;if(i+=e.display.viewOffset,i<0)return ya(r.first,0,null,-1,-1);var n=zt(r,i),A=r.first+r.size-1;if(n>A)return ya(r.first+r.size-1,ut(r,A).text.length,null,1,1);t<0&&(t=0);for(var U=ut(r,n);;){var X=zs(e,U,n,t,i),$=yi(U,X.ch+(X.xRel>0||X.outside>0?1:0));if(!$)return X;var Z=$.find(1);if(Z.line==n)return Z;U=ut(r,n=Z.line)}}function po(e,t,i,r){r-=ga(t);var n=t.text.length,A=ft(function(U){return li(e,i,U-1).bottom<=r},n,0);return n=ft(function(U){return li(e,i,U).top>r},A,n),{begin:A,end:n}}function mo(e,t,i,r){i||(i=$i(e,t));var n=Hn(e,t,li(e,i,r),"line").top;return po(e,t,i,n)}function xa(e,t,i,r){return e.bottom<=i?!1:e.top>i?!0:(r?e.left:e.right)>t}function zs(e,t,i,r,n){n-=Wr(t);var A=$i(e,t),U=ga(t),X=0,$=t.text.length,Z=!0,le=Ve(t,e.doc.direction);if(le){var ce=(e.options.lineWrapping?Ks:Gs)(e,t,i,A,le,r,n);Z=ce.level!=1,X=Z?ce.from:ce.to-1,$=Z?ce.to:ce.from-1}var xe=null,ye=null,ke=ft(function(wt){var St=li(e,A,wt);return St.top+=U,St.bottom+=U,xa(St,r,n,!1)?(St.top<=n&&St.left<=r&&(xe=wt,ye=St),!0):!1},X,$),Fe,Je,nt=!1;if(ye){var dt=r-ye.left<ye.right-r,at=dt==Z;ke=xe+(at?0:1),Je=at?"after":"before",Fe=dt?ye.left:ye.right}else{!Z&&(ke==$||ke==X)&&ke++,Je=ke==0?"after":ke==t.text.length?"before":li(e,A,ke-(Z?1:0)).bottom+U<=n==Z?"after":"before";var pt=ei(e,ze(i,ke,Je),"line",t,A);Fe=pt.left,nt=n<pt.top?-1:n>=pt.bottom?1:0}return ke=We(t.text,ke,1),ya(i,ke,Je,nt,r-Fe)}function Gs(e,t,i,r,n,A,U){var X=ft(function(ce){var xe=n[ce],ye=xe.level!=1;return xa(ei(e,ze(i,ye?xe.to:xe.from,ye?"before":"after"),"line",t,r),A,U,!0)},0,n.length-1),$=n[X];if(X>0){var Z=$.level!=1,le=ei(e,ze(i,Z?$.from:$.to,Z?"after":"before"),"line",t,r);xa(le,A,U,!0)&&le.top>U&&($=n[X-1])}return $}function Ks(e,t,i,r,n,A,U){var X=po(e,t,r,U),$=X.begin,Z=X.end;/\s/.test(t.text.charAt(Z-1))&&Z--;for(var le=null,ce=null,xe=0;xe<n.length;xe++){var ye=n[xe];if(ye.from>=Z||ye.to<=$)continue;var ke=ye.level!=1,Fe=li(e,r,ke?Math.min(Z,ye.to)-1:Math.max($,ye.from)).right,Je=Fe<A?A-Fe+1e9:Fe-A;(!le||ce>Je)&&(le=ye,ce=Je)}return le||(le=n[n.length-1]),le.from<$&&(le={from:$,to:le.to,level:le.level}),le.to>Z&&(le={from:le.from,to:Z,level:le.level}),le}var Ni;function Qi(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Ni==null){Ni=o("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Ni.appendChild(document.createTextNode("x")),Ni.appendChild(o("br"));Ni.appendChild(document.createTextNode("x"))}u(e.measure,Ni);var i=Ni.offsetHeight/50;return i>3&&(e.cachedTextHeight=i),c(e.measure),i||1}function Ji(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=o("span","xxxxxxxxxx"),i=o("pre",[t],"CodeMirror-line-like");u(e.measure,i);var r=t.getBoundingClientRect(),n=(r.right-r.left)/10;return n>2&&(e.cachedCharWidth=n),n||10}function Ea(e){for(var t=e.display,i={},r={},n=t.gutters.clientLeft,A=t.gutters.firstChild,U=0;A;A=A.nextSibling,++U){var X=e.display.gutterSpecs[U].className;i[X]=A.offsetLeft+A.clientLeft+n,r[X]=A.clientWidth}return{fixedPos:Sa(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:i,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Sa(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function go(e){var t=Qi(e.display),i=e.options.lineWrapping,r=i&&Math.max(5,e.display.scroller.clientWidth/Ji(e.display)-3);return function(n){if(qr(e.doc,n))return 0;var A=0;if(n.widgets)for(var U=0;U<n.widgets.length;U++)n.widgets[U].height&&(A+=n.widgets[U].height);return i?A+(Math.ceil(n.text.length/r)||1)*t:A+t}}function Ca(e){var t=e.doc,i=go(e);t.iter(function(r){var n=i(r);n!=r.height&&Nt(r,n)})}function Bi(e,t,i,r){var n=e.display;if(!i&&ve(t).getAttribute("cm-not-content")=="true")return null;var A,U,X=n.lineSpace.getBoundingClientRect();try{A=t.clientX-X.left,U=t.clientY-X.top}catch(ce){return null}var $=ba(e,A,U),Z;if(r&&$.xRel>0&&(Z=ut(e.doc,$.line).text).length==$.ch){var le=ee(Z,Z.length,e.options.tabSize)-Z.length;$=ze($.line,Math.max(0,Math.round((A-ro(e.display).left)/Ji(e.display))-le))}return $}function Ui(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 Mr(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)kr&&xi(e.doc,t)<n.viewTo&&Ci(e);else if(i<=n.viewFrom)kr&&Fn(e.doc,i+r)>n.viewFrom?Ci(e):(n.viewFrom+=r,n.viewTo+=r);else if(t<=n.viewFrom&&i>=n.viewTo)Ci(e);else if(t<=n.viewFrom){var A=zn(e,i,i+r,1);A?(n.view=n.view.slice(A.index),n.viewFrom=A.lineN,n.viewTo+=r):Ci(e)}else if(i>=n.viewTo){var U=zn(e,t,t,-1);U?(n.view=n.view.slice(0,U.index),n.viewTo=U.lineN):Ci(e)}else{var X=zn(e,t,t,-1),$=zn(e,i,i+r,1);X&&$?(n.view=n.view.slice(0,X.index).concat(tr(e,X.lineN,$.lineN)).concat(n.view.slice($.index)),n.viewTo+=r):Ci(e)}var Z=n.externalMeasured;Z&&(i<Z.lineN?Z.lineN+=r:t<Z.lineN+Z.size&&(n.externalMeasured=null))}function Si(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 A=r.view[Ui(e,t)];if(A.node==null)return;var U=A.changes||(A.changes=[]);he(U,i)==-1&&U.push(i)}function Ci(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zn(e,t,i,r){var n=Ui(e,t),A,U=e.display.view;if(!kr||i==e.doc.first+e.doc.size)return{index:n,lineN:i};for(var X=e.display.viewFrom,$=0;$<n;$++)X+=U[$].size;if(X!=t){if(r>0){if(n==U.length-1)return null;A=X+U[n].size-t,n++}else A=X-t;t+=A,i+=A}for(;xi(e.doc,i)!=i;){if(n==(r<0?0:U.length-1))return null;i+=r*U[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=tr(e,t,i),r.viewFrom=t):(r.viewFrom>t?r.view=tr(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Ui(e,t))),r.viewFrom=t,r.viewTo<i?r.view=r.view.concat(tr(e,r.viewTo,i)):r.viewTo>i&&(r.view=r.view.slice(0,Ui(e,i)))),r.viewTo=i}function vo(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 yn(e){e.display.input.showSelection(e.display.input.prepareSelection())}function yo(e,t){t===void 0&&(t=!0);for(var i=e.doc,r={},n=r.cursors=document.createDocumentFragment(),A=r.selection=document.createDocumentFragment(),U=0;U<i.sel.ranges.length;U++){if(!t&&U==i.sel.primIndex)continue;var X=i.sel.ranges[U];if(X.from().line>=e.display.viewTo||X.to().line<e.display.viewFrom)continue;var $=X.empty();($||e.options.showCursorWhenSelecting)&&bo(e,X.head,n),$||Xs(e,X,A)}return r}function bo(e,t,i){var r=ei(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),n=i.appendChild(o("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 A=i.appendChild(o("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));A.style.display="",A.style.left=r.other.left+"px",A.style.top=r.other.top+"px",A.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function Gn(e,t){return e.top-t.top||e.left-t.left}function Xs(e,t,i){var r=e.display,n=e.doc,A=document.createDocumentFragment(),U=ro(e.display),X=U.left,$=Math.max(r.sizerWidth,Ii(e)-r.sizer.offsetLeft)-U.right,Z=n.direction=="ltr";function le(at,pt,wt,St){pt<0&&(pt=0),pt=Math.round(pt),St=Math.round(St),A.appendChild(o("div",null,"CodeMirror-selected","position: absolute; left: "+at+`px;
top: `+pt+"px; width: "+(wt==null?$-at:wt)+`px;
height: `+(St-pt)+"px"))}function ce(at,pt,wt){var St=ut(n,at),Mt=St.text.length,Zt,br;function rr(ur,Nr){return va(e,ze(at,ur),"div",St,Nr)}function zr(ur,Nr,Tr){var fr=mo(e,St,null,ur),dr=Nr=="ltr"==(Tr=="after")?"left":"right",nr=Tr=="after"?fr.begin:fr.end-(/\s/.test(St.text.charAt(fr.end-1))?2:1);return rr(nr,dr)[dr]}var Ir=Ve(St,n.direction);return Ke(Ir,pt||0,wt==null?Mt:wt,function(ur,Nr,Tr,fr){var dr=Tr=="ltr",nr=rr(ur,dr?"left":"right"),Br=rr(Nr-1,dr?"right":"left"),hn=pt==null&&ur==0,Di=wt==null&&Nr==Mt,Ar=fr==0,ui=!Ir||fr==Ir.length-1;if(Br.top-nr.top<=3){var xr=(Z?hn:Di)&&Ar,Ya=(Z?Di:hn)&&ui,mi=xr?X:(dr?nr:Br).left,zi=Ya?$:(dr?Br:nr).right;le(mi,nr.top,zi-mi,nr.bottom)}else{var Gi,Dr,cn,$a;dr?(Gi=Z&&hn&&Ar?X:nr.left,Dr=Z?$:zr(ur,Tr,"before"),cn=Z?X:zr(Nr,Tr,"after"),$a=Z&&Di&&ui?$:Br.right):(Gi=Z?zr(ur,Tr,"before"):X,Dr=!Z&&hn&&Ar?$:nr.right,cn=!Z&&Di&&ui?X:Br.left,$a=Z?zr(Nr,Tr,"after"):$),le(Gi,nr.top,Dr-Gi,nr.bottom),nr.bottom<Br.top&&le(X,nr.bottom,null,Br.top),le(cn,Br.top,$a-cn,Br.bottom)}(!Zt||Gn(nr,Zt)<0)&&(Zt=nr),Gn(Br,Zt)<0&&(Zt=Br),(!br||Gn(nr,br)<0)&&(br=nr),Gn(Br,br)<0&&(br=Br)}),{start:Zt,end:br}}var xe=t.from(),ye=t.to();if(xe.line==ye.line)ce(xe.line,xe.ch,ye.ch);else{var ke=ut(n,xe.line),Fe=ut(n,ye.line),Je=cr(ke)==cr(Fe),nt=ce(xe.line,xe.ch,Je?ke.text.length+1:null).end,dt=ce(ye.line,Je?0:null,ye.ch).start;Je&&(nt.top<dt.top-2?(le(nt.right,nt.top,null,nt.bottom),le(X,dt.top,dt.left,dt.bottom)):le(nt.right,nt.top,dt.left-nt.right,nt.bottom)),nt.bottom<dt.top&&le(X,nt.bottom,null,dt.top)}i.appendChild(A)}function Ta(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()||Zi(e),t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function xo(e){e.state.focused||(e.display.input.focus(),wa(e))}function Eo(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Zi(e))},100)}function wa(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,j(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),M&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Ta(e)}function Zi(e,t){if(e.state.delayingBlurEvent)return;e.state.focused&&(Ae(e,"blur",e,t),e.state.focused=!1,g(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Kn(e){for(var t=e.display,i=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var n=t.view[r],A=e.options.lineWrapping,U=void 0,X=0;if(n.hidden)continue;if(B&&N<8){var $=n.node.offsetTop+n.node.offsetHeight;U=$-i,i=$}else{var Z=n.node.getBoundingClientRect();U=Z.bottom-Z.top,!A&&n.text.firstChild&&(X=n.text.firstChild.getBoundingClientRect().right-Z.left-1)}var le=n.line.height-U;if((le>.005||le<-.005)&&(Nt(n.line,U),So(n.line),n.rest))for(var ce=0;ce<n.rest.length;ce++)So(n.rest[ce]);if(X>e.display.sizerWidth){var xe=Math.ceil(X/Ji(e.display));xe>e.display.maxLineLength&&(e.display.maxLineLength=xe,e.display.maxLine=n.line,e.display.maxLineChanged=!0)}}}function So(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 Vn(e,t,i){var r=i&&i.top!=null?Math.max(0,i.top):e.scroller.scrollTop;r=Math.floor(r-Wn(e));var n=i&&i.bottom!=null?i.bottom:r+e.wrapper.clientHeight,A=zt(t,r),U=zt(t,n);if(i&&i.ensure){var X=i.ensure.from.line,$=i.ensure.to.line;X<A?(A=X,U=zt(t,Wr(ut(t,X))+e.wrapper.clientHeight)):Math.min($,t.lastLine())>=U&&(A=zt(t,Wr(ut(t,$))-e.wrapper.clientHeight),U=$)}return{from:A,to:Math.max(U,A+1)}}function Ys(e,t){if(Oe(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&&!x){var A=o("div","\u200B",null,`position: absolute;
top: `+(t.top-i.viewOffset-Wn(e.display))+`px;
height: `+(t.bottom-t.top+si(e)+i.barHeight)+`px;
left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(A),A.scrollIntoView(n),e.display.lineSpace.removeChild(A)}}function $s(e,t,i,r){r==null&&(r=0);var n;!e.options.lineWrapping&&t==i&&(t=t.ch?ze(t.line,t.sticky=="before"?t.ch-1:t.ch,"after"):t,i=t.sticky=="before"?ze(t.line,t.ch+1,"before"):t);for(var A=0;A<5;A++){var U=!1,X=ei(e,t),$=!i||i==t?X:ei(e,i);n={left:Math.min(X.left,$.left),top:Math.min(X.top,$.top)-r,right:Math.max(X.left,$.left),bottom:Math.max(X.bottom,$.bottom)+r};var Z=La(e,n),le=e.doc.scrollTop,ce=e.doc.scrollLeft;if(Z.scrollTop!=null&&(xn(e,Z.scrollTop),Math.abs(e.doc.scrollTop-le)>1&&(U=!0)),Z.scrollLeft!=null&&(Fi(e,Z.scrollLeft),Math.abs(e.doc.scrollLeft-ce)>1&&(U=!0)),!U)break}return n}function Qs(e,t){var i=La(e,t);i.scrollTop!=null&&xn(e,i.scrollTop),i.scrollLeft!=null&&Fi(e,i.scrollLeft)}function La(e,t){var i=e.display,r=Qi(e.display);t.top<0&&(t.top=0);var n=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:i.scroller.scrollTop,A=pa(e),U={};t.bottom-t.top>A&&(t.bottom=t.top+A);var X=e.doc.height+fa(i),$=t.top<r,Z=t.bottom>X-r;if(t.top<n)U.scrollTop=$?0:t.top;else if(t.bottom>n+A){var le=Math.min(t.top,(Z?X:t.bottom)-A);le!=n&&(U.scrollTop=le)}var ce=e.options.fixedGutter?0:i.gutters.offsetWidth,xe=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:i.scroller.scrollLeft-ce,ye=Ii(e)-i.gutters.offsetWidth,ke=t.right-t.left>ye;return ke&&(t.right=t.left+ye),t.left<10?U.scrollLeft=0:t.left<xe?U.scrollLeft=Math.max(0,t.left+ce-(ke?0:10)):t.right>ye+xe-3&&(U.scrollLeft=t.right+(ke?0:10)-ye),U}function Aa(e,t){if(t==null)return;Xn(e),e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+t}function qi(e){Xn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function bn(e,t,i){(t!=null||i!=null)&&Xn(e),t!=null&&(e.curOp.scrollLeft=t),i!=null&&(e.curOp.scrollTop=i)}function Js(e,t){Xn(e),e.curOp.scrollToPos=t}function Xn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=fo(e,t.from),r=fo(e,t.to);Co(e,i,r,t.margin)}}function Co(e,t,i,r){var n=La(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});bn(e,n.scrollLeft,n.scrollTop)}function xn(e,t){if(Math.abs(e.doc.scrollTop-t)<2)return;D||Da(e,{top:t}),To(e,t,!0),D&&Da(e),Cn(e,100)}function To(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,Do(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t)}function En(e){var t=e.display,i=t.gutters.offsetWidth,r=Math.round(e.doc.height+fa(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+si(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var ji=function(e,t,i){this.cm=i;var r=this.vert=o("div",[o("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n=this.horiz=o("div",[o("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=n.tabIndex=-1,e(r),e(n),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(n,"scroll",function(){n.clientWidth&&t(n.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,B&&N<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};ji.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 A=e.viewWidth-e.barLeft-(i?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+A)+"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}},ji.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},ji.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},ji.prototype.zeroWidthHack=function(){var e=l&&!L?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new oe,this.disableVert=new oe},ji.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function r(){var n=e.getBoundingClientRect(),A=i=="vert"?document.elementFromPoint(n.right-1,(n.top+n.bottom)/2):document.elementFromPoint((n.right+n.left)/2,n.bottom-1);A!=e?e.style.pointerEvents="none":t.set(1e3,r)}t.set(1e3,r)},ji.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Sn=function(){};Sn.prototype.update=function(){return{bottom:0,right:0}},Sn.prototype.setScrollLeft=function(){},Sn.prototype.setScrollTop=function(){},Sn.prototype.clear=function(){};function en(e,t){t||(t=En(e));var i=e.display.barWidth,r=e.display.barHeight;wo(e,t);for(var n=0;n<4&&i!=e.display.barWidth||r!=e.display.barHeight;n++)i!=e.display.barWidth&&e.options.lineWrapping&&Kn(e),wo(e,En(e)),i=e.display.barWidth,r=e.display.barHeight}function wo(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 Lo={native:ji,null:Sn};function Ao(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&g(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Lo[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),we(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):xn(e,t)},e),e.display.scrollbars.addClass&&j(e.display.wrapper,e.display.scrollbars.addClass)}var Zs=0;function Wi(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Zs},It(e.curOp)}function Hi(e){var t=e.curOp;t&&Yt(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 A=0;A<t.length;A++)il(t[A]);for(var U=0;U<t.length;U++)nl(t[U])}function el(e){var t=e.cm,i=t.display;ol(t),e.updateMaxLine&&ci(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 Yn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function tl(e){e.updatedDisplay=e.mustUpdate&&_a(e.cm,e.update)}function rl(e){var t=e.cm,i=t.display;e.updatedDisplay&&Kn(t),e.barMeasure=En(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=no(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+si(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Ii(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==O();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,i),(e.updatedDisplay||e.startHeight!=t.doc.height)&&en(t,e.barMeasure),e.updatedDisplay&&ka(t,e.barMeasure),e.selectionChanged&&Ta(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),i&&xo(e.cm)}function nl(e){var t=e.cm,i=t.display,r=t.doc;if(e.updatedDisplay&&_o(t,e.update),i.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(i.wheelStartX=i.wheelStartY=null),e.scrollTop!=null&&To(t,e.scrollTop,e.forceScroll),e.scrollLeft!=null&&Fi(t,e.scrollLeft,!0,!0),e.scrollToPos){var n=$s(t,s(r,e.scrollToPos.from),s(r,e.scrollToPos.to),e.scrollToPos.margin);Ys(t,n)}var A=e.maybeHiddenMarkers,U=e.maybeUnhiddenMarkers;if(A)for(var X=0;X<A.length;++X)A[X].lines.length||Ae(A[X],"hide");if(U)for(var $=0;$<U.length;++$)U[$].lines.length&&Ae(U[$],"unhide");i.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&Ae(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function Hr(e,t){if(e.curOp)return t();Wi(e);try{return t()}finally{Hi(e)}}function vr(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Wi(e);try{return t.apply(e,arguments)}finally{Hi(e)}}}function _r(e){return function(){if(this.curOp)return e.apply(this,arguments);Wi(this);try{return e.apply(this,arguments)}finally{Hi(this)}}}function yr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);Wi(t);try{return e.apply(this,arguments)}finally{Hi(t)}}}function Cn(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,K(al,e))}function al(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo)return;var i=+new Date+e.options.workTime,r=Se(e,t.highlightFrontier),n=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(A){if(r.line>=e.display.viewFrom){var U=A.styles,X=A.text.length>e.options.maxHighlightLength?wr(t.mode,r.state):null,$=fe(e,A,r,!0);X&&(r.state=X),A.styles=$.styles;var Z=A.styleClasses,le=$.classes;le?A.styleClasses=le:Z&&(A.styleClasses=null);for(var ce=!U||U.length!=A.styles.length||Z!=le&&(!Z||!le||Z.bgClass!=le.bgClass||Z.textClass!=le.textClass),xe=0;!ce&&xe<U.length;++xe)ce=U[xe]!=A.styles[xe];ce&&n.push(r.line),A.stateAfter=r.save(),r.nextLine()}else A.text.length<=e.options.maxHighlightLength&&vt(e,A.text,r),A.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>i)return Cn(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),n.length&&Hr(e,function(){for(var A=0;A<n.length;A++)Si(e,n[A],"text")})}var Yn=function(e,t,i){var r=e.display;this.viewport=t,this.visible=Vn(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Ii(e),this.force=i,this.dims=Ea(e),this.events=[]};Yn.prototype.signal=function(e,t){de(e,t)&&this.events.push(arguments)},Yn.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=si(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=si(e)+"px",t.scrollbarsClipped=!0)}function sl(e){if(e.hasFocus())return null;var t=O();if(!t||!v(e.display.lineDiv,t))return null;var i={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&v(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==O())return;if(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&v(document.body,e.anchorNode)&&v(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 _a(e,t){var i=e.display,r=e.doc;if(t.editorIsHidden)return Ci(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&&vo(e)==0)return!1;Ro(e)&&(Ci(e),t.dims=Ea(e));var n=r.first+r.size,A=Math.max(t.visible.from-e.options.viewportMargin,r.first),U=Math.min(n,t.visible.to+e.options.viewportMargin);i.viewFrom<A&&A-i.viewFrom<20&&(A=Math.max(r.first,i.viewFrom)),i.viewTo>U&&i.viewTo-U<20&&(U=Math.min(n,i.viewTo)),kr&&(A=xi(e.doc,A),U=Fn(e.doc,U));var X=A!=i.viewFrom||U!=i.viewTo||i.lastWrapHeight!=t.wrapperHeight||i.lastWrapWidth!=t.wrapperWidth;Vs(e,A,U),i.viewOffset=Wr(ut(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var $=vo(e);if(!X&&$==0&&!t.force&&i.renderedView==i.view&&(i.updateLineNumbers==null||i.updateLineNumbers>=i.viewTo))return!1;var Z=sl(e);return $>4&&(i.lineDiv.style.display="none"),ul(e,i.updateLineNumbers,t.dims),$>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,ll(Z),c(i.cursorDiv),c(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,X&&(i.lastWrapHeight=t.wrapperHeight,i.lastWrapWidth=t.wrapperWidth,Cn(e,400)),i.updateLineNumbers=null,!0}function _o(e,t){for(var i=t.viewport,r=!0;;r=!1){if(!r||!e.options.lineWrapping||t.oldDisplayWidth==Ii(e)){if(i&&i.top!=null&&(i={top:Math.min(e.doc.height+fa(e.display)-pa(e),i.top)}),t.visible=Vn(e.display,e.doc,i),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}else r&&(t.visible=Vn(e.display,e.doc,i));if(!_a(e,t))break;Kn(e);var n=En(e);yn(e),en(e,n),ka(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 Da(e,t){var i=new Yn(e,t);if(_a(e,i)){Kn(e),_o(e,i);var r=En(e);yn(e),en(e,r),ka(e,r),i.finish()}}function ul(e,t,i){var r=e.display,n=e.options.lineNumbers,A=r.lineDiv,U=A.firstChild;function X(ke){var Fe=ke.nextSibling;return M&&l&&e.display.currentWheelTarget==ke?ke.style.display="none":ke.parentNode.removeChild(ke),Fe}for(var $=r.view,Z=r.viewFrom,le=0;le<$.length;le++){var ce=$[le];if(!ce.hidden)if(!ce.node||ce.node.parentNode!=A){var xe=Ns(e,ce,Z,i);A.insertBefore(xe,U)}else{for(;U!=ce.node;)U=X(U);var ye=n&&t!=null&&t<=Z&&ce.lineNumber;ce.changes&&(he(ce.changes,"gutter")>-1&&(ye=!1),pn(e,ce,Z,i)),ye&&(c(ce.lineNumber),ce.lineNumber.appendChild(document.createTextNode(gi(e.options,Z)))),U=ce.node.nextSibling}Z+=ce.size}for(;U;)U=X(U)}function Ra(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function ka(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+si(e)+"px"}function Do(e){var t=e.display,i=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;for(var r=Sa(t)-t.scroller.scrollLeft+e.doc.scrollLeft,n=t.gutters.offsetWidth,A=r+"px",U=0;U<i.length;U++)if(!i[U].hidden){e.options.fixedGutter&&(i[U].gutter&&(i[U].gutter.style.left=A),i[U].gutterBackground&&(i[U].gutterBackground.style.left=A));var X=i[U].alignable;if(X)for(var $=0;$<X.length;$++)X[$].style.left=A}e.options.fixedGutter&&(t.gutters.style.left=r+n+"px")}function Ro(e){if(!e.options.lineNumbers)return!1;var t=e.doc,i=gi(e.options,t.first+t.size-1),r=e.display;if(i.length!=r.lineNumChars){var n=r.measure.appendChild(o("div",[o("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),A=n.firstChild.offsetWidth,U=n.offsetWidth-A;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(A,r.lineGutter.offsetWidth-U)+1,r.lineNumWidth=r.lineNumInnerWidth+U,r.lineNumChars=r.lineNumInnerWidth?i.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",Ra(e.display),!0}return!1}function Oa(e,t){for(var i=[],r=!1,n=0;n<e.length;n++){var A=e[n],U=null;if(typeof A!="string"&&(U=A.style,A=A.className),A=="CodeMirror-linenumbers")if(t)r=!0;else continue;i.push({className:A,style:U})}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],A=n.className,U=n.style,X=t.appendChild(o("div",null,"CodeMirror-gutter "+A));U&&(X.style.cssText=U),A=="CodeMirror-linenumbers"&&(e.lineGutter=X,X.style.width=(e.lineNumWidth||1)+"px")}t.style.display=i.length?"":"none",Ra(e)}function Tn(e){ko(e.display),Mr(e),Do(e)}function dl(e,t,i,r){var n=this;this.input=i,n.scrollbarFiller=o("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=o("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=C("div",null,"CodeMirror-code"),n.selectionDiv=o("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=o("div",null,"CodeMirror-cursors"),n.measure=o("div",null,"CodeMirror-measure"),n.lineMeasure=o("div",null,"CodeMirror-measure"),n.lineSpace=C("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var A=C("div",[n.lineSpace],"CodeMirror-lines");n.mover=o("div",[A],null,"position: relative"),n.sizer=o("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=o("div",null,null,"position: absolute; height: "+ge+"px; width: 1px;"),n.gutters=o("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=o("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=o("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),B&&N<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),!M&&!(D&&a)&&(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=Oa(r.gutters,r.lineNumbers),ko(n),i.init(n)}var $n=0,Xr=null;B?Xr=-.53:D?Xr=15:p?Xr=-.7:P&&(Xr=-1/3);function Oo(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 hl(e){var t=Oo(e);return t.x*=Xr,t.y*=Xr,t}function Mo(e,t){var i=Oo(t),r=i.x,n=i.y,A=e.display,U=A.scroller,X=U.scrollWidth>U.clientWidth,$=U.scrollHeight>U.clientHeight;if(!(r&&X||n&&$))return;if(n&&l&&M){e:for(var Z=t.target,le=A.view;Z!=U;Z=Z.parentNode)for(var ce=0;ce<le.length;ce++)if(le[ce].node==Z){e.display.currentWheelTarget=Z;break e}}if(r&&!D&&!y&&Xr!=null){n&&$&&xn(e,Math.max(0,U.scrollTop+n*Xr)),Fi(e,Math.max(0,U.scrollLeft+r*Xr)),(!n||n&&$)&&te(t),A.wheelStartX=null;return}if(n&&Xr!=null){var xe=n*Xr,ye=e.doc.scrollTop,ke=ye+A.wrapper.clientHeight;xe<0?ye=Math.max(0,ye+xe-50):ke=Math.min(e.doc.height,ke+xe+50),Da(e,{top:ye,bottom:ke})}$n<20&&(A.wheelStartX==null?(A.wheelStartX=U.scrollLeft,A.wheelStartY=U.scrollTop,A.wheelDX=r,A.wheelDY=n,setTimeout(function(){if(A.wheelStartX==null)return;var Fe=U.scrollLeft-A.wheelStartX,Je=U.scrollTop-A.wheelStartY,nt=Je&&A.wheelDY&&Je/A.wheelDY||Fe&&A.wheelDX&&Fe/A.wheelDX;if(A.wheelStartX=A.wheelStartY=null,!nt)return;Xr=(Xr*$n+nt)/($n+1),++$n},200)):(A.wheelDX+=r,A.wheelDY+=n))}var Yr=function(e,t){this.ranges=e,this.primIndex=t};Yr.prototype.primary=function(){return this.ranges[this.primIndex]},Yr.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(!ii(i.anchor,r.anchor)||!ii(i.head,r.head))return!1}return!0},Yr.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new Gt(di(this.ranges[t].anchor),di(this.ranges[t].head));return new Yr(e,this.primIndex)},Yr.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Yr.prototype.contains=function(e,t){t||(t=e);for(var i=0;i<this.ranges.length;i++){var r=this.ranges[i];if(At(t,r.from())>=0&&At(e,r.to())<=0)return i}return-1};var Gt=function(e,t){this.anchor=e,this.head=t};Gt.prototype.from=function(){return Ri(this.anchor,this.head)},Gt.prototype.to=function(){return hi(this.anchor,this.head)},Gt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function ti(e,t,i){var r=e&&e.options.selectionsMayTouch,n=t[i];t.sort(function(xe,ye){return At(xe.from(),ye.from())}),i=he(t,n);for(var A=1;A<t.length;A++){var U=t[A],X=t[A-1],$=At(X.to(),U.from());if(r&&!U.empty()?$>0:$>=0){var Z=Ri(X.from(),U.from()),le=hi(X.to(),U.to()),ce=X.empty()?U.from()==U.head:X.from()==X.head;A<=i&&--i,t.splice(--A,2,new Gt(ce?le:Z,ce?Z:le))}}return new Yr(t,i)}function Ti(e,t){return new Yr([new Gt(e,t||e)],0)}function wi(e){return e.text?ze(e.from.line+e.text.length-1,Re(e.text).length+(e.text.length==1?e.from.ch:0)):e.to}function Po(e,t){if(At(e,t.from)<0)return e;if(At(e,t.to)<=0)return wi(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+=wi(t).ch-t.to.ch),ze(i,r)}function Ma(e,t){for(var i=[],r=0;r<e.sel.ranges.length;r++){var n=e.sel.ranges[r];i.push(new Gt(Po(n.anchor,t),Po(n.head,t)))}return ti(e.cm,i,e.sel.primIndex)}function Io(e,t,i){return e.line==t.line?ze(i.line,e.ch-t.ch+i.ch):ze(i.line+(e.line-t.line),e.ch)}function cl(e,t,i){for(var r=[],n=ze(e.first,0),A=n,U=0;U<t.length;U++){var X=t[U],$=Io(X.from,n,A),Z=Io(wi(X),n,A);if(n=X.to,A=Z,i=="around"){var le=e.sel.ranges[U],ce=At(le.head,le.anchor)<0;r[U]=new Gt(ce?Z:$,ce?$:Z)}else r[U]=new Gt($,$)}return new Yr(r,e.sel.primIndex)}function Pa(e){e.doc.mode=ir(e.options,e.doc.modeOption),wn(e)}function wn(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,Cn(e,100),e.state.modeGen++,e.curOp&&Mr(e)}function No(e,t){return t.from.ch==0&&t.to.ch==0&&Re(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ia(e,t,i,r){function n(dt){return i?i[dt]:null}function A(dt,at,pt){ua(dt,at,pt,r),Qt(dt,"change",dt,t)}function U(dt,at){for(var pt=[],wt=dt;wt<at;++wt)pt.push(new Ei(Z[wt],n(wt),r));return pt}var X=t.from,$=t.to,Z=t.text,le=ut(e,X.line),ce=ut(e,$.line),xe=Re(Z),ye=n(Z.length-1),ke=$.line-X.line;if(t.full)e.insert(0,U(0,Z.length)),e.remove(Z.length,e.size-Z.length);else if(No(e,t)){var Fe=U(0,Z.length-1);A(ce,ce.text,ye),ke&&e.remove(X.line,ke),Fe.length&&e.insert(X.line,Fe)}else if(le==ce)if(Z.length==1)A(le,le.text.slice(0,X.ch)+xe+le.text.slice($.ch),ye);else{var Je=U(1,Z.length-1);Je.push(new Ei(xe+le.text.slice($.ch),ye,r)),A(le,le.text.slice(0,X.ch)+Z[0],n(0)),e.insert(X.line+1,Je)}else if(Z.length==1)A(le,le.text.slice(0,X.ch)+Z[0]+ce.text.slice($.ch),n(0)),e.remove(X.line+1,ke);else{A(le,le.text.slice(0,X.ch)+Z[0],n(0)),A(ce,xe+ce.text.slice($.ch),ye);var nt=U(1,Z.length-1);ke>1&&e.remove(X.line+1,ke-1),e.insert(X.line+1,nt)}Qt(e,"change",e,t)}function Li(e,t,i){function r(n,A,U){if(n.linked)for(var X=0;X<n.linked.length;++X){var $=n.linked[X];if($.doc==A)continue;var Z=U&&$.sharedHist;if(i&&!Z)continue;t($.doc,Z),r($.doc,n,Z)}}r(e,null,!0)}function Bo(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,Ca(e),Pa(e),Uo(e),e.options.lineWrapping||ci(e),e.options.mode=t.modeOption,Mr(e)}function Uo(e){(e.doc.direction=="rtl"?j:g)(e.display.lineDiv,"CodeMirror-rtl")}function fl(e){Hr(e,function(){Uo(e),Mr(e)})}function Qn(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 Na(e,t){var i={from:di(t.from),to:wi(t),text:qt(e,t.from,t.to)};return Wo(e,i,t.from.line,t.to.line+1),Li(e,function(r){return Wo(r,i,t.from.line,t.to.line+1)},!0),i}function Fo(e){for(;e.length;){var t=Re(e);if(t.ranges)e.pop();else break}}function pl(e,t){if(t)return Fo(e.done),Re(e.done);if(e.done.length&&!Re(e.done).ranges)return Re(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Re(e.done)}function jo(e,t,i,r){var n=e.history;n.undone.length=0;var A=+new Date,U,X;if((n.lastOp==r||n.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.lastModTime>A-(e.cm?e.cm.options.historyEventDelay:500)||t.origin.charAt(0)=="*"))&&(U=pl(n,n.lastOp==r)))X=Re(U.changes),At(t.from,t.to)==0&&At(t.from,X.to)==0?X.to=wi(t):U.changes.push(Na(e,t));else{var $=Re(n.done);for((!$||!$.ranges)&&Jn(e.sel,n.done),U={changes:[Na(e,t)],generation:n.generation},n.done.push(U);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=A,n.lastOp=n.lastSelOp=r,n.lastOrigin=n.lastSelOrigin=t.origin,X||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,A=r&&r.origin;i==n.lastSelOp||A&&n.lastSelOrigin==A&&(n.lastModTime==n.lastSelTime&&n.lastOrigin==A||ml(e,A,Re(n.done),t))?n.done[n.done.length-1]=t:Jn(t,n.done),n.lastSelTime=+new Date,n.lastSelOrigin=A,n.lastSelOp=i,r&&r.clearRedo!==!1&&Fo(n.undone)}function Jn(e,t){var i=Re(t);i&&i.ranges&&i.equals(e)||t.push(e)}function Wo(e,t,i,r){var n=t["spans_"+e.id],A=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,r),function(U){U.markedSpans&&((n||(n=t["spans_"+e.id]={}))[A]=U.markedSpans),++A})}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 Ho(e,t){var i=yl(e,t),r=Fr(e,t);if(!i)return r;if(!r)return i;for(var n=0;n<i.length;++n){var A=i[n],U=r[n];if(A&&U){e:for(var X=0;X<U.length;++X){for(var $=U[X],Z=0;Z<A.length;++Z)if(A[Z].marker==$.marker)continue e;A.push($)}}else U&&(i[n]=U)}return i}function tn(e,t,i){for(var r=[],n=0;n<e.length;++n){var A=e[n];if(A.ranges){r.push(i?Yr.prototype.deepCopy.call(A):A);continue}var U=A.changes,X=[];r.push({changes:X});for(var $=0;$<U.length;++$){var Z=U[$],le=void 0;if(X.push({from:Z.from,to:Z.to,text:Z.text}),t)for(var ce in Z)(le=ce.match(/^spans_(\d+)$/))&&(he(t,Number(le[1]))>-1&&(Re(X)[ce]=Z[ce],delete Z[ce]))}}return r}function Ba(e,t,i,r){if(r){var n=e.anchor;if(i){var A=At(t,n)<0;A!=At(i,n)<0?(n=t,t=i):A!=At(t,i)<0&&(t=i)}return new Gt(n,t)}else return new Gt(i||t,t)}function Zn(e,t,i,r,n){n==null&&(n=e.cm&&(e.cm.display.shift||e.extend)),Lr(e,new Yr([Ba(e.sel.primary(),t,i,n)],0),r)}function zo(e,t,i){for(var r=[],n=e.cm&&(e.cm.display.shift||e.extend),A=0;A<e.sel.ranges.length;A++)r[A]=Ba(e.sel.ranges[A],t[A],null,n);var U=ti(e.cm,r,e.sel.primIndex);Lr(e,U,i)}function Ua(e,t,i,r){var n=e.sel.ranges.slice(0);n[t]=i,Lr(e,ti(e.cm,n,e.sel.primIndex),r)}function Go(e,t,i,r){Lr(e,Ti(t,i),r)}function bl(e,t,i){var r={ranges:t.ranges,update:function(n){this.ranges=[];for(var A=0;A<n.length;A++)this.ranges[A]=new Gt(s(e,n[A].anchor),s(e,n[A].head))},origin:i&&i.origin};return Ae(e,"beforeSelectionChange",e,r),e.cm&&Ae(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?ti(e.cm,r.ranges,r.ranges.length-1):t}function Ko(e,t,i){var r=e.history.done,n=Re(r);n&&n.ranges?(r[r.length-1]=t,qn(e,t,i)):Lr(e,t,i)}function Lr(e,t,i){qn(e,t,i),gl(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function qn(e,t,i){(de(e,"beforeSelectionChange")||e.cm&&de(e.cm,"beforeSelectionChange"))&&(t=bl(e,t,i));var r=i&&i.bias||(At(t.primary().head,e.sel.primary().head)<0?-1:1);Vo(e,Yo(e,t,r,!0)),!(i&&i.scroll===!1)&&e.cm&&qi(e.cm)}function Vo(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,pe(e.cm)),Qt(e,"cursorActivity",e)}function Xo(e){Vo(e,Yo(e,e.sel,null,!1))}function Yo(e,t,i,r){for(var n,A=0;A<t.ranges.length;A++){var U=t.ranges[A],X=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[A],$=ea(e,U.anchor,X&&X.anchor,i,r),Z=ea(e,U.head,X&&X.head,i,r);(n||$!=U.anchor||Z!=U.head)&&(n||(n=t.ranges.slice(0,A)),n[A]=new Gt($,Z))}return n?ti(e.cm,n,t.primIndex):t}function rn(e,t,i,r,n){var A=ut(e,t.line);if(A.markedSpans)for(var U=0;U<A.markedSpans.length;++U){var X=A.markedSpans[U],$=X.marker,Z="selectLeft"in $?!$.selectLeft:$.inclusiveLeft,le="selectRight"in $?!$.selectRight:$.inclusiveRight;if((X.from==null||(Z?X.from<=t.ch:X.from<t.ch))&&(X.to==null||(le?X.to>=t.ch:X.to>t.ch))){if(n&&(Ae($,"beforeCursorEnter"),$.explicitlyCleared))if(A.markedSpans){--U;continue}else break;if(!$.atomic)continue;if(i){var ce=$.find(r<0?1:-1),xe=void 0;if((r<0?le:Z)&&(ce=$o(e,ce,-r,ce&&ce.line==t.line?A:null)),ce&&ce.line==t.line&&(xe=At(ce,i))&&(r<0?xe<0:xe>0))return rn(e,ce,t,r,n)}var ye=$.find(r<0?-1:1);return(r<0?Z:le)&&(ye=$o(e,ye,r,ye.line==t.line?A:null)),ye?rn(e,ye,t,r,n):null}}return t}function ea(e,t,i,r,n){var A=r||1,U=rn(e,t,i,A,n)||!n&&rn(e,t,i,A,!0)||rn(e,t,i,-A,n)||!n&&rn(e,t,i,-A,!0);return U||(e.cantEdit=!0,ze(e.first,0))}function $o(e,t,i,r){return i<0&&t.ch==0?t.line>e.first?s(e,ze(t.line-1)):null:i>0&&t.ch==(r||ut(e,t.line)).text.length?t.line<e.first+e.size-1?ze(t.line+1,0):null:new ze(t.line,t.ch+i)}function Qo(e){e.setSelection(ze(e.firstLine(),0),ze(e.lastLine()),be)}function Jo(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,A,U,X){n&&(r.from=s(e,n)),A&&(r.to=s(e,A)),U&&(r.text=U),X!==void 0&&(r.origin=X)}),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 nn(e,t,i){if(e.cm){if(!e.cm.curOp)return vr(e.cm,nn)(e,t,i);if(e.cm.state.suppressEdits)return}if((de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"))&&(t=Jo(e,t,!0),!t))return;var r=Ki&&!i&&ki(e,t.from,t.to);if(r)for(var n=r.length-1;n>=0;--n)Zo(e,{from:r[n].from,to:r[n].to,text:n?[""]:t.text,origin:t.origin});else Zo(e,t)}function Zo(e,t){if(t.text.length==1&&t.text[0]==""&&At(t.from,t.to)==0)return;var i=Ma(e,t);jo(e,t,i,e.cm?e.cm.curOp.id:NaN),Ln(e,t,i,Fr(e,t));var r=[];Li(e,function(n,A){!A&&he(r,n.history)==-1&&(rs(n.history,t),r.push(n.history)),Ln(n,t,null,Fr(n,t))})}function ta(e,t,i){var r=e.cm&&e.cm.state.suppressEdits;if(r&&!i)return;for(var n=e.history,A,U=e.sel,X=t=="undo"?n.done:n.undone,$=t=="undo"?n.undone:n.done,Z=0;Z<X.length&&!(A=X[Z],i?A.ranges&&!A.equals(e.sel):!A.ranges);Z++);if(Z==X.length)return;for(n.lastOrigin=n.lastSelOrigin=null;;)if(A=X.pop(),A.ranges){if(Jn(A,$),i&&!A.equals(e.sel)){Lr(e,A,{clearRedo:!1});return}U=A}else if(r){X.push(A);return}else break;var le=[];Jn(U,$),$.push({changes:le,generation:n.generation}),n.generation=A.generation||++n.maxGeneration;for(var ce=de(e,"beforeChange")||e.cm&&de(e.cm,"beforeChange"),xe=function(Fe){var Je=A.changes[Fe];if(Je.origin=t,ce&&!Jo(e,Je,!1))return X.length=0,{};le.push(Na(e,Je));var nt=Fe?Ma(e,Je):Re(X);Ln(e,Je,nt,Ho(e,Je)),!Fe&&e.cm&&e.cm.scrollIntoView({from:Je.from,to:wi(Je)});var dt=[];Li(e,function(at,pt){!pt&&he(dt,at.history)==-1&&(rs(at.history,Je),dt.push(at.history)),Ln(at,Je,null,Ho(at,Je))})},ye=A.changes.length-1;ye>=0;--ye){var ke=xe(ye);if(ke)return ke.v}}function qo(e,t){if(t==0)return;if(e.first+=t,e.sel=new Yr(et(e.sel.ranges,function(n){return new Gt(ze(n.anchor.line+t,n.anchor.ch),ze(n.head.line+t,n.head.ch))}),e.sel.primIndex),e.cm){Mr(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,r=i.viewFrom;r<i.viewTo;r++)Si(e.cm,r,"gutter")}}function Ln(e,t,i,r){if(e.cm&&!e.cm.curOp)return vr(e.cm,Ln)(e,t,i,r);if(t.to.line<e.first){qo(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);qo(e,n),t={from:ze(e.first,0),to:ze(t.to.line+n,t.to.ch),text:[Re(t.text)],origin:t.origin}}var A=e.lastLine();t.to.line>A&&(t={from:t.from,to:ze(A,ut(e,A).text.length),text:[t.text[0]],origin:t.origin}),t.removed=qt(e,t.from,t.to),i||(i=Ma(e,t)),e.cm?xl(e.cm,t,r):Ia(e,t,r),qn(e,i,be),e.cantEdit&&ea(e,ze(e.firstLine(),0))&&(e.cantEdit=!1)}function xl(e,t,i){var r=e.doc,n=e.display,A=t.from,U=t.to,X=!1,$=A.line;e.options.lineWrapping||($=Ot(cr(ut(r,A.line))),r.iter($,U.line+1,function(ye){if(ye==n.maxLine)return X=!0,!0})),r.sel.contains(t.from,t.to)>-1&&pe(e),Ia(r,t,i,go(e)),e.options.lineWrapping||(r.iter($,A.line+t.text.length,function(ye){var ke=Yi(ye);ke>n.maxLineLength&&(n.maxLine=ye,n.maxLineLength=ke,n.maxLineChanged=!0,X=!1)}),X&&(e.curOp.updateMaxLine=!0)),Qr(r,A.line),Cn(e,400);var Z=t.text.length-(U.line-A.line)-1;t.full?Mr(e):A.line==U.line&&t.text.length==1&&!No(e.doc,t)?Si(e,A.line,"text"):Mr(e,A.line,U.line+1,Z);var le=de(e,"changes"),ce=de(e,"change");if(ce||le){var xe={from:A,to:U,text:t.text,removed:t.removed,origin:t.origin};ce&&Qt(e,"change",e,xe),le&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(xe)}e.display.selForContextMenu=null}function an(e,t,i,r,n){var A;r||(r=i),At(r,i)<0&&(A=[r,i],i=A[0],r=A[1]),typeof t=="string"&&(t=e.splitLines(t)),nn(e,{from:i,to:r,text:t,origin:n})}function es(e,t,i,r){i<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function ts(e,t,i,r){for(var n=0;n<e.length;++n){var A=e[n],U=!0;if(A.ranges){A.copied||(A=e[n]=A.deepCopy(),A.copied=!0);for(var X=0;X<A.ranges.length;X++)es(A.ranges[X].anchor,t,i,r),es(A.ranges[X].head,t,i,r);continue}for(var $=0;$<A.changes.length;++$){var Z=A.changes[$];if(i<Z.from.line)Z.from=ze(Z.from.line+r,Z.from.ch),Z.to=ze(Z.to.line+r,Z.to.ch);else if(t<=Z.to.line){U=!1;break}}U||(e.splice(0,n+1),n=0)}}function rs(e,t){var i=t.from.line,r=t.to.line,n=t.text.length-(r-i)-1;ts(e.done,i,r,n),ts(e.undone,i,r,n)}function An(e,t,i,r){var n=t,A=t;return typeof t=="number"?A=ut(e,z(e,t)):n=Ot(t),n==null?null:(r(A,n)&&e.cm&&Si(e.cm,n,i),A)}function _n(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}_n.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,da(n),Qt(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 Dn(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}Dn.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 A=Math.min(t,n-e),U=r.height;if(r.removeInner(e,A),this.height-=U-r.height,n==A&&(this.children.splice(i--,1),r.parent=null),(t-=A)==0)break;e=0}else e-=n}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof _n))){var X=[];this.collapse(X),this.children=[new _n(X)],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],A=n.chunkSize();if(e<=A){if(n.insertInner(e,t,i),n.lines&&n.lines.length>50){for(var U=n.lines.length%25+25,X=U;X<n.lines.length;){var $=new _n(n.lines.slice(X,X+=25));n.height-=$.height,this.children.splice(++r,0,$),$.parent=this}n.lines=n.lines.slice(0,U),this.maybeSpill()}break}e-=A}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new Dn(t);if(e.parent){e.size-=i.size,e.height-=i.height;var n=he(e.parent.children,e);e.parent.children.splice(n+1,0,i)}else{var r=new Dn(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],A=n.chunkSize();if(e<A){var U=Math.min(t,A-e);if(n.iterN(e,U,i))return!0;if((t-=U)==0)break;e=0}else e-=A}}};var Rn=function(e,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.doc=e,this.node=t};Rn.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,i=this.line,r=Ot(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 A=gn(this);Nt(i,Math.max(0,i.height-A)),e&&(Hr(e,function(){is(e,i,-A),Si(e,r,"widget")}),Qt(e,"lineWidgetCleared",e,this,r))},Rn.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,r=this.line;this.height=null;var n=gn(this)-t;if(!n)return;qr(this.doc,r)||Nt(r,r.height+n),i&&Hr(i,function(){i.curOp.forceUpdate=!0,is(i,r,n),Qt(i,"lineWidgetChanged",i,e,Ot(r))})},ue(Rn);function is(e,t,i){Wr(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Aa(e,i)}function El(e,t,i,r){var n=new Rn(e,i,r),A=e.cm;return A&&n.noHScroll&&(A.display.alignWidgets=!0),An(e,t,"widget",function(U){var X=U.widgets||(U.widgets=[]);if(n.insertAt==null?X.push(n):X.splice(Math.min(X.length-1,Math.max(0,n.insertAt)),0,n),n.line=U,A&&!qr(e,U)){var $=Wr(U)<e.scrollTop;Nt(U,U.height+gn(n)),$&&Aa(A,n.height),A.curOp.forceUpdate=!0}return!0}),A&&Qt(A,"lineWidgetAdded",A,n,typeof t=="number"?t:Ot(t)),n}var ns=0,Ai=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ns};Ai.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;if(t&&Wi(e),de(this,"clear")){var i=this.find();i&&Qt(this,"clear",i.from,i.to)}for(var r=null,n=null,A=0;A<this.lines.length;++A){var U=this.lines[A],X=Zr(U.markedSpans,this);e&&!this.collapsed?Si(e,Ot(U),"text"):e&&(X.to!=null&&(n=Ot(U)),X.from!=null&&(r=Ot(U))),U.markedSpans=ai(U.markedSpans,X),X.from==null&&this.collapsed&&!qr(this.doc,U)&&e&&Nt(U,Qi(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var $=0;$<this.lines.length;++$){var Z=cr(this.lines[$]),le=Yi(Z);le>e.display.maxLineLength&&(e.display.maxLine=Z,e.display.maxLineLength=le,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Mr(e,r,n+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Xo(e.doc)),e&&Qt(e,"markerCleared",e,this,r,n),t&&Hi(e),this.parent&&this.parent.clear()},Ai.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);for(var i,r,n=0;n<this.lines.length;++n){var A=this.lines[n],U=Zr(A.markedSpans,this);if(U.from!=null&&(i=ze(t?A:Ot(A),U.from),e==-1))return i;if(U.to!=null&&(r=ze(t?A:Ot(A),U.to),e==1))return r}return i&&{from:i,to:r}},Ai.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,r=this.doc.cm;if(!t||!r)return;Hr(r,function(){var n=t.line,A=Ot(t.line),U=ma(r,A);if(U&&(so(U),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!qr(i.doc,n)&&i.height!=null){var X=i.height;i.height=null;var $=gn(i)-X;$&&Nt(n,n.height+$)}Qt(r,"markerChanged",r,e)})},Ai.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||he(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Ai.prototype.detachLine=function(e){if(this.lines.splice(he(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},ue(Ai);function on(e,t,i,r,n){if(r&&r.shared)return Sl(e,t,i,r,n);if(e.cm&&!e.cm.curOp)return vr(e.cm,on)(e,t,i,r,n);var A=new Ai(e,n),U=At(t,i);if(r&&F(r,A,!1),U>0||U==0&&A.clearWhenEmpty!==!1)return A;if(A.replacedWith&&(A.collapsed=!0,A.widgetNode=C("span",[A.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||A.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(A.widgetNode.insertLeft=!0)),A.collapsed){if(hr(e,t.line,t,i,A)||t.line!=i.line&&hr(e,i.line,t,i,A))throw new Error("Inserting collapsed marker partially overlapping an existing one");ni()}A.addToHistory&&jo(e,{from:t,to:i,origin:"markText"},e.sel,NaN);var X=t.line,$=e.cm,Z;if(e.iter(X,i.line+1,function(ce){$&&A.collapsed&&!$.options.lineWrapping&&cr(ce)==$.display.maxLine&&(Z=!0),A.collapsed&&X!=t.line&&Nt(ce,0),Vr(ce,new vi(A,X==t.line?t.ch:null,X==i.line?i.ch:null)),++X}),A.collapsed&&e.iter(t.line,i.line+1,function(ce){qr(e,ce)&&Nt(ce,0)}),A.clearOnEnter&&we(A,"beforeCursorEnter",function(){return A.clear()}),A.readOnly&&(Or(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),A.collapsed&&(A.id=++ns,A.atomic=!0),$){if(Z&&($.curOp.updateMaxLine=!0),A.collapsed)Mr($,t.line,i.line+1);else if(A.className||A.startStyle||A.endStyle||A.css||A.attributes||A.title)for(var le=t.line;le<=i.line;le++)Si($,le,"text");A.atomic&&Xo($.doc),Qt($,"markerAdded",$,A)}return A}var kn=function(e,t){this.markers=e,this.primary=t;for(var i=0;i<e.length;++i)e[i].parent=this};kn.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Qt(this,"clear")},kn.prototype.find=function(e,t){return this.primary.find(e,t)},ue(kn);function Sl(e,t,i,r,n){r=F(r),r.shared=!1;var A=[on(e,t,i,r,n)],U=A[0],X=r.widgetNode;return Li(e,function($){X&&(r.widgetNode=X.cloneNode(!0)),A.push(on($,s($,t),s($,i),r,n));for(var Z=0;Z<$.linked.length;++Z)if($.linked[Z].isParent)return;U=Re(A)}),new kn(A,U)}function as(e){return e.findMarks(ze(e.first,0),e.clipPos(ze(e.lastLine())),function(t){return t.parent})}function Cl(e,t){for(var i=0;i<t.length;i++){var r=t[i],n=r.find(),A=e.clipPos(n.from),U=e.clipPos(n.to);if(At(A,U)){var X=on(e,A,U,r.primary,r.primary.type);r.markers.push(X),X.parent=r}}}function Tl(e){for(var t=function(r){var n=e[r],A=[n.primary.doc];Li(n.primary.doc,function($){return A.push($)});for(var U=0;U<n.markers.length;U++){var X=n.markers[U];he(A,X.doc)==-1&&(X.parent=null,n.markers.splice(U--,1))}},i=0;i<e.length;i++)t(i)}var wl=0,Pr=function(e,t,i,r,n){if(!(this instanceof Pr))return new Pr(e,t,i,r,n);i==null&&(i=0),Dn.call(this,[new _n([new Ei("",null)])]),this.first=i,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=i;var A=ze(i,0);this.sel=Ti(A),this.history=new Qn(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)),Ia(this,{from:A,to:A,text:e}),Lr(this,Ti(A),be)};Pr.prototype=Ye(Dn.prototype,{constructor:Pr,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=jt(this,this.first,this.first+this.size);return e===!1?t:t.join(e||this.lineSeparator())},setValue:yr(function(e){var t=ze(this.first,0),i=this.first+this.size-1;nn(this,{from:t,to:ze(i,ut(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&bn(this.cm,0,0),Lr(this,Ti(t),be)}),replaceRange:function(e,t,i,r){t=s(this,t),i=i?s(this,i):t,an(this,e,t,i,r)},getRange:function(e,t,i){var r=qt(this,s(this,e),s(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(Rr(this,e))return ut(this,e)},getLineNumber:function(e){return Ot(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=ut(this,e)),cr(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return s(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:yr(function(e,t,i){Go(this,s(this,typeof e=="number"?ze(e,t||0):e),null,i)}),setSelection:yr(function(e,t,i){Go(this,s(this,e),s(this,t||e),i)}),extendSelection:yr(function(e,t,i){Zn(this,s(this,e),t&&s(this,t),i)}),extendSelections:yr(function(e,t){zo(this,W(this,e),t)}),extendSelectionsBy:yr(function(e,t){var i=et(this.sel.ranges,e);zo(this,W(this,i),t)}),setSelections:yr(function(e,t,i){if(!e.length)return;for(var r=[],n=0;n<e.length;n++)r[n]=new Gt(s(this,e[n].anchor),s(this,e[n].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Lr(this,ti(this.cm,r,t),i)}),addSelection:yr(function(e,t,i){var r=this.sel.ranges.slice(0);r.push(new Gt(s(this,e),s(this,t||e))),Lr(this,ti(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=qt(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=qt(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:yr(function(e,t,i){for(var r=[],n=this.sel,A=0;A<n.ranges.length;A++){var U=n.ranges[A];r[A]={from:U.from(),to:U.to(),text:this.splitLines(e[A]),origin:i}}for(var X=t&&t!="end"&&cl(this,r,t),$=r.length-1;$>=0;$--)nn(this,r[$]);X?Ko(this,X):this.cm&&qi(this.cm)}),undo:yr(function(){ta(this,"undo")}),redo:yr(function(){ta(this,"redo")}),undoSelection:yr(function(){ta(this,"undo",!0)}),redoSelection:yr(function(){ta(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 Qn(this.history.maxGeneration),Li(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:tn(this.history.done),undone:tn(this.history.undone)}},setHistory:function(e){var t=this.history=new Qn(this.history.maxGeneration);t.done=tn(e.done.slice(0),null,!0),t.undone=tn(e.undone.slice(0),null,!0)},setGutterMarker:yr(function(e,t,i){return An(this,e,"gutter",function(r){var n=r.gutterMarkers||(r.gutterMarkers={});return n[t]=i,!i&&st(n)&&(r.gutterMarkers=null),!0})}),clearGutter:yr(function(e){var t=this;this.iter(function(i){i.gutterMarkers&&i.gutterMarkers[e]&&An(t,i,"gutter",function(){return i.gutterMarkers[e]=null,st(i.gutterMarkers)&&(i.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if(typeof e=="number"){if(!Rr(this,e))return null;if(t=e,e=ut(this,e),!e)return null}else if(t=Ot(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:yr(function(e,t,i){return An(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(T(i).test(r[n]))return!1;r[n]+=" "+i}return!0})}),removeLineClass:yr(function(e,t,i){return An(this,e,t=="gutter"?"gutter":"class",function(r){var n=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",A=r[n];if(A)if(i==null)r[n]=null;else{var U=A.match(T(i));if(!U)return!1;var X=U.index+U[0].length;r[n]=A.slice(0,U.index)+(!U.index||X==A.length?"":" ")+A.slice(X)||null}else return!1;return!0})}),addLineWidget:yr(function(e,t,i){return El(this,e,t,i)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,i){return on(this,s(this,e),s(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=s(this,e),on(this,e,e,i,"bookmark")},findMarksAt:function(e){e=s(this,e);var t=[],i=ut(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=s(this,e),t=s(this,t);var r=[],n=e.line;return this.iter(e.line,t.line+1,function(A){var U=A.markedSpans;if(U)for(var X=0;X<U.length;X++){var $=U[X];!($.to!=null&&n==e.line&&e.ch>=$.to||$.from==null&&n!=e.line||$.from!=null&&n==t.line&&$.from>=t.ch)&&(!i||i($.marker))&&r.push($.marker.parent||$.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 A=n.text.length+r;if(A>e)return t=e,!0;e-=A,++i}),s(this,ze(i,t))},indexFromPos:function(e){e=s(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 Pr(jt(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 Pr(jt(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}],Cl(r,as(this)),r},unlinkDoc:function(e){if(e instanceof er&&(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),Tl(as(this));break}if(e.history==this.history){var r=[e.id];Li(e,function(n){return r.push(n.id)},!0),e.history=new Qn(null),e.history.done=tn(this.history.done,r),e.history.undone=tn(this.history.undone,r)}},iterLinkedDocs:function(e){Li(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):mt(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:yr(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)})}),Pr.prototype.eachLine=Pr.prototype.iter;var os=0;function Ll(e){var t=this;if(ss(t),Oe(t,e)||fi(t.display,e))return;te(e),B&&(os=+new Date);var i=Bi(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,A=Array(n),U=0,X=function(){++U==n&&vr(t,function(){i=s(t.doc,i);var ye={from:i,to:i,text:t.doc.splitLines(A.filter(function(ke){return ke!=null}).join(t.doc.lineSeparator())),origin:"paste"};nn(t.doc,ye),Ko(t.doc,Ti(s(t.doc,i),s(t.doc,wi(ye))))})()},$=function(ye,ke){if(t.options.allowDropFileTypes&&he(t.options.allowDropFileTypes,ye.type)==-1){X();return}var Fe=new FileReader;Fe.onerror=function(){return X()},Fe.onload=function(){var Je=Fe.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(Je)){X();return}A[ke]=Je,X()},Fe.readAsText(ye)},Z=0;Z<r.length;Z++)$(r[Z],Z);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 le=e.dataTransfer.getData("Text");if(le){var ce;if(t.state.draggingText&&!t.state.draggingText.copy&&(ce=t.listSelections()),qn(t.doc,Ti(i,i)),ce)for(var xe=0;xe<ce.length;++xe)an(t.doc,"",ce[xe].anchor,ce[xe].head,"drag");t.replaceSelection(le,"around","paste"),t.display.input.focus()}}catch(ye){}}}function Al(e,t){if(B&&(!e.state.draggingText||+new Date-os<100)){ae(t);return}if(Oe(e,t)||fi(e.display,t))return;if(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!P){var i=o("img",null,null,"position: fixed; left: 0; top: 0;");i.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",y&&(i.width=i.height=1,e.display.wrapper.appendChild(i),i._top=i.offsetTop),t.dataTransfer.setDragImage(i,0,0),y&&i.parentNode.removeChild(i)}}function _l(e,t){var i=Bi(e,t);if(!i)return;var r=document.createDocumentFragment();bo(e,i,r),e.display.dragCursor||(e.display.dragCursor=o("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),u(e.display.dragCursor,r)}function ss(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function ls(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 A=0;A<i.length;A++)e(i[A])})}var us=!1;function Dl(){if(us)return;Rl(),us=!0}function Rl(){var e;we(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,ls(kl)},100))}),we(window,"blur",function(){return ls(Zi)})}function kl(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var _i={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"},On=0;On<10;On++)_i[On+48]=_i[On+96]=String(On);for(var ra=65;ra<=90;ra++)_i[ra]=String.fromCharCode(ra);for(var Mn=1;Mn<=12;Mn++)_i[Mn+111]=_i[Mn+63235]="F"+Mn;var pi={};pi.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"},pi.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"},pi.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"},pi.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"]},pi.default=l?pi.macDefault:pi.pcDefault;function Ol(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var i,r,n,A,U=0;U<t.length-1;U++){var X=t[U];if(/^(cmd|meta|m)$/i.test(X))A=!0;else if(/^a(lt)?$/i.test(X))i=!0;else if(/^(c|ctrl|control)$/i.test(X))r=!0;else if(/^s(hift)?$/i.test(X))n=!0;else throw new Error("Unrecognized modifier name: "+X)}return i&&(e="Alt-"+e),r&&(e="Ctrl-"+e),A&&(e="Cmd-"+e),n&&(e="Shift-"+e),e}function Ml(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=et(i.split(" "),Ol),A=0;A<n.length;A++){var U=void 0,X=void 0;A==n.length-1?(X=n.join(" "),U=r):(X=n.slice(0,A+1).join(" "),U="...");var $=t[X];if(!$)t[X]=U;else if($!=U)throw new Error("Inconsistent bindings for "+X)}delete e[i]}for(var Z in t)e[Z]=t[Z];return e}function sn(e,t,i,r){t=ia(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 sn(e,t.fallthrough,i,r);for(var A=0;A<t.fallthrough.length;A++){var U=sn(e,t.fallthrough[A],i,r);if(U)return U}}}function ds(e){var t=typeof e=="string"?e:_i[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function hs(e,t,i){var r=e;return t.altKey&&r!="Alt"&&(e="Alt-"+e),(b?t.metaKey:t.ctrlKey)&&r!="Ctrl"&&(e="Ctrl-"+e),(b?t.ctrlKey:t.metaKey)&&r!="Mod"&&(e="Cmd-"+e),!i&&t.shiftKey&&r!="Shift"&&(e="Shift-"+e),e}function cs(e,t){if(y&&e.keyCode==34&&e.char)return!1;var i=_i[e.keyCode];return i==null||e.altGraphKey?!1:(e.keyCode==3&&e.code&&(i=e.code),hs(i,e,t))}function ia(e){return typeof e=="string"?pi[e]:e}function ln(e,t){for(var i=e.doc.sel.ranges,r=[],n=0;n<i.length;n++){for(var A=t(i[n]);r.length&&At(A.from,Re(r).to)<=0;){var U=r.pop();if(At(U.from,A.from)<0){A.from=U.from;break}}r.push(A)}Hr(e,function(){for(var X=r.length-1;X>=0;X--)an(e.doc,"",r[X].from,r[X].to,"+delete");qi(e)})}function Fa(e,t,i){var r=We(e.text,t+i,i);return r<0||r>e.text.length?null:r}function ja(e,t,i){var r=Fa(e,t.ch,i);return r==null?null:new ze(t.line,r,i<0?"after":"before")}function Wa(e,t,i,r,n){if(e){t.doc.direction=="rtl"&&(n=-n);var A=Ve(i,t.doc.direction);if(A){var U=n<0?Re(A):A[0],X=n<0==(U.level==1),$=X?"after":"before",Z;if(U.level>0||t.doc.direction=="rtl"){var le=$i(t,i);Z=n<0?i.text.length-1:0;var ce=li(t,le,Z).top;Z=ft(function(xe){return li(t,le,xe).top==ce},n<0==(U.level==1)?U.from:U.to-1,Z),$=="before"&&(Z=Fa(i,Z,1))}else Z=n<0?U.to:U.from;return new ze(r,Z,$)}}return new ze(r,n<0?i.text.length:0,n<0?"before":"after")}function Pl(e,t,i,r){var n=Ve(t,e.doc.direction);if(!n)return ja(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 A=Xe(n,i.ch,i.sticky),U=n[A];if(e.doc.direction=="ltr"&&U.level%2==0&&(r>0?U.to>i.ch:U.from<i.ch))return ja(t,i,r);var X=function(nt,dt){return Fa(t,nt instanceof ze?nt.ch:nt,dt)},$,Z=function(nt){return e.options.lineWrapping?($=$||$i(e,t),mo(e,t,$,nt)):{begin:0,end:t.text.length}},le=Z(i.sticky=="before"?X(i,-1):i.ch);if(e.doc.direction=="rtl"||U.level==1){var ce=U.level==1==r<0,xe=X(i,ce?1:-1);if(xe!=null&&(ce?xe<=U.to&&xe<=le.end:xe>=U.from&&xe>=le.begin)){var ye=ce?"before":"after";return new ze(i.line,xe,ye)}}var ke=function(nt,dt,at){for(var pt=function(Zt,br){return br?new ze(i.line,X(Zt,1),"before"):new ze(i.line,Zt,"after")};nt>=0&&nt<n.length;nt+=dt){var wt=n[nt],St=dt>0==(wt.level!=1),Mt=St?at.begin:X(at.end,-1);if(wt.from<=Mt&&Mt<wt.to)return pt(Mt,St);if(Mt=St?wt.from:X(wt.to,-1),at.begin<=Mt&&Mt<at.end)return pt(Mt,St)}},Fe=ke(A+r,r,le);if(Fe)return Fe;var Je=r>0?le.end:X(le.begin,-1);return Je!=null&&!(r>0&&Je==t.text.length)&&(Fe=ke(r>0?0:n.length-1,r,Z(Je)),Fe)?Fe:null}var Pn={selectAll:Qo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),be)},killLine:function(e){return ln(e,function(t){if(t.empty()){var i=ut(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.line<e.lastLine()?{from:t.head,to:ze(t.head.line+1,0)}:{from:t.head,to:ze(t.head.line,i)}}else return{from:t.from(),to:t.to()}})},deleteLine:function(e){return ln(e,function(t){return{from:ze(t.from().line,0),to:s(e.doc,ze(t.to().line+1,0))}})},delLineLeft:function(e){return ln(e,function(t){return{from:ze(t.from().line,0),to:t.from()}})},delWrappedLineLeft:function(e){return ln(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 ln(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(ze(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(ze(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return fs(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return ps(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")},Te)},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")},Te)},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/)?ps(e,t.head):r},Te)},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 A=i[n].from(),U=ee(e.getLine(A.line),A.ch,r);t.push(se(r-U%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return Hr(e,function(){for(var t=e.listSelections(),i=[],r=0;r<t.length;r++){if(!t[r].empty())continue;var n=t[r].head,A=ut(e.doc,n.line).text;if(A){if(n.ch==A.length&&(n=new ze(n.line,n.ch-1)),n.ch>0)n=new ze(n.line,n.ch+1),e.replaceRange(A.charAt(n.ch-1)+A.charAt(n.ch-2),ze(n.line,n.ch-2),n,"+transpose");else if(n.line>e.doc.first){var U=ut(e.doc,n.line-1).text;U&&(n=new ze(n.line,1),e.replaceRange(A.charAt(0)+e.doc.lineSeparator()+U.charAt(U.length-1),ze(n.line-1,U.length-1),n,"+transpose"))}}i.push(new Gt(n,n))}e.setSelections(i)})},newlineAndIndent:function(e){return Hr(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);qi(e)})},openLine:function(e){return e.replaceSelection(`
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function fs(e,t){var i=ut(e.doc,t),r=cr(i);return r!=i&&(t=Ot(r)),Wa(!0,e,r,t,1)}function Il(e,t){var i=ut(e.doc,t),r=oi(i);return r!=i&&(t=Ot(r)),Wa(!0,e,i,t,-1)}function ps(e,t){var i=fs(e,t.line),r=ut(e.doc,i.line),n=Ve(r,e.doc.direction);if(!n||n[0].level==0){var A=Math.max(i.ch,r.text.search(/\S/)),U=t.line==i.line&&t.ch<=A&&t.ch;return ze(i.line,U?0:A,i.sticky)}return i}function na(e,t,i){if(typeof t=="string"&&(t=Pn[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)!=_e}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=sn(t,e.state.keyMaps[r],i,e);if(n)return n}return e.options.extraKeys&&sn(t,e.options.extraKeys,i,e)||sn(t,e.options.keyMap,i,e)}var Bl=new oe;function In(e,t,i,r){var n=e.state.keySeq;if(n){if(ds(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())}),ms(e,n+" "+t,i,r))return!0}return ms(e,t,i,r)}function ms(e,t,i,r){var n=Nl(e,t,r);return n=="multi"&&(e.state.keySeq=t),n=="handled"&&Qt(e,"keyHandled",e,t,i),(n=="handled"||n=="multi")&&(te(i),Ta(e)),!!n}function gs(e,t){var i=cs(t,!0);return i?t.shiftKey&&!e.state.keySeq?In(e,"Shift-"+i,t,function(r){return na(e,r,!0)})||In(e,i,t,function(r){if(typeof r=="string"?/^go[A-Z]/.test(r):r.motion)return na(e,r)}):In(e,i,t,function(r){return na(e,r)}):!1}function Ul(e,t,i){return In(e,"'"+i+"'",t,function(r){return na(e,r,!0)})}var Ha=null;function vs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(t.curOp.focus=O(),Oe(t,e))return;B&&N<11&&e.keyCode==27&&(e.returnValue=!1);var i=e.keyCode;t.display.shift=i==16||e.shiftKey;var r=gs(t,e);y&&(Ha=r?i:null,!r&&i==88&&!Tt&&(l?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),D&&!l&&!r&&i==46&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),i==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Fl(t)}function Fl(e){var t=e.display.lineDiv;j(t,"CodeMirror-crosshair");function i(r){(r.keyCode==18||!r.altKey)&&(g(t,"CodeMirror-crosshair"),it(document,"keyup",i),it(document,"mouseover",i))}we(document,"keyup",i),we(document,"mouseover",i)}function ys(e){e.keyCode==16&&(this.doc.sel.shift=!1),Oe(this,e)}function bs(e){var t=this;if(e.target&&e.target!=t.display.input.getField())return;if(fi(t.display,e)||Oe(t,e)||e.ctrlKey&&!e.altKey||l&&e.metaKey)return;var i=e.keyCode,r=e.charCode;if(y&&i==Ha){Ha=null,te(e);return}if(y&&(!e.which||e.which<10)&&gs(t,e))return;var n=String.fromCharCode(r==null?i:r);if(n=="\b")return;if(Ul(t,e,n))return;t.display.input.onKeyPress(e)}var jl=400,za=function(e,t,i){this.time=e,this.pos=t,this.button=i};za.prototype.compare=function(e,t,i){return this.time+jl>e&&At(t,this.pos)==0&&i==this.button};var Nn,Bn;function Wl(e,t){var i=+new Date;return Bn&&Bn.compare(i,e,t)?(Nn=Bn=null,"triple"):Nn&&Nn.compare(i,e,t)?(Bn=new za(i,e,t),Nn=null,"double"):(Nn=new za(i,e,t),Bn=null,"single")}function xs(e){var t=this,i=t.display;if(Oe(t,e)||i.activeTouch&&i.input.supportsTouch())return;if(i.input.ensurePolled(),i.shift=e.shiftKey,fi(i,e)){M||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100));return}if(Ga(t,e))return;var r=Bi(t,e),n=Le(e),A=r?Wl(r,n):"single";if(window.focus(),n==1&&t.state.selectingText&&t.state.selectingText(e),r&&Hl(t,n,r,A,e))return;n==1?r?Gl(t,r,A,e):ve(e)==i.scroller&&te(e):n==2?(r&&Zn(t.doc,r),setTimeout(function(){return i.input.focus()},20)):n==3&&(R?t.display.input.onContextMenu(e):Eo(t))}function Hl(e,t,i,r,n){var A="Click";return r=="double"?A="Double"+A:r=="triple"&&(A="Triple"+A),A=(t==1?"Left":t==2?"Middle":"Right")+A,In(e,hs(A,n),n,function(U){if(typeof U=="string"&&(U=Pn[U]),!U)return!1;var X=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),X=U(e,i)!=_e}finally{e.state.suppressEdits=!1}return X})}function zl(e,t,i){var r=e.getOption("configureMouse"),n=r?r(e,t,i):{};if(n.unit==null){var A=h?i.shiftKey&&i.metaKey:i.altKey;n.unit=A?"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=l?i.metaKey:i.ctrlKey),n.moveOnDrag==null&&(n.moveOnDrag=!(l?i.altKey:i.ctrlKey)),n}function Gl(e,t,i,r){B?setTimeout(K(xo,e),0):e.curOp.focus=O();var n=zl(e,i,r),A=e.doc.sel,U;e.options.dragDrop&&Ie&&!e.isReadOnly()&&i=="single"&&(U=A.contains(t))>-1&&(At((U=A.ranges[U]).from(),t)<0||t.xRel>0)&&(At(U.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,A=!1,U=vr(e,function(Z){M&&(n.scroller.draggable=!1),e.state.draggingText=!1,it(n.wrapper.ownerDocument,"mouseup",U),it(n.wrapper.ownerDocument,"mousemove",X),it(n.scroller,"dragstart",$),it(n.scroller,"drop",U),A||(te(Z),r.addNew||Zn(e.doc,i,null,null,r.extend),M&&!P||B&&N==9?setTimeout(function(){n.wrapper.ownerDocument.body.focus({preventScroll:!0}),n.input.focus()},20):n.input.focus())}),X=function(Z){A=A||Math.abs(t.clientX-Z.clientX)+Math.abs(t.clientY-Z.clientY)>=10},$=function(){return A=!0};M&&(n.scroller.draggable=!0),e.state.draggingText=U,U.copy=!r.moveOnDrag,n.scroller.dragDrop&&n.scroller.dragDrop(),we(n.wrapper.ownerDocument,"mouseup",U),we(n.wrapper.ownerDocument,"mousemove",X),we(n.scroller,"dragstart",$),we(n.scroller,"drop",U),Eo(e),setTimeout(function(){return n.input.focus()},20)}function Es(e,t,i){if(i=="char")return new Gt(t,t);if(i=="word")return e.findWordAt(t);if(i=="line")return new Gt(ze(t.line,0),s(e.doc,ze(t.line+1,0)));var r=i(e,t);return new Gt(r.from,r.to)}function Vl(e,t,i,r){var n=e.display,A=e.doc;te(t);var U,X,$=A.sel,Z=$.ranges;if(r.addNew&&!r.extend?(X=A.sel.contains(i),X>-1?U=Z[X]:U=new Gt(i,i)):(U=A.sel.primary(),X=A.sel.primIndex),r.unit=="rectangle")r.addNew||(U=new Gt(i,i)),i=Bi(e,t,!0,!0),X=-1;else{var le=Es(e,i,r.unit);r.extend?U=Ba(U,le.anchor,le.head,r.extend):U=le}r.addNew?X==-1?(X=Z.length,Lr(A,ti(e,Z.concat([U]),X),{scroll:!1,origin:"*mouse"})):Z.length>1&&Z[X].empty()&&r.unit=="char"&&!r.extend?(Lr(A,ti(e,Z.slice(0,X).concat(Z.slice(X+1)),0),{scroll:!1,origin:"*mouse"}),$=A.sel):Ua(A,X,U,Ee):(X=0,Lr(A,new Yr([U],0),Ee),$=A.sel);var ce=i;function xe(at){if(At(ce,at)==0)return;if(ce=at,r.unit=="rectangle"){for(var pt=[],wt=e.options.tabSize,St=ee(ut(A,i.line).text,i.ch,wt),Mt=ee(ut(A,at.line).text,at.ch,wt),Zt=Math.min(St,Mt),br=Math.max(St,Mt),rr=Math.min(i.line,at.line),zr=Math.min(e.lastLine(),Math.max(i.line,at.line));rr<=zr;rr++){var Ir=ut(A,rr).text,ur=Ce(Ir,Zt,wt);Zt==br?pt.push(new Gt(ze(rr,ur),ze(rr,ur))):Ir.length>ur&&pt.push(new Gt(ze(rr,ur),ze(rr,Ce(Ir,br,wt))))}pt.length||pt.push(new Gt(i,i)),Lr(A,ti(e,$.ranges.slice(0,X).concat(pt),X),{origin:"*mouse",scroll:!1}),e.scrollIntoView(at)}else{var Nr=U,Tr=Es(e,at,r.unit),fr=Nr.anchor,dr;At(Tr.anchor,fr)>0?(dr=Tr.head,fr=Ri(Nr.from(),Tr.anchor)):(dr=Tr.anchor,fr=hi(Nr.to(),Tr.head));var nr=$.ranges.slice(0);nr[X]=Xl(e,new Gt(s(A,fr),dr)),Lr(A,ti(e,nr,X),Ee)}}var ye=n.wrapper.getBoundingClientRect(),ke=0;function Fe(at){var pt=++ke,wt=Bi(e,at,!0,r.unit=="rectangle");if(!wt)return;if(At(wt,ce)!=0){e.curOp.focus=O(),xe(wt);var St=Vn(n,A);(wt.line>=St.to||wt.line<St.from)&&setTimeout(vr(e,function(){ke==pt&&Fe(at)}),150)}else{var Mt=at.clientY<ye.top?-20:at.clientY>ye.bottom?20:0;Mt&&setTimeout(vr(e,function(){if(ke!=pt)return;n.scroller.scrollTop+=Mt,Fe(at)}),50)}}function Je(at){e.state.selectingText=!1,ke=Infinity,at&&(te(at),n.input.focus()),it(n.wrapper.ownerDocument,"mousemove",nt),it(n.wrapper.ownerDocument,"mouseup",dt),A.history.lastSelOrigin=null}var nt=vr(e,function(at){at.buttons===0||!Le(at)?Je(at):Fe(at)}),dt=vr(e,Je);e.state.selectingText=dt,we(n.wrapper.ownerDocument,"mousemove",nt),we(n.wrapper.ownerDocument,"mouseup",dt)}function Xl(e,t){var i=t.anchor,r=t.head,n=ut(e.doc,i.line);if(At(i,r)==0&&i.sticky==r.sticky)return t;var A=Ve(n);if(!A)return t;var U=Xe(A,i.ch,i.sticky),X=A[U];if(X.from!=i.ch&&X.to!=i.ch)return t;var $=U+(X.from==i.ch==(X.level!=1)?0:1);if($==0||$==A.length)return t;var Z;if(r.line!=i.line)Z=(r.line-i.line)*(e.doc.direction=="ltr"?1:-1)>0;else{var le=Xe(A,r.ch,r.sticky),ce=le-U||(r.ch-i.ch)*(X.level==1?-1:1);le==$-1||le==$?Z=ce<0:Z=ce>0}var xe=A[$+(Z?-1:0)],ye=Z==(xe.level==1),ke=ye?xe.from:xe.to,Fe=ye?"after":"before";return i.ch==ke&&i.sticky==Fe?t:new Gt(new ze(i.line,ke,Fe),r)}function Ss(e,t,i,r){var n,A;if(t.touches)n=t.touches[0].clientX,A=t.touches[0].clientY;else try{n=t.clientX,A=t.clientY}catch(xe){return!1}if(n>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&te(t);var U=e.display,X=U.lineDiv.getBoundingClientRect();if(A>X.bottom||!de(e,i))return ne(t);A-=X.top-U.viewOffset;for(var $=0;$<e.display.gutterSpecs.length;++$){var Z=U.gutters.childNodes[$];if(Z&&Z.getBoundingClientRect().right>=n){var le=zt(e.doc,A),ce=e.display.gutterSpecs[$];return Ae(e,i,e,le,ce.className,t),ne(t)}}}function Ga(e,t){return Ss(e,t,"gutterClick",!0)}function Cs(e,t){if(fi(e.display,t)||Yl(e,t))return;if(Oe(e,t,"contextmenu"))return;R||e.display.input.onContextMenu(t)}function Yl(e,t){return de(e,"gutterContextMenu")?Ss(e,t,"gutterContextMenu",!1):!1}function Ts(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),vn(e)}var un={toString:function(){return"CodeMirror.Init"}},ws={},aa={};function $l(e){var t=e.optionHandlers;function i(r,n,A,U){e.defaults[r]=n,A&&(t[r]=U?function(X,$,Z){Z!=un&&A(X,$,Z)}:A)}e.defineOption=i,e.Init=un,i("value","",function(r,n){return r.setValue(n)},!0),i("mode",null,function(r,n){r.doc.modeOption=n,Pa(r)},!0),i("indentUnit",2,Pa,!0),i("indentWithTabs",!1),i("smartIndent",!0),i("tabSize",4,function(r){wn(r),vn(r),Mr(r)},!0),i("lineSeparator",null,function(r,n){if(r.doc.lineSep=n,!n)return;var A=[],U=r.doc.first;r.doc.iter(function($){for(var Z=0;;){var le=$.text.indexOf(n,Z);if(le==-1)break;Z=le+n.length,A.push(ze(U,le))}U++});for(var X=A.length-1;X>=0;X--)an(r.doc,n,A[X],ze(A[X].line,A[X].ch+n.length))}),i("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(r,n,A){r.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),A!=un&&r.refresh()}),i("specialCharPlaceholder",bt,function(r){return r.refresh()},!0),i("electricChars",!0),i("inputStyle",a?"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",!_),i("wholeLineUpdateBefore",!0),i("theme","default",function(r){Ts(r),Tn(r)},!0),i("keyMap","default",function(r,n,A){var U=ia(n),X=A!=un&&ia(A);X&&X.detach&&X.detach(r,U),U.attach&&U.attach(r,X||null)}),i("extraKeys",null),i("configureMouse",null),i("lineWrapping",!1,Jl,!0),i("gutters",[],function(r,n){r.display.gutterSpecs=Oa(n,r.options.lineNumbers),Tn(r)},!0),i("fixedGutter",!0,function(r,n){r.display.gutters.style.left=n?Sa(r.display)+"px":"0",r.refresh()},!0),i("coverGutterNextToScrollbar",!1,function(r){return en(r)},!0),i("scrollbarStyle","native",function(r){Ao(r),en(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=Oa(r.options.gutters,n),Tn(r)},!0),i("firstLineNumber",1,Tn,!0),i("lineNumberFormatter",function(r){return r},Tn,!0),i("showCursorWhenSelecting",!1,yn,!0),i("resetSelectionOnContextMenu",!0),i("lineWiseCopyCut",!0),i("pasteLinesPerSelection",!0),i("selectionsMayTouch",!1),i("readOnly",!1,function(r,n){n=="nocursor"&&(Zi(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,Ql),i("allowDropFileTypes",null),i("cursorBlinkRate",530),i("cursorScrollMargin",0),i("cursorHeight",1,yn,!0),i("singleCursorHeightPerLine",!0,yn,!0),i("workTime",100),i("workDelay",100),i("flattenSpans",!0,wn,!0),i("addModeClass",!1,wn,!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,wn,!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 Ql(e,t,i){var r=i&&i!=un;if(!t!=!r){var n=e.display.dragFunctions,A=t?we:it;A(e.display.scroller,"dragstart",n.start),A(e.display.scroller,"dragenter",n.enter),A(e.display.scroller,"dragover",n.over),A(e.display.scroller,"dragleave",n.leave),A(e.display.scroller,"drop",n.drop)}}function Jl(e){e.options.lineWrapping?(j(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(g(e.display.wrapper,"CodeMirror-wrap"),ci(e)),Ca(e),Mr(e),vn(e),setTimeout(function(){return en(e)},100)}function er(e,t){var i=this;if(!(this instanceof er))return new er(e,t);this.options=t=t?F(t):{},F(ws,t,!1);var r=t.value;typeof r=="string"?r=new Pr(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var n=new er.inputStyles[t.inputStyle](this),A=this.display=new dl(e,r,n,t);A.wrapper.CodeMirror=this,Ts(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Ao(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 oe,keySeq:null,specialChars:null},t.autofocus&&!a&&A.input.focus(),B&&N<11&&setTimeout(function(){return i.display.input.reset(!0)},20),Zl(this),Dl(),Wi(this),this.curOp.forceUpdate=!0,Bo(this,r),t.autofocus&&!a||this.hasFocus()?setTimeout(function(){i.hasFocus()&&!i.state.focused&&wa(i)},20):Zi(this);for(var U in aa)aa.hasOwnProperty(U)&&aa[U](this,t[U],un);Ro(this),t.finishInit&&t.finishInit(this);for(var X=0;X<Ka.length;++X)Ka[X](this);Hi(this),M&&t.lineWrapping&&getComputedStyle(A.lineDiv).textRendering=="optimizelegibility"&&(A.lineDiv.style.textRendering="auto")}er.defaults=ws,er.optionHandlers=aa;function Zl(e){var t=e.display;we(t.scroller,"mousedown",vr(e,xs)),B&&N<11?we(t.scroller,"dblclick",vr(e,function($){if(Oe(e,$))return;var Z=Bi(e,$);if(!Z||Ga(e,$)||fi(e.display,$))return;te($);var le=e.findWordAt(Z);Zn(e.doc,le.anchor,le.head)})):we(t.scroller,"dblclick",function($){return Oe(e,$)||te($)}),we(t.scroller,"contextmenu",function($){return Cs(e,$)}),we(t.input.getField(),"contextmenu",function($){t.scroller.contains($.target)||Cs(e,$)});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 A($){if($.touches.length!=1)return!1;var Z=$.touches[0];return Z.radiusX<=1&&Z.radiusY<=1}function U($,Z){if(Z.left==null)return!0;var le=Z.left-$.left,ce=Z.top-$.top;return le*le+ce*ce>20*20}we(t.scroller,"touchstart",function($){if(!Oe(e,$)&&!A($)&&!Ga(e,$)){t.input.ensurePolled(),clearTimeout(i);var Z=+new Date;t.activeTouch={start:Z,moved:!1,prev:Z-r.end<=300?r:null},$.touches.length==1&&(t.activeTouch.left=$.touches[0].pageX,t.activeTouch.top=$.touches[0].pageY)}}),we(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),we(t.scroller,"touchend",function($){var Z=t.activeTouch;if(Z&&!fi(t,$)&&Z.left!=null&&!Z.moved&&new Date-Z.start<300){var le=e.coordsChar(t.activeTouch,"page"),ce;!Z.prev||U(Z,Z.prev)?ce=new Gt(le,le):!Z.prev.prev||U(Z,Z.prev.prev)?ce=e.findWordAt(le):ce=new Gt(ze(le.line,0),s(e.doc,ze(le.line+1,0))),e.setSelection(ce.anchor,ce.head),e.focus(),te($)}n()}),we(t.scroller,"touchcancel",n),we(t.scroller,"scroll",function(){t.scroller.clientHeight&&(xn(e,t.scroller.scrollTop),Fi(e,t.scroller.scrollLeft,!0),Ae(e,"scroll",e))}),we(t.scroller,"mousewheel",function($){return Mo(e,$)}),we(t.scroller,"DOMMouseScroll",function($){return Mo(e,$)}),we(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function($){Oe(e,$)||ae($)},over:function($){Oe(e,$)||(_l(e,$),ae($))},start:function($){return Al(e,$)},drop:vr(e,Ll),leave:function($){Oe(e,$)||ss(e)}};var X=t.input.getField();we(X,"keyup",function($){return ys.call(e,$)}),we(X,"keydown",vr(e,vs)),we(X,"keypress",vr(e,bs)),we(X,"focus",function($){return wa(e,$)}),we(X,"blur",function($){return Zi(e,$)})}var Ka=[];er.defineInitHook=function(e){return Ka.push(e)};function Un(e,t,i,r){var n=e.doc,A;i==null&&(i="add"),i=="smart"&&(n.mode.indent?A=Se(e,t).state:i="prev");var U=e.options.tabSize,X=ut(n,t),$=ee(X.text,null,U);X.stateAfter&&(X.stateAfter=null);var Z=X.text.match(/^\s*/)[0],le;if(!r&&!/\S/.test(X.text))le=0,i="not";else if(i=="smart"&&(le=n.mode.indent(A,X.text.slice(Z.length),X.text),le==_e||le>150)){if(!r)return;i="prev"}i=="prev"?t>n.first?le=ee(ut(n,t-1).text,null,U):le=0:i=="add"?le=$+e.options.indentUnit:i=="subtract"?le=$-e.options.indentUnit:typeof i=="number"&&(le=$+i),le=Math.max(0,le);var ce="",xe=0;if(e.options.indentWithTabs)for(var ye=Math.floor(le/U);ye;--ye)xe+=U,ce+=" ";if(xe<le&&(ce+=se(le-xe)),ce!=Z)return an(n,ce,ze(t,0),ze(t,Z.length),"+input"),X.stateAfter=null,!0;for(var ke=0;ke<n.sel.ranges.length;ke++){var Fe=n.sel.ranges[ke];if(Fe.head.line==t&&Fe.head.ch<Z.length){var Je=ze(t,Z.length);Ua(n,ke,new Gt(Je,Je));break}}}var ri=null;function oa(e){ri=e}function Va(e,t,i,r,n){var A=e.doc;e.display.shift=!1,r||(r=A.sel);var U=+new Date-200,X=n=="paste"||e.state.pasteIncoming>U,$=mt(t),Z=null;if(X&&r.ranges.length>1)if(ri&&ri.text.join(`
`)==t){if(r.ranges.length%ri.text.length==0){Z=[];for(var le=0;le<ri.text.length;le++)Z.push(A.splitLines(ri.text[le]))}}else $.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(Z=et($,function(nt){return[nt]}));for(var ce=e.curOp.updateInput,xe=r.ranges.length-1;xe>=0;xe--){var ye=r.ranges[xe],ke=ye.from(),Fe=ye.to();ye.empty()&&(i&&i>0?ke=ze(ke.line,ke.ch-i):e.state.overwrite&&!X?Fe=ze(Fe.line,Math.min(ut(A,Fe.line).text.length,Fe.ch+Re($).length)):X&&ri&&ri.lineWise&&ri.text.join(`
`)==$.join(`
`)&&(ke=Fe=ze(ke.line,0)));var Je={from:ke,to:Fe,text:Z?Z[xe%Z.length]:$,origin:n||(X?"paste":e.state.cutIncoming>U?"cut":"+input")};nn(e.doc,Je),Qt(e,"inputRead",e,Je)}t&&!X&&As(e,t),qi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=ce),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ls(e,t){var i=e.clipboardData&&e.clipboardData.getData("Text");if(i)return e.preventDefault(),!t.isReadOnly()&&!t.options.disableInput&&Hr(t,function(){return Va(t,i,0,null,"paste")}),!0}function As(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 A=e.getModeAt(n.head),U=!1;if(A.electricChars){for(var X=0;X<A.electricChars.length;X++)if(t.indexOf(A.electricChars.charAt(X))>-1){U=Un(e,n.head.line,"smart");break}}else A.electricInput&&(A.electricInput.test(ut(e.doc,n.head.line).text.slice(0,n.head.ch))&&(U=Un(e,n.head.line,"smart")));U&&Qt(e,"electricInput",e,n.head.line)}}function _s(e){for(var t=[],i=[],r=0;r<e.doc.sel.ranges.length;r++){var n=e.doc.sel.ranges[r].head.line,A={anchor:ze(n,0),head:ze(n+1,0)};i.push(A),t.push(e.getRange(A.anchor,A.head))}return{text:t,ranges:i}}function Ds(e,t,i,r){e.setAttribute("autocorrect",i?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function Rs(){var e=o("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=o("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return M?e.style.width="1000px":e.setAttribute("wrap","off"),S&&(e.style.border="1px solid black"),Ds(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 A=this.options,U=A[r];if(A[r]==n&&r!="mode")return;A[r]=n,t.hasOwnProperty(r)&&vr(this,t[r])(this,n,U),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"](ia(r))},removeKeyMap:function(r){for(var n=this.state.keyMaps,A=0;A<n.length;++A)if(n[A]==r||n[A].name==r)return n.splice(A,1),!0},addOverlay:_r(function(r,n){var A=r.token?r:e.getMode(this.options,r);if(A.startState)throw new Error("Overlays may not be stateful.");Ge(this.state.overlays,{mode:A,modeSpec:r,opaque:n&&n.opaque,priority:n&&n.priority||0},function(U){return U.priority}),this.state.modeGen++,Mr(this)}),removeOverlay:_r(function(r){for(var n=this.state.overlays,A=0;A<n.length;++A){var U=n[A].modeSpec;if(U==r||typeof r=="string"&&U.name==r){n.splice(A,1),this.state.modeGen++,Mr(this);return}}}),indentLine:_r(function(r,n,A){typeof n!="string"&&typeof n!="number"&&(n==null?n=this.options.smartIndent?"smart":"prev":n=n?"add":"subtract"),Rr(this.doc,r)&&Un(this,r,n,A)}),indentSelection:_r(function(r){for(var n=this.doc.sel.ranges,A=-1,U=0;U<n.length;U++){var X=n[U];if(X.empty())X.head.line>A&&(Un(this,X.head.line,r,!0),A=X.head.line,U==this.doc.sel.primIndex&&qi(this));else{var $=X.from(),Z=X.to(),le=Math.max(A,$.line);A=Math.min(this.lastLine(),Z.line-(Z.ch?0:1))+1;for(var ce=le;ce<A;++ce)Un(this,ce,r);var xe=this.doc.sel.ranges;$.ch==0&&n.length==xe.length&&xe[U].from().ch>0&&Ua(this.doc,U,new Gt($,xe[U].to()),be)}}}),getTokenAt:function(r,n){return Kt(this,r,n)},getLineTokens:function(r,n){return Kt(this,ze(r),n,!0)},getTokenTypeAt:function(r){r=s(this.doc,r);var n=Me(this,ut(this.doc,r.line)),A=0,U=(n.length-1)/2,X=r.ch,$;if(X==0)$=n[2];else for(;;){var Z=A+U>>1;if((Z?n[Z*2-1]:0)>=X)U=Z;else if(n[Z*2+1]<X)A=Z+1;else{$=n[Z*2+2];break}}var le=$?$.indexOf("overlay "):-1;return le<0?$:le==0?null:$.slice(0,le-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 A=[];if(!i.hasOwnProperty(n))return A;var U=i[n],X=this.getModeAt(r);if(typeof X[n]=="string")U[X[n]]&&A.push(U[X[n]]);else if(X[n])for(var $=0;$<X[n].length;$++){var Z=U[X[n][$]];Z&&A.push(Z)}else X.helperType&&U[X.helperType]?A.push(U[X.helperType]):U[X.name]&&A.push(U[X.name]);for(var le=0;le<U._global.length;le++){var ce=U._global[le];ce.pred(X,this)&&he(A,ce.val)==-1&&A.push(ce.val)}return A},getStateAfter:function(r,n){var A=this.doc;return r=z(A,r==null?A.first+A.size-1:r),Se(this,r+1,n).state},cursorCoords:function(r,n){var A,U=this.doc.sel.primary();return r==null?A=U.head:typeof r=="object"?A=s(this.doc,r):A=r?U.from():U.to(),ei(this,A,n||"page")},charCoords:function(r,n){return va(this,s(this.doc,r),n||"page")},coordsChar:function(r,n){return r=co(this,r,n||"page"),ba(this,r.left,r.top)},lineAtHeight:function(r,n){return r=co(this,{top:r,left:0},n||"page").top,zt(this.doc,r+this.display.viewOffset)},heightAtLine:function(r,n,A){var U=!1,X;if(typeof r=="number"){var $=this.doc.first+this.doc.size-1;r<this.doc.first?r=this.doc.first:r>$&&(r=$,U=!0),X=ut(this.doc,r)}else X=r;return Hn(this,X,{top:0,left:0},n||"page",A||U).top+(U?this.doc.height-Wr(X):0)},defaultTextHeight:function(){return Qi(this.display)},defaultCharWidth:function(){return Ji(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(r,n,A,U,X){var $=this.display;r=ei(this,s(this.doc,r));var Z=r.bottom,le=r.left;if(n.style.position="absolute",n.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(n),$.sizer.appendChild(n),U=="over")Z=r.top;else if(U=="above"||U=="near"){var ce=Math.max($.wrapper.clientHeight,this.doc.height),xe=Math.max($.sizer.clientWidth,$.lineSpace.clientWidth);(U=="above"||r.bottom+n.offsetHeight>ce)&&r.top>n.offsetHeight?Z=r.top-n.offsetHeight:r.bottom+n.offsetHeight<=ce&&(Z=r.bottom),le+n.offsetWidth>xe&&(le=xe-n.offsetWidth)}n.style.top=Z+"px",n.style.left=n.style.right="",X=="right"?(le=$.sizer.clientWidth-n.offsetWidth,n.style.right="0px"):(X=="left"?le=0:X=="middle"&&(le=($.sizer.clientWidth-n.offsetWidth)/2),n.style.left=le+"px"),A&&Qs(this,{left:le,top:Z,right:le+n.offsetWidth,bottom:Z+n.offsetHeight})},triggerOnKeyDown:_r(vs),triggerOnKeyPress:_r(bs),triggerOnKeyUp:ys,triggerOnMouseDown:_r(xs),execCommand:function(r){if(Pn.hasOwnProperty(r))return Pn[r].call(null,this)},triggerElectric:_r(function(r){As(this,r)}),findPosH:function(r,n,A,U){var X=1;n<0&&(X=-1,n=-n);for(var $=s(this.doc,r),Z=0;Z<n&&!($=Xa(this.doc,$,X,A,U),$.hitSide);++Z);return $},moveH:_r(function(r,n){var A=this;this.extendSelectionsBy(function(U){return A.display.shift||A.doc.extend||U.empty()?Xa(A.doc,U.head,r,n,A.options.rtlMoveVisually):r<0?U.from():U.to()},Te)}),deleteH:_r(function(r,n){var A=this.doc.sel,U=this.doc;A.somethingSelected()?U.replaceSelection("",null,"+delete"):ln(this,function(X){var $=Xa(U,X.head,r,n,!1);return r<0?{from:$,to:X.head}:{from:X.head,to:$}})}),findPosV:function(r,n,A,U){var X=1,$=U;n<0&&(X=-1,n=-n);for(var Z=s(this.doc,r),le=0;le<n;++le){var ce=ei(this,Z,"div");if($==null?$=ce.left:ce.left=$,Z=ks(this,ce,X,A),Z.hitSide)break}return Z},moveV:_r(function(r,n){var A=this,U=this.doc,X=[],$=!this.display.shift&&!U.extend&&U.sel.somethingSelected();if(U.extendSelectionsBy(function(le){if($)return r<0?le.from():le.to();var ce=ei(A,le.head,"div");le.goalColumn!=null&&(ce.left=le.goalColumn),X.push(ce.left);var xe=ks(A,ce,r,n);return n=="page"&&le==U.sel.primary()&&Aa(A,va(A,xe,"div").top-ce.top),xe},Te),X.length)for(var Z=0;Z<U.sel.ranges.length;Z++)U.sel.ranges[Z].goalColumn=X[Z]}),findWordAt:function(r){var n=this.doc,A=ut(n,r.line).text,U=r.ch,X=r.ch;if(A){var $=this.getHelper(r,"wordChars");(r.sticky=="before"||X==A.length)&&U?--U:++X;for(var Z=A.charAt(U),le=$e(Z,$)?function(ce){return $e(ce,$)}:/\s/.test(Z)?function(ce){return/\s/.test(ce)}:function(ce){return!/\s/.test(ce)&&!$e(ce)};U>0&&le(A.charAt(U-1));)--U;for(;X<A.length&&le(A.charAt(X));)++X}return new Gt(ze(r.line,U),ze(r.line,X))},toggleOverwrite:function(r){if(r!=null&&r==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?j(this.display.cursorDiv,"CodeMirror-overwrite"):g(this.display.cursorDiv,"CodeMirror-overwrite"),Ae(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==O()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:_r(function(r,n){bn(this,r,n)}),getScrollInfo:function(){var r=this.display.scroller;return{left:r.scrollLeft,top:r.scrollTop,height:r.scrollHeight-si(this)-this.display.barHeight,width:r.scrollWidth-si(this)-this.display.barWidth,clientHeight:pa(this),clientWidth:Ii(this)}},scrollIntoView:_r(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:ze(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):Co(this,r.from,r.to,r.margin)}),setSize:_r(function(r,n){var A=this,U=function($){return typeof $=="number"||/^\d+$/.test(String($))?$+"px":$};r!=null&&(this.display.wrapper.style.width=U(r)),n!=null&&(this.display.wrapper.style.height=U(n)),this.options.lineWrapping&&lo(this);var X=this.display.viewFrom;this.doc.iter(X,this.display.viewTo,function($){if($.widgets){for(var Z=0;Z<$.widgets.length;Z++)if($.widgets[Z].noHScroll){Si(A,X,"widget");break}}++X}),this.curOp.forceUpdate=!0,Ae(this,"refresh",this)}),operation:function(r){return Hr(this,r)},startOperation:function(){return Wi(this)},endOperation:function(){return Hi(this)},refresh:_r(function(){var r=this.display.cachedTextHeight;Mr(this),this.curOp.forceUpdate=!0,vn(this),bn(this,this.doc.scrollLeft,this.doc.scrollTop),Ra(this.display),(r==null||Math.abs(r-Qi(this.display))>.5||this.options.lineWrapping)&&Ca(this),Ae(this,"refresh",this)}),swapDoc:_r(function(r){var n=this.doc;return n.cm=null,this.state.selectingText&&this.state.selectingText(),Bo(this,r),vn(this),this.display.input.reset(),bn(this,r.scrollLeft,r.scrollTop),this.curOp.forceScroll=!0,Qt(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}},ue(e),e.registerHelper=function(r,n,A){i.hasOwnProperty(r)||(i[r]=e[r]={_global:[]}),i[r][n]=A},e.registerGlobalHelper=function(r,n,A,U){e.registerHelper(r,n,U),i[r]._global.push({pred:A,val:U})}}function Xa(e,t,i,r,n){var A=t,U=i,X=ut(e,t.line),$=n&&e.direction=="rtl"?-i:i;function Z(){var dt=t.line+$;return dt<e.first||dt>=e.first+e.size?!1:(t=new ze(dt,t.ch,t.sticky),X=ut(e,dt))}function le(dt){var at;if(r=="codepoint"){var pt=X.text.charCodeAt(t.ch+(r>0?0:-1));isNaN(pt)?at=null:at=new ze(t.line,Math.max(0,Math.min(X.text.length,t.ch+i*(pt>=55296&&pt<56320?2:1))),-i)}else n?at=Pl(e.cm,X,t,i):at=ja(X,t,i);if(at==null)if(!dt&&Z())t=Wa(n,e.cm,X,t.line,$);else return!1;else t=at;return!0}if(r=="char"||r=="codepoint")le();else if(r=="column")le(!0);else if(r=="word"||r=="group")for(var ce=null,xe=r=="group",ye=e.cm&&e.cm.getHelper(t,"wordChars"),ke=!0;!(i<0&&!le(!ke));ke=!1){var Fe=X.text.charAt(t.ch)||`
`,Je=$e(Fe,ye)?"w":xe&&Fe==`
`?"n":!xe||/\s/.test(Fe)?null:"p";if(xe&&!ke&&!Je&&(Je="s"),ce&&ce!=Je){i<0&&(i=1,le(),t.sticky="after");break}if(Je&&(ce=Je),i>0&&!le(!ke))break}var nt=ea(e,t,A,U,!0);return ii(A,nt)&&(nt.hitSide=!0),nt}function ks(e,t,i,r){var n=e.doc,A=t.left,U;if(r=="page"){var X=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),$=Math.max(X-.5*Qi(e.display),3);U=(i>0?t.bottom:t.top)+i*$}else r=="line"&&(U=i>0?t.bottom+3:t.top-3);for(var Z;!(Z=ba(e,A,U),!Z.outside);){if(i<0?U<=0:U>=n.height){Z.hitSide=!0;break}U+=i*5}return Z}var $t=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new oe,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;Ds(n,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize);function A(X){for(var $=X.target;$;$=$.parentNode){if($==n)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test($.className))break}return!1}we(n,"paste",function(X){if(!A(X)||Oe(r,X)||Ls(X,r))return;N<=11&&setTimeout(vr(r,function(){return t.updateFromDOM()}),20)}),we(n,"compositionstart",function(X){t.composing={data:X.data,done:!1}}),we(n,"compositionupdate",function(X){t.composing||(t.composing={data:X.data,done:!1})}),we(n,"compositionend",function(X){t.composing&&(X.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),we(n,"touchstart",function(){return i.forceCompositionEnd()}),we(n,"input",function(){t.composing||t.readFromDOMSoon()});function U(X){if(!A(X)||Oe(r,X))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()}),X.type=="cut"&&r.replaceSelection("",null,"cut");else if(r.options.lineWiseCopyCut){var $=_s(r);oa({lineWise:!0,text:$.text}),X.type=="cut"&&r.operation(function(){r.setSelections($.ranges,0,be),r.replaceSelection("",null,"cut")})}else return;if(X.clipboardData){X.clipboardData.clearData();var Z=ri.text.join(`
`);if(X.clipboardData.setData("Text",Z),X.clipboardData.getData("Text")==Z){X.preventDefault();return}}var le=Rs(),ce=le.firstChild;r.display.lineSpace.insertBefore(le,r.display.lineSpace.firstChild),ce.value=ri.text.join(`
`);var xe=document.activeElement;J(ce),setTimeout(function(){r.display.lineSpace.removeChild(le),xe.focus(),xe==n&&i.showPrimarySelection()},50)}we(n,"copy",U),we(n,"cut",U)},$t.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},$t.prototype.prepareSelection=function(){var e=yo(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 A=sa(t,e.anchorNode,e.anchorOffset),U=sa(t,e.focusNode,e.focusOffset);if(A&&!A.bad&&U&&!U.bad&&At(Ri(A,U),r)==0&&At(hi(A,U),n)==0)return;var X=t.display.view,$=r.line>=t.display.viewFrom&&Os(t,r)||{node:X[0].measure.map[2],offset:0},Z=n.line<t.display.viewTo&&Os(t,n);if(!Z){var le=X[X.length-1].measure,ce=le.maps?le.maps[le.maps.length-1]:le.map;Z={node:ce[ce.length-1],offset:ce[ce.length-2]-ce[ce.length-3]}}if(!$||!Z){e.removeAllRanges();return}var xe=e.rangeCount&&e.getRangeAt(0),ye;try{ye=E($.node,$.offset,Z.offset,Z.node)}catch(ke){}ye&&(!D&&t.state.focused?(e.collapse($.node,$.offset),ye.collapsed||(e.removeAllRanges(),e.addRange(ye))):(e.removeAllRanges(),e.addRange(ye)),xe&&e.anchorNode==null?e.addRange(xe):D&&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){u(this.cm.display.cursorDiv,e.cursors),u(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 v(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():Hr(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(d&&p&&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=sa(t,e.anchorNode,e.anchorOffset),r=sa(t,e.focusNode,e.focusOffset);i&&r&&Hr(t,function(){Lr(t.doc,Ti(i,r),be),(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=ze(r.line-1,ut(e.doc,r.line-1).length)),n.ch==ut(e.doc,n.line).text.length&&n.line<e.lastLine()&&(n=ze(n.line+1,0)),r.line<t.viewFrom||n.line>t.viewTo-1)return!1;var A,U,X;r.line==t.viewFrom||(A=Ui(e,r.line))==0?(U=Ot(t.view[0].line),X=t.view[0].node):(U=Ot(t.view[A].line),X=t.view[A-1].node.nextSibling);var $=Ui(e,n.line),Z,le;if($==t.view.length-1?(Z=t.viewTo-1,le=t.lineDiv.lastChild):(Z=Ot(t.view[$+1].line)-1,le=t.view[$+1].node.previousSibling),!X)return!1;for(var ce=e.doc.splitLines(tu(e,X,le,U,Z)),xe=qt(e.doc,ze(U,0),ze(Z,ut(e.doc,Z).text.length));ce.length>1&&xe.length>1;)if(Re(ce)==Re(xe))ce.pop(),xe.pop(),Z--;else if(ce[0]==xe[0])ce.shift(),xe.shift(),U++;else break;for(var ye=0,ke=0,Fe=ce[0],Je=xe[0],nt=Math.min(Fe.length,Je.length);ye<nt&&Fe.charCodeAt(ye)==Je.charCodeAt(ye);)++ye;for(var dt=Re(ce),at=Re(xe),pt=Math.min(dt.length-(ce.length==1?ye:0),at.length-(xe.length==1?ye:0));ke<pt&&dt.charCodeAt(dt.length-ke-1)==at.charCodeAt(at.length-ke-1);)++ke;if(ce.length==1&&xe.length==1&&U==r.line)for(;ye&&ye>r.ch&&dt.charCodeAt(dt.length-ke-1)==at.charCodeAt(at.length-ke-1);)ye--,ke++;ce[ce.length-1]=dt.slice(0,dt.length-ke).replace(/^\u200b+/,""),ce[0]=ce[0].slice(ye).replace(/\u200b+$/,"");var wt=ze(U,ye),St=ze(Z,xe.length?Re(xe).length-ke:0);if(ce.length>1||ce[0]||At(wt,St))return an(e.doc,ce,wt,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())&&Hr(this.cm,function(){return Mr(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()||vr(this.cm,Va)(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 Os(e,t){var i=ma(e,t.line);if(!i||i.hidden)return null;var r=ut(e.doc,t.line),n=io(i,r,t.line),A=Ve(r,e.doc.direction),U="left";if(A){var X=Xe(A,t.ch);U=X%2?"right":"left"}var $=oo(n.map,t.ch,U);return $.offset=$.collapse=="right"?$.end:$.start,$}function eu(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function dn(e,t){return t&&(e.bad=!0),e}function tu(e,t,i,r,n){var A="",U=!1,X=e.doc.lineSeparator(),$=!1;function Z(ye){return function(ke){return ke.id==ye}}function le(){U&&(A+=X,$&&(A+=X),U=$=!1)}function ce(ye){ye&&(le(),A+=ye)}function xe(ye){if(ye.nodeType==1){var ke=ye.getAttribute("cm-text");if(ke){ce(ke);return}var Fe=ye.getAttribute("cm-marker"),Je;if(Fe){var nt=e.findMarks(ze(r,0),ze(n+1,0),Z(+Fe));nt.length&&(Je=nt[0].find(0))&&ce(qt(e.doc,Je.from,Je.to).join(X));return}if(ye.getAttribute("contenteditable")=="false")return;var dt=/^(pre|div|p|li|table|br)$/i.test(ye.nodeName);if(!/^br$/i.test(ye.nodeName)&&ye.textContent.length==0)return;dt&&le();for(var at=0;at<ye.childNodes.length;at++)xe(ye.childNodes[at]);/^(pre|p)$/i.test(ye.nodeName)&&($=!0),dt&&(U=!0)}else ye.nodeType==3&&ce(ye.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;!(xe(t),t==i);)t=t.nextSibling,$=!1;return A}function sa(e,t,i){var r;if(t==e.display.lineDiv){if(r=e.display.lineDiv.childNodes[i],!r)return dn(e.clipPos(ze(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 A=e.display.view[n];if(A.node==r)return ru(A,t,i)}}function ru(e,t,i){var r=e.text.firstChild,n=!1;if(!t||!v(r,t))return dn(ze(Ot(e.line),0),!0);if(t==r&&(n=!0,t=r.childNodes[i],i=0,!t)){var A=e.rest?Re(e.rest):e.line;return dn(ze(Ot(A),A.text.length),n)}var U=t.nodeType==3?t:null,X=t;for(!U&&t.childNodes.length==1&&t.firstChild.nodeType==3&&(U=t.firstChild,i&&(i=U.nodeValue.length));X.parentNode!=r;)X=X.parentNode;var $=e.measure,Z=$.maps;function le(Je,nt,dt){for(var at=-1;at<(Z?Z.length:0);at++)for(var pt=at<0?$.map:Z[at],wt=0;wt<pt.length;wt+=3){var St=pt[wt+2];if(St==Je||St==nt){var Mt=Ot(at<0?e.line:e.rest[at]),Zt=pt[wt]+dt;return(dt<0||St!=Je)&&(Zt=pt[wt+(dt?1:0)]),ze(Mt,Zt)}}}var ce=le(U,X,i);if(ce)return dn(ce,n);for(var xe=X.nextSibling,ye=U?U.nodeValue.length-i:0;xe;xe=xe.nextSibling){if(ce=le(xe,xe.firstChild,0),ce)return dn(ze(ce.line,ce.ch-ye),n);ye+=xe.textContent.length}for(var ke=X.previousSibling,Fe=i;ke;ke=ke.previousSibling){if(ce=le(ke,ke.firstChild,-1),ce)return dn(ze(ce.line,ce.ch+Fe),n);Fe+=ke.textContent.length}}var or=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new oe,this.hasSelection=!1,this.composing=null};or.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"),we(n,"input",function(){B&&N>=9&&t.hasSelection&&(t.hasSelection=null),i.poll()}),we(n,"paste",function(U){if(Oe(r,U)||Ls(U,r))return;r.state.pasteIncoming=+new Date,i.fastPoll()});function A(U){if(Oe(r,U))return;if(r.somethingSelected())oa({lineWise:!1,text:r.getSelections()});else if(r.options.lineWiseCopyCut){var X=_s(r);oa({lineWise:!0,text:X.text}),U.type=="cut"?r.setSelections(X.ranges,null,be):(i.prevInput="",n.value=X.text.join(`
`),J(n))}else return;U.type=="cut"&&(r.state.cutIncoming=+new Date)}we(n,"cut",A),we(n,"copy",A),we(e.scroller,"paste",function(U){if(fi(e,U)||Oe(r,U))return;if(!n.dispatchEvent){r.state.pasteIncoming=+new Date,i.focus();return}var X=new Event("paste");X.clipboardData=U.clipboardData,n.dispatchEvent(X)}),we(e.lineSpace,"selectstart",function(U){fi(e,U)||te(U)}),we(n,"compositionstart",function(){var U=r.getCursor("from");i.composing&&i.composing.range.clear(),i.composing={start:U,range:r.markText(U,r.getCursor("to"),{className:"CodeMirror-composing"})}}),we(n,"compositionend",function(){i.composing&&(i.poll(),i.composing.range.clear(),i.composing=null)})},or.prototype.createField=function(e){this.wrapper=Rs(),this.textarea=this.wrapper.firstChild},or.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},or.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,r=yo(e);if(e.options.moveInputWithCursor){var n=ei(e,i.sel.primary().head,"div"),A=t.wrapper.getBoundingClientRect(),U=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,n.top+U.top-A.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,n.left+U.left-A.left))}return r},or.prototype.showSelection=function(e){var t=this.cm,i=t.display;u(i.cursorDiv,e.cursors),u(i.selectionDiv,e.selection),e.teTop!=null&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},or.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&&J(this.textarea),B&&N>=9&&(this.hasSelection=i)}else e||(this.prevInput=this.textarea.value="",B&&N>=9&&(this.hasSelection=null))},or.prototype.getField=function(){return this.textarea},or.prototype.supportsTouch=function(){return!1},or.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!a||O()!=this.textarea))try{this.textarea.focus()}catch(e){}},or.prototype.blur=function(){this.textarea.blur()},or.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},or.prototype.receivedFocus=function(){this.slowPoll()},or.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()})},or.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)},or.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||He(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(B&&N>=9&&this.hasSelection===n||l&&/[\uf700-\uf7ff]/.test(n))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var A=n.charCodeAt(0);if(A==8203&&!r&&(r="\u200B"),A==8666)return this.reset(),this.cm.execCommand("undo")}for(var U=0,X=Math.min(r.length,n.length);U<X&&r.charCodeAt(U)==n.charCodeAt(U);)++U;return Hr(t,function(){Va(t,n.slice(U),r.length-U,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},or.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},or.prototype.onKeyPress=function(){B&&N>=9&&(this.hasSelection=null),this.fastPoll()},or.prototype.onContextMenu=function(e){var t=this,i=t.cm,r=i.display,n=t.textarea;t.contextMenuPending&&t.contextMenuPending();var A=Bi(i,e),U=r.scroller.scrollTop;if(!A||y)return;var X=i.options.resetSelectionOnContextMenu;X&&i.doc.sel.contains(A)==-1&&vr(i,Lr)(i.doc,Ti(A),be);var $=n.style.cssText,Z=t.wrapper.style.cssText,le=t.wrapper.offsetParent.getBoundingClientRect();t.wrapper.style.cssText="position: static",n.style.cssText=`position: absolute; width: 30px; height: 30px;
top: `+(e.clientY-le.top-5)+"px; left: "+(e.clientX-le.left-5)+`px;
z-index: 1000; background: `+(B?"rgba(255, 255, 255, .05)":"transparent")+`;
outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`;var ce;M&&(ce=window.scrollY),r.input.focus(),M&&window.scrollTo(null,ce),r.input.reset(),i.somethingSelected()||(n.value=t.prevInput=" "),t.contextMenuPending=ye,r.selForContextMenu=i.doc.sel,clearTimeout(r.detectingSelectAll);function xe(){if(n.selectionStart!=null){var Fe=i.somethingSelected(),Je="\u200B"+(Fe?n.value:"");n.value="\u21DA",n.value=Je,t.prevInput=Fe?"":"\u200B",n.selectionStart=1,n.selectionEnd=Je.length,r.selForContextMenu=i.doc.sel}}function ye(){if(t.contextMenuPending!=ye)return;if(t.contextMenuPending=!1,t.wrapper.style.cssText=Z,n.style.cssText=$,B&&N<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=U),n.selectionStart!=null){(!B||B&&N<9)&&xe();var Fe=0,Je=function(){r.selForContextMenu==i.doc.sel&&n.selectionStart==0&&n.selectionEnd>0&&t.prevInput=="\u200B"?vr(i,Qo)(i):Fe++<10?r.detectingSelectAll=setTimeout(Je,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(Je,200)}}if(B&&N>=9&&xe(),R){ae(e);var ke=function(){it(window,"mouseup",ke),setTimeout(ye,20)};we(window,"mouseup",ke)}else setTimeout(ye,50)},or.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled=e=="nocursor",this.textarea.readOnly=!!e},or.prototype.setUneditable=function(){},or.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=O();t.autofocus=i==e||e.getAttribute("autofocus")!=null&&i==document.body}function r(){e.value=X.getValue()}var n;if(e.form&&(we(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var A=e.form;n=A.submit;try{var U=A.submit=function(){r(),A.submit=n,A.submit(),A.submit=U}}catch($){}}t.finishInit=function($){$.save=r,$.getTextArea=function(){return e},$.toTextArea=function(){$.toTextArea=isNaN,r(),e.parentNode.removeChild($.getWrapperElement()),e.style.display="",e.form&&(it(e.form,"submit",r),!t.leaveSubmitMethodAlone&&typeof e.form.submit=="function"&&(e.form.submit=n))}},e.style.display="none";var X=er(function($){return e.parentNode.insertBefore($,e.nextSibling)},t);return X}function nu(e){e.off=it,e.on=we,e.wheelEventPixels=hl,e.Doc=Pr,e.splitLines=mt,e.countColumn=ee,e.findColumn=Ce,e.isWordChar=je,e.Pass=_e,e.signal=Ae,e.Line=Ei,e.changeEnd=wi,e.scrollbarModel=Lo,e.Pos=ze,e.cmpPos=At,e.modes=Lt,e.mimeModes=Et,e.resolveMode=gt,e.getMode=ir,e.modeExtensions=pr,e.extendMode=lr,e.copyState=wr,e.startState=Ur,e.innerMode=$r,e.commands=Pn,e.keyMap=pi,e.keyName=cs,e.isModifierKey=ds,e.lookupKey=sn,e.normalizeKeyMap=Ml,e.StringStream=ct,e.SharedTextMarker=kn,e.TextMarker=Ai,e.LineWidget=Rn,e.e_preventDefault=te,e.e_stopPropagation=q,e.e_stop=ae,e.addClass=j,e.contains=v,e.rmClass=g,e.keyNames=_i}$l(er),ql(er);var au="iter insert remove copy getEditor constructor".split(" ");for(var la in Pr.prototype)Pr.prototype.hasOwnProperty(la)&&he(au,la)<0&&(er.prototype[la]=function(e){return function(){return e.apply(this.doc,arguments)}}(Pr.prototype[la]));return ue(Pr),er.inputStyles={textarea:or,contenteditable:$t},er.defineMode=function(e){!er.defaults.mode&&e!="null"&&(er.defaults.mode=e),sr.apply(this,arguments)},er.defineMIME=Xt,er.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),er.defineMIME("text/plain","null"),er.defineExtension=function(e,t){er.prototype[e]=t},er.defineDocExtension=function(e,t){Pr.prototype[e]=t},er.fromTextArea=iu,nu(er),er.version="5.58.2",er})},Y1PL:function(ht,ot,re){"use strict";re.r(ot),re.d(ot,"ResizableTextArea",function(){return he});var ie=re("wx14"),Y=re("1OyB"),D=re("vuIU"),V=re("Ji7U"),I=re("LK+K"),w=re("q1tI"),B=re("VTBJ"),N=re("rePB"),M=re("Zm9Q"),k=re("Kwbf"),p=re("c+Xe"),y=re("m+aA"),P=re("bdgK"),L=new Map;function x(be){be.forEach(function(Ee){var Te,Ce=Ee.target;(Te=L.get(Ce))===null||Te===void 0||Te.forEach(function(me){return me(Ce)})})}var S=new P.default(x),d=null,a=null;function l(be,Ee){L.has(be)||(L.set(be,new Set),S.observe(be)),L.get(be).add(Ee)}function h(be,Ee){L.has(be)&&(L.get(be).delete(Ee),L.get(be).size||(S.unobserve(be),L.delete(be)))}var _=function(be){Object(V.a)(Te,be);var Ee=Object(I.a)(Te);function Te(){return Object(Y.a)(this,Te),Ee.apply(this,arguments)}return Object(D.a)(Te,[{key:"render",value:function(){return this.props.children}}]),Te}(w.Component),f=w.createContext(null);function b(be){var Ee=be.children,Te=be.onBatchResize,Ce=w.useRef(0),me=w.useRef([]),se=w.useContext(f),Re=w.useCallback(function(et,Ge,tt){Ce.current+=1;var Ye=Ce.current;me.current.push({size:et,element:Ge,data:tt}),Promise.resolve().then(function(){Ye===Ce.current&&(Te==null||Te(me.current),me.current=[])}),se==null||se(et,Ge,tt)},[Te,se]);return w.createElement(f.Provider,{value:Re},Ee)}function R(be){var Ee=be.children,Te=be.disabled,Ce=w.useRef(null),me=w.useRef(null),se=w.useContext(f),Re=w.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),et=w.isValidElement(Ee)&&Object(p.c)(Ee),Ge=et?Ee.ref:null,tt=w.useMemo(function(){return Object(p.a)(Ge,Ce)},[Ge,Ce]),Ye=w.useRef(be);Ye.current=be;var De=w.useCallback(function(je){var $e=Ye.current,st=$e.onResize,Qe=$e.data,Be=je.getBoundingClientRect(),We=Be.width,ft=Be.height,Ke=je.offsetWidth,Ue=je.offsetHeight,Xe=Math.floor(We),Ze=Math.floor(ft);if(Re.current.width!==Xe||Re.current.height!==Ze||Re.current.offsetWidth!==Ke||Re.current.offsetHeight!==Ue){var Ve={width:Xe,height:Ze,offsetWidth:Ke,offsetHeight:Ue};Re.current=Ve;var rt=Ke===Math.round(We)?We:Ke,we=Ue===Math.round(ft)?ft:Ue,qe=Object(B.a)(Object(B.a)({},Ve),{},{offsetWidth:rt,offsetHeight:we});se==null||se(qe,je,Qe),st&&Promise.resolve().then(function(){st(qe,je)})}},[]);return w.useEffect(function(){var je=Object(y.a)(Ce.current)||Object(y.a)(me.current);return je&&!Te&&l(je,De),function(){return h(je,De)}},[Ce.current,Te]),w.createElement(_,{ref:me},et?w.cloneElement(Ee,{ref:tt}):Ee)}var T="rc-observer-key";function g(be){var Ee=be.children,Te=Object(M.a)(Ee);return Te.map(function(Ce,me){var se=(Ce==null?void 0:Ce.key)||"".concat(T,"-").concat(me);return w.createElement(R,Object(ie.a)({},be,{key:se}),Ce)})}g.Collection=b;var c=g,u=re("bT9E"),o=re("TSYQ"),C=re.n(o),E=`
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
`,v=["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"],O={},j;function G(be){var Ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=be.getAttribute("id")||be.getAttribute("data-reactid")||be.getAttribute("name");if(Ee&&O[Te])return O[Te];var Ce=window.getComputedStyle(be),me=Ce.getPropertyValue("box-sizing")||Ce.getPropertyValue("-moz-box-sizing")||Ce.getPropertyValue("-webkit-box-sizing"),se=parseFloat(Ce.getPropertyValue("padding-bottom"))+parseFloat(Ce.getPropertyValue("padding-top")),Re=parseFloat(Ce.getPropertyValue("border-bottom-width"))+parseFloat(Ce.getPropertyValue("border-top-width")),et=v.map(function(tt){return"".concat(tt,":").concat(Ce.getPropertyValue(tt))}).join(";"),Ge={sizingStyle:et,paddingSize:se,borderSize:Re,boxSizing:me};return Ee&&Te&&(O[Te]=Ge),Ge}function J(be){var Ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Te=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,Ce=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;j||(j=document.createElement("textarea"),j.setAttribute("tab-index","-1"),j.setAttribute("aria-hidden","true"),document.body.appendChild(j)),be.getAttribute("wrap")?j.setAttribute("wrap",be.getAttribute("wrap")):j.removeAttribute("wrap");var me=G(be,Ee),se=me.paddingSize,Re=me.borderSize,et=me.boxSizing,Ge=me.sizingStyle;j.setAttribute("style","".concat(Ge,";").concat(E)),j.value=be.value||be.placeholder||"";var tt=Number.MIN_SAFE_INTEGER,Ye=Number.MAX_SAFE_INTEGER,De=j.scrollHeight,je;if(et==="border-box"?De+=Re:et==="content-box"&&(De-=se),Te!==null||Ce!==null){j.value=" ";var $e=j.scrollHeight-se;Te!==null&&(tt=$e*Te,et==="border-box"&&(tt=tt+se+Re),De=Math.max(tt,De)),Ce!==null&&(Ye=$e*Ce,et==="border-box"&&(Ye=Ye+se+Re),je=De>Ye?"":"hidden",De=Math.min(Ye,De))}return{height:De,minHeight:tt,maxHeight:Ye,overflowY:je,resize:"none"}}var K=re("Gytx"),F=re.n(K),ee;(function(be){be[be.NONE=0]="NONE",be[be.RESIZING=1]="RESIZING",be[be.RESIZED=2]="RESIZED"})(ee||(ee={}));var oe=function(be){Object(V.a)(Te,be);var Ee=Object(I.a)(Te);function Te(Ce){var me;return Object(Y.a)(this,Te),me=Ee.call(this,Ce),me.nextFrameActionId=void 0,me.resizeFrameId=void 0,me.textArea=void 0,me.saveTextArea=function(se){me.textArea=se},me.handleResize=function(se){var Re=me.state.resizeStatus,et=me.props,Ge=et.autoSize,tt=et.onResize;if(Re!==ee.NONE)return;typeof tt=="function"&&tt(se),Ge&&me.resizeOnNextFrame()},me.resizeOnNextFrame=function(){cancelAnimationFrame(me.nextFrameActionId),me.nextFrameActionId=requestAnimationFrame(me.resizeTextarea)},me.resizeTextarea=function(){var se=me.props.autoSize;if(!se||!me.textArea)return;var Re=se.minRows,et=se.maxRows,Ge=J(me.textArea,!1,Re,et);me.setState({textareaStyles:Ge,resizeStatus:ee.RESIZING},function(){cancelAnimationFrame(me.resizeFrameId),me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:ee.RESIZED},function(){me.resizeFrameId=requestAnimationFrame(function(){me.setState({resizeStatus:ee.NONE}),me.fixFirefoxAutoScroll()})})})})},me.renderTextArea=function(){var se=me.props,Re=se.prefixCls,et=Re===void 0?"rc-textarea":Re,Ge=se.autoSize,tt=se.onResize,Ye=se.className,De=se.disabled,je=me.state,$e=je.textareaStyles,st=je.resizeStatus,Qe=Object(u.a)(me.props,["prefixCls","onPressEnter","autoSize","defaultValue","onResize"]),Be=C()(et,Ye,Object(N.a)({},"".concat(et,"-disabled"),De));"value"in Qe&&(Qe.value=Qe.value||"");var We=Object(B.a)(Object(B.a)(Object(B.a)({},me.props.style),$e),st===ee.RESIZING?{overflowX:"hidden",overflowY:"hidden"}:null);return w.createElement(c,{onResize:me.handleResize,disabled:!(Ge||tt)},w.createElement("textarea",Object(ie.a)({},Qe,{className:Be,style:We,ref:me.saveTextArea})))},me.state={textareaStyles:{},resizeStatus:ee.NONE},me}return Object(D.a)(Te,[{key:"componentDidUpdate",value:function(me){(me.value!==this.props.value||!F()(me.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 me=this.textArea.selectionStart,se=this.textArea.selectionEnd;this.textArea.setSelectionRange(me,se)}}catch(Re){}}},{key:"render",value:function(){return this.renderTextArea()}}]),Te}(w.Component),he=oe,ge=function(be){Object(V.a)(Te,be);var Ee=Object(I.a)(Te);function Te(Ce){var me;Object(Y.a)(this,Te),me=Ee.call(this,Ce),me.resizableTextArea=void 0,me.focus=function(){me.resizableTextArea.textArea.focus()},me.saveTextArea=function(Re){me.resizableTextArea=Re},me.handleChange=function(Re){var et=me.props.onChange;me.setValue(Re.target.value,function(){me.resizableTextArea.resizeTextarea()}),et&&et(Re)},me.handleKeyDown=function(Re){var et=me.props,Ge=et.onPressEnter,tt=et.onKeyDown;Re.keyCode===13&&Ge&&Ge(Re),tt&&tt(Re)};var se=typeof Ce.value=="undefined"||Ce.value===null?Ce.defaultValue:Ce.value;return me.state={value:se},me}return Object(D.a)(Te,[{key:"setValue",value:function(me,se){"value"in this.props||this.setState({value:me},se)}},{key:"blur",value:function(){this.resizableTextArea.textArea.blur()}},{key:"render",value:function(){return w.createElement(he,Object(ie.a)({},this.props,{value:this.state.value,onKeyDown:this.handleKeyDown,onChange:this.handleChange,ref:this.saveTextArea}))}}],[{key:"getDerivedStateFromProps",value:function(me){return"value"in me?{value:me.value}:null}}]),Te}(w.Component),_e=ot.default=ge},ZW9T:function(ht,ot,re){"use strict";re.d(ot,"a",function(){return _});var ie=re("k1fw"),Y=re("miYZ"),D=re("tsqr"),V=re("rAM+"),I=re("tJVT"),w=re("PpiC"),B=re("q1tI"),N=re.n(B),M=re("bdgK");function k(f,b,R,T,g){var c=b.getWordUntilPosition(R),u={startLineNumber:R.lineNumber,endLineNumber:R.lineNumber,startColumn:c.startColumn,endColumn:c.endColumn},o=T.map(function(C){return{label:C,kind:f.languages.CompletionItemKind.Keyword,insertText:C,insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:u}});return g.map(function(C){o.push(Object(ie.a)(Object(ie.a)({},C),{},{range:u}))}),o}var p=function(f){var b={label:"ifelse",kind:f.languages.CompletionItemKind.Method,insertText:["if (${1:condition}) {"," $0","} else {"," ","}"].join(`
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet},R=["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","_Complex","_Imaginary","_Alignas","_Alignof","_Atomic","_Static_assert","_Noreturn","_Thread_local","_Generic"];f.languages.registerCompletionItemProvider("cpp",{provideCompletionItems:function(u,o){var C=k(f,u,o,R,[b]);return{suggestions:C}}});var T=["False","None","True","and","as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"];f.languages.registerCompletionItemProvider("python",{provideCompletionItems:function(u,o){var C=[{label:"print",kind:f.languages.CompletionItemKind.Snippet,insertText:["print($0)"].join(`
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet}],E=k(f,u,o,T,C);return{suggestions:E}}});var g=["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instance of","int","interface","long","native","new","package","private","protected","public","return","strictfp","short","static","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"];f.languages.registerCompletionItemProvider("java",{provideCompletionItems:function(u,o){var C=[b,{label:"main",kind:f.languages.CompletionItemKind.Snippet,insertText:["public static void main(String[] args) {"," $0","}"].join(`
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet},{label:"System.out.print",kind:f.languages.CompletionItemKind.Snippet,insertText:["System.out.print($0)"].join(`
`),insertTextRules:f.languages.CompletionItemInsertTextRule.InsertAsSnippet}],E=k(f,u,o,g,C);return{suggestions:E}}})},y="\u8BE5\u4EFB\u52A1\u5173\u5361\u8BBE\u7F6E\u4E86\u7981\u6B62\u590D\u5236\u7C98\u8D34\uFF0C\u8BF7\u624B\u52A8\u8F93\u5165\u4EE3\u7801\u3002",P=re("LvDl");function L(f){return/^\d+$/.test(f)?"".concat(f,"px"):f}function x(){}var S=!1,d={"Python3.6":"python","Python2.7":"python",Dynamips:"cpp",Java:"java",Web:"php",Html:"html",Hive:"sql",Hadoop:"java",SDL:"cpp",PHP:"php",Matlab:"python",Git:"python",Python:"python","C/C++":"cpp","C++":"cpp",C:"cpp",Ruby:"ruby",Shell:"shell",JavaScript:"javascript",Perl6:"perl",Kotlin:"kotlin",Elixir:"elixir",Android:"java",JavaWeb:"java",Go:"go",Spark:"sql",MachineLearning:"python",Verilog:"xml","Verilog/VNC":"xml",Docker:"dockerfile","C#":"csharp",SQLite3:"sql",Oracle:"sql",Vhdl:"vhdl",R:"r",Swift:"swift",SQLServer:"mysql",MySQL:"mysql",Mongo:"sql",PostgreSql:"pgsql",Hbase:"powershell",Sqoop:"sql",Nasm:"cpp",Kafka:"java",Flink:"java",Sml:"javascript",OpenGL:"cpp",Perl5:"perl",Orange:"python"};function a(){var f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],b=f;if(Array.isArray(f)){for(var R=0;R<f.length;R++){var T=d[f[R]];if(T)return T}return b[0]}return d[b]||b}var l=null,h=ot.b=function(f){var b=f.width,R=b===void 0?"100%":b,T=f.height,g=T===void 0?"100%":T,c=f.value,u=f.language,o=u===void 0?"javascript":u,C=f.style,E=C===void 0?{}:C,v=f.options,O=v===void 0?{}:v,j=f.overrideServices,G=j===void 0?{}:j,J=f.theme,K=J===void 0?"vs-dark":J,F=f.onEditBlur,ee=f.onSave,oe=f.autoHeight,he=oe===void 0?!1:oe,ge=f.forbidCopy,_e=ge===void 0?!1:ge,be=f.onChange,Ee=be===void 0?x:be,Te=f.editorDidMount,Ce=Te===void 0?x:Te,me=f.onFocus,se=me===void 0?x:me,Re=f.filename,et=Re===void 0?"educoder.txt":Re,Ge=Object(w.a)(f,["width","height","value","language","style","options","overrideServices","theme","onEditBlur","onSave","autoHeight","forbidCopy","onChange","editorDidMount","onFocus","filename"]),tt=Object(B.useRef)(),Ye=Object(B.useRef)({}),De=Object(B.useRef)(),je=Object(B.useRef)(!1),$e=Object(B.useRef)(),st=Object(B.useState)(!1),Qe=Object(I.a)(st,2),Be=Qe[0],We=Qe[1];function ft(){var ne;return tt.current&&(ne=new M.default(function(ae){var ve=Object(V.a)(ae),Le;try{for(ve.s();!(Le=ve.n()).done;){var Ie=Le.value;(Ie.target.offsetHeight>0||Ie.target.offsetWidth>0)&&Ye.current.instance.layout()}}catch(lt){ve.e(lt)}finally{ve.f()}}),ne.observe(tt.current)),ne}function Ke(){D.b.warn(decodeURIComponent(y))}var Ue=function(){var ae=Ye.current.instance;if(c!=null&&ae&&Be){var ve=ae.getModel();ve&&c!==ve.getValue()&&(S=!0,ve.setValue(c),ae.layout(),S=!1)}};Object(B.useEffect)(function(){De.current&&clearTimeout(De.current),De.current=setTimeout(function(){Ue()},500)},[c,Be,Ye.current]);function Xe(){var ne=Ye.current.instance;if(ne){var ae=ne.getSelection(),ve=Ye.current.pastePos||{},Le=new l.Range(ve.startLineNumber||ae.endLineNumber,ve.startColumn||ae.endColumn,ve.endLineNumber||ae.endLineNumber,ve.endColumn||ae.endColumn);setTimeout(function(){ne.executeEdits("",[{range:Le,text:""}])},300)}}function Ze(ne){(window.navigator.platform.match("Mac")?ne.metaKey:ne.ctrlKey)&&ne.keyCode==83&&(ne.preventDefault(),ee())}var Ve=function(){if(he&&Ye.current.instance){var ae=Ye.current.instance.getContentHeight();te(ae<g?g:ae)}else te(g)};function rt(ne){var ae=document.createEvent("MouseEvents");ae.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),ne.dispatchEvent(ae)}function we(ne,ae){var ve=window.URL||window.webkitURL||window,Le=new Blob([ae]),Ie=document.createElementNS("http://www.w3.org/1999/xhtml","a");Ie.href=ve.createObjectURL(Le),Ie.download=ne,rt(Ie)}Object(B.useEffect)(function(){Ve()},[Ve]),Object(B.useEffect)(function(){tt.current&&!Be&&re.e(27).then(re.t.bind(null,"M/lh",7)).then(function(ne){try{l=ne,Ye.current.instance=l.editor.create(tt.current,{value:c,language:a(o),theme:K,requireConfig:{"vs/nls":{availableLanguages:{"*":"zh-cn"}}},wordWrap:!0},G);var ae=Ye.current.instance;if(Ce(ae,l),setTimeout(function(){Ve(),Ye.current.instance.addAction({id:"d123123",label:"Download File",contextMenuGroupId:"9_cutcopypaste",run:function(){we(et||"educoder.txt",ae.getValue())}})},500),Ye.current.subscription=ae.onDidChangeModelContent(function(Le){je.current?clearTimeout($e.current):(Ve(),Ee(ae.getValue(),Le)),$e.current=setTimeout(function(){je.current=!1},500)}),window.Monaco||p(l),_e&&(ae.addCommand(l.KeyMod.CtrlCmd|l.KeyMod.Shift|l.KeyCode.KEY_V,function(){return Ke(),null}),ae.addCommand(l.KeyMod.CtrlCmd|l.KeyCode.KEY_C,function(){return Ke(),null})),window.Monaco=l,F&&ae.onDidBlurEditorWidget(function(){F(ae.getValue())}),se&&ae.onDidFocusEditorText(function(){se(ae.getValue())}),_e){ae.addCommand(l.KeyMod.CtrlCmd|l.KeyCode.KEY_V,function(){return Ke(),null}),ae.onDidPaste(function(Le){Ye.current.pastePos=Le});try{window.addEventListener("paste",Xe)}catch(Le){}}var ve=ft();return We(!0),function(){var Le=Ye.current.instance;Le.dispose();var Ie=Le.getModel();Ie&&Ie.dispose(),Ye.current.subscription&&Ye.current.subscription.dispose(),_e&&window.removeEventListener("paste",Xe),ve.unobserve(tt.current)}}catch(Le){}})},[]),Object(B.useEffect)(function(){var ne=Ye.current.instance;if(ne&&Be)return document.addEventListener("keydown",Ze,!1),function(){document.removeEventListener("keydown",Ze)}},[ee,Be]),Object(B.useEffect)(function(){var ne=Ye.current.instance;if(ne&&Be){var ae=a(o);l.editor.setModelLanguage(ne.getModel(),ae),console.log("language:",o,ne.getModel(),ae)}},[o,Be]),Object(B.useEffect)(function(){var ne=Ye.current.instance;ne&&Be&&l.editor.setTheme(K)},[K,Be]),Object(B.useEffect)(function(){var ne=Ye.current.instance;ne&&Be&&(ne.updateOptions(Object(ie.a)({},O)),setTimeout(function(){ne.getModel().updateOptions(Object(ie.a)({},O))},200))},[JSON.stringify(O),Be]),Object(B.useEffect)(function(){var ne=Ye.current.instance;ne&&Be&&ne.layout()},[R,g,Be]);var qe=Object(B.useState)(L(R)),it=Object(I.a)(qe,2),Ae=it[0],Oe=it[1],pe=Object(B.useState)(L(g)),de=Object(I.a)(pe,2),ue=de[0],te=de[1],q=Object(ie.a)(Object(ie.a)({},E),{},{width:Ae,height:ue});return N.a.createElement("div",{className:"my-monaco-editor",ref:tt,style:q})};function _(f){var b=f.width,R=b===void 0?"100%":b,T=f.height,g=T===void 0?"100%":T,c=f.original,u=f.modified,o=f.language,C=f.options,E=C===void 0?{}:C,v=Object(B.useRef)(),O=Object(B.useState)(null),j=Object(I.a)(O,2),G=j[0],J=j[1];function K(he){var ge;return v.current&&(ge=new M.default(function(_e){var be=Object(V.a)(_e),Ee;try{for(be.s();!(Ee=be.n()).done;){var Te=Ee.value;(Te.target.offsetHeight>0||Te.target.offsetWidth>0)&&he.layout()}}catch(Ce){be.e(Ce)}finally{be.f()}}),ge.observe(v.current)),ge}Object(B.useEffect)(function(){v.current&&re.e(27).then(re.t.bind(null,"M/lh",7)).then(function(he){l=he;var ge=l.editor.createDiffEditor(v.current,Object(ie.a)(Object(ie.a)({enableSplitViewResizing:!1,scrollBeyondLastLine:!1,roundedSelection:!1,renderIndicators:!1,useShadows:!1,horizontal:"hidden",lineNumbers:"off",ignoreTrimWhitespace:!1,followsCaret:!0,ignoreCharChanges:!0,minimap:{enabled:!1},readOnly:!0},E),{},{wordWrap:!0}));J(ge);var _e=K(ge);return function(){ge.dispose();var be=ge.getModel();be&&be.dispose(),_e.unobserve(v.current)}})},[]),Object(B.useEffect)(function(){G&&G.setModel({original:l.editor.createModel(c,o),modified:l.editor.createModel(u,o)})},[c,u,o,G]);var F=L(R),ee=L(g),oe={width:F,height:ee};return N.a.createElement("div",{className:"my-diff-editor",ref:v,style:oe})}},ZpRC:function(ht,ot,re){"use strict";function ie(p){return typeof p=="object"&&p!=null&&p.nodeType===1}function Y(p,y){return(!y||p!=="hidden")&&p!=="visible"&&p!=="clip"}function D(p,y){if(p.clientHeight<p.scrollHeight||p.clientWidth<p.scrollWidth){var P=getComputedStyle(p,null);return Y(P.overflowY,y)||Y(P.overflowX,y)||function(L){var x=function(S){if(!S.ownerDocument||!S.ownerDocument.defaultView)return null;try{return S.ownerDocument.defaultView.frameElement}catch(d){return null}}(L);return!!x&&(x.clientHeight<L.scrollHeight||x.clientWidth<L.scrollWidth)}(p)}return!1}function V(p,y,P,L,x,S,d,a){return S<p&&d>y||S>p&&d<y?0:S<=p&&a<=P||d>=y&&a>=P?S-p-L:d>y&&a<P||S<p&&a>P?d-y+x:0}var I=function(p,y){var P=window,L=y.scrollMode,x=y.block,S=y.inline,d=y.boundary,a=y.skipOverflowHiddenElements,l=typeof d=="function"?d:function($e){return $e!==d};if(!ie(p))throw new TypeError("Invalid target");for(var h=document.scrollingElement||document.documentElement,_=[],f=p;ie(f)&&l(f);){if((f=f.parentElement)===h){_.push(f);break}f!=null&&f===document.body&&D(f)&&!D(document.documentElement)||f!=null&&D(f,a)&&_.push(f)}for(var b=P.visualViewport?P.visualViewport.width:innerWidth,R=P.visualViewport?P.visualViewport.height:innerHeight,T=window.scrollX||pageXOffset,g=window.scrollY||pageYOffset,c=p.getBoundingClientRect(),u=c.height,o=c.width,C=c.top,E=c.right,v=c.bottom,O=c.left,j=x==="start"||x==="nearest"?C:x==="end"?v:C+u/2,G=S==="center"?O+o/2:S==="end"?E:O,J=[],K=0;K<_.length;K++){var F=_[K],ee=F.getBoundingClientRect(),oe=ee.height,he=ee.width,ge=ee.top,_e=ee.right,be=ee.bottom,Ee=ee.left;if(L==="if-needed"&&C>=0&&O>=0&&v<=R&&E<=b&&C>=ge&&v<=be&&O>=Ee&&E<=_e)return J;var Te=getComputedStyle(F),Ce=parseInt(Te.borderLeftWidth,10),me=parseInt(Te.borderTopWidth,10),se=parseInt(Te.borderRightWidth,10),Re=parseInt(Te.borderBottomWidth,10),et=0,Ge=0,tt="offsetWidth"in F?F.offsetWidth-F.clientWidth-Ce-se:0,Ye="offsetHeight"in F?F.offsetHeight-F.clientHeight-me-Re:0;if(h===F)et=x==="start"?j:x==="end"?j-R:x==="nearest"?V(g,g+R,R,me,Re,g+j,g+j+u,u):j-R/2,Ge=S==="start"?G:S==="center"?G-b/2:S==="end"?G-b:V(T,T+b,b,Ce,se,T+G,T+G+o,o),et=Math.max(0,et+g),Ge=Math.max(0,Ge+T);else{et=x==="start"?j-ge-me:x==="end"?j-be+Re+Ye:x==="nearest"?V(ge,be,oe,me,Re+Ye,j,j+u,u):j-(ge+oe/2)+Ye/2,Ge=S==="start"?G-Ee-Ce:S==="center"?G-(Ee+he/2)+tt/2:S==="end"?G-_e+se+tt:V(Ee,_e,he,Ce,se+tt,G,G+o,o);var De=F.scrollLeft,je=F.scrollTop;j+=je-(et=Math.max(0,Math.min(je+et,F.scrollHeight-oe+Ye))),G+=De-(Ge=Math.max(0,Math.min(De+Ge,F.scrollWidth-he+tt)))}J.push({el:F,top:et,left:Ge})}return J};function w(p){return p===Object(p)&&Object.keys(p).length!==0}function B(p,y){y===void 0&&(y="auto");var P="scrollBehavior"in document.body.style;p.forEach(function(L){var x=L.el,S=L.top,d=L.left;x.scroll&&P?x.scroll({top:S,left:d,behavior:y}):(x.scrollTop=S,x.scrollLeft=d)})}function N(p){return p===!1?{block:"end",inline:"nearest"}:w(p)?p:{block:"start",inline:"nearest"}}function M(p,y){var P=!p.ownerDocument.documentElement.contains(p);if(w(y)&&typeof y.behavior=="function")return y.behavior(P?[]:I(p,y));if(P)return;var L=N(y);return B(I(p,L),L.behavior)}var k=ot.a=M},aRTE:function(ht,ot){ht.exports={L:1,M:0,Q:3,H:2}},bT9E:function(ht,ot,re){"use strict";re.d(ot,"a",function(){return Y});var ie=re("VTBJ");function Y(D,V){var I=Object(ie.a)({},D);return Array.isArray(V)&&V.forEach(function(w){delete I[w]}),I}},c5Ni:function(ht,ot,re){},dQei:function(ht,ot){for(var re={glog:function(Y){if(Y<1)throw new Error("glog("+Y+")");return re.LOG_TABLE[Y]},gexp:function(Y){for(;Y<0;)Y+=255;for(;Y>=256;)Y-=255;return re.EXP_TABLE[Y]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},ie=0;ie<8;ie++)re.EXP_TABLE[ie]=1<<ie;for(var ie=8;ie<256;ie++)re.EXP_TABLE[ie]=re.EXP_TABLE[ie-4]^re.EXP_TABLE[ie-5]^re.EXP_TABLE[ie-6]^re.EXP_TABLE[ie-8];for(var ie=0;ie<255;ie++)re.LOG_TABLE[re.EXP_TABLE[ie]]=ie;ht.exports=re},dWSS:function(ht,ot,re){var ie=re("dQei");function Y(D,V){if(D.length==null)throw new Error(D.length+"/"+V);for(var I=0;I<D.length&&D[I]==0;)I++;this.num=new Array(D.length-I+V);for(var w=0;w<D.length-I;w++)this.num[w]=D[w+I]}Y.prototype={get:function(D){return this.num[D]},getLength:function(){return this.num.length},multiply:function(D){for(var V=new Array(this.getLength()+D.getLength()-1),I=0;I<this.getLength();I++)for(var w=0;w<D.getLength();w++)V[I+w]^=ie.gexp(ie.glog(this.get(I))+ie.glog(D.get(w)));return new Y(V,0)},mod:function(D){if(this.getLength()-D.getLength()<0)return this;for(var V=ie.glog(this.get(0))-ie.glog(D.get(0)),I=new Array(this.getLength()),w=0;w<this.getLength();w++)I[w]=this.get(w);for(var w=0;w<D.getLength();w++)I[w]^=ie.gexp(ie.glog(D.get(w))+V);return new Y(I,0).mod(D)}},ht.exports=Y},dejd:function(ht,ot,re){},dmUQ:function(ht,ot,re){"use strict";var ie=re("Ff2n"),Y=re("rePB"),D=re("1OyB"),V=re("vuIU"),I=re("Ji7U"),w=re("md7G"),B=re("foSv"),N=re("q1tI"),M=re.n(N),k=re("TSYQ"),p=re.n(k),y=re("4IlW");function P(u,o){var C=Object.keys(u);if(Object.getOwnPropertySymbols){var E=Object.getOwnPropertySymbols(u);o&&(E=E.filter(function(v){return Object.getOwnPropertyDescriptor(u,v).enumerable})),C.push.apply(C,E)}return C}function L(u){for(var o=1;o<arguments.length;o++){var C=arguments[o]!=null?arguments[o]:{};o%2?P(Object(C),!0).forEach(function(E){Object(Y.a)(u,E,C[E])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(C)):P(Object(C)).forEach(function(E){Object.defineProperty(u,E,Object.getOwnPropertyDescriptor(C,E))})}return u}function x(u){var o=S();return function(){var E=Object(B.a)(u),v;if(o){var O=Object(B.a)(this).constructor;v=Reflect.construct(E,arguments,O)}else v=E.apply(this,arguments);return Object(w.a)(this,v)}}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(u){return!1}}function d(){}function a(u){u.preventDefault()}var l=function(o){return o.replace(/[^\w.-]+/g,"")},h=200,_=600,f=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,b=function(o){return o!=null},R=function(o,C){return C===o||typeof C=="number"&&typeof o=="number"&&isNaN(C)&&isNaN(o)},T=function(u){Object(I.a)(C,u);var o=x(C);function C(E){var v;Object(D.a)(this,C),v=o.call(this,E),v.onKeyDown=function(G){var J=v.props,K=J.onKeyDown,F=J.onPressEnter;if(G.keyCode===y.a.UP){var ee=v.getRatio(G);v.up(G,ee,null),v.stop()}else if(G.keyCode===y.a.DOWN){var oe=v.getRatio(G);v.down(G,oe,null),v.stop()}else G.keyCode===y.a.ENTER&&F&&F(G);if(v.recordCursorPosition(),v.lastKeyCode=G.keyCode,K){for(var he=arguments.length,ge=new Array(he>1?he-1:0),_e=1;_e<he;_e++)ge[_e-1]=arguments[_e];K.apply(void 0,[G].concat(ge))}},v.onKeyUp=function(G){var J=v.props.onKeyUp;if(v.stop(),v.recordCursorPosition(),J){for(var K=arguments.length,F=new Array(K>1?K-1:0),ee=1;ee<K;ee++)F[ee-1]=arguments[ee];J.apply(void 0,[G].concat(F))}},v.onChange=function(G){var J=v.props.onChange;v.state.focused&&(v.inputting=!0),v.rawInput=v.props.parser(v.getValueFromEvent(G)),v.setState({inputValue:v.rawInput}),J(v.toNumber(v.rawInput))},v.onMouseUp=function(){var G=v.props.onMouseUp;v.recordCursorPosition(),G&&G.apply(void 0,arguments)},v.onFocus=function(){var G;v.setState({focused:!0}),(G=v.props).onFocus.apply(G,arguments)},v.onBlur=function(){var G=v.props.onBlur;v.inputting=!1,v.setState({focused:!1});var J=v.getCurrentValidValue(v.state.inputValue),K=v.setValue(J,d);if(G){var F=v.input.value,ee=v.getInputDisplayValue({focus:!1,value:K});v.input.value=ee&&Number(ee),G.apply(void 0,arguments),v.input.value=F}},v.getRatio=function(G){var J=1;return G.metaKey||G.ctrlKey?J=.1:G.shiftKey&&(J=10),J},v.getFullNum=function(G){return isNaN(G)?G:/e/i.test(String(G))?Number(G).toFixed(18).replace(/\.?0+$/,""):G},v.getPrecision=function(G){if(b(v.props.precision))return v.props.precision;var J=String(G);if(J.indexOf("e-")>=0)return parseInt(J.slice(J.indexOf("e-")+2),10);var K=0;return J.indexOf(".")>=0&&(K=J.length-J.indexOf(".")-1),K},v.getInputDisplayValue=function(G){var J=G||v.state,K=J.focused,F=J.inputValue,ee=J.value,oe;K?oe=F:oe=v.toPrecisionAsStep(ee),oe==null&&(oe="");var he=v.formatWrapper(oe);return b(v.props.decimalSeparator)&&(he=he.toString().replace(".",v.props.decimalSeparator)),he},v.recordCursorPosition=function(){try{v.cursorStart=v.input.selectionStart,v.cursorEnd=v.input.selectionEnd,v.currentValue=v.input.value,v.cursorBefore=v.input.value.substring(0,v.cursorStart),v.cursorAfter=v.input.value.substring(v.cursorEnd)}catch(G){}},v.restoreByAfter=function(G){if(G===void 0)return!1;var J=v.input.value,K=J.lastIndexOf(G);if(K===-1)return!1;var F=v.cursorBefore.length;return v.lastKeyCode===y.a.DELETE&&v.cursorBefore.charAt(F-1)===G[0]?(v.fixCaret(F,F),!0):K+G.length===J.length?(v.fixCaret(K,K),!0):!1},v.partRestoreByAfter=function(G){return G===void 0?!1:Array.prototype.some.call(G,function(J,K){var F=G.substring(K);return v.restoreByAfter(F)})},v.isNotCompleteNumber=function(G){return isNaN(G)||G===""||G===null||G&&G.toString().indexOf(".")===G.toString().length-1},v.stop=function(){v.autoStepTimer&&clearTimeout(v.autoStepTimer)},v.down=function(G,J,K){v.pressingUpOrDown=!0,v.step("down",G,J,K)},v.up=function(G,J,K){v.pressingUpOrDown=!0,v.step("up",G,J,K)},v.saveInput=function(G){v.input=G};var O=E.value;O===void 0&&(O=E.defaultValue),v.state={focused:E.autoFocus};var j=v.getValidValue(v.toNumber(O));return v.state=L(L({},v.state),{},{inputValue:v.toPrecisionAsStep(j),value:j}),v}return Object(V.a)(C,[{key:"componentDidMount",value:function(){this.componentDidUpdate(null)}},{key:"componentDidUpdate",value:function(v){var O=this.props,j=O.value,G=O.onChange,J=O.max,K=O.min,F=this.state.focused;if(v){if(!R(v.value,j)||!R(v.max,J)||!R(v.min,K)){var ee=F?j:this.getValidValue(j),oe;this.pressingUpOrDown?oe=ee:this.inputting?oe=this.rawInput:oe=this.toPrecisionAsStep(ee),this.setState({value:ee,inputValue:oe})}var he="value"in this.props?j:this.state.value;"max"in this.props&&v.max!==J&&typeof he=="number"&&he>J&&G&&G(J),"min"in this.props&&v.min!==K&&typeof he=="number"&&he<K&&G&&G(K)}try{if(this.cursorStart!==void 0&&this.state.focused){if(!this.partRestoreByAfter(this.cursorAfter)&&this.state.value!==this.props.value){var ge=this.cursorStart+1;this.cursorAfter?this.lastKeyCode===y.a.BACKSPACE?ge=this.cursorStart-1:this.lastKeyCode===y.a.DELETE&&(ge=this.cursorStart):ge=this.input.value.length,this.fixCaret(ge,ge)}else if(this.currentValue===this.input.value)switch(this.lastKeyCode){case y.a.BACKSPACE:this.fixCaret(this.cursorStart-1,this.cursorStart-1);break;case y.a.DELETE:this.fixCaret(this.cursorStart+1,this.cursorStart+1);break;default:}}}catch(_e){}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(v){var O=v;return O===""?O="":this.isNotCompleteNumber(parseFloat(O))?O=this.state.value:O=this.getValidValue(O),this.toNumber(O)}},{key:"getValueFromEvent",value:function(v){var O=v.target.value.trim().replace(/。/g,".");return b(this.props.decimalSeparator)&&(O=O.replace(this.props.decimalSeparator,".")),O}},{key:"getValidValue",value:function(v){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.props.min,j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.props.max,G=parseFloat(v);return isNaN(G)?v:(G<O&&(G=O),G>j&&(G=j),G)}},{key:"setValue",value:function(v,O){var j=this.props.precision,G=this.isNotCompleteNumber(parseFloat(v))?null:parseFloat(v),J=this.state.value,K=J===void 0?null:J,F=this.state.inputValue,ee=F===void 0?null:F,oe=typeof G=="number"?G.toFixed(j):"".concat(G),he=G!==K||oe!=="".concat(ee);return"value"in this.props?(ee=this.toPrecisionAsStep(this.state.value),this.setState({inputValue:ee},O)):this.setState({value:G,inputValue:this.toPrecisionAsStep(v)},O),he&&this.props.onChange(G),G}},{key:"getMaxPrecision",value:function(v){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,j=this.props,G=j.precision,J=j.step;if(b(G))return G;var K=this.getPrecision(O),F=this.getPrecision(J),ee=this.getPrecision(v);return v?Math.max(ee,K+F):K+F}},{key:"getPrecisionFactor",value:function(v){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,j=this.getMaxPrecision(v,O);return Math.pow(10,j)}},{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(v){return this.props.formatter?this.props.formatter(v):v}},{key:"toPrecisionAsStep",value:function(v){if(this.isNotCompleteNumber(v)||v==="")return v;var O=Math.abs(this.getMaxPrecision(v));return isNaN(O)?v.toString():Number(v).toFixed(O)}},{key:"toNumber",value:function(v){var O=this.props.precision,j=this.state.focused,G=v&&v.length>16&&j;return this.isNotCompleteNumber(v)||G?v:b(O)?Math.round(v*Math.pow(10,O))/Math.pow(10,O):Number(v)}},{key:"upStep",value:function(v,O){var j=this.props.step,G=this.getPrecisionFactor(v,O),J=Math.abs(this.getMaxPrecision(v,O)),K=((G*v+G*j*O)/G).toFixed(J);return this.toNumber(K)}},{key:"downStep",value:function(v,O){var j=this.props.step,G=this.getPrecisionFactor(v,O),J=Math.abs(this.getMaxPrecision(v,O)),K=((G*v-G*j*O)/G).toFixed(J);return this.toNumber(K)}},{key:"step",value:function(v,O){var j=this,G=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,J=arguments.length>3?arguments[3]:void 0;this.stop(),O&&(O.persist(),O.preventDefault());var K=this.props;if(K.disabled)return;var F=this.getCurrentValidValue(this.state.inputValue)||0;if(this.isNotCompleteNumber(F))return;var ee=this["".concat(v,"Step")](F,G),oe=ee>K.max||ee<K.min;if(ee>K.max?ee=K.max:ee<K.min&&(ee=K.min),this.setValue(ee,null),this.setState({focused:!0},function(){j.pressingUpOrDown=!1}),oe)return;this.autoStepTimer=setTimeout(function(){j[v](O,G,!0)},J?h:_)}},{key:"fixCaret",value:function(v,O){if(v===void 0||O===void 0||!this.input||!this.input.value)return;try{var j=this.input.selectionStart,G=this.input.selectionEnd;(v!==j||O!==G)&&this.input.setSelectionRange(v,O)}catch(J){}}},{key:"render",value:function(){var v,O=this.props,j=O.prefixCls,G=O.disabled,J=O.readOnly,K=O.useTouch,F=O.autoComplete,ee=O.upHandler,oe=O.downHandler,he=O.className,ge=O.max,_e=O.min,be=O.style,Ee=O.title,Te=O.onMouseEnter,Ce=O.onMouseLeave,me=O.onMouseOver,se=O.onMouseOut,Re=O.required,et=O.onClick,Ge=O.tabIndex,tt=O.type,Ye=O.placeholder,De=O.id,je=O.inputMode,$e=O.pattern,st=O.step,Qe=O.maxLength,Be=O.autoFocus,We=O.name,ft=O.onPaste,Ke=O.onInput,Ue=Object(ie.a)(O,["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"]),Xe=this.state,Ze=Xe.value,Ve=Xe.focused,rt=p()(j,(v={},Object(Y.a)(v,he,!!he),Object(Y.a)(v,"".concat(j,"-disabled"),G),Object(Y.a)(v,"".concat(j,"-focused"),Ve),v)),we={};Object.keys(Ue).forEach(function(ae){(ae.substr(0,5)==="data-"||ae.substr(0,5)==="aria-"||ae==="role")&&(we[ae]=Ue[ae])});var qe=!J&&!G,it=this.getInputDisplayValue(null),Ae=(Ze||Ze===0)&&(isNaN(Ze)||Number(Ze)>=ge),Oe=(Ze||Ze===0)&&(isNaN(Ze)||Number(Ze)<=_e),pe=Ae||G||J,de=Oe||G||J,ue=p()("".concat(j,"-handler"),"".concat(j,"-handler-up"),Object(Y.a)({},"".concat(j,"-handler-up-disabled"),pe)),te=p()("".concat(j,"-handler"),"".concat(j,"-handler-down"),Object(Y.a)({},"".concat(j,"-handler-down-disabled"),de)),q=K?{onTouchStart:pe?d:this.up,onTouchEnd:this.stop}:{onMouseDown:pe?d:this.up,onMouseUp:this.stop,onMouseLeave:this.stop},ne=K?{onTouchStart:de?d:this.down,onTouchEnd:this.stop}:{onMouseDown:de?d:this.down,onMouseUp:this.stop,onMouseLeave:this.stop};return M.a.createElement("div",{className:rt,style:be,title:Ee,onMouseEnter:Te,onMouseLeave:Ce,onMouseOver:me,onMouseOut:se,onFocus:function(){return null},onBlur:function(){return null}},M.a.createElement("div",{className:"".concat(j,"-handler-wrap")},M.a.createElement("span",Object.assign({unselectable:"on"},q,{role:"button","aria-label":"Increase Value","aria-disabled":pe,className:ue}),ee||M.a.createElement("span",{unselectable:"on",className:"".concat(j,"-handler-up-inner"),onClick:a})),M.a.createElement("span",Object.assign({unselectable:"on"},ne,{role:"button","aria-label":"Decrease Value","aria-disabled":de,className:te}),oe||M.a.createElement("span",{unselectable:"on",className:"".concat(j,"-handler-down-inner"),onClick:a}))),M.a.createElement("div",{className:"".concat(j,"-input-wrap")},M.a.createElement("input",Object.assign({role:"spinbutton","aria-valuemin":_e,"aria-valuemax":ge,"aria-valuenow":Ze,required:Re,type:tt,placeholder:Ye,onPaste:ft,onClick:et,onMouseUp:this.onMouseUp,className:"".concat(j,"-input"),tabIndex:Ge,autoComplete:F,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:qe?this.onKeyDown:d,onKeyUp:qe?this.onKeyUp:d,autoFocus:Be,maxLength:Qe,readOnly:J,disabled:G,max:ge,min:_e,step:st,name:We,title:Ee,id:De,onChange:this.onChange,ref:this.saveInput,value:this.getFullNum(it),pattern:$e,inputMode:je,onInput:Ke},we))))}}]),C}(M.a.Component);T.defaultProps={focusOnUpDown:!0,useTouch:!1,prefixCls:"rc-input-number",max:f,min:-f,step:1,style:{},onChange:d,onKeyDown:d,onPressEnter:d,onFocus:d,onBlur:d,parser:l,required:!1,autoComplete:"off"};var g=T,c=ot.a=g},f4xo:function(ht,ot,re){var ie=re("nVVt");function Y(D){this.mode=ie.MODE_8BIT_BYTE,this.data=D}Y.prototype={getLength:function(D){return this.data.length},write:function(D){for(var V=0;V<this.data.length;V++)D.put(this.data.charCodeAt(V),8)}},ht.exports=Y},kSUc:function(ht,ot,re){},"kaH+":function(ht,ot,re){"use strict";var ie=re("+L6B"),Y=re("2/Rp"),D=re("tJVT"),V=re("q1tI"),I=re.n(V),w=re("UZu5"),B=re.n(w),N=re("dhSg"),M=re("rLCj"),k=re("dF/Y"),p=re("4i/N");ot.a=function(){var y=Object(V.useState)(""),P=Object(D.a)(y,2),L=P[0],x=P[1],S=Object(V.useState)(0),d=Object(D.a)(S,2),a=d[0],l=d[1],h=Object(V.useRef)("");Object(V.useEffect)(function(){var R=N.a.subscribe("preview-image",function(T){x(T),document.body.style.overflow="hidden"});return R},[]),Object(V.useEffect)(function(){return document.addEventListener("keydown",_),function(){document.removeEventListener("keydown",_)}},[]),Object(V.useEffect)(function(){h.current=L},[L]);function _(R){R.keyCode==27&&h.current&&f()}function f(){document.body.style.overflow="auto",x("")}function b(){l(a+90)}return I.a.createElement(V.Fragment,null,L?I.a.createElement("div",{className:"image-preview-container"},I.a.createElement("div",{className:"button-group"},I.a.createElement(Y.a,{onClick:b},"\u65CB\u8F6C",I.a.createElement(M.a,null)),I.a.createElement(Y.a,{href:L},"\u4E0B\u8F7D",I.a.createElement(k.a,null)),I.a.createElement(Y.a,{onClick:f},"\u5173\u95ED",I.a.createElement(p.a,null))),I.a.createElement("div",{className:"preview-wrp-group"},I.a.createElement("img",{className:"image-preview",src:L,alt:"\u9884\u89C8\u5927\u56FE",style:{transform:"rotate(".concat(a,"deg)")}}))):null)}},lZu9:function(ht,ot,re){(function(ie){ie(re("VrN/"),re("1eCo"),re("8EBN"))})(function(ie){"use strict";ie.defineMode("markdown",function(Y,D){var V=ie.getMode(Y,"text/html"),I=V.name=="null";function w(K){if(ie.findModeByName){var F=ie.findModeByName(K);F&&(K=F.mime||F.mimes[0])}var ee=ie.getMode(Y,K);return ee.name=="null"?null:ee}D.highlightFormatting===void 0&&(D.highlightFormatting=!1),D.maxBlockquoteDepth===void 0&&(D.maxBlockquoteDepth=0),D.taskLists===void 0&&(D.taskLists=!1),D.strikethrough===void 0&&(D.strikethrough=!1),D.emoji===void 0&&(D.emoji=!1),D.fencedCodeBlockHighlighting===void 0&&(D.fencedCodeBlockHighlighting=!0),D.fencedCodeBlockDefaultMode===void 0&&(D.fencedCodeBlockDefaultMode="text/plain"),D.xml===void 0&&(D.xml=!0),D.tokenTypeOverrides===void 0&&(D.tokenTypeOverrides={});var B={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 N in B)B.hasOwnProperty(N)&&D.tokenTypeOverrides[N]&&(B[N]=D.tokenTypeOverrides[N]);var M=/^([*\-_])(?:\s*\1){2,}\s*$/,k=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,p=/^\[(x| )\](?=\s)/i,y=D.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,P=/^ {0,3}(?:\={1,}|-{2,})\s*$/,L=/^[^#!\[\]*_\\<>` "'(~:]+/,x=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,S=/^\s*\[[^\]]+?\]:.*$/,d=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\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]/,a=" ";function l(K,F,ee){return F.f=F.inline=ee,ee(K,F)}function h(K,F,ee){return F.f=F.block=ee,ee(K,F)}function _(K){return!K||!/\S/.test(K.string)}function f(K){if(K.linkTitle=!1,K.linkHref=!1,K.linkText=!1,K.em=!1,K.strong=!1,K.strikethrough=!1,K.quote=0,K.indentedCode=!1,K.f==R){var F=I;if(!F){var ee=ie.innerMode(V,K.htmlState);F=ee.mode.name=="xml"&&ee.state.tagStart===null&&!ee.state.context&&ee.state.tokenize.isInText}F&&(K.f=u,K.block=b,K.htmlState=null)}return K.trailingSpace=0,K.trailingSpaceNewLine=!1,K.prevLine=K.thisLine,K.thisLine={stream:null},null}function b(K,F){var ee=K.column()===F.indentation,oe=_(F.prevLine.stream),he=F.indentedCode,ge=F.prevLine.hr,_e=F.list!==!1,be=(F.listStack[F.listStack.length-1]||0)+3;F.indentedCode=!1;var Ee=F.indentation;if(F.indentationDiff===null&&(F.indentationDiff=F.indentation,_e)){for(F.list=null;Ee<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=Ee-F.listStack[F.listStack.length-1])}var Te=!oe&&!ge&&!F.prevLine.header&&(!_e||!he)&&!F.prevLine.fencedCodeEnd,Ce=(F.list===!1||ge||oe)&&F.indentation<=be&&K.match(M),me=null;if(F.indentationDiff>=4&&(he||F.prevLine.fencedCodeEnd||F.prevLine.header||oe))return K.skipToEnd(),F.indentedCode=!0,B.code;if(K.eatSpace())return null;if(ee&&F.indentation<=be&&(me=K.match(y))&&me[1].length<=6)return F.quote=0,F.header=me[1].length,F.thisLine.header=!0,D.highlightFormatting&&(F.formatting="header"),F.f=F.inline,g(F);if(F.indentation<=be&&K.eat(">"))return F.quote=ee?1:F.quote+1,D.highlightFormatting&&(F.formatting="quote"),K.eatSpace(),g(F);if(!Ce&&!F.setext&&ee&&F.indentation<=be&&(me=K.match(k))){var se=me[1]?"ol":"ul";return F.indentation=Ee+K.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,D.taskLists&&K.match(p,!1)&&(F.taskList=!0),F.f=F.inline,D.highlightFormatting&&(F.formatting=["list","list-"+se]),g(F)}else{if(ee&&F.indentation<=be&&(me=K.match(x,!0)))return F.quote=0,F.fencedEndRE=new RegExp(me[1]+"+ *$"),F.localMode=D.fencedCodeBlockHighlighting&&w(me[2]||D.fencedCodeBlockDefaultMode),F.localMode&&(F.localState=ie.startState(F.localMode)),F.f=F.block=T,D.highlightFormatting&&(F.formatting="code-block"),F.code=-1,g(F);if(F.setext||(!Te||!_e)&&!F.quote&&F.list===!1&&!F.code&&!Ce&&!S.test(K.string)&&(me=K.lookAhead(1))&&(me=me.match(P)))return F.setext?(F.header=F.setext,F.setext=0,K.skipToEnd(),D.highlightFormatting&&(F.formatting="header")):(F.header=me[0].charAt(0)=="="?1:2,F.setext=F.header),F.thisLine.header=!0,F.f=F.inline,g(F);if(Ce)return K.skipToEnd(),F.hr=!0,F.thisLine.hr=!0,B.hr;if(K.peek()==="[")return l(K,F,O)}return l(K,F,F.inline)}function R(K,F){var ee=V.token(K,F.htmlState);if(!I){var oe=ie.innerMode(V,F.htmlState);(oe.mode.name=="xml"&&oe.state.tagStart===null&&!oe.state.context&&oe.state.tokenize.isInText||F.md_inside&&K.current().indexOf(">")>-1)&&(F.f=u,F.block=b,F.htmlState=null)}return ee}function T(K,F){var ee=F.listStack[F.listStack.length-1]||0,oe=F.indentation<ee,he=ee+3;if(F.fencedEndRE&&F.indentation<=he&&(oe||K.match(F.fencedEndRE))){D.highlightFormatting&&(F.formatting="code-block");var ge;return oe||(ge=g(F)),F.localMode=F.localState=null,F.block=b,F.f=u,F.fencedEndRE=null,F.code=0,F.thisLine.fencedCodeEnd=!0,oe?h(K,F,F.block):ge}else return F.localMode?F.localMode.token(K,F.localState):(K.skipToEnd(),B.code)}function g(K){var F=[];if(K.formatting){F.push(B.formatting),typeof K.formatting=="string"&&(K.formatting=[K.formatting]);for(var ee=0;ee<K.formatting.length;ee++)F.push(B.formatting+"-"+K.formatting[ee]),K.formatting[ee]==="header"&&F.push(B.formatting+"-"+K.formatting[ee]+"-"+K.header),K.formatting[ee]==="quote"&&(!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=K.quote?F.push(B.formatting+"-"+K.formatting[ee]+"-"+K.quote):F.push("error"))}if(K.taskOpen)return F.push("meta"),F.length?F.join(" "):null;if(K.taskClosed)return F.push("property"),F.length?F.join(" "):null;if(K.linkHref?F.push(B.linkHref,"url"):(K.strong&&F.push(B.strong),K.em&&F.push(B.em),K.strikethrough&&F.push(B.strikethrough),K.emoji&&F.push(B.emoji),K.linkText&&F.push(B.linkText),K.code&&F.push(B.code),K.image&&F.push(B.image),K.imageAltText&&F.push(B.imageAltText,"link"),K.imageMarker&&F.push(B.imageMarker)),K.header&&F.push(B.header,B.header+"-"+K.header),K.quote&&(F.push(B.quote),!D.maxBlockquoteDepth||D.maxBlockquoteDepth>=K.quote?F.push(B.quote+"-"+K.quote):F.push(B.quote+"-"+D.maxBlockquoteDepth)),K.list!==!1){var oe=(K.listStack.length-1)%3;oe?oe===1?F.push(B.list2):F.push(B.list3):F.push(B.list1)}return K.trailingSpaceNewLine?F.push("trailing-space-new-line"):K.trailingSpace&&F.push("trailing-space-"+(K.trailingSpace%2?"a":"b")),F.length?F.join(" "):null}function c(K,F){return K.match(L,!0)?g(F):void 0}function u(K,F){var ee=F.text(K,F);if(typeof ee!="undefined")return ee;if(F.list)return F.list=null,g(F);if(F.taskList){var oe=K.match(p,!0)[1]===" ";return oe?F.taskOpen=!0:F.taskClosed=!0,D.highlightFormatting&&(F.formatting="task"),F.taskList=!1,g(F)}if(F.taskOpen=!1,F.taskClosed=!1,F.header&&K.match(/^#+$/,!0))return D.highlightFormatting&&(F.formatting="header"),g(F);var he=K.next();if(F.linkTitle){F.linkTitle=!1;var ge=he;he==="("&&(ge=")"),ge=(ge+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var _e="^\\s*(?:[^"+ge+"\\\\]+|\\\\\\\\|\\\\.)"+ge;if(K.match(new RegExp(_e),!0))return B.linkHref}if(he==="`"){var be=F.formatting;D.highlightFormatting&&(F.formatting="code"),K.eatWhile("`");var Ee=K.current().length;if(F.code==0&&(!F.quote||Ee==1))return F.code=Ee,g(F);if(Ee==F.code){var Te=g(F);return F.code=0,Te}else return F.formatting=be,g(F)}else if(F.code)return g(F);if(he==="\\"&&(K.next(),D.highlightFormatting)){var Ce=g(F),me=B.formatting+"-escape";return Ce?Ce+" "+me:me}if(he==="!"&&K.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return F.imageMarker=!0,F.image=!0,D.highlightFormatting&&(F.formatting="image"),g(F);if(he==="["&&F.imageMarker&&K.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return F.imageMarker=!1,F.imageAltText=!0,D.highlightFormatting&&(F.formatting="image"),g(F);if(he==="]"&&F.imageAltText){D.highlightFormatting&&(F.formatting="image");var Ce=g(F);return F.imageAltText=!1,F.image=!1,F.inline=F.f=C,Ce}if(he==="["&&!F.image)return F.linkText&&K.match(/^.*?\]/)||(F.linkText=!0,D.highlightFormatting&&(F.formatting="link")),g(F);if(he==="]"&&F.linkText){D.highlightFormatting&&(F.formatting="link");var Ce=g(F);return F.linkText=!1,F.inline=F.f=K.match(/\(.*?\)| ?\[.*?\]/,!1)?C:u,Ce}if(he==="<"&&K.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){F.f=F.inline=o,D.highlightFormatting&&(F.formatting="link");var Ce=g(F);return Ce?Ce+=" ":Ce="",Ce+B.linkInline}if(he==="<"&&K.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){F.f=F.inline=o,D.highlightFormatting&&(F.formatting="link");var Ce=g(F);return Ce?Ce+=" ":Ce="",Ce+B.linkEmail}if(D.xml&&he==="<"&&K.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var se=K.string.indexOf(">",K.pos);if(se!=-1){var Re=K.string.substring(K.start,se);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(Re)&&(F.md_inside=!0)}return K.backUp(1),F.htmlState=ie.startState(V),h(K,F,R)}if(D.xml&&he==="<"&&K.match(/^\/\w*?>/))return F.md_inside=!1,"tag";if(he==="*"||he==="_"){for(var et=1,Ge=K.pos==1?" ":K.string.charAt(K.pos-2);et<3&&K.eat(he);)et++;var tt=K.peek()||" ",Ye=!/\s/.test(tt)&&(!d.test(tt)||/\s/.test(Ge)||d.test(Ge)),De=!/\s/.test(Ge)&&(!d.test(Ge)||/\s/.test(tt)||d.test(tt)),je=null,$e=null;if(et%2&&(!F.em&&Ye&&(he==="*"||!De||d.test(Ge))?je=!0:F.em==he&&De&&(he==="*"||!Ye||d.test(tt))&&(je=!1)),et>1&&(!F.strong&&Ye&&(he==="*"||!De||d.test(Ge))?$e=!0:F.strong==he&&De&&(he==="*"||!Ye||d.test(tt))&&($e=!1)),$e!=null||je!=null){D.highlightFormatting&&(F.formatting=je==null?"strong":$e==null?"em":"strong em"),je===!0&&(F.em=he),$e===!0&&(F.strong=he);var Te=g(F);return je===!1&&(F.em=!1),$e===!1&&(F.strong=!1),Te}}else if(he===" "&&(K.eat("*")||K.eat("_"))){if(K.peek()===" ")return g(F);K.backUp(1)}if(D.strikethrough){if(he==="~"&&K.eatWhile(he)){if(F.strikethrough){D.highlightFormatting&&(F.formatting="strikethrough");var Te=g(F);return F.strikethrough=!1,Te}else if(K.match(/^[^\s]/,!1))return F.strikethrough=!0,D.highlightFormatting&&(F.formatting="strikethrough"),g(F)}else if(he===" "&&K.match(/^~~/,!0)){if(K.peek()===" ")return g(F);K.backUp(2)}}if(D.emoji&&he===":"&&K.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){F.emoji=!0,D.highlightFormatting&&(F.formatting="emoji");var st=g(F);return F.emoji=!1,st}return he===" "&&(K.match(/^ +$/,!1)?F.trailingSpace++:F.trailingSpace&&(F.trailingSpaceNewLine=!0)),g(F)}function o(K,F){var ee=K.next();if(ee===">"){F.f=F.inline=u,D.highlightFormatting&&(F.formatting="link");var oe=g(F);return oe?oe+=" ":oe="",oe+B.linkInline}return K.match(/^[^>]+/,!0),B.linkInline}function C(K,F){if(K.eatSpace())return null;var ee=K.next();return ee==="("||ee==="["?(F.f=F.inline=v(ee==="("?")":"]"),D.highlightFormatting&&(F.formatting="link-string"),F.linkHref=!0,g(F)):"error"}var E={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function v(K){return function(F,ee){var oe=F.next();if(oe===K){ee.f=ee.inline=u,D.highlightFormatting&&(ee.formatting="link-string");var he=g(ee);return ee.linkHref=!1,he}return F.match(E[K]),ee.linkHref=!0,g(ee)}}function O(K,F){return K.match(/^([^\]\\]|\\.)*\]:/,!1)?(F.f=j,K.next(),D.highlightFormatting&&(F.formatting="link"),F.linkText=!0,g(F)):l(K,F,u)}function j(K,F){if(K.match(/^\]:/,!0)){F.f=F.inline=G,D.highlightFormatting&&(F.formatting="link");var ee=g(F);return F.linkText=!1,ee}return K.match(/^([^\]\\]|\\.)+/,!0),B.linkText}function G(K,F){return K.eatSpace()?null:(K.match(/^[^\s]+/,!0),K.peek()===void 0?F.linkTitle=!0:K.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),F.f=F.inline=u,B.linkHref+" url")}var J={startState:function(){return{f:b,prevLine:{stream:null},thisLine:{stream:null},block:b,htmlState:null,indentation:0,inline:u,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(K){return{f:K.f,prevLine:K.prevLine,thisLine:K.thisLine,block:K.block,htmlState:K.htmlState&&ie.copyState(V,K.htmlState),indentation:K.indentation,localMode:K.localMode,localState:K.localMode?ie.copyState(K.localMode,K.localState):null,inline:K.inline,text:K.text,formatting:!1,linkText:K.linkText,linkTitle:K.linkTitle,linkHref:K.linkHref,code:K.code,em:K.em,strong:K.strong,strikethrough:K.strikethrough,emoji:K.emoji,header:K.header,setext:K.setext,hr:K.hr,taskList:K.taskList,list:K.list,listStack:K.listStack.slice(0),quote:K.quote,indentedCode:K.indentedCode,trailingSpace:K.trailingSpace,trailingSpaceNewLine:K.trailingSpaceNewLine,md_inside:K.md_inside,fencedEndRE:K.fencedEndRE}},token:function(K,F){if(F.formatting=!1,K!=F.thisLine.stream){if(F.header=0,F.hr=!1,K.match(/^\s*$/,!0))return f(F),null;if(F.prevLine=F.thisLine,F.thisLine={stream:K},F.taskList=!1,F.trailingSpace=0,F.trailingSpaceNewLine=!1,!F.localState&&(F.f=F.block,F.f!=R)){var ee=K.match(/^\s*/,!0)[0].replace(/\t/g,a).length;if(F.indentation=ee,F.indentationDiff=null,ee>0)return null}}return F.f(K,F)},innerMode:function(K){return K.block==R?{state:K.htmlState,mode:V}:K.localState?{state:K.localState,mode:K.localMode}:{state:K,mode:J}},indent:function(K,F,ee){return K.block==R&&V.indent?V.indent(K.htmlState,F,ee):K.localState&&K.localMode.indent?K.localMode.indent(K.localState,F,ee):ie.Pass},blankLine:f,getType:g,blockCommentStart:"<!--",blockCommentEnd:"-->",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return J},"xml"),ie.defineMIME("text/markdown","markdown"),ie.defineMIME("text/x-markdown","markdown")})},nVVt:function(ht,ot){ht.exports={MODE_NUMBER:1<<0,MODE_ALPHA_NUM:1<<1,MODE_8BIT_BYTE:1<<2,MODE_KANJI:1<<3}},osHv:function(ht,ot,re){(function(ie){ie(re("VrN/"))})(function(ie){"use strict";var Y=ie.Pos;function D(d,a){return d.line-a.line||d.ch-a.ch}var V="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=V+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",w=new RegExp("<(/?)(["+V+"]["+I+"]*)","g");function B(d,a,l,h){this.line=a,this.ch=l,this.cm=d,this.text=d.getLine(a),this.min=h?Math.max(h.from,d.firstLine()):d.firstLine(),this.max=h?Math.min(h.to-1,d.lastLine()):d.lastLine()}function N(d,a){var l=d.cm.getTokenTypeAt(Y(d.line,a));return l&&/\btag\b/.test(l)}function M(d){return d.line>=d.max?void 0:(d.ch=0,d.text=d.cm.getLine(++d.line),!0)}function k(d){return d.line<=d.min?void 0:(d.text=d.cm.getLine(--d.line),d.ch=d.text.length,!0)}function p(d){for(;;){var a=d.text.indexOf(">",d.ch);if(a==-1){if(M(d))continue;return}if(!N(d,a+1)){d.ch=a+1;continue}var l=d.text.lastIndexOf("/",a),h=l>-1&&!/\S/.test(d.text.slice(l+1,a));return d.ch=a+1,h?"selfClose":"regular"}}function y(d){for(;;){var a=d.ch?d.text.lastIndexOf("<",d.ch-1):-1;if(a==-1){if(k(d))continue;return}if(!N(d,a+1)){d.ch=a;continue}w.lastIndex=a,d.ch=a;var l=w.exec(d.text);if(l&&l.index==a)return l}}function P(d){for(;;){w.lastIndex=d.ch;var a=w.exec(d.text);if(!a){if(M(d))continue;return}if(!N(d,a.index+1)){d.ch=a.index+1;continue}return d.ch=a.index+a[0].length,a}}function L(d){for(;;){var a=d.ch?d.text.lastIndexOf(">",d.ch-1):-1;if(a==-1){if(k(d))continue;return}if(!N(d,a+1)){d.ch=a;continue}var l=d.text.lastIndexOf("/",a),h=l>-1&&!/\S/.test(d.text.slice(l+1,a));return d.ch=a+1,h?"selfClose":"regular"}}function x(d,a){for(var l=[];;){var h=P(d),_,f=d.line,b=d.ch-(h?h[0].length:0);if(!h||!(_=p(d)))return;if(_=="selfClose")continue;if(h[1]){for(var R=l.length-1;R>=0;--R)if(l[R]==h[2]){l.length=R;break}if(R<0&&(!a||a==h[2]))return{tag:h[2],from:Y(f,b),to:Y(d.line,d.ch)}}else l.push(h[2])}}function S(d,a){for(var l=[];;){var h=L(d);if(!h)return;if(h=="selfClose"){y(d);continue}var _=d.line,f=d.ch,b=y(d);if(!b)return;if(b[1])l.push(b[2]);else{for(var R=l.length-1;R>=0;--R)if(l[R]==b[2]){l.length=R;break}if(R<0&&(!a||a==b[2]))return{tag:b[2],from:Y(d.line,d.ch),to:Y(_,f)}}}}ie.registerHelper("fold","xml",function(d,a){for(var l=new B(d,a.line,0);;){var h=P(l);if(!h||l.line!=a.line)return;var _=p(l);if(!_)return;if(!h[1]&&_!="selfClose"){var f=Y(l.line,l.ch),b=x(l,h[2]);return b&&D(b.from,f)>0?{from:f,to:b.from}:null}}}),ie.findMatchingTag=function(d,a,l){var h=new B(d,a.line,a.ch,l);if(h.text.indexOf(">")==-1&&h.text.indexOf("<")==-1)return;var _=p(h),f=_&&Y(h.line,h.ch),b=_&&y(h);if(!_||!b||D(h,a)>0)return;var R={from:Y(h.line,h.ch),to:f,tag:b[2]};return _=="selfClose"?{open:R,close:null,at:"open"}:b[1]?{open:S(h,b[2]),close:R,at:"close"}:(h=new B(d,f.line,f.ch,l),{open:R,close:x(h,b[2]),at:"open"})},ie.findEnclosingTag=function(d,a,l,h){for(var _=new B(d,a.line,a.ch,l);;){var f=S(_,h);if(!f)break;var b=new B(d,a.line,a.ch,l),R=x(b,f.tag);if(R)return{open:f,close:R}}},ie.scanForClosingTag=function(d,a,l,h){var _=new B(d,a.line,a.ch,h?{from:0,to:h}:null);return x(_,l)}})},p5ED:function(ht,ot,re){"use strict";var ie=re("+L6B"),Y=re("2/Rp"),D=re("5Dmo"),V=re("3S7+"),I=re("k1fw"),w=re("tJVT"),B=re("q1tI"),N=re.n(B),M=re("vHTk"),k=re.n(M),p=re("yEEn"),y=re("ZW9T"),P=re("1vsH");ot.a=function(L){var x=L.name,S=L.data,d=L.theme,a=L.type,l=L.filename,h=L.monacoEditor,_=L.className,f=L.style,b=L.close,R=L.onClose,T=L.hasMask,g=Object(B.useState)("https://view.officeapps.live.com/op/view.aspx?src=http://testgs.educoder.net//rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--03541f6234b93d7ac3b2d84e7eb0e6594a952945/1.ppt"),c=Object(w.a)(g,2),u=c[0],o=c[1],C=Object(B.useState)(""),E=Object(w.a)(C,2),v=E[0],O=E[1],j=Object(B.useRef)();l&&(h.filename=l),Object(B.useEffect)(function(){var K,F,ee=(K=document.cookie)===null||K===void 0||((F=K.replace(/\s/g,""))===null||F===void 0)?void 0:F.split(";");ee==null||ee.map(function(oe){var he=oe.split("=");he[0]==="_educoder_session"&&O(he[1])})},[]);var G=function(){if(S.startsWith("http")||S.startsWith("/")){J();return}Object(P.x)(l||"educoder",S,l)},J=function(){Object(P.v)(l||x,S)};return console.log("data:",S,"fileanme:",l," name:",x),N.a.createElement("div",{style:Object(I.a)({},f||{}),className:"".concat(T&&k.a.bgBlack," ").concat(a?k.a.wrp:"hide")},b&&N.a.createElement("div",{className:k.a.close,ref:j},N.a.createElement(V.a,{title:"\u70B9\u51FB\u4E0B\u8F7D\u6B64\u6587\u4EF6",getPopupContainer:function(){return j.current}},N.a.createElement("span",{onClick:J},N.a.createElement("i",{className:"icon-quxiaozhiding"}))),N.a.createElement(V.a,{title:"\u5173\u95ED",getPopupContainer:function(){return j.current}},N.a.createElement("span",{className:"",onClick:R},N.a.createElement("i",{className:"icon-guanbi1"})))),N.a.createElement("div",{className:"".concat(k.a[_]," ").concat(_," ").concat(k.a.monaco," ").concat(a==="txt"?"show":"hide")},a==="txt"&&N.a.createElement(y.b,h)),a==="audio"&&N.a.createElement("audio",{src:"".concat(S!=null&&S.startsWith("/")||(S==null?void 0:S.indexOf("https://"))>-1?S:"data:audio/mp3;base64,").concat(S),autoPlay:!0}),a==="video"&&N.a.createElement(N.a.Fragment,null,S!=null&&S.startsWith("/")?N.a.createElement("video",{controls:!0,src:"".concat(S),autoPlay:!0}):N.a.createElement("video",{controls:!0,src:"data:video/mp4;base64,".concat(S),autoPlay:!0})),a==="html"&&N.a.createElement("iframe",{src:S+"&disposition=inline"}),a==="pdf"&&N.a.createElement("embed",{className:k.a.embed,src:S}),a==="image"&&N.a.createElement(N.a.Fragment,null,N.a.createElement("img",{src:"".concat(S!=null&&S.startsWith("/")||(S==null?void 0:S.indexOf("https://"))>-1?"":"data:image/png;base64,").concat(S)})),a==="other"&&N.a.createElement("div",null,N.a.createElement(Y.a,{type:"primary",size:"large",onClick:G},N.a.createElement(p.a,null),"\u70B9\u51FB\u4E0B\u8F7D")),(a==="download"||a==="office")&&N.a.createElement(Y.a,{type:"primary",size:"large",onClick:G},N.a.createElement(p.a,null),"\u70B9\u51FB\u4E0B\u8F7D"))}},"p77/":function(ht,ot,re){},"rAM+":function(ht,ot,re){"use strict";re.d(ot,"a",function(){return Y});var ie=re("Qw5x");function Y(D,V){var I;if(typeof Symbol=="undefined"||D[Symbol.iterator]==null){if(Array.isArray(D)||(I=Object(ie.a)(D))||V&&D&&typeof D.length=="number"){I&&(D=I);var w=0,B=function(){};return{s:B,n:function(){return w>=D.length?{done:!0}:{done:!1,value:D[w++]}},e:function(y){throw y},f:B}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var N=!0,M=!1,k;return{s:function(){I=D[Symbol.iterator]()},n:function(){var y=I.next();return N=y.done,y},e:function(y){M=!0,k=y},f:function(){try{!N&&I.return!=null&&I.return()}finally{if(M)throw k}}}}},rUJ1:function(ht,ot){const re=/[&<>"']/,ie=/[&<>"']/g,Y=/[<>"']|&(?!#?\w+;)/,D=/[<>"']|&(?!#?\w+;)/g,V={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},I=T=>V[T];function w(T,g){if(g){if(re.test(T))return T.replace(ie,I)}else if(Y.test(T))return T.replace(D,I);return T}const B=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function N(T){return T.replace(B,(g,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 M=/(^|[^\[])\^/g;function k(T,g){T=T.source||T,g=g||"";const c={replace:(u,o)=>(o=o.source||o,o=o.replace(M,"$1"),T=T.replace(u,o),c),getRegex:()=>new RegExp(T,g)};return c}const p=/[^\w:]/g,y=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function P(T,g,c){if(T){let u;try{u=decodeURIComponent(N(c)).replace(p,"").toLowerCase()}catch(o){return null}if(u.indexOf("javascript:")===0||u.indexOf("vbscript:")===0||u.indexOf("data:")===0)return null}g&&!y.test(c)&&(c=a(g,c));try{c=encodeURI(c).replace(/%25/g,"%")}catch(u){return null}return c}const L={},x=/^[^:]+:\/*[^/]*$/,S=/^([^:]+:)[\s\S]*$/,d=/^([^:]+:\/*[^/]*)[\s\S]*$/;function a(T,g){L[" "+T]||(x.test(T)?L[" "+T]=T+"/":L[" "+T]=f(T,"/",!0)),T=L[" "+T];const c=T.indexOf(":")===-1;return g.substring(0,2)==="//"?c?g:T.replace(S,"$1")+g:g.charAt(0)==="/"?c?g:T.replace(d,"$1")+g:T+g}const l={exec:function(){}};function h(T){let g=1,c,u;for(;g<arguments.length;g++){c=arguments[g];for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(T[u]=c[u])}return T}function _(T,g){const c=T.replace(/\|/g,(C,E,v)=>{let O=!1,j=E;for(;--j>=0&&v[j]==="\\";)O=!O;return O?"|":" |"}),u=c.split(/ \|/);let o=0;if(u.length>g)u.splice(g);else for(;u.length<g;)u.push("");for(;o<u.length;o++)u[o]=u[o].trim().replace(/\\\|/g,"|");return u}function f(T,g,c){const u=T.length;if(u===0)return"";let o=0;for(;o<u;){const C=T.charAt(u-o-1);if(C===g&&!c)o++;else if(C!==g&&c)o++;else break}return T.substr(0,u-o)}function b(T,g){if(T.indexOf(g[1])===-1)return-1;const c=T.length;let u=0,o=0;for(;o<c;o++)if(T[o]==="\\")o++;else if(T[o]===g[0])u++;else if(T[o]===g[1]&&(u--,u<0))return o;return-1}function R(T){T&&T.sanitize&&!T.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")}ht.exports={escape:w,unescape:N,edit:k,cleanUrl:P,resolveUrl:a,noopTest:l,merge:h,splitCells:_,rtrim:f,findClosingBracket:b,checkSanitizeDeprecation:R}},rcnY:function(ht,ot,re){var ie=re("aRTE");function Y(D,V){this.totalCount=D,this.dataCount=V}Y.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],Y.getRSBlocks=function(D,V){var I=Y.getRsBlockTable(D,V);if(I==null)throw new Error("bad rs block @ typeNumber:"+D+"/errorCorrectLevel:"+V);for(var w=I.length/3,B=new Array,N=0;N<w;N++)for(var M=I[N*3+0],k=I[N*3+1],p=I[N*3+2],y=0;y<M;y++)B.push(new Y(k,p));return B},Y.getRsBlockTable=function(D,V){switch(V){case ie.L:return Y.RS_BLOCK_TABLE[(D-1)*4+0];case ie.M:return Y.RS_BLOCK_TABLE[(D-1)*4+1];case ie.Q:return Y.RS_BLOCK_TABLE[(D-1)*4+2];case ie.H:return Y.RS_BLOCK_TABLE[(D-1)*4+3];default:return}},ht.exports=Y},smFo:function(ht,ot,re){ht.exports={wrap:"wrap___1xSvp",header:"header___1niV1",title:"title____shwY",menu:"menu___2Y-rd",top:"top___1_d5Y",line:"line___1kciD",flexCenter:"flexCenter___3bP7s",like:"like___3lXjz",canLike:"canLike___AuDmL",attachmentName:"attachmentName___2SteY"}},ulZh:function(ht,ot,re){typeof window!="undefined"&&function(Y,D){ht.exports=D()}(this,function(){return function(ie){var Y={};function D(V){if(Y[V])return Y[V].exports;var I=Y[V]={i:V,l:!1,exports:{}};return ie[V].call(I.exports,I,I.exports,D),I.l=!0,I.exports}return D.m=ie,D.c=Y,D.d=function(V,I,w){D.o(V,I)||Object.defineProperty(V,I,{enumerable:!0,get:w})},D.r=function(V){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(V,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(V,"__esModule",{value:!0})},D.t=function(V,I){if(I&1&&(V=D(V)),I&8)return V;if(I&4&&typeof V=="object"&&V&&V.__esModule)return V;var w=Object.create(null);if(D.r(w),Object.defineProperty(w,"default",{enumerable:!0,value:V}),I&2&&typeof V!="string")for(var B in V)D.d(w,B,function(N){return V[N]}.bind(null,B));return w},D.n=function(V){var I=V&&V.__esModule?function(){return V.default}:function(){return V};return D.d(I,"a",I),I},D.o=function(V,I){return Object.prototype.hasOwnProperty.call(V,I)},D.p="/dist/",D(D.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(ie,Y,D){"use strict";var V=Object.prototype.hasOwnProperty,I="~";function w(){}Object.create&&(w.prototype=Object.create(null),new w().__proto__||(I=!1));function B(p,y,P){this.fn=p,this.context=y,this.once=P||!1}function N(p,y,P,L,x){if(typeof P!="function")throw new TypeError("The listener must be a function");var S=new B(P,L||p,x),d=I?I+y:y;return p._events[d]?p._events[d].fn?p._events[d]=[p._events[d],S]:p._events[d].push(S):(p._events[d]=S,p._eventsCount++),p}function M(p,y){--p._eventsCount===0?p._events=new w:delete p._events[y]}function k(){this._events=new w,this._eventsCount=0}k.prototype.eventNames=function(){var y=[],P,L;if(this._eventsCount===0)return y;for(L in P=this._events)V.call(P,L)&&y.push(I?L.slice(1):L);return Object.getOwnPropertySymbols?y.concat(Object.getOwnPropertySymbols(P)):y},k.prototype.listeners=function(y){var P=I?I+y:y,L=this._events[P];if(!L)return[];if(L.fn)return[L.fn];for(var x=0,S=L.length,d=new Array(S);x<S;x++)d[x]=L[x].fn;return d},k.prototype.listenerCount=function(y){var P=I?I+y:y,L=this._events[P];return L?L.fn?1:L.length:0},k.prototype.emit=function(y,P,L,x,S,d){var a=I?I+y:y;if(!this._events[a])return!1;var l=this._events[a],h=arguments.length,_,f;if(l.fn){l.once&&this.removeListener(y,l.fn,void 0,!0);switch(h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,P),!0;case 3:return l.fn.call(l.context,P,L),!0;case 4:return l.fn.call(l.context,P,L,x),!0;case 5:return l.fn.call(l.context,P,L,x,S),!0;case 6:return l.fn.call(l.context,P,L,x,S,d),!0}for(f=1,_=new Array(h-1);f<h;f++)_[f-1]=arguments[f];l.fn.apply(l.context,_)}else{var b=l.length,R;for(f=0;f<b;f++){l[f].once&&this.removeListener(y,l[f].fn,void 0,!0);switch(h){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,P);break;case 3:l[f].fn.call(l[f].context,P,L);break;case 4:l[f].fn.call(l[f].context,P,L,x);break;default:if(!_)for(R=1,_=new Array(h-1);R<h;R++)_[R-1]=arguments[R];l[f].fn.apply(l[f].context,_)}}}return!0},k.prototype.on=function(y,P,L){return N(this,y,P,L,!1)},k.prototype.once=function(y,P,L){return N(this,y,P,L,!0)},k.prototype.removeListener=function(y,P,L,x){var S=I?I+y:y;if(!this._events[S])return this;if(!P)return M(this,S),this;var d=this._events[S];if(d.fn)d.fn===P&&(!x||d.once)&&(!L||d.context===L)&&M(this,S);else{for(var a=0,l=[],h=d.length;a<h;a++)(d[a].fn!==P||x&&!d[a].once||L&&d[a].context!==L)&&l.push(d[a]);l.length?this._events[S]=l.length===1?l[0]:l:M(this,S)}return this},k.prototype.removeAllListeners=function(y){var P;return y?(P=I?I+y:y,this._events[P]&&M(this,P)):(this._events=new w,this._eventsCount=0),this},k.prototype.off=k.prototype.removeListener,k.prototype.addListener=k.prototype.on,k.prefixed=I,k.EventEmitter=k,ie.exports=k},"./node_modules/url-toolkit/src/url-toolkit.js":function(ie,Y,D){(function(V){var I=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,w=/^([^\/?#]*)([^]*)$/,B=/(?:\/|^)\.(?=\/)/g,N=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,M={buildAbsoluteURL:function(k,p,y){if(y=y||{},k=k.trim(),p=p.trim(),!p){if(!y.alwaysNormalize)return k;var P=M.parseURL(k);if(!P)throw new Error("Error trying to parse base URL.");return P.path=M.normalizePath(P.path),M.buildURLFromParts(P)}var L=M.parseURL(p);if(!L)throw new Error("Error trying to parse relative URL.");if(L.scheme)return y.alwaysNormalize?(L.path=M.normalizePath(L.path),M.buildURLFromParts(L)):p;var x=M.parseURL(k);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var S=w.exec(x.path);x.netLoc=S[1],x.path=S[2]}x.netLoc&&!x.path&&(x.path="/");var d={scheme:x.scheme,netLoc:L.netLoc,path:null,params:L.params,query:L.query,fragment:L.fragment};if(!L.netLoc&&(d.netLoc=x.netLoc,L.path[0]!=="/"))if(!L.path)d.path=x.path,L.params||(d.params=x.params,L.query||(d.query=x.query));else{var a=x.path,l=a.substring(0,a.lastIndexOf("/")+1)+L.path;d.path=M.normalizePath(l)}return d.path===null&&(d.path=y.alwaysNormalize?M.normalizePath(L.path):L.path),M.buildURLFromParts(d)},parseURL:function(k){var p=I.exec(k);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(k){for(k=k.split("").reverse().join("").replace(B,"");k.length!==(k=k.replace(N,"")).length;);return k.split("").reverse().join("")},buildURLFromParts:function(k){return k.scheme+k.netLoc+k.path+k.params+k.query+k.fragment}};ie.exports=M})(this)},"./node_modules/webworkify-webpack/index.js":function(ie,Y,D){function V(y){var P={};function L(S){if(P[S])return P[S].exports;var d=P[S]={i:S,l:!1,exports:{}};return y[S].call(d.exports,d,d.exports,L),d.l=!0,d.exports}L.m=y,L.c=P,L.i=function(S){return S},L.d=function(S,d,a){L.o(S,d)||Object.defineProperty(S,d,{configurable:!1,enumerable:!0,get:a})},L.r=function(S){Object.defineProperty(S,"__esModule",{value:!0})},L.n=function(S){var d=S&&S.__esModule?function(){return S.default}:function(){return S};return L.d(d,"a",d),d},L.o=function(S,d){return Object.prototype.hasOwnProperty.call(S,d)},L.p="/",L.oe=function(S){throw console.error(S),S};var x=L(L.s=ENTRY_MODULE);return x.default||x}var I="[\\.|\\-|\\+|\\w|/|@]+",w="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+I+").*?\\)";function B(y){return(y+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function N(y){return!isNaN(1*y)}function M(y,P,L){var x={};x[L]=[];var S=P.toString(),d=S.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return x;for(var a=d[1],l=new RegExp("(\\\\n|\\W)"+B(a)+w,"g"),h;h=l.exec(S);){if(h[3]==="dll-reference")continue;x[L].push(h[3])}for(l=new RegExp("\\("+B(a)+'\\("(dll-reference\\s('+I+'))"\\)\\)'+w,"g");h=l.exec(S);)y[h[2]]||(x[L].push(h[1]),y[h[2]]=D(h[1]).m),x[h[2]]=x[h[2]]||[],x[h[2]].push(h[4]);for(var _=Object.keys(x),f=0;f<_.length;f++)for(var b=0;b<x[_[f]].length;b++)N(x[_[f]][b])&&(x[_[f]][b]=1*x[_[f]][b]);return x}function k(y){var P=Object.keys(y);return P.reduce(function(L,x){return L||y[x].length>0},!1)}function p(y,P){for(var L={main:[P]},x={main:[]},S={main:{}};k(L);)for(var d=Object.keys(L),a=0;a<d.length;a++){var l=d[a],h=L[l],_=h.pop();if(S[l]=S[l]||{},S[l][_]||!y[l][_])continue;S[l][_]=!0,x[l]=x[l]||[],x[l].push(_);for(var f=M(y,y[l][_],l),b=Object.keys(f),R=0;R<b.length;R++)L[b[R]]=L[b[R]]||[],L[b[R]]=L[b[R]].concat(f[b[R]])}return x}ie.exports=function(y,P){P=P||{};var L={main:D.m},x=P.all?{main:Object.keys(L.main)}:p(L,y),S="";Object.keys(x).filter(function(_){return _!=="main"}).forEach(function(_){for(var f=0;x[_][f];)f++;x[_].push(f),L[_][f]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",S=S+"var "+_+" = ("+V.toString().replace("ENTRY_MODULE",JSON.stringify(f))+")({"+x[_].map(function(b){return""+JSON.stringify(b)+": "+L[_][b].toString()}).join(",")+`});
`}),S=S+"new (("+V.toString().replace("ENTRY_MODULE",JSON.stringify(y))+")({"+x.main.map(function(_){return""+JSON.stringify(_)+": "+L.main[_].toString()}).join(",")+"}))(self);";var d=new window.Blob([S],{type:"text/javascript"});if(P.bare)return d;var a=window.URL||window.webkitURL||window.mozURL||window.msURL,l=a.createObjectURL(d),h=new window.Worker(l);return h.objectURL=l,h}},"./src/config.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"hlsDefaultConfig",function(){return R}),D.d(Y,"mergeConfig",function(){return g}),D.d(Y,"enableStreamingMode",function(){return c});var V=D("./src/controller/abr-controller.ts"),I=D("./src/controller/audio-stream-controller.ts"),w=D("./src/controller/audio-track-controller.ts"),B=D("./src/controller/subtitle-stream-controller.ts"),N=D("./src/controller/subtitle-track-controller.ts"),M=D("./src/controller/buffer-controller.ts"),k=D("./src/controller/timeline-controller.ts"),p=D("./src/controller/cap-level-controller.ts"),y=D("./src/controller/fps-controller.ts"),P=D("./src/controller/eme-controller.ts"),L=D("./src/controller/cmcd-controller.ts"),x=D("./src/utils/xhr-loader.ts"),S=D("./src/utils/fetch-loader.ts"),d=D("./src/utils/cues.ts"),a=D("./src/utils/mediakeys-helper.ts"),l=D("./src/utils/logger.ts");function h(){return h=Object.assign||function(u){for(var o=1;o<arguments.length;o++){var C=arguments[o];for(var E in C)Object.prototype.hasOwnProperty.call(C,E)&&(u[E]=C[E])}return u},h.apply(this,arguments)}function _(u,o){var C=Object.keys(u);if(Object.getOwnPropertySymbols){var E=Object.getOwnPropertySymbols(u);o&&(E=E.filter(function(v){return Object.getOwnPropertyDescriptor(u,v).enumerable})),C.push.apply(C,E)}return C}function f(u){for(var o=1;o<arguments.length;o++){var C=arguments[o]!=null?arguments[o]:{};o%2?_(Object(C),!0).forEach(function(E){b(u,E,C[E])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(C)):_(Object(C)).forEach(function(E){Object.defineProperty(u,E,Object.getOwnPropertyDescriptor(C,E))})}return u}function b(u,o,C){return o in u?Object.defineProperty(u,o,{value:C,enumerable:!0,configurable:!0,writable:!0}):u[o]=C,u}var R=f(f({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:x.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:V.default,bufferController:M.default,capLevelController:p.default,fpsController:y.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:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},T()),{},{subtitleStreamController:B.SubtitleStreamController,subtitleTrackController:N.default,timelineController:k.TimelineController,audioStreamController:I.default,audioTrackController:w.default,emeController:P.default,cmcdController:L.default});function T(){return{cueHandler:d.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 g(u,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return h({},u,o)}function c(u){var o=u.loader;if(o!==S.default&&o!==x.default)l.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),u.progressive=!1;else{var C=Object(S.fetchSupported)();C&&(u.loader=S.default,u.progressive=!0,u.enableSoftwareAES=!0,l.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/polyfills/number.ts"),I=D("./src/utils/ewma-bandwidth-estimator.ts"),w=D("./src/events.ts"),B=D("./src/utils/buffer-helper.ts"),N=D("./src/errors.ts"),M=D("./src/types/loader.ts"),k=D("./src/utils/logger.ts");function p(L,x){for(var S=0;S<x.length;S++){var d=x[S];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(L,d.key,d)}}function y(L,x,S){return x&&p(L.prototype,x),S&&p(L,S),L}var P=function(){function L(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 d=S.config;this.bwEstimator=new I.default(d.abrEwmaSlowVoD,d.abrEwmaFastVoD,d.abrEwmaDefaultEstimate),this.registerListeners()}var x=L.prototype;return x.registerListeners=function(){var d=this.hls;d.on(w.Events.FRAG_LOADING,this.onFragLoading,this),d.on(w.Events.FRAG_LOADED,this.onFragLoaded,this),d.on(w.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.on(w.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(w.Events.ERROR,this.onError,this)},x.unregisterListeners=function(){var d=this.hls;d.off(w.Events.FRAG_LOADING,this.onFragLoading,this),d.off(w.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(w.Events.FRAG_BUFFERED,this.onFragBuffered,this),d.off(w.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(w.Events.ERROR,this.onError,this)},x.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},x.onFragLoading=function(d,a){var l=a.frag;if(l.type===M.PlaylistLevelType.MAIN&&!this.timer){var h;this.fragCurrent=l,this.partCurrent=(h=a.part)!=null?h:null,this.timer=self.setInterval(this.onCheck,100)}},x.onLevelLoaded=function(d,a){var l=this.hls.config;a.details.live?this.bwEstimator.update(l.abrEwmaSlowLive,l.abrEwmaFastLive):this.bwEstimator.update(l.abrEwmaSlowVoD,l.abrEwmaFastVoD)},x._abandonRulesCheck=function(){var d=this.fragCurrent,a=this.partCurrent,l=this.hls,h=l.autoLevelEnabled,_=l.config,f=l.media;if(!d||!f)return;var b=a?a.stats:d.stats,R=a?a.duration:d.duration;if(b.aborted){k.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!h||f.paused||!f.playbackRate||!f.readyState)return;var T=performance.now()-b.loading.start,g=Math.abs(f.playbackRate);if(T<=500*R/g)return;var c=l.levels,u=l.minAutoLevel,o=c[d.level],C=b.total||Math.max(b.loaded,Math.round(R*o.maxBitrate/8)),E=Math.max(1,b.bwEstimate?b.bwEstimate/8:b.loaded*1e3/T),v=(C-b.loaded)/E,O=f.currentTime,j=(B.BufferHelper.bufferInfo(f,O,_.maxBufferHole).end-O)/g;if(j>=2*R/g||v<=j)return;var G=Number.POSITIVE_INFINITY,J;for(J=d.level-1;J>u;J--){var K=c[J].maxBitrate;if(G=R*K/(8*.8*E),G<j)break}if(G>=v)return;var F=this.bwEstimator.getEstimate();k.logger.warn("Fragment "+d.sn+(a?" part "+a.index:"")+" of level "+d.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+J+`
Current BW estimate: `+(Object(V.isFiniteNumber)(F)?(F/1024).toFixed(3):"Unknown")+` Kb/s
Estimated load time for current fragment: `+v.toFixed(3)+` s
Estimated load time for the next fragment: `+G.toFixed(3)+` s
Time to underbuffer: `+j.toFixed(3)+" s"),l.nextLoadLevel=J,this.bwEstimator.sample(T,b.loaded),this.clearTimer(),d.loader&&(this.fragCurrent=this.partCurrent=null,d.loader.abort()),l.trigger(w.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:d,part:a,stats:b})},x.onFragLoaded=function(d,a){var l=a.frag,h=a.part;if(l.type===M.PlaylistLevelType.MAIN&&Object(V.isFiniteNumber)(l.sn)){var _=h?h.stats:l.stats,f=h?h.duration:l.duration;if(this.clearTimer(),this.lastLoadedFragLevel=l.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var b=this.hls.levels[l.level],R=(b.loaded?b.loaded.bytes:0)+_.loaded,T=(b.loaded?b.loaded.duration:0)+f;b.loaded={bytes:R,duration:T},b.realBitrate=Math.round(8*R/T)}if(l.bitrateTest){var g={stats:_,frag:l,part:h,id:l.type};this.onFragBuffered(w.Events.FRAG_BUFFERED,g),l.bitrateTest=!1}}},x.onFragBuffered=function(d,a){var l=a.frag,h=a.part,_=h?h.stats:l.stats;if(_.aborted)return;if(l.type!==M.PlaylistLevelType.MAIN||l.sn==="initSegment")return;var f=_.parsing.end-_.loading.start;this.bwEstimator.sample(f,_.loaded),_.bwEstimate=this.bwEstimator.getEstimate(),l.bitrateTest?this.bitrateTestDelay=f/1e3:this.bitrateTestDelay=0},x.onError=function(d,a){switch(a.details){case N.ErrorDetails.FRAG_LOAD_ERROR:case N.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},x.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},x.getNextABRAutoLevel=function(){var d=this.fragCurrent,a=this.partCurrent,l=this.hls,h=l.maxAutoLevel,_=l.config,f=l.minAutoLevel,b=l.media,R=a?a.duration:d?d.duration:0,T=b?b.currentTime:0,g=b&&b.playbackRate!==0?Math.abs(b.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():_.abrEwmaDefaultEstimate,u=(B.BufferHelper.bufferInfo(b,T,_.maxBufferHole).end-T)/g,o=this.findBestLevel(c,f,h,u,_.abrBandWidthFactor,_.abrBandWidthUpFactor);if(o>=0)return o;k.logger.trace((u?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var C=R?Math.min(R,_.maxStarvationDelay):_.maxStarvationDelay,E=_.abrBandWidthFactor,v=_.abrBandWidthUpFactor;if(!u){var O=this.bitrateTestDelay;if(O){var j=R?Math.min(R,_.maxLoadingDelay):_.maxLoadingDelay;C=j-O,k.logger.trace("bitrate test took "+Math.round(1e3*O)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*C)+" ms"),E=v=1}}return o=this.findBestLevel(c,f,h,u+C,E,v),Math.max(o,0)},x.findBestLevel=function(d,a,l,h,_,f){for(var b,R=this.fragCurrent,T=this.partCurrent,g=this.lastLoadedFragLevel,c=this.hls.levels,u=c[g],o=!!(u!=null&&(b=u.details)!==null&&b!==void 0&&b.live),C=u==null?void 0:u.codecSet,E=T?T.duration:R?R.duration:0,v=l;v>=a;v--){var O=c[v];if(!O||C&&O.codecSet!==C)continue;var j=O.details,G=(T?j==null?void 0:j.partTarget:j==null?void 0:j.averagetargetduration)||E,J=void 0;v<=g?J=_*d:J=f*d;var K=c[v].maxBitrate,F=K*G/J;if(k.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+v+"/"+Math.round(J)+"/"+K+"/"+G+"/"+h+"/"+F),J>K&&(!F||o&&!this.bitrateTestDelay||F<h))return v}return-1},y(L,[{key:"nextAutoLevel",get:function(){var d=this._nextAutoLevel,a=this.bwEstimator;if(d!==-1&&(!a||!a.canEstimate()))return d;var l=this.getNextABRAutoLevel();return d!==-1&&(l=Math.min(d,l)),l},set:function(d){this._nextAutoLevel=d}}]),L}();Y.default=P},"./src/controller/audio-stream-controller.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/polyfills/number.ts"),I=D("./src/controller/base-stream-controller.ts"),w=D("./src/events.ts"),B=D("./src/utils/buffer-helper.ts"),N=D("./src/controller/fragment-tracker.ts"),M=D("./src/types/level.ts"),k=D("./src/types/loader.ts"),p=D("./src/loader/fragment.ts"),y=D("./src/demux/chunk-cache.ts"),P=D("./src/demux/transmuxer-interface.ts"),L=D("./src/types/transmuxer.ts"),x=D("./src/controller/fragment-finders.ts"),S=D("./src/utils/discontinuities.ts"),d=D("./src/errors.ts"),a=D("./src/utils/logger.ts");function l(){return l=Object.assign||function(R){for(var T=1;T<arguments.length;T++){var g=arguments[T];for(var c in g)Object.prototype.hasOwnProperty.call(g,c)&&(R[c]=g[c])}return R},l.apply(this,arguments)}function h(R,T){R.prototype=Object.create(T.prototype),R.prototype.constructor=R,_(R,T)}function _(R,T){return _=Object.setPrototypeOf||function(c,u){return c.__proto__=u,c},_(R,T)}var f=100,b=function(R){h(T,R);function T(c,u){var o;return o=R.call(this,c,u,"[audio-stream-controller]")||this,o.videoBuffer=null,o.videoTrackCC=-1,o.waitingVideoCC=-1,o.audioSwitch=!1,o.trackId=-1,o.waitingData=null,o.mainDetails=null,o.bufferFlushed=!1,o._registerListeners(),o}var g=T.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var u=this.hls;u.on(w.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(w.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(w.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(w.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(w.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),u.on(w.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.on(w.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.on(w.Events.ERROR,this.onError,this),u.on(w.Events.BUFFER_RESET,this.onBufferReset,this),u.on(w.Events.BUFFER_CREATED,this.onBufferCreated,this),u.on(w.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.on(w.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.on(w.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g._unregisterListeners=function(){var u=this.hls;u.off(w.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(w.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(w.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(w.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(w.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),u.off(w.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.off(w.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),u.off(w.Events.ERROR,this.onError,this),u.off(w.Events.BUFFER_RESET,this.onBufferReset,this),u.off(w.Events.BUFFER_CREATED,this.onBufferCreated,this),u.off(w.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.off(w.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),u.off(w.Events.FRAG_BUFFERED,this.onFragBuffered,this)},g.onInitPtsFound=function(u,o){var C=o.frag,E=o.id,v=o.initPTS;if(E==="main"){var O=C.cc;this.initPTS[C.cc]=v,this.log("InitPTS for cc: "+O+" found from main: "+v),this.videoTrackCC=O,this.state===I.State.WAITING_INIT_PTS&&this.tick()}},g.startLoad=function(u){if(!this.levels){this.startPosition=u,this.state=I.State.STOPPED;return}var o=this.lastCurrentTime;this.stopLoad(),this.setInterval(f),this.fragLoadError=0,o>0&&u===-1?(this.log("Override startPosition with lastCurrentTime @"+o.toFixed(3)),this.state=I.State.IDLE):(this.loadedmetadata=!1,this.state=I.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=u,this.tick()},g.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_TRACK:{var u,o=this.levels,C=this.trackId,E=o==null||((u=o[C])===null||u===void 0)?void 0:u.details;if(E){if(this.waitForCdnTuneIn(E))break;this.state=I.State.WAITING_INIT_PTS}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var v,O=performance.now(),j=this.retryDate;(!j||O>=j||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=I.State.IDLE);break}case I.State.WAITING_INIT_PTS:{var G=this.waitingData;if(G){var J=G.frag,K=G.part,F=G.cache,ee=G.complete;if(this.initPTS[J.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.FRAG_LOADING;var oe=F.flush(),he={frag:J,part:K,payload:oe,networkDetails:null};this._handleFragmentLoadProgress(he),ee&&R.prototype._handleFragmentLoadComplete.call(this,he)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+J.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var ge=this.getLoadPosition(),_e=B.BufferHelper.bufferInfo(this.mediaBuffer,ge,this.config.maxBufferHole),be=Object(x.fragmentWithinToleranceTest)(_e.end,this.config.maxFragLookUpTolerance,J);be<0&&(a.logger.log("Waiting fragment cc ("+J.cc+") @ "+J.start+" cancelled because another fragment at "+_e.end+" is needed"),this.clearWaitingFragment())}}else this.state=I.State.IDLE}}this.onTickEnd()},g.clearWaitingFragment=function(){var u=this.waitingData;u&&(this.fragmentTracker.removeFragment(u.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=I.State.IDLE)},g.onTickEnd=function(){var u=this.media;if(!u||!u.readyState)return;var o=this.mediaBuffer?this.mediaBuffer:u,C=o.buffered;!this.loadedmetadata&&C.length&&(this.loadedmetadata=!0),this.lastCurrentTime=u.currentTime},g.doTickIdle=function(){var u,o,C=this.hls,E=this.levels,v=this.media,O=this.trackId,j=C.config;if(!E||!E[O])return;if(!v&&(this.startFragRequested||!j.startFragPrefetch))return;var G=E[O],J=G.details;if(!J||J.live&&this.levelLastLoaded!==O||this.waitForCdnTuneIn(J)){this.state=I.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,p.ElementaryStreamTypes.AUDIO,k.PlaylistLevelType.AUDIO));var K=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,k.PlaylistLevelType.AUDIO);if(K===null)return;var F=K.len,ee=this.getMaxBufferLength(),oe=this.audioSwitch;if(F>=ee&&!oe)return;if(!oe&&this._streamEnded(K,J)){C.trigger(w.Events.BUFFER_EOS,{type:"audio"}),this.state=I.State.ENDED;return}var he=J.fragments,ge=he[0].start,_e=K.end;if(oe){var be=this.getLoadPosition();_e=be,J.PTSKnown&&be<ge&&((K.end>ge||K.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),v.currentTime=ge+.05))}var Ee=this.getNextFragment(_e,J);if(!Ee){this.bufferFlushed=!0;return}((u=Ee.decryptdata)===null||u===void 0?void 0:u.keyFormat)==="identity"&&!((o=Ee.decryptdata)!==null&&o!==void 0&&o.key)?this.loadKey(Ee,J):this.loadFragment(Ee,J,_e)},g.getMaxBufferLength=function(){var u=R.prototype.getMaxBufferLength.call(this),o=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,k.PlaylistLevelType.MAIN);return o===null?u:Math.max(u,o.len)},g.onMediaDetaching=function(){this.videoBuffer=null,R.prototype.onMediaDetaching.call(this)},g.onAudioTracksUpdated=function(u,o){var C=o.audioTracks;this.resetTransmuxer(),this.levels=C.map(function(E){return new M.Level(E)})},g.onAudioTrackSwitching=function(u,o){var C=!!o.url;this.trackId=o.id;var E=this.fragCurrent;E!=null&&E.loader&&E.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),C?this.setInterval(f):this.resetTransmuxer(),C?(this.audioSwitch=!0,this.state=I.State.IDLE):this.state=I.State.STOPPED,this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},g.onLevelLoaded=function(u,o){this.mainDetails=o.details},g.onAudioTrackLoaded=function(u,o){var C,E=this.levels,v=o.details,O=o.id;if(!E){this.warn("Audio tracks were reset while loading level "+O);return}this.log("Track "+O+" loaded ["+v.startSN+","+v.endSN+"],duration:"+v.totalduration);var j=E[O],G=0;if(v.live||(C=j.details)!==null&&C!==void 0&&C.live){var J=this.mainDetails;if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed||!J)return;!j.details&&v.hasProgramDateTime&&J.hasProgramDateTime?(Object(S.alignMediaPlaylistByPDT)(v,J),G=v.fragments[0].start):G=this.alignPlaylists(v,j.details)}j.details=v,this.levelLastLoaded=O,!this.startFragRequested&&(this.mainDetails||!v.live)&&this.setStartPosition(j.details,G),this.state===I.State.WAITING_TRACK&&!this.waitForCdnTuneIn(v)&&(this.state=I.State.IDLE),this.tick()},g._handleFragmentLoadProgress=function(u){var o,C=u.frag,E=u.part,v=u.payload,O=this.config,j=this.trackId,G=this.levels;if(!G){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+C.sn+" of level "+C.level+" will not be buffered");return}var J=G[j];console.assert(J,"Audio track is defined on fragment load progress");var K=J.details;console.assert(K,"Audio track details are defined on fragment load progress");var F=O.defaultAudioCodec||J.audioCodec||"mp4a.40.2",ee=this.transmuxer;ee||(ee=this.transmuxer=new P.default(this.hls,k.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var oe=this.initPTS[C.cc],he=(o=C.initSegment)===null||o===void 0?void 0:o.data;if(oe!==void 0){var ge=!1,_e=E?E.index:-1,be=_e!==-1,Ee=new L.ChunkMetadata(C.level,C.sn,C.stats.chunkCount,v.byteLength,_e,be);ee.push(v,he,F,"",C,E,K.totalduration,ge,Ee,oe)}else{a.logger.log("Unknown video PTS for cc "+C.cc+", waiting for video PTS before demuxing audio frag "+C.sn+" of ["+K.startSN+" ,"+K.endSN+"],track "+j);var Te=this.waitingData=this.waitingData||{frag:C,part:E,cache:new y.default,complete:!1},Ce=Te.cache;Ce.push(new Uint8Array(v)),this.waitingVideoCC=this.videoTrackCC,this.state=I.State.WAITING_INIT_PTS}},g._handleFragmentLoadComplete=function(u){if(this.waitingData){this.waitingData.complete=!0;return}R.prototype._handleFragmentLoadComplete.call(this,u)},g.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},g.onBufferCreated=function(u,o){var C=o.tracks.audio;C&&(this.mediaBuffer=C.buffer),o.tracks.video&&(this.videoBuffer=o.tracks.video.buffer)},g.onFragBuffered=function(u,o){var C=o.frag,E=o.part;if(C.type!==k.PlaylistLevelType.AUDIO)return;if(this.fragContextChanged(C)){this.warn("Fragment "+C.sn+(E?" p: "+E.index:"")+" of level "+C.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}C.sn!=="initSegment"&&(this.fragPrevious=C,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(w.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(C,E)},g.onError=function(u,o){switch(o.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(k.PlaylistLevelType.AUDIO,o);break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==I.State.ERROR&&this.state!==I.State.STOPPED&&(this.state=o.fatal?I.State.ERROR:I.State.IDLE,this.warn(o.details+" while loading frag, switching to "+this.state+" state"));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if(o.parent==="audio"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var C=!0,E=this.getFwdBufferInfo(this.mediaBuffer,k.PlaylistLevelType.AUDIO);E&&E.len>.5&&(C=!this.reduceMaxBufferLength(E.len)),C&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,R.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},g.onBufferFlushed=function(u,o){var C=o.type;C===p.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},g._handleTransmuxComplete=function(u){var o,C="audio",E=this.hls,v=u.remuxResult,O=u.chunkMeta,j=this.getCurrentContext(O);if(!j){this.warn("The loading context changed while buffering fragment "+O.sn+" of level "+O.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(O.level);return}var G=j.frag,J=j.part,K=v.audio,F=v.text,ee=v.id3,oe=v.initSegment;if(this.fragContextChanged(G))return;if(this.state=I.State.PARSING,this.audioSwitch&&K&&this.completeAudioSwitch(),oe!=null&&oe.tracks&&(this._bufferInitSegment(oe.tracks,G,O),E.trigger(w.Events.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:C,tracks:oe.tracks})),K){var he=K.startPTS,ge=K.endPTS,_e=K.startDTS,be=K.endDTS;J&&(J.elementaryStreams[p.ElementaryStreamTypes.AUDIO]={startPTS:he,endPTS:ge,startDTS:_e,endDTS:be}),G.setElementaryStreamInfo(p.ElementaryStreamTypes.AUDIO,he,ge,_e,be),this.bufferFragmentData(K,G,J,O)}if(ee!=null&&(o=ee.samples)!==null&&o!==void 0&&o.length){var Ee=l({frag:G,id:C},ee);E.trigger(w.Events.FRAG_PARSING_METADATA,Ee)}if(F){var Te=l({frag:G,id:C},F);E.trigger(w.Events.FRAG_PARSING_USERDATA,Te)}},g._bufferInitSegment=function(u,o,C){if(this.state!==I.State.PARSING)return;u.video&&delete u.video;var E=u.audio;if(!E)return;E.levelCodec=E.codec,E.id="audio",this.log("Init audio buffer, container:"+E.container+", codecs[parsed]=["+E.codec+"]"),this.hls.trigger(w.Events.BUFFER_CODECS,u);var v=E.initSegment;if(v!=null&&v.byteLength){var O={type:"audio",frag:o,part:null,chunkMeta:C,parent:o.type,data:v};this.hls.trigger(w.Events.BUFFER_APPENDING,O)}this.tick()},g.loadFragment=function(u,o,C){var E=this.fragmentTracker.getState(u);this.fragCurrent=u,(this.audioSwitch||E===N.FragmentState.NOT_LOADED||E===N.FragmentState.PARTIAL)&&(u.sn==="initSegment"?this._loadInitSegment(u):o.live&&!Object(V.isFiniteNumber)(this.initPTS[u.cc])?(this.log("Waiting for video PTS in continuity counter "+u.cc+" of live stream before loading audio fragment "+u.sn+" of level "+this.trackId),this.state=I.State.WAITING_INIT_PTS):(this.startFragRequested=!0,R.prototype.loadFragment.call(this,u,o,C)))},g.completeAudioSwitch=function(){var u=this.hls,o=this.media,C=this.trackId;o&&(this.log("Switching audio track : flushing all audio"),R.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,u.trigger(w.Events.AUDIO_TRACK_SWITCHED,{id:C})},T}(I.default);Y.default=b},"./src/controller/audio-track-controller.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/events.ts"),I=D("./src/errors.ts"),w=D("./src/controller/base-playlist-controller.ts"),B=D("./src/types/loader.ts");function N(P,L){for(var x=0;x<L.length;x++){var S=L[x];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(P,S.key,S)}}function M(P,L,x){return L&&N(P.prototype,L),x&&N(P,x),P}function k(P,L){P.prototype=Object.create(L.prototype),P.prototype.constructor=P,p(P,L)}function p(P,L){return p=Object.setPrototypeOf||function(S,d){return S.__proto__=d,S},p(P,L)}var y=function(P){k(L,P);function L(S){var d;return d=P.call(this,S,"[audio-track-controller]")||this,d.tracks=[],d.groupId=null,d.tracksInGroup=[],d.trackId=-1,d.trackName="",d.selectDefaultTrack=!0,d.registerListeners(),d}var x=L.prototype;return x.registerListeners=function(){var d=this.hls;d.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.on(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(V.Events.ERROR,this.onError,this)},x.unregisterListeners=function(){var d=this.hls;d.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.off(V.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(V.Events.ERROR,this.onError,this)},x.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,P.prototype.destroy.call(this)},x.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},x.onManifestParsed=function(d,a){this.tracks=a.audioTracks||[]},x.onAudioTrackLoaded=function(d,a){var l=a.id,h=a.details,_=this.tracksInGroup[l];if(!_){this.warn("Invalid audio track id "+l);return}var f=_.details;_.details=a.details,this.log("audioTrack "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,a,f))},x.onLevelLoading=function(d,a){this.switchLevel(a.level)},x.onLevelSwitching=function(d,a){this.switchLevel(a.level)},x.switchLevel=function(d){var a=this.hls.levels[d];if(!(a!=null&&a.audioGroupIds))return;var l=a.audioGroupIds[a.urlId];if(this.groupId!==l){this.groupId=l;var h=this.tracks.filter(function(f){return!l||f.groupId===l});this.selectDefaultTrack&&!h.some(function(f){return f.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=h;var _={audioTracks:h};this.log("Updating audio tracks, "+h.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(V.Events.AUDIO_TRACKS_UPDATED,_),this.selectInitialTrack()}},x.onError=function(d,a){if(P.prototype.onError.call(this,d,a),a.fatal||!a.context)return;a.context.type===B.PlaylistContextType.AUDIO_TRACK&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.retryLoadingOrFail(a)},x.setAudioTrack=function(d){var a=this.tracksInGroup;if(d<0||d>=a.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=a[this.trackId];this.log("Now switching to audio-track index "+d);var h=a[d],_=h.id,f=h.groupId,b=f===void 0?"":f,R=h.name,T=h.type,g=h.url;if(this.trackId=d,this.trackName=R,this.selectDefaultTrack=!1,this.hls.trigger(V.Events.AUDIO_TRACK_SWITCHING,{id:_,groupId:b,name:R,type:T,url:g}),h.details&&!h.details.live)return;var c=this.switchParams(h.url,l==null?void 0:l.details);this.loadPlaylist(c)},x.selectInitialTrack=function(){var d=this.tracksInGroup;console.assert(d.length,"Initial audio track should be selected when tracks are known");var a=this.trackName,l=this.findTrackId(a)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},x.findTrackId=function(d){for(var a=this.tracksInGroup,l=0;l<a.length;l++){var h=a[l];if((!this.selectDefaultTrack||h.default)&&(!d||d===h.name))return h.id}return-1},x.loadPlaylist=function(d){var a=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(a)){var l=a.id,h=a.groupId,_=a.url;if(d)try{_=d.addDirectives(_)}catch(f){this.warn("Could not construct new URL with HLS Delivery Directives: "+f)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(V.Events.AUDIO_TRACK_LOADING,{url:_,id:l,groupId:h,deliveryDirectives:d||null})}},M(L,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(d){this.selectDefaultTrack=!1,this.setAudioTrack(d)}}]),L}(w.default);Y.default=y},"./src/controller/base-playlist-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return M});var V=D("./src/polyfills/number.ts"),I=D("./src/types/level.ts"),w=D("./src/controller/level-helper.ts"),B=D("./src/utils/logger.ts"),N=D("./src/errors.ts"),M=function(){function k(y,P){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=B.logger.log.bind(B.logger,P+":"),this.warn=B.logger.warn.bind(B.logger,P+":"),this.hls=y}var p=k.prototype;return p.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},p.onError=function(P,L){L.fatal&&L.type===N.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},p.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},p.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},p.stopLoad=function(){this.canLoad=!1,this.clearTimer()},p.switchParams=function(P,L){var x=L==null?void 0:L.renditionReports;if(x)for(var S=0;S<x.length;S++){var d=x[S],a=""+d.URI;if(a===P.substr(-a.length)){var l=parseInt(d["LAST-MSN"]),h=parseInt(d["LAST-PART"]);if(L&&this.hls.config.lowLatencyMode){var _=Math.min(L.age-L.partTarget,L.targetduration);h!==void 0&&_>L.partTarget&&(h+=1)}if(Object(V.isFiniteNumber)(l))return new I.HlsUrlParameters(l,Object(V.isFiniteNumber)(h)?h:void 0,I.HlsSkip.No)}}},p.loadPlaylist=function(P){},p.shouldLoadTrack=function(P){return this.canLoad&&P&&!!P.url&&(!P.details||P.details.live)},p.playlistLoaded=function(P,L,x){var S=this,d=L.details,a=L.stats,l=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(d.advancedDateTime=Date.now()-l,d.live||x!=null&&x.live){if(d.reloaded(x),x&&this.log("live playlist "+P+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),x&&d.fragments.length>0&&Object(w.mergeDetails)(x,d),!this.canLoad||!d.live)return;var h,_=void 0,f=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var b=this.hls.config.lowLatencyMode,R=d.lastPartSn,T=d.endSN,g=d.lastPartIndex,c=g!==-1,u=R===T,o=b?0:g;c?(_=u?T+1:R,f=u?o:g+1):_=T+1;var C=d.age,E=C+d.ageHeader,v=Math.min(E-d.partTarget,d.targetduration*1.5);if(v>0){if(x&&v>x.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+x.tuneInGoal+" to: "+v+" with playlist age: "+d.age),v=0;else{var O=Math.floor(v/d.targetduration);if(_+=O,f!==void 0){var j=Math.round(v%d.targetduration/d.partTarget);f+=j}this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+C.toFixed(2)+"s goal: "+v+" skip sn "+O+" to part "+f)}d.tuneInGoal=v}if(h=this.getDeliveryDirectives(d,L.deliveryDirectives,_,f),b||!u){this.loadPlaylist(h);return}}else h=this.getDeliveryDirectives(d,L.deliveryDirectives,_,f);var G=Object(w.computeReloadInterval)(d,a);_!==void 0&&d.canBlockReload&&(G-=d.partTarget||1),this.log("reload live playlist "+P+" in "+Math.round(G)+" ms"),this.timer=self.setTimeout(function(){return S.loadPlaylist(h)},G)}else this.clearTimer()},p.getDeliveryDirectives=function(P,L,x,S){var d=Object(I.getSkipValue)(P,x);return L!=null&&L.skip&&P.deltaUpdateFailed&&(x=L.msn,S=L.part,d=I.HlsSkip.No),new I.HlsUrlParameters(x,S,d)},p.retryLoadingOrFail=function(P){var L=this,x=this.hls.config,S=this.retryCount<x.levelLoadingMaxRetry;if(S){var d;if(this.retryCount++,P.details.indexOf("LoadTimeOut")>-1&&(d=P.context)!==null&&d!==void 0&&d.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+P.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*x.levelLoadingRetryDelay,x.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return L.loadPlaylist()},a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+P.details+'"')}}else this.warn('cannot recover from error "'+P.details+'"'),this.clearTimer(),P.fatal=!0;return S},k}()},"./src/controller/base-stream-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"State",function(){return T}),D.d(Y,"default",function(){return g});var V=D("./src/polyfills/number.ts"),I=D("./src/task-loop.ts"),w=D("./src/controller/fragment-tracker.ts"),B=D("./src/utils/buffer-helper.ts"),N=D("./src/utils/logger.ts"),M=D("./src/events.ts"),k=D("./src/errors.ts"),p=D("./src/types/transmuxer.ts"),y=D("./src/utils/mp4-tools.ts"),P=D("./src/utils/discontinuities.ts"),L=D("./src/controller/fragment-finders.ts"),x=D("./src/controller/level-helper.ts"),S=D("./src/loader/fragment-loader.ts"),d=D("./src/crypt/decrypter.ts"),a=D("./src/utils/time-ranges.ts"),l=D("./src/types/loader.ts");function h(c,u){for(var o=0;o<u.length;o++){var C=u[o];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(c,C.key,C)}}function _(c,u,o){return u&&h(c.prototype,u),o&&h(c,o),c}function f(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function b(c,u){c.prototype=Object.create(u.prototype),c.prototype.constructor=c,R(c,u)}function R(c,u){return R=Object.setPrototypeOf||function(C,E){return C.__proto__=E,C},R(c,u)}var T={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"},g=function(c){b(u,c);function u(C,E,v){var O;return O=c.call(this)||this,O.hls=void 0,O.fragPrevious=null,O.fragCurrent=null,O.fragmentTracker=void 0,O.transmuxer=null,O._state=T.STOPPED,O.media=void 0,O.mediaBuffer=void 0,O.config=void 0,O.bitrateTest=!1,O.lastCurrentTime=0,O.nextLoadPosition=0,O.startPosition=0,O.loadedmetadata=!1,O.fragLoadError=0,O.retryDate=0,O.levels=null,O.fragmentLoader=void 0,O.levelLastLoaded=null,O.startFragRequested=!1,O.decrypter=void 0,O.initPTS=[],O.onvseeking=null,O.onvended=null,O.logPrefix="",O.log=void 0,O.warn=void 0,O.logPrefix=v,O.log=N.logger.log.bind(N.logger,v+":"),O.warn=N.logger.warn.bind(N.logger,v+":"),O.hls=C,O.fragmentLoader=new S.default(C.config),O.fragmentTracker=E,O.config=C.config,O.decrypter=new d.default(C,C.config),C.on(M.Events.KEY_LOADED,O.onKeyLoaded,f(O)),O}var o=u.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(E){},o.stopLoad=function(){this.fragmentLoader.abort();var E=this.fragCurrent;E&&this.fragmentTracker.removeFragment(E),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=T.STOPPED},o._streamEnded=function(E,v){var O=this.fragCurrent,j=this.fragmentTracker;if(!v.live&&O&&O.sn===v.endSN&&!E.nextStart){var G=j.getState(O);return G===w.FragmentState.PARTIAL||G===w.FragmentState.OK}return!1},o.onMediaAttached=function(E,v){var O=this.media=this.mediaBuffer=v.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),O.addEventListener("seeking",this.onvseeking),O.addEventListener("ended",this.onvended);var j=this.config;this.levels&&j.autoStartLoad&&this.state===T.STOPPED&&this.startLoad(j.startPosition)},o.onMediaDetaching=function(){var E=this.media;E!=null&&E.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),E&&(E.removeEventListener("seeking",this.onvseeking),E.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var E=this.config,v=this.fragCurrent,O=this.media,j=this.mediaBuffer,G=this.state,J=O?O.currentTime:0,K=B.BufferHelper.bufferInfo(j||O,J,E.maxBufferHole);if(this.log("media seeking to "+(Object(V.isFiniteNumber)(J)?J.toFixed(3):J)+", state: "+G),G===T.ENDED)this.resetLoadingState();else if(v&&!K.len){var F=E.maxFragLookUpTolerance,ee=v.start-F,oe=v.start+v.duration+F,he=J>oe;(J<ee||he)&&(he&&v.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),v.loader.abort()),this.resetLoadingState())}O&&(this.lastCurrentTime=J),!this.loadedmetadata&&!K.len&&(this.nextLoadPosition=this.startPosition=J),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(E,v){if(this.state!==T.KEY_LOADING||v.frag!==this.fragCurrent||!this.levels)return;this.state=T.IDLE;var O=this.levels[v.frag.level].details;O&&this.loadFragment(v.frag,O,v.frag.start)},o.onHandlerDestroying=function(){this.stopLoad(),c.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=T.STOPPED,this.hls.off(M.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)},o.loadKey=function(E,v){this.log("Loading key for "+E.sn+" of ["+v.startSN+"-"+v.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+E.level),this.state=T.KEY_LOADING,this.fragCurrent=E,this.hls.trigger(M.Events.KEY_LOADING,{frag:E})},o.loadFragment=function(E,v,O){this._loadFragForPlayback(E,v,O)},o._loadFragForPlayback=function(E,v,O){var j=this,G=function(K){if(j.fragContextChanged(E)){j.warn("Fragment "+E.sn+(K.part?" p: "+K.part.index:"")+" of level "+E.level+" was dropped during download."),j.fragmentTracker.removeFragment(E);return}E.stats.chunkCount++,j._handleFragmentLoadProgress(K)};this._doFragLoad(E,v,O,G).then(function(J){if(!J)return;j.fragLoadError=0;var K=j.state;if(j.fragContextChanged(E)){(K===T.FRAG_LOADING||K===T.BACKTRACKING||!j.fragCurrent&&K===T.PARSING)&&(j.fragmentTracker.removeFragment(E),j.state=T.IDLE);return}if("payload"in J&&(j.log("Loaded fragment "+E.sn+" of level "+E.level),j.hls.trigger(M.Events.FRAG_LOADED,J),j.state===T.BACKTRACKING)){j.fragmentTracker.backtrack(E,J),j.resetFragmentLoading(E);return}j._handleFragmentLoadComplete(J)}).catch(function(J){j.warn(J),j.resetFragmentLoading(E)})},o.flushMainBuffer=function(E,v,O){if(O===void 0&&(O=null),!(E-v))return;var j={startOffset:E,endOffset:v,type:O};this.fragLoadError=0,this.hls.trigger(M.Events.BUFFER_FLUSHING,j)},o._loadInitSegment=function(E){var v=this;this._doFragLoad(E).then(function(O){if(!O||v.fragContextChanged(E)||!v.levels)throw new Error("init load aborted");return O}).then(function(O){var j=v.hls,G=O.payload,J=E.decryptdata;if(G&&G.byteLength>0&&J&&J.key&&J.iv&&J.method==="AES-128"){var K=self.performance.now();return v.decrypter.webCryptoDecrypt(new Uint8Array(G),J.key.buffer,J.iv.buffer).then(function(F){var ee=self.performance.now();return j.trigger(M.Events.FRAG_DECRYPTED,{frag:E,payload:F,stats:{tstart:K,tdecrypt:ee}}),O.payload=F,O})}return O}).then(function(O){var j=v.fragCurrent,G=v.hls,J=v.levels;if(!J)throw new Error("init load aborted, missing levels");var K=J[E.level].details;console.assert(K,"Level details are defined when init segment is loaded");var F=E.stats;v.state=T.IDLE,v.fragLoadError=0,E.data=new Uint8Array(O.payload),F.parsing.start=F.buffering.start=self.performance.now(),F.parsing.end=F.buffering.end=self.performance.now(),O.frag===j&&G.trigger(M.Events.FRAG_BUFFERED,{stats:F,frag:j,part:null,id:E.type}),v.tick()}).catch(function(O){v.warn(O),v.resetFragmentLoading(E)})},o.fragContextChanged=function(E){var v=this.fragCurrent;return!E||!v||E.level!==v.level||E.sn!==v.sn||E.urlId!==v.urlId},o.fragBufferedComplete=function(E,v){var O=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+E.type+" sn: "+E.sn+(v?" part: "+v.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+E.level+" "+a.default.toString(B.BufferHelper.getBuffered(O))),this.state=T.IDLE,this.tick()},o._handleFragmentLoadComplete=function(E){var v=this.transmuxer;if(!v)return;var O=E.frag,j=E.part,G=E.partsLoaded,J=!G||G.length===0||G.some(function(F){return!F}),K=new p.ChunkMetadata(O.level,O.sn,O.stats.chunkCount+1,0,j?j.index:-1,!J);v.flush(K)},o._handleFragmentLoadProgress=function(E){},o._doFragLoad=function(E,v,O,j){var G=this;if(O===void 0&&(O=null),!this.levels)throw new Error("frag load aborted, missing levels");if(O=Math.max(E.start,O||0),this.config.lowLatencyMode&&v){var J=v.partList;if(J&&j){O>E.end&&v.fragmentHint&&(E=v.fragmentHint);var K=this.getNextPart(J,E,O);if(K>-1){var F=J[K];return this.log("Loading part sn: "+E.sn+" p: "+F.index+" cc: "+E.cc+" of playlist ["+v.startSN+"-"+v.endSN+"] parts [0-"+K+"-"+(J.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+E.level+", target: "+parseFloat(O.toFixed(3))),this.nextLoadPosition=F.start+F.duration,this.state=T.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:E,part:J[K],targetBufferTime:O}),this.doFragPartsLoad(E,J,K,j).catch(function(ee){return G.handleFragLoadError(ee)})}else if(!E.url||this.loadedEndOfParts(J,O))return Promise.resolve(null)}}return this.log("Loading fragment "+E.sn+" cc: "+E.cc+" "+(v?"of ["+v.startSN+"-"+v.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+E.level+", target: "+parseFloat(O.toFixed(3))),Object(V.isFiniteNumber)(E.sn)&&!this.bitrateTest&&(this.nextLoadPosition=E.start+E.duration),this.state=T.FRAG_LOADING,this.hls.trigger(M.Events.FRAG_LOADING,{frag:E,targetBufferTime:O}),this.fragmentLoader.load(E,j).catch(function(ee){return G.handleFragLoadError(ee)})},o.doFragPartsLoad=function(E,v,O,j){var G=this;return new Promise(function(J,K){var F=[],ee=function oe(he){var ge=v[he];G.fragmentLoader.loadPart(E,ge,j).then(function(_e){F[ge.index]=_e;var be=_e.part;G.hls.trigger(M.Events.FRAG_LOADED,_e);var Ee=v[he+1];if(Ee&&Ee.fragment===E)oe(he+1);else return J({frag:E,part:be,partsLoaded:F})}).catch(K)};ee(O)})},o.handleFragLoadError=function(E){var v=E.data;return v&&v.details===k.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(v.frag,v.part):this.hls.trigger(M.Events.ERROR,v),null},o._handleTransmuxerFlush=function(E){var v=this.getCurrentContext(E);if(!v||this.state!==T.PARSING){this.fragCurrent||(this.state=T.IDLE);return}var O=v.frag,j=v.part,G=v.level,J=self.performance.now();O.stats.parsing.end=J,j&&(j.stats.parsing.end=J),this.updateLevelTiming(O,j,G,E.partial)},o.getCurrentContext=function(E){var v=this.levels,O=E.level,j=E.sn,G=E.part;if(!v||!v[O])return this.warn("Levels object was unset while buffering fragment "+j+" of level "+O+". The current chunk will not be buffered."),null;var J=v[O],K=G>-1?Object(x.getPartWith)(J,j,G):null,F=K?K.fragment:Object(x.getFragmentWithSN)(J,j,this.fragCurrent);return F?{frag:F,part:K,level:J}:null},o.bufferFragmentData=function(E,v,O,j){if(!E||this.state!==T.PARSING)return;var G=E.data1,J=E.data2,K=G;if(G&&J&&(K=Object(y.appendUint8Array)(G,J)),!K||!K.length)return;var F={type:E.type,frag:v,part:O,chunkMeta:j,parent:v.type,data:K};this.hls.trigger(M.Events.BUFFER_APPENDING,F),E.dropped&&E.independent&&!O&&this.flushBufferGap(v)},o.flushBufferGap=function(E){var v=this.media;if(!v)return;if(!B.BufferHelper.isBuffered(v,v.currentTime)){this.flushMainBuffer(0,E.start);return}var O=v.currentTime,j=B.BufferHelper.bufferInfo(v,O,0),G=E.duration,J=Math.min(this.config.maxFragLookUpTolerance*2,G*.25),K=Math.max(Math.min(E.start-J,j.end-J),O+J);E.start-K>J&&this.flushMainBuffer(K,E.start)},o.getFwdBufferInfo=function(E,v){var O=this.config,j=this.getLoadPosition();if(!Object(V.isFiniteNumber)(j))return null;var G=B.BufferHelper.bufferInfo(E,j,O.maxBufferHole);if(G.len===0&&G.nextStart!==void 0){var J=this.fragmentTracker.getBufferedFrag(j,v);if(J&&G.nextStart<J.end)return B.BufferHelper.bufferInfo(E,j,Math.max(G.nextStart,O.maxBufferHole))}return G},o.getMaxBufferLength=function(E){var v=this.config,O;return E?O=Math.max(8*v.maxBufferSize/E,v.maxBufferLength):O=v.maxBufferLength,Math.min(O,v.maxMaxBufferLength)},o.reduceMaxBufferLength=function(E){var v=this.config,O=E||v.maxBufferLength;return v.maxMaxBufferLength>=O?(v.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+v.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(E,v){var O,j,G=v.fragments,J=G.length;if(!J)return null;var K=this.config,F=G[0].start,ee;if(v.live){var oe=K.initialLiveManifestSize;if(J<oe)return this.warn("Not enough fragments to start playback (have: "+J+", need: "+oe+")"),null;!v.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(ee=this.getInitialLiveFragment(v,G),this.startPosition=ee?this.hls.liveSyncPosition||ee.start:E)}else E<=F&&(ee=G[0]);if(!ee){var he=K.lowLatencyMode?v.partEnd:v.fragmentEnd;ee=this.getFragmentAtPosition(E,he,v)}return(O=ee)!==null&&O!==void 0&&O.initSegment&&!((j=ee)!==null&&j!==void 0&&j.initSegment.data)&&!this.bitrateTest&&(ee=ee.initSegment),ee},o.getNextPart=function(E,v,O){for(var j=-1,G=!1,J=!0,K=0,F=E.length;K<F;K++){var ee=E[K];if(J=J&&!ee.independent,j>-1&&O<ee.start)break;var oe=ee.loaded;!oe&&(G||ee.independent||J)&&ee.fragment===v&&(j=K),G=oe}return j},o.loadedEndOfParts=function(E,v){var O=E[E.length-1];return O&&v>O.start&&O.loaded},o.getInitialLiveFragment=function(E,v){var O=this.fragPrevious,j=null;if(O){if(E.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+O.programDateTime),j=Object(L.findFragmentByPDT)(v,O.endProgramDateTime,this.config.maxFragLookUpTolerance)),!j){var G=O.sn+1;if(G>=E.startSN&&G<=E.endSN){var J=v[G-E.startSN];O.cc===J.cc&&(j=J,this.log("Live playlist, switching playlist, load frag with next SN: "+j.sn))}j||(j=Object(L.findFragWithCC)(v,O.cc),j&&this.log("Live playlist, switching playlist, load frag with same CC: "+j.sn))}}else{var K=this.hls.liveSyncPosition;K!==null&&(j=this.getFragmentAtPosition(K,this.bitrateTest?E.fragmentEnd:E.edge,E))}return j},o.getFragmentAtPosition=function(E,v,O){var j=this.config,G=this.fragPrevious,J=O.fragments,K=O.endSN,F=O.fragmentHint,ee=j.maxFragLookUpTolerance,oe=!!(j.lowLatencyMode&&O.partList&&F);oe&&F&&!this.bitrateTest&&(J=J.concat(F),K=F.sn);var he;if(E<v){var ge=E>v-ee?0:ee;he=Object(L.findFragmentByPTS)(G,J,E,ge)}else he=J[J.length-1];if(he){var _e=he.sn-O.startSN,be=G&&he.level===G.level,Ee=J[_e+1],Te=this.fragmentTracker.getState(he);if(Te===w.FragmentState.BACKTRACKED){he=null;for(var Ce=_e;J[Ce]&&this.fragmentTracker.getState(J[Ce])===w.FragmentState.BACKTRACKED;)G?he=J[Ce--]:he=J[--Ce];he||(he=Ee)}else G&&he.sn===G.sn&&!oe&&(be&&(he.sn<K&&this.fragmentTracker.getState(Ee)!==w.FragmentState.OK?(this.log("SN "+he.sn+" just loaded, load next one: "+Ee.sn),he=Ee):he=null))}return he},o.synchronizeToLiveEdge=function(E){var v=this.config,O=this.media;if(!O)return;var j=this.hls.liveSyncPosition,G=O.currentTime,J=E.fragments[0].start,K=E.edge,F=G>=J-v.maxFragLookUpTolerance&&G<=K;if(j!==null&&O.duration>j&&(G<j||!F)){var ee=v.liveMaxLatencyDuration!==void 0?v.liveMaxLatencyDuration:v.liveMaxLatencyDurationCount*E.targetduration;(!F&&O.readyState<4||G<K-ee)&&(this.loadedmetadata||(this.nextLoadPosition=j),O.readyState&&(this.warn("Playback: "+G.toFixed(3)+" is located too far from the end of live sliding playlist: "+K+", reset currentTime to : "+j.toFixed(3)),O.currentTime=j))}},o.alignPlaylists=function(E,v){var O=this.levels,j=this.levelLastLoaded,G=this.fragPrevious,J=j!==null?O[j]:null,K=E.fragments.length;if(!K)return this.warn("No fragments in live playlist"),0;var F=E.fragments[0].start,ee=!v,oe=E.alignedSliding&&Object(V.isFiniteNumber)(F);if(ee||!oe&&!F){Object(P.alignStream)(G,J,E);var he=E.fragments[0].start;return this.log("Live playlist sliding: "+he.toFixed(2)+" start-sn: "+(v?v.startSN:"na")+"->"+E.startSN+" prev-sn: "+(G?G.sn:"na")+" fragments: "+K),he}return F},o.waitForCdnTuneIn=function(E){var v=3;return E.live&&E.canBlockReload&&E.tuneInGoal>Math.max(E.partHoldBack,E.partTarget*v)},o.setStartPosition=function(E,v){var O=this.startPosition;if(O<v&&(O=-1),O===-1||this.lastCurrentTime===-1){var j=E.startTimeOffset;Object(V.isFiniteNumber)(j)?(O=v+j,j<0&&(O+=E.totalduration),O=Math.min(Math.max(v,O),v+E.totalduration),this.log("Start time offset "+j+" found in playlist, adjust startPosition to "+O),this.startPosition=O):E.live?O=this.hls.liveSyncPosition||v:this.startPosition=O=0,this.lastCurrentTime=O}this.nextLoadPosition=O},o.getLoadPosition=function(){var E=this.media,v=0;return this.loadedmetadata&&E?v=E.currentTime:this.nextLoadPosition&&(v=this.nextLoadPosition),v},o.handleFragLoadAborted=function(E,v){this.transmuxer&&E.sn!=="initSegment"&&E.stats.aborted&&(this.warn("Fragment "+E.sn+(v?" part"+v.index:"")+" of level "+E.level+" was aborted"),this.resetFragmentLoading(E))},o.resetFragmentLoading=function(E){(!this.fragCurrent||!this.fragContextChanged(E))&&(this.state=T.IDLE)},o.onFragmentOrKeyLoadError=function(E,v){if(v.fatal)return;var O=v.frag;if(!O||O.type!==E)return;var j=this.fragCurrent;console.assert(j&&O.sn===j.sn&&O.level===j.level&&O.urlId===j.urlId,"Frag load error must match current frag to retry");var G=this.config;if(this.fragLoadError+1<=G.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(O.level))return;var J=Math.min(Math.pow(2,this.fragLoadError)*G.fragLoadingRetryDelay,G.fragLoadingMaxRetryTimeout);this.warn("Fragment "+O.sn+" of "+E+" "+O.level+" failed to load, retrying in "+J+"ms"),this.retryDate=self.performance.now()+J,this.fragLoadError++,this.state=T.FRAG_LOADING_WAITING_RETRY}else v.levelRetry?(E===l.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=T.IDLE):(N.logger.error(v.details+" reaches max retry, redispatch as fatal ..."),v.fatal=!0,this.hls.stopLoad(),this.state=T.ERROR)},o.afterBufferFlushed=function(E,v,O){if(!E)return;var j=B.BufferHelper.getBuffered(E);this.fragmentTracker.detectEvictedFragments(v,j,O),this.state===T.ENDED&&this.resetLoadingState()},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=T.IDLE},o.resetLiveStartWhenNotLoaded=function(E){if(!this.loadedmetadata){this.startFragRequested=!1;var v=this.levels?this.levels[E].details:null;if(v!=null&&v.live)return this.startPosition=-1,this.setStartPosition(v,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},o.updateLevelTiming=function(E,v,O,j){var G=this,J=O.details;console.assert(!!J,"level.details must be defined");var K=Object.keys(E.elementaryStreams).reduce(function(F,ee){var oe=E.elementaryStreams[ee];if(oe){var he=oe.endPTS-oe.startPTS;if(he<=0)return G.warn("Could not parse fragment "+E.sn+" "+ee+" duration reliably ("+he+") resetting transmuxer to fallback to playlist timing"),G.resetTransmuxer(),F||!1;var ge=j?0:Object(x.updateFragPTSDTS)(J,E,oe.startPTS,oe.endPTS,oe.startDTS,oe.endDTS);return G.hls.trigger(M.Events.LEVEL_PTS_UPDATED,{details:J,level:O,drift:ge,type:ee,frag:E,start:oe.startPTS,end:oe.endPTS}),!0}return F},!1);K?(this.state=T.PARSED,this.hls.trigger(M.Events.FRAG_PARSED,{frag:E,part:v})):this.resetLoadingState()},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},_(u,[{key:"state",get:function(){return this._state},set:function(E){var v=this._state;v!==E&&(this._state=E,this.log(v+"->"+E))}}]),u}(I.default)},"./src/controller/buffer-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return L});var V=D("./src/polyfills/number.ts"),I=D("./src/events.ts"),w=D("./src/utils/logger.ts"),B=D("./src/errors.ts"),N=D("./src/utils/buffer-helper.ts"),M=D("./src/utils/mediasource-helper.ts"),k=D("./src/loader/fragment.ts"),p=D("./src/controller/buffer-operation-queue.ts"),y=Object(M.getMediaSource)(),P=/([ha]vc.)(?:\.[^.,]+)+/,L=function(){function x(d){var a=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 l=a.hls,h=a.media,_=a.mediaSource;w.logger.log("[buffer-controller]: Media source opened"),h&&(a.updateMediaElementDuration(),l.trigger(I.Events.MEDIA_ATTACHED,{media:h})),_&&_.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){w.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){w.logger.log("[buffer-controller]: Media source ended")},this.hls=d,this._initSourceBuffer(),this.registerListeners()}var S=x.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 a=this.hls;a.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(I.Events.BUFFER_RESET,this.onBufferReset,this),a.on(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.on(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(I.Events.BUFFER_EOS,this.onBufferEos,this),a.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.on(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.on(I.Events.FRAG_PARSED,this.onFragParsed,this),a.on(I.Events.FRAG_CHANGED,this.onFragChanged,this)},S.unregisterListeners=function(){var a=this.hls;a.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(I.Events.BUFFER_RESET,this.onBufferReset,this),a.off(I.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.off(I.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(I.Events.BUFFER_EOS,this.onBufferEos,this),a.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.off(I.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.off(I.Events.FRAG_PARSED,this.onFragParsed,this),a.off(I.Events.FRAG_CHANGED,this.onFragChanged,this)},S._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new p.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},S.onManifestParsed=function(a,l){var h=2;(l.audio&&!l.video||!l.altAudio)&&(h=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=h,this.details=null,w.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},S.onMediaAttaching=function(a,l){var h=this.media=l.media;if(h&&y){var _=this.mediaSource=new y;_.addEventListener("sourceopen",this._onMediaSourceOpen),_.addEventListener("sourceended",this._onMediaSourceEnded),_.addEventListener("sourceclose",this._onMediaSourceClose),h.src=self.URL.createObjectURL(_),this._objectUrl=h.src}},S.onMediaDetaching=function(){var a=this.media,l=this.mediaSource,h=this._objectUrl;if(l){if(w.logger.log("[buffer-controller]: media source detaching"),l.readyState==="open")try{l.endOfStream()}catch(_){w.logger.warn("[buffer-controller]: onMediaDetaching: "+_.message+" while calling endOfStream")}this.onBufferReset(),l.removeEventListener("sourceopen",this._onMediaSourceOpen),l.removeEventListener("sourceended",this._onMediaSourceEnded),l.removeEventListener("sourceclose",this._onMediaSourceClose),a&&(h&&self.URL.revokeObjectURL(h),a.src===h?(a.removeAttribute("src"),a.load()):w.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 a=this;this.getSourceBufferTypes().forEach(function(l){var h=a.sourceBuffer[l];try{h&&(a.removeBufferListeners(l),a.mediaSource&&a.mediaSource.removeSourceBuffer(h),a.sourceBuffer[l]=void 0)}catch(_){w.logger.warn("[buffer-controller]: Failed to reset the "+l+" buffer",_)}}),this._initSourceBuffer()},S.onBufferCodecs=function(a,l){var h=this,_=this.getSourceBufferTypes().length;if(Object.keys(l).forEach(function(f){if(_){var b=h.tracks[f];if(b&&typeof b.buffer.changeType=="function"){var R=l[f],T=R.codec,g=R.levelCodec,c=R.container,u=(b.levelCodec||b.codec).replace(P,"$1"),o=(g||T).replace(P,"$1");if(u!==o){var C=c+";codecs="+(g||T);h.appendChangeType(f,C)}}}else h.pendingTracks[f]=l[f]}),_)return;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()},S.appendChangeType=function(a,l){var h=this,_=this.operationQueue,f={execute:function(){var R=h.sourceBuffer[a];R&&(w.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+l),R.changeType(l)),_.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(R){w.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",R)}};_.append(f,a)},S.onBufferAppending=function(a,l){var h=this,_=this.hls,f=this.operationQueue,b=this.tracks,R=l.data,T=l.type,g=l.frag,c=l.part,u=l.chunkMeta,o=u.buffering[T],C=self.performance.now();o.start=C;var E=g.stats.buffering,v=c?c.stats.buffering:null;E.start===0&&(E.start=C),v&&v.start===0&&(v.start=C);var O=b.audio,j=T==="audio"&&u.id===1&&(O==null?void 0:O.container)==="audio/mpeg",G={execute:function(){if(o.executeStart=self.performance.now(),j){var K=h.sourceBuffer[T];if(K){var F=g.start-K.timestampOffset;Math.abs(F)>=.1&&(w.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+F+") sn: "+g.sn+")"),K.timestampOffset=g.start)}}h.appendExecutor(R,T)},onStart:function(){},onComplete:function(){var K=self.performance.now();o.executeEnd=o.end=K,E.first===0&&(E.first=K),v&&v.first===0&&(v.first=K);var F=h.sourceBuffer,ee={};for(var oe in F)ee[oe]=N.BufferHelper.getBuffered(F[oe]);h.appendError=0,h.hls.trigger(I.Events.BUFFER_APPENDED,{type:T,frag:g,part:c,chunkMeta:u,parent:g.type,timeRanges:ee})},onError:function(K){w.logger.error("[buffer-controller]: Error encountered while trying to append to the "+T+" SourceBuffer",K);var F={type:B.ErrorTypes.MEDIA_ERROR,parent:g.type,details:B.ErrorDetails.BUFFER_APPEND_ERROR,err:K,fatal:!1};K.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=B.ErrorDetails.BUFFER_FULL_ERROR:(h.appendError++,F.details=B.ErrorDetails.BUFFER_APPEND_ERROR,h.appendError>_.config.appendErrorMaxRetry&&(w.logger.error("[buffer-controller]: Failed "+_.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),F.fatal=!0)),_.trigger(I.Events.ERROR,F)}};f.append(G,T)},S.onBufferFlushing=function(a,l){var h=this,_=this.operationQueue,f=function(R){return{execute:h.removeExecutor.bind(h,R,l.startOffset,l.endOffset),onStart:function(){},onComplete:function(){h.hls.trigger(I.Events.BUFFER_FLUSHED,{type:R})},onError:function(g){w.logger.warn("[buffer-controller]: Failed to remove from "+R+" SourceBuffer",g)}}};l.type?_.append(f(l.type),l.type):this.getSourceBufferTypes().forEach(function(b){_.append(f(b),b)})},S.onFragParsed=function(a,l){var h=this,_=l.frag,f=l.part,b=[],R=f?f.elementaryStreams:_.elementaryStreams;R[k.ElementaryStreamTypes.AUDIOVIDEO]?b.push("audiovideo"):(R[k.ElementaryStreamTypes.AUDIO]&&b.push("audio"),R[k.ElementaryStreamTypes.VIDEO]&&b.push("video"));var T=function(){var c=self.performance.now();_.stats.buffering.end=c,f&&(f.stats.buffering.end=c);var u=f?f.stats:_.stats;h.hls.trigger(I.Events.FRAG_BUFFERED,{frag:_,part:f,stats:u,id:_.type})};b.length===0&&w.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+_.type+" level: "+_.level+" sn: "+_.sn),this.blockBuffers(T,b)},S.onFragChanged=function(a,l){this.flushBackBuffer()},S.onBufferEos=function(a,l){var h=this,_=this.getSourceBufferTypes().reduce(function(f,b){var R=h.sourceBuffer[b];return(!l.type||l.type===b)&&(R&&!R.ended&&(R.ended=!0,w.logger.log("[buffer-controller]: "+b+" sourceBuffer now EOS"))),f&&!!(!R||R.ended)},!0);_&&this.blockBuffers(function(){var f=h.mediaSource;if(!f||f.readyState!=="open")return;f.endOfStream()})},S.onLevelUpdated=function(a,l){var h=l.details;if(!h.fragments.length)return;this.details=h,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration()},S.flushBackBuffer=function(){var a=this.hls,l=this.details,h=this.media,_=this.sourceBuffer;if(!h||l===null)return;var f=this.getSourceBufferTypes();if(!f.length)return;var b=l.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!Object(V.isFiniteNumber)(b)||b<0)return;var R=h.currentTime,T=l.levelTargetDuration,g=Math.max(b,T),c=Math.floor(R/T)*T-g;f.forEach(function(u){var o=_[u];if(o){var C=N.BufferHelper.getBuffered(o);C.length>0&&c>C.start(0)&&(a.trigger(I.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),l.live&&a.trigger(I.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c}),a.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:u}))}})},S.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;var a=this.details,l=this.hls,h=this.media,_=this.mediaSource,f=a.fragments[0].start+a.totalduration,b=h.duration,R=Object(V.isFiniteNumber)(_.duration)?_.duration:0;a.live&&l.config.liveDurationInfinity?(w.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),_.duration=Infinity,this.updateSeekableRange(a)):(f>R&&f>b||!Object(V.isFiniteNumber)(b))&&(w.logger.log("[buffer-controller]: Updating Media Source duration to "+f.toFixed(3)),_.duration=f)},S.updateSeekableRange=function(a){var l=this.mediaSource,h=a.fragments,_=h.length;if(_&&a.live&&l!==null&&l!==void 0&&l.setLiveSeekableRange){var f=Math.max(0,h[0].start),b=Math.max(f,f+a.totalduration);l.setLiveSeekableRange(f,b)}},S.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,l=this.operationQueue,h=this.pendingTracks,_=Object.keys(h).length;if(_&&!a||_===2){this.createSourceBuffers(h),this.pendingTracks={};var f=this.getSourceBufferTypes();if(f.length===0){this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}f.forEach(function(b){l.executeNext(b)})}},S.createSourceBuffers=function(a){var l=this.sourceBuffer,h=this.mediaSource;if(!h)throw Error("createSourceBuffers called when mediaSource was null");var _=0;for(var f in a)if(!l[f]){var b=a[f];if(!b)throw Error("source buffer exists for track "+f+", however track does not");var R=b.levelCodec||b.codec,T=b.container+";codecs="+R;w.logger.log("[buffer-controller]: creating sourceBuffer("+T+")");try{var g=l[f]=h.addSourceBuffer(T),c=f;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[f]={buffer:g,codec:R,container:b.container,levelCodec:b.levelCodec,id:b.id},_++}catch(u){w.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+u.message),this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:u,mimeType:T})}}_&&this.hls.trigger(I.Events.BUFFER_CREATED,{tracks:this.tracks})},S._onSBUpdateStart=function(a){var l=this.operationQueue,h=l.current(a);h.onStart()},S._onSBUpdateEnd=function(a){var l=this.operationQueue,h=l.current(a);h.onComplete(),l.shiftAndExecuteNext(a)},S._onSBUpdateError=function(a,l){w.logger.error("[buffer-controller]: "+a+" SourceBuffer error",l),this.hls.trigger(I.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var h=this.operationQueue.current(a);h&&h.onError(l)},S.removeExecutor=function(a,l,h){var _=this.media,f=this.mediaSource,b=this.operationQueue,R=this.sourceBuffer,T=R[a];if(!_||!f||!T){w.logger.warn("[buffer-controller]: Attempting to remove from the "+a+" SourceBuffer, but it does not exist"),b.shiftAndExecuteNext(a);return}var g=Object(V.isFiniteNumber)(_.duration)?_.duration:Infinity,c=Object(V.isFiniteNumber)(f.duration)?f.duration:Infinity,u=Math.max(0,l),o=Math.min(h,g,c);o>u?(w.logger.log("[buffer-controller]: Removing ["+u+","+o+"] from the "+a+" SourceBuffer"),console.assert(!T.updating,a+" sourceBuffer must not be updating"),T.remove(u,o)):b.shiftAndExecuteNext(a)},S.appendExecutor=function(a,l){var h=this.operationQueue,_=this.sourceBuffer,f=_[l];if(!f){w.logger.warn("[buffer-controller]: Attempting to append to the "+l+" SourceBuffer, but it does not exist"),h.shiftAndExecuteNext(l);return}f.ended=!1,console.assert(!f.updating,l+" sourceBuffer must not be updating"),f.appendBuffer(a)},S.blockBuffers=function(a,l){var h=this;if(l===void 0&&(l=this.getSourceBufferTypes()),!l.length){w.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve(a);return}var _=this.operationQueue,f=l.map(function(b){return _.appendBlocker(b)});Promise.all(f).then(function(){a(),l.forEach(function(b){var R=h.sourceBuffer[b];(!R||!R.updating)&&_.shiftAndExecuteNext(b)})})},S.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},S.addBufferListener=function(a,l,h){var _=this.sourceBuffer[a];if(!_)return;var f=h.bind(this,a);this.listeners[a].push({event:l,listener:f}),_.addEventListener(l,f)},S.removeBufferListeners=function(a){var l=this.sourceBuffer[a];if(!l)return;this.listeners[a].forEach(function(h){l.removeEventListener(h.event,h.listener)})},x}()},"./src/controller/buffer-operation-queue.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return I});var V=D("./src/utils/logger.ts"),I=function(){function w(N){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=N}var B=w.prototype;return B.append=function(M,k){var p=this.queues[k];p.push(M),p.length===1&&this.buffers[k]&&this.executeNext(k)},B.insertAbort=function(M,k){var p=this.queues[k];p.unshift(M),this.executeNext(k)},B.appendBlocker=function(M){var k,p=new Promise(function(P){k=P}),y={execute:k,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(y,M),p},B.executeNext=function(M){var k=this.buffers,p=this.queues,y=k[M],P=p[M];if(P.length){var L=P[0];try{L.execute()}catch(x){V.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),L.onError(x),(!y||!y.updating)&&(P.shift(),this.executeNext(M))}}},B.shiftAndExecuteNext=function(M){this.queues[M].shift(),this.executeNext(M)},B.current=function(M){return this.queues[M][0]},w}()},"./src/controller/cap-level-controller.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/events.ts");function I(N,M){for(var k=0;k<M.length;k++){var p=M[k];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(N,p.key,p)}}function w(N,M,k){return M&&I(N.prototype,M),k&&I(N,k),N}var B=function(){function N(k){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=k,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var M=N.prototype;return M.setStreamController=function(p){this.streamController=p},M.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},M.registerListeners=function(){var p=this.hls;p.on(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),p.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),p.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.on(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),p.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.unregisterListener=function(){var p=this.hls;p.off(V.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),p.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),p.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),p.off(V.Events.BUFFER_CODECS,this.onBufferCodecs,this),p.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},M.onFpsDropLevelCapping=function(p,y){N.isLevelAllowed(y.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(y.droppedLevel)},M.onMediaAttaching=function(p,y){this.media=y.media instanceof HTMLVideoElement?y.media:null},M.onManifestParsed=function(p,y){var P=this.hls;this.restrictedLevels=[],this.firstLevel=y.firstLevel,P.config.capLevelToPlayerSize&&y.video&&this.startCapping()},M.onBufferCodecs=function(p,y){var P=this.hls;P.config.capLevelToPlayerSize&&y.video&&this.startCapping()},M.onMediaDetaching=function(){this.stopCapping()},M.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var p=this.hls.levels;if(p.length){var y=this.hls;y.autoLevelCapping=this.getMaxLevel(p.length-1),y.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=y.autoLevelCapping}}},M.getMaxLevel=function(p){var y=this,P=this.hls.levels;if(!P.length)return-1;var L=P.filter(function(x,S){return N.isLevelAllowed(S,y.restrictedLevels)&&S<=p});return this.clientRect=null,N.getMaxLevelByMediaSize(L,this.mediaWidth,this.mediaHeight)},M.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()},M.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},M.getDimensions=function(){if(this.clientRect)return this.clientRect;var p=this.media,y={width:0,height:0};if(p){var P=p.getBoundingClientRect();y.width=P.width,y.height=P.height,!y.width&&!y.height&&(y.width=P.right-P.left||p.width||0,y.height=P.bottom-P.top||p.height||0)}return this.clientRect=y,y},N.isLevelAllowed=function(p,y){return y===void 0&&(y=[]),y.indexOf(p)===-1},N.getMaxLevelByMediaSize=function(p,y,P){if(!p||!p.length)return-1;for(var L=function(l,h){return h?l.width!==h.width||l.height!==h.height:!0},x=p.length-1,S=0;S<p.length;S+=1){var d=p[S];if((d.width>=y||d.height>=P)&&L(d,p[S+1])){x=S;break}}return x},w(N,[{key:"mediaWidth",get:function(){return this.getDimensions().width*N.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*N.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var p=1;try{p=self.devicePixelRatio}catch(y){}return p}}]),N}();Y.default=B},"./src/controller/cmcd-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return L});var V=D("./src/events.ts"),I=D("./src/types/cmcd.ts"),w=D("./src/utils/buffer-helper.ts"),B=D("./src/utils/logger.ts");function N(x,S){for(var d=0;d<S.length;d++){var a=S[d];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(x,a.key,a)}}function M(x,S,d){return S&&N(x.prototype,S),d&&N(x,d),x}function k(x,S){var d=typeof Symbol!="undefined"&&x[Symbol.iterator]||x["@@iterator"];if(d)return(d=d.call(x)).next.bind(d);if(Array.isArray(x)||(d=p(x))||S&&x&&typeof x.length=="number"){d&&(x=d);var a=0;return function(){return a>=x.length?{done:!0}:{done:!1,value:x[a++]}}}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 p(x,S){if(!x)return;if(typeof x=="string")return y(x,S);var d=Object.prototype.toString.call(x).slice(8,-1);if(d==="Object"&&x.constructor&&(d=x.constructor.name),d==="Map"||d==="Set")return Array.from(x);if(d==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(d))return y(x,S)}function y(x,S){(S==null||S>x.length)&&(S=x.length);for(var d=0,a=new Array(S);d<S;d++)a[d]=x[d];return a}function P(){return P=Object.assign||function(x){for(var S=1;S<arguments.length;S++){var d=arguments[S];for(var a in d)Object.prototype.hasOwnProperty.call(d,a)&&(x[a]=d[a])}return x},P.apply(this,arguments)}var L=function(){function x(d){var a=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(){a.initialized&&(a.starved=!0),a.buffering=!0},this.onPlaying=function(){a.initialized||(a.initialized=!0),a.buffering=!1},this.applyPlaylistData=function(_){try{a.apply(_,{ot:I.CMCDObjectType.MANIFEST,su:!a.initialized})}catch(f){B.logger.warn("Could not generate manifest CMCD data.",f)}},this.applyFragmentData=function(_){try{var f=_.frag,b=a.hls.levels[f.level],R=a.getObjectType(f),T={d:f.duration*1e3,ot:R};(R===I.CMCDObjectType.VIDEO||R===I.CMCDObjectType.AUDIO||R==I.CMCDObjectType.MUXED)&&(T.br=b.bitrate/1e3,T.tb=a.getTopBandwidth(R),T.bl=a.getBufferLength(R)),a.apply(_,T)}catch(g){B.logger.warn("Could not generate segment CMCD data.",g)}},this.hls=d;var l=this.config=d.config,h=l.cmcd;h!=null&&(l.pLoader=this.createPlaylistLoader(),l.fLoader=this.createFragmentLoader(),this.sid=h.sessionId||x.uuid(),this.cid=h.contentId,this.useHeaders=h.useHeaders===!0,this.registerListeners())}var S=x.prototype;return S.registerListeners=function(){var a=this.hls;a.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.on(V.Events.BUFFER_CREATED,this.onBufferCreated,this)},S.unregisterListeners=function(){var a=this.hls;a.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),a.off(V.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(a,l){this.media=l.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(a,l){var h,_;this.audioBuffer=(h=l.tracks.audio)===null||h===void 0?void 0:h.buffer,this.videoBuffer=(_=l.tracks.video)===null||_===void 0?void 0:_.buffer},S.createData=function(){var a;return{v:I.CMCDVersion,sf:I.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(a=this.media)===null||a===void 0?void 0:a.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},S.apply=function(a,l){l===void 0&&(l={}),P(l,this.createData());var h=l.ot===I.CMCDObjectType.INIT||l.ot===I.CMCDObjectType.VIDEO||l.ot===I.CMCDObjectType.MUXED;if(this.starved&&h&&(l.bs=!0,l.su=!0,this.starved=!1),l.su==null&&(l.su=this.buffering),this.useHeaders){var _=x.toHeaders(l);if(!Object.keys(_).length)return;a.headers||(a.headers={}),P(a.headers,_)}else{var f=x.toQuery(l);if(!f)return;a.url=x.appendQueryToUri(a.url,f)}},S.getObjectType=function(a){var l=a.type;return l==="subtitle"?I.CMCDObjectType.TIMED_TEXT:a.sn==="initSegment"?I.CMCDObjectType.INIT:l==="audio"?I.CMCDObjectType.AUDIO:l==="main"?this.hls.audioTracks.length?I.CMCDObjectType.VIDEO:I.CMCDObjectType.MUXED:void 0},S.getTopBandwidth=function(a){for(var l=0,h=a===I.CMCDObjectType.AUDIO?this.hls.audioTracks:this.hls.levels,_=k(h),f;!(f=_()).done;){var b=f.value;b.bitrate>l&&(l=b.bitrate)}return l>0?l:NaN},S.getBufferLength=function(a){var l=this.hls.media,h=a===I.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!h||!l)return NaN;var _=w.BufferHelper.bufferInfo(h,l.currentTime,this.config.maxBufferHole);return _.len*1e3},S.createPlaylistLoader=function(){var a=this.config.pLoader,l=this.applyPlaylistData,h=a||this.config.loader;return function(){function _(b){this.loader=void 0,this.loader=new h(b)}var f=_.prototype;return f.destroy=function(){this.loader.destroy()},f.abort=function(){this.loader.abort()},f.load=function(R,T,g){l(R),this.loader.load(R,T,g)},M(_,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),_}()},S.createFragmentLoader=function(){var a=this.config.fLoader,l=this.applyFragmentData,h=a||this.config.loader;return function(){function _(b){this.loader=void 0,this.loader=new h(b)}var f=_.prototype;return f.destroy=function(){this.loader.destroy()},f.abort=function(){this.loader.abort()},f.load=function(R,T,g){l(R),this.loader.load(R,T,g)},M(_,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),_}()},x.uuid=function(){var a=URL.createObjectURL(new Blob),l=a.toString();return URL.revokeObjectURL(a),l.substr(l.lastIndexOf("/")+1)},x.serialize=function(a){for(var l=[],h=function(j){return!Number.isNaN(j)&&j!=null&&j!==""&&j!==!1},_=function(j){return Math.round(j)},f=function(j){return _(j/100)*100},b=function(j){return encodeURIComponent(j)},R={br:_,d:_,bl:f,dl:f,mtp:f,nor:b,rtp:f,tb:_},T=Object.keys(a||{}).sort(),g=k(T),c;!(c=g()).done;){var u=c.value,o=a[u];if(!h(o))continue;if(u==="v"&&o===1)continue;if(u=="pr"&&o===1)continue;var C=R[u];C&&(o=C(o));var E=typeof o,v=void 0;u==="ot"||u==="sf"||u==="st"?v=u+"="+o:E==="boolean"?v=u:E==="number"?v=u+"="+o:v=u+"="+JSON.stringify(o),l.push(v)}return l.join(",")},x.toHeaders=function(a){for(var l=Object.keys(a),h={},_=["Object","Request","Session","Status"],f=[{},{},{},{}],b={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},R=0,T=l;R<T.length;R++){var g=T[R],c=b[g]!=null?b[g]:1;f[c][g]=a[g]}for(var u=0;u<f.length;u++){var o=x.serialize(f[u]);o&&(h["CMCD-"+_[u]]=o)}return h},x.toQuery=function(a){return"CMCD="+encodeURIComponent(x.serialize(a))},x.appendQueryToUri=function(a,l){if(!l)return a;var h=a.includes("?")?"&":"?";return""+a+h+l},x}()},"./src/controller/eme-controller.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/events.ts"),I=D("./src/errors.ts"),w=D("./src/utils/logger.ts"),B=D("./src/utils/mediakeys-helper.ts");function N(L,x){for(var S=0;S<x.length;S++){var d=x[S];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(L,d.key,d)}}function M(L,x,S){return x&&N(L.prototype,x),S&&N(L,S),L}var k=3,p=function(x,S,d){var a={audioCapabilities:[],videoCapabilities:[]};return x.forEach(function(l){a.audioCapabilities.push({contentType:'audio/mp4; codecs="'+l+'"',robustness:d.audioRobustness||""})}),S.forEach(function(l){a.videoCapabilities.push({contentType:'video/mp4; codecs="'+l+'"',robustness:d.videoRobustness||""})}),[a]},y=function(x,S,d,a){switch(x){case B.KeySystems.WIDEVINE:return p(S,d,a);default:throw new Error("Unknown key-system: "+x)}},P=function(){function L(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 x=L.prototype;return x.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},x._registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},x._unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(V.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this)},x.getLicenseServerUrl=function(d){switch(d){case B.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+d+'"')},x._attemptKeySystemAccess=function(d,a,l){var h=this,_=y(d,a,l,this._drmSystemOptions);w.logger.log("Requesting encrypted media key-system access");var f=this.requestMediaKeySystemAccess(d,_);this.mediaKeysPromise=f.then(function(b){return h._onMediaKeySystemAccessObtained(d,b)}),f.catch(function(b){w.logger.error('Failed to obtain key-system "'+d+'" access:',b)})},x._onMediaKeySystemAccessObtained=function(d,a){var l=this;w.logger.log('Access for key-system "'+d+'" obtained');var h={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:a,mediaKeySystemDomain:d};this._mediaKeysList.push(h);var _=Promise.resolve().then(function(){return a.createMediaKeys()}).then(function(f){return h.mediaKeys=f,w.logger.log('Media-keys created for key-system "'+d+'"'),l._onMediaKeysCreated(),f});return _.catch(function(f){w.logger.error("Failed to create media-keys:",f)}),_},x._onMediaKeysCreated=function(){var d=this;this._mediaKeysList.forEach(function(a){a.mediaKeysSession||(a.mediaKeysSession=a.mediaKeys.createSession(),d._onNewMediaKeySession(a.mediaKeysSession))})},x._onNewMediaKeySession=function(d){var a=this;w.logger.log("New key-system session "+d.sessionId),d.addEventListener("message",function(l){a._onKeySessionMessage(d,l.message)},!1)},x._onKeySessionMessage=function(d,a){w.logger.log("Got EME message event, creating license request"),this._requestLicense(a,function(l){w.logger.log("Received license data (length: "+(l&&l.byteLength)+"), updating key-session"),d.update(l)})},x.onMediaEncrypted=function(d){var a=this;if(w.logger.log('Media is encrypted using "'+d.initDataType+'" init data type'),!this.mediaKeysPromise){w.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var l=function(_){if(!a._media)return;a._attemptSetMediaKeys(_),a._generateRequestWithPreferredKeySession(d.initDataType,d.initData)};this.mediaKeysPromise.then(l).catch(l)},x._attemptSetMediaKeys=function(d){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var a=this._mediaKeysList[0];if(!a||!a.mediaKeys){w.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}w.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(a.mediaKeys),this._hasSetMediaKeys=!0}},x._generateRequestWithPreferredKeySession=function(d,a){var l=this,h=this._mediaKeysList[0];if(!h){w.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(h.mediaKeysSessionInitialized){w.logger.warn("Key-Session already initialized but requested again");return}var _=h.mediaKeysSession;if(!_){w.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!a){w.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}w.logger.log('Generating key-session request for "'+d+'" init data type'),h.mediaKeysSessionInitialized=!0,_.generateRequest(d,a).then(function(){w.logger.debug("Key-session generation succeeded")}).catch(function(f){w.logger.error("Error generating key-session request:",f),l.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},x._createLicenseXhr=function(d,a,l){var h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,h,d,a,l);var _=this._licenseXhrSetup;if(_)try{_.call(this.hls,h,d),_=void 0}catch(f){w.logger.error(f)}try{h.readyState||h.open("POST",d,!0),_&&_.call(this.hls,h,d)}catch(f){throw new Error("issue setting up KeySystem license XHR "+f)}return h},x._onLicenseRequestReadyStageChange=function(d,a,l,h){switch(d.readyState){case 4:if(d.status===200){this._requestLicenseFailureCount=0,w.logger.log("License request succeeded");var _=d.response,f=this._licenseResponseCallback;if(f)try{_=f.call(this.hls,d,a)}catch(R){w.logger.error(R)}h(_)}else{if(w.logger.error("License Request XHR failed ("+a+"). Status: "+d.status+" ("+d.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>k){this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var b=k-this._requestLicenseFailureCount+1;w.logger.warn("Retrying license request, "+b+" attempts left"),this._requestLicense(l,h)}break}},x._generateLicenseRequestChallenge=function(d,a){switch(d.mediaKeySystemDomain){case B.KeySystems.WIDEVINE:return a}throw new Error("unsupported key-system: "+d.mediaKeySystemDomain)},x._requestLicense=function(d,a){w.logger.log("Requesting content license for key-system");var l=this._mediaKeysList[0];if(!l){w.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var h=this.getLicenseServerUrl(l.mediaKeySystemDomain),_=this._createLicenseXhr(h,d,a);w.logger.log("Sending license request to URL: "+h);var f=this._generateLicenseRequestChallenge(l,d);_.send(f)}catch(b){w.logger.error("Failure requesting DRM license: "+b),this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.KEY_SYSTEM_ERROR,details:I.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},x.onMediaAttached=function(d,a){if(!this._emeEnabled)return;var l=a.media;this._media=l,l.addEventListener("encrypted",this._onMediaEncrypted)},x.onMediaDetached=function(){var d=this._media,a=this._mediaKeysList;if(!d)return;d.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(a.map(function(l){if(l.mediaKeysSession)return l.mediaKeysSession.close().catch(function(){})})).then(function(){return d.setMediaKeys(null)}).catch(function(){})},x.onManifestParsed=function(d,a){if(!this._emeEnabled)return;var l=a.levels.map(function(_){return _.audioCodec}).filter(function(_){return!!_}),h=a.levels.map(function(_){return _.videoCodec}).filter(function(_){return!!_});this._attemptKeySystemAccess(B.KeySystems.WIDEVINE,l,h)},M(L,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),L}();Y.default=P},"./src/controller/fps-controller.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/events.ts"),I=D("./src/utils/logger.ts"),w=function(){function B(M){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=M,this.registerListeners()}var N=B.prototype;return N.setStreamController=function(k){this.streamController=k},N.registerListeners=function(){this.hls.on(V.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},N.unregisterListeners=function(){this.hls.off(V.Events.MEDIA_ATTACHING,this.onMediaAttaching)},N.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},N.onMediaAttaching=function(k,p){var y=this.hls.config;if(y.capLevelOnFPSDrop){var P=p.media instanceof self.HTMLVideoElement?p.media:null;this.media=P,P&&typeof P.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),y.fpsDroppedMonitoringPeriod)}},N.checkFPS=function(k,p,y){var P=performance.now();if(p){if(this.lastTime){var L=P-this.lastTime,x=y-this.lastDroppedFrames,S=p-this.lastDecodedFrames,d=1e3*x/L,a=this.hls;if(a.trigger(V.Events.FPS_DROP,{currentDropped:x,currentDecoded:S,totalDroppedFrames:y}),d>0&&x>a.config.fpsDroppedMonitoringThreshold*S){var l=a.currentLevel;I.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(a.autoLevelCapping===-1||a.autoLevelCapping>=l)&&(l=l-1,a.trigger(V.Events.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:a.currentLevel}),a.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=P,this.lastDroppedFrames=y,this.lastDecodedFrames=p}},N.checkFPSInterval=function(){var k=this.media;if(k)if(this.isVideoPlaybackQualityAvailable){var p=k.getVideoPlaybackQuality();this.checkFPS(k,p.totalVideoFrames,p.droppedVideoFrames)}else this.checkFPS(k,k.webkitDecodedFrameCount,k.webkitDroppedFrameCount)},B}();Y.default=w},"./src/controller/fragment-finders.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"findFragmentByPDT",function(){return w}),D.d(Y,"findFragmentByPTS",function(){return B}),D.d(Y,"fragmentWithinToleranceTest",function(){return N}),D.d(Y,"pdtWithinToleranceTest",function(){return M}),D.d(Y,"findFragWithCC",function(){return k});var V=D("./src/polyfills/number.ts"),I=D("./src/utils/binary-search.ts");function w(p,y,P){if(y===null||!Array.isArray(p)||!p.length||!Object(V.isFiniteNumber)(y))return null;var L=p[0].programDateTime;if(y<(L||0))return null;var x=p[p.length-1].endProgramDateTime;if(y>=(x||0))return null;P=P||0;for(var S=0;S<p.length;++S){var d=p[S];if(M(y,P,d))return d}return null}function B(p,y,P,L){P===void 0&&(P=0),L===void 0&&(L=0);var x=null;if(p?x=y[p.sn-y[0].sn+1]||null:P===0&&y[0].start===0&&(x=y[0]),x&&N(P,L,x)===0)return x;var S=I.default.search(y,N.bind(null,P,L));return S||x}function N(p,y,P){p===void 0&&(p=0),y===void 0&&(y=0);var L=Math.min(y,P.duration+(P.deltaPTS?P.deltaPTS:0));return P.start+P.duration-L<=p?1:P.start-L>p&&P.start?-1:0}function M(p,y,P){var L=Math.min(y,P.duration+(P.deltaPTS?P.deltaPTS:0))*1e3,x=P.endProgramDateTime||0;return x-L>p}function k(p,y){return I.default.search(p,function(P){return P.cc<y?1:P.cc>y?-1:0})}},"./src/controller/fragment-tracker.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"FragmentState",function(){return w}),D.d(Y,"FragmentTracker",function(){return B});var V=D("./src/events.ts"),I=D("./src/types/loader.ts"),w;(function(k){k.NOT_LOADED="NOT_LOADED",k.BACKTRACKED="BACKTRACKED",k.APPENDING="APPENDING",k.PARTIAL="PARTIAL",k.OK="OK"})(w||(w={}));var B=function(){function k(y){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=y,this._registerListeners()}var p=k.prototype;return p._registerListeners=function(){var P=this.hls;P.on(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),P.on(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),P.on(V.Events.FRAG_LOADED,this.onFragLoaded,this)},p._unregisterListeners=function(){var P=this.hls;P.off(V.Events.BUFFER_APPENDED,this.onBufferAppended,this),P.off(V.Events.FRAG_BUFFERED,this.onFragBuffered,this),P.off(V.Events.FRAG_LOADED,this.onFragLoaded,this)},p.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},p.getAppendedFrag=function(P,L){if(L===I.PlaylistLevelType.MAIN){var x=this.activeFragment,S=this.activeParts;if(!x)return null;if(S)for(var d=S.length;d--;){var a=S[d],l=a?a.end:x.appendedPTS;if(a.start<=P&&l!==void 0&&P<=l)return d>9&&(this.activeParts=S.slice(d-9)),a}else if(x.start<=P&&x.appendedPTS!==void 0&&P<=x.appendedPTS)return x}return this.getBufferedFrag(P,L)},p.getBufferedFrag=function(P,L){for(var x=this.fragments,S=Object.keys(x),d=S.length;d--;){var a=x[S[d]];if((a==null?void 0:a.body.type)===L&&a.buffered){var l=a.body;if(l.start<=P&&P<=l.end)return l}}return null},p.detectEvictedFragments=function(P,L,x){var S=this;Object.keys(this.fragments).forEach(function(d){var a=S.fragments[d];if(!a)return;if(!a.buffered){a.body.type===x&&S.removeFragment(a.body);return}var l=a.range[P];if(!l)return;l.time.some(function(h){var _=!S.isTimeBuffered(h.startPTS,h.endPTS,L);return _&&S.removeFragment(a.body),_})})},p.detectPartialFragments=function(P){var L=this,x=this.timeRanges,S=P.frag,d=P.part;if(!x||S.sn==="initSegment")return;var a=M(S),l=this.fragments[a];if(!l)return;Object.keys(x).forEach(function(h){var _=S.elementaryStreams[h];if(!_)return;var f=x[h],b=d!==null||_.partial===!0;l.range[h]=L.getBufferedTimes(S,d,b,f)}),l.backtrack=l.loaded=null,Object.keys(l.range).length?l.buffered=!0:this.removeFragment(l.body)},p.fragBuffered=function(P){var L=M(P),x=this.fragments[L];x&&(x.backtrack=x.loaded=null,x.buffered=!0)},p.getBufferedTimes=function(P,L,x,S){for(var d={time:[],partial:x},a=L?L.start:P.start,l=L?L.end:P.end,h=P.minEndPTS||l,_=P.maxStartPTS||a,f=0;f<S.length;f++){var b=S.start(f)-this.bufferPadding,R=S.end(f)+this.bufferPadding;if(_>=b&&h<=R){d.time.push({startPTS:Math.max(a,S.start(f)),endPTS:Math.min(l,S.end(f))});break}else if(a<R&&l>b)d.partial=!0,d.time.push({startPTS:Math.max(a,S.start(f)),endPTS:Math.min(l,S.end(f))});else if(l<=b)break}return d},p.getPartialFragment=function(P){var L=null,x,S,d,a=0,l=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach(function(_){var f=h[_];if(!f)return;N(f)&&(S=f.body.start-l,d=f.body.end+l,P>=S&&P<=d&&(x=Math.min(P-S,d-P),a<=x&&(L=f.body,a=x)))}),L},p.getState=function(P){var L=M(P),x=this.fragments[L];return x?x.buffered?N(x)?w.PARTIAL:w.OK:x.backtrack?w.BACKTRACKED:w.APPENDING:w.NOT_LOADED},p.backtrack=function(P,L){var x=M(P),S=this.fragments[x];if(!S||S.backtrack)return null;var d=S.backtrack=L||S.loaded;return S.loaded=null,d},p.getBacktrackData=function(P){var L=M(P),x=this.fragments[L];if(x){var S,d=x.backtrack;if(d!=null&&(S=d.payload)!==null&&S!==void 0&&S.byteLength)return d;this.removeFragment(P)}return null},p.isTimeBuffered=function(P,L,x){for(var S,d,a=0;a<x.length;a++){if(S=x.start(a)-this.bufferPadding,d=x.end(a)+this.bufferPadding,P>=S&&L<=d)return!0;if(L<=S)return!1}return!1},p.onFragLoaded=function(P,L){var x=L.frag,S=L.part;if(x.sn==="initSegment"||x.bitrateTest||S)return;var d=M(x);this.fragments[d]={body:x,loaded:L,backtrack:null,buffered:!1,range:Object.create(null)}},p.onBufferAppended=function(P,L){var x=this,S=L.frag,d=L.part,a=L.timeRanges;if(S.type===I.PlaylistLevelType.MAIN)if(this.activeFragment=S,d){var l=this.activeParts;l||(this.activeParts=l=[]),l.push(d)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(h){var _=a[h];if(x.detectEvictedFragments(h,_),!d)for(var f=0;f<_.length;f++)S.appendedPTS=Math.max(_.end(f),S.appendedPTS||0)})},p.onFragBuffered=function(P,L){this.detectPartialFragments(L)},p.hasFragment=function(P){var L=M(P);return!!this.fragments[L]},p.removeFragmentsInRange=function(P,L,x){var S=this;Object.keys(this.fragments).forEach(function(d){var a=S.fragments[d];if(!a)return;if(a.buffered){var l=a.body;l.type===x&&l.start<L&&l.end>P&&S.removeFragment(l)}})},p.removeFragment=function(P){var L=M(P);P.stats.loaded=0,P.clearElementaryStreamInfo(),delete this.fragments[L]},p.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},k}();function N(k){var p,y;return k.buffered&&(((p=k.range.video)===null||p===void 0?void 0:p.partial)||((y=k.range.audio)===null||y===void 0?void 0:y.partial))}function M(k){return k.type+"_"+k.level+"_"+k.urlId+"_"+k.sn}},"./src/controller/gap-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"STALL_MINIMUM_DURATION_MS",function(){return N}),D.d(Y,"MAX_START_GAP_JUMP",function(){return M}),D.d(Y,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return k}),D.d(Y,"SKIP_BUFFER_RANGE_START",function(){return p}),D.d(Y,"default",function(){return y});var V=D("./src/utils/buffer-helper.ts"),I=D("./src/errors.ts"),w=D("./src/events.ts"),B=D("./src/utils/logger.ts"),N=250,M=2,k=.1,p=.05,y=function(){function P(x,S,d,a){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=x,this.media=S,this.fragmentTracker=d,this.hls=a}var L=P.prototype;return L.destroy=function(){this.hls=this.fragmentTracker=this.media=null},L.poll=function(S){var d=this.config,a=this.media,l=this.stalled,h=a.currentTime,_=a.seeking,f=this.seeking&&!_,b=!this.seeking&&_;if(this.seeking=_,h!==S){if(this.moved=!0,l!==null){if(this.stallReported){var R=self.performance.now()-l;B.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(R)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((b||f)&&(this.stalled=null),a.paused||a.ended||a.playbackRate===0||!V.BufferHelper.getBuffered(a).length)return;var T=V.BufferHelper.bufferInfo(a,h,0),g=T.len>0,c=T.nextStart||0;if(!g&&!c)return;if(_){var u=T.len>M,o=!c||c-h>M&&!this.fragmentTracker.getPartialFragment(h);if(u||o)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var C,E=Math.max(c,T.start||0)-h,v=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,O=v==null||((C=v.details)===null||C===void 0)?void 0:C.live,j=O?v.details.targetduration*2:M;if(E>0&&E<=j){this._trySkipBufferHole(null);return}}var G=self.performance.now();if(l===null){this.stalled=G;return}var J=G-l;!_&&J>=N&&this._reportStall(T.len);var K=V.BufferHelper.bufferInfo(a,h,d.maxBufferHole);this._tryFixBufferStall(K,J)},L._tryFixBufferStall=function(S,d){var a=this.config,l=this.fragmentTracker,h=this.media,_=h.currentTime,f=l.getPartialFragment(_);if(f){var b=this._trySkipBufferHole(f);if(b)return}S.len>a.maxBufferHole&&d>a.highBufferWatchdogPeriod*1e3&&(B.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},L._reportStall=function(S){var d=this.hls,a=this.media,l=this.stallReported;l||(this.stallReported=!0,B.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer (buffer="+S+")"),d.trigger(w.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:S}))},L._trySkipBufferHole=function(S){for(var d=this.config,a=this.hls,l=this.media,h=l.currentTime,_=0,f=V.BufferHelper.getBuffered(l),b=0;b<f.length;b++){var R=f.start(b);if(h+d.maxBufferHole>=_&&h<R){var T=Math.max(R+p,l.currentTime+k);return B.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+T),this.moved=!0,this.stalled=null,l.currentTime=T,S&&a.trigger(w.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+T,frag:S}),T}_=f.end(b)}return 0},L._tryNudgeBuffer=function(){var S=this.config,d=this.hls,a=this.media,l=a.currentTime,h=(this.nudgeRetry||0)+1;if(this.nudgeRetry=h,h<S.nudgeMaxRetry){var _=l+h*S.nudgeOffset;B.logger.warn("Nudging 'currentTime' from "+l+" to "+_),a.currentTime=_,d.trigger(w.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else B.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+S.nudgeMaxRetry+" nudges"),d.trigger(w.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},P}()},"./src/controller/id3-track-controller.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/events.ts"),I=D("./src/utils/texttrack-utils.ts"),w=D("./src/demux/id3.ts"),B=.25,N=function(){function M(p){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=p,this._registerListeners()}var k=M.prototype;return k.destroy=function(){this._unregisterListeners()},k._registerListeners=function(){var y=this.hls;y.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),y.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),y.on(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),y.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},k._unregisterListeners=function(){var y=this.hls;y.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),y.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),y.off(V.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),y.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},k.onMediaAttached=function(y,P){this.media=P.media},k.onMediaDetaching=function(){if(!this.id3Track)return;Object(I.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null},k.getID3Track=function(y){if(!this.media)return;for(var P=0;P<y.length;P++){var L=y[P];if(L.kind==="metadata"&&L.label==="id3")return Object(I.sendAddTrackEvent)(L,this.media),L}return this.media.addTextTrack("metadata","id3")},k.onFragParsingMetadata=function(y,P){if(!this.media)return;var L=P.frag,x=P.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var S=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,d=0;d<x.length;d++){var a=w.getID3Frames(x[d].data);if(a){var l=x[d].pts,h=d<x.length-1?x[d+1].pts:L.end,_=h-l;_<=0&&(h=l+B);for(var f=0;f<a.length;f++){var b=a[f];if(!w.isTimeStampFrame(b)){var R=new S(l,h,"");R.value=b,this.id3Track.addCue(R)}}}}},k.onBufferFlushing=function(y,P){var L=P.startOffset,x=P.endOffset,S=P.type;if(!S||S==="audio"){var d=this.id3Track;d&&Object(I.removeCuesInRange)(d,L,x)}},M}();Y.default=N},"./src/controller/latency-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return M});var V=D("./src/errors.ts"),I=D("./src/events.ts"),w=D("./src/utils/logger.ts");function B(k,p){for(var y=0;y<p.length;y++){var P=p[y];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(k,P.key,P)}}function N(k,p,y){return p&&B(k.prototype,p),y&&B(k,y),k}var M=function(){function k(y){var P=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 P.timeupdate()},this.hls=y,this.config=y.config,this.registerListeners()}var p=k.prototype;return p.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},p.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)},p.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)},p.onMediaAttached=function(P,L){this.media=L.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},p.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},p.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},p.onLevelUpdated=function(P,L){var x=L.details;this.levelDetails=x,x.advanced&&this.timeupdate(),!x.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},p.onError=function(P,L){if(L.details!==V.ErrorDetails.BUFFER_STALLED_ERROR)return;this.stallCount++,w.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")},p.timeupdate=function(){var P=this.media,L=this.levelDetails;if(!P||!L)return;this.currentTime=P.currentTime;var x=this.computeLatency();if(x===null)return;this._latency=x;var S=this.config,d=S.lowLatencyMode,a=S.maxLiveSyncPlaybackRate;if(!d||a===1)return;var l=this.targetLatency;if(l===null)return;var h=x-l,_=Math.min(this.maxLatency,l+L.targetduration),f=h<_;if(L.live&&f&&h>.05&&this.forwardBufferLength>1){var b=Math.min(2,Math.max(1,a)),R=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;P.playbackRate=Math.min(b,Math.max(1,R))}else P.playbackRate!==1&&P.playbackRate!==0&&(P.playbackRate=1)},p.estimateLiveEdge=function(){var P=this.levelDetails;return P===null?null:P.edge+P.age},p.computeLatency=function(){var P=this.estimateLiveEdge();return P===null?null:P-this.currentTime},N(k,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var P=this.config,L=this.levelDetails;return P.liveMaxLatencyDuration!==void 0?P.liveMaxLatencyDuration:L?P.liveMaxLatencyDurationCount*L.targetduration:0}},{key:"targetLatency",get:function(){var P=this.levelDetails;if(P===null)return null;var L=P.holdBack,x=P.partHoldBack,S=P.targetduration,d=this.config,a=d.liveSyncDuration,l=d.liveSyncDurationCount,h=d.lowLatencyMode,_=this.hls.userConfig,f=h&&x||L;(_.liveSyncDuration||_.liveSyncDurationCount||f===0)&&(f=a!==void 0?a:l*S);var b=S,R=1;return f+Math.min(this.stallCount*R,b)}},{key:"liveSyncPosition",get:function(){var P=this.estimateLiveEdge(),L=this.targetLatency,x=this.levelDetails;if(P===null||L===null||x===null)return null;var S=x.edge,d=P-L-this.edgeStalled,a=S-x.totalduration,l=S-(this.config.lowLatencyMode&&x.partTarget||x.targetduration);return Math.min(Math.max(a,d),l)}},{key:"drift",get:function(){var P=this.levelDetails;return P===null?1:P.drift}},{key:"edgeStalled",get:function(){var P=this.levelDetails;if(P===null)return 0;var L=(this.config.lowLatencyMode&&P.partTarget||P.targetduration)*3;return Math.max(P.age-L,0)}},{key:"forwardBufferLength",get:function(){var P=this.media,L=this.levelDetails;if(!P||!L)return 0;var x=P.buffered.length;return x?P.buffered.end(x-1):L.edge-this.currentTime}}]),k}()},"./src/controller/level-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return d});var V=D("./src/types/level.ts"),I=D("./src/events.ts"),w=D("./src/errors.ts"),B=D("./src/utils/codecs.ts"),N=D("./src/controller/level-helper.ts"),M=D("./src/controller/base-playlist-controller.ts"),k=D("./src/types/loader.ts");function p(){return p=Object.assign||function(a){for(var l=1;l<arguments.length;l++){var h=arguments[l];for(var _ in h)Object.prototype.hasOwnProperty.call(h,_)&&(a[_]=h[_])}return a},p.apply(this,arguments)}function y(a,l){for(var h=0;h<l.length;h++){var _=l[h];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(a,_.key,_)}}function P(a,l,h){return l&&y(a.prototype,l),h&&y(a,h),a}function L(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,x(a,l)}function x(a,l){return x=Object.setPrototypeOf||function(_,f){return _.__proto__=f,_},x(a,l)}var S=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(a){L(l,a);function l(_){var f;return f=a.call(this,_,"[level-controller]")||this,f._levels=[],f._firstLevel=-1,f._startLevel=void 0,f.currentLevelIndex=-1,f.manualLevelIndex=-1,f.onParsedComplete=void 0,f._registerListeners(),f}var h=l.prototype;return h._registerListeners=function(){var f=this.hls;f.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(I.Events.ERROR,this.onError,this)},h._unregisterListeners=function(){var f=this.hls;f.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),f.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),f.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),f.off(I.Events.ERROR,this.onError,this)},h.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,a.prototype.destroy.call(this)},h.startLoad=function(){var f=this._levels;f.forEach(function(b){b.loadError=0}),a.prototype.startLoad.call(this)},h.onManifestLoaded=function(f,b){var R=[],T=[],g=[],c,u={},o,C=!1,E=!1,v=!1;if(b.levels.forEach(function(J){var K=J.attrs;C=C||!!(J.width&&J.height),E=E||!!J.videoCodec,v=v||!!J.audioCodec,S&&J.audioCodec&&J.audioCodec.indexOf("mp4a.40.34")!==-1&&(J.audioCodec=void 0);var F=J.bitrate+"-"+J.attrs.RESOLUTION+"-"+J.attrs.CODECS;o=u[F],o?o.url.push(J.url):(o=new V.Level(J),u[F]=o,R.push(o)),K&&(K.AUDIO&&Object(N.addGroupId)(o,"audio",K.AUDIO),K.SUBTITLES&&Object(N.addGroupId)(o,"text",K.SUBTITLES))}),(C||E)&&v&&(R=R.filter(function(J){var K=J.videoCodec,F=J.width,ee=J.height;return!!K||!!(F&&ee)})),R=R.filter(function(J){var K=J.audioCodec,F=J.videoCodec;return(!K||Object(B.isCodecSupportedInMp4)(K,"audio"))&&(!F||Object(B.isCodecSupportedInMp4)(F,"video"))}),b.audioTracks&&(T=b.audioTracks.filter(function(J){return!J.audioCodec||Object(B.isCodecSupportedInMp4)(J.audioCodec,"audio")}),Object(N.assignTrackIdsByGroup)(T)),b.subtitles&&(g=b.subtitles,Object(N.assignTrackIdsByGroup)(g)),R.length>0){c=R[0].bitrate,R.sort(function(J,K){return J.bitrate-K.bitrate}),this._levels=R;for(var O=0;O<R.length;O++)if(R[O].bitrate===c){this._firstLevel=O,this.log("manifest loaded, "+R.length+" level(s) found, first bitrate: "+c);break}var j=v&&!E,G={levels:R,audioTracks:T,subtitleTracks:g,firstLevel:this._firstLevel,stats:b.stats,audio:v,video:E,altAudio:!j&&T.some(function(J){return!!J.url})};this.hls.trigger(I.Events.MANIFEST_PARSED,G),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(I.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:b.url,reason:"no level with compatible codecs found in manifest"})},h.onError=function(f,b){if(a.prototype.onError.call(this,f,b),b.fatal)return;var R=b.context,T=this._levels[this.currentLevelIndex];if(R&&(R.type===k.PlaylistContextType.AUDIO_TRACK&&T.audioGroupIds&&R.groupId===T.audioGroupIds[T.urlId]||R.type===k.PlaylistContextType.SUBTITLE_TRACK&&T.textGroupIds&&R.groupId===T.textGroupIds[T.urlId])){this.redundantFailover(this.currentLevelIndex);return}var g=!1,c=!0,u;switch(b.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:if(b.frag){var o=this._levels[b.frag.level];o?(o.fragmentError++,o.fragmentError>this.hls.config.fragLoadingMaxRetry&&(u=b.frag.level)):u=b.frag.level}break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:R&&(R.deliveryDirectives&&(c=!1),u=R.level),g=!0;break;case w.ErrorDetails.REMUX_ALLOC_ERROR:u=b.level,g=!0;break}u!==void 0&&this.recoverLevel(b,u,g,c)},h.recoverLevel=function(f,b,R,T){var g=f.details,c=this._levels[b];if(c.loadError++,R){var u=this.retryLoadingOrFail(f);if(u)f.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(T){var o=c.url.length;if(o>1&&c.loadError<o)f.levelRetry=!0,this.redundantFailover(b);else if(this.manualLevelIndex===-1){var C=b===0?this._levels.length-1:b-1;this.currentLevelIndex!==C&&this._levels[C].loadError===0&&(this.warn(g+": switch to "+C),f.levelRetry=!0,this.hls.nextAutoLevel=C)}}},h.redundantFailover=function(f){var b=this._levels[f],R=b.url.length;if(R>1){var T=(b.urlId+1)%R;this.warn("Switching to redundant URL-id "+T),this._levels.forEach(function(g){g.urlId=T}),this.level=f}},h.onFragLoaded=function(f,b){var R=b.frag;if(R!==void 0&&R.type===k.PlaylistLevelType.MAIN){var T=this._levels[R.level];T!==void 0&&(T.fragmentError=0,T.loadError=0)}},h.onLevelLoaded=function(f,b){var R,T=b.level,g=b.details,c=this._levels[T];if(!c){var u;this.warn("Invalid level index "+T),(u=b.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(g.deltaUpdateFailed=!0);return}T===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(T,b,c.details)):(R=b.deliveryDirectives)!==null&&R!==void 0&&R.skip&&(g.deltaUpdateFailed=!0)},h.onAudioTrackSwitched=function(f,b){var R=this.hls.levels[this.currentLevelIndex];if(!R)return;if(R.audioGroupIds){for(var T=-1,g=this.hls.audioTracks[b.id].groupId,c=0;c<R.audioGroupIds.length;c++)if(R.audioGroupIds[c]===g){T=c;break}T!==R.urlId&&(R.urlId=T,this.startLoad())}},h.loadPlaylist=function(f){var b=this.currentLevelIndex,R=this._levels[b];if(this.canLoad&&R&&R.url.length>0){var T=R.urlId,g=R.url[T];if(f)try{g=f.addDirectives(g)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Attempt loading level index "+b+(f?" at sn "+f.msn+" part "+f.part:"")+" with URL-id "+T+" "+g),this.clearTimer(),this.hls.trigger(I.Events.LEVEL_LOADING,{url:g,level:b,id:T,deliveryDirectives:f||null})}},h.removeLevel=function(f,b){var R=function(c,u){return u!==b},T=this._levels.filter(function(g,c){return c!==f?!0:g.url.length>1&&b!==void 0?(g.url=g.url.filter(R),g.audioGroupIds&&(g.audioGroupIds=g.audioGroupIds.filter(R)),g.textGroupIds&&(g.textGroupIds=g.textGroupIds.filter(R)),g.urlId=0,!0):!1}).map(function(g,c){var u=g.details;return u!=null&&u.fragments&&u.fragments.forEach(function(o){o.level=c}),g});this._levels=T,this.hls.trigger(I.Events.LEVELS_UPDATED,{levels:T})},P(l,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(f){var b,R=this._levels;if(R.length===0)return;if(this.currentLevelIndex===f&&(b=R[f])!==null&&b!==void 0&&b.details)return;if(f<0||f>=R.length){var T=f<0;if(this.hls.trigger(I.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.LEVEL_SWITCH_ERROR,level:f,fatal:T,reason:"invalid level idx"}),T)return;f=Math.min(f,R.length-1)}this.clearTimer();var g=this.currentLevelIndex,c=R[g],u=R[f];this.log("switching to level "+f+" from "+g),this.currentLevelIndex=f;var o=p({},u,{level:f,maxBitrate:u.maxBitrate,uri:u.uri,urlId:u.urlId});delete o._urlId,this.hls.trigger(I.Events.LEVEL_SWITCHING,o);var C=u.details;if(!C||C.live){var E=this.switchParams(u.uri,c==null?void 0:c.details);this.loadPlaylist(E)}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(f){this.manualLevelIndex=f,this._startLevel===void 0&&(this._startLevel=f),f!==-1&&(this.level=f)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(f){this._firstLevel=f}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var f=this.hls.config.startLevel;return f!==void 0?f:this._firstLevel}else return this._startLevel},set:function(f){this._startLevel=f}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(f){this.level=f,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=f)}}]),l}(M.default)},"./src/controller/level-helper.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"addGroupId",function(){return w}),D.d(Y,"assignTrackIdsByGroup",function(){return B}),D.d(Y,"updatePTS",function(){return N}),D.d(Y,"updateFragPTSDTS",function(){return k}),D.d(Y,"mergeDetails",function(){return p}),D.d(Y,"mapPartIntersection",function(){return y}),D.d(Y,"mapFragmentIntersection",function(){return P}),D.d(Y,"adjustSliding",function(){return L}),D.d(Y,"addSliding",function(){return x}),D.d(Y,"computeReloadInterval",function(){return S}),D.d(Y,"getFragmentWithSN",function(){return d}),D.d(Y,"getPartWith",function(){return a});var V=D("./src/polyfills/number.ts"),I=D("./src/utils/logger.ts");function w(l,h,_){switch(h){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(_);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(_);break}}function B(l){var h={};l.forEach(function(_){var f=_.groupId||"";_.id=h[f]=h[f]||0,h[f]++})}function N(l,h,_){var f=l[h],b=l[_];M(f,b)}function M(l,h){var _=h.startPTS;if(Object(V.isFiniteNumber)(_)){var f=0,b;h.sn>l.sn?(f=_-l.start,b=l):(f=l.start-_,b=h),b.duration!==f&&(b.duration=f)}else if(h.sn>l.sn){var R=l.cc===h.cc;R&&l.minEndPTS?h.start=l.start+(l.minEndPTS-l.start):h.start=l.start+l.duration}else h.start=Math.max(l.start-h.duration,0)}function k(l,h,_,f,b,R){var T=f-_;T<=0&&(I.logger.warn("Fragment should have a positive duration",h),f=_+h.duration,R=b+h.duration);var g=_,c=f,u=h.startPTS,o=h.endPTS;if(Object(V.isFiniteNumber)(u)){var C=Math.abs(u-_);Object(V.isFiniteNumber)(h.deltaPTS)?h.deltaPTS=Math.max(C,h.deltaPTS):h.deltaPTS=C,g=Math.max(_,u),_=Math.min(_,u),b=Math.min(b,h.startDTS),c=Math.min(f,o),f=Math.max(f,o),R=Math.max(R,h.endDTS)}h.duration=f-_;var E=_-h.start;h.appendedPTS=f,h.start=h.startPTS=_,h.maxStartPTS=g,h.startDTS=b,h.endPTS=f,h.minEndPTS=c,h.endDTS=R;var v=h.sn;if(!l||v<l.startSN||v>l.endSN)return 0;var O,j=v-l.startSN,G=l.fragments;for(G[j]=h,O=j;O>0;O--)M(G[O],G[O-1]);for(O=j;O<G.length-1;O++)M(G[O],G[O+1]);return l.fragmentHint&&M(G[G.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,E}function p(l,h){for(var _=null,f=l.fragments,b=f.length-1;b>=0;b--){var R=f[b].initSegment;if(R){_=R;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var T=0,g;if(P(l,h,function(O,j){O.relurl&&(T=O.cc-j.cc),Object(V.isFiniteNumber)(O.startPTS)&&Object(V.isFiniteNumber)(O.endPTS)&&(j.start=j.startPTS=O.startPTS,j.startDTS=O.startDTS,j.appendedPTS=O.appendedPTS,j.maxStartPTS=O.maxStartPTS,j.endPTS=O.endPTS,j.endDTS=O.endDTS,j.minEndPTS=O.minEndPTS,j.duration=O.endPTS-O.startPTS,j.duration&&(g=j),h.PTSKnown=h.alignedSliding=!0),j.elementaryStreams=O.elementaryStreams,j.loader=O.loader,j.stats=O.stats,j.urlId=O.urlId,O.initSegment&&(j.initSegment=O.initSegment,_=O.initSegment)}),_){var c=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments;c.forEach(function(O){var j;(!O.initSegment||O.initSegment.relurl===((j=_)===null||j===void 0?void 0:j.relurl))&&(O.initSegment=_)})}if(h.skippedSegments&&(h.deltaUpdateFailed=h.fragments.some(function(O){return!O}),h.deltaUpdateFailed)){I.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=h.skippedSegments;u--;)h.fragments.shift();h.startSN=h.fragments[0].sn,h.startCC=h.fragments[0].cc}var o=h.fragments;if(T){I.logger.warn("discontinuity sliding from playlist, take drift into account");for(var C=0;C<o.length;C++)o[C].cc+=T}h.skippedSegments&&(h.startCC=h.fragments[0].cc),y(l.partList,h.partList,function(O,j){j.elementaryStreams=O.elementaryStreams,j.stats=O.stats}),g?k(h,g,g.startPTS,g.endPTS,g.startDTS,g.endDTS):L(l,h),o.length&&(h.totalduration=h.edge-o[0].start),h.driftStartTime=l.driftStartTime,h.driftStart=l.driftStart;var E=h.advancedDateTime;if(h.advanced&&E){var v=h.edge;h.driftStart||(h.driftStartTime=E,h.driftStart=v),h.driftEndTime=E,h.driftEnd=v}else h.driftEndTime=l.driftEndTime,h.driftEnd=l.driftEnd,h.advancedDateTime=l.advancedDateTime}function y(l,h,_){if(l&&h)for(var f=0,b=0,R=l.length;b<=R;b++){var T=l[b],g=h[b+f];T&&g&&T.index===g.index&&T.fragment.sn===g.fragment.sn?_(T,g):f--}}function P(l,h,_){for(var f=h.skippedSegments,b=Math.max(l.startSN,h.startSN)-h.startSN,R=(l.fragmentHint?1:0)+(f?h.endSN:Math.min(l.endSN,h.endSN))-h.startSN,T=h.startSN-l.startSN,g=h.fragmentHint?h.fragments.concat(h.fragmentHint):h.fragments,c=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,u=b;u<=R;u++){var o=c[T+u],C=g[u];f&&!C&&u<f&&(C=h.fragments[u]=o),o&&C&&_(o,C)}}function L(l,h){var _=h.startSN+h.skippedSegments-l.startSN,f=l.fragments;if(_<0||_>=f.length)return;x(h,f[_].start)}function x(l,h){if(h){for(var _=l.fragments,f=l.skippedSegments;f<_.length;f++)_[f].start+=h;l.fragmentHint&&(l.fragmentHint.start+=h)}}function S(l,h){var _=1e3*l.levelTargetDuration,f=_/2,b=l.age,R=b>0&&b<_*3,T=h.loading.end-h.loading.start,g,c=l.availabilityDelay;if(l.updated===!1)if(R){var u=333*l.misses;g=Math.max(Math.min(f,T*2),u),l.availabilityDelay=(l.availabilityDelay||0)+g}else g=f;else R?(c=Math.min(c||_/2,b),l.availabilityDelay=c,g=c+_-b):g=_-T;return Math.round(g)}function d(l,h,_){if(!l||!l.details)return null;var f=l.details,b=f.fragments[h-f.startSN];return b||(b=f.fragmentHint,b&&b.sn===h?b:h<f.startSN&&_&&_.sn===h?_:null)}function a(l,h,_){if(!l||!l.details)return null;var f=l.details.partList;if(f)for(var b=f.length;b--;){var R=f[b];if(R.index===_&&R.fragment.sn===h)return R}return null}},"./src/controller/stream-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return f});var V=D("./src/polyfills/number.ts"),I=D("./src/controller/base-stream-controller.ts"),w=D("./src/is-supported.ts"),B=D("./src/events.ts"),N=D("./src/utils/buffer-helper.ts"),M=D("./src/controller/fragment-tracker.ts"),k=D("./src/types/loader.ts"),p=D("./src/loader/fragment.ts"),y=D("./src/demux/transmuxer-interface.ts"),P=D("./src/types/transmuxer.ts"),L=D("./src/controller/gap-controller.ts"),x=D("./src/errors.ts"),S=D("./src/utils/logger.ts");function d(b,R){for(var T=0;T<R.length;T++){var g=R[T];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(b,g.key,g)}}function a(b,R,T){return R&&d(b.prototype,R),T&&d(b,T),b}function l(b,R){b.prototype=Object.create(R.prototype),b.prototype.constructor=b,h(b,R)}function h(b,R){return h=Object.setPrototypeOf||function(g,c){return g.__proto__=c,g},h(b,R)}var _=100,f=function(b){l(R,b);function R(g,c){var u;return u=b.call(this,g,c,"[stream-controller]")||this,u.audioCodecSwap=!1,u.gapController=null,u.level=-1,u._forceStartLoad=!1,u.altAudio=!1,u.audioOnly=!1,u.fragPlaying=null,u.onvplaying=null,u.onvseeked=null,u.fragLastKbps=0,u.stalled=!1,u.couldBacktrack=!1,u.audioCodecSwitch=!1,u.videoBuffer=null,u._registerListeners(),u}var T=R.prototype;return T._registerListeners=function(){var c=this.hls;c.on(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.on(B.Events.LEVEL_LOADING,this.onLevelLoading,this),c.on(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(B.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.on(B.Events.ERROR,this.onError,this),c.on(B.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.on(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.on(B.Events.BUFFER_CREATED,this.onBufferCreated,this),c.on(B.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.on(B.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.on(B.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T._unregisterListeners=function(){var c=this.hls;c.off(B.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(B.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(B.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(B.Events.MANIFEST_PARSED,this.onManifestParsed,this),c.off(B.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(B.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),c.off(B.Events.ERROR,this.onError,this),c.off(B.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),c.off(B.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),c.off(B.Events.BUFFER_CREATED,this.onBufferCreated,this),c.off(B.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),c.off(B.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),c.off(B.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},T.startLoad=function(c){if(this.levels){var u=this.lastCurrentTime,o=this.hls;if(this.stopLoad(),this.setInterval(_),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var C=o.startLevel;C===-1&&(o.config.testBandwidth?(C=0,this.bitrateTest=!0):C=o.nextAutoLevel),this.level=o.nextLoadLevel=C,this.loadedmetadata=!1}u>0&&c===-1&&(this.log("Override startPosition with lastCurrentTime @"+u.toFixed(3)),c=u),this.state=I.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()}else this._forceStartLoad=!0,this.state=I.State.STOPPED},T.stopLoad=function(){this._forceStartLoad=!1,b.prototype.stopLoad.call(this)},T.doTick=function(){switch(this.state){case I.State.IDLE:this.doTickIdle();break;case I.State.WAITING_LEVEL:{var c,u=this.levels,o=this.level,C=u==null||((c=u[o])===null||c===void 0)?void 0:c.details;if(C&&(!C.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(C))break;this.state=I.State.IDLE;break}break}case I.State.FRAG_LOADING_WAITING_RETRY:{var E,v=self.performance.now(),O=this.retryDate;(!O||v>=O||(E=this.media)!==null&&E!==void 0&&E.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=I.State.IDLE)}break;default:break}this.onTickEnd()},T.onTickEnd=function(){b.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},T.doTickIdle=function(){var c,u,o=this.hls,C=this.levelLastLoaded,E=this.levels,v=this.media,O=o.config,j=o.nextLoadLevel;if(C===null||!v&&(this.startFragRequested||!O.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(!E||!E[j])return;var G=E[j];this.level=o.nextLoadLevel=j;var J=G.details;if(!J||this.state===I.State.WAITING_LEVEL||J.live&&this.levelLastLoaded!==j){this.state=I.State.WAITING_LEVEL;return}var K=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:v,k.PlaylistLevelType.MAIN);if(K===null)return;var F=K.len,ee=this.getMaxBufferLength(G.maxBitrate);if(F>=ee)return;if(this._streamEnded(K,J)){var oe={};this.altAudio&&(oe.type="video"),this.hls.trigger(B.Events.BUFFER_EOS,oe),this.state=I.State.ENDED;return}var he=K.end,ge=this.getNextFragment(he,J);if(this.couldBacktrack&&!this.fragPrevious&&ge&&ge.sn!=="initSegment"){var _e=ge.sn-J.startSN;_e>1&&(ge=J.fragments[_e-1],this.fragmentTracker.removeFragment(ge))}if(ge&&this.fragmentTracker.getState(ge)===M.FragmentState.OK&&this.nextLoadPosition>he){var be=this.audioOnly&&!this.altAudio?p.ElementaryStreamTypes.AUDIO:p.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(v,be,k.PlaylistLevelType.MAIN),ge=this.getNextFragment(this.nextLoadPosition,J)}if(!ge)return;ge.initSegment&&!ge.initSegment.data&&!this.bitrateTest&&(ge=ge.initSegment),((c=ge.decryptdata)===null||c===void 0?void 0:c.keyFormat)==="identity"&&!((u=ge.decryptdata)!==null&&u!==void 0&&u.key)?this.loadKey(ge,J):this.loadFragment(ge,J,he)},T.loadFragment=function(c,u,o){var C,E=this.fragmentTracker.getState(c);if(this.fragCurrent=c,E===M.FragmentState.BACKTRACKED){var v=this.fragmentTracker.getBacktrackData(c);if(v){this._handleFragmentLoadProgress(v),this._handleFragmentLoadComplete(v);return}else E=M.FragmentState.NOT_LOADED}E===M.FragmentState.NOT_LOADED||E===M.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,b.prototype.loadFragment.call(this,c,u,o)):E===M.FragmentState.APPENDING?this.reduceMaxBufferLength(c.duration)&&this.fragmentTracker.removeFragment(c):((C=this.media)===null||C===void 0?void 0:C.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},T.getAppendedFrag=function(c){var u=this.fragmentTracker.getAppendedFrag(c,k.PlaylistLevelType.MAIN);return u&&"fragment"in u?u.fragment:u},T.getBufferedFrag=function(c){return this.fragmentTracker.getBufferedFrag(c,k.PlaylistLevelType.MAIN)},T.followingBufferedFrag=function(c){return c?this.getBufferedFrag(c.end+.5):null},T.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},T.nextLevelSwitch=function(){var c=this.levels,u=this.media;if(u!=null&&u.readyState){var o,C=this.getAppendedFrag(u.currentTime);if(C&&C.start>1&&this.flushMainBuffer(0,C.start-1),!u.paused&&c){var E=this.hls.nextLoadLevel,v=c[E],O=this.fragLastKbps;O&&this.fragCurrent?o=this.fragCurrent.duration*v.maxBitrate/(1e3*O)+1:o=0}else o=0;var j=this.getBufferedFrag(u.currentTime+o);if(j){var G=this.followingBufferedFrag(j);if(G){this.abortCurrentFrag();var J=G.maxStartPTS?G.maxStartPTS:G.start,K=G.duration,F=Math.max(j.end,J+Math.min(Math.max(K-this.config.maxFragLookUpTolerance,K*.5),K*.75));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},T.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()},T.flushMainBuffer=function(c,u){b.prototype.flushMainBuffer.call(this,c,u,this.altAudio?"video":null)},T.onMediaAttached=function(c,u){b.prototype.onMediaAttached.call(this,c,u);var o=u.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),o.addEventListener("playing",this.onvplaying),o.addEventListener("seeked",this.onvseeked),this.gapController=new L.default(this.config,o,this.fragmentTracker,this.hls)},T.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),b.prototype.onMediaDetaching.call(this)},T.onMediaPlaying=function(){this.tick()},T.onMediaSeeked=function(){var c=this.media,u=c?c.currentTime:null;Object(V.isFiniteNumber)(u)&&this.log("Media seeked to "+u.toFixed(3)),this.tick()},T.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(B.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},T.onManifestParsed=function(c,u){var o=!1,C=!1,E;u.levels.forEach(function(v){E=v.audioCodec,E&&(E.indexOf("mp4a.40.2")!==-1&&(o=!0),E.indexOf("mp4a.40.5")!==-1&&(C=!0))}),this.audioCodecSwitch=o&&C&&!Object(w.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=u.levels,this.startFragRequested=!1},T.onLevelLoading=function(c,u){var o=this.levels;if(!o||this.state!==I.State.IDLE)return;var C=o[u.level];(!C.details||C.details.live&&this.levelLastLoaded!==u.level||this.waitForCdnTuneIn(C.details))&&(this.state=I.State.WAITING_LEVEL)},T.onLevelLoaded=function(c,u){var o,C=this.levels,E=u.level,v=u.details,O=v.totalduration;if(!C){this.warn("Levels were reset while loading level "+E);return}this.log("Level "+E+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+O);var j=this.fragCurrent;j&&(this.state===I.State.FRAG_LOADING||this.state===I.State.FRAG_LOADING_WAITING_RETRY)&&(j.level!==u.level&&j.loader&&(this.state=I.State.IDLE,j.loader.abort()));var G=C[E],J=0;if(v.live||(o=G.details)!==null&&o!==void 0&&o.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;J=this.alignPlaylists(v,G.details)}if(G.details=v,this.levelLastLoaded=E,this.hls.trigger(B.Events.LEVEL_UPDATED,{details:v,level:E}),this.state===I.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(v))return;this.state=I.State.IDLE}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,J),this.tick()},T._handleFragmentLoadProgress=function(c){var u,o=c.frag,C=c.part,E=c.payload,v=this.levels;if(!v){this.warn("Levels were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var O=v[o.level],j=O.details;if(!j){this.warn("Dropping fragment "+o.sn+" of level "+o.level+" after level details were reset");return}var G=O.videoCodec,J=j.PTSKnown||!j.live,K=(u=o.initSegment)===null||u===void 0?void 0:u.data,F=this._getAudioCodec(O),ee=this.transmuxer=this.transmuxer||new y.default(this.hls,k.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),oe=C?C.index:-1,he=oe!==-1,ge=new P.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,E.byteLength,oe,he),_e=this.initPTS[o.cc];ee.push(E,K,F,G,o,C,j.totalduration,J,ge,_e)},T.onAudioTrackSwitching=function(c,u){var o=this.altAudio,C=!!u.url,E=u.id;if(!C){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v!=null&&v.loader&&(this.log("Switching to main audio track, cancel main fragment load"),v.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var O=this.hls;o&&O.trigger(B.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),O.trigger(B.Events.AUDIO_TRACK_SWITCHED,{id:E})}},T.onAudioTrackSwitched=function(c,u){var o=u.id,C=!!this.hls.audioTracks[o].url;if(C){var E=this.videoBuffer;E&&this.mediaBuffer!==E&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=E)}this.altAudio=C,this.tick()},T.onBufferCreated=function(c,u){var o=u.tracks,C,E,v=!1;for(var O in o){var j=o[O];if(j.id==="main"){if(E=O,C=j,O==="video"){var G=o[O];G&&(this.videoBuffer=G.buffer)}}else v=!0}v&&C?(this.log("Alternate track found, use "+E+".buffered to schedule main fragment loading"),this.mediaBuffer=C.buffer):this.mediaBuffer=this.media},T.onFragBuffered=function(c,u){var o=u.frag,C=u.part;if(o&&o.type!==k.PlaylistLevelType.MAIN)return;if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(C?" p: "+C.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state),this.state===I.State.PARSED&&(this.state=I.State.IDLE);return}var E=C?C.stats:o.stats;this.fragLastKbps=Math.round(8*E.total/(E.buffering.end-E.loading.first)),o.sn!=="initSegment"&&(this.fragPrevious=o),this.fragBufferedComplete(o,C)},T.onError=function(c,u){switch(u.details){case x.ErrorDetails.FRAG_LOAD_ERROR:case x.ErrorDetails.FRAG_LOAD_TIMEOUT:case x.ErrorDetails.KEY_LOAD_ERROR:case x.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(k.PlaylistLevelType.MAIN,u);break;case x.ErrorDetails.LEVEL_LOAD_ERROR:case x.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==I.State.ERROR&&(u.fatal?(this.warn(""+u.details),this.state=I.State.ERROR):!u.levelRetry&&this.state===I.State.WAITING_LEVEL&&(this.state=I.State.IDLE));break;case x.ErrorDetails.BUFFER_FULL_ERROR:if(u.parent==="main"&&(this.state===I.State.PARSING||this.state===I.State.PARSED)){var o=!0,C=this.getFwdBufferInfo(this.media,k.PlaylistLevelType.MAIN);C&&C.len>.5&&(o=!this.reduceMaxBufferLength(C.len)),o&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},T.checkBuffer=function(){var c=this.media,u=this.gapController;if(!c||!u||!c.readyState)return;var o=N.BufferHelper.getBuffered(c);!this.loadedmetadata&&o.length?(this.loadedmetadata=!0,this.seekToStartPos()):u.poll(this.lastCurrentTime),this.lastCurrentTime=c.currentTime},T.onFragLoadEmergencyAborted=function(){this.state=I.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},T.onBufferFlushed=function(c,u){var o=u.type;if(o!==p.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var C=(o===p.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(C,o,k.PlaylistLevelType.MAIN)}},T.onLevelsUpdated=function(c,u){this.levels=u.levels},T.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},T.seekToStartPos=function(){var c=this.media,u=c.currentTime,o=this.startPosition;if(o>=0&&u<o){if(c.seeking){S.logger.log("could not seek to "+o+", already seeking at "+u);return}var C=N.BufferHelper.getBuffered(c),E=C.length?C.start(0):0,v=E-o;v>0&&(v<this.config.maxBufferHole||v<this.config.maxFragLookUpTolerance)&&(S.logger.log("adjusting start position by "+v+" to match buffer start"),o+=v,this.startPosition=o),this.log("seek to target start position "+o+" from current time "+u),c.currentTime=o}},T._getAudioCodec=function(c){var u=this.config.defaultAudioCodec||c.audioCodec;return this.audioCodecSwap&&u&&(this.log("Swapping audio codec"),u.indexOf("mp4a.40.5")!==-1?u="mp4a.40.2":u="mp4a.40.5"),u},T._loadBitrateTestFrag=function(c){var u=this;this._doFragLoad(c).then(function(o){var C=u.hls;if(!o||C.nextLoadLevel||u.fragContextChanged(c))return;u.fragLoadError=0,u.state=I.State.IDLE,u.startFragRequested=!1,u.bitrateTest=!1;var E=c.stats;E.parsing.start=E.parsing.end=E.buffering.start=E.buffering.end=self.performance.now(),C.trigger(B.Events.FRAG_LOADED,o)})},T._handleTransmuxComplete=function(c){var u,o="main",C=this.hls,E=c.remuxResult,v=c.chunkMeta,O=this.getCurrentContext(v);if(!O){this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(v.level);return}var j=O.frag,G=O.part,J=O.level,K=E.video,F=E.text,ee=E.id3,oe=E.initSegment,he=this.altAudio?void 0:E.audio;if(this.fragContextChanged(j))return;if(this.state=I.State.PARSING,oe){oe.tracks&&(this._bufferInitSegment(J,oe.tracks,j,v),C.trigger(B.Events.FRAG_PARSING_INIT_SEGMENT,{frag:j,id:o,tracks:oe.tracks}));var ge=oe.initPTS,_e=oe.timescale;Object(V.isFiniteNumber)(ge)&&(this.initPTS[j.cc]=ge,C.trigger(B.Events.INIT_PTS_FOUND,{frag:j,id:o,initPTS:ge,timescale:_e}))}if(K&&E.independent!==!1){if(J.details){var be=K.startPTS,Ee=K.endPTS,Te=K.startDTS,Ce=K.endDTS;if(G)G.elementaryStreams[K.type]={startPTS:be,endPTS:Ee,startDTS:Te,endDTS:Ce};else if(K.firstKeyFrame&&K.independent&&(this.couldBacktrack=!0),K.dropped&&K.independent){var me=this.getLoadPosition()+this.config.maxBufferHole;if(me<be){this.backtrack(j);return}j.setElementaryStreamInfo(K.type,j.start,Ee,j.start,Ce,!0)}j.setElementaryStreamInfo(K.type,be,Ee,Te,Ce),this.bufferFragmentData(K,j,G,v)}}else if(E.independent===!1){this.backtrack(j);return}if(he){var se=he.startPTS,Re=he.endPTS,et=he.startDTS,Ge=he.endDTS;G&&(G.elementaryStreams[p.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:Re,startDTS:et,endDTS:Ge}),j.setElementaryStreamInfo(p.ElementaryStreamTypes.AUDIO,se,Re,et,Ge),this.bufferFragmentData(he,j,G,v)}if(ee!=null&&(u=ee.samples)!==null&&u!==void 0&&u.length){var tt={frag:j,id:o,samples:ee.samples};C.trigger(B.Events.FRAG_PARSING_METADATA,tt)}if(F){var Ye={frag:j,id:o,samples:F.samples};C.trigger(B.Events.FRAG_PARSING_USERDATA,Ye)}},T._bufferInitSegment=function(c,u,o,C){var E=this;if(this.state!==I.State.PARSING)return;this.audioOnly=!!u.audio&&!u.video,this.altAudio&&!this.audioOnly&&delete u.audio;var v=u.audio,O=u.video,j=u.audiovideo;if(v){var G=c.audioCodec,J=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(G&&(G.indexOf("mp4a.40.5")!==-1?G="mp4a.40.2":G="mp4a.40.5"),v.metadata.channelCount!==1&&J.indexOf("firefox")===-1&&(G="mp4a.40.5")),J.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(G="mp4a.40.2",this.log("Android: force audio codec to "+G)),c.audioCodec&&c.audioCodec!==G&&this.log('Swapping manifest audio codec "'+c.audioCodec+'" for "'+G+'"'),v.levelCodec=G,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(G||"")+"/"+(c.audioCodec||"")+"/"+v.codec+"]")}O&&(O.levelCodec=c.videoCodec,O.id="main",this.log("Init video buffer, container:"+O.container+", codecs[level/parsed]=["+(c.videoCodec||"")+"/"+O.codec+"]")),j&&this.log("Init audiovideo buffer, container:"+j.container+", codecs[level/parsed]=["+(c.attrs.CODECS||"")+"/"+j.codec+"]"),this.hls.trigger(B.Events.BUFFER_CODECS,u),Object.keys(u).forEach(function(K){var F=u[K],ee=F.initSegment;ee!=null&&ee.byteLength&&E.hls.trigger(B.Events.BUFFER_APPENDING,{type:K,data:ee,frag:o,part:null,chunkMeta:C,parent:o.type})}),this.tick()},T.backtrack=function(c){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(c);var u=this.fragmentTracker.backtrack(c);this.fragPrevious=null,this.nextLoadPosition=c.start,u?this.resetFragmentLoading(c):this.state=I.State.BACKTRACKING},T.checkFragmentChanged=function(){var c=this.media,u=null;if(c&&c.readyState>1&&c.seeking===!1){var o=c.currentTime;if(N.BufferHelper.isBuffered(c,o)?u=this.getAppendedFrag(o):N.BufferHelper.isBuffered(c,o+.1)&&(u=this.getAppendedFrag(o+.1)),u){var C=this.fragPlaying,E=u.level;(!C||u.sn!==C.sn||C.level!==E||u.urlId!==C.urlId)&&(this.hls.trigger(B.Events.FRAG_CHANGED,{frag:u}),(!C||C.level!==E)&&this.hls.trigger(B.Events.LEVEL_SWITCHED,{level:E}),this.fragPlaying=u)}}},a(R,[{key:"nextLevel",get:function(){var c=this.nextBufferedFrag;return c?c.level:-1}},{key:"currentLevel",get:function(){var c=this.media;if(c){var u=this.getAppendedFrag(c.currentTime);if(u)return u.level}return-1}},{key:"nextBufferedFrag",get:function(){var c=this.media;if(c){var u=this.getAppendedFrag(c.currentTime);return this.followingBufferedFrag(u)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),R}(I.default)},"./src/controller/subtitle-stream-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"SubtitleStreamController",function(){return l});var V=D("./src/events.ts"),I=D("./src/utils/logger.ts"),w=D("./src/utils/buffer-helper.ts"),B=D("./src/controller/fragment-finders.ts"),N=D("./src/utils/discontinuities.ts"),M=D("./src/controller/level-helper.ts"),k=D("./src/controller/fragment-tracker.ts"),p=D("./src/controller/base-stream-controller.ts"),y=D("./src/types/loader.ts"),P=D("./src/types/level.ts");function L(h,_){for(var f=0;f<_.length;f++){var b=_[f];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(h,b.key,b)}}function x(h,_,f){return _&&L(h.prototype,_),f&&L(h,f),h}function S(h,_){h.prototype=Object.create(_.prototype),h.prototype.constructor=h,d(h,_)}function d(h,_){return d=Object.setPrototypeOf||function(b,R){return b.__proto__=R,b},d(h,_)}var a=500,l=function(h){S(_,h);function _(b,R){var T;return T=h.call(this,b,R,"[subtitle-stream-controller]")||this,T.levels=[],T.currentTrackId=-1,T.tracksBuffered=[],T.mainDetails=null,T._registerListeners(),T}var f=_.prototype;return f.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},f._registerListeners=function(){var R=this.hls;R.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),R.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),R.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),R.on(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),R.on(V.Events.ERROR,this.onError,this),R.on(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),R.on(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),R.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),R.on(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),R.on(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},f._unregisterListeners=function(){var R=this.hls;R.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),R.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),R.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),R.off(V.Events.LEVEL_LOADED,this.onLevelLoaded,this),R.off(V.Events.ERROR,this.onError,this),R.off(V.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),R.off(V.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),R.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),R.off(V.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),R.off(V.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},f.startLoad=function(){this.stopLoad(),this.state=p.State.IDLE,this.setInterval(a),this.tick()},f.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},f.onLevelLoaded=function(R,T){this.mainDetails=T.details},f.onSubtitleFragProcessed=function(R,T){var g=T.frag,c=T.success;if(this.fragPrevious=g,this.state=p.State.IDLE,!c)return;var u=this.tracksBuffered[this.currentTrackId];if(!u)return;for(var o,C=g.start,E=0;E<u.length;E++)if(C>=u[E].start&&C<=u[E].end){o=u[E];break}var v=g.start+g.duration;o?o.end=v:(o={start:C,end:v},u.push(o)),this.fragmentTracker.fragBuffered(g)},f.onBufferFlushing=function(R,T){var g=T.startOffset,c=T.endOffset;if(g===0&&c!==Number.POSITIVE_INFINITY){var u=this.currentTrackId,o=this.levels;if(!o.length||!o[u]||!o[u].details)return;var C=o[u].details,E=C.targetduration,v=c-E;if(v<=0)return;T.endOffsetSubtitles=Math.max(0,v),this.tracksBuffered.forEach(function(O){for(var j=0;j<O.length;){if(O[j].end<=v){O.shift();continue}else if(O[j].start<v)O[j].start=v;else break;j++}}),this.fragmentTracker.removeFragmentsInRange(g,v,y.PlaylistLevelType.SUBTITLE)}},f.onError=function(R,T){var g,c=T.frag;if(!c||c.type!==y.PlaylistLevelType.SUBTITLE)return;(g=this.fragCurrent)!==null&&g!==void 0&&g.loader&&this.fragCurrent.loader.abort(),this.state=p.State.IDLE},f.onSubtitleTracksUpdated=function(R,T){var g=this,c=T.subtitleTracks;this.tracksBuffered=[],this.levels=c.map(function(u){return new P.Level(u)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(u){g.tracksBuffered[u.id]=[]}),this.mediaBuffer=null},f.onSubtitleTrackSwitch=function(R,T){if(this.currentTrackId=T.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var g=this.levels[this.currentTrackId];g!=null&&g.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,g&&this.setInterval(a)},f.onSubtitleTrackLoaded=function(R,T){var g,c=T.details,u=T.id,o=this.currentTrackId,C=this.levels;if(!C.length)return;var E=C[o];if(u>=C.length||u!==o||!E)return;if(this.mediaBuffer=this.mediaBufferTimeRanges,c.live||(g=E.details)!==null&&g!==void 0&&g.live){var v=this.mainDetails;if(c.deltaUpdateFailed||!v)return;var O=v.fragments[0];if(!E.details)c.hasProgramDateTime&&v.hasProgramDateTime?Object(N.alignMediaPlaylistByPDT)(c,v):O&&Object(M.addSliding)(c,O.start);else{var j=this.alignPlaylists(c,E.details);j===0&&O&&Object(M.addSliding)(c,O.start)}}if(E.details=c,this.levelLastLoaded=u,this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===p.State.IDLE){var G=Object(B.findFragmentByPTS)(null,c.fragments,this.media.currentTime,0);G||(this.warn("Subtitle playlist not aligned with playback"),E.details=void 0)}},f._handleFragmentLoadComplete=function(R){var T=R.frag,g=R.payload,c=T.decryptdata,u=this.hls;if(this.fragContextChanged(T))return;if(g&&g.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(g),c.key.buffer,c.iv.buffer).then(function(C){var E=performance.now();u.trigger(V.Events.FRAG_DECRYPTED,{frag:T,payload:C,stats:{tstart:o,tdecrypt:E}})})}},f.doTick=function(){if(!this.media){this.state=p.State.IDLE;return}if(this.state===p.State.IDLE){var R,T=this.currentTrackId,g=this.levels;if(!g.length||!g[T]||!g[T].details)return;var c=g[T].details,u=c.targetduration,o=this.config,C=this.media,E=w.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,C.currentTime-u,o.maxBufferHole),v=E.end,O=E.len,j=this.getMaxBufferLength()+u;if(O>j)return;console.assert(c,"Subtitle track details are defined on idle subtitle stream controller tick");var G=c.fragments,J=G.length,K=c.edge,F,ee=this.fragPrevious;if(v<K){var oe=o.maxFragLookUpTolerance;ee&&c.hasProgramDateTime&&(F=Object(B.findFragmentByPDT)(G,ee.endProgramDateTime,oe)),F||(F=Object(B.findFragmentByPTS)(ee,G,v,oe),!F&&ee&&ee.start<G[0].start&&(F=G[0]))}else F=G[J-1];(R=F)!==null&&R!==void 0&&R.encrypted?(I.logger.log("Loading key for "+F.sn),this.state=p.State.KEY_LOADING,this.hls.trigger(V.Events.KEY_LOADING,{frag:F})):F&&this.fragmentTracker.getState(F)===k.FragmentState.NOT_LOADED&&this.loadFragment(F,c,v)}},f.loadFragment=function(R,T,g){this.fragCurrent=R,h.prototype.loadFragment.call(this,R,T,g)},x(_,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),_}(p.default)},"./src/controller/subtitle-track-controller.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/events.ts"),I=D("./src/utils/texttrack-utils.ts"),w=D("./src/controller/base-playlist-controller.ts"),B=D("./src/types/loader.ts");function N(L,x){for(var S=0;S<x.length;S++){var d=x[S];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(L,d.key,d)}}function M(L,x,S){return x&&N(L.prototype,x),S&&N(L,S),L}function k(L,x){L.prototype=Object.create(x.prototype),L.prototype.constructor=L,p(L,x)}function p(L,x){return p=Object.setPrototypeOf||function(d,a){return d.__proto__=a,d},p(L,x)}var y=function(L){k(x,L);function x(d){var a;return a=L.call(this,d,"[subtitle-track-controller]")||this,a.media=null,a.tracks=[],a.groupId=null,a.tracksInGroup=[],a.trackId=-1,a.selectDefaultTrack=!0,a.queuedDefaultTrack=-1,a.trackChangeListener=function(){return a.onTextTracksChanged()},a.asyncPollTrackChange=function(){return a.pollTrackChange(0)},a.useTextTrackPolling=!1,a.subtitlePollingInterval=-1,a.subtitleDisplay=!0,a.registerListeners(),a}var S=x.prototype;return S.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,L.prototype.destroy.call(this)},S.registerListeners=function(){var a=this.hls;a.on(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.on(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(V.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.on(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.on(V.Events.ERROR,this.onError,this)},S.unregisterListeners=function(){var a=this.hls;a.off(V.Events.MEDIA_ATTACHED,this.onMediaAttached,this),a.off(V.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(V.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(V.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(V.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(V.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),a.off(V.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),a.off(V.Events.ERROR,this.onError,this)},S.onMediaAttached=function(a,l){if(this.media=l.media,!this.media)return;this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)},S.pollTrackChange=function(a){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,a)},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 a=P(this.media.textTracks);a.forEach(function(l){Object(I.clearCurrentCues)(l)}),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(a,l){this.tracks=l.subtitleTracks},S.onSubtitleTrackLoaded=function(a,l){var h=l.id,_=l.details,f=this.trackId,b=this.tracksInGroup[f];if(!b){this.warn("Invalid subtitle track id "+h);return}var R=b.details;b.details=l.details,this.log("subtitle track "+h+" loaded ["+_.startSN+"-"+_.endSN+"]"),h===this.trackId&&(this.retryCount=0,this.playlistLoaded(h,l,R))},S.onLevelLoading=function(a,l){this.switchLevel(l.level)},S.onLevelSwitching=function(a,l){this.switchLevel(l.level)},S.switchLevel=function(a){var l=this.hls.levels[a];if(!(l!=null&&l.textGroupIds))return;var h=l.textGroupIds[l.urlId];if(this.groupId!==h){var _=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,f=this.tracks.filter(function(T){return!h||T.groupId===h});this.tracksInGroup=f;var b=this.findTrackId(_==null?void 0:_.name)||this.findTrackId();this.groupId=h;var R={subtitleTracks:f};this.log("Updating subtitle tracks, "+f.length+' track(s) found in "'+h+'" group-id'),this.hls.trigger(V.Events.SUBTITLE_TRACKS_UPDATED,R),b!==-1&&this.setSubtitleTrack(b,_)}},S.findTrackId=function(a){for(var l=this.tracksInGroup,h=0;h<l.length;h++){var _=l[h];if((!this.selectDefaultTrack||_.default)&&(!a||a===_.name))return _.id}return-1},S.onError=function(a,l){if(L.prototype.onError.call(this,a,l),l.fatal||!l.context)return;l.context.type===B.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},S.loadPlaylist=function(a){var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var h=l.id,_=l.groupId,f=l.url;if(a)try{f=a.addDirectives(f)}catch(b){this.warn("Could not construct new URL with HLS Delivery Directives: "+b)}this.log("Loading subtitle playlist for id "+h),this.hls.trigger(V.Events.SUBTITLE_TRACK_LOADING,{url:f,id:h,groupId:_,deliveryDirectives:a||null})}},S.toggleTrackModes=function(a){var l=this,h=this.media,_=this.subtitleDisplay,f=this.trackId;if(!h)return;var b=P(h.textTracks),R=b.filter(function(c){return c.groupId===l.groupId});if(a===-1)[].slice.call(b).forEach(function(c){c.mode="disabled"});else{var T=R[f];T&&(T.mode="disabled")}var g=R[a];g&&(g.mode=_?"showing":"hidden")},S.setSubtitleTrack=function(a,l){var h,_=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=a;return}if(this.trackId!==a&&this.toggleTrackModes(a),this.trackId===a&&(a===-1||(h=_[a])!==null&&h!==void 0&&h.details)||a<-1||a>=_.length)return;this.clearTimer();var f=_[a];if(this.log("Switching to subtitle track "+a),this.trackId=a,f){var b=f.id,R=f.groupId,T=R===void 0?"":R,g=f.name,c=f.type,u=f.url;this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:b,groupId:T,name:g,type:c,url:u});var o=this.switchParams(f.url,l==null?void 0:l.details);this.loadPlaylist(o)}else this.hls.trigger(V.Events.SUBTITLE_TRACK_SWITCH,{id:a})},S.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;for(var a=-1,l=P(this.media.textTracks),h=0;h<l.length;h++)if(l[h].mode==="hidden")a=h;else if(l[h].mode==="showing"){a=h;break}this.subtitleTrack!==a&&(this.subtitleTrack=a)},M(x,[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(a){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(a,l)}}]),x}(w.default);function P(L){for(var x=[],S=0;S<L.length;S++){var d=L[S];d.kind==="subtitles"&&d.label&&x.push(L[S])}return x}Y.default=y},"./src/controller/timeline-controller.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"TimelineController",function(){return P});var V=D("./src/polyfills/number.ts"),I=D("./src/events.ts"),w=D("./src/utils/cea-608-parser.ts"),B=D("./src/utils/output-filter.ts"),N=D("./src/utils/webvtt-parser.ts"),M=D("./src/utils/texttrack-utils.ts"),k=D("./src/utils/imsc1-ttml-parser.ts"),p=D("./src/types/loader.ts"),y=D("./src/utils/logger.ts"),P=function(){function d(l){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=l,this.config=l.config,this.Cues=l.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 h=new B.default(this,"textTrack1"),_=new B.default(this,"textTrack2"),f=new B.default(this,"textTrack3"),b=new B.default(this,"textTrack4");this.cea608Parser1=new w.default(1,h,_),this.cea608Parser2=new w.default(3,f,b)}l.on(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(I.Events.FRAG_LOADING,this.onFragLoading,this),l.on(I.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var a=d.prototype;return a.destroy=function(){var h=this.hls;h.off(I.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(I.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(I.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(I.Events.FRAG_LOADING,this.onFragLoading,this),h.off(I.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(I.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(I.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(I.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(I.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(I.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},a.addCues=function(h,_,f,b,R){for(var T=!1,g=R.length;g--;){var c=R[g],u=x(c[0],c[1],_,f);if(u>=0&&(c[0]=Math.min(c[0],_),c[1]=Math.max(c[1],f),T=!0,u/(f-_)>.5))return}if(T||R.push([_,f]),this.config.renderTextTracksNatively){var o=this.captionsTracks[h];this.Cues.newCue(o,_,f,b)}else{var C=this.Cues.newCue(null,_,f,b);this.hls.trigger(I.Events.CUES_PARSED,{type:"captions",cues:C,track:h})}},a.onInitPtsFound=function(h,_){var f=this,b=_.frag,R=_.id,T=_.initPTS,g=_.timescale,c=this.unparsedVttFrags;R==="main"&&(this.initPTS[b.cc]=T,this.timescale[b.cc]=g),c.length&&(this.unparsedVttFrags=[],c.forEach(function(u){f.onFragLoaded(I.Events.FRAG_LOADED,u)}))},a.getExistingTrack=function(h){var _=this.media;if(_)for(var f=0;f<_.textTracks.length;f++){var b=_.textTracks[f];if(b[h])return b}return null},a.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},a.createNativeTrack=function(h){if(this.captionsTracks[h])return;var _=this.captionsProperties,f=this.captionsTracks,b=this.media,R=_[h],T=R.label,g=R.languageCode,c=this.getExistingTrack(h);if(c)f[h]=c,Object(M.clearCurrentCues)(f[h]),Object(M.sendAddTrackEvent)(f[h],b);else{var u=this.createTextTrack("captions",T,g);u&&(u[h]=!0,f[h]=u)}},a.createNonNativeTrack=function(h){if(this.nonNativeCaptionsTracks[h])return;var _=this.captionsProperties[h];if(!_)return;var f=_.label,b={_id:h,label:f,kind:"captions",default:_.media?!!_.media.default:!1,closedCaptions:_.media};this.nonNativeCaptionsTracks[h]=b,this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[b]})},a.createTextTrack=function(h,_,f){var b=this.media;return b?b.addTextTrack(h,_,f):void 0},a.onMediaAttaching=function(h,_){this.media=_.media,this._cleanTracks()},a.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(_){Object(M.clearCurrentCues)(h[_]),delete h[_]}),this.nonNativeCaptionsTracks={}},a.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())},a._cleanTracks=function(){var h=this.media;if(!h)return;var _=h.textTracks;if(_)for(var f=0;f<_.length;f++)Object(M.clearCurrentCues)(_[f])},a.onSubtitleTracksUpdated=function(h,_){var f=this;this.textTracks=[];var b=_.subtitleTracks||[],R=b.some(function(u){return u.textCodec===k.IMSC1_CODEC});if(this.config.enableWebVTT||R&&this.config.enableIMSC1){var T=this.tracks&&b&&this.tracks.length===b.length;if(this.tracks=b||[],this.config.renderTextTracksNatively){var g=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,o){var C;if(o<g.length){for(var E=null,v=0;v<g.length;v++)if(L(g[v],u)){E=g[v];break}E&&(C=E)}C?Object(M.clearCurrentCues)(C):(C=f.createTextTrack("subtitles",u.name,u.lang),C&&(C.mode="disabled")),C&&(C.groupId=u.groupId,f.textTracks.push(C))})}else if(!T&&this.tracks&&this.tracks.length){var c=this.tracks.map(function(u){return{label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}});this.hls.trigger(I.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},a.onManifestLoaded=function(h,_){var f=this;this.config.enableCEA708Captions&&_.captions&&_.captions.forEach(function(b){var R=/(?:CC|SERVICE)([1-4])/.exec(b.instreamId);if(!R)return;var T="textTrack"+R[1],g=f.captionsProperties[T];if(!g)return;g.label=b.name,b.lang&&(g.languageCode=b.lang),g.media=b})},a.onFragLoading=function(h,_){var f=this.cea608Parser1,b=this.cea608Parser2,R=this.lastSn,T=this.lastPartIndex;if(!this.enabled||!(f&&b))return;if(_.frag.type===p.PlaylistLevelType.MAIN){var g,c,u=_.frag.sn,o=(g=_==null||((c=_.part)===null||c===void 0)?void 0:c.index)!=null?g:-1;u===R+1||u===R&&o===T+1||(f.reset(),b.reset()),this.lastSn=u,this.lastPartIndex=o}},a.onFragLoaded=function(h,_){var f=_.frag,b=_.payload,R=this.initPTS,T=this.unparsedVttFrags;if(f.type===p.PlaylistLevelType.SUBTITLE)if(b.byteLength){if(!Object(V.isFiniteNumber)(R[f.cc])){T.push(_),R.length&&this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:f,error:new Error("Missing initial subtitle PTS")});return}var g=f.decryptdata;if(g==null||g.key==null||g.method!=="AES-128"){var c=this.tracks[f.level],u=this.vttCCs;u[f.cc]||(u[f.cc]={start:f.start,prevCC:this.prevCC,new:!0},this.prevCC=f.cc),c&&c.textCodec===k.IMSC1_CODEC?this._parseIMSC1(f,b):this._parseVTTs(f,b,u)}}else this.hls.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:f,error:new Error("Empty subtitle payload")})},a._parseIMSC1=function(h,_){var f=this,b=this.hls;Object(k.parseIMSC1)(_,this.initPTS[h.cc],this.timescale[h.cc],function(R){f._appendCues(R,h.level),b.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(R){y.logger.log("Failed to parse IMSC1: "+R),b.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:R})})},a._parseVTTs=function(h,_,f){var b=this,R=this.hls;Object(N.parseWebVTT)(_,this.initPTS[h.cc],this.timescale[h.cc],f,h.cc,h.start,function(T){b._appendCues(T,h.level),R.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(T){b._fallbackToIMSC1(h,_),y.logger.log("Failed to parse VTT cue: "+T),R.trigger(I.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:T})})},a._fallbackToIMSC1=function(h,_){var f=this,b=this.tracks[h.level];b.textCodec||Object(k.parseIMSC1)(_,this.initPTS[h.cc],this.timescale[h.cc],function(){b.textCodec=k.IMSC1_CODEC,f._parseIMSC1(h,_)},function(){b.textCodec="wvtt"})},a._appendCues=function(h,_){var f=this.hls;if(this.config.renderTextTracksNatively){var b=this.textTracks[_];if(b.mode==="disabled")return;h.forEach(function(g){return Object(M.addCueToTrack)(b,g)})}else{var R=this.tracks[_],T=R.default?"default":"subtitles"+_;f.trigger(I.Events.CUES_PARSED,{type:"subtitles",cues:h,track:T})}},a.onFragDecrypted=function(h,_){var f=_.frag;if(f.type===p.PlaylistLevelType.SUBTITLE){if(!Object(V.isFiniteNumber)(this.initPTS[f.cc])){this.unparsedVttFrags.push(_);return}this.onFragLoaded(I.Events.FRAG_LOADED,_)}},a.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},a.onFragParsingUserdata=function(h,_){var f=this.cea608Parser1,b=this.cea608Parser2;if(!this.enabled||!(f&&b))return;for(var R=0;R<_.samples.length;R++){var T=_.samples[R].bytes;if(T){var g=this.extractCea608Data(T);f.addData(_.samples[R].pts,g[0]),b.addData(_.samples[R].pts,g[1])}}},a.onBufferFlushing=function(h,_){var f=_.startOffset,b=_.endOffset,R=_.endOffsetSubtitles,T=_.type,g=this.media;if(!g||g.currentTime<b)return;if(!T||T==="video"){var c=this.captionsTracks;Object.keys(c).forEach(function(o){return Object(M.removeCuesInRange)(c[o],f,b)})}if(this.config.renderTextTracksNatively&&(f===0&&R!==void 0)){var u=this.textTracks;Object.keys(u).forEach(function(o){return Object(M.removeCuesInRange)(u[o],f,R)})}},a.extractCea608Data=function(h){for(var _=h[0]&31,f=2,b=[[],[]],R=0;R<_;R++){var T=h[f++],g=127&h[f++],c=127&h[f++],u=(4&T)!==0,o=3&T;if(g===0&&c===0)continue;u&&((o===0||o===1)&&(b[o].push(g),b[o].push(c)))}return b},d}();function L(d,a){return d&&d.label===a.name&&!(d.textTrack1||d.textTrack2)}function x(d,a,l,h){return Math.min(a,h)-Math.max(d,l)}function S(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return V});var V=function(){function I(B,N){this.subtle=void 0,this.aesIV=void 0,this.subtle=B,this.aesIV=N}var w=I.prototype;return w.decrypt=function(N,M){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},M,N)},I}()},"./src/crypt/aes-decryptor.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"removePadding",function(){return I}),D.d(Y,"default",function(){return w});var V=D("./src/utils/typed-array.ts");function I(B){var N=B.byteLength,M=N&&new DataView(B.buffer).getUint8(N-1);return M?Object(V.sliceUint8)(B,0,N-M):B}var w=function(){function B(){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 N=B.prototype;return N.uint8ArrayToUint32Array_=function(k){for(var p=new DataView(k),y=new Uint32Array(4),P=0;P<4;P++)y[P]=p.getUint32(P*4);return y},N.initTable=function(){var k=this.sBox,p=this.invSBox,y=this.subMix,P=y[0],L=y[1],x=y[2],S=y[3],d=this.invSubMix,a=d[0],l=d[1],h=d[2],_=d[3],f=new Uint32Array(256),b=0,R=0,T=0;for(T=0;T<256;T++)T<128?f[T]=T<<1:f[T]=T<<1^283;for(T=0;T<256;T++){var g=R^R<<1^R<<2^R<<3^R<<4;g=g>>>8^g&255^99,k[b]=g,p[g]=b;var c=f[b],u=f[c],o=f[u],C=f[g]*257^g*16843008;P[b]=C<<24|C>>>8,L[b]=C<<16|C>>>16,x[b]=C<<8|C>>>24,S[b]=C,C=o*16843009^u*65537^c*257^b*16843008,a[g]=C<<24|C>>>8,l[g]=C<<16|C>>>16,h[g]=C<<8|C>>>24,_[g]=C,b?(b=c^f[f[f[o^c]]],R^=f[f[R]]):b=R=1}},N.expandKey=function(k){for(var p=this.uint8ArrayToUint32Array_(k),y=!0,P=0;P<p.length&&y;)y=p[P]===this.key[P],P++;if(y)return;this.key=p;var L=this.keySize=p.length;if(L!==4&&L!==6&&L!==8)throw new Error("Invalid aes key size="+L);var x=this.ksRows=(L+6+1)*4,S,d,a=this.keySchedule=new Uint32Array(x),l=this.invKeySchedule=new Uint32Array(x),h=this.sBox,_=this.rcon,f=this.invSubMix,b=f[0],R=f[1],T=f[2],g=f[3],c,u;for(S=0;S<x;S++){if(S<L){c=a[S]=p[S];continue}u=c,S%L===0?(u=u<<8|u>>>24,u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255],u^=_[S/L|0]<<24):L>6&&S%L===4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[u&255]),a[S]=c=(a[S-L]^u)>>>0}for(d=0;d<x;d++)S=x-d,d&3?u=a[S]:u=a[S-4],d<4||S<=4?l[d]=u:l[d]=b[h[u>>>24]]^R[h[u>>>16&255]]^T[h[u>>>8&255]]^g[h[u&255]],l[d]=l[d]>>>0},N.networkToHostOrderSwap=function(k){return k<<24|(k&65280)<<8|(k&16711680)>>8|k>>>24},N.decrypt=function(k,p,y){for(var P=this.keySize+6,L=this.invKeySchedule,x=this.invSBox,S=this.invSubMix,d=S[0],a=S[1],l=S[2],h=S[3],_=this.uint8ArrayToUint32Array_(y),f=_[0],b=_[1],R=_[2],T=_[3],g=new Int32Array(k),c=new Int32Array(g.length),u,o,C,E,v,O,j,G,J,K,F,ee,oe,he,ge=this.networkToHostOrderSwap;p<g.length;){for(J=ge(g[p]),K=ge(g[p+1]),F=ge(g[p+2]),ee=ge(g[p+3]),v=J^L[0],O=ee^L[1],j=F^L[2],G=K^L[3],oe=4,he=1;he<P;he++)u=d[v>>>24]^a[O>>16&255]^l[j>>8&255]^h[G&255]^L[oe],o=d[O>>>24]^a[j>>16&255]^l[G>>8&255]^h[v&255]^L[oe+1],C=d[j>>>24]^a[G>>16&255]^l[v>>8&255]^h[O&255]^L[oe+2],E=d[G>>>24]^a[v>>16&255]^l[O>>8&255]^h[j&255]^L[oe+3],v=u,O=o,j=C,G=E,oe=oe+4;u=x[v>>>24]<<24^x[O>>16&255]<<16^x[j>>8&255]<<8^x[G&255]^L[oe],o=x[O>>>24]<<24^x[j>>16&255]<<16^x[G>>8&255]<<8^x[v&255]^L[oe+1],C=x[j>>>24]<<24^x[G>>16&255]<<16^x[v>>8&255]<<8^x[O&255]^L[oe+2],E=x[G>>>24]<<24^x[v>>16&255]<<16^x[O>>8&255]<<8^x[j&255]^L[oe+3],c[p]=ge(u^f),c[p+1]=ge(E^b),c[p+2]=ge(C^R),c[p+3]=ge(o^T),f=J,b=K,R=F,T=ee,p=p+4}return c.buffer},B}()},"./src/crypt/decrypter.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return p});var V=D("./src/crypt/aes-crypto.ts"),I=D("./src/crypt/fast-aes-key.ts"),w=D("./src/crypt/aes-decryptor.ts"),B=D("./src/utils/logger.ts"),N=D("./src/utils/mp4-tools.ts"),M=D("./src/utils/typed-array.ts"),k=16,p=function(){function y(L,x,S){var d=S===void 0?{}:S,a=d.removePKCS7Padding,l=a===void 0?!0:a;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=L,this.config=x,this.removePKCS7Padding=l,l)try{var h=self.crypto;h&&(this.subtle=h.subtle||h.webkitSubtle)}catch(_){}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var P=y.prototype;return P.destroy=function(){this.observer=null},P.isSync=function(){return this.config.enableSoftwareAES},P.flush=function(){var x=this.currentResult;if(!x){this.reset();return}var S=new Uint8Array(x);return this.reset(),this.removePKCS7Padding?Object(w.removePadding)(S):S},P.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},P.decrypt=function(x,S,d,a){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(x),S,d);var l=this.flush();l&&a(l.buffer)}else this.webCryptoDecrypt(new Uint8Array(x),S,d).then(a)},P.softwareDecrypt=function(x,S,d){var a=this.currentIV,l=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt"),h&&(x=Object(N.appendUint8Array)(h,x),this.remainderData=null);var _=this.getValidChunk(x);if(!_.length)return null;a&&(d=a);var f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new w.default),f.expandKey(S);var b=l;return this.currentResult=f.decrypt(_.buffer,0,d),this.currentIV=Object(M.sliceUint8)(_,-16).buffer,b||null},P.webCryptoDecrypt=function(x,S,d){var a=this,l=this.subtle;return(this.key!==S||!this.fastAesKey)&&(this.key=S,this.fastAesKey=new I.default(l,S)),this.fastAesKey.expandKey().then(function(h){if(!l)return Promise.reject(new Error("web crypto not initialized"));var _=new V.default(l,d);return _.decrypt(x.buffer,h)}).catch(function(h){return a.onWebCryptoError(h,x,S,d)})},P.onWebCryptoError=function(x,S,d,a){return B.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",x),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(S,d,a)},P.getValidChunk=function(x){var S=x,d=x.length-x.length%k;return d!==x.length&&(S=Object(M.sliceUint8)(x,0,d),this.remainderData=Object(M.sliceUint8)(x,d)),S},P.logOnce=function(x){if(!this.logEnabled)return;B.logger.log("[decrypter.ts]: "+x),this.logEnabled=!1},y}()},"./src/crypt/fast-aes-key.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return V});var V=function(){function I(B,N){this.subtle=void 0,this.key=void 0,this.subtle=B,this.key=N}var w=I.prototype;return w.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},I}()},"./src/demux/aacdemuxer.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/demux/base-audio-demuxer.ts"),I=D("./src/demux/adts.ts"),w=D("./src/utils/logger.ts"),B=D("./src/demux/id3.ts");function N(p,y){p.prototype=Object.create(y.prototype),p.prototype.constructor=p,M(p,y)}function M(p,y){return M=Object.setPrototypeOf||function(L,x){return L.__proto__=x,L},M(p,y)}var k=function(p){N(y,p);function y(L,x){var S;return S=p.call(this)||this,S.observer=void 0,S.config=void 0,S.observer=L,S.config=x,S}var P=y.prototype;return P.resetInitSegment=function(x,S,d){p.prototype.resetInitSegment.call(this,x,S,d),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:x,duration:d,inputTimeScale:9e4,dropped:0}},y.probe=function(x){if(!x)return!1;for(var S=B.getID3Data(x,0)||[],d=S.length,a=x.length;d<a;d++)if(I.probe(x,d))return w.logger.log("ADTS sync word found !"),!0;return!1},P.canParse=function(x,S){return I.canParse(x,S)},P.appendFrame=function(x,S,d){I.initTrackConfig(x,this.observer,S,d,x.manifestCodec);var a=I.appendFrame(x,S,d,this.initPTS,this.frameIndex);if(a&&a.missing===0)return a},y}(V.default);k.minProbeByteLength=9,Y.default=k},"./src/demux/adts.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"getAudioConfig",function(){return B}),D.d(Y,"isHeaderPattern",function(){return N}),D.d(Y,"getHeaderLength",function(){return M}),D.d(Y,"getFullFrameLength",function(){return k}),D.d(Y,"canGetFrameLength",function(){return p}),D.d(Y,"isHeader",function(){return y}),D.d(Y,"canParse",function(){return P}),D.d(Y,"probe",function(){return L}),D.d(Y,"initTrackConfig",function(){return x}),D.d(Y,"getFrameDuration",function(){return S}),D.d(Y,"parseFrameHeader",function(){return d}),D.d(Y,"appendFrame",function(){return a});var V=D("./src/utils/logger.ts"),I=D("./src/errors.ts"),w=D("./src/events.ts");function B(l,h,_,f){var b,R,T,g,c=navigator.userAgent.toLowerCase(),u=f,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];b=((h[_+2]&192)>>>6)+1;var C=(h[_+2]&60)>>>2;if(C>o.length-1){l.trigger(w.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+C});return}return T=(h[_+2]&1)<<2,T|=(h[_+3]&192)>>>6,V.logger.log("manifest codec:"+f+", ADTS type:"+b+", samplingIndex:"+C),/firefox/i.test(c)?C>=6?(b=5,g=new Array(4),R=C-3):(b=2,g=new Array(2),R=C):c.indexOf("android")!==-1?(b=2,g=new Array(2),R=C):(b=5,g=new Array(4),f&&(f.indexOf("mp4a.40.29")!==-1||f.indexOf("mp4a.40.5")!==-1)||!f&&C>=6?R=C-3:((f&&f.indexOf("mp4a.40.2")!==-1&&(C>=6&&T===1||/vivaldi/i.test(c))||!f&&T===1)&&(b=2,g=new Array(2)),R=C)),g[0]=b<<3,g[0]|=(C&14)>>1,g[1]|=(C&1)<<7,g[1]|=T<<3,b===5&&(g[1]|=(R&14)>>1,g[2]=(R&1)<<7,g[2]|=2<<2,g[3]=0),{config:g,samplerate:o[C],channelCount:T,codec:"mp4a.40."+b,manifestCodec:u}}function N(l,h){return l[h]===255&&(l[h+1]&246)===240}function M(l,h){return l[h+1]&1?7:9}function k(l,h){return(l[h+3]&3)<<11|l[h+4]<<3|(l[h+5]&224)>>>5}function p(l,h){return h+5<l.length}function y(l,h){return h+1<l.length&&N(l,h)}function P(l,h){return p(l,h)&&N(l,h)&&k(l,h)<=l.length-h}function L(l,h){if(y(l,h)){var _=M(l,h);if(h+_>=l.length)return!1;var f=k(l,h);if(f<=_)return!1;var b=h+f;return b===l.length||y(l,b)}return!1}function x(l,h,_,f,b){if(!l.samplerate){var R=B(h,_,f,b);if(!R)return;l.config=R.config,l.samplerate=R.samplerate,l.channelCount=R.channelCount,l.codec=R.codec,l.manifestCodec=R.manifestCodec,V.logger.log("parsed codec:"+l.codec+", rate:"+R.samplerate+", channels:"+R.channelCount)}}function S(l){return 1024*9e4/l}function d(l,h,_,f,b){var R=M(l,h),T=k(l,h);if(T-=R,T>0){var g=_+f*b;return{headerLength:R,frameLength:T,stamp:g}}}function a(l,h,_,f,b){var R=S(l.samplerate),T=d(h,_,f,b,R);if(T){var g=T.frameLength,c=T.headerLength,u=T.stamp,o=c+g,C=Math.max(0,_+o-h.length),E;C?(E=new Uint8Array(o-c),E.set(h.subarray(_+c,h.length),0)):E=h.subarray(_+c,_+o);var v={unit:E,pts:u};return C||l.samples.push(v),{sample:v,length:o,missing:C}}}},"./src/demux/base-audio-demuxer.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"initPTSFn",function(){return k});var V=D("./src/polyfills/number.ts"),I=D("./src/demux/id3.ts"),w=D("./src/demux/dummy-demuxed-track.ts"),B=D("./src/utils/mp4-tools.ts"),N=D("./src/utils/typed-array.ts"),M=function(){function p(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var y=p.prototype;return y.resetInitSegment=function(L,x,S){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},y.resetTimeStamp=function(){},y.resetContiguity=function(){},y.canParse=function(L,x){return!1},y.appendFrame=function(L,x,S){},y.demux=function(L,x){this.cachedData&&(L=Object(B.appendUint8Array)(this.cachedData,L),this.cachedData=null);var S=I.getID3Data(L,0),d=S?S.length:0,a,l,h=this._audioTrack,_=this._id3Track,f=S?I.getTimeStamp(S):void 0,b=L.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=k(f,x)),S&&S.length>0&&_.samples.push({pts:this.initPTS,dts:this.initPTS,data:S}),l=this.initPTS;d<b;){if(this.canParse(L,d)){var R=this.appendFrame(h,L,d);R?(this.frameIndex++,l=R.sample.pts,d+=R.length,a=d):d=b}else I.canParse(L,d)?(S=I.getID3Data(L,d),_.samples.push({pts:l,dts:l,data:S}),d+=S.length,a=d):d++;if(d===b&&a!==b){var T=Object(N.sliceUint8)(L,a);this.cachedData?this.cachedData=Object(B.appendUint8Array)(this.cachedData,T):this.cachedData=T}}return{audioTrack:h,avcTrack:Object(w.dummyTrack)(),id3Track:_,textTrack:Object(w.dummyTrack)()}},y.demuxSampleAes=function(L,x,S){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},y.flush=function(L){var x=this.cachedData;return x&&(this.cachedData=null,this.demux(x,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(w.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(w.dummyTrack)()}},y.destroy=function(){},p}(),k=function(y,P){return Object(V.isFiniteNumber)(y)?y*90:P*9e4};Y.default=M},"./src/demux/chunk-cache.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return V});var V=function(){function w(){this.chunks=[],this.dataLength=0}var B=w.prototype;return B.push=function(M){this.chunks.push(M),this.dataLength+=M.length},B.flush=function(){var M=this.chunks,k=this.dataLength,p;if(M.length)M.length===1?p=M[0]:p=I(M,k);else return new Uint8Array(0);return this.reset(),p},B.reset=function(){this.chunks.length=0,this.dataLength=0},w}();function I(w,B){for(var N=new Uint8Array(B),M=0,k=0;k<w.length;k++){var p=w[k];N.set(p,M),M+=p.length}return N}},"./src/demux/dummy-demuxed-track.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"dummyTrack",function(){return V});function V(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/utils/logger.ts"),I=function(){function w(N){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=N,this.bytesAvailable=N.byteLength,this.word=0,this.bitsAvailable=0}var B=w.prototype;return B.loadWord=function(){var M=this.data,k=this.bytesAvailable,p=M.byteLength-k,y=new Uint8Array(4),P=Math.min(4,k);if(P===0)throw new Error("no bytes available");y.set(M.subarray(p,p+P)),this.word=new DataView(y.buffer).getUint32(0),this.bitsAvailable=P*8,this.bytesAvailable-=P},B.skipBits=function(M){var k;this.bitsAvailable>M?(this.word<<=M,this.bitsAvailable-=M):(M-=this.bitsAvailable,k=M>>3,M-=k>>3,this.bytesAvailable-=k,this.loadWord(),this.word<<=M,this.bitsAvailable-=M)},B.readBits=function(M){var k=Math.min(this.bitsAvailable,M),p=this.word>>>32-k;return M>32&&V.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=k,this.bitsAvailable>0?this.word<<=k:this.bytesAvailable>0&&this.loadWord(),k=M-k,k>0&&this.bitsAvailable?p<<k|this.readBits(k):p},B.skipLZ=function(){var M;for(M=0;M<this.bitsAvailable;++M)if((this.word&2147483648>>>M)!==0)return this.word<<=M,this.bitsAvailable-=M,M;return this.loadWord(),M+this.skipLZ()},B.skipUEG=function(){this.skipBits(1+this.skipLZ())},B.skipEG=function(){this.skipBits(1+this.skipLZ())},B.readUEG=function(){var M=this.skipLZ();return this.readBits(M+1)-1},B.readEG=function(){var M=this.readUEG();return 1&M?1+M>>>1:-1*(M>>>1)},B.readBoolean=function(){return this.readBits(1)===1},B.readUByte=function(){return this.readBits(8)},B.readUShort=function(){return this.readBits(16)},B.readUInt=function(){return this.readBits(32)},B.skipScalingList=function(M){for(var k=8,p=8,y,P=0;P<M;P++)p!==0&&(y=this.readEG(),p=(k+y+256)%256),k=p===0?k:p},B.readSPS=function(){var M=0,k=0,p=0,y=0,P,L,x,S=this.readUByte.bind(this),d=this.readBits.bind(this),a=this.readUEG.bind(this),l=this.readBoolean.bind(this),h=this.skipBits.bind(this),_=this.skipEG.bind(this),f=this.skipUEG.bind(this),b=this.skipScalingList.bind(this);S();var R=S();if(d(5),h(3),S(),f(),R===100||R===110||R===122||R===244||R===44||R===83||R===86||R===118||R===128){var T=a();if(T===3&&h(1),f(),f(),h(1),l())for(L=T!==3?8:12,x=0;x<L;x++)l()&&(x<6?b(16):b(64))}f();var g=a();if(g===0)a();else if(g===1)for(h(1),_(),_(),P=a(),x=0;x<P;x++)_();f(),h(1);var c=a(),u=a(),o=d(1);o===0&&h(1),h(1),l()&&(M=a(),k=a(),p=a(),y=a());var C=[1,1];if(l()&&l()){var E=S();switch(E){case 1:C=[1,1];break;case 2:C=[12,11];break;case 3:C=[10,11];break;case 4:C=[16,11];break;case 5:C=[40,33];break;case 6:C=[24,11];break;case 7:C=[20,11];break;case 8:C=[32,11];break;case 9:C=[80,33];break;case 10:C=[18,11];break;case 11:C=[15,11];break;case 12:C=[64,33];break;case 13:C=[160,99];break;case 14:C=[4,3];break;case 15:C=[3,2];break;case 16:C=[2,1];break;case 255:{C=[S()<<8|S(),S()<<8|S()];break}}}return{width:Math.ceil((c+1)*16-M*2-k*2),height:(2-o)*(u+1)*16-(o?2:4)*(p+y),pixelRatio:C}},B.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},w}();Y.default=I},"./src/demux/id3.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"isHeader",function(){return V}),D.d(Y,"isFooter",function(){return I}),D.d(Y,"getID3Data",function(){return w}),D.d(Y,"canParse",function(){return N}),D.d(Y,"getTimeStamp",function(){return M}),D.d(Y,"isTimeStampFrame",function(){return k}),D.d(Y,"getID3Frames",function(){return y}),D.d(Y,"decodeFrame",function(){return P}),D.d(Y,"utf8ArrayToStr",function(){return a}),D.d(Y,"testables",function(){return l});var V=function(b,R){return R+10<=b.length&&(b[R]===73&&b[R+1]===68&&b[R+2]===51&&(b[R+3]<255&&b[R+4]<255&&(b[R+6]<128&&b[R+7]<128&&b[R+8]<128&&b[R+9]<128)))},I=function(b,R){return R+10<=b.length&&(b[R]===51&&b[R+1]===68&&b[R+2]===73&&(b[R+3]<255&&b[R+4]<255&&(b[R+6]<128&&b[R+7]<128&&b[R+8]<128&&b[R+9]<128)))},w=function(b,R){for(var T=R,g=0;V(b,R);){g+=10;var c=B(b,R+6);g+=c,I(b,R+10)&&(g+=10),R+=g}return g>0?b.subarray(T,T+g):void 0},B=function(b,R){var T=0;return T=(b[R]&127)<<21,T|=(b[R+1]&127)<<14,T|=(b[R+2]&127)<<7,T|=b[R+3]&127,T},N=function(b,R){return V(b,R)&&B(b,R+6)+10<=b.length-R},M=function(b){for(var R=y(b),T=0;T<R.length;T++){var g=R[T];if(k(g))return d(g)}return},k=function(b){return b&&b.key==="PRIV"&&b.info==="com.apple.streaming.transportStreamTimestamp"},p=function(b){var R=String.fromCharCode(b[0],b[1],b[2],b[3]),T=B(b,4),g=10;return{type:R,size:T,data:b.subarray(g,g+T)}},y=function(b){for(var R=0,T=[];V(b,R);){var g=B(b,R+6);R+=10;for(var c=R+g;R+8<c;){var u=p(b.subarray(R)),o=P(u);o&&T.push(o),R+=u.size+10}I(b,R)&&(R+=10)}return T},P=function(b){return b.type==="PRIV"?L(b):b.type[0]==="W"?S(b):x(b)},L=function(b){if(b.size<2)return;var R=a(b.data,!0),T=new Uint8Array(b.data.subarray(R.length+1));return{key:b.type,info:R,data:T.buffer}},x=function(b){if(b.size<2)return;if(b.type==="TXXX"){var R=1,T=a(b.data.subarray(R),!0);R+=T.length+1;var g=a(b.data.subarray(R));return{key:b.type,info:T,data:g}}var c=a(b.data.subarray(1));return{key:b.type,data:c}},S=function(b){if(b.type==="WXXX"){if(b.size<2)return;var R=1,T=a(b.data.subarray(R),!0);R+=T.length+1;var g=a(b.data.subarray(R));return{key:b.type,info:T,data:g}}var c=a(b.data);return{key:b.type,data:c}},d=function(b){if(b.data.byteLength===8){var R=new Uint8Array(b.data),T=R[3]&1,g=(R[4]<<23)+(R[5]<<15)+(R[6]<<7)+R[7];return g/=45,T&&(g+=4772185884e-2),Math.round(g)}return},a=function(b,R){R===void 0&&(R=!1);var T=_();if(T){var g=T.decode(b);if(R){var c=g.indexOf("\0");return c!==-1?g.substring(0,c):g}return g.replace(/\0/g,"")}for(var u=b.length,o,C,E,v="",O=0;O<u;){if(o=b[O++],o===0&&R)return v;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:v+=String.fromCharCode(o);break;case 12:case 13:C=b[O++],v+=String.fromCharCode((o&31)<<6|C&63);break;case 14:C=b[O++],E=b[O++],v+=String.fromCharCode((o&15)<<12|(C&63)<<6|(E&63)<<0);break;default:}}return v},l={decodeTextFrame:x},h;function _(){return!h&&typeof self.TextDecoder!="undefined"&&(h=new self.TextDecoder("utf-8")),h}},"./src/demux/mp3demuxer.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/demux/base-audio-demuxer.ts"),I=D("./src/demux/id3.ts"),w=D("./src/utils/logger.ts"),B=D("./src/demux/mpegaudio.ts");function N(p,y){p.prototype=Object.create(y.prototype),p.prototype.constructor=p,M(p,y)}function M(p,y){return M=Object.setPrototypeOf||function(L,x){return L.__proto__=x,L},M(p,y)}var k=function(p){N(y,p);function y(){return p.apply(this,arguments)||this}var P=y.prototype;return P.resetInitSegment=function(x,S,d){p.prototype.resetInitSegment.call(this,x,S,d),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:x,duration:d,inputTimeScale:9e4,dropped:0}},y.probe=function(x){if(!x)return!1;for(var S=I.getID3Data(x,0)||[],d=S.length,a=x.length;d<a;d++)if(B.probe(x,d))return w.logger.log("MPEG Audio sync word found !"),!0;return!1},P.canParse=function(x,S){return B.canParse(x,S)},P.appendFrame=function(x,S,d){return this.initPTS===null?void 0:B.appendFrame(x,S,d,this.initPTS,this.frameIndex)},y}(V.default);k.minProbeByteLength=4,Y.default=k},"./src/demux/mp4demuxer.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/utils/mp4-tools.ts"),I=D("./src/demux/dummy-demuxed-track.ts"),w=function(){function B(M,k){this.remainderData=null,this.config=void 0,this.config=k}var N=B.prototype;return N.resetTimeStamp=function(){},N.resetInitSegment=function(){},N.resetContiguity=function(){},B.probe=function(k){return Object(V.findBox)({data:k,start:0,end:Math.min(k.length,16384)},["moof"]).length>0},N.demux=function(k){var p=k,y=Object(I.dummyTrack)();if(this.config.progressive){this.remainderData&&(p=Object(V.appendUint8Array)(this.remainderData,k));var P=Object(V.segmentValidRange)(p);this.remainderData=P.remainder,y.samples=P.valid||new Uint8Array}else y.samples=p;return{audioTrack:Object(I.dummyTrack)(),avcTrack:y,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},N.flush=function(){var k=Object(I.dummyTrack)();return k.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(I.dummyTrack)(),avcTrack:k,id3Track:Object(I.dummyTrack)(),textTrack:Object(I.dummyTrack)()}},N.demuxSampleAes=function(k,p,y){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},N.destroy=function(){},B}();w.minProbeByteLength=1024,Y.default=w},"./src/demux/mpegaudio.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"appendFrame",function(){return M}),D.d(Y,"parseHeader",function(){return k}),D.d(Y,"isHeaderPattern",function(){return p}),D.d(Y,"isHeader",function(){return y}),D.d(Y,"canParse",function(){return P}),D.d(Y,"probe",function(){return L});var V=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],w=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],B=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],N=[0,1,1,4];function M(x,S,d,a,l){if(d+24>S.length)return;var h=k(S,d);if(h&&d+h.frameLength<=S.length){var _=h.samplesPerFrame*9e4/h.sampleRate,f=a+l*_,b={unit:S.subarray(d,d+h.frameLength),pts:f,dts:f};return x.config=[],x.channelCount=h.channelCount,x.samplerate=h.sampleRate,x.samples.push(b),{sample:b,length:h.frameLength,missing:0}}}function k(x,S){var d=x[S+1]>>3&3,a=x[S+1]>>1&3,l=x[S+2]>>4&15,h=x[S+2]>>2&3;if(d!==1&&l!==0&&l!==15&&h!==3){var _=x[S+2]>>1&1,f=x[S+3]>>6,b=d===3?3-a:a===3?3:4,R=I[b*14+l-1]*1e3,T=d===3?0:d===2?1:2,g=w[T*3+h],c=f===3?1:2,u=B[d][a],o=N[a],C=u*8*o,E=Math.floor(u*R/g+_)*o;if(V===null){var v=navigator.userAgent||"",O=v.match(/Chrome\/(\d+)/i);V=O?parseInt(O[1]):0}var j=!!V&&V<=87;return j&&a===2&&R>=224e3&&f===0&&(x[S+3]=x[S+3]|128),{sampleRate:g,channelCount:c,frameLength:E,samplesPerFrame:C}}}function p(x,S){return x[S]===255&&(x[S+1]&224)===224&&(x[S+1]&6)!==0}function y(x,S){return S+1<x.length&&p(x,S)}function P(x,S){var d=4;return p(x,S)&&d<=x.length-S}function L(x,S){if(S+1<x.length&&p(x,S)){var d=4,a=k(x,S),l=d;a!=null&&a.frameLength&&(l=a.frameLength);var h=S+l;return h===x.length||y(x,h)}return!1}},"./src/demux/sample-aes.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/crypt/decrypter.ts"),I=D("./src/demux/tsdemuxer.ts"),w=function(){function B(M,k,p){this.keyData=void 0,this.decrypter=void 0,this.keyData=p,this.decrypter=new V.default(M,k,{removePKCS7Padding:!1})}var N=B.prototype;return N.decryptBuffer=function(k,p){this.decrypter.decrypt(k,this.keyData.key.buffer,this.keyData.iv.buffer,p)},N.decryptAacSample=function(k,p,y,P){var L=k[p].unit,x=L.subarray(16,L.length-L.length%16),S=x.buffer.slice(x.byteOffset,x.byteOffset+x.length),d=this;this.decryptBuffer(S,function(a){var l=new Uint8Array(a);L.set(l,16),P||d.decryptAacSamples(k,p+1,y)})},N.decryptAacSamples=function(k,p,y){for(;;p++){if(p>=k.length){y();return}if(k[p].unit.length<32)continue;var P=this.decrypter.isSync();if(this.decryptAacSample(k,p,y,P),!P)return}},N.getAvcEncryptedData=function(k){for(var p=Math.floor((k.length-48)/160)*16+16,y=new Int8Array(p),P=0,L=32;L<=k.length-16;L+=160,P+=16)y.set(k.subarray(L,L+16),P);return y},N.getAvcDecryptedUnit=function(k,p){for(var y=new Uint8Array(p),P=0,L=32;L<=k.length-16;L+=160,P+=16)k.set(y.subarray(P,P+16),L);return k},N.decryptAvcSample=function(k,p,y,P,L,x){var S=Object(I.discardEPB)(L.data),d=this.getAvcEncryptedData(S),a=this;this.decryptBuffer(d.buffer,function(l){L.data=a.getAvcDecryptedUnit(S,l),x||a.decryptAvcSamples(k,p,y+1,P)})},N.decryptAvcSamples=function(k,p,y,P){if(k instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;p++,y=0){if(p>=k.length){P();return}for(var L=k[p].units;!(y>=L.length);y++){var x=L[y];if(x.data.length<=48||x.type!==1&&x.type!==5)continue;var S=this.decrypter.isSync();if(this.decryptAvcSample(k,p,y,P,x,S),!S)return}}},B}();Y.default=w},"./src/demux/transmuxer-interface.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return L});var V=D("./node_modules/webworkify-webpack/index.js"),I=D.n(V),w=D("./src/events.ts"),B=D("./src/demux/transmuxer.ts"),N=D("./src/utils/logger.ts"),M=D("./src/errors.ts"),k=D("./src/utils/mediasource-helper.ts"),p=D("./node_modules/eventemitter3/index.js"),y=D.n(p),P=Object(k.getMediaSource)()||{isTypeSupported:function(){return!1}},L=function(){function x(d,a,l,h){var _=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=d,this.id=a,this.onTransmuxComplete=l,this.onFlush=h;var f=d.config,b=function(u,o){o=o||{},o.frag=_.frag,o.id=_.id,d.trigger(u,o)};this.observer=new p.EventEmitter,this.observer.on(w.Events.FRAG_DECRYPTED,b),this.observer.on(w.Events.ERROR,b);var R={mp4:P.isTypeSupported("video/mp4"),mpeg:P.isTypeSupported("audio/mpeg"),mp3:P.isTypeSupported('audio/mp4; codecs="mp3"')},T=navigator.vendor;if(f.enableWorker&&typeof Worker!="undefined"){N.logger.log("demuxing in webworker");var g;try{g=this.worker=V("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(c){d.trigger(w.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},g.postMessage({cmd:"init",typeSupported:R,vendor:T,id:a,config:JSON.stringify(f)})}catch(c){N.logger.warn("Error in worker:",c),N.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new B.default(this.observer,R,f,T,a),this.worker=null}}else this.transmuxer=new B.default(this.observer,R,f,T,a)}var S=x.prototype;return S.destroy=function(){var a=this.worker;if(a)a.removeEventListener("message",this.onwmsg),a.terminate(),this.worker=null;else{var l=this.transmuxer;l&&(l.destroy(),this.transmuxer=null)}var h=this.observer;h&&h.removeAllListeners(),this.observer=null},S.push=function(a,l,h,_,f,b,R,T,g,c){var u=this;g.transmuxing.start=self.performance.now();var o=this.transmuxer,C=this.worker,E=b?b.start:f.start,v=f.decryptdata,O=this.frag,j=!(O&&f.cc===O.cc),G=!(O&&g.level===O.level),J=O?g.sn-O.sn:-1,K=this.part?g.part-this.part.index:1,F=!G&&(J===1||J===0&&K===1),ee=self.performance.now();(G||J||f.stats.parsing.start===0)&&(f.stats.parsing.start=ee),b&&(K||!F)&&(b.stats.parsing.start=ee);var oe=new B.TransmuxState(j,F,T,G,E);if(!F||j){N.logger.log("[transmuxer-interface, "+f.type+"]: Starting new transmux session for sn: "+g.sn+" p: "+g.part+" level: "+g.level+" id: "+g.id+`
discontinuity: `+j+`
trackSwitch: `+G+`
contiguous: `+F+`
accurateTimeOffset: `+T+`
timeOffset: `+E);var he=new B.TransmuxConfig(h,_,l,R,c);this.configureTransmuxer(he)}if(this.frag=f,this.part=b,C)C.postMessage({cmd:"demux",data:a,decryptdata:v,chunkMeta:g,state:oe},a instanceof ArrayBuffer?[a]:[]);else if(o){var ge=o.push(a,v,g,oe);Object(B.isPromise)(ge)?ge.then(function(_e){u.handleTransmuxComplete(_e)}):this.handleTransmuxComplete(ge)}},S.flush=function(a){var l=this;a.transmuxing.start=self.performance.now();var h=this.transmuxer,_=this.worker;if(_)_.postMessage({cmd:"flush",chunkMeta:a});else if(h){var f=h.flush(a);Object(B.isPromise)(f)?f.then(function(b){l.handleFlushResult(b,a)}):this.handleFlushResult(f,a)}},S.handleFlushResult=function(a,l){var h=this;a.forEach(function(_){h.handleTransmuxComplete(_)}),this.onFlush(l)},S.onWorkerMessage=function(a){var l=a.data,h=this.hls;switch(l.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.id=this.id,h.trigger(l.event,l.data);break}}},S.configureTransmuxer=function(a){var l=this.worker,h=this.transmuxer;l?l.postMessage({cmd:"configure",config:a}):h&&h.configure(a)},S.handleTransmuxComplete=function(a){a.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(a)},x}()},"./src/demux/transmuxer-worker.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return M});var V=D("./src/demux/transmuxer.ts"),I=D("./src/events.ts"),w=D("./src/utils/logger.ts"),B=D("./node_modules/eventemitter3/index.js"),N=D.n(B);function M(L){var x=new B.EventEmitter,S=function(a,l){L.postMessage({event:a,data:l})};x.on(I.Events.FRAG_DECRYPTED,S),x.on(I.Events.ERROR,S),L.addEventListener("message",function(d){var a=d.data;switch(a.cmd){case"init":{var l=JSON.parse(a.config);L.transmuxer=new V.default(x,a.typeSupported,l,a.vendor,a.id),Object(w.enableLogs)(l.debug),S("init",null);break}case"configure":{L.transmuxer.configure(a.config);break}case"demux":{var h=L.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(V.isPromise)(h)?h.then(function(b){k(L,b)}):k(L,h);break}case"flush":{var _=a.chunkMeta,f=L.transmuxer.flush(_);Object(V.isPromise)(f)?f.then(function(b){y(L,b,_)}):y(L,f,_);break}default:break}})}function k(L,x){if(P(x.remuxResult))return;var S=[],d=x.remuxResult,a=d.audio,l=d.video;a&&p(S,a),l&&p(S,l),L.postMessage({event:"transmuxComplete",data:x},S)}function p(L,x){x.data1&&L.push(x.data1.buffer),x.data2&&L.push(x.data2.buffer)}function y(L,x,S){x.forEach(function(d){k(L,d)}),L.postMessage({event:"flush",data:S})}function P(L){return!L.audio&&!L.video&&!L.text&&!L.id3&&!L.initSegment}},"./src/demux/transmuxer.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return l}),D.d(Y,"isPromise",function(){return f}),D.d(Y,"TransmuxConfig",function(){return b}),D.d(Y,"TransmuxState",function(){return R});var V=D("./src/events.ts"),I=D("./src/errors.ts"),w=D("./src/crypt/decrypter.ts"),B=D("./src/demux/aacdemuxer.ts"),N=D("./src/demux/mp4demuxer.ts"),M=D("./src/demux/tsdemuxer.ts"),k=D("./src/demux/mp3demuxer.ts"),p=D("./src/remux/mp4-remuxer.ts"),y=D("./src/remux/passthrough-remuxer.ts"),P=D("./src/demux/chunk-cache.ts"),L=D("./src/utils/mp4-tools.ts"),x=D("./src/utils/logger.ts"),S;try{S=self.performance.now.bind(self.performance)}catch(T){x.logger.debug("Unable to use Performance API on this environment"),S=self.Date.now}var d=[{demux:M.default,remux:p.default},{demux:N.default,remux:y.default},{demux:B.default,remux:p.default},{demux:k.default,remux:p.default}],a=1024;d.forEach(function(T){var g=T.demux;a=Math.max(a,g.minProbeByteLength)});var l=function(){function T(c,u,o,C,E){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 P.default,this.observer=c,this.typeSupported=u,this.config=o,this.vendor=C,this.id=E}var g=T.prototype;return g.configure=function(u){this.transmuxConfig=u,this.decrypter&&this.decrypter.reset()},g.push=function(u,o,C,E){var v=this,O=C.transmuxing;O.executeStart=S();var j=new Uint8Array(u),G=this.cache,J=this.config,K=this.currentTransmuxState,F=this.transmuxConfig;E&&(this.currentTransmuxState=E);var ee=h(j,o);if(ee&&ee.method==="AES-128"){var oe=this.getDecrypter();if(J.enableSoftwareAES){var he=oe.softwareDecrypt(j,ee.key.buffer,ee.iv.buffer);if(!he)return O.executeEnd=S(),_(C);j=new Uint8Array(he)}else return this.decryptionPromise=oe.webCryptoDecrypt(j,ee.key.buffer,ee.iv.buffer).then(function(je){var $e=v.push(je,null,C);return v.decryptionPromise=null,$e}),this.decryptionPromise}var ge=E||K,_e=ge.contiguous,be=ge.discontinuity,Ee=ge.trackSwitch,Te=ge.accurateTimeOffset,Ce=ge.timeOffset,me=F.audioCodec,se=F.videoCodec,Re=F.defaultInitPts,et=F.duration,Ge=F.initSegmentData;if((be||Ee)&&this.resetInitSegment(Ge,me,se,et),be&&this.resetInitialTimestamp(Re),_e||this.resetContiguity(),this.needsProbing(j,be,Ee)){if(G.dataLength){var tt=G.flush();j=Object(L.appendUint8Array)(tt,j)}this.configureTransmuxer(j,F)}var Ye=this.transmux(j,ee,Ce,Te,C),De=this.currentTransmuxState;return De.contiguous=!0,De.discontinuity=!1,De.trackSwitch=!1,O.executeEnd=S(),Ye},g.flush=function(u){var o=this,C=u.transmuxing;C.executeStart=S();var E=this.decrypter,v=this.cache,O=this.currentTransmuxState,j=this.decryptionPromise;if(j)return j.then(function(){return o.flush(u)});var G=[],J=O.timeOffset;if(E){var K=E.flush();K&&G.push(this.push(K,null,u))}var F=v.dataLength;v.reset();var ee=this.demuxer,oe=this.remuxer;if(!ee||!oe)return F>=a&&this.observer.emit(V.Events.ERROR,V.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),C.executeEnd=S(),[_(u)];var he=ee.flush(J);return f(he)?he.then(function(ge){return o.flushRemux(G,ge,u),G}):(this.flushRemux(G,he,u),G)},g.flushRemux=function(u,o,C){var E=o.audioTrack,v=o.avcTrack,O=o.id3Track,j=o.textTrack,G=this.currentTransmuxState,J=G.accurateTimeOffset,K=G.timeOffset;x.logger.log("[transmuxer.ts]: Flushed fragment "+C.sn+(C.part>-1?" p: "+C.part:"")+" of level "+C.level);var F=this.remuxer.remux(E,v,O,j,K,J,!0,this.id);u.push({remuxResult:F,chunkMeta:C}),C.transmuxing.executeEnd=S()},g.resetInitialTimestamp=function(u){var o=this.demuxer,C=this.remuxer;if(!o||!C)return;o.resetTimeStamp(u),C.resetTimeStamp(u)},g.resetContiguity=function(){var u=this.demuxer,o=this.remuxer;if(!u||!o)return;u.resetContiguity(),o.resetNextTimestamp()},g.resetInitSegment=function(u,o,C,E){var v=this.demuxer,O=this.remuxer;if(!v||!O)return;v.resetInitSegment(o,C,E),O.resetInitSegment(u,o,C)},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(u,o,C,E,v){var O;return o&&o.method==="SAMPLE-AES"?O=this.transmuxSampleAes(u,o,C,E,v):O=this.transmuxUnencrypted(u,C,E,v),O},g.transmuxUnencrypted=function(u,o,C,E){var v=this.demuxer.demux(u,o,!1,!this.config.progressive),O=v.audioTrack,j=v.avcTrack,G=v.id3Track,J=v.textTrack,K=this.remuxer.remux(O,j,G,J,o,C,!1,this.id);return{remuxResult:K,chunkMeta:E}},g.transmuxSampleAes=function(u,o,C,E,v){var O=this;return this.demuxer.demuxSampleAes(u,o,C).then(function(j){var G=O.remuxer.remux(j.audioTrack,j.avcTrack,j.id3Track,j.textTrack,C,E,!1,O.id);return{remuxResult:G,chunkMeta:v}})},g.configureTransmuxer=function(u,o){for(var C=this.config,E=this.observer,v=this.typeSupported,O=this.vendor,j=o.audioCodec,G=o.defaultInitPts,J=o.duration,K=o.initSegmentData,F=o.videoCodec,ee,oe=0,he=d.length;oe<he;oe++)if(d[oe].demux.probe(u)){ee=d[oe];break}ee||(x.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),ee={demux:N.default,remux:y.default});var ge=this.demuxer,_e=this.remuxer,be=ee.remux,Ee=ee.demux;(!_e||!(_e instanceof be))&&(this.remuxer=new be(E,C,v,O)),(!ge||!(ge instanceof Ee))&&(this.demuxer=new Ee(E,C,v),this.probe=Ee.probe),this.resetInitSegment(K,j,F,J),this.resetInitialTimestamp(G)},g.needsProbing=function(u,o,C){return!this.demuxer||!this.remuxer||o||C},g.getDecrypter=function(){var u=this.decrypter;return u||(u=this.decrypter=new w.default(this.observer,this.config)),u},T}();function h(T,g){var c=null;return T.byteLength>0&&g!=null&&g.key!=null&&g.iv!==null&&g.method!=null&&(c=g),c}var _=function(g){return{remuxResult:{},chunkMeta:g}};function f(T){return"then"in T&&T.then instanceof Function}var b=function(g,c,u,o,C){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=g,this.videoCodec=c,this.initSegmentData=u,this.duration=o,this.defaultInitPts=C},R=function(g,c,u,o,C){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.discontinuity=g,this.contiguous=c,this.accurateTimeOffset=u,this.trackSwitch=o,this.timeOffset=C}},"./src/demux/tsdemuxer.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"discardEPB",function(){return _});var V=D("./src/demux/adts.ts"),I=D("./src/demux/mpegaudio.ts"),w=D("./src/demux/exp-golomb.ts"),B=D("./src/demux/id3.ts"),N=D("./src/demux/sample-aes.ts"),M=D("./src/events.ts"),k=D("./src/utils/mp4-tools.ts"),p=D("./src/utils/logger.ts"),y=D("./src/errors.ts"),P={video:1,audio:2,id3:3,text:4},L=function(){function f(R,T,g){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=R,this.config=T,this.typeSupported=g}f.probe=function(T){var g=f.syncOffset(T);return g<0?!1:(g&&p.logger.warn("MPEG2-TS detected but first sync word found @ offset "+g+", junk ahead ?"),!0)},f.syncOffset=function(T){for(var g=Math.min(1e3,T.length-3*188),c=0;c<g;){if(T[c]===71&&T[c+188]===71&&T[c+2*188]===71)return c;c++}return-1},f.createTrack=function(T,g){return{container:T==="video"||T==="audio"?"video/mp2t":void 0,type:T,id:P[T],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:T==="audio"?g:void 0}};var b=f.prototype;return b.resetInitSegment=function(T,g,c){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=f.createTrack("video",c),this._audioTrack=f.createTrack("audio",c),this._id3Track=f.createTrack("id3",c),this._txtTrack=f.createTrack("text",c),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=T,this.videoCodec=g,this._duration=c},b.resetTimeStamp=function(){},b.resetContiguity=function(){var T=this._audioTrack,g=this._avcTrack,c=this._id3Track;T&&(T.pesData=null),g&&(g.pesData=null),c&&(c.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},b.demux=function(T,g,c,u){c===void 0&&(c=!1),u===void 0&&(u=!1),c||(this.sampleAes=null);var o,C=this._avcTrack,E=this._audioTrack,v=this._id3Track,O=C.pid,j=C.pesData,G=E.pid,J=v.pid,K=E.pesData,F=v.pesData,ee=!1,oe=this.pmtParsed,he=this._pmtId,ge=T.length;if(this.remainderData&&(T=Object(k.appendUint8Array)(this.remainderData,T),ge=T.length,this.remainderData=null),ge<188&&!u)return this.remainderData=T,{audioTrack:E,avcTrack:C,id3Track:v,textTrack:this._txtTrack};var _e=Math.max(0,f.syncOffset(T));ge-=(ge+_e)%188,ge<T.byteLength&&!u&&(this.remainderData=new Uint8Array(T.buffer,ge,T.buffer.byteLength-ge));for(var be=_e;be<ge;be+=188)if(T[be]===71){var Ee=!!(T[be+1]&64),Te=((T[be+1]&31)<<8)+T[be+2],Ce=(T[be+3]&48)>>4,me=void 0;if(Ce>1){if(me=be+5+T[be+4],me===be+188)continue}else me=be+4;switch(Te){case O:Ee&&(j&&(o=a(j))&&this.parseAVCPES(o,!1),j={data:[],size:0}),j&&(j.data.push(T.subarray(me,be+188)),j.size+=be+188-me);break;case G:Ee&&(K&&(o=a(K))&&(E.isAAC?this.parseAACPES(o):this.parseMPEGPES(o)),K={data:[],size:0}),K&&(K.data.push(T.subarray(me,be+188)),K.size+=be+188-me);break;case J:Ee&&(F&&(o=a(F))&&this.parseID3PES(o),F={data:[],size:0}),F&&(F.data.push(T.subarray(me,be+188)),F.size+=be+188-me);break;case 0:Ee&&(me+=T[me]+1),he=this._pmtId=S(T,me);break;case he:{Ee&&(me+=T[me]+1);var se=d(T,me,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,c);O=se.avc,O>0&&(C.pid=O),G=se.audio,G>0&&(E.pid=G,E.isAAC=se.isAAC),J=se.id3,J>0&&(v.pid=J),ee&&!oe&&(p.logger.log("reparse from beginning"),ee=!1,be=_e-188),oe=this.pmtParsed=!0;break}case 17:case 8191:break;default:ee=!0;break}}else this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});C.pesData=j,E.pesData=K,v.pesData=F;var Re={audioTrack:E,avcTrack:C,id3Track:v,textTrack:this._txtTrack};return u&&this.extractRemainingSamples(Re),Re},b.flush=function(){var T=this.remainderData;this.remainderData=null;var g;return T?g=this.demux(T,-1,!1,!0):g={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(g),this.sampleAes?this.decrypt(g,this.sampleAes):g},b.extractRemainingSamples=function(T){var g=T.audioTrack,c=T.avcTrack,u=T.id3Track,o=c.pesData,C=g.pesData,E=u.pesData,v;o&&(v=a(o))?(this.parseAVCPES(v,!0),c.pesData=null):c.pesData=o,C&&(v=a(C))?(g.isAAC?this.parseAACPES(v):this.parseMPEGPES(v),g.pesData=null):(C!=null&&C.size&&p.logger.log("last AAC PES packet truncated,might overlap between fragments"),g.pesData=C),E&&(v=a(E))?(this.parseID3PES(v),u.pesData=null):u.pesData=E},b.demuxSampleAes=function(T,g,c){var u=this.demux(T,c,!0,!this.config.progressive),o=this.sampleAes=new N.default(this.observer,this.config,g);return this.decrypt(u,o)},b.decrypt=function(T,g){return new Promise(function(c){var u=T.audioTrack,o=T.avcTrack;u.samples&&u.isAAC?g.decryptAacSamples(u.samples,0,function(){o.samples?g.decryptAvcSamples(o.samples,0,0,function(){c(T)}):c(T)}):o.samples&&g.decryptAvcSamples(o.samples,0,0,function(){c(T)})})},b.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},b.parseAVCPES=function(T,g){var c=this,u=this._avcTrack,o=this.parseAVCNALu(T.data),C=!1,E=this.avcSample,v,O=!1;T.data=null,E&&o.length&&!u.audFound&&(l(E,u),E=this.avcSample=x(!1,T.pts,T.dts,"")),o.forEach(function(j){switch(j.type){case 1:{v=!0,E||(E=c.avcSample=x(!0,T.pts,T.dts,"")),C&&(E.debug+="NDR "),E.frame=!0;var G=j.data;if(O&&G.length>4){var J=new w.default(G).readSliceType();(J===2||J===4||J===7||J===9)&&(E.key=!0)}break}case 5:v=!0,E||(E=c.avcSample=x(!0,T.pts,T.dts,"")),C&&(E.debug+="IDR "),E.key=!0,E.frame=!0;break;case 6:{v=!0,C&&E&&(E.debug+="SEI ");var K=new w.default(_(j.data));K.readUByte();for(var F=0,ee=0,oe=!1,he=0;!oe&&K.bytesAvailable>1;){F=0;do he=K.readUByte(),F+=he;while(he===255);ee=0;do he=K.readUByte(),ee+=he;while(he===255);if(F===4&&K.bytesAvailable!==0){oe=!0;var ge=K.readUByte();if(ge===181){var _e=K.readUShort();if(_e===49){var be=K.readUInt();if(be===1195456820){var Ee=K.readUByte();if(Ee===3){for(var Te=K.readUByte(),Ce=K.readUByte(),me=31&Te,se=[Te,Ce],Re=0;Re<me;Re++)se.push(K.readUByte()),se.push(K.readUByte()),se.push(K.readUByte());h(c._txtTrack.samples,{type:3,pts:T.pts,bytes:se})}}}}}else if(F===5&&K.bytesAvailable!==0){if(oe=!0,ee>16){for(var et=[],Ge=0;Ge<16;Ge++)et.push(K.readUByte().toString(16)),(Ge===3||Ge===5||Ge===7||Ge===9)&&et.push("-");for(var tt=ee-16,Ye=new Uint8Array(tt),De=0;De<tt;De++)Ye[De]=K.readUByte();h(c._txtTrack.samples,{pts:T.pts,payloadType:F,uuid:et.join(""),userData:Object(B.utf8ArrayToStr)(Ye),userDataBytes:Ye})}}else if(ee<K.bytesAvailable)for(var je=0;je<ee;je++)K.readUByte()}break}case 7:if(v=!0,O=!0,C&&E&&(E.debug+="SPS "),!u.sps){var $e=new w.default(j.data),st=$e.readSPS();u.width=st.width,u.height=st.height,u.pixelRatio=st.pixelRatio,u.sps=[j.data],u.duration=c._duration;for(var Qe=j.data.subarray(1,4),Be="avc1.",We=0;We<3;We++){var ft=Qe[We].toString(16);ft.length<2&&(ft="0"+ft),Be+=ft}u.codec=Be}break;case 8:v=!0,C&&E&&(E.debug+="PPS "),u.pps||(u.pps=[j.data]);break;case 9:v=!1,u.audFound=!0,E&&l(E,u),E=c.avcSample=x(!1,T.pts,T.dts,C?"AUD ":"");break;case 12:v=!1;break;default:v=!1,E&&(E.debug+="unknown NAL "+j.type+" ");break}if(E&&v){var Ke=E.units;Ke.push(j)}}),g&&E&&(l(E,u),this.avcSample=null)},b.getLastNalUnit=function(){var T,g=this.avcSample,c;if(!g||g.units.length===0){var u=this._avcTrack.samples;g=u[u.length-1]}if((T=g)!==null&&T!==void 0&&T.units){var o=g.units;c=o[o.length-1]}return c},b.parseAVCNALu=function(T){var g=T.byteLength,c=this._avcTrack,u=c.naluState||0,o=u,C=[],E=0,v,O,j,G=-1,J=0;for(u===-1&&(G=0,J=T[0]&31,u=0,E=1);E<g;){if(v=T[E++],!u){u=v?0:1;continue}if(u===1){u=v?0:2;continue}if(!v)u=3;else if(v===1){if(G>=0){var K={data:T.subarray(G,E-u-1),type:J};C.push(K)}else{var F=this.getLastNalUnit();if(F&&(o&&E<=4-o&&(F.state&&(F.data=F.data.subarray(0,F.data.byteLength-o))),O=E-u-1,O>0)){var ee=new Uint8Array(F.data.byteLength+O);ee.set(F.data,0),ee.set(T.subarray(0,O),F.data.byteLength),F.data=ee,F.state=0}}E<g?(j=T[E]&31,G=E,J=j,u=0):u=-1}else u=0}if(G>=0&&u>=0){var oe={data:T.subarray(G,g),type:J,state:u};C.push(oe)}if(C.length===0){var he=this.getLastNalUnit();if(he){var ge=new Uint8Array(he.data.byteLength+T.byteLength);ge.set(he.data,0),ge.set(T,he.data.byteLength),he.data=ge}}return c.naluState=u,C},b.parseAACPES=function(T){var g=0,c=this._audioTrack,u=this.aacOverFlow,o=T.data;if(u){this.aacOverFlow=null;var C=u.sample.unit.byteLength,E=Math.min(u.missing,C),v=C-E;u.sample.unit.set(o.subarray(0,E),v),c.samples.push(u.sample),g=u.missing}var O,j;for(O=g,j=o.length;O<j-1&&!V.isHeader(o,O);O++);if(O!==g){var G,J;if(O<j-1?(G="AAC PES did not start with ADTS header,offset:"+O,J=!1):(G="no ADTS header found in AAC PES",J=!0),p.logger.warn("parsing error:"+G),this.observer.emit(M.Events.ERROR,M.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:J,reason:G}),J)return}V.initTrackConfig(c,this.observer,o,O,this.audioCodec);var K;if(T.pts!==void 0)K=T.pts;else if(u){var F=V.getFrameDuration(c.samplerate);K=u.sample.pts+F}else{p.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var ee=0;O<j;)if(V.isHeader(o,O)){if(O+5<j){var oe=V.appendFrame(c,o,O,K,ee);if(oe)if(oe.missing)this.aacOverFlow=oe;else{O+=oe.length,ee++;continue}}break}else O++},b.parseMPEGPES=function(T){var g=T.data,c=g.length,u=0,o=0,C=T.pts;if(C===void 0){p.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<c;)if(I.isHeader(g,o)){var E=I.appendFrame(this._audioTrack,g,o,C,u);if(E)o+=E.length,u++;else break}else o++},b.parseID3PES=function(T){if(T.pts===void 0){p.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(T)},f}();L.minProbeByteLength=188;function x(f,b,R,T){return{key:f,frame:!1,pts:b,dts:R,units:[],debug:T,length:0}}function S(f,b){return(f[b+10]&31)<<8|f[b+11]}function d(f,b,R,T){var g={audio:-1,avc:-1,id3:-1,isAAC:!0},c=(f[b+1]&15)<<8|f[b+2],u=b+3+c-4,o=(f[b+10]&15)<<8|f[b+11];for(b+=12+o;b<u;){var C=(f[b+1]&31)<<8|f[b+2];switch(f[b]){case 207:if(!T){p.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:g.audio===-1&&(g.audio=C);break;case 21:g.id3===-1&&(g.id3=C);break;case 219:if(!T){p.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:g.avc===-1&&(g.avc=C);break;case 3:case 4:R?g.audio===-1&&(g.audio=C,g.isAAC=!1):p.logger.log("MPEG audio found, not supported in this browser");break;case 36:p.logger.warn("Unsupported HEVC stream type found");break;default:break}b+=((f[b+3]&15)<<8|f[b+4])+5}return g}function a(f){var b=0,R,T,g,c,u,o=f.data;if(!f||f.size===0)return null;for(;o[0].length<19&&o.length>1;){var C=new Uint8Array(o[0].length+o[1].length);C.set(o[0]),C.set(o[1],o[0].length),o[0]=C,o.splice(1,1)}R=o[0];var E=(R[0]<<16)+(R[1]<<8)+R[2];if(E===1){if(T=(R[4]<<8)+R[5],T&&T>f.size-6)return null;var v=R[7];v&192&&(c=(R[9]&14)*536870912+(R[10]&255)*4194304+(R[11]&254)*16384+(R[12]&255)*128+(R[13]&254)/2,v&64?(u=(R[14]&14)*536870912+(R[15]&255)*4194304+(R[16]&254)*16384+(R[17]&255)*128+(R[18]&254)/2,c-u>60*9e4&&(p.logger.warn(Math.round((c-u)/9e4)+"s delta between PTS and DTS, align them"),c=u)):u=c),g=R[8];var O=g+9;if(f.size<=O)return null;f.size-=O;for(var j=new Uint8Array(f.size),G=0,J=o.length;G<J;G++){R=o[G];var K=R.byteLength;if(O)if(O>K){O-=K;continue}else R=R.subarray(O),K-=O,O=0;j.set(R,b),b+=K}return T&&(T-=g+3),{data:j,pts:c,dts:u,len:T}}return null}function l(f,b){if(f.units.length&&f.frame){if(f.pts===void 0){var R=b.samples,T=R.length;if(T){var g=R[T-1];f.pts=g.pts,f.dts=g.dts}else{b.dropped++;return}}b.samples.push(f)}f.debug.length&&p.logger.log(f.pts+"/"+f.dts+":"+f.debug)}function h(f,b){var R=f.length;if(R>0){if(b.pts>=f[R-1].pts)f.push(b);else for(var T=R-1;T>=0;T--)if(b.pts<f[T].pts){f.splice(T,0,b);break}}else f.push(b)}function _(f){for(var b=f.byteLength,R=[],T=1;T<b-2;)f[T]===0&&f[T+1]===0&&f[T+2]===3?(R.push(T+2),T+=2):T++;if(R.length===0)return f;var g=b-R.length,c=new Uint8Array(g),u=0;for(T=0;T<g;u++,T++)u===R[0]&&(u++,R.shift()),c[T]=f[u];return c}Y.default=L},"./src/errors.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"ErrorTypes",function(){return V}),D.d(Y,"ErrorDetails",function(){return I});var V;(function(w){w.NETWORK_ERROR="networkError",w.MEDIA_ERROR="mediaError",w.KEY_SYSTEM_ERROR="keySystemError",w.MUX_ERROR="muxError",w.OTHER_ERROR="otherError"})(V||(V={}));var I;(function(w){w.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",w.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",w.KEY_SYSTEM_NO_SESSION="keySystemNoSession",w.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",w.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",w.MANIFEST_LOAD_ERROR="manifestLoadError",w.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",w.MANIFEST_PARSING_ERROR="manifestParsingError",w.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",w.LEVEL_EMPTY_ERROR="levelEmptyError",w.LEVEL_LOAD_ERROR="levelLoadError",w.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",w.LEVEL_SWITCH_ERROR="levelSwitchError",w.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",w.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",w.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",w.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",w.FRAG_LOAD_ERROR="fragLoadError",w.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",w.FRAG_DECRYPT_ERROR="fragDecryptError",w.FRAG_PARSING_ERROR="fragParsingError",w.REMUX_ALLOC_ERROR="remuxAllocError",w.KEY_LOAD_ERROR="keyLoadError",w.KEY_LOAD_TIMEOUT="keyLoadTimeOut",w.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",w.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",w.BUFFER_APPEND_ERROR="bufferAppendError",w.BUFFER_APPENDING_ERROR="bufferAppendingError",w.BUFFER_STALLED_ERROR="bufferStalledError",w.BUFFER_FULL_ERROR="bufferFullError",w.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",w.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",w.INTERNAL_EXCEPTION="internalException",w.INTERNAL_ABORTED="aborted",w.UNKNOWN="unknown"})(I||(I={}))},"./src/events.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"Events",function(){return V});var V;(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"})(V||(V={}))},"./src/hls.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return f});var V=D("./node_modules/url-toolkit/src/url-toolkit.js"),I=D.n(V),w=D("./src/loader/playlist-loader.ts"),B=D("./src/loader/key-loader.ts"),N=D("./src/controller/id3-track-controller.ts"),M=D("./src/controller/latency-controller.ts"),k=D("./src/controller/level-controller.ts"),p=D("./src/controller/fragment-tracker.ts"),y=D("./src/controller/stream-controller.ts"),P=D("./src/is-supported.ts"),L=D("./src/utils/logger.ts"),x=D("./src/config.ts"),S=D("./node_modules/eventemitter3/index.js"),d=D.n(S),a=D("./src/events.ts"),l=D("./src/errors.ts");function h(b,R){for(var T=0;T<R.length;T++){var g=R[T];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(b,g.key,g)}}function _(b,R,T){return R&&h(b.prototype,R),T&&h(b,T),b}var f=function(){b.isSupported=function(){return Object(P.isSupported)()};function b(T){T===void 0&&(T={}),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 g=this.config=Object(x.mergeConfig)(b.DefaultConfig,T);this.userConfig=T,Object(L.enableLogs)(g.debug),this._autoLevelCapping=-1,g.progressive&&Object(x.enableStreamingMode)(g);var c=g.abrController,u=g.bufferController,o=g.capLevelController,C=g.fpsController,E=this.abrController=new c(this),v=this.bufferController=new u(this),O=this.capLevelController=new o(this),j=new C(this),G=new w.default(this),J=new B.default(this),K=new N.default(this),F=this.levelController=new k.default(this),ee=new p.FragmentTracker(this),oe=this.streamController=new y.default(this,ee);O.setStreamController(oe),j.setStreamController(oe);var he=[F,oe];this.networkControllers=he;var ge=[G,J,E,v,O,j,K,ee];this.audioTrackController=this.createController(g.audioTrackController,null,he),this.createController(g.audioStreamController,ee,he),this.subtitleTrackController=this.createController(g.subtitleTrackController,null,he),this.createController(g.subtitleStreamController,ee,he),this.createController(g.timelineController,null,ge),this.emeController=this.createController(g.emeController,null,ge),this.cmcdController=this.createController(g.cmcdController,null,ge),this.latencyController=this.createController(M.default,null,ge),this.coreComponents=ge}var R=b.prototype;return R.createController=function(g,c,u){if(g){var o=c?new g(this,c):new g(this);return u&&u.push(o),o}return null},R.on=function(g,c,u){u===void 0&&(u=this),this._emitter.on(g,c,u)},R.once=function(g,c,u){u===void 0&&(u=this),this._emitter.once(g,c,u)},R.removeAllListeners=function(g){this._emitter.removeAllListeners(g)},R.off=function(g,c,u,o){u===void 0&&(u=this),this._emitter.off(g,c,u,o)},R.listeners=function(g){return this._emitter.listeners(g)},R.emit=function(g,c,u){return this._emitter.emit(g,c,u)},R.trigger=function(g,c){if(this.config.debug)return this.emit(g,g,c);try{return this.emit(g,g,c)}catch(u){L.logger.error("An internal error happened while handling event "+g+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(a.Events.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:g,error:u})}return!1},R.listenerCount=function(g){return this._emitter.listenerCount(g)},R.destroy=function(){L.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(g){return g.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(g){return g.destroy()}),this.coreComponents.length=0},R.attachMedia=function(g){L.logger.log("attachMedia"),this._media=g,this.trigger(a.Events.MEDIA_ATTACHING,{media:g})},R.detachMedia=function(){L.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},R.loadSource=function(g){this.stopLoad();var c=this.media,u=this.url,o=this.url=V.buildAbsoluteURL(self.location.href,g,{alwaysNormalize:!0});L.logger.log("loadSource:"+o),c&&u&&u!==o&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(c)),this.trigger(a.Events.MANIFEST_LOADING,{url:g})},R.startLoad=function(g){g===void 0&&(g=-1),L.logger.log("startLoad("+g+")"),this.networkControllers.forEach(function(c){c.startLoad(g)})},R.stopLoad=function(){L.logger.log("stopLoad"),this.networkControllers.forEach(function(g){g.stopLoad()})},R.swapAudioCodec=function(){L.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},R.recoverMediaError=function(){L.logger.log("recoverMediaError");var g=this._media;this.detachMedia(),g&&this.attachMedia(g)},R.removeLevel=function(g,c){c===void 0&&(c=0),this.levelController.removeLevel(g,c)},_(b,[{key:"levels",get:function(){var g=this.levelController.levels;return g||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(g){L.logger.log("set currentLevel:"+g),this.loadLevel=g,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(g){L.logger.log("set nextLevel:"+g),this.levelController.manualLevel=g,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(g){L.logger.log("set loadLevel:"+g),this.levelController.manualLevel=g}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(g){this.levelController.nextLoadLevel=g}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(g){L.logger.log("set firstLevel:"+g),this.levelController.firstLevel=g}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(g){L.logger.log("set startLevel:"+g),g!==-1&&(g=Math.max(g,this.minAutoLevel)),this.levelController.startLevel=g}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(g){var c=!!g;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(g){this._autoLevelCapping!==g&&(L.logger.log("set autoLevelCapping:"+g),this._autoLevelCapping=g)}},{key:"bandwidthEstimate",get:function(){var g=this.abrController.bwEstimator;return g?g.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var g=this.levels,c=this.config.minAutoBitrate;if(!g)return 0;for(var u=g.length,o=0;o<u;o++)if(g[o].maxBitrate>c)return o;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,c=this.autoLevelCapping,u;return c===-1&&g&&g.length?u=g.length-1:u=c,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var c=this.audioTrackController;c&&(c.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var c=this.subtitleTrackController;c&&(c.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return g?g.subtitleDisplay:!1},set:function(g){var c=this.subtitleTrackController;c&&(c.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{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 a.Events}},{key:"ErrorTypes",get:function(){return l.ErrorTypes}},{key:"ErrorDetails",get:function(){return l.ErrorDetails}},{key:"DefaultConfig",get:function(){return b.defaultConfig?b.defaultConfig:x.hlsDefaultConfig},set:function(g){b.defaultConfig=g}}]),b}();f.defaultConfig=void 0},"./src/is-supported.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"isSupported",function(){return w}),D.d(Y,"changeTypeSupported",function(){return B});var V=D("./src/utils/mediasource-helper.ts");function I(){return self.SourceBuffer||self.WebKitSourceBuffer}function w(){var N=Object(V.getMediaSource)();if(!N)return!1;var M=I(),k=N&&typeof N.isTypeSupported=="function"&&N.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),p=!M||M.prototype&&typeof M.prototype.appendBuffer=="function"&&typeof M.prototype.remove=="function";return!!k&&!!p}function B(){var N,M=I();return typeof(M==null||((N=M.prototype)===null||N===void 0)?void 0:N.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return L}),D.d(Y,"LoadError",function(){return S});var V=D("./src/polyfills/number.ts"),I=D("./src/errors.ts");function w(d,a){d.prototype=Object.create(a.prototype),d.prototype.constructor=d,p(d,a)}function B(d){var a=typeof Map=="function"?new Map:void 0;return B=function(h){if(h===null||!k(h))return h;if(typeof h!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(h))return a.get(h);a.set(h,_)}function _(){return N(h,arguments,y(this).constructor)}return _.prototype=Object.create(h.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),p(_,h)},B(d)}function N(d,a,l){return M()?N=Reflect.construct:N=function(_,f,b){var R=[null];R.push.apply(R,f);var T=Function.bind.apply(_,R),g=new T;return b&&p(g,b.prototype),g},N.apply(null,arguments)}function M(){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(d){return!1}}function k(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function p(d,a){return p=Object.setPrototypeOf||function(h,_){return h.__proto__=_,h},p(d,a)}function y(d){return y=Object.setPrototypeOf?Object.getPrototypeOf:function(l){return l.__proto__||Object.getPrototypeOf(l)},y(d)}var P=Math.pow(2,17),L=function(){function d(l){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=l}var a=d.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(h,_){var f=this,b=h.url;if(!b)return Promise.reject(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,networkDetails:null},"Fragment does not have a "+(b?"part list":"url")));this.abort();var R=this.config,T=R.fLoader,g=R.loader;return new Promise(function(c,u){f.loader&&f.loader.destroy();var o=f.loader=h.loader=T?new T(R):new g(R),C=x(h),E={timeout:R.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:R.fragLoadingMaxRetryTimeout,highWaterMark:P};h.stats=o.stats,o.load(C,E,{onSuccess:function(O,j,G,J){f.resetLoader(h,o),c({frag:h,part:null,payload:O.data,networkDetails:J})},onError:function(O,j,G){f.resetLoader(h,o),u(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,response:O,networkDetails:G}))},onAbort:function(O,j,G){f.resetLoader(h,o),u(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,networkDetails:G}))},onTimeout:function(O,j,G){f.resetLoader(h,o),u(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,networkDetails:G}))},onProgress:function(O,j,G,J){_&&_({frag:h,part:null,payload:G,networkDetails:J})}})})},a.loadPart=function(h,_,f){var b=this;this.abort();var R=this.config,T=R.fLoader,g=R.loader;return new Promise(function(c,u){b.loader&&b.loader.destroy();var o=b.loader=h.loader=T?new T(R):new g(R),C=x(h,_),E={timeout:R.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:R.fragLoadingMaxRetryTimeout,highWaterMark:P};_.stats=o.stats,o.load(C,E,{onSuccess:function(O,j,G,J){b.resetLoader(h,o),b.updateStatsFromPart(h,_);var K={frag:h,part:_,payload:O.data,networkDetails:J};f(K),c(K)},onError:function(O,j,G){b.resetLoader(h,o),u(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:h,part:_,response:O,networkDetails:G}))},onAbort:function(O,j,G){h.stats.aborted=_.stats.aborted,b.resetLoader(h,o),u(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:h,part:_,networkDetails:G}))},onTimeout:function(O,j,G){b.resetLoader(h,o),u(new S({type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:h,part:_,networkDetails:G}))}})})},a.updateStatsFromPart=function(h,_){var f=h.stats,b=_.stats,R=b.total;if(f.loaded+=b.loaded,R){var T=Math.round(h.duration/_.duration),g=Math.min(Math.round(f.loaded/R),T),c=T-g,u=c*Math.round(f.loaded/g);f.total=f.loaded+u}else f.total=Math.max(f.loaded,f.total);var o=f.loading,C=b.loading;o.start?o.first+=C.first-C.start:(o.start=C.start,o.first=C.first),o.end=C.end},a.resetLoader=function(h,_){h.loader=null,this.loader===_&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),_.destroy()},d}();function x(d,a){a===void 0&&(a=null);var l=a||d,h={frag:d,part:a,responseType:"arraybuffer",url:l.url,headers:{},rangeStart:0,rangeEnd:0},_=l.byteRangeStartOffset,f=l.byteRangeEndOffset;return Object(V.isFiniteNumber)(_)&&Object(V.isFiniteNumber)(f)&&(h.rangeStart=_,h.rangeEnd=f),h}var S=function(d){w(a,d);function a(l){for(var h,_=arguments.length,f=new Array(_>1?_-1:0),b=1;b<_;b++)f[b-1]=arguments[b];return h=d.call.apply(d,[this].concat(f))||this,h.data=void 0,h.data=l,h}return a}(B(Error))},"./src/loader/fragment.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"ElementaryStreamTypes",function(){return L}),D.d(Y,"BaseSegment",function(){return x}),D.d(Y,"Fragment",function(){return S}),D.d(Y,"Part",function(){return d});var V=D("./src/polyfills/number.ts"),I=D("./node_modules/url-toolkit/src/url-toolkit.js"),w=D.n(I),B=D("./src/utils/logger.ts"),N=D("./src/loader/level-key.ts"),M=D("./src/loader/load-stats.ts");function k(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,p(a,l)}function p(a,l){return p=Object.setPrototypeOf||function(_,f){return _.__proto__=f,_},p(a,l)}function y(a,l){for(var h=0;h<l.length;h++){var _=l[h];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(a,_.key,_)}}function P(a,l,h){return l&&y(a.prototype,l),h&&y(a,h),a}var L;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(L||(L={}));var x=function(){function a(h){var _;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(_={},_[L.AUDIO]=null,_[L.VIDEO]=null,_[L.AUDIOVIDEO]=null,_),this.baseurl=h}var l=a.prototype;return l.setByteRange=function(_,f){var b=_.split("@",2),R=[];b.length===1?R[0]=f?f.byteRangeEndOffset:0:R[0]=parseInt(b[1]),R[1]=parseInt(b[0])+R[0],this._byteRange=R},P(a,[{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(_){this._url=_}}]),a}(),S=function(a){k(l,a);function l(_,f){var b;return b=a.call(this,f)||this,b._decryptdata=null,b.rawProgramDateTime=null,b.programDateTime=null,b.tagList=[],b.duration=0,b.sn=0,b.levelkey=void 0,b.type=void 0,b.loader=null,b.level=-1,b.cc=0,b.startPTS=void 0,b.endPTS=void 0,b.appendedPTS=void 0,b.startDTS=void 0,b.endDTS=void 0,b.start=0,b.deltaPTS=void 0,b.maxStartPTS=void 0,b.minEndPTS=void 0,b.stats=new M.LoadStats,b.urlId=0,b.data=void 0,b.bitrateTest=!1,b.title=null,b.initSegment=null,b.type=_,b}var h=l.prototype;return h.createInitializationVector=function(f){for(var b=new Uint8Array(16),R=12;R<16;R++)b[R]=f>>8*(15-R)&255;return b},h.setDecryptDataFromLevelKey=function(f,b){var R=f;return(f==null?void 0:f.method)==="AES-128"&&f.uri&&!f.iv&&(R=N.LevelKey.fromURI(f.uri),R.method=f.method,R.iv=this.createInitializationVector(b),R.keyFormat="identity"),R},h.setElementaryStreamInfo=function(f,b,R,T,g,c){c===void 0&&(c=!1);var u=this.elementaryStreams,o=u[f];if(!o){u[f]={startPTS:b,endPTS:R,startDTS:T,endDTS:g,partial:c};return}o.startPTS=Math.min(o.startPTS,b),o.endPTS=Math.max(o.endPTS,R),o.startDTS=Math.min(o.startDTS,T),o.endDTS=Math.max(o.endDTS,g)},h.clearElementaryStreamInfo=function(){var f=this.elementaryStreams;f[L.AUDIO]=null,f[L.VIDEO]=null,f[L.AUDIOVIDEO]=null},P(l,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var f=this.sn;typeof f!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&B.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),f=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,f)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null)return null;if(!Object(V.isFiniteNumber)(this.programDateTime))return null;var f=Object(V.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+f*1e3}},{key:"encrypted",get:function(){var f;return!!((f=this.decryptdata)!==null&&f!==void 0&&f.keyFormat&&this.decryptdata.uri)}}]),l}(x),d=function(a){k(l,a);function l(h,_,f,b,R){var T;T=a.call(this,f)||this,T.fragOffset=0,T.duration=0,T.gap=!1,T.independent=!1,T.relurl=void 0,T.fragment=void 0,T.index=void 0,T.stats=new M.LoadStats,T.duration=h.decimalFloatingPoint("DURATION"),T.gap=h.bool("GAP"),T.independent=h.bool("INDEPENDENT"),T.relurl=h.enumeratedString("URI"),T.fragment=_,T.index=b;var g=h.enumeratedString("BYTERANGE");return g&&T.setByteRange(g,R),R&&(T.fragOffset=R.fragOffset+R.duration),T}return P(l,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var _=this.elementaryStreams;return!!(_.audio||_.video||_.audiovideo)}}]),l}(x)},"./src/loader/key-loader.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return B});var V=D("./src/events.ts"),I=D("./src/errors.ts"),w=D("./src/utils/logger.ts"),B=function(){function N(k){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=k,this._registerListeners()}var M=N.prototype;return M._registerListeners=function(){this.hls.on(V.Events.KEY_LOADING,this.onKeyLoading,this)},M._unregisterListeners=function(){this.hls.off(V.Events.KEY_LOADING,this.onKeyLoading)},M.destroy=function(){this._unregisterListeners();for(var p in this.loaders){var y=this.loaders[p];y&&y.destroy()}this.loaders={}},M.onKeyLoading=function(p,y){var P=y.frag,L=P.type,x=this.loaders[L];if(!P.decryptdata){w.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var S=P.decryptdata.uri;if(S!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(x&&(w.logger.warn("abort previous key loader for type:"+L),x.abort()),!S){w.logger.warn("key uri is falsy");return}var a=d.loader,l=P.loader=this.loaders[L]=new a(d);this.decrypturl=S,this.decryptkey=null;var h={url:S,frag:P,responseType:"arraybuffer"},_={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};l.load(h,_,f)}else this.decryptkey&&(P.decryptdata.key=this.decryptkey,this.hls.trigger(V.Events.KEY_LOADED,{frag:P}))},M.loadsuccess=function(p,y,P){var L=P.frag;if(!L.decryptdata){w.logger.error("after key load, decryptdata unset");return}this.decryptkey=L.decryptdata.key=new Uint8Array(p.data),L.loader=null,delete this.loaders[L.type],this.hls.trigger(V.Events.KEY_LOADED,{frag:L})},M.loaderror=function(p,y){var P=y.frag,L=P.loader;L&&L.abort(),delete this.loaders[P.type],this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:P,response:p})},M.loadtimeout=function(p,y){var P=y.frag,L=P.loader;L&&L.abort(),delete this.loaders[P.type],this.hls.trigger(V.Events.ERROR,{type:I.ErrorTypes.NETWORK_ERROR,details:I.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:P})},N}()},"./src/loader/level-details.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"LevelDetails",function(){return N});var V=D("./src/polyfills/number.ts");function I(M,k){for(var p=0;p<k.length;p++){var y=k[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(M,y.key,y)}}function w(M,k,p){return k&&I(M.prototype,k),p&&I(M,p),M}var B=10,N=function(){function M(p){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=p}var k=M.prototype;return k.reloaded=function(y){if(!y){this.advanced=!0,this.updated=!0;return}var P=this.lastPartSn-y.lastPartSn,L=this.lastPartIndex-y.lastPartIndex;this.updated=this.endSN!==y.endSN||!!L||!!P,this.advanced=this.endSN>y.endSN||P>0||P===0&&L>0,this.updated||this.advanced?this.misses=Math.floor(y.misses*.6):this.misses=y.misses+1,this.availabilityDelay=y.availabilityDelay},w(M,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(V.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||B}},{key:"drift",get:function(){var y=this.driftEndTime-this.driftStartTime;if(y>0){var P=this.driftEnd-this.driftStart;return P*1e3/y}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var y;return(y=this.partList)!==null&&y!==void 0&&y.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var y;return(y=this.fragments)!==null&&y!==void 0&&y.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 y;return(y=this.partList)!==null&&y!==void 0&&y.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var y;return(y=this.partList)!==null&&y!==void 0&&y.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),M}()},"./src/loader/level-key.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"LevelKey",function(){return N});var V=D("./node_modules/url-toolkit/src/url-toolkit.js"),I=D.n(V);function w(M,k){for(var p=0;p<k.length;p++){var y=k[p];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(M,y.key,y)}}function B(M,k,p){return k&&w(M.prototype,k),p&&w(M,p),M}var N=function(){M.fromURL=function(p,y){return new M(p,y)},M.fromURI=function(p){return new M(p)};function M(k,p){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,p?this._uri=Object(V.buildAbsoluteURL)(k,p,{alwaysNormalize:!0}):this._uri=k}return B(M,[{key:"uri",get:function(){return this._uri}}]),M}()},"./src/loader/load-stats.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"LoadStats",function(){return V});var V=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(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return l});var V=D("./src/polyfills/number.ts"),I=D("./node_modules/url-toolkit/src/url-toolkit.js"),w=D.n(I),B=D("./src/loader/fragment.ts"),N=D("./src/loader/level-details.ts"),M=D("./src/loader/level-key.ts"),k=D("./src/utils/attr-list.ts"),p=D("./src/utils/logger.ts"),y=D("./src/utils/codecs.ts"),P=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,L=/#EXT-X-MEDIA:(.*)/g,x=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("|")),d=/\.(mp4|m4s|m4v|m4a)$/i;function a(R){var T,g;return d.test((T=(g=I.parseURL(R))===null||g===void 0?void 0:g.path)!=null?T:"")}var l=function(){function R(){}return R.findGroup=function(g,c){for(var u=0;u<g.length;u++){var o=g[u];if(o.id===c)return o}},R.convertAVC1ToAVCOTI=function(g){var c=g.split(".");if(c.length>2){var u=c.shift()+".";return u+=parseInt(c.shift()).toString(16),u+=("000"+parseInt(c.shift()).toString(16)).substr(-4),u}return g},R.resolve=function(g,c){return I.buildAbsoluteURL(c,g,{alwaysNormalize:!0})},R.parseMasterPlaylist=function(g,c){var u=[],o={},C=!1;P.lastIndex=0;for(var E;(E=P.exec(g))!=null;)if(E[1]){var v=new k.AttrList(E[1]),O={attrs:v,bitrate:v.decimalInteger("AVERAGE-BANDWIDTH")||v.decimalInteger("BANDWIDTH"),name:v.NAME,url:R.resolve(E[2],c)},j=v.decimalResolution("RESOLUTION");j&&(O.width=j.width,O.height=j.height),h((v.CODECS||"").split(/[ ,]+/).filter(function(J){return J}),O),O.videoCodec&&O.videoCodec.indexOf("avc1")!==-1&&(O.videoCodec=R.convertAVC1ToAVCOTI(O.videoCodec)),u.push(O)}else if(E[3]){var G=new k.AttrList(E[3]);G["DATA-ID"]&&(C=!0,o[G["DATA-ID"]]=G)}return{levels:u,sessionData:C?o:null}},R.parseMasterPlaylistMedia=function(g,c,u,o){o===void 0&&(o=[]);var C,E=[],v=0;for(L.lastIndex=0;(C=L.exec(g))!==null;){var O=new k.AttrList(C[1]);if(O.TYPE===u){var j={attrs:O,bitrate:0,id:v++,groupId:O["GROUP-ID"],instreamId:O["INSTREAM-ID"],name:O.NAME||O.LANGUAGE||"",type:u,default:O.bool("DEFAULT"),autoselect:O.bool("AUTOSELECT"),forced:O.bool("FORCED"),lang:O.LANGUAGE,url:O.URI?R.resolve(O.URI,c):""};if(o.length){var G=R.findGroup(o,j.groupId)||o[0];_(j,G,"audioCodec"),_(j,G,"textCodec")}E.push(j)}}return E},R.parseLevelPlaylist=function(g,c,u,o,C){var E=new N.LevelDetails(c),v=E.fragments,O=null,j=0,G=0,J=0,K=0,F=null,ee=new B.Fragment(o,c),oe,he,ge,_e=-1,be=!1;for(x.lastIndex=0,E.m3u8=g;(oe=x.exec(g))!==null;){be&&(be=!1,ee=new B.Fragment(o,c),ee.start=J,ee.sn=j,ee.cc=K,ee.level=u,O&&(ee.initSegment=O,ee.rawProgramDateTime=O.rawProgramDateTime));var Ee=oe[1];if(Ee){ee.duration=parseFloat(Ee);var Te=(" "+oe[2]).slice(1);ee.title=Te||null,ee.tagList.push(Te?["INF",Ee,Te]:["INF",Ee])}else if(oe[3])Object(V.isFiniteNumber)(ee.duration)&&(ee.start=J,ge&&(ee.levelkey=ge),ee.sn=j,ee.level=u,ee.cc=K,ee.urlId=C,v.push(ee),ee.relurl=(" "+oe[3]).slice(1),b(ee,F),F=ee,J+=ee.duration,j++,G=0,be=!0);else if(oe[4]){var Ce=(" "+oe[4]).slice(1);F?ee.setByteRange(Ce,F):ee.setByteRange(Ce)}else if(oe[5])ee.rawProgramDateTime=(" "+oe[5]).slice(1),ee.tagList.push(["PROGRAM-DATE-TIME",ee.rawProgramDateTime]),_e===-1&&(_e=v.length);else{if(oe=oe[0].match(S),!oe){p.logger.warn("No matches on slow regex match for level playlist!");continue}for(he=1;he<oe.length&&!(typeof oe[he]!="undefined");he++);var me=(" "+oe[he]).slice(1),se=(" "+oe[he+1]).slice(1),Re=oe[he+2]?(" "+oe[he+2]).slice(1):"";switch(me){case"PLAYLIST-TYPE":E.type=se.toUpperCase();break;case"MEDIA-SEQUENCE":j=E.startSN=parseInt(se);break;case"SKIP":{var et=new k.AttrList(se),Ge=et.decimalInteger("SKIPPED-SEGMENTS");if(Object(V.isFiniteNumber)(Ge)){E.skippedSegments=Ge;for(var tt=Ge;tt--;)v.unshift(null);j+=Ge}var Ye=et.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ye&&(E.recentlyRemovedDateranges=Ye.split(" "));break}case"TARGETDURATION":E.targetduration=parseFloat(se);break;case"VERSION":E.version=parseInt(se);break;case"EXTM3U":break;case"ENDLIST":E.live=!1;break;case"#":(se||Re)&&ee.tagList.push(Re?[se,Re]:[se]);break;case"DIS":K++;case"GAP":ee.tagList.push([me]);break;case"BITRATE":ee.tagList.push([me,se]);break;case"DISCONTINUITY-SEQ":K=parseInt(se);break;case"KEY":{var De,je=new k.AttrList(se),$e=je.enumeratedString("METHOD"),st=je.URI,Qe=je.hexadecimalInteger("IV"),Be=je.enumeratedString("KEYFORMATVERSIONS"),We=je.enumeratedString("KEYID"),ft=(De=je.enumeratedString("KEYFORMAT"))!=null?De:"identity",Ke=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ke.indexOf(ft)>-1){p.logger.warn("Keyformat "+ft+" is not supported from the manifest");continue}else if(ft!=="identity")continue;$e&&(ge=M.LevelKey.fromURL(c,st),st&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf($e)>=0&&(ge.method=$e,ge.keyFormat=ft,We&&(ge.keyID=We),Be&&(ge.keyFormatVersions=Be),ge.iv=Qe));break}case"START":{var Ue=new k.AttrList(se),Xe=Ue.decimalFloatingPoint("TIME-OFFSET");Object(V.isFiniteNumber)(Xe)&&(E.startTimeOffset=Xe);break}case"MAP":{var Ze=new k.AttrList(se);ee.relurl=Ze.URI,Ze.BYTERANGE&&ee.setByteRange(Ze.BYTERANGE),ee.level=u,ee.sn="initSegment",ge&&(ee.levelkey=ge),ee.initSegment=null,O=ee,be=!0;break}case"SERVER-CONTROL":{var Ve=new k.AttrList(se);E.canBlockReload=Ve.bool("CAN-BLOCK-RELOAD"),E.canSkipUntil=Ve.optionalFloat("CAN-SKIP-UNTIL",0),E.canSkipDateRanges=E.canSkipUntil>0&&Ve.bool("CAN-SKIP-DATERANGES"),E.partHoldBack=Ve.optionalFloat("PART-HOLD-BACK",0),E.holdBack=Ve.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new k.AttrList(se);E.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var we=E.partList;we||(we=E.partList=[]);var qe=G>0?we[we.length-1]:void 0,it=G++,Ae=new B.Part(new k.AttrList(se),ee,c,it,qe);we.push(Ae),ee.duration+=Ae.duration;break}case"PRELOAD-HINT":{var Oe=new k.AttrList(se);E.preloadHint=Oe;break}case"RENDITION-REPORT":{var pe=new k.AttrList(se);E.renditionReports=E.renditionReports||[],E.renditionReports.push(pe);break}default:p.logger.warn("line parsed but not handled: "+oe);break}}}F&&!F.relurl?(v.pop(),J-=F.duration,E.partList&&(E.fragmentHint=F)):E.partList&&(b(ee,F),ee.cc=K,E.fragmentHint=ee);var de=v.length,ue=v[0],te=v[de-1];if(J+=E.skippedSegments*E.targetduration,J>0&&de&&te){E.averagetargetduration=J/de;var q=te.sn;E.endSN=q!=="initSegment"?q:0,ue&&(E.startCC=ue.cc,ue.initSegment||E.fragments.every(function(ne){return ne.relurl&&a(ne.relurl)})&&(p.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),ee=new B.Fragment(o,c),ee.relurl=te.relurl,ee.level=u,ee.sn="initSegment",ue.initSegment=ee,E.needSidxRanges=!0))}else E.endSN=0,E.startCC=0;return E.fragmentHint&&(J+=E.fragmentHint.duration),E.totalduration=J,E.endCC=K,_e>0&&f(v,_e),E},R}();function h(R,T){["video","audio","text"].forEach(function(g){var c=R.filter(function(o){return Object(y.isCodecType)(o,g)});if(c.length){var u=c.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});T[g+"Codec"]=u.length>0?u[0]:c[0],R=R.filter(function(o){return c.indexOf(o)===-1})}}),T.unknownCodecs=R}function _(R,T,g){var c=T[g];c&&(R[g]=c)}function f(R,T){for(var g=R[T],c=T;c--;){var u=R[c];if(!u)return;u.programDateTime=g.programDateTime-u.duration*1e3,g=u}}function b(R,T){R.rawProgramDateTime?R.programDateTime=Date.parse(R.rawProgramDateTime):T!=null&&T.programDateTime&&(R.programDateTime=T.endProgramDateTime),Object(V.isFiniteNumber)(R.programDateTime)||(R.programDateTime=null,R.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/polyfills/number.ts"),I=D("./src/events.ts"),w=D("./src/errors.ts"),B=D("./src/utils/logger.ts"),N=D("./src/utils/mp4-tools.ts"),M=D("./src/loader/m3u8-parser.ts"),k=D("./src/types/loader.ts"),p=D("./src/utils/attr-list.ts");function y(x){var S=x.type;switch(S){case k.PlaylistContextType.AUDIO_TRACK:return k.PlaylistLevelType.AUDIO;case k.PlaylistContextType.SUBTITLE_TRACK:return k.PlaylistLevelType.SUBTITLE;default:return k.PlaylistLevelType.MAIN}}function P(x,S){var d=x.url;return(d===void 0||d.indexOf("data:")===0)&&(d=S.url),d}var L=function(){function x(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var S=x.prototype;return S.registerListeners=function(){var a=this.hls;a.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.unregisterListeners=function(){var a=this.hls;a.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(I.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(I.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(I.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},S.createInternalLoader=function(a){var l=this.hls.config,h=l.pLoader,_=l.loader,f=h||_,b=new f(l);return a.loader=b,this.loaders[a.type]=b,b},S.getInternalLoader=function(a){return this.loaders[a.type]},S.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},S.destroyInternalLoaders=function(){for(var a in this.loaders){var l=this.loaders[a];l&&l.destroy(),this.resetInternalLoader(a)}},S.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},S.onManifestLoading=function(a,l){var h=l.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:k.PlaylistContextType.MANIFEST,url:h,deliveryDirectives:null})},S.onLevelLoading=function(a,l){var h=l.id,_=l.level,f=l.url,b=l.deliveryDirectives;this.load({id:h,groupId:null,level:_,responseType:"text",type:k.PlaylistContextType.LEVEL,url:f,deliveryDirectives:b})},S.onAudioTrackLoading=function(a,l){var h=l.id,_=l.groupId,f=l.url,b=l.deliveryDirectives;this.load({id:h,groupId:_,level:null,responseType:"text",type:k.PlaylistContextType.AUDIO_TRACK,url:f,deliveryDirectives:b})},S.onSubtitleTrackLoading=function(a,l){var h=l.id,_=l.groupId,f=l.url,b=l.deliveryDirectives;this.load({id:h,groupId:_,level:null,responseType:"text",type:k.PlaylistContextType.SUBTITLE_TRACK,url:f,deliveryDirectives:b})},S.load=function(a){var l,h=this.hls.config,_=this.getInternalLoader(a);if(_){var f=_.context;if(f&&f.url===a.url){B.logger.trace("[playlist-loader]: playlist request ongoing");return}B.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),_.abort()}var b,R,T,g;switch(a.type){case k.PlaylistContextType.MANIFEST:b=h.manifestLoadingMaxRetry,R=h.manifestLoadingTimeOut,T=h.manifestLoadingRetryDelay,g=h.manifestLoadingMaxRetryTimeout;break;case k.PlaylistContextType.LEVEL:case k.PlaylistContextType.AUDIO_TRACK:case k.PlaylistContextType.SUBTITLE_TRACK:b=0,R=h.levelLoadingTimeOut;break;default:b=h.levelLoadingMaxRetry,R=h.levelLoadingTimeOut,T=h.levelLoadingRetryDelay,g=h.levelLoadingMaxRetryTimeout;break}if(_=this.createInternalLoader(a),(l=a.deliveryDirectives)!==null&&l!==void 0&&l.part){var c;if(a.type===k.PlaylistContextType.LEVEL&&a.level!==null?c=this.hls.levels[a.level].details:a.type===k.PlaylistContextType.AUDIO_TRACK&&a.id!==null?c=this.hls.audioTracks[a.id].details:a.type===k.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(c=this.hls.subtitleTracks[a.id].details),c){var u=c.partTarget,o=c.targetduration;u&&o&&(R=Math.min(Math.max(u*3,o*.8)*1e3,R))}}var C={timeout:R,maxRetry:b,retryDelay:T,maxRetryDelay:g,highWaterMark:0},E={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};_.load(a,C,E)},S.loadsuccess=function(a,l,h,_){if(_===void 0&&(_=null),h.isSidxRequest){this.handleSidxRequest(a,h),this.handlePlaylistLoaded(a,l,h,_);return}this.resetInternalLoader(h.type);var f=a.data;if(f.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,h,"no EXTM3U delimiter",_);return}l.parsing.start=performance.now(),f.indexOf("#EXTINF:")>0||f.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,l,h,_):this.handleMasterPlaylist(a,l,h,_)},S.loaderror=function(a,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!1,a)},S.loadtimeout=function(a,l,h){h===void 0&&(h=null),this.handleNetworkError(l,h,!0)},S.handleMasterPlaylist=function(a,l,h,_){var f=this.hls,b=a.data,R=P(a,h),T=M.default.parseMasterPlaylist(b,R),g=T.levels,c=T.sessionData;if(!g.length){this.handleManifestParsingError(a,h,"no level found in manifest",_);return}var u=g.map(function(j){return{id:j.attrs.AUDIO,audioCodec:j.audioCodec}}),o=g.map(function(j){return{id:j.attrs.SUBTITLES,textCodec:j.textCodec}}),C=M.default.parseMasterPlaylistMedia(b,R,"AUDIO",u),E=M.default.parseMasterPlaylistMedia(b,R,"SUBTITLES",o),v=M.default.parseMasterPlaylistMedia(b,R,"CLOSED-CAPTIONS");if(C.length){var O=C.some(function(j){return!j.url});!O&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(B.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),C.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new p.AttrList({}),bitrate:0,url:""}))}f.trigger(I.Events.MANIFEST_LOADED,{levels:g,audioTracks:C,subtitles:E,captions:v,url:R,stats:l,networkDetails:_,sessionData:c})},S.handleTrackOrLevelPlaylist=function(a,l,h,_){var f=this.hls,b=h.id,R=h.level,T=h.type,g=P(a,h),c=Object(V.isFiniteNumber)(b)?b:0,u=Object(V.isFiniteNumber)(R)?R:c,o=y(h),C=M.default.parseLevelPlaylist(a.data,g,u,o,c);if(!C.fragments.length){f.trigger(I.Events.ERROR,{type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:typeof h.level=="number"?h.level:void 0});return}if(T===k.PlaylistContextType.MANIFEST){var E={attrs:new p.AttrList({}),bitrate:0,details:C,name:"",url:g};f.trigger(I.Events.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:g,stats:l,networkDetails:_,sessionData:null})}if(l.parsing.end=performance.now(),C.needSidxRanges){var v,O=(v=C.fragments[0].initSegment)===null||v===void 0?void 0:v.url;this.load({url:O,isSidxRequest:!0,type:T,level:R,levelDetails:C,id:b,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}h.levelDetails=C,this.handlePlaylistLoaded(a,l,h,_)},S.handleSidxRequest=function(a,l){var h=Object(N.parseSegmentIndex)(new Uint8Array(a.data));if(!h)return;var _=h.references,f=l.levelDetails;_.forEach(function(b,R){var T=b.info,g=f.fragments[R];g.byteRange.length===0&&g.setByteRange(String(1+T.end-T.start)+"@"+String(T.start)),g.initSegment&&g.initSegment.setByteRange(String(h.moovEndOffset)+"@0")})},S.handleManifestParsingError=function(a,l,h,_){this.hls.trigger(I.Events.ERROR,{type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:l.type===k.PlaylistContextType.MANIFEST,url:a.url,reason:h,response:a,context:l,networkDetails:_})},S.handleNetworkError=function(a,l,h,_){h===void 0&&(h=!1),B.logger.warn("[playlist-loader]: A network "+(h?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var f=w.ErrorDetails.UNKNOWN,b=!1,R=this.getInternalLoader(a);switch(a.type){case k.PlaylistContextType.MANIFEST:f=h?w.ErrorDetails.MANIFEST_LOAD_TIMEOUT:w.ErrorDetails.MANIFEST_LOAD_ERROR,b=!0;break;case k.PlaylistContextType.LEVEL:f=h?w.ErrorDetails.LEVEL_LOAD_TIMEOUT:w.ErrorDetails.LEVEL_LOAD_ERROR,b=!1;break;case k.PlaylistContextType.AUDIO_TRACK:f=h?w.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,b=!1;break;case k.PlaylistContextType.SUBTITLE_TRACK:f=h?w.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:w.ErrorDetails.SUBTITLE_LOAD_ERROR,b=!1;break}R&&this.resetInternalLoader(a.type);var T={type:w.ErrorTypes.NETWORK_ERROR,details:f,fatal:b,url:a.url,loader:R,context:a,networkDetails:l};_&&(T.response=_),this.hls.trigger(I.Events.ERROR,T)},S.handlePlaylistLoaded=function(a,l,h,_){var f=h.type,b=h.level,R=h.id,T=h.groupId,g=h.loader,c=h.levelDetails,u=h.deliveryDirectives;if(!(c!=null&&c.targetduration)){this.handleManifestParsingError(a,h,"invalid target duration",_);return}if(!g)return;c.live&&(g.getCacheAge&&(c.ageHeader=g.getCacheAge()||0),(!g.getCacheAge||isNaN(c.ageHeader))&&(c.ageHeader=0));switch(f){case k.PlaylistContextType.MANIFEST:case k.PlaylistContextType.LEVEL:this.hls.trigger(I.Events.LEVEL_LOADED,{details:c,level:b||0,id:R||0,stats:l,networkDetails:_,deliveryDirectives:u});break;case k.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(I.Events.AUDIO_TRACK_LOADED,{details:c,id:R||0,groupId:T||"",stats:l,networkDetails:_,deliveryDirectives:u});break;case k.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(I.Events.SUBTITLE_TRACK_LOADED,{details:c,id:R||0,groupId:T||"",stats:l,networkDetails:_,deliveryDirectives:u});break}},x}();Y.default=L},"./src/polyfills/number.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"isFiniteNumber",function(){return V}),D.d(Y,"MAX_SAFE_INTEGER",function(){return I});var V=Number.isFinite||function(w){return typeof w=="number"&&isFinite(w)},I=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(ie,Y,D){"use strict";D.r(Y);var V=function(){function I(){}return I.getSilentFrame=function(B,N){switch(B){case"mp4a.40.2":if(N===1)return new Uint8Array([0,200,0,128,35,128]);if(N===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(N===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(N===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(N===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(N===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(N===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(N===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(N===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}();Y.default=V},"./src/remux/mp4-generator.ts":function(ie,Y,D){"use strict";D.r(Y);var V=Math.pow(2,32)-1,I=function(){function w(){}return w.init=function(){w.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 N;for(N in w.types)w.types.hasOwnProperty(N)&&(w.types[N]=[N.charCodeAt(0),N.charCodeAt(1),N.charCodeAt(2),N.charCodeAt(3)]);var M=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]),k=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]);w.HDLR_TYPES={video:M,audio:k};var p=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),y=new Uint8Array([0,0,0,0,0,0,0,0]);w.STTS=w.STSC=w.STCO=y,w.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),w.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),w.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),w.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var P=new Uint8Array([105,115,111,109]),L=new Uint8Array([97,118,99,49]),x=new Uint8Array([0,0,0,1]);w.FTYP=w.box(w.types.ftyp,P,x,P,L),w.DINF=w.box(w.types.dinf,w.box(w.types.dref,p))},w.box=function(N){for(var M=8,k=arguments.length,p=new Array(k>1?k-1:0),y=1;y<k;y++)p[y-1]=arguments[y];for(var P=p.length,L=P;P--;)M+=p[P].byteLength;var x=new Uint8Array(M);for(x[0]=M>>24&255,x[1]=M>>16&255,x[2]=M>>8&255,x[3]=M&255,x.set(N,4),P=0,M=8;P<L;P++)x.set(p[P],M),M+=p[P].byteLength;return x},w.hdlr=function(N){return w.box(w.types.hdlr,w.HDLR_TYPES[N])},w.mdat=function(N){return w.box(w.types.mdat,N)},w.mdhd=function(N,M){M*=N;var k=Math.floor(M/(V+1)),p=Math.floor(M%(V+1));return w.box(w.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,N>>24&255,N>>16&255,N>>8&255,N&255,k>>24,k>>16&255,k>>8&255,k&255,p>>24,p>>16&255,p>>8&255,p&255,85,196,0,0]))},w.mdia=function(N){return w.box(w.types.mdia,w.mdhd(N.timescale,N.duration),w.hdlr(N.type),w.minf(N))},w.mfhd=function(N){return w.box(w.types.mfhd,new Uint8Array([0,0,0,0,N>>24,N>>16&255,N>>8&255,N&255]))},w.minf=function(N){return N.type==="audio"?w.box(w.types.minf,w.box(w.types.smhd,w.SMHD),w.DINF,w.stbl(N)):w.box(w.types.minf,w.box(w.types.vmhd,w.VMHD),w.DINF,w.stbl(N))},w.moof=function(N,M,k){return w.box(w.types.moof,w.mfhd(N),w.traf(k,M))},w.moov=function(N){for(var M=N.length,k=[];M--;)k[M]=w.trak(N[M]);return w.box.apply(null,[w.types.moov,w.mvhd(N[0].timescale,N[0].duration)].concat(k).concat(w.mvex(N)))},w.mvex=function(N){for(var M=N.length,k=[];M--;)k[M]=w.trex(N[M]);return w.box.apply(null,[w.types.mvex].concat(k))},w.mvhd=function(N,M){M*=N;var k=Math.floor(M/(V+1)),p=Math.floor(M%(V+1)),y=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,N>>24&255,N>>16&255,N>>8&255,N&255,k>>24,k>>16&255,k>>8&255,k&255,p>>24,p>>16&255,p>>8&255,p&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 w.box(w.types.mvhd,y)},w.sdtp=function(N){var M=N.samples||[],k=new Uint8Array(4+M.length),p,y;for(p=0;p<M.length;p++)y=M[p].flags,k[p+4]=y.dependsOn<<4|y.isDependedOn<<2|y.hasRedundancy;return w.box(w.types.sdtp,k)},w.stbl=function(N){return w.box(w.types.stbl,w.stsd(N),w.box(w.types.stts,w.STTS),w.box(w.types.stsc,w.STSC),w.box(w.types.stsz,w.STSZ),w.box(w.types.stco,w.STCO))},w.avc1=function(N){var M=[],k=[],p,y,P;for(p=0;p<N.sps.length;p++)y=N.sps[p],P=y.byteLength,M.push(P>>>8&255),M.push(P&255),M=M.concat(Array.prototype.slice.call(y));for(p=0;p<N.pps.length;p++)y=N.pps[p],P=y.byteLength,k.push(P>>>8&255),k.push(P&255),k=k.concat(Array.prototype.slice.call(y));var L=w.box(w.types.avcC,new Uint8Array([1,M[3],M[4],M[5],252|3,224|N.sps.length].concat(M).concat([N.pps.length]).concat(k))),x=N.width,S=N.height,d=N.pixelRatio[0],a=N.pixelRatio[1];return w.box(w.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,x>>8&255,x&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]),L,w.box(w.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),w.box(w.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&255,a>>24,a>>16&255,a>>8&255,a&255])))},w.esds=function(N){var M=N.config.length;return new Uint8Array([0,0,0,0,3,23+M,0,1,0,4,15+M,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([M]).concat(N.config).concat([6,1,2]))},w.mp4a=function(N){var M=N.samplerate;return w.box(w.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,N.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]),w.box(w.types.esds,w.esds(N)))},w.mp3=function(N){var M=N.samplerate;return w.box(w.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,N.channelCount,0,16,0,0,0,0,M>>8&255,M&255,0,0]))},w.stsd=function(N){return N.type==="audio"?!N.isAAC&&N.codec==="mp3"?w.box(w.types.stsd,w.STSD,w.mp3(N)):w.box(w.types.stsd,w.STSD,w.mp4a(N)):w.box(w.types.stsd,w.STSD,w.avc1(N))},w.tkhd=function(N){var M=N.id,k=N.duration*N.timescale,p=N.width,y=N.height,P=Math.floor(k/(V+1)),L=Math.floor(k%(V+1));return w.box(w.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,M>>24&255,M>>16&255,M>>8&255,M&255,0,0,0,0,P>>24,P>>16&255,P>>8&255,P&255,L>>24,L>>16&255,L>>8&255,L&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,p>>8&255,p&255,0,0,y>>8&255,y&255,0,0]))},w.traf=function(N,M){var k=w.sdtp(N),p=N.id,y=Math.floor(M/(V+1)),P=Math.floor(M%(V+1));return w.box(w.types.traf,w.box(w.types.tfhd,new Uint8Array([0,0,0,0,p>>24,p>>16&255,p>>8&255,p&255])),w.box(w.types.tfdt,new Uint8Array([1,0,0,0,y>>24,y>>16&255,y>>8&255,y&255,P>>24,P>>16&255,P>>8&255,P&255])),w.trun(N,k.length+16+20+8+16+8+8),k)},w.trak=function(N){return N.duration=N.duration||4294967295,w.box(w.types.trak,w.tkhd(N),w.mdia(N))},w.trex=function(N){var M=N.id;return w.box(w.types.trex,new Uint8Array([0,0,0,0,M>>24,M>>16&255,M>>8&255,M&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},w.trun=function(N,M){var k=N.samples||[],p=k.length,y=12+16*p,P=new Uint8Array(y),L,x,S,d,a,l;for(M+=8+y,P.set([0,0,15,1,p>>>24&255,p>>>16&255,p>>>8&255,p&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255],0),L=0;L<p;L++)x=k[L],S=x.duration,d=x.size,a=x.flags,l=x.cts,P.set([S>>>24&255,S>>>16&255,S>>>8&255,S&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,a.degradPrio&240<<8,a.degradPrio&15,l>>>24&255,l>>>16&255,l>>>8&255,l&255],12+16*L);return w.box(w.types.trun,P)},w.initSegment=function(N){w.types||w.init();var M=w.moov(N),k=new Uint8Array(w.FTYP.byteLength+M.byteLength);return k.set(w.FTYP),k.set(M,w.FTYP.byteLength),k},w}();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,Y.default=I},"./src/remux/mp4-remuxer.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return l}),D.d(Y,"normalizePts",function(){return h});var V=D("./src/polyfills/number.ts"),I=D("./src/remux/aac-helper.ts"),w=D("./src/remux/mp4-generator.ts"),B=D("./src/events.ts"),N=D("./src/errors.ts"),M=D("./src/utils/logger.ts"),k=D("./src/types/loader.ts"),p=D("./src/utils/timescale-conversion.ts");function y(){return y=Object.assign||function(R){for(var T=1;T<arguments.length;T++){var g=arguments[T];for(var c in g)Object.prototype.hasOwnProperty.call(g,c)&&(R[c]=g[c])}return R},y.apply(this,arguments)}var P=10*1e3,L=1024,x=1152,S=null,d=null,a=!1,l=function(){function R(g,c,u,o){if(o===void 0&&(o=""),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=g,this.config=c,this.typeSupported=u,this.ISGenerated=!1,S===null){var C=navigator.userAgent||"",E=C.match(/Chrome\/(\d+)/i);S=E?parseInt(E[1]):0}if(d===null){var v=navigator.userAgent.match(/Safari\/(\d+)/i);d=v?parseInt(v[1]):0}a=!!S&&S<75||!!d&&d<600}var T=R.prototype;return T.destroy=function(){},T.resetTimeStamp=function(c){M.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=c},T.resetNextTimestamp=function(){M.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},T.resetInitSegment=function(){M.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},T.getVideoStartPts=function(c){var u=!1,o=c.reduce(function(C,E){var v=E.pts-C;return v<-4294967296?(u=!0,h(C,E.pts)):v>0?C:E.pts},c[0].pts);return u&&M.logger.debug("PTS rollover detected"),o},T.remux=function(c,u,o,C,E,v,O,j){var G,J,K,F,ee,oe,he=E,ge=E,_e=c.pid>-1,be=u.pid>-1,Ee=u.samples.length,Te=c.samples.length>0,Ce=Ee>1,me=(!_e||Te)&&(!be||Ce)||this.ISGenerated||O;if(me){this.ISGenerated||(K=this.generateIS(c,u,E));var se=this.isVideoContiguous,Re=-1;if(Ce&&(Re=_(u.samples),!se&&this.config.forceKeyFrameOnDiscontinuity))if(oe=!0,Re>0){M.logger.warn("[mp4-remuxer]: Dropped "+Re+" out of "+Ee+" video samples due to a missing keyframe");var et=this.getVideoStartPts(u.samples);u.samples=u.samples.slice(Re),u.dropped+=Re,ge+=(u.samples[0].pts-et)/(u.timescale||9e4)}else Re===-1&&(M.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ee+" video samples"),oe=!1);if(this.ISGenerated){if(Te&&Ce){var Ge=this.getVideoStartPts(u.samples),tt=h(c.samples[0].pts,Ge)-Ge,Ye=tt/u.inputTimeScale;he+=Math.max(0,Ye),ge+=Math.max(0,-Ye)}if(Te){if(c.samplerate||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),K=this.generateIS(c,u,E)),J=this.remuxAudio(c,he,this.isAudioContiguous,v,be||Ce||j===k.PlaylistLevelType.AUDIO?ge:void 0),Ce){var De=J?J.endPTS-J.startPTS:0;u.inputTimeScale||(M.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),K=this.generateIS(c,u,E)),G=this.remuxVideo(u,ge,se,De)}}else Ce&&(G=this.remuxVideo(u,ge,se,0));G&&(G.firstKeyFrame=Re,G.independent=Re!==-1)}}return this.ISGenerated&&(o.samples.length&&(ee=this.remuxID3(o,E)),C.samples.length&&(F=this.remuxText(C,E))),{audio:J,video:G,initSegment:K,independent:oe,text:F,id3:ee}},T.generateIS=function(c,u,o){var C=c.samples,E=u.samples,v=this.typeSupported,O={},j=!Object(V.isFiniteNumber)(this._initPTS),G="audio/mp4",J,K,F;if(j&&(J=K=Infinity),c.config&&C.length&&(c.timescale=c.samplerate,c.isAAC||(v.mpeg?(G="audio/mpeg",c.codec=""):v.mp3&&(c.codec="mp3")),O.audio={id:"audio",container:G,codec:c.codec,initSegment:!c.isAAC&&v.mpeg?new Uint8Array(0):w.default.initSegment([c]),metadata:{channelCount:c.channelCount}},j&&(F=c.inputTimeScale,J=K=C[0].pts-Math.round(F*o))),u.sps&&u.pps&&E.length&&(u.timescale=u.inputTimeScale,O.video={id:"main",container:"video/mp4",codec:u.codec,initSegment:w.default.initSegment([u]),metadata:{width:u.width,height:u.height}},j)){F=u.inputTimeScale;var ee=this.getVideoStartPts(E),oe=Math.round(F*o);K=Math.min(K,h(E[0].dts,ee)-oe),J=Math.min(J,ee-oe)}if(Object.keys(O).length)return this.ISGenerated=!0,j&&(this._initPTS=J,this._initDTS=K),{tracks:O,initPTS:J,timescale:F}},T.remuxVideo=function(c,u,o,C){var E=c.inputTimeScale,v=c.samples,O=[],j=v.length,G=this._initPTS,J=this.nextAvcDts,K=8,F,ee,oe,he=Number.POSITIVE_INFINITY,ge=Number.NEGATIVE_INFINITY,_e=0,be=!1;if(!o||J===null){var Ee=u*E,Te=v[0].pts-h(v[0].dts,v[0].pts);J=Ee-Te}for(var Ce=0;Ce<j;Ce++){var me=v[Ce];if(me.pts=h(me.pts-G,J),me.dts=h(me.dts-G,J),me.dts>me.pts){var se=9e4*.2;_e=Math.max(Math.min(_e,me.pts-me.dts),-1*se)}me.dts<v[Ce>0?Ce-1:Ce].dts&&(be=!0)}be&&v.sort(function(xt,mt){var He=xt.dts-mt.dts,Tt=xt.pts-mt.pts;return He||Tt}),ee=v[0].dts,oe=v[v.length-1].dts;var Re=Math.round((oe-ee)/(j-1));if(_e<0){if(_e<Re*-2){M.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(p.toMsFromMpegTsClock)(-Re,!0)+" ms");for(var et=_e,Ge=0;Ge<j;Ge++)v[Ge].dts=et=Math.max(et,v[Ge].pts-Re),v[Ge].pts=Math.max(et,v[Ge].pts)}else{M.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(p.toMsFromMpegTsClock)(_e,!0)+" ms to overcome this issue");for(var tt=0;tt<j;tt++)v[tt].dts=v[tt].dts+_e}ee=v[0].dts}if(o){var Ye=ee-J,De=Ye>Re,je=Ye<-1;if(De||je){De?M.logger.warn("AVC: "+Object(p.toMsFromMpegTsClock)(Ye,!0)+" ms ("+Ye+"dts) hole between fragments detected, filling it"):M.logger.warn("AVC: "+Object(p.toMsFromMpegTsClock)(-Ye,!0)+" ms ("+Ye+"dts) overlapping between fragments detected"),ee=J;var $e=v[0].pts-Ye;v[0].dts=ee,v[0].pts=$e,M.logger.log("Video: First PTS/DTS adjusted: "+Object(p.toMsFromMpegTsClock)($e,!0)+"/"+Object(p.toMsFromMpegTsClock)(ee,!0)+", delta: "+Object(p.toMsFromMpegTsClock)(Ye,!0)+" ms")}}a&&(ee=Math.max(0,ee));for(var st=0,Qe=0,Be=0;Be<j;Be++){for(var We=v[Be],ft=We.units,Ke=ft.length,Ue=0,Xe=0;Xe<Ke;Xe++)Ue+=ft[Xe].data.length;Qe+=Ue,st+=Ke,We.length=Ue,We.dts=Math.max(We.dts,ee),We.pts=Math.max(We.pts,We.dts,0),he=Math.min(We.pts,he),ge=Math.max(We.pts,ge)}oe=v[j-1].dts;var Ze=Qe+4*st+8,Ve;try{Ve=new Uint8Array(Ze)}catch(xt){this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:N.ErrorTypes.MUX_ERROR,details:N.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Ze,reason:"fail allocating video mdat "+Ze});return}var rt=new DataView(Ve.buffer);rt.setUint32(0,Ze),Ve.set(w.default.types.mdat,4);for(var we=0;we<j;we++){for(var qe=v[we],it=qe.units,Ae=0,Oe=0,pe=it.length;Oe<pe;Oe++){var de=it[Oe],ue=de.data,te=de.data.byteLength;rt.setUint32(K,te),K+=4,Ve.set(ue,K),K+=te,Ae+=4+te}if(we<j-1)F=v[we+1].dts-qe.dts;else{var q=this.config,ne=qe.dts-v[we>0?we-1:we].dts;if(q.stretchShortVideoTrack&&this.nextAudioPts!==null){var ae=Math.floor(q.maxBufferHole*E),ve=(C?he+C*E:this.nextAudioPts)-qe.pts;ve>ae?(F=ve-ne,F<0&&(F=ne),M.logger.log("[mp4-remuxer]: It is approximately "+ve/90+" ms to the next segment; using duration "+F/90+" ms for the last video frame.")):F=ne}else F=ne}var Le=Math.round(qe.pts-qe.dts);O.push(new f(qe.key,F,Ae,Le))}if(O.length&&S&&S<70){var Ie=O[0].flags;Ie.dependsOn=2,Ie.isNonSync=0}console.assert(F!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=J=oe+F,this.isVideoContiguous=!0;var lt=w.default.moof(c.sequenceNumber++,ee,y({},c,{samples:O})),Rt="video",Pe={data1:lt,data2:Ve,startPTS:he/E,endPTS:(ge+F)/E,startDTS:ee/E,endDTS:J/E,type:Rt,hasAudio:!1,hasVideo:!0,nb:O.length,dropped:c.dropped};return c.samples=[],c.dropped=0,console.assert(Ve.length,"MDAT length must not be zero"),Pe},T.remuxAudio=function(c,u,o,C,E){var v=c.inputTimeScale,O=c.samplerate?c.samplerate:v,j=v/O,G=c.isAAC?L:x,J=G*j,K=this._initPTS,F=!c.isAAC&&this.typeSupported.mpeg,ee=[],oe=c.samples,he=F?0:8,ge=this.nextAudioPts||-1,_e=u*v;if(this.isAudioContiguous=o=o||oe.length&&ge>0&&(C&&Math.abs(_e-ge)<9e3||Math.abs(h(oe[0].pts-K,_e)-ge)<20*J),oe.forEach(function(ue){ue.pts=h(ue.pts-K,_e)}),!o||ge<0){if(oe=oe.filter(function(ue){return ue.pts>=0}),!oe.length)return;E===0?ge=0:C?ge=Math.max(0,_e):ge=oe[0].pts}if(c.isAAC)for(var be=E!==void 0,Ee=this.config.maxAudioFramesDrift,Te=0,Ce=ge;Te<oe.length;Te++){var me=oe[Te],se=me.pts,Re=se-Ce,et=Math.abs(1e3*Re/v);if(Re<=-Ee*J&&be)Te===0&&(M.logger.warn("Audio frame @ "+(se/v).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Re/v)+" ms."),this.nextAudioPts=ge=Ce=se);else if(Re>=Ee*J&&et<P&&be){var Ge=Math.round(Re/J);Ce=se-Ge*J,Ce<0&&(Ge--,Ce+=J),Te===0&&(this.nextAudioPts=ge=Ce),M.logger.warn("[mp4-remuxer]: Injecting "+Ge+" audio frame @ "+(Ce/v).toFixed(3)+"s due to "+Math.round(1e3*Re/v)+" ms gap.");for(var tt=0;tt<Ge;tt++){var Ye=Math.max(Ce,0),De=I.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);De||(M.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),De=me.unit.subarray()),oe.splice(Te,0,{unit:De,pts:Ye}),Ce+=J,Te++}}me.pts=Ce,Ce+=J}for(var je=null,$e=null,st,Qe=0,Be=oe.length;Be--;)Qe+=oe[Be].unit.byteLength;for(var We=0,ft=oe.length;We<ft;We++){var Ke=oe[We],Ue=Ke.unit,Xe=Ke.pts;if($e!==null){var Ze=ee[We-1];Ze.duration=Math.round((Xe-$e)/j)}else if(o&&c.isAAC&&(Xe=ge),je=Xe,Qe>0){Qe+=he;try{st=new Uint8Array(Qe)}catch(ue){this.observer.emit(B.Events.ERROR,B.Events.ERROR,{type:N.ErrorTypes.MUX_ERROR,details:N.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Qe,reason:"fail allocating audio mdat "+Qe});return}if(!F){var Ve=new DataView(st.buffer);Ve.setUint32(0,Qe),st.set(w.default.types.mdat,4)}}else return;st.set(Ue,he);var rt=Ue.byteLength;he+=rt,ee.push(new f(!0,G,rt,0)),$e=Xe}var we=ee.length;if(!we)return;var qe=ee[ee.length-1];this.nextAudioPts=ge=$e+j*qe.duration;var it=F?new Uint8Array(0):w.default.moof(c.sequenceNumber++,je/j,y({},c,{samples:ee}));c.samples=[];var Ae=je/v,Oe=ge/v,pe="audio",de={data1:it,data2:st,startPTS:Ae,endPTS:Oe,startDTS:Ae,endDTS:Oe,type:pe,hasAudio:!0,hasVideo:!1,nb:we};return this.isAudioContiguous=!0,console.assert(st.length,"MDAT length must not be zero"),de},T.remuxEmptyAudio=function(c,u,o,C){var E=c.inputTimeScale,v=c.samplerate?c.samplerate:E,O=E/v,j=this.nextAudioPts,G=(j!==null?j:C.startDTS*E)+this._initDTS,J=C.endDTS*E+this._initDTS,K=O*L,F=Math.ceil((J-G)/K),ee=I.default.getSilentFrame(c.manifestCodec||c.codec,c.channelCount);if(M.logger.warn("[mp4-remuxer]: remux empty Audio"),!ee){M.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var oe=[],he=0;he<F;he++){var ge=G+he*K;oe.push({unit:ee,pts:ge,dts:ge})}return c.samples=oe,this.remuxAudio(c,u,o,!1)},T.remuxID3=function(c,u){var o=c.samples.length;if(!o)return;for(var C=c.inputTimeScale,E=this._initPTS,v=this._initDTS,O=0;O<o;O++){var j=c.samples[O];j.pts=h(j.pts-E,u*C)/C,j.dts=h(j.dts-v,u*C)/C}var G=c.samples;return c.samples=[],{samples:G}},T.remuxText=function(c,u){var o=c.samples.length;if(!o)return;for(var C=c.inputTimeScale,E=this._initPTS,v=0;v<o;v++){var O=c.samples[v];O.pts=h(O.pts-E,u*C)/C}c.samples.sort(function(G,J){return G.pts-J.pts});var j=c.samples;return c.samples=[],{samples:j}},R}();function h(R,T){var g;if(T===null)return R;for(T<R?g=-8589934592:g=8589934592;Math.abs(R-T)>4294967296;)R+=g;return R}function _(R){for(var T=0;T<R.length;T++)if(R[T].key)return T;return-1}var f=function(T,g,c,u){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=g,this.size=c,this.cts=u,this.flags=new b(T)},b=function(T){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=T?2:1,this.isNonSync=T?0:1}},"./src/remux/passthrough-remuxer.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/polyfills/number.ts"),I=D("./src/utils/mp4-tools.ts"),w=D("./src/loader/fragment.ts"),B=D("./src/utils/logger.ts"),N=function(){function p(){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 y=p.prototype;return y.destroy=function(){},y.resetTimeStamp=function(L){this.initPTS=L,this.lastEndDTS=null},y.resetNextTimestamp=function(){this.lastEndDTS=null},y.resetInitSegment=function(L,x,S){this.audioCodec=x,this.videoCodec=S,this.generateInitSegment(L),this.emitInitSegment=!0},y.generateInitSegment=function(L){var x=this.audioCodec,S=this.videoCodec;if(!L||!L.byteLength){this.initTracks=void 0,this.initData=void 0;return}var d=this.initData=Object(I.parseInitSegment)(L);x||(x=k(d.audio,w.ElementaryStreamTypes.AUDIO)),S||(S=k(d.video,w.ElementaryStreamTypes.VIDEO));var a={};d.audio&&d.video?a.audiovideo={container:"video/mp4",codec:x+","+S,initSegment:L,id:"main"}:d.audio?a.audio={container:"audio/mp4",codec:x,initSegment:L,id:"audio"}:d.video?a.video={container:"video/mp4",codec:S,initSegment:L,id:"main"}:B.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},y.remux=function(L,x,S,d,a){var l=this.initPTS,h=this.lastEndDTS,_={audio:void 0,video:void 0,text:d,id3:S,initSegment:void 0};Object(V.isFiniteNumber)(h)||(h=this.lastEndDTS=a||0);var f=x.samples;if(!f||!f.length)return _;var b={initPTS:void 0,timescale:1},R=this.initData;if((!R||!R.length)&&(this.generateInitSegment(f),R=this.initData),!R||!R.length)return B.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),_;this.emitInitSegment&&(b.tracks=this.initTracks,this.emitInitSegment=!1),Object(V.isFiniteNumber)(l)||(this.initPTS=b.initPTS=l=M(R,f,h));var T=Object(I.getDuration)(f,R),g=h,c=T+g;Object(I.offsetStartDTS)(R,f,l),T>0?this.lastEndDTS=c:(B.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var u=!!R.audio,o=!!R.video,C="";u&&(C+="audio"),o&&(C+="video");var E={data1:f,startPTS:g,startDTS:g,endPTS:c,endDTS:c,type:C,hasAudio:u,hasVideo:o,nb:1,dropped:0};return _.audio=E.type==="audio"?E:void 0,_.video=E.type!=="audio"?E:void 0,_.text=d,_.id3=S,_.initSegment=b,_},p}(),M=function(y,P,L){return Object(I.getStartDTS)(y,P)-L};function k(p,y){var P=p==null?void 0:p.codec;return P&&P.length>4?P:P==="hvc1"?"hvc1.1.c.L120.90":P==="av01"?"av01.0.04M.08":P==="avc1"||y===w.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}Y.default=N},"./src/task-loop.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return V});var V=function(){function I(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var w=I.prototype;return w.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},w.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},w.onHandlerDestroyed=function(){},w.hasInterval=function(){return!!this._tickInterval},w.hasNextTick=function(){return!!this._tickTimer},w.setInterval=function(N){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,N),!0)},w.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},w.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},w.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},w.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},w.doTick=function(){},I}()},"./src/types/cmcd.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"CMCDVersion",function(){return V}),D.d(Y,"CMCDObjectType",function(){return I}),D.d(Y,"CMCDStreamingFormat",function(){return w}),D.d(Y,"CMCDStreamType",function(){return B});var V=1,I;(function(N){N.MANIFEST="m",N.AUDIO="a",N.VIDEO="v",N.MUXED="av",N.INIT="i",N.CAPTION="c",N.TIMED_TEXT="tt",N.KEY="k",N.OTHER="o"})(I||(I={}));var w;(function(N){N.DASH="d",N.HLS="h",N.SMOOTH="s",N.OTHER="o"})(w||(w={}));var B;(function(N){N.VOD="v",N.LIVE="l"})(B||(B={}))},"./src/types/level.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"HlsSkip",function(){return w}),D.d(Y,"getSkipValue",function(){return B}),D.d(Y,"HlsUrlParameters",function(){return N}),D.d(Y,"Level",function(){return M});function V(k,p){for(var y=0;y<p.length;y++){var P=p[y];P.enumerable=P.enumerable||!1,P.configurable=!0,"value"in P&&(P.writable=!0),Object.defineProperty(k,P.key,P)}}function I(k,p,y){return p&&V(k.prototype,p),y&&V(k,y),k}var w;(function(k){k.No="",k.Yes="YES",k.v2="v2"})(w||(w={}));function B(k,p){var y=k.canSkipUntil,P=k.canSkipDateRanges,L=k.endSN,x=p!==void 0?p-L:0;return y&&x<y?P?w.v2:w.Yes:w.No}var N=function(){function k(y,P,L){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=y,this.part=P,this.skip=L}var p=k.prototype;return p.addDirectives=function(P){var L=new self.URL(P);return this.msn!==void 0&&L.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&L.searchParams.set("_HLS_part",this.part.toString()),this.skip&&L.searchParams.set("_HLS_skip",this.skip),L.toString()},k}(),M=function(){function k(p){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=[p.url],this.attrs=p.attrs,this.bitrate=p.bitrate,p.details&&(this.details=p.details),this.id=p.id||0,this.name=p.name,this.width=p.width||0,this.height=p.height||0,this.audioCodec=p.audioCodec,this.videoCodec=p.videoCodec,this.unknownCodecs=p.unknownCodecs,this.codecSet=[p.videoCodec,p.audioCodec].filter(function(y){return y}).join(",").replace(/\.[^.,]+/g,"")}return I(k,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(y){var P=y%this.url.length;this._urlId!==P&&(this.details=void 0,this._urlId=P)}}]),k}()},"./src/types/loader.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"PlaylistContextType",function(){return V}),D.d(Y,"PlaylistLevelType",function(){return I});var V;(function(w){w.MANIFEST="manifest",w.LEVEL="level",w.AUDIO_TRACK="audioTrack",w.SUBTITLE_TRACK="subtitleTrack"})(V||(V={}));var I;(function(w){w.MAIN="main",w.AUDIO="audio",w.SUBTITLE="subtitle"})(I||(I={}))},"./src/types/transmuxer.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"ChunkMetadata",function(){return V});var V=function(B,N,M,k,p,y){k===void 0&&(k=0),p===void 0&&(p=-1),y===void 0&&(y=!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=B,this.sn=N,this.id=M,this.size=k,this.part=p,this.partial=y};function I(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"AttrList",function(){return w});var V=/^(\d+)x(\d+)$/,I=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,w=function(){function B(M){typeof M=="string"&&(M=B.parseAttrList(M));for(var k in M)M.hasOwnProperty(k)&&(this[k]=M[k])}var N=B.prototype;return N.decimalInteger=function(k){var p=parseInt(this[k],10);return p>Number.MAX_SAFE_INTEGER?Infinity:p},N.hexadecimalInteger=function(k){if(this[k]){var p=(this[k]||"0x").slice(2);p=(p.length&1?"0":"")+p;for(var y=new Uint8Array(p.length/2),P=0;P<p.length/2;P++)y[P]=parseInt(p.slice(P*2,P*2+2),16);return y}else return null},N.hexadecimalIntegerAsNumber=function(k){var p=parseInt(this[k],16);return p>Number.MAX_SAFE_INTEGER?Infinity:p},N.decimalFloatingPoint=function(k){return parseFloat(this[k])},N.optionalFloat=function(k,p){var y=this[k];return y?parseFloat(y):p},N.enumeratedString=function(k){return this[k]},N.bool=function(k){return this[k]==="YES"},N.decimalResolution=function(k){var p=V.exec(this[k]);return p===null?void 0:{width:parseInt(p[1],10),height:parseInt(p[2],10)}},B.parseAttrList=function(k){var p,y={},P='"';for(I.lastIndex=0;(p=I.exec(k))!==null;){var L=p[2];L.indexOf(P)===0&&L.lastIndexOf(P)===L.length-1&&(L=L.slice(1,-1)),y[p[1]]=L}return y},B}()},"./src/utils/binary-search.ts":function(ie,Y,D){"use strict";D.r(Y);var V={search:function(w,B){for(var N=0,M=w.length-1,k=null,p=null;N<=M;){k=(N+M)/2|0,p=w[k];var y=B(p);if(y>0)N=k+1;else if(y<0)M=k-1;else return p}return null}};Y.default=V},"./src/utils/buffer-helper.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"BufferHelper",function(){return w});var V=D("./src/utils/logger.ts"),I={length:0,start:function(){return 0},end:function(){return 0}},w=function(){function B(){}return B.isBuffered=function(M,k){try{if(M){for(var p=B.getBuffered(M),y=0;y<p.length;y++)if(k>=p.start(y)&&k<=p.end(y))return!0}}catch(P){}return!1},B.bufferInfo=function(M,k,p){try{if(M){var y=B.getBuffered(M),P=[],L;for(L=0;L<y.length;L++)P.push({start:y.start(L),end:y.end(L)});return this.bufferedInfo(P,k,p)}}catch(x){}return{len:0,start:k,end:k,nextStart:void 0}},B.bufferedInfo=function(M,k,p){k=Math.max(0,k),M.sort(function(b,R){var T=b.start-R.start;return T||R.end-b.end});var y=[];if(p)for(var P=0;P<M.length;P++){var L=y.length;if(L){var x=y[L-1].end;M[P].start-x<p?M[P].end>x&&(y[L-1].end=M[P].end):y.push(M[P])}else y.push(M[P])}else y=M;for(var S=0,d,a=k,l=k,h=0;h<y.length;h++){var _=y[h].start,f=y[h].end;if(k+p>=_&&k<f)a=_,l=f,S=l-k;else if(k+p<_){d=_;break}}return{len:S,start:a||0,end:l||0,nextStart:d}},B.getBuffered=function(M){try{return M.buffered}catch(k){return V.logger.log("failed to get media.buffered",k),I}},B}()},"./src/utils/cea-608-parser.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"Row",function(){return l}),D.d(Y,"CaptionScreen",function(){return h});var V=D("./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},w=function(c){var u=c;return I.hasOwnProperty(c)&&(u=I[c]),String.fromCharCode(u)},B=15,N=100,M={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},k={17:2,18:4,21:6,22:8,23:10,19:13,20:15},p={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},y={25:2,26:4,29:6,30:8,31:10,27:13,28:15},P=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],L;(function(g){g[g.ERROR=0]="ERROR",g[g.TEXT=1]="TEXT",g[g.WARNING=2]="WARNING",g[g.INFO=2]="INFO",g[g.DEBUG=3]="DEBUG",g[g.DATA=3]="DATA"})(L||(L={}));var x=function(){function g(){this.time=null,this.verboseLevel=L.ERROR}var c=g.prototype;return c.log=function(o,C){this.verboseLevel>=o&&V.logger.log(this.time+" ["+o+"] "+C)},g}(),S=function(c){for(var u=[],o=0;o<c.length;o++)u.push(c[o].toString(16));return u},d=function(){function g(u,o,C,E,v){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=u||"white",this.underline=o||!1,this.italics=C||!1,this.background=E||"black",this.flash=v||!1}var c=g.prototype;return c.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},c.setStyles=function(o){for(var C=["foreground","underline","italics","background","flash"],E=0;E<C.length;E++){var v=C[E];o.hasOwnProperty(v)&&(this[v]=o[v])}},c.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},c.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},c.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},c.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},g}(),a=function(){function g(u,o,C,E,v,O){this.uchar=void 0,this.penState=void 0,this.uchar=u||" ",this.penState=new d(o,C,E,v,O)}var c=g.prototype;return c.reset=function(){this.uchar=" ",this.penState.reset()},c.setChar=function(o,C){this.uchar=o,this.penState.copy(C)},c.setPenState=function(o){this.penState.copy(o)},c.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},c.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},c.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},g}(),l=function(){function g(u){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<N;o++)this.chars.push(new a);this.logger=u,this.pos=0,this.currPenState=new d}var c=g.prototype;return c.equals=function(o){for(var C=!0,E=0;E<N;E++)if(!this.chars[E].equals(o.chars[E])){C=!1;break}return C},c.copy=function(o){for(var C=0;C<N;C++)this.chars[C].copy(o.chars[C])},c.isEmpty=function(){for(var o=!0,C=0;C<N;C++)if(!this.chars[C].isEmpty()){o=!1;break}return o},c.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(L.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>N&&(this.logger.log(L.DEBUG,"Too large cursor position "+this.pos),this.pos=N)},c.moveCursor=function(o){var C=this.pos+o;if(o>1)for(var E=this.pos+1;E<C+1;E++)this.chars[E].setPenState(this.currPenState);this.setCursor(C)},c.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},c.insertChar=function(o){o>=144&&this.backSpace();var C=w(o);if(this.pos>=N){this.logger.log(L.ERROR,"Cannot insert "+o.toString(16)+" ("+C+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(C,this.currPenState),this.moveCursor(1)},c.clearFromPos=function(o){var C;for(C=o;C<N;C++)this.chars[C].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 o=[],C=!0,E=0;E<N;E++){var v=this.chars[E].uchar;v!==" "&&(C=!1),o.push(v)}return C?"":o.join("")},c.setPenStyles=function(o){this.currPenState.setStyles(o);var C=this.chars[this.pos];C.setPenState(this.currPenState)},g}(),h=function(){function g(u){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<B;o++)this.rows.push(new l(u));this.logger=u,this.currRow=B-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var c=g.prototype;return c.reset=function(){for(var o=0;o<B;o++)this.rows[o].clear();this.currRow=B-1},c.equals=function(o){for(var C=!0,E=0;E<B;E++)if(!this.rows[E].equals(o.rows[E])){C=!1;break}return C},c.copy=function(o){for(var C=0;C<B;C++)this.rows[C].copy(o.rows[C])},c.isEmpty=function(){for(var o=!0,C=0;C<B;C++)if(!this.rows[C].isEmpty()){o=!1;break}return o},c.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},c.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},c.insertChar=function(o){var C=this.rows[this.currRow];C.insertChar(o)},c.setPen=function(o){var C=this.rows[this.currRow];C.setPenStyles(o)},c.moveCursor=function(o){var C=this.rows[this.currRow];C.moveCursor(o)},c.setCursor=function(o){this.logger.log(L.INFO,"setCursor: "+o);var C=this.rows[this.currRow];C.setCursor(o)},c.setPAC=function(o){this.logger.log(L.INFO,"pacData = "+JSON.stringify(o));var C=o.row-1;if(this.nrRollUpRows&&C<this.nrRollUpRows-1&&(C=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==C){for(var E=0;E<B;E++)this.rows[E].clear();var v=this.currRow+1-this.nrRollUpRows,O=this.lastOutputScreen;if(O){var j=O.rows[v].cueStartTime,G=this.logger.time;if(j&&G!==null&&j<G)for(var J=0;J<this.nrRollUpRows;J++)this.rows[C-this.nrRollUpRows+J+1].copy(O.rows[v+J])}}this.currRow=C;var K=this.rows[this.currRow];if(o.indent!==null){var F=o.indent,ee=Math.max(F-1,0);K.setCursor(o.indent),o.color=K.chars[ee].penState.foreground}var oe={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(oe)},c.setBkgData=function(o){this.logger.log(L.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},c.setRollUpRows=function(o){this.nrRollUpRows=o},c.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(L.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(L.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,C=this.rows.splice(o,1)[0];C.clear(),this.rows.splice(this.currRow,0,C),this.logger.log(L.INFO,"Rolling up")},c.getDisplayText=function(o){o=o||!1;for(var C=[],E="",v=-1,O=0;O<B;O++){var j=this.rows[O].getTextString();j&&(v=O+1,o?C.push("Row "+v+": '"+j+"'"):C.push(j.trim()))}return C.length>0&&(o?E="["+C.join(" | ")+"]":E=C.join(`
`)),E},c.getTextAndFormat=function(){return this.rows},g}(),_=function(){function g(u,o,C){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=u,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new h(C),this.nonDisplayedMemory=new h(C),this.lastOutputScreen=new h(C),this.currRollUpRow=this.displayedMemory.rows[B-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=C}var c=g.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[B-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},c.getHandler=function(){return this.outputFilter},c.setHandler=function(o){this.outputFilter=o},c.setPAC=function(o){this.writeScreen.setPAC(o)},c.setBkgData=function(o){this.writeScreen.setBkgData(o)},c.setMode=function(o){if(o===this.mode)return;this.mode=o,this.logger.log(L.INFO,"MODE="+o),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=o},c.insertChars=function(o){for(var C=0;C<o.length;C++)this.writeScreen.insertChar(o[C]);var E=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(L.INFO,E+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(L.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},c.ccRCL=function(){this.logger.log(L.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},c.ccBS=function(){if(this.logger.log(L.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(L.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},c.ccRU=function(o){this.logger.log(L.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},c.ccFON=function(){this.logger.log(L.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},c.ccRDC=function(){this.logger.log(L.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},c.ccTR=function(){this.logger.log(L.INFO,"TR"),this.setMode("MODE_TEXT")},c.ccRTD=function(){this.logger.log(L.INFO,"RTD"),this.setMode("MODE_TEXT")},c.ccEDM=function(){this.logger.log(L.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},c.ccCR=function(){this.logger.log(L.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},c.ccENM=function(){this.logger.log(L.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},c.ccEOC=function(){if(this.logger.log(L.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(L.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},c.ccTO=function(o){this.logger.log(L.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},c.ccMIDROW=function(o){var C={flash:!1};if(C.underline=o%2===1,C.italics=o>=46,C.italics)C.foreground="white";else{var E=Math.floor(o/2)-16,v=["white","green","blue","cyan","red","yellow","magenta"];C.foreground=v[E]}this.logger.log(L.INFO,"MIDROW: "+JSON.stringify(C)),this.writeScreen.setPen(C)},c.outputDataUpdate=function(o){o===void 0&&(o=!1);var C=this.logger.time;if(C===null)return;this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=C:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,C,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:C),this.lastOutputScreen.copy(this.displayedMemory))},c.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},g}(),f=function(){function g(u,o,C){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var E=new x;this.channels=[null,new _(u,o,E),new _(u+1,C,E)],this.cmdHistory=T(),this.logger=E}var c=g.prototype;return c.getHandler=function(o){return this.channels[o].getHandler()},c.setHandler=function(o,C){this.channels[o].setHandler(C)},c.addData=function(o,C){var E,v,O,j=!1;this.logger.time=o;for(var G=0;G<C.length;G+=2){if(v=C[G]&127,O=C[G+1]&127,v===0&&O===0)continue;if(this.logger.log(L.DATA,"["+S([C[G],C[G+1]])+"] -> ("+S([v,O])+")"),E=this.parseCmd(v,O),E||(E=this.parseMidrow(v,O)),E||(E=this.parsePAC(v,O)),E||(E=this.parseBackgroundAttributes(v,O)),!E&&(j=this.parseChars(v,O),j)){var J=this.currentChannel;if(J&&J>0){var K=this.channels[J];K.insertChars(j)}else this.logger.log(L.WARNING,"No channel found yet. TEXT-MODE?")}!E&&!j&&this.logger.log(L.WARNING,"Couldn't parse cleaned data "+S([v,O])+" orig: "+S([C[G],C[G+1]]))}},c.parseCmd=function(o,C){var E=this.cmdHistory,v=(o===20||o===28||o===21||o===29)&&C>=32&&C<=47,O=(o===23||o===31)&&C>=33&&C<=35;if(!(v||O))return!1;if(R(o,C,E))return b(null,null,E),this.logger.log(L.DEBUG,"Repeated command ("+S([o,C])+") is dropped"),!0;var j=o===20||o===21||o===23?1:2,G=this.channels[j];return o===20||o===21||o===28||o===29?C===32?G.ccRCL():C===33?G.ccBS():C===34?G.ccAOF():C===35?G.ccAON():C===36?G.ccDER():C===37?G.ccRU(2):C===38?G.ccRU(3):C===39?G.ccRU(4):C===40?G.ccFON():C===41?G.ccRDC():C===42?G.ccTR():C===43?G.ccRTD():C===44?G.ccEDM():C===45?G.ccCR():C===46?G.ccENM():C===47&&G.ccEOC():G.ccTO(C-32),b(o,C,E),this.currentChannel=j,!0},c.parseMidrow=function(o,C){var E=0;if((o===17||o===25)&&C>=32&&C<=47){if(o===17?E=1:E=2,E!==this.currentChannel)return this.logger.log(L.ERROR,"Mismatch channel in midrow parsing"),!1;var v=this.channels[E];return v?(v.ccMIDROW(C),this.logger.log(L.DEBUG,"MIDROW ("+S([o,C])+")"),!0):!1}return!1},c.parsePAC=function(o,C){var E,v=this.cmdHistory,O=(o>=17&&o<=23||o>=25&&o<=31)&&C>=64&&C<=127,j=(o===16||o===24)&&C>=64&&C<=95;if(!(O||j))return!1;if(R(o,C,v))return b(null,null,v),!0;var G=o<=23?1:2;C>=64&&C<=95?E=G===1?M[o]:p[o]:E=G===1?k[o]:y[o];var J=this.channels[G];return J?(J.setPAC(this.interpretPAC(E,C)),b(o,C,v),this.currentChannel=G,!0):!1},c.interpretPAC=function(o,C){var E,v={color:null,italics:!1,indent:null,underline:!1,row:o};return C>95?E=C-96:E=C-64,v.underline=(E&1)===1,E<=13?v.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(E/2)]:E<=15?(v.italics=!0,v.color="white"):v.indent=Math.floor((E-16)/2)*4,v},c.parseChars=function(o,C){var E,v=null,O=null;if(o>=25?(E=2,O=o-8):(E=1,O=o),O>=17&&O<=19){var j;O===17?j=C+80:O===18?j=C+112:j=C+144,this.logger.log(L.INFO,"Special char '"+w(j)+"' in channel "+E),v=[j]}else o>=32&&o<=127&&(v=C===0?[o]:[o,C]);if(v){var G=S(v);this.logger.log(L.DEBUG,"Char codes = "+G.join(",")),b(o,C,this.cmdHistory)}return v},c.parseBackgroundAttributes=function(o,C){var E=(o===16||o===24)&&C>=32&&C<=47,v=(o===23||o===31)&&C>=45&&C<=47;if(!(E||v))return!1;var O,j={};o===16||o===24?(O=Math.floor((C-32)/2),j.background=P[O],C%2===1&&(j.background=j.background+"_semi")):C===45?j.background="transparent":(j.foreground="black",C===47&&(j.underline=!0));var G=o<=23?1:2,J=this.channels[G];return J.setBkgData(j),b(o,C,this.cmdHistory),!0},c.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var C=this.channels[o];C&&C.reset()}this.cmdHistory=T()},c.cueSplitAtTime=function(o){for(var C=0;C<this.channels.length;C++){var E=this.channels[C];E&&E.cueSplitAtTime(o)}},g}();function b(g,c,u){u.a=g,u.b=c}function R(g,c,u){return u.a===g&&u.b===c}function T(){return{a:null,b:null}}Y.default=f},"./src/utils/codecs.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"isCodecType",function(){return I}),D.d(Y,"isCodecSupportedInMp4",function(){return w});var V={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(B,N){var M=V[N];return!!M&&M[B.slice(0,4)]===!0}function w(B,N){return MediaSource.isTypeSupported((N||"video")+'/mp4;codecs="'+B+'"')}},"./src/utils/cues.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/utils/vttparser.ts"),I=D("./src/utils/webvtt-parser.ts"),w=D("./src/utils/texttrack-utils.ts"),B=/\s/,N={newCue:function(k,p,y,P){for(var L=[],x,S,d,a,l,h=self.VTTCue||self.TextTrackCue,_=0;_<P.rows.length;_++)if(x=P.rows[_],d=!0,a=0,l="",!x.isEmpty()){for(var f=0;f<x.chars.length;f++)B.test(x.chars[f].uchar)&&d?a++:(l+=x.chars[f].uchar,d=!1);x.cueStartTime=p,p===y&&(y+=1e-4),a>=16?a--:a++;var b=Object(V.fixLineBreaks)(l.trim()),R=Object(I.generateCueId)(p,y,b);(!k||!k.cues||!k.cues.getCueById(R))&&(S=new h(p,y,b),S.id=R,S.line=_+1,S.align="left",S.position=10+Math.min(80,Math.floor(a*8/32)*10),L.push(S))}return k&&L.length&&(L.sort(function(T,g){return T.line==="auto"||g.line==="auto"?0:T.line>8&&g.line>8?g.line-T.line:T.line-g.line}),L.forEach(function(T){return Object(w.addCueToTrack)(k,T)})),L}};Y.default=N},"./src/utils/discontinuities.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"findFirstFragWithCC",function(){return B}),D.d(Y,"shouldAlignOnDiscontinuities",function(){return N}),D.d(Y,"findDiscontinuousReferenceFrag",function(){return M}),D.d(Y,"adjustSlidingStart",function(){return p}),D.d(Y,"alignStream",function(){return y}),D.d(Y,"alignPDT",function(){return L}),D.d(Y,"alignFragmentByPDTDelta",function(){return x}),D.d(Y,"alignMediaPlaylistByPDT",function(){return S});var V=D("./src/polyfills/number.ts"),I=D("./src/utils/logger.ts"),w=D("./src/controller/level-helper.ts");function B(d,a){for(var l=null,h=0,_=d.length;h<_;h++){var f=d[h];if(f&&f.cc===a){l=f;break}}return l}function N(d,a,l){return!!(a.details&&(l.endCC>l.startCC||d&&d.cc<l.startCC))}function M(d,a){var l=d.fragments,h=a.fragments;if(!h.length||!l.length){I.logger.log("No fragments to align");return}var _=B(l,h[0].cc);if(!_||_&&!_.startPTS){I.logger.log("No frag in previous level to align on");return}return _}function k(d,a){if(d){var l=d.start+a;d.start=d.startPTS=l,d.endPTS=l+d.duration}}function p(d,a){for(var l=a.fragments,h=0,_=l.length;h<_;h++)k(l[h],d);a.fragmentHint&&k(a.fragmentHint,d),a.alignedSliding=!0}function y(d,a,l){if(!a)return;P(d,l,a),!l.alignedSliding&&a.details&&L(l,a.details),!l.alignedSliding&&a.details&&!l.skippedSegments&&Object(w.adjustSliding)(a.details,l)}function P(d,a,l){if(N(d,l,a)){var h=M(l.details,a);h&&Object(V.isFiniteNumber)(h.start)&&(I.logger.log("Adjusting PTS using last level due to CC increase within current level "+a.url),p(h.start,a))}}function L(d,a){if(!a.fragments.length||!d.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,h=d.fragments[0].programDateTime,_=(h-l)/1e3+a.fragments[0].start;_&&Object(V.isFiniteNumber)(_)&&(I.logger.log("Adjusting PTS using programDateTime delta "+(h-l)+"ms, sliding:"+_.toFixed(3)+" "+d.url+" "),p(_,d))}function x(d,a){var l=d.programDateTime;if(!l)return;var h=(l-a)/1e3;d.start=d.startPTS=h,d.endPTS=h+d.duration}function S(d,a){if(!a.fragments.length||!d.hasProgramDateTime||!a.hasProgramDateTime)return;var l=a.fragments[0].programDateTime,h=a.fragments[0].start,_=l-h*1e3;d.fragments.forEach(function(f){x(f,_)}),d.fragmentHint&&x(d.fragmentHint,_),d.alignedSliding=!0}},"./src/utils/ewma-bandwidth-estimator.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/utils/ewma.ts"),I=function(){function w(N,M,k){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=k,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new V.default(N),this.fast_=new V.default(M)}var B=w.prototype;return B.update=function(M,k){var p=this.slow_,y=this.fast_;this.slow_.halfLife!==M&&(this.slow_=new V.default(M,p.getEstimate(),p.getTotalWeight())),this.fast_.halfLife!==k&&(this.fast_=new V.default(k,y.getEstimate(),y.getTotalWeight()))},B.sample=function(M,k){M=Math.max(M,this.minDelayMs_);var p=8*k,y=M/1e3,P=p/y;this.fast_.sample(y,P),this.slow_.sample(y,P)},B.canEstimate=function(){var M=this.fast_;return M&&M.getTotalWeight()>=this.minWeight_},B.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},B.destroy=function(){},w}();Y.default=I},"./src/utils/ewma.ts":function(ie,Y,D){"use strict";D.r(Y);var V=function(){function I(B,N,M){N===void 0&&(N=0),M===void 0&&(M=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=B,this.alpha_=B?Math.exp(Math.log(.5)/B):0,this.estimate_=N,this.totalWeight_=M}var w=I.prototype;return w.sample=function(N,M){var k=Math.pow(this.alpha_,N);this.estimate_=M*(1-k)+k*this.estimate_,this.totalWeight_+=N},w.getTotalWeight=function(){return this.totalWeight_},w.getEstimate=function(){if(this.alpha_){var N=1-Math.pow(this.alpha_,this.totalWeight_);if(N)return this.estimate_/N}return this.estimate_},I}();Y.default=V},"./src/utils/fetch-loader.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"fetchSupported",function(){return x});var V=D("./src/polyfills/number.ts"),I=D("./src/loader/load-stats.ts"),w=D("./src/demux/chunk-cache.ts");function B(h,_){h.prototype=Object.create(_.prototype),h.prototype.constructor=h,y(h,_)}function N(h){var _=typeof Map=="function"?new Map:void 0;return N=function(b){if(b===null||!p(b))return b;if(typeof b!="function")throw new TypeError("Super expression must either be null or a function");if(typeof _!="undefined"){if(_.has(b))return _.get(b);_.set(b,R)}function R(){return M(b,arguments,P(this).constructor)}return R.prototype=Object.create(b.prototype,{constructor:{value:R,enumerable:!1,writable:!0,configurable:!0}}),y(R,b)},N(h)}function M(h,_,f){return k()?M=Reflect.construct:M=function(R,T,g){var c=[null];c.push.apply(c,T);var u=Function.bind.apply(R,c),o=new u;return g&&y(o,g.prototype),o},M.apply(null,arguments)}function k(){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(h){return!1}}function p(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function y(h,_){return y=Object.setPrototypeOf||function(b,R){return b.__proto__=R,b},y(h,_)}function P(h){return P=Object.setPrototypeOf?Object.getPrototypeOf:function(f){return f.__proto__||Object.getPrototypeOf(f)},P(h)}function L(){return L=Object.assign||function(h){for(var _=1;_<arguments.length;_++){var f=arguments[_];for(var b in f)Object.prototype.hasOwnProperty.call(f,b)&&(h[b]=f[b])}return h},L.apply(this,arguments)}function x(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(h){}return!1}var S=function(){function h(f){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=f.fetchSetup||a,this.controller=new self.AbortController,this.stats=new I.LoadStats}var _=h.prototype;return _.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},_.abortInternal=function(){var b=this.response;(!b||!b.ok)&&(this.stats.aborted=!0,this.controller.abort())},_.abort=function(){var b;this.abortInternal(),(b=this.callbacks)!==null&&b!==void 0&&b.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},_.load=function(b,R,T){var g=this,c=this.stats;if(c.loading.start)throw new Error("Loader can only be used once.");c.loading.start=self.performance.now();var u=d(b,this.controller.signal),o=T.onProgress,C=b.responseType==="arraybuffer",E=C?"byteLength":"length";this.context=b,this.config=R,this.callbacks=T,this.request=this.fetchSetup(b,u),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){g.abortInternal(),T.onTimeout(c,b,g.response)},R.timeout),self.fetch(this.request).then(function(v){if(g.response=g.loader=v,!v.ok){var O=v.status,j=v.statusText;throw new l(j||"fetch, bad network response",O,v)}return c.loading.first=Math.max(self.performance.now(),c.loading.start),c.total=parseInt(v.headers.get("Content-Length")||"0"),o&&Object(V.isFiniteNumber)(R.highWaterMark)?g.loadProgressively(v,c,b,R.highWaterMark,o):C?v.arrayBuffer():v.text()}).then(function(v){var O=g.response;self.clearTimeout(g.requestTimeout),c.loading.end=Math.max(self.performance.now(),c.loading.first),c.loaded=c.total=v[E];var j={url:O.url,data:v};o&&!Object(V.isFiniteNumber)(R.highWaterMark)&&o(c,b,v,O),T.onSuccess(j,c,b,O)}).catch(function(v){if(self.clearTimeout(g.requestTimeout),c.aborted)return;var O=v.code||0;T.onError({code:O,text:v.message},b,v.details)})},_.getCacheAge=function(){var b=null;if(this.response){var R=this.response.headers.get("age");b=R?parseFloat(R):null}return b},_.loadProgressively=function(b,R,T,g,c){g===void 0&&(g=0);var u=new w.default,o=b.body.getReader(),C=function E(){return o.read().then(function(v){if(v.done)return u.dataLength&&c(R,T,u.flush(),b),Promise.resolve(new ArrayBuffer(0));var O=v.value,j=O.length;return R.loaded+=j,j<g||u.dataLength?(u.push(O),u.dataLength>=g&&c(R,T,u.flush(),b)):c(R,T,O,b),E()}).catch(function(){return Promise.reject()})};return C()},h}();function d(h,_){var f={method:"GET",mode:"cors",credentials:"same-origin",signal:_,headers:new self.Headers(L({},h.headers))};return h.rangeEnd&&f.headers.set("Range","bytes="+h.rangeStart+"-"+String(h.rangeEnd-1)),f}function a(h,_){return new self.Request(h.url,_)}var l=function(h){B(_,h);function _(f,b,R){var T;return T=h.call(this,f)||this,T.code=void 0,T.details=void 0,T.code=b,T.details=R,T}return _}(N(Error));Y.default=S},"./src/utils/imsc1-ttml-parser.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"IMSC1_CODEC",function(){return p}),D.d(Y,"parseIMSC1",function(){return x});var V=D("./src/utils/mp4-tools.ts"),I=D("./src/utils/vttparser.ts"),w=D("./src/utils/vttcue.ts"),B=D("./src/demux/id3.ts"),N=D("./src/utils/timescale-conversion.ts"),M=D("./src/utils/webvtt-parser.ts");function k(){return k=Object.assign||function(g){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var o in u)Object.prototype.hasOwnProperty.call(u,o)&&(g[o]=u[o])}return g},k.apply(this,arguments)}var p="stpp.ttml.im1t",y=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,P=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,L={left:"start",center:"center",right:"end",start:"start",end:"end"};function x(g,c,u,o,C){var E=Object(V.findBox)(new Uint8Array(g),["mdat"]);if(E.length===0){C(new Error("Could not parse IMSC1 mdat"));return}var v=E[0],O=Object(B.utf8ArrayToStr)(new Uint8Array(g,v.start,v.end-v.start)),j=Object(N.toTimescaleFromScale)(c,1,u);try{o(S(O,j))}catch(G){C(G)}}function S(g,c){var u=new DOMParser,o=u.parseFromString(g,"text/xml"),C=o.getElementsByTagName("tt")[0];if(!C)throw new Error("Invalid ttml");var E={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},v=Object.keys(E).reduce(function(K,F){return K[F]=C.getAttribute("ttp:"+F)||E[F],K},{}),O=C.getAttribute("xml:space")!=="preserve",j=a(d(C,"styling","style")),G=a(d(C,"layout","region")),J=d(C,"body","[begin]");return[].map.call(J,function(K){var F=l(K,O);if(!F||!K.hasAttribute("begin"))return null;var ee=b(K.getAttribute("begin"),v),oe=b(K.getAttribute("dur"),v),he=b(K.getAttribute("end"),v);if(ee===null)throw f(K);if(he===null){if(oe===null)throw f(K);he=ee+oe}var ge=new w.default(ee-c,he-c,F);ge.id=Object(M.generateCueId)(ge.startTime,ge.endTime,ge.text);var _e=G[K.getAttribute("region")],be=j[K.getAttribute("style")];ge.position=10,ge.size=80;var Ee=h(_e,be),Te=Ee.textAlign;if(Te){var Ce=L[Te];Ce&&(ge.lineAlign=Ce),ge.align=Te}return k(ge,Ee),ge}).filter(function(K){return K!==null})}function d(g,c,u){var o=g.getElementsByTagName(c)[0];return o?[].slice.call(o.querySelectorAll(u)):[]}function a(g){return g.reduce(function(c,u){var o=u.getAttribute("xml:id");return o&&(c[o]=u),c},{})}function l(g,c){return[].slice.call(g.childNodes).reduce(function(u,o,C){var E;return o.nodeName==="br"&&C?u+`
`:(E=o.childNodes)!==null&&E!==void 0&&E.length?l(o,c):c?u+o.textContent.trim().replace(/\s+/g," "):u+o.textContent},"")}function h(g,c){var u="http://www.w3.org/ns/ttml#styling",o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return o.reduce(function(C,E){var v=_(c,u,E)||_(g,u,E);return v&&(C[E]=v),C},{})}function _(g,c,u){return g.hasAttributeNS(c,u)?g.getAttributeNS(c,u):null}function f(g){return new Error("Could not parse ttml timestamp "+g)}function b(g,c){if(!g)return null;var u=Object(I.parseTimeStamp)(g);return u===null&&(y.test(g)?u=R(g,c):P.test(g)&&(u=T(g,c))),u}function R(g,c){var u=y.exec(g),o=(u[4]|0)+(u[5]|0)/c.subFrameRate;return(u[1]|0)*3600+(u[2]|0)*60+(u[3]|0)+o/c.frameRate}function T(g,c){var u=P.exec(g),o=Number(u[1]),C=u[2];switch(C){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/c.frameRate;case"t":return o/c.tickRate}return o}},"./src/utils/logger.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"enableLogs",function(){return M}),D.d(Y,"logger",function(){return k});var V=function(){},I={trace:V,debug:V,log:V,warn:V,info:V,error:V},w=I;function B(p){var y=self.console[p];return y?y.bind(self.console,"["+p+"] >"):V}function N(p){for(var y=arguments.length,P=new Array(y>1?y-1:0),L=1;L<y;L++)P[L-1]=arguments[L];P.forEach(function(x){w[x]=p[x]?p[x].bind(p):B(x)})}function M(p){if(self.console&&p===!0||typeof p=="object"){N(p,"debug","log","info","warn","error");try{w.log()}catch(y){w=I}}else w=I}var k=w},"./src/utils/mediakeys-helper.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"KeySystems",function(){return V}),D.d(Y,"requestMediaKeySystemAccess",function(){return I});var V;(function(w){w.WIDEVINE="com.widevine.alpha",w.PLAYREADY="com.microsoft.playready"})(V||(V={}));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(ie,Y,D){"use strict";D.r(Y),D.d(Y,"getMediaSource",function(){return V});function V(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"bin2str",function(){return N}),D.d(Y,"readUint16",function(){return M}),D.d(Y,"readUint32",function(){return k}),D.d(Y,"writeUint32",function(){return p}),D.d(Y,"findBox",function(){return y}),D.d(Y,"parseSegmentIndex",function(){return P}),D.d(Y,"parseInitSegment",function(){return L}),D.d(Y,"getStartDTS",function(){return x}),D.d(Y,"getDuration",function(){return S}),D.d(Y,"computeRawDurationFromSamples",function(){return d}),D.d(Y,"offsetStartDTS",function(){return a}),D.d(Y,"segmentValidRange",function(){return l}),D.d(Y,"appendUint8Array",function(){return h});var V=D("./src/utils/typed-array.ts"),I=D("./src/loader/fragment.ts"),w=Math.pow(2,32)-1,B=[].push;function N(_){return String.fromCharCode.apply(null,_)}function M(_,f){"data"in _&&(f+=_.start,_=_.data);var b=_[f]<<8|_[f+1];return b<0?65536+b:b}function k(_,f){"data"in _&&(f+=_.start,_=_.data);var b=_[f]<<24|_[f+1]<<16|_[f+2]<<8|_[f+3];return b<0?4294967296+b:b}function p(_,f,b){"data"in _&&(f+=_.start,_=_.data),_[f]=b>>24,_[f+1]=b>>16&255,_[f+2]=b>>8&255,_[f+3]=b&255}function y(_,f){var b=[];if(!f.length)return b;var R,T,g;"data"in _?(R=_.data,T=_.start,g=_.end):(R=_,T=0,g=R.byteLength);for(var c=T;c<g;){var u=k(R,c),o=N(R.subarray(c+4,c+8)),C=u>1?c+u:g;if(o===f[0])if(f.length===1)b.push({data:R,start:c+8,end:C});else{var E=y({data:R,start:c+8,end:C},f.slice(1));E.length&&B.apply(b,E)}c=C}return b}function P(_){var f=y(_,["moov"]),b=f[0],R=b?b.end:null,T=y(_,["sidx"]);if(!T||!T[0])return null;var g=[],c=T[0],u=c.data[0],o=u===0?8:16,C=k(c,o);o+=4;var E=0,v=0;u===0?o+=8:o+=16,o+=2;var O=c.end+v,j=M(c,o);o+=2;for(var G=0;G<j;G++){var J=o,K=k(c,J);J+=4;var F=K&2147483647,ee=(K&2147483648)>>>31;if(ee===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var oe=k(c,J);J+=4,g.push({referenceSize:F,subsegmentDuration:oe,info:{duration:oe/C,start:O,end:O+F-1}}),O+=F,J+=4,o=J}return{earliestPresentationTime:E,timescale:C,version:u,referencesCount:j,references:g,moovEndOffset:R}}function L(_){for(var f=[],b=y(_,["moov","trak"]),R=0;R<b.length;R++){var T=b[R],g=y(T,["tkhd"])[0];if(g){var c=g.data[g.start],u=c===0?12:20,o=k(g,u),C=y(T,["mdia","mdhd"])[0];if(C){c=C.data[C.start],u=c===0?12:20;var E=k(C,u),v=y(T,["mdia","hdlr"])[0];if(v){var O=N(v.data.subarray(v.start+8,v.start+12)),j={soun:I.ElementaryStreamTypes.AUDIO,vide:I.ElementaryStreamTypes.VIDEO}[O];if(j){var G=y(T,["mdia","minf","stbl","stsd"])[0],J=void 0;G&&(J=N(G.data.subarray(G.start+12,G.start+16))),f[o]={timescale:E,type:j},f[j]={timescale:E,id:o,codec:J}}}}}}var K=y(_,["moov","mvex","trex"]);return K.forEach(function(F){var ee=k(F,4),oe=f[ee];oe&&(oe.default={duration:k(F,12),flags:k(F,20)})}),f}function x(_,f){return y(f,["moof","traf"]).reduce(function(b,R){var T=y(R,["tfdt"])[0],g=T.data[T.start],c=y(R,["tfhd"]).reduce(function(u,o){var C=k(o,4),E=_[C];if(E){var v=k(T,4);g===1&&(v*=Math.pow(2,32),v+=k(T,8));var O=E.timescale||9e4,j=v/O;if(isFinite(j)&&(u===null||j<u))return j}return u},null);return c!==null&&isFinite(c)&&(b===null||c<b)?c:b},null)||0}function S(_,f){for(var b=0,R=0,T=0,g=y(_,["moof","traf"]),c=0;c<g.length;c++){var u=g[c],o=y(u,["tfhd"])[0],C=k(o,4),E=f[C];if(!E)continue;var v=E.default,O=k(o,0)|(v==null?void 0:v.flags),j=v==null?void 0:v.duration;O&8&&(O&2?j=k(o,12):j=k(o,8));for(var G=E.timescale||9e4,J=y(u,["trun"]),K=0;K<J.length;K++){if(j){var F=k(J[K],4);b=j*F}else b=d(J[K]);E.type===I.ElementaryStreamTypes.VIDEO?R+=b/G:E.type===I.ElementaryStreamTypes.AUDIO&&(T+=b/G)}}if(R===0&&T===0){var ee=P(_);if(ee!=null&&ee.references)return ee.references.reduce(function(oe,he){return oe+he.info.duration||0},0)}return R||T}function d(_){var f=k(_,0),b=8;f&1&&(b+=4),f&4&&(b+=4);for(var R=0,T=k(_,4),g=0;g<T;g++){if(f&256){var c=k(_,b);R+=c,b+=4}f&512&&(b+=4),f&1024&&(b+=4),f&2048&&(b+=4)}return R}function a(_,f,b){y(f,["moof","traf"]).forEach(function(R){y(R,["tfhd"]).forEach(function(T){var g=k(T,4),c=_[g];if(!c)return;var u=c.timescale||9e4;y(R,["tfdt"]).forEach(function(o){var C=o.data[o.start],E=k(o,4);if(C===0)p(o,4,E-b*u);else{E*=Math.pow(2,32),E+=k(o,8),E-=b*u,E=Math.max(E,0);var v=Math.floor(E/(w+1)),O=Math.floor(E%(w+1));p(o,4,v),p(o,8,O)}})})})}function l(_){var f={valid:null,remainder:null},b=y(_,["moof"]);if(b){if(b.length<2)return f.remainder=_,f}else return f;var R=b[b.length-1];return f.valid=Object(V.sliceUint8)(_,0,R.start-8),f.remainder=Object(V.sliceUint8)(_,R.start-8),f}function h(_,f){var b=new Uint8Array(_.length+f.length);return b.set(_),b.set(f,_.length),b}},"./src/utils/output-filter.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"default",function(){return V});var V=function(){function I(B,N){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=B,this.trackName=N}var w=I.prototype;return w.dispatchCue=function(){if(this.startTime===null)return;this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null},w.newCue=function(N,M,k){(this.startTime===null||this.startTime>N)&&(this.startTime=N),this.endTime=M,this.screen=k,this.timelineController.createCaptionsTrack(this.trackName)},w.reset=function(){this.cueRanges=[]},I}()},"./src/utils/texttrack-utils.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"sendAddTrackEvent",function(){return I}),D.d(Y,"addCueToTrack",function(){return w}),D.d(Y,"clearCurrentCues",function(){return B}),D.d(Y,"removeCuesInRange",function(){return N}),D.d(Y,"getCuesInRange",function(){return k});var V=D("./src/utils/logger.ts");function I(p,y){var P;try{P=new Event("addtrack")}catch(L){P=document.createEvent("Event"),P.initEvent("addtrack",!1,!1)}P.track=p,y.dispatchEvent(P)}function w(p,y){var P=p.mode;if(P==="disabled"&&(p.mode="hidden"),p.cues&&!p.cues.getCueById(y.id))try{if(p.addCue(y),!p.cues.getCueById(y.id))throw new Error("addCue is failed for: "+y)}catch(x){V.logger.debug("[texttrack-utils]: "+x);var L=new self.TextTrackCue(y.startTime,y.endTime,y.text);L.id=y.id,p.addCue(L)}P==="disabled"&&(p.mode=P)}function B(p){var y=p.mode;if(y==="disabled"&&(p.mode="hidden"),p.cues)for(var P=p.cues.length;P--;)p.removeCue(p.cues[P]);y==="disabled"&&(p.mode=y)}function N(p,y,P){var L=p.mode;if(L==="disabled"&&(p.mode="hidden"),p.cues&&p.cues.length>0)for(var x=k(p.cues,y,P),S=0;S<x.length;S++)p.removeCue(x[S]);L==="disabled"&&(p.mode=L)}function M(p,y){if(y<p[0].startTime)return 0;var P=p.length-1;if(y>p[P].endTime)return-1;for(var L=0,x=P;L<=x;){var S=Math.floor((x+L)/2);if(y<p[S].startTime)x=S-1;else if(y>p[S].startTime&&L<P)L=S+1;else return S}return p[L].startTime-y<y-p[x].startTime?L:x}function k(p,y,P){var L=[],x=M(p,y);if(x>-1)for(var S=x,d=p.length;S<d;S++){var a=p[S];if(a.startTime>=y&&a.endTime<=P)L.push(a);else if(a.startTime>P)return L}return L}},"./src/utils/time-ranges.ts":function(ie,Y,D){"use strict";D.r(Y);var V={toString:function(w){for(var B="",N=w.length,M=0;M<N;M++)B+="["+w.start(M).toFixed(3)+","+w.end(M).toFixed(3)+"]";return B}};Y.default=V},"./src/utils/timescale-conversion.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"toTimescaleFromBase",function(){return I}),D.d(Y,"toTimescaleFromScale",function(){return w}),D.d(Y,"toMsFromMpegTsClock",function(){return B}),D.d(Y,"toMpegTsClockFromTimescale",function(){return N});var V=9e4;function I(M,k,p,y){p===void 0&&(p=1),y===void 0&&(y=!1);var P=M*k*p;return y?Math.round(P):P}function w(M,k,p,y){return p===void 0&&(p=1),y===void 0&&(y=!1),I(M,k,1/p,y)}function B(M,k){return k===void 0&&(k=!1),I(M,1e3,1/V,k)}function N(M,k){return k===void 0&&(k=1),I(M,V,1/k)}},"./src/utils/typed-array.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"sliceUint8",function(){return V});function V(I,w,B){return Uint8Array.prototype.slice?I.slice(w,B):new Uint8Array(Array.prototype.slice.call(I,w,B))}},"./src/utils/vttcue.ts":function(ie,Y,D){"use strict";D.r(Y),Y.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var V=["","lr","rl"],I=["start","middle","end","left","right"];function w(p,y){if(typeof y!="string")return!1;if(!Array.isArray(p))return!1;var P=y.toLowerCase();return~p.indexOf(P)?P:!1}function B(p){return w(V,p)}function N(p){return w(I,p)}function M(p){for(var y=arguments.length,P=new Array(y>1?y-1:0),L=1;L<y;L++)P[L-1]=arguments[L];for(var x=1;x<arguments.length;x++){var S=arguments[x];for(var d in S)p[d]=S[d]}return p}function k(p,y,P){var L=this,x={enumerable:!0};L.hasBeenReset=!1;var S="",d=!1,a=p,l=y,h=P,_=null,f="",b=!0,R="auto",T="start",g=50,c="middle",u=50,o="middle";Object.defineProperty(L,"id",M({},x,{get:function(){return S},set:function(E){S=""+E}})),Object.defineProperty(L,"pauseOnExit",M({},x,{get:function(){return d},set:function(E){d=!!E}})),Object.defineProperty(L,"startTime",M({},x,{get:function(){return a},set:function(E){if(typeof E!="number")throw new TypeError("Start time must be set to a number.");a=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"endTime",M({},x,{get:function(){return l},set:function(E){if(typeof E!="number")throw new TypeError("End time must be set to a number.");l=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"text",M({},x,{get:function(){return h},set:function(E){h=""+E,this.hasBeenReset=!0}})),Object.defineProperty(L,"region",M({},x,{get:function(){return _},set:function(E){_=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"vertical",M({},x,{get:function(){return f},set:function(E){var v=B(E);if(v===!1)throw new SyntaxError("An invalid or illegal string was specified.");f=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"snapToLines",M({},x,{get:function(){return b},set:function(E){b=!!E,this.hasBeenReset=!0}})),Object.defineProperty(L,"line",M({},x,{get:function(){return R},set:function(E){if(typeof E!="number"&&E!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");R=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"lineAlign",M({},x,{get:function(){return T},set:function(E){var v=N(E);if(!v)throw new SyntaxError("An invalid or illegal string was specified.");T=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"position",M({},x,{get:function(){return g},set:function(E){if(E<0||E>100)throw new Error("Position must be between 0 and 100.");g=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"positionAlign",M({},x,{get:function(){return c},set:function(E){var v=N(E);if(!v)throw new SyntaxError("An invalid or illegal string was specified.");c=v,this.hasBeenReset=!0}})),Object.defineProperty(L,"size",M({},x,{get:function(){return u},set:function(E){if(E<0||E>100)throw new Error("Size must be between 0 and 100.");u=E,this.hasBeenReset=!0}})),Object.defineProperty(L,"align",M({},x,{get:function(){return o},set:function(E){var v=N(E);if(!v)throw new SyntaxError("An invalid or illegal string was specified.");o=v,this.hasBeenReset=!0}})),L.displayState=void 0}return k.prototype.getCueAsHTML=function(){var p=self.WebVTT;return p.convertCueToDOMTree(self,this.text)},k}()},"./src/utils/vttparser.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"parseTimeStamp",function(){return w}),D.d(Y,"fixLineBreaks",function(){return y}),D.d(Y,"VTTParser",function(){return P});var V=D("./src/utils/vttcue.ts"),I=function(){function L(){}var x=L.prototype;return x.decode=function(d,a){if(!d)return"";if(typeof d!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(d))},L}();function w(L){function x(d,a,l,h){return(d|0)*3600+(a|0)*60+(l|0)+parseFloat(h||0)}var S=L.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return S?parseFloat(S[2])>59?x(S[2],S[3],0,S[4]):x(S[1],S[2],S[3],S[4]):null}var B=function(){function L(){this.values=Object.create(null)}var x=L.prototype;return x.set=function(d,a){!this.get(d)&&a!==""&&(this.values[d]=a)},x.get=function(d,a,l){return l?this.has(d)?this.values[d]:a[l]:this.has(d)?this.values[d]:a},x.has=function(d){return d in this.values},x.alt=function(d,a,l){for(var h=0;h<l.length;++h)if(a===l[h]){this.set(d,a);break}},x.integer=function(d,a){/^-?\d+$/.test(a)&&this.set(d,parseInt(a,10))},x.percent=function(d,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var l=parseFloat(a);if(l>=0&&l<=100)return this.set(d,l),!0}return!1},L}();function N(L,x,S,d){var a=d?L.split(d):[L];for(var l in a){if(typeof a[l]!="string")continue;var h=a[l].split(S);if(h.length!==2)continue;var _=h[0],f=h[1];x(_,f)}}var M=new V.default(0,0,""),k=M.align==="middle"?"middle":"center";function p(L,x,S){var d=L;function a(){var _=w(L);if(_===null)throw new Error("Malformed timestamp: "+d);return L=L.replace(/^[^\sa-zA-Z-]+/,""),_}function l(_,f){var b=new B;N(_,function(g,c){var u;switch(g){case"region":for(var o=S.length-1;o>=0;o--)if(S[o].id===c){b.set(g,S[o].region);break}break;case"vertical":b.alt(g,c,["rl","lr"]);break;case"line":u=c.split(","),b.integer(g,u[0]),b.percent(g,u[0])&&b.set("snapToLines",!1),b.alt(g,u[0],["auto"]),u.length===2&&b.alt("lineAlign",u[1],["start",k,"end"]);break;case"position":u=c.split(","),b.percent(g,u[0]),u.length===2&&b.alt("positionAlign",u[1],["start",k,"end","line-left","line-right","auto"]);break;case"size":b.percent(g,c);break;case"align":b.alt(g,c,["start",k,"end","left","right"]);break}},/:/,/\s/),f.region=b.get("region",null),f.vertical=b.get("vertical","");var R=b.get("line","auto");R==="auto"&&M.line===-1&&(R=-1),f.line=R,f.lineAlign=b.get("lineAlign","start"),f.snapToLines=b.get("snapToLines",!0),f.size=b.get("size",100),f.align=b.get("align",k);var T=b.get("position","auto");T==="auto"&&M.position===50&&(T=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=T}function h(){L=L.replace(/^\s+/,"")}if(h(),x.startTime=a(),h(),L.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+d);L=L.substr(3),h(),x.endTime=a(),h(),l(L,x)}function y(L){return L.replace(/<br(?: \/)?>/gi,`
`)}var P=function(){function L(){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 x=L.prototype;return x.parse=function(d){var a=this;d&&(a.buffer+=a.decoder.decode(d,{stream:!0}));function l(){var T=a.buffer,g=0;for(T=y(T);g<T.length&&T[g]!=="\r"&&T[g]!==`
`;)++g;var c=T.substr(0,g);return T[g]==="\r"&&++g,T[g]===`
`&&++g,a.buffer=T.substr(g),c}function h(T){N(T,function(g,c){},/:/)}try{var _="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;_=l();var f=_.match(/^()?WEBVTT([ \t].*)?$/);if(!f||!f[0])throw new Error("Malformed WebVTT signature.");a.state="HEADER"}for(var b=!1;a.buffer;){if(!/\r\n|\n/.test(a.buffer))return this;b?b=!1:_=l();switch(a.state){case"HEADER":/:/.test(_)?h(_):_||(a.state="ID");continue;case"NOTE":_||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(_)){a.state="NOTE";break}if(!_)continue;if(a.cue=new V.default(0,0,""),a.state="CUE",_.indexOf("-->")===-1){a.cue.id=_;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{p(_,a.cue,a.regionList)}catch(T){a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var R=_.indexOf("-->")!==-1;if(!_||R&&(b=!0)){a.oncue&&a.cue&&a.oncue(a.cue),a.cue=null,a.state="ID";continue}if(a.cue===null)continue;a.cue.text&&(a.cue.text+=`
`),a.cue.text+=_}continue;case"BADCUE":_||(a.state="ID")}}}catch(T){a.state==="CUETEXT"&&a.cue&&a.oncue&&a.oncue(a.cue),a.cue=null,a.state=a.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},x.flush=function(){var d=this;try{if((d.cue||d.state==="HEADER")&&(d.buffer+=`
`,d.parse()),d.state==="INITIAL"||d.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(a){d.onparsingerror&&d.onparsingerror(a)}return d.onflush&&d.onflush(),this},L}()},"./src/utils/webvtt-parser.ts":function(ie,Y,D){"use strict";D.r(Y),D.d(Y,"generateCueId",function(){return P}),D.d(Y,"parseWebVTT",function(){return x});var V=D("./src/polyfills/number.ts"),I=D("./src/utils/vttparser.ts"),w=D("./src/demux/id3.ts"),B=D("./src/utils/timescale-conversion.ts"),N=D("./src/remux/mp4-remuxer.ts"),M=/\r\n|\n\r|\n|\r/g,k=function(d,a,l){return l===void 0&&(l=0),d.substr(l,a.length)===a},p=function(d){var a=parseInt(d.substr(-3)),l=parseInt(d.substr(-6,2)),h=parseInt(d.substr(-9,2)),_=d.length>9?parseInt(d.substr(0,d.indexOf(":"))):0;if(!Object(V.isFiniteNumber)(a)||!Object(V.isFiniteNumber)(l)||!Object(V.isFiniteNumber)(h)||!Object(V.isFiniteNumber)(_))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+d);return a+=1e3*l,a+=60*1e3*h,a+=60*60*1e3*_,a},y=function(d){for(var a=5381,l=d.length;l;)a=a*33^d.charCodeAt(--l);return(a>>>0).toString()};function P(S,d,a){return y(S.toString())+y(d.toString())+y(a)}var L=function(d,a,l){var h=d[a],_=d[h.prevCC];if(!_||!_.new&&h.new){d.ccOffset=d.presentationOffset=h.start,h.new=!1;return}for(;(f=_)!==null&&f!==void 0&&f.new;){var f;d.ccOffset+=h.start-_.start,h.new=!1,h=_,_=d[h.prevCC]}d.presentationOffset=l};function x(S,d,a,l,h,_,f,b){var R=new I.VTTParser,T=Object(w.utf8ArrayToStr)(new Uint8Array(S)).trim().replace(M,`
`).split(`
`),g=[],c=Object(B.toMpegTsClockFromTimescale)(d,a),u="00:00.000",o=0,C=0,E,v=!0,O=!1;R.oncue=function(j){var G=l[h],J=l.ccOffset,K=(o-c)/9e4;if(G!=null&&G.new&&(C!==void 0?J=l.ccOffset=G.start:L(l,h,K)),K&&(J=K-l.presentationOffset),O){var F=j.endTime-j.startTime,ee=Object(N.normalizePts)((j.startTime+J-C)*9e4,_*9e4)/9e4;j.startTime=ee,j.endTime=ee+F}var oe=j.text.trim();j.text=decodeURIComponent(encodeURIComponent(oe)),j.id||(j.id=P(j.startTime,j.endTime,oe)),j.endTime>0&&g.push(j)},R.onparsingerror=function(j){E=j},R.onflush=function(){if(E){b(E);return}f(g)},T.forEach(function(j){if(v)if(k(j,"X-TIMESTAMP-MAP=")){v=!1,O=!0,j.substr(16).split(",").forEach(function(G){k(G,"LOCAL:")?u=G.substr(6):k(G,"MPEGTS:")&&(o=parseInt(G.substr(7)))});try{C=p(u)/1e3}catch(G){O=!1,E=G}return}else j===""&&(v=!1);R.parse(j+`
`)}),R.flush()}},"./src/utils/xhr-loader.ts":function(ie,Y,D){"use strict";D.r(Y);var V=D("./src/utils/logger.ts"),I=D("./src/loader/load-stats.ts"),w=/^age:\s*[\d.]+\s*$/m,B=function(){function N(k){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=k?k.xhrSetup:null,this.stats=new I.LoadStats,this.retryDelay=0}var M=N.prototype;return M.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},M.abortInternal=function(){var p=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),p&&(p.onreadystatechange=null,p.onprogress=null,p.readyState!==4&&(this.stats.aborted=!0,p.abort()))},M.abort=function(){var p;this.abortInternal(),(p=this.callbacks)!==null&&p!==void 0&&p.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},M.load=function(p,y,P){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=p,this.config=y,this.callbacks=P,this.retryDelay=y.retryDelay,this.loadInternal()},M.loadInternal=function(){var p=this.config,y=this.context;if(!p)return;var P=this.loader=new self.XMLHttpRequest,L=this.stats;L.loading.first=0,L.loaded=0;var x=this.xhrSetup;try{if(x)try{x(P,y.url)}catch(a){P.open("GET",y.url,!0),x(P,y.url)}P.readyState||P.open("GET",y.url,!0);var S=this.context.headers;if(S)for(var d in S)P.setRequestHeader(d,S[d])}catch(a){this.callbacks.onError({code:P.status,text:a.message},y,P);return}y.rangeEnd&&P.setRequestHeader("Range","bytes="+y.rangeStart+"-"+(y.rangeEnd-1)),P.onreadystatechange=this.readystatechange.bind(this),P.onprogress=this.loadprogress.bind(this),P.responseType=y.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),p.timeout),P.send()},M.readystatechange=function(){var p=this.context,y=this.loader,P=this.stats;if(!p||!y)return;var L=y.readyState,x=this.config;if(P.aborted)return;if(L>=2)if(self.clearTimeout(this.requestTimeout),P.loading.first===0&&(P.loading.first=Math.max(self.performance.now(),P.loading.start)),L===4){y.onreadystatechange=null,y.onprogress=null;var S=y.status;if(S>=200&&S<300){P.loading.end=Math.max(self.performance.now(),P.loading.first);var d,a;if(p.responseType==="arraybuffer"?(d=y.response,a=d.byteLength):(d=y.responseText,a=d.length),P.loaded=P.total=a,!this.callbacks)return;var l=this.callbacks.onProgress;if(l&&l(P,p,d,y),!this.callbacks)return;var h={url:y.responseURL,data:d};this.callbacks.onSuccess(h,P,p,y)}else P.retry>=x.maxRetry||S>=400&&S<499?(V.logger.error(S+" while loading "+p.url),this.callbacks.onError({code:S,text:y.statusText},p,y)):(V.logger.warn(S+" while loading "+p.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,x.maxRetryDelay),P.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),x.timeout)},M.loadtimeout=function(){V.logger.warn("timeout while loading "+this.context.url);var p=this.callbacks;p&&(this.abortInternal(),p.onTimeout(this.stats,this.context,this.loader))},M.loadprogress=function(p){var y=this.stats;y.loaded=p.loaded,p.lengthComputable&&(y.total=p.total)},M.getCacheAge=function(){var p=null;if(this.loader&&w.test(this.loader.getAllResponseHeaders())){var y=this.loader.getResponseHeader("age");p=y?parseFloat(y):null}return p},N}();Y.default=B}}).default})},vHTk:function(ht,ot,re){ht.exports={wrp:"wrp___z2l1F",bgBlack:"bgBlack___3ezfX",monaco:"monaco___1ypjT",darkBlue:"darkBlue___2ViJc",close:"close___3q-z4",embed:"embed___3dQqc"}},wU8J:function(ht,ot){function re(){this.buffer=new Array,this.length=0}re.prototype={get:function(ie){var Y=Math.floor(ie/8);return(this.buffer[Y]>>>7-ie%8&1)==1},put:function(ie,Y){for(var D=0;D<Y;D++)this.putBit((ie>>>Y-D-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(ie){var Y=Math.floor(this.length/8);this.buffer.length<=Y&&this.buffer.push(0),ie&&(this.buffer[Y]|=128>>>this.length%8),this.length++}},ht.exports=re}}]);